Skip to content

test(store): assert stamped receipt cannot be overwritten in append-only store - #58

Merged
kikashy merged 1 commit into
Judgment-Pack:mainfrom
snowyukitty:test/store-refuse-overwrite
Aug 18, 2026
Merged

kikashy merged 1 commit into
Judgment-Pack:mainfrom
snowyukitty:test/store-refuse-overwrite

Conversation

@snowyukitty

@snowyukitty snowyukitty commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Adds regression coverage in go/teeth_test.go for the receipt store's append-only guarantees.

Coverage

  • Builds the store with the shared test fixture and stamps production-shape receipt cores.
  • Confirms a distinct duplicate at the same callIndex is refused and the original receipt bytes remain unchanged.
  • Confirms the refused write leaves only 0.json in the session directory, with no temporary or partial file.
  • Confirms the next callIndex still succeeds and chains to the first receipt's signature.
  • Confirms a direct exclusive write to an existing receipt is refused without altering its contents.

Testing

  • gofmt -l .
  • go vet ./...
  • go test ./...
  • go build -trimpath
  • gateway conform — 30 canonicalization vectors, 19 store vectors, 0 disagreements

Closes #55

@kikashy kikashy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for taking #55 — the heart of this is right. Reviewed and verified locally on your branch merged onto current main. Before the detail: the property you set out to pin is pinned. I broke the append-only path five ways — stamp writing non-exclusively, exclusive-write silently overwriting, the store damaging the existing file before returning its refusal, a duplicate stamp succeeding as a silent no-op, and the refusal message changing — and your test caught every one.

Four required changes:

  1. DCO. Your commit has no Signed-off-by trailer, and the DCO check fails on it. Amend and force-push: git commit --amend -s --no-edit then git push -f.

  2. gofmt. The ubuntu CI leg fails because teeth_test.go ends with a trailing blank line; cd go && gofmt -w teeth_test.go fixes it.

  3. #55's third checkbox is missing, and it is provably the load-bearing one. Nothing in the test enumerates the session directory — it only ever reads the one path it wrote. I deleted store.go's temp-file cleanup so every write leaks a .tmp scratch file next to the receipt, and neither your test nor the entire existing suite noticed. Asserting the directory holds exactly one entry after the refusal is the assertion that catches it.

  4. #55's fourth checkbox is missing. The test never stamps a second callIndex, so it cannot show the refusal is about the collision rather than the session. I made the receipt filename ignore the index entirely — every call in a session colliding with the first — and your test passed. A stamp at the next index, asserted to succeed, pins it.

Two smaller asks, per the issue's scope text: build the store with the existing testStore(t) helper instead of hand-assembling paths, and stamp a production-shape core — the current one carries argumentsCommitment, which appears nowhere in SPEC.md, and omits receiptVersion, prevSignature, servedAt, and authority, which every receipt the gateway actually stamps carries.

None of this changes the verdict on your approach: the exclusive-link refusal, the byte-comparison of the surviving receipt, and driving the unexported layer directly are all sound instincts for this file. Fix the four, and consider the two, and this merges.

@snowyukitty
snowyukitty force-pushed the test/store-refuse-overwrite branch from b8fc4a9 to 2531f41 Compare August 17, 2026 21:31
@snowyukitty

Copy link
Copy Markdown
Contributor Author

Thanks @kikashy for the review and the detailed feedback on each edge case.

Head 2531f41 addresses all four required points and both scope suggestions:

  1. DCO: Signed-off-by trailer added and DCO check is now passing.
  2. gofmt: File formatted cleanly with gofmt -w.
  3. Session directory enumeration: Added directory inspection asserting exactly one file (

@kikashy

kikashy commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Re-verified locally on your amended branch merged onto current main, the same way as round 1.

All six points landed, and the two that mattered most now demonstrably bite:

  • The four required checks pass — gofmt clean, vet clean, full suite green, gateway conform 30 canon / 19 store vectors, 0 disagreements — and CI is green on all three platforms with the DCO check passing.
  • I re-ran the round-1 break set. The five your first version already caught still fail correctly. The two that previously survived are now caught by exactly the assertions you added: deleting the store's temp-file cleanup now fails at your directory enumeration — the failure message literally prints the two leaked .tmp files next to 0.json — and dropping the index from the receipt filename now fails at your next-callIndex stamp. In round 1, the first of those two survived the entire repository suite; your test is now the only thing in the tree that holds it.
  • The rewritten receipt core carries the nine caller-supplied members SPEC.md requires, argumentsCommitment is gone, and a semantically identical rewrite of the exclusive-write branch correctly does not trip the test — it pins behavior, not source shape.

Merging. For a first contribution to this repository, closing a gap the whole suite had is a strong place to start. Thank you.

@kikashy kikashy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-verified in full — all six review points addressed; details in the comment above.

@kikashy
kikashy merged commit db8cd8e into Judgment-Pack:main Aug 18, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution to Judgment Pack!

If you’d like another task, choose a path that interests you:

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.

Assert a stamped receipt cannot be overwritten

2 participants