Repository navigation
fix(broker): compose the caller's signal, and check the issuer the document claims (TASK-172) - #2007
Merged
Merged
Conversation
…cument claims (TASK-172) Two guards the vendor path was missing, both recorded by the #2006 review rather than blocking on it: - `upstreamFetch` composed nothing: `{ ...init, signal: AbortSignal.timeout(…) }` reads as though `init` were honoured and silently drops the one field in it that cancels. A caller's signal is now composed with the deadline instead of replaced, and the arms cover both directions — a caller who aborts stops the call, and a caller whose signal never aborts still hits the deadline. No caller passes one today (all three take the default), so this is the difference between a wrapper that is bounded and one that is bounded AND cancellable. - Discovery read endpoints out of the metadata without ever comparing the document's `issuer` to the issuer the URL was built from. RFC 8414 §3.3 requires them identical, and what the check defends is the next line of the flow: `authorization_endpoint` is where the person's browser is sent, so a document written for another issuer hands that consent to whoever wrote it. A missing `issuer` is `issuer_metadata_incomplete` (§2 makes it REQUIRED); a different one is the new `issuer_mismatch`, which the start route maps to a 502 with the other vendor-side states. Evidence: baseline (3, 50); tsc:check clean; eslint clean on the three sources; ledger 10 mutants — 9 killed, 1 recorded equivalent, no survivors, no named-arm misses, no not-applied. The equivalent is measured rather than argued: applying it leaves the suite 50/50, because the arm asserts WHICH failure arrives and an ignored timeout parameter still produces it, fifteen seconds later rather than in twenty milliseconds.
The credential suite's METADATA was the only one that failed, because it is the only one whose discovery is real rather than mocked: with no `issuer`, the new check refuses the document and the refresh arm dies on `authorization server metadata names no issuer` — a red that says nothing about the deadline it is testing. The two mocked stubs (connect's AS_METADATA, callback's discovery return) are corrected in the same pass: they stand in for a conformant vendor today and would have been a live trap the moment either was wired to real discovery.
…eam, not on a budget The arm failed in 4 of 8 isolated runs BEFORE this change, always the same way: the loser's `WINNER_WAIT_MS` budget elapsed while the winner was still writing the row, so the loser refused `credential_refreshing` and the arm read as the fence having broken. The clock is the reason, and it is the same defect #2004 removed elsewhere. This suite injects `sleep`, which advances a VIRTUAL clock, while the winner's progress — its vendor call, its `commit` — is real. A poll loop therefore spends 1500 virtual milliseconds in microseconds of real time: the budget expires faster than the work it is waiting for, and which side wins is decided by mongod's scheduling. A budget that expires faster than the work it waits for is not a budget. So the loser's first poll still wakes the winner and then WAITS for the winner's commit at its seam, which the suite now wraps alongside the bump. The arm turns on the store's state — a fresh row means the winner wrote — instead of on which task the event loop ran first, and the deadline keeps its deterministic witness in `a live lease is not takeable`, where nothing else can move the row. Witnessed by instrument rather than by a quiet re-run: - 10/10 isolated runs green, against 4/8 red before - mutant S1 (the fence takes no lease at all — the defect this arm exists for) still turns it RED, along with two sibling arms, so the seam did not hollow it out - mutant S2 (`preImageWasStale &&` dropped from the loser's freshness check) SURVIVED: that clause is not a tautology, so this is an UNWITNESSED BRANCH, not an equivalence — the corner it covers (no `credentialRef` while `expiresAt` is fresh) has no arm, and whether refusing `credential_refreshing` there is right is a behaviour question for the board, not something to pin inside a test-only diff
…dpoint guard is witnessed again Vera's catch, and it is the good kind: my §3.3 check landed ABOVE the endpoint guard, and this arm sent a document with no issuer. It went on refusing, with the SAME error code as a missing endpoint, so deleting the endpoint guard outright changed no test in the neighbourhood (she measured 102/102 green; I reproduce it). The refusal was never in doubt — its ATTRIBUTION was. Two defects, one code, and the arm was pinning whichever ran first. So the document carries an issuer on purpose, and the arm pins its MESSAGE as well as its code — the message is the only thing that tells the two apart, which is why the no-issuer arm pins its own message too. Witnessed by mutant: delete `if (!body.authorization_endpoint || !body.token_endpoint)` and this arm is the one that goes red, by name, alone. 13 suites / 155 tests green otherwise.
This was referenced Sep 29, 2026
lilyshen0722
added a commit
to thantiklermcirony/commonly
that referenced
this pull request
Oct 9, 2026
…ss ambiguous (Team-Commonly#2008) * docs(checklist): rule 42 — a shared refusal code makes an arm's witness ambiguous Two guards that refuse with the same code make one arm ambiguous, and a guard added ABOVE an existing one silently transfers the old guard's only witness to the new one. The arm does not change, the test file shows nothing, the suite is green — which is why the review check is not "is this arm good" but "how many guards emit this code". Earned today on Team-Commonly#2007/TASK-172. The new RFC 8414 §3.3 issuer check landed above an established endpoint guard; the neighbouring arm sent a document naming no issuer, kept refusing with the same `issuer_metadata_incomplete`, and so was pinning the new guard rather than the one it was written for. Deleting the endpoint guard changed no test in the neighbourhood. Measured on both sides of the repair, in one instrument: pre-repair arm + guard deleted = 30/30 green (the survivor), post-repair arm + guard deleted = that arm alone goes red, by name. Rider: where a route answers `{ error: code }` with no message, the shared code is client-visible too, so "same code" is a contract decision rather than a test detail. Guard: scripts/verify-numbered-rules.js → 42 rules, 1..42, 20 citations resolve. * docs(checklist): rule 42 — witness is fixture reachability, not the assertion shape Corrected per the docs gate's HOLD at 568df1c. The first draft claimed a shared refusal code obliges every arm to assert the message; the rule's own incident disproves it, and I measured the counter-example before rewriting: arm fixture endpoint guard deleted result no `issuer` (pre) yes 30/30 green (guard unwitnessed) `issuer` present yes that arm ALONE reds — on the CODE assertion: with the guard gone nothing is thrown, so `thrown.code` is a TypeError So re-aiming the fixture is the fix and it is local; pinning the message is an option that additionally pins WHICH refusal, not a requirement. The review move: counting a code's emitters says where attribution is at risk (rule 25); the per-arm question is which guards can fire on its input, and the witness is a mutation of the guard that arm NAMES. The rider (a shared code is client-visible, so "same code" is a contract decision) is unchanged. Guard: 42 rules, 1..42, 20 citations resolve.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two guards the hosted-MCP vendor path was missing. Both were recorded during the #2006 review rather than held against it — this lands them now that the stack is on main.
1. The caller's signal is composed with the deadline, not replaced
upstreamFetchdeclaredinitand then setsignalover it:which reads as though
initwere honoured and silently drops the one field in it that cancels. It now composes:AbortSignal.any([init.signal, deadline])when a caller supplies one, the deadline alone otherwise.The arms cover both directions, because a composition can lose the bound as easily as it can lose the caller: one arm aborts a caller's controller and asserts the request rejects with that reason (and that the signal the fetch received is a composite, not the controller's own — a pass-through is a red here too); another passes a signal that never aborts and asserts the deadline still refuses it.
No caller passes a signal today — all three take the default, which I verified by reading the call sites rather than repeating the claim — so nothing was broken. This is the difference between a wrapper that is bounded and one that is bounded and cancellable.
2.
issueris checked before anything is read out of the documentDiscovery fetched the metadata and read endpoints straight out of it. RFC 8414 §3.3 requires the document's
issuerto be identical to the issuer the URL was built from, and what the check defends is the next line of the flow:authorization_endpointis where the person's browser is sent next, so a document fetched for this URL but written for another issuer hands that consent to whoever wrote it.issuer→issuer_metadata_incomplete(§2 makes the claim REQUIRED, so a document without one has no identity to match)issuer→ the newissuer_mismatch, whichvendorFailureStatusmaps to a 502 alongsideissuer_unreachableandissuer_metadata_incomplete— it was reached and it answered, so it is still the vendor's failure and still not a 4xxThe comparison is exact, with no trailing-slash allowance, and there is an arm pinning that: a trailing-slash allowance is how an identity check quietly becomes a prefix check. I checked it against the live first-wave vendors rather than assuming it would be safe — all four echo their issuer byte-for-byte, and every entry's
issueris ours to write, so nothing needs the allowance.The arm asserts the refusal's message as well as its code, because the message names the document's issuer and not the one we asked about: the reader is an operator whose next question is what the vendor actually said.
Evidence
(3, 50)across the three suites whose arms name these claimstsc:checkexit 0; eslint 0 on the three changed sourcesThe equivalent is MEASURED rather than argued: ignoring the
timeoutMsparameter leaves the suite 50/50, because the arm asserts which failure arrives and an ignored parameter still produces it — fifteen seconds later instead of in twenty milliseconds. Recorded as an equivalence rather than papered over with an elapsed-time assertion, which would measure the constant under test.Two mutants were cut to reach that: the first run also had a duplicate of that equivalence as an applied mutant (a bookkeeping error of mine, and it showed up as a survivor exactly as the equivalence predicted), and one survivor was a real gap — mutating the refusal message to name the requested issuer instead of the document's passed, because nothing asserted the message. That is now asserted.