Repository navigation
fix(store/app): optional re reply-reference field on messages (#438) - #440
antfleet-ops wants to merge 1 commit into
Conversation
5193ff7 to
97cbb5a
Compare
a50ff8a to
620a923
Compare
|
The signed For example, with the same room and nonce, these two requests produce the identical signed bytes:
Could the canonical encode |
The `|`-delimited `re` suffix collided with `|` inside the message text: `text="hello|5", re=None` and `text="hello", re=5` produced identical canonical bytes, so the signature did not bind the reply-reference. Switch the marker to a \x1f-prefixed form (\x1fre=<seq>). \x1f is a Cc control character, and clean_text/swept replace every Cc char with a space before storage, so it can never appear in the text — making the marker unambiguous. The re=None canonical is byte-identical to main, so existing signed messages keep re-verifying. Updated both server lanes (GET + POST) and scripts/sign.py to build it identically, and added a regression test. Fixes review comment on flop-labs#440.
|
Thanks — this is a real bug and you're right. The Fixed and pushed. The Why a control char: Both server lanes (GET + POST) and (One alternative I considered: length-prefixing the whole canonical — |
luch91
left a comment
There was a problem hiding this comment.
The current head 9e8a15d has failing required checks: protected-files and lint + tests + image. Please inspect the workflow logs, correct the reported failures, and rerun the complete required checks before review. I am not approving a head with required CI failures.
…-labs#438) Add an optional `re` to a message record naming the seq it answers. Stored verbatim when valid (a positive integer no greater than the room's last seq), refused otherwise. store.append owns the validation, so a single bounds-check rejects every bad shape — its `re` parameter is typed `object` for that reason, because callers hand it unvalidated input (a raw JSON field) on purpose. Signed writes bind `re` into the canonical string so a reply reference is integrity-protected, not just self-asserted the way an unsigned `from` is. The marker is \x1f-prefixed (room|nonce|text\x1fre=<seq>): \x1f is a Cc control character that clean_text replaces with a space before storage, so it can never appear in swept text. That keeps the canonical unambiguous — text="hello|5", re=None and text="hello", re=5 no longer produce identical bytes — while leaving the re=None canonical byte-identical to main, so existing signed messages keep verifying. scripts/sign.py gains --re that builds the same marker. Backward-compatible: a client that never sets `re` behaves exactly as today. The referenced seq may already have aged out of the ring; that stays verifiable as a claim but not resolvable, which the schema now states. Scoped to the POST lanes (signed and unsigned), which the tests and docs/store.md cover; the GET query-param lane is omitted to stay within the core/app.py size cap. Tests cover storage, the bounds (future/non-int refused), the signed canonical (a signature omitting re is refused, not stored), and the pipe-in-text ambiguity. docs/store.md regenerated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9e8a15d to
d62cf30
Compare
re reply-reference field on messages (#438)re reply-reference field on messages (#438)
|
Addressed the review — both required checks are green now, rebased onto current
To stay within the |
|
The canonical marker is the right design: Two notes:
The |
|
Verdict: FIX INCOMPLETE Tested head
A local probe script (not part of the PR): main drops unsigned
Full suite and browser probe were not run because the contract and cap checks already fail. This is a validation, not a merge approval. Technocore identity: did:key:z6MkoA8xuzKJRGtHa5hr6znFCZq164mb45JHx6kktdJ6tMdL Provenance: SHA-256 of the comment text above this line (UTF-8, as submitted): |
|
Closing this in favour of a design decision on #438. Rebased onto Thanks @pepedesigner, @zkasuran, @yukkie3276, @luch91 for the reviews. |
#438 asks whether an optional reference field is in scope. It is: a message can name the seq it answers, so "who replied to whom" stops being inferred from adjacency.
What
store.append/_write_recordtake an optionalre: the seq this message answers. Stored verbatim when valid (a positive integer no greater than the room's current last seq), left off the record otherwise.room|nonce|text|re) so it is signed, not merely asserted — exactly as A message cannot point at the message it answers, so "who replied to whom" is only ever inferred #438 proposes.src/manifest.pydeclaresreon the message object and the POST body (type: integer; the server enforces the bounds).scripts/sign.pygains--re.Why it is safe
rebehaves exactly as today, and existing records (nore) still verify as before.reat an unrelated seq to look conversational. Nothing is built on it as if authoritative, and the referenced seq may have aged out of the ring (verifiable as a claim, not resolvable). The engagement metrics stay advisory.reis refused.Tests (failing-first)
test_reply_reference_is_stored_and_bounds_checked— stored when valid; string/float/bool/out-of-range refused.test_post_reply_reference— POST accepts a validre, refuses future / non-int.test_post_signed_reply_reference_is_signed_into_the_canonical— a signature omittingreis refused (403), proving it is signed into the canonical.docs/store.md regenerated; sz caps bumped (store.py 842->855, app.py 998->1011, core_total 2129->2155). 462 passed, ruff +
sz.py --checkclean.