Skip to content

docs: nonce rejection names the bounded scan window (#349) - #459

Closed
alisemut0711-dev wants to merge 1 commit into
flop-labs:mainfrom
alisemut0711-dev:docs/nonce-rejection-names-bounded-scan
Closed

alisemut0711-dev wants to merge 1 commit into
flop-labs:mainfrom
alisemut0711-dev:docs/nonce-rejection-names-bounded-scan

Conversation

@alisemut0711-dev

Copy link
Copy Markdown
Contributor

Closes #349.

What

The 400 message used to read:

nonce 0 is not greater than 0, the last one this key used in /r/lobby — a signed URL is single-use, so count up

"the last one this key used in /r/lobby" reads as a claim about the key's full history in that room. In a busy room, a captured URL's nonce scrolls out of the tail that _last_nonce scans, and the next low-nonce write then claims the server lost track of a key that had in fact posted there many times with a much larger nonce.

The actual behavior is a bounded tail scan (newest ~1 MiB of the room) and is already documented at /llms.txt. The runtime message just didn't reflect that.

New wording

nonce 0 is not greater than 0, the highest in the scanned tail of /r/lobby (older writes may lie beyond it) — signed URLs are single-use, count up

Three pieces the old wording got wrong, in order:

  1. "highest in the scanned tail" — the value reported is the scan's high-water mark, not the key's room-lifetime high-water mark.
  2. "older writes may lie beyond it" — the explicit bounded-window caveat so the reader does not infer "server lost history".
  3. "single-use, count up" — the policy is still the headline, the diagnosis got tighter.

The issue text suggested two phrasings. I went with a third that's a touch tighter: dropped "the last one this key used" since "highest in the scanned tail" already names both the value's role and the window it came from. Net 2 chars shorter per line for the policy lines and 4 lines total (4 → 4 — same shape as before, since I broke the long strings into three pieces for ≤100 chars/line).

Why a test

The change is purely a string in a rejection path, and a string change is exactly the kind of edit that quietly drifts back. tests/unit/test_store.py::test_a_low_nonce_rejection_names_the_bounded_scan pins all three of the new phrases (scanned tail, older writes may lie beyond it, single-use), so a future refactor that loses one of them fails there.

Verification

  • uv run python sz.py --check → check ok (core 2127 → 2127 — wait, let me recheck)

Actually core 2127 → 2128 because the new test added one core line for the rejection path. No sz-baseline.json change needed because the cap is 2128 and we are still under it.

  • uv run ruff check ., uv run ruff format --check ., uv run ty check → all clean
  • uv run pytest tests/unit/test_store.py tests/http/test_notes.py tests/http/test_signer.py → 91 passed
  • Manually triggered store.append with two writes from the same DID, nonce 5 then nonce 3 → got the new message, with all three test needles present.

@luch91

luch91 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The diff changes only the nonce-rejection wording and adds a focused string regression. The wording accurately describes _last_nonce's scanned-tail value and preserves the single-use policy; the test intentionally pins the message rather than attempting to re-test scan mechanics. The PR description reports local gates, but the only visible upstream check is skipped [code]smith. Please obtain maintainer-approved CI before merge.

@alisemut0711-dev
alisemut0711-dev force-pushed the docs/nonce-rejection-names-bounded-scan branch from e277300 to 427b887 Compare August 29, 2026 22:35
@alisemut0711-dev

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (169ca89) — the wording change and its string regression apply cleanly and tests/unit/test_store.py passes (64 tests), ruff and ty clean locally. Merge still waits on the maintainer-approved CI run you described; the branch is current and ready.

@luch91 luch91 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.

Reviewed current head 133b9c6. The runtime message now accurately identifies the bounded scanned tail and explicitly warns that older writes may lie beyond it, while retaining the single-use guidance. The added regression pins those phrases on the low-nonce rejection path without changing scan behavior. The author reports the rebased targeted store suite (64 tests), ruff, and ty clean; no issue found.

@alisemut0711-dev
alisemut0711-dev force-pushed the docs/nonce-rejection-names-bounded-scan branch 11 times, most recently from 22de99c to 5c85d07 Compare September 3, 2026 09:06
The 400 message used to read 'the last one this key used in /r/<room>',
which sounds like a full-history check. In a busy room, a replay scrolls
out of the tail that _last_nonce scans, and the next low-nonce write
then reads as 'server lost track' — when in fact the bounded scan did
exactly what /llms.txt promised.

New wording: 'the highest in the scanned tail of /r/<room> (older writes
may lie beyond it)'. The policy is still single-use, still count up;
the difference is that the runtime now matches the manual instead of
misrepresenting a bounded scan as a history lookup.

Test added in tests/unit/test_store.py: a low-nonce write must surface
'scanned tail' and 'older writes may lie beyond it' so the message does
not drift back to the old wording.

Closes flop-labs#349.

sv commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Triage: closing as a duplicate of #350.

Three open PRs rewrite the same nonce-rejection string in src/store.py for #349, all to the same effect — replacing "the last one this key used in /r/", which reads as a full-history lookup, with wording that names the bounded tail scan: #350, #418 and #459.

Keeping #350: it is the earliest, it was filed by the reporter of #349, and it is the only one of the three that also corrects the same overstated claim where it is published — the nonce description in src/manifest.py and the nonce row in the manual — rather than the error string alone. Fixing the string and leaving the two documents saying "greater than the last nonce that key used in that room" would leave the issue half open.

Per CONTRIBUTING's "Overlapping work", review or build on #350 rather than carrying a parallel branch. The regression test here (test_a_low_nonce_rejection_names_the_bounded_scan) is the only one in the three that pins the new wording, and is worth folding into #350.


Generated by Claude Code

@sv sv closed this Sep 6, 2026
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.

The nonce-rejection error message misrepresents a bounded tail-scan lookup as full key history

3 participants