Skip to content

v0.3.1 compliant, non-accept after challenge, duplicate before continue#18

Merged
markmnl merged 2 commits intomainfrom
revisions
Apr 17, 2026
Merged

v0.3.1 compliant, non-accept after challenge, duplicate before continue#18
markmnl merged 2 commits intomainfrom
revisions

Conversation

@markmnl
Copy link
Copy Markdown
Owner

@markmnl markmnl commented Apr 17, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates host-side protocol flow to better align with the v0.3.1 spec by moving some response decisions out of downloadMessage and into the initial-accept phase in handleConn.

Changes:

  • Refactors add-to handling so handleAddToPath sets InitialResponseCode and defers sending/storing to handleConn.
  • Removes the post-accept global-duplicate response path and introduces a pre-continue duplicate check in handleConn.
  • Updates spec text and header field comment to include accept code 11 in InitialResponseCode.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/host.go Moves add-to response/send/store into handleConn; removes respondGlobalDuplicateIfNeeded; adds duplicate check before sending code 64.
src/host_test.go Removes unit test for respondGlobalDuplicateIfNeeded.
src/defs.go Updates InitialResponseCode comment to include code 11.
SPEC.md Reworks receiving flow description and minor formatting tweaks.

Comment thread src/host.go
Comment thread src/host_test.go
@@ -510,29 +510,3 @@ func TestReadAttachmentHeadersRejectsReservedAttachmentBits(t *testing.T) {
t.Fatalf("expected reject code %d, got %v", RejectCodeInvalid, got)
}
}
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the only unit test that exercised the global duplicate response behavior, but does not add coverage for the new behavior (duplicate check now happening in handleConn before sending the initial accept code). Please add/adjust tests to cover at least:

  • global duplicate rejection is sent as the initial response (code 10) when all local recipients already have the challenged message hash
  • this holds for both the continue (64) and skip-data (65) paths, if those flows are intended to support global-duplicate rejection.
Suggested change
}
}
func TestHandleConnRejectsGlobalDuplicateAsInitialResponseOnContinuePath(t *testing.T) {
runHandleConnGlobalDuplicateInitialResponseTest(t, 64)
}
func TestHandleConnRejectsGlobalDuplicateAsInitialResponseOnSkipDataPath(t *testing.T) {
runHandleConnGlobalDuplicateInitialResponseTest(t, 65)
}
func runHandleConnGlobalDuplicateInitialResponseTest(t *testing.T, expectedPath byte) {
t.Helper()
host, conn, done := newHandleConnTestHarness(t)
t.Cleanup(func() {
conn.Close()
<-done
})
req := newChallengedMessageRequest(t)
seedAllLocalRecipientsWithChallengedHash(t, host, req)
go handleConn(conn)
writeHandleConnRequest(t, conn, req, expectedPath)
got := readHandleConnResponseCode(t, conn)
if got != 10 {
t.Fatalf("expected initial global duplicate reject code 10 on path %d, got %d", expectedPath, got)
}
}

Copilot uses AI. Check for mistakes.
@markmnl markmnl merged commit 7616d66 into main Apr 17, 2026
2 checks passed
@markmnl markmnl deleted the revisions branch April 17, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants