Skip to content

Flag routes refuse a scoped caller before validating; scoped readers see no rule ids, labels or reply_from (BACKLOG #6638) - #3567

Merged
wshallwshall merged 10 commits into
mainfrom
b20056-6638
Dec 2, 2026
Merged

wshallwshall merged 10 commits into
mainfrom
b20056-6638

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Row: BACKLOG #6638. Changes a security control (scoped-caller authorization on flag routes; metadata withholding). Head f2ac5c1 (code 8d38a8b, doc f2ac5c1) on c3151df. Not rebased; docs/CONNECTIONS.md moved on main: check for a conflict.

Repair round fixed: (a) a scoped caller's non-JSON body with a +json type gave an unaudited 500, now the audited 403; (b) scoped readers get reply_from as null with reply_from_withheld=true; (c) the direction marker is written only when the body was read as JSON; (f) prose.

QA: Level xhigh. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings, fork a474066ac8d3853c1 round-0289fe51, review_tag.py exit 0. Rounds: 1 on this repair (final, unrepaired); earlier build rounds on c3151df.
Checks: ruff, four mypy legs; pytest 557 passed over flag/posture/metadata/field-authz/seam/request-model/doc-drift/console files; doc-drift rerun 69 passed; two seam-snapshot subprocess tests failed under xdist and passed alone (19 passed). Full suite not run.

Open findings:

  1. OWNER-ROUTE CANDIDATE (behaviour + audit): a scoped caller's correct request to its own inbound with no Content-Type or text/plain is refused 403 with an unmarked row, conflicting with SECURITY.md "a row without that marker was not refused for its direction".
  2. OWNER-ROUTE CANDIDATE (control parity): posture lists withheld reminder-silencing rules to a scoped reader by position and event type, with no alert_rules_withheld row.
  3. The gate copies FastAPI's private JSON test (strict_content_type=True); no test pins it.
  4. Other per-name routes answer a scoped caller's malformed name with an unaudited 422 (needs its own row).
  5. Scoped metadata withholds only reply_from; other free-text settings and an outbound's reingress_to still go out (outbound unreachable to scoped callers today).
  6. No test pins a shared pacing charge; 7. body parsed twice; 8. dead metadata_withheld branch; 9. marker rule stated in several places.

Refusals: form check at 07:10:13Z, split as printed (script written with Write, run as a plain command).

Manager d6318533 opened this for a subagent Builder. The Lander merges. Open findings are named here for filing under ledger ruling R2; any that changes behaviour or weakens a control is marked OWNER-ROUTE CANDIDATE for the Lander to classify.

…see no rule ids or labels

BACKLOG #6638 items 1 to 6.

- GET /security/posture labels a credential-reminder-silencing alert rule
  by its position alone for a channel-scoped reader (item 1), as
  GET /alerts/rules shows that reader no id.
- POST /connections/{name}/flag now reads its own body and runs the scope
  refusal on the raw name and direction before it validates either
  (item 2). BEHAVIOUR CHANGE: a channel-scoped caller's malformed request
  (a direction naming neither side, a body that is not JSON or is empty,
  a name failing the connection-name rule) was an unaudited 422; it is
  now the 403 and auth.channel_denied row any other out-of-scope target
  gets. An all-channels caller still gets the 422.
- The refusal is one function, _refuse_connection_flag, exposed to the
  console as CoreHandlers.refuse_connection_flag (item 4). The console's
  flag route calls it on the raw form before validating, takes its name
  unannotated and checks the name rule after (item 3), and no longer
  imports CONNECTION_DENIED_DETAIL. Seam digest regenerated with
  scripts/webconsole_seam_snapshot.py --write (4033184244d47e90 to
  649e40ac2b7f6902); SUPPORTED_ENGINE_SEAMS bumped to match.
- AlertRuleInfo gains id_withheld, so a null id no longer means both
  unlabelled and withheld (item 5).
- GET /connections/{name}/metadata withholds the metadata labels from a
  channel-scoped reader, with metadata_withheld true (item 6).

Verified-by: tests
…withheld ids and labels

BACKLOG #6638 items 1 to 7, doc limb.

- docs/SECURITY.md: the posture bullet no longer lists an alert rule's id
  as free text a scoped reader is shown; the flag paragraphs say both
  routes refuse a scoped caller before validating, and that a scoped
  reader's null rule id carries id_withheld.
- CHANGELOG.md and the web console CHANGELOG record the change. The
  console's 0.5.3 BACKLOG #3378 entry read "the handshake will not catch
  an older engine", which understated the protection (item 7, the merge
  review's comment); it is corrected in place, naming the old text.

BEHAVIOUR CHANGE (stated for the Lander's routing): a channel-scoped
caller's malformed POST /connections/{name}/flag now answers 403 and is
audited, where it answered an unaudited 422.

Not changed: item 7's three other nits (an app.py comment scope, a
restated docstring, SECURITY.md sentence order) name no line, and the
text they pointed at has since been rewritten.

Proposed PR title: Flag routes refuse a scoped caller before validating; scoped readers see no rule ids or labels (BACKLOG #6638)
Proposed vault banner: BUILT on engine branch b20056-6638 (batch 20056 Builder F): items 1-6 fixed with tests; item 7 CHANGELOG line corrected, its three unlocated nits left; one behaviour change, a scoped caller's malformed flag request goes from an unaudited 422 to the audited 403.

Verified-by: tests
…s a dependency

BACKLOG #6638, review round 1 repair (code).

The first commit read the flag route's body by hand. The review found
that this dropped FastAPI's strict JSON content-type check (an
all-channels caller's text/plain body flagged a connection where main
answered 422), took ConnectionFlagRequest out of the request-model
census (test_api_request_models_forbid_extra failed), and charged the
pacing gate before a malformed body's 422.

The route is set_connection_flag again, with name: ConnectionName and
req: ConnectionFlagRequest declared. The scope refusal runs in
_flag_scope_gate, a dependency after the gate: FastAPI raises a path or
body validation error only after the route's dependencies run, so a
channel-scoped caller's bad direction, missing direction or bad name is
still the audited 403. A body that is not JSON at all is refused by
FastAPI before any dependency, so it stays an unaudited 422 for every
caller; a test pins that. The gate and the handler share one require_paced
object, so one admission and one pacing charge.

Comments the review found false are corrected (_common.py's list of
unannotated names, test_ui_input_rules.py's "the one name", the handler's
reason for its second refusal).

Verified-by: tests
…-JSON residual

BACKLOG #6638, review round 1 repair (docs).

- docs/SECURITY.md: the GET /connections/{name}/metadata row states that a
  channel-scoped reader gets no metadata labels and metadata_withheld
  true (the review found the rule stated only in a model comment).
- docs/SECURITY.md and CHANGELOG.md: the flag paragraphs no longer list a
  body that is not JSON among the scoped refusals; such a body is still an
  unaudited 422 for every caller, and both say so.

BEHAVIOUR CHANGE (stated for the Lander's routing): a channel-scoped
caller's POST /connections/{name}/flag with a direction naming neither
side or missing, or a name failing the connection-name rule, now answers
the audited 403 where it answered an unaudited 422.

Proposed PR title: Flag routes refuse a scoped caller before validating; scoped readers see no rule ids or labels (BACKLOG #6638)
Proposed vault banner: BUILT on engine branch b20056-6638 (batch 20056 Builder F): items 1-6 fixed with tests; item 7's CHANGELOG line corrected, its three unlocated nits left; one behaviour change, a scoped caller's malformed flag request goes from an unaudited 422 to the audited 403 (a body that is not JSON stays an unaudited 422).

Verified-by: none
…ection marker

BACKLOG #6638, review round 2 repair (code).

- _flag_scope_gate reads the direction only from a non-empty body sent as
  JSON, FastAPI's own test, so it reads FastAPI's cached parse and never
  parses a body FastAPI would not. A body sent as another type names no
  direction, so a scoped caller is refused; an all-channels caller still
  gets FastAPI's 422. A test pins both.
- The test checks each denial row's detail: the marker on the four bad
  bodies, the malformed-name row naming no channel.
- ui_purge_confirm's comment no longer calls dest the only unannotated
  name.

Verified-by: tests
… get no metadata labels

BACKLOG #6638, review round 2 repair (docs).

- docs/SECURITY.md: the flag paragraph says only the name and direction
  are read first, so other faults stay a 422, and how a body not sent as
  JSON is handled; the console's rule-check sentence names the flag route
  as the exception, where record_channel_denied is the only bound.
- docs/CONNECTIONS.md: GET /connections/{name}/metadata gives a
  channel-scoped user no metadata labels.
- CHANGELOG.md: the same narrowing of the flag entry.

BEHAVIOUR CHANGE (stated for the Lander's routing): a channel-scoped
caller's POST /connections/{name}/flag whose direction names neither side
or is missing, or whose name fails the connection-name rule, now answers
the audited 403 where it answered an unaudited 422.

Proposed PR title: Flag routes refuse a scoped caller before validating; scoped readers see no rule ids or labels (BACKLOG #6638)
Proposed vault banner: BUILT on engine branch b20056-6638 (batch 20056 Builder F): items 1-6 fixed with tests; item 7's CHANGELOG line corrected, its three unlocated nits left; one behaviour change, a scoped caller's malformed flag name or direction goes from an unaudited 422 to the audited 403. Residuals filed in the report: other per-name routes keep the unaudited 422; posture still lists a withheld silencing rule by position.

Verified-by: tests
…eaders get no reply_from

BACKLOG #6638 repair round.

- _flag_scope_gate decides whether a body is JSON with FastAPI's own
  test (email.message parse, application/json or a +json subtype), and
  catches a decode failure, so a scoped caller's application/x/y+json
  body that does not parse is the audited 403, not a 500 with no row.
- A body not read as JSON is still refused for a scoped caller, but its
  row no longer carries flag_direction_not_inbound, since its direction
  was never read (_refuse_connection_flag gains direction_read).
- GET /connections/{name}/metadata gives a channel-scoped reader an
  inbound's settings.reply_from as null, with the new
  ConnectionMetadata.reply_from_withheld true; an all-channels reader
  still reads it. The route's docstring says what such a reader gets.
- Tests: the +json and text/plain cases and their row markers, and the
  reply_from withholding with an all-channels control.

Verified-by: tests
BACKLOG #6638 repair round.

- CHANGELOG: the flag entry names the row a bad name gets (no channel,
  malformed_name) instead of "the row it gives any other target", and
  says a body of another type is refused with no direction marker; the
  metadata entry adds reply_from_withheld.
- SECURITY.md: the marker is written for a direction the route read,
  and a body of another type is refused without it; "sent as JSON" is
  stated as the framework's own test; the metadata route row lists
  reply_from.
- CONNECTIONS.md: the metadata route lists reply_from.

Proposed PR title: Flag routes refuse a scoped caller before validating; scoped readers see no rule ids, labels or reply_from
Proposed vault banner: BUILT on branch b20056-6638 (repair round): items 1-7 fixed with tests; flag gate fails closed on any body, reply_from withheld from scoped readers.

Verified-by: none
@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): your QA line is the review proof; I take the disclosed refusal as a corrected act. A fresh-context reviewer measured the open findings against origin/main (195 tests passed). Finding 1: for a scoped caller's non-JSON body main answered 422 with no audit row; this head answers 403 and writes a row. Refused on both, and the head records more, so I accept it (empower added class 2; LOGGED d20261202T093929032-dd9135 posted). Finding 2 (posture shows the position of withheld rules) is on main; the head only removes the id. I enqueue when the required contexts are green. Queued for filing under R2: the docs/SECURITY.md sentence 'so a row without that marker was not refused for its direction' is now false for the non-JSON refusal (safe direction; suggested: 'so a row without that marker was not refused for a direction the route read; the JSON route's refusal of a scoped caller's body not sent as JSON carries no marker either (below)'); the 403 names no cause; findings 3 to 9; a semantic check of docs/CONNECTIONS.md against main's newer rows was not completed. Undo: revert this PR.

@github-actions github-actions Bot added the ci-red A required check went red. Attribute it before retrying. label Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): a sql server (store + connector) leg went red on f2ac5c1 (run 46850739228, job 143354767767): tests/test_stage_dispatcher.py::test_t11_wake_during_claiming_empty_dirty_rereadies[sqlserver] (assert [] == [one id]). This PR touches no dispatcher or store code. One rerun of the failed job; a second red on this leg is a finding. Flake queued for filing.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): pinned head f2ac5c1, required contexts green. The rerun of the SQL Server leg passed. Enqueuing.

@wshallwshall
wshallwshall added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 2, 2026
The only conflict was CHANGELOG.md, a plain both-added case under
Unreleased / Security. Both sides' entries are kept verbatim, main's
BACKLOG #6600 entry first, then this branch's two BACKLOG #6638 entries.
docs/CONNECTIONS.md auto-merged. Nothing else changed.

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): the queue removed this PR for a merge conflict in CHANGELOG.md. A Lander Builder merged main in (fast-forward push, no force): head now 359a6bc, parents f2ac5c1 and baa9d4f. Both sides' entries kept word for word.

Independent Lander-started review of the resolution only (fork adbfed9d4d174e1b0, round-c41d7e9a02): xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (read with review_tag.py, exit 0). Measured: the head differs from the automatic merge of its parents in CHANGELOG.md only; its diff against main equals the branch's own additions; no markers. No correctness finding. One cleanup finding, queued for filing under R2: the two #6638 entries are direct CHANGELOG.md edits where changelog.d/README.md asks for a fragment.

Pinned head for the merge: 359a6bc. I enqueue once every required context is green on it.

@wshallwshall
wshallwshall added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 2, 2026
Three files conflicted, all on the web console seam digest that PR 3568
(BACKLOG #3771) and this branch (BACKLOG #6638) each moved from
4033184244d47e90 on their own (main to be04f29ecb86c73b, branch to
649e40ac2b7f6902):

- messagefoundry/api/_ui_seam.py: both history entries kept verbatim
  (#3771, then #6638), plus a merge entry in the file's own convention;
  ENGINE_UI_SEAM re-derived on the merged tree.
- tests/golden/webconsole_seam.snapshot: took main's side to clear the
  markers, then regenerated with
  python scripts/webconsole_seam_snapshot.py --write
- messagefoundry_webconsole/__init__.py: SUPPORTED_ENGINE_SEAMS set by
  hand to the value --write printed, 955191cd49e25c20, as
  docs/WEBCONSOLE-PACKAGE.md step 3 requires. Neither side's value holds
  for the merged surface.

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): main moved (PR 3568 and others) and this PR conflicted again, in messagefoundry_webconsole/__init__.py, messagefoundry/api/_ui_seam.py and tests/golden/webconsole_seam.snapshot, all on the UI seam digest. A Lander Builder merged main in (fast-forward push, no force): head 6f678b8, parents 359a6bc and 710228c. Both sides' history entries kept verbatim; the digest re-derived to 955191cd49e25c20 with scripts/webconsole_seam_snapshot.py --write (docs/WEBCONSOLE-PACKAGE.md); one 3-line comment entry added recording the merge. This is the second and last Lander repair here.

Independent Lander-started review of the resolution only (fork a5e76757d7821f4c2, round-2f6b8d13a7): xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (review_tag.py exit 0). CLEAN: the head differs from the automatic merge in those three files only; the stored digest equals the derived one (43 seam tests pass; 1587 scope and web console tests pass). Queued for filing under R2, comment wording only: the bare "(#3771)" should read "vault BACKLOG #3771"; the #6638 entry lacks the "on the branch" qualifier; the merge entry is a separate paragraph where the file's convention appends to the later entry; the ledger is named three ways in adjacent entries.

Pinned head for the merge: 6f678b8. I enqueue once every required context is green on it.

@wshallwshall
wshallwshall added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit c9e7335 Dec 2, 2026
67 of 69 checks passed
@wshallwshall
wshallwshall deleted the b20056-6638 branch December 2, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-red A required check went red. Attribute it before retrying. qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant