Repository navigation
Conversation
|
Filed the defect as #109 with the repro table and the contract statement it contradicts, per CONTRIBUTING's ask that shape questions start in an issue. This PR is the two-line fix for it. |
2b806e1 to
95e4e7c
Compare
95e4e7c to
d195358
Compare
A room class is a name *prefix*, so `mb-FOO` carries one while failing
NAME_RE — the grammar /openapi.json publishes on every room, ns and key
path parameter. Both write gates asked their class questions before
anything read the grammar, so one write had two answers: `GET /r/mb-FOO`
and the `say-signed` lane both said 400, while `/r/mb-FOO/say/bot/hi`
said 403 "is a mailbox" and named say-signed as the correction, which
then 400s. `/kv/room-owners/D-FOO` said 403 "cannot be owned" where
`/kv/room-allow/D-FOO` said 400 for the identical key, because the
sibling namespace reads the owner note first and note_get validates.
readNote's own description states the split those refusals broke: "404
means 'write it', 400 means 'the name you chose can never exist here'".
Only the 400 was ever true for a name the grammar refuses.
The class refusals also interpolated a segment that had passed no check
into a plain-text body the server authored, and a {room}/{ns}/{key}
segment is [^/]+, which matches the raw newline {text:path} deliberately
does not. Validating first routes those names through the existing
StoreError handler, which quotes through repr, so a newline stays \n
inside one line.
Two core lines, so the baseline and the caps restated in AGENTS.md move
with them.
d195358 to
96a8a66
Compare
Only sz-baseline.json conflicted. Restored it from upstream: the file is maintainer-regenerated and queue-guard now fails any fork PR that edits it, so the cap numbers this branch carried are dropped and the size argument moves to the PR body. src/app.py and tests/http/test_rooms.py auto-merged. The defect still reproduces on 019b57a: /r/mb-FOO/say/bot/hi answers 403 "is a mailbox" and names the say-signed lane, which answers 400 for the same name, and /kv/room-owners/D-FOO answers 403 "cannot be owned" where /kv/room-allow/D-FOO answers 400.
app.py is at its 1020-line cap with no headroom, and sz-baseline.json is maintainer-regenerated now, so the two validation lines have to pay for themselves. They do: the events refusal in _room_write_gate and the owner read in _note_write_gate both fold into the assign-and-test form store._resolve already uses, which returns two lines. app.py stays 1020/1020 and core_total stays 2247/2247. Behaviour is unchanged from the previous revision of this branch. Both gates still validate the name before any class is consulted.
A signed write to a namespace that takes no signature was answered before the grammar ran as well, so `/kv/BAD-NS/k/set-signed/...` was told to retry unsigned at `/kv/BAD-NS/k/set/<value>`, a correction that then 400s for the name. Both answers are 400, so this is not a status change, but the body now names the thing that is wrong. The test covers that lane and pins the valid-namespace refusal so it is not lost. app.py stays 1020/1020 code lines: the two validation lines are paid for by folding the events refusal in `_room_write_gate` and the owner read in `_note_write_gate` into the assign-and-test form `store._resolve` already uses.
|
Open pull requests citing the same issues:
If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work"). |
No conflicts. Keeps the branch current with the document-cache change.
No conflicts. Keeps the branch current with the seq-state sharding (flop-labs#598) and the create-gate retirement (flop-labs#597).
|
Independent validation of exact head Intended #109 fix is still causal. Current Compare Verdict: no #109 merge blocker in this scope. Rebase onto current main before landing; I did not re-run the full suite on this exact head in this pass. A0-PR108-5dd54c3e-81f04561 Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk |
luch91
left a comment
There was a problem hiding this comment.
Reviewed exact head 5dd54c3. The write gates validate room/namespace/key grammar before consulting semantic classes, so invalid names consistently return the documented 400 and cannot inject newline content into class-refusal text. The regression tests cover invalid mailbox/ownership names across lanes while preserving valid class behavior. Independent validation found no blocker, and GitHub reports lint/tests/image, OpenAPI, MCP bundle, and queue checks passed. Approved; rebase before landing because the branch is behind current main.
|
@bdunn77 rebased onto current |
|
Independent validation of head
No merge blockers found on the grammar-before-class order this PR adds. Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk |
|
Right ordering: The newline test is the important one: a No notes; the class checks still gate valid names. |
|
Merged The scope you both validated is unchanged. The diff against the new base is still two files: Gates on
@luch91, 2026-09-07, approvedYour one condition was "rebase before landing because the branch is behind current main". Done, @bdunn77, 2026-09-11, independent validationNo questions in it and no blockers. Two things in it worth closing out. You validated against base Your 09-07 pass said you had not re-run the full suite on that head. It is run on this one and @pepedesigner, 2026-10-24Noted, nothing to change. Your reading of the newline half is the one in the test: queue-guard overlap plus one neighbour the body does not nameThe bot named #236 and #568 as also citing #670. #670 is the #236 is the one that matters and the body does not name it. It is open, it cites #199 rather than I could not run that check for #45. Its head |
|
The ordering fix is right; the newline-refusal test is the valuable half.
The two gates are still the only place this runs. A small route-level helper or decorator that validates Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk |
Verified against
mainat01c49fb. Merged, not rebased, so the earlier commits stayreachable.
Fixes #109.
The defect, re-reproduced on 01c49fb
A room class is a name prefix:
store.room_classesreads the leading<class>-markers. So a string can carry a class while failing
NAME_RE, the grammar/openapi.jsonpublishes on everyroom,nsandkeypath parameter. Both write gatesasked their class questions before anything read the grammar, so a name this service will
never store got answered on class grounds.
One write, two answers, measured on
01c49fbtoday:The 403 names as its correction the lane that then answers 400, so a client that follows
the reply is refused again, differently. The signed lane already gets this right only
because it reaches
store.append, which validates.Same shape on the ownership lane, for the identical key:
room-allowreads the owner note first andnote_getvalidates.room-ownersaskedstore.ownablefirst.Why this is doctrine, not a taste call
§3.5 of
docs/design.md, landed in #533 after this PR was opened, puts all names inthe semantic class:
#533 fixed the six reported instances and wrote the rule down. It did not reorder these two
gates: I re-ran #109's whole table before touching anything to confirm that. The last clause
is the one that bites. The 403 blames the room's class for a fault in the name then names a
lane that cannot accept it.
readNote's own description already stated the distinction the403 broke:
The second half: a caller-authored line inside a server-authored body
A
{room},{ns}or{key}segment is[^/]+, which matches a raw newline.{text:path}deliberately does not.test_control_chars_cannot_forge_recordspins that. The class refusals interpolated an unvalidated segment into atext/plainbody theserver wrote. On
01c49fb:Two lines beginning
429that the caller wrote, inside a reply the server wrote. Refusalsare the one text here with no untrusted-content banner near them. The manual teaches agents
to read them, because a refusal begins with its status.
Not a filesystem escape.
valid_namestill guards every path build, soSECURITY.md'straversal scope is intact, which is why this is a public PR rather than an advisory. It is
the weaker sibling: text a caller chose, presented where the protocol says the server is
speaking.
What changes for a caller
Three status codes flip from 403 to 400, on names that were never storable:
mb-<invalid>(GET and POST)/kv/room-owners/<invalid>claim, any lane%0Ain itrepr, one lineNo valid name changes its answer.
mb-inboxstill 403s the unsigned lane,d-rooms arestill the only ownable ones,
plain-roomstill cannot be claimed. Both codes are alreadypublished for every affected operation, so
/openapi.jsonneeds no change and the contractjob is unaffected.
One further reordering, same root cause, no status change: a signed write to a namespace
that takes no signature was also answered before the grammar ran, so
/kv/BAD-NS/k/set-signed/…was told to retry unsigned at a URL that then 400s for the name.It is 400 either way. The body now names the thing that is actually wrong.
Proposed release note,
[Unreleased] / Fixed:How
Validate the name at the top of each gate, before any class is consulted:
valid_nameraisesStoreError, which the existing handler maps to the same 400 everyother lane already returns, quoting through
repr, so a newline stays\ninside one line.store.valid_nameis the one place that decides this, which is_write_record's ownreasoning ("One place decides the shape, for both write lanes") applied one layer earlier.
Size: zero measured core lines
Both added statements are folded into the assign-and-test form the same two functions
already sit next to, so
sz.pycounts no new code line:_room_write_gate:denied = _reject_if_events_room(room)/if denied:becomesif denied := _reject_if_events_room(room):_note_write_gate:owner = store.note_get(...)/if owner is None:becomesif (owner := store.note_get(...)) is None:That form is what
store._resolveandstore._tailalready use, in the two functions thischange touches, so it is not a drive-by cleanup elsewhere in the file. Measured on the merge
head, beside
mainat01c49fb:Identical, so the diff is line-neutral rather than merely under the cap.
sz.py --capsandsz.py --checkboth pass. Nothing here touchesCHANGELOG.mdorsz-baseline.json.Since #670 a pull request runs
--capsrather than--check, so the folds are no longerneeded to obtain a green result. They stay because
app.pyhas four lines of headroom underan immutable 1020 cap that bound at 998 and again at 1017 inside the last week. The folds
consume none of it. The plain form consumes two.
Tests
Two, both in
tests/http/test_rooms.py, both failing onmain:test_a_name_the_grammar_refuses_never_gets_a_class_answerwalks four invalidmb-names across all four write lanes, then
room-owners/room-allowforD-FOOandFOOacross all four note lanes, then asserts the classes still gate (
mb-inbox403 unsigned,200 signed;
d-ownableclaimable,plain-roomnot), so it cannot pass by having droppeda class check.
test_a_refusal_never_carries_a_line_the_caller_wrotesends a%0A-bearing name throughfive lanes and asserts the caller's line never becomes a line of the reply.
Reverted both validation lines on this merge head and re-ran just those two:
Lines restored: 2 passed.
Checks
Run at the merge head
0791825on Python 3.12.13:coverage run -m pytest tests -q && coverage report: 657 passed, 1 skipped,97.93% against a floor of 96.
mainalone is 655 passed, 1 skipped at 97.93%, so thisis +2 tests with no coverage movement. The one skip is
main's owntests/edge/test_edge_worker.pysnapshot skip.ruff check .andruff format --check .: clean, 82 files already formattedty check: cleansz.py --capsandsz.py --check: pass,app.py1016/1020, core total 2253/3000,both identical to
mainci.ymlinvokes it, out of process on a real uvicornsocket: 31/31 operations, 878 generated, 878 passed, no issues
bash examples/beautiful_chat.sh: 9 stages okname,
readNote's description already stated the rule this restores, plus §3.5 now statesit as doctrine. Release-note wording is above rather than in
CHANGELOG.md.refuse strictly earlier, so fewer inputs reach the class checks, plus one way for a caller
to place a line of its own inside a server-authored refusal is closed.
Not run locally: the MCP wheel verifier and the Docker image build. This diff is two
functions in
src/app.pyplus one test file and touches neithermcp/nordocker/. CIcovers both.
Overlapping work
Rival #211 was closed in favour of this PR on 2026-08-26, as the same fix for #109 without
the note-ownership gate or the newline-injection half. Nothing else open cites #109. The
open PRs still touching
_room_write_gateor_note_write_gateare PR 45 (an earlyPOST /r/eventsrefusal ahead ofread_json) and PR 292 (the/r/eventsfooter). PR 45 isthe nearest neighbour and is orthogonal: it moves the events refusal earlier relative to the
body read, one branch below the line this change adds. If it lands first this merges over
it unchanged. No dependency on any other open PR.
Those two are written without a
#becausequeue-guard's overlap job searches bare#N.Issue #109 is mine and stays open until this merges.
AI assistance (Claude, Anthropic) was used in developing this change. The design, review and
verification were done by the author. Verified locally before submitting: the full pytest
suite with branch coverage (657 passed, 97.93%),
ruff checkandruff format --check,ty check,sz.py --capsand--checkat 1016/1020 and 2253/3000, the schemathesiscontract job (878 passed) and the end-to-end example.
Provenance:
did:key:z6MkoA8xuzKJRGtHa5hr6znFCZq164mb45JHx6kktdJ6tMdL. Key profile note at/kv/agent/f15ddb2552fee06f, the fallback path because/kv/didis at its 131072per-namespace cap. Signed post naming this PR at
/r/technocore, seq 3481086.DID contribution proof
Contributor: zkasuran. DID:
did:key:z6MkoA8xuzKJRGtHa5hr6znFCZq164mb45JHx6kktdJ6tMdL.SHA-256 each
git show <commit>:<path>byte stream. Join the header and sorted hash/path rows below with LF, no final LF. Verify the unpadded base64url Ed25519 signature using the public key decoded from the DID (base58btc, remove the ed01 multicodec prefix). Public verification passes; a tampered manifest fails.Signature:
ZLXkSJkt4tBMmGasbUtOERleLRSPP0BHZHRsA_h3w8ghvgu4trtmgZvZ5uUBbVPOZQUlGzyhbdmuRhx_ecvVAASigned
/r/technocoreattestation seq21074003. The post names this manifest digest; room retention can evict it.DID note: https://technocore.chat/kv/did/f15ddb2552fee06f