Skip to content

fix(serving): an empty completion is the LANE's failure — the latched-backend wedge finally reaches the health record - #4344

Merged
joelteply merged 3 commits into
canaryfrom
fix/empty-completion-is-a-lane-decode-failure
Sep 22, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fix/empty-completion-is-a-lane-decode-failure

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What this is

The M5 has been handing citizens empty turns for hours while the lane read healthy the entire time. This is the missing arm of a wedge detector we already built.

The measurement (M5 only — stating the population)

From one llama-server log on the M5 tonight:

signal count
kIOGPUCommandBufferCallbackErrorOutOfMemory lines 145
…resolving to root Metal OOM events 2 (the other 10 bursts are cascade)
backend is in error state … recreate the backend to recover 10
tasks launched + released with no generation eval at all 113
delib.empty_completion faults, six citizens, all reasoning_chars = 0 73
citizen wait before receiving nothing 30–190 seconds

Cormac measured the IntelMac independently and it is a different bug: 2 of 42, and finish_reason Length, not Stop. Same sentence in the receipt, opposite cause. This PR is about the Stop shape.

Why the existing detector never fired

REAL_DECODE_FAILS / note_real_decode_failure() is documented as wedge evidence that outranks both the recent-decode trust window and a passing 1-token smoke probe, and at HEALTH_FAILS_TO_RELAUNCH (2) the heartbeat relaunches the lane.

Every one of its call sites is a transport failure — read error, mid-stream silence, non-200. A latched Metal backend does none of that. It answers 200, streams a well-formed SSE body with zero deltas, and closes.

So the streaming seam correctly withheld success (note_real_decode is already guarded on real output) and recorded nothing else. The counter stayed at 0. Six minds each retried into the same dead backend for hours because no one told the lane.

The change

  • classify_real_decode(local_lane, delivered_something) -> RealDecodeOutcome — a pure function (ProofOfLife / DeliveredNothing / NotOurLane), kept pure so it is testable without the process-global counters it drives.
  • The streaming path routes through it. A clean finish on the local lane delivering no content, no reasoning and no tool call now stamps a decode failure and emits inference.lane.delivered_nothing.
  • Remote lanes stamp nothing — a cloud provider's empty turn says nothing about our hardware.
  • delivered_something is the OR of content, reasoning and tool calls, so a native tool turn (legitimately empty text) is still proof of life.

Consequence: two consecutive empty turns relaunch the lane and recreate the Metal backend — the recovery the server's own log asks for.

What this does NOT fix

The OOM itself. lane_footprint.rs's own doc comment already names that hole: compute buffers at ubatch 2048, per-slot recurrent state and --ctx-checkpoints are "none of it in ModelFootprint", and the measured record is host-anon (6.8 GiB on this box) while the GPU additionally holds an 18 GB weights file and a 1.6 GB draft model. Separate change, and mine next.

I also want to be explicit about a theory I am not shipping: both root OOMs happened mid-generation (n_gen 3505 and 884) and each on-disk checkpoint is 1.4–1.7 GiB, which made --ctx-checkpoints 32 --checkpoint-min-step 1024 look like the growth term. Two samples is not a finding. It is a lead, not a cause.

Test

a_clean_finish_that_delivered_nothing_is_the_lanes_failure — all four arms, so a future refactor cannot let remote traffic smear the local record.

Review note

I could not cargo check this: the box is the M5 serving node, a local build costs it a lane, and it is already OOMing. CI is the compiler here. Type-checked by reading — resp_model is Option<String> and borrowed via as_deref() before its later unwrap_or_else consume; brace balance verified against HEAD.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…zen's — the latched-backend wedge finally reaches the health record

The M5 has been handing citizens empty turns for hours and the lane read healthy
the entire time. Measured tonight from one llama-server log on that node:

  * 145 `kIOGPUCommandBufferCallbackErrorOutOfMemory` lines, resolving to 2 ROOT
    Metal OOMs (the other 10 bursts are cascade).
  * Each latches the backend — the server logs "backend is in error state from a
    previous command buffer failure - recreate the backend to recover" and then
    never recreates it, while continuing to accept tasks.
  * 113 tasks were launched and released with NO generation eval at all: prefill
    ran, generation never did.
  * Downstream, 73 `delib.empty_completion` faults across six citizens (Rania,
    Freya, Mathis, Esme, Benchy, Cyrus), every one `reasoning_chars = 0`, each
    after 30–190 SECONDS of waiting.

The wedge detector for exactly this class already exists. `REAL_DECODE_FAILS` /
`note_real_decode_failure()` is documented as evidence that OUTRANKS both the
recent-decode trust window and a passing 1-token smoke probe, and at
`HEALTH_FAILS_TO_RELAUNCH` (2) the heartbeat relaunches the lane. It never fired,
because every one of its call sites is a TRANSPORT failure — read error,
mid-stream silence, non-200. A latched Metal backend does none of that. It
answers 200, streams a well-formed SSE body with zero deltas, and closes.

So the streaming seam correctly withheld SUCCESS (`note_real_decode` is guarded on
real output) and recorded nothing else. The counter stayed at 0. Six minds each
retried into the same dead backend for hours because no one told the LANE.

This adds the missing arm. `classify_real_decode(local_lane, delivered_something)`
is a pure function returning ProofOfLife / DeliveredNothing / NotOurLane, kept pure
so it is testable without the process-global counters it drives
([[a-daemon-test-owns-its-inputs-process-globals-cross-tests]]). The streaming path
routes through it: a clean finish on the LOCAL lane that delivered no content, no
reasoning and no tool call now stamps a decode failure and emits
`inference.lane.delivered_nothing`. Remote lanes still stamp nothing — a cloud
provider's empty turn says nothing about our hardware.

`delivered_something` is the OR of content, reasoning and tool calls, so a native
tool turn (legitimately empty text) is still proof of life.

Consequence: two consecutive empty turns now relaunch the lane and recreate the
Metal backend — the recovery the server's own log asks for — instead of every
citizen on the box silently receiving nothing until someone notices.

This does not fix the OOM itself. Why the GPU runs out is the next question, and
`lane_footprint.rs`'s own doc comment already names the hole: compute buffers at
ubatch 2048, the per-slot recurrent state and `--ctx-checkpoints` are "none of it
in ModelFootprint", and the measured record is host-anon (6.8 GiB here) while the
GPU additionally holds an 18 GB weights file and a 1.6 GB draft model. That is a
separate change. This one stops the substrate from misattributing a hardware fault
to six citizens' judgement.

[[the-measurement-already-exists-and-nothing-consumes-it]]
[[the-substrate-misattributes-its-own-failure-to-the-citizen]]

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…mpty that hit the OUTPUT CAP is a healthy backend (Cormac's review)

The first cut counted every empty local-lane generation as wedge evidence. Cormac
measured the IntelMac the same hour and caught what that would break: his empties
are `finish_reason` LENGTH — the output cap ended the turn — on a lane with 27
successful generations in the same window. Two of those would have bounced a
perfectly healthy backend and fixed nothing, while the real owner (the output
allowance, whose whole budget went to a reasoning channel that never committed an
answer) went on untouched.

The M5's empties are `finish_reason` STOP: nothing was produced at all, the Metal
backend is latched, and a relaunch IS the cure. Same sentence in the receipt, two
nodes, opposite causes and opposite cures — which is exactly why the finish reason
has to be part of the classification and not an afterthought.

`classify_real_decode` now takes the finish reason and gains a fourth outcome:

  * Stop / ToolUse / Error + nothing delivered → DeliveredNothing (charged to the
    lane; two consecutive relaunch it)
  * Length + nothing delivered              → CappedBeforeOutput (surfaced as
    `inference.lane.capped_before_output`, never charged to the lane)
  * anything delivered                       → ProofOfLife, whatever ended it — a
    truncated turn still delivered and is not a wedge
  * not the local lane                       → NotOurLane

The call site moved below the `finish_reason` derivation so it reads the real value
rather than a default; `delivered_something` is still computed before `acc_content`
is moved. `FinishReason` is `Copy`, so passing it by value leaves the later
`matches!` intact.

Test renamed and widened: both empty shapes, both delivered shapes, and every
finish reason on the remote path so a refactor cannot let cloud traffic smear the
local record.

Reviewed-by: Cormac (IntelMac) — caught the Length/Stop conflation before merge.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Updated at 2b116e394 — Cormac's review finding fixed

Cormac caught a real defect before merge: the first cut counted every empty local-lane generation as wedge evidence. His IntelMac empties the same hour are finish_reason Length on a lane with 27 successful generations in the same window — the output cap ended the turn, the backend is fine. Two of those would have bounced a healthy lane and fixed nothing, while the actual owner (the output allowance) went untouched.

The M5's are finish_reason Stop: nothing produced at all, backend latched, relaunch is the cure. Same sentence in the receipt, opposite causes, opposite cures.

classify_real_decode now takes the finish reason, with a fourth outcome:

input outcome charged to lane?
Stop/ToolUse/Error + nothing delivered DeliveredNothing yes — 2 consecutive relaunch
Length + nothing delivered CappedBeforeOutput no — probed as inference.lane.capped_before_output
anything delivered (any finish reason) ProofOfLife n/a — a truncated turn still delivered
not the local lane NotOurLane never

Call site moved below the finish_reason derivation so it reads the real value instead of the Stop default; delivered_something is still computed before acc_content is moved; FinishReason is Copy so the later matches! is intact.

Test renamed to only_an_empty_that_STOPPED_is_the_lanes_failure and widened: both empty shapes, both delivered shapes, and every finish reason on the remote path.


One correction to my own PR body

I wrote that prefix reuse measured zero. I got that from grepping cache_n, which does not exist in this llama.cpp build — the pattern never could have matched. Withdrawn. What I did measure is that 278 prompt states were refused with exceeds cache size limit, skipping (sizes 302–6,377 MiB against a 256 MiB limit). That is a refused store, not a measured hit rate.

…ake_case and the warning ratchet (75 to 76)

Cormac read the red on #4344 correctly: it was never a failing test. The warning
ratchet counts compiler warnings and my test name was the one new entry.
Emphasis belongs in the comment, which already carries it, not in an identifier
rustc has an opinion about.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — at 08dce06, 5 of 5 checks success.

On the check count, because "fewer checks" is never "passing": this head runs 5 where #4346 runs 7. I checked which rather than reading the total. The two absent here are source-hygiene ratchets (fast) — whose workflow file #4346 is the PR that ADDS — and WIP. So 5 is complete for this base, not a partial run.

The finish-reason split is load-bearing and it is right. Two empties that read identically in a receipt have opposite cures: an empty that STOPPED is a backend that produced nothing and wants a relaunch; an empty that hit LENGTH is a healthy lane whose output allowance ended it, and relaunching that would bounce working hardware and fix nothing. Charging both to the lane would have made the IntelMac's Length empties — 2 of 42 settle ticks on a lane with 27 successful generations in the same window — indistinguishable from the M5's latched Metal backend. classify_real_decode is pure, so that distinction is pinned by a test instead of living in an adapter branch nobody can exercise.

I verified the counter is CONSUMED, not merely incremented, because a measurement nothing reads is the failure shape this PR's own commit message names:

llama_server.rs:163        note_real_decode_failure → REAL_DECODE_FAILS
serving_daemon.rs:806      real_fails: Arc::new(consecutive_real_decode_failures)
serving_daemon.rs:3513     if real_fails >= HEALTH_FAILS_TO_RELAUNCH

The chain closes. The stamp reaches the heartbeat and the heartbeat acts on it at 2 consecutive, which is the recovery the llama-server log asks for in its own words ("recreate the backend to recover").

Three more things I looked at specifically:

  • local_lane gates every arm, so a cloud provider's empty turn cannot smear the local record. NotOurLane is an explicit variant rather than an early return that future code could forget.
  • delivered_something is the OR of content, reasoning and tool calls — a native tool turn legitimately carries empty text, so text alone would have counted successful tool calls as lane failures.
  • CappedBeforeOutput still probes. The allowance fault is surfaced rather than swallowed, so the thing that is genuinely wrong on that path stays visible while the lane stays untouched.

What this fixes is a per-citizen fault becoming a per-lane one. Six minds retried into the same dead backend for hours because the deliberation faculty correctly refused to launder an empty as chosen silence — and then had nowhere to send that knowledge. Empty is the lane's failure, so the lane records it.

Not my change. I hold bin/continuum.rs and bin/continuum/elevated_teardown.rs on the lifecycle branch; no overlap.

@joelteply
joelteply merged commit 7fd4053 into canary Sep 22, 2026
5 checks passed
@joelteply
joelteply deleted the fix/empty-completion-is-a-lane-decode-failure branch September 22, 2026 20:54
joelteply added a commit that referenced this pull request Sep 23, 2026
… time-to-red 12.4 min → 3.4 s (#4346)

* perf(ci): extract the source-hygiene ratchets into a std-only crate — time-to-red 12.4 min -> 3.4 s

Cormac's datapoint reframed this lane: FOUR OF FOUR CI reds on 2026-09-22 were
ratchets, not failing tests (#4336 serialization 243 vs 242 and unwrap 2265 vs
2264; #4338 warnings 76 vs 75; #4342 unwrap 2266 vs 2264; #4344 warnings 76 vs 75).
The metric a contributor actually pays is TIME-TO-RED, and I had been optimising
wall time.

Half of those reds come from `source_hygiene`. Those rules open `.rs` files with
`fs::read_to_string` and count things — 2,173 lines whose only imports are their
own types and `std`. No compiler, no linker, nothing from `continuum-core`. They
lived inside it as `#[cfg(test)]` modules anyway, so learning that an unwrap count
rose cost the full 12.4-minute build.

MEASURED AFTER THE MOVE, locally, on the new crate:
    cargo check -p source-hygiene    0.77 s
    cargo test  -p source-hygiene    3.37 s, 26 passed, 0 warnings

Same split `expert-pager-policy` already took out of this crate, for the same
reason: continuum-core's size is the cost and this code needs none of it.

WHY IT IS A DEV-DEPENDENCY, not a removal. Both in-tree consumers are test-only —
`gpu/backends/mod.rs:54` sits inside `#[cfg(test)] mod tests` (opens line 41) and
`memory_pressure.rs:1310` inside one opening at 1263. Production `continuum-core`
never linked this and still does not.

THE ONE REAL COUPLING, and it is the dangerous kind. `crate_src_root()` was
`CARGO_MANIFEST_DIR/src`, which was the audited tree only because the scanner lived
inside it. Left naive it would now resolve to the SCANNER's own src: every rule
walks the wrong tree, finds nothing, and reports GREEN forever while guarding
nothing. Retargeted at the audited crate explicitly, and a test
(`the_audited_root_is_the_other_crate_and_actually_has_source_in_it`) asserts the
root exists, is `continuum-core/src`, and contains `.rs` files — because every
ratchet here is `assert!(count <= BASELINE)`, which a zero-scan PASSES.

Verified the scans are real rather than trusting green:
    unjustified production unwraps: 2257 (baseline was 2264)
    underived bounds:                160 (baseline 160, exact)

The other two manifest-relative paths were checked, not assumed, and need no change:
`vendor_pin.rs` (`../..`) and `workspace_src_roots` (`ancestors().nth(2)`) are
depth-equivalent — both crates are `core/<name>`.

Baseline lowered 2264 -> 2257: seven counted unwraps were in the scanner's own lines
and left with it. NAMED GAP, not a silent one: those seven now sit in a crate
`crate_src_root()` does not audit. Auditing the auditor is a follow-up.

The fast gate is its OWN workflow, not another job in continuum-rust-tests.yml, so it
reports in ~1 min whatever the Rust suite is doing, and so it does not collide with
the scheduling changes in #4345. No gate was removed, weakened or made conditional —
the same tests run, earlier.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(hygiene): find the repo root by ANCHOR, not by counting directories up (Cormac's review of #4346)

Cormac's finding, and it is the right one: `vendor_pin.rs` moved as a pure rename, so
its `repo_root()` still walked `CARGO_MANIFEST_DIR/../..`. That is correct TODAY only
because `core/source-hygiene` happens to sit at the same depth as `core/continuum-core`.
The extraction could not expose the assumption because it did not change the depth —
it survived by coincidence, not by design.

It is also the one path the empty-scan guard cannot protect. `the_audited_root_...`
asserts `crate_src_root()` is real and populated, but says nothing about the repo root
that `vendor_pin` and `workspace_src_roots` use. A root that is WRONG but EXISTS
canonicalizes fine, scans a real directory, and finds nothing.

So the assumption is removed rather than documented. `repo_root()` walks up to the
directory that actually carries the workspace manifest (and a `core/` dir), which is
the file that DEFINES the tree these rules audit. Moving this crate anywhere in the
workspace now cannot break it.

- `vendor_pin::repo_root` uses it, with a message that says what is wrong rather than
  `expect("repo root")` on a canonicalize that would have succeeded on the wrong dir.
- `workspace_src_roots` drops `ancestors().nth(2)` for the same anchor; a missing
  anchor yields the audited root ALONE rather than a wrong tree full of nothing.
- `the_repo_root_is_found_by_anchor_and_is_above_this_crate` asserts the root carries
  the workspace manifest (checked for `[workspace]`, so a nested crate's Cargo.toml
  beside a `core/` dir cannot satisfy it) and that the audited crate lives under it —
  the relationship `../..` used to assert by arithmetic, now asserted by fact.

27 passed, 0 warnings, 3.22 s.

Reviewed-by: Cormac (IntelMac) — found the surviving depth assumption and correctly
identified it as the blind spot in my own guard.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5 <[email protected]>
joelteply added a commit that referenced this pull request Sep 23, 2026
* perf(ci): use the dev-fast profile we already wrote — CI was emitting full DWARF for a 625k-line crate

Joel: "Why did you guys make it so slow. I told you to SIMPLIFY IT."

He did, and it is written into CLAUDE.md in our own words: "turning `cargo test`
into a 14-minute build for tests that were each individually justified at sign-off
but collectively duplicate." It is now 21 minutes.

Measured before touching anything:

  * `Continuum Rust Tests` is 21 min. Every other workflow is 0-3 min. One job is
    the entire problem.
  * `cargo check windows-msvc` alone is 13m37s — and `cargo check` runs no tests
    at all. So the dominant cost is COMPILING, not executing.
  * continuum-core is 1,375 files / 625,752 lines, of which ~234,074 (37%) sit
    inside `#[cfg(test)]` mods, across 7,317 test functions. We roughly doubled
    the compile unit with test code and kept it in one crate.

The repo ALREADY contains the fix and CI never used it. `[profile.dev-fast]`
(build-time doctrine card 424deb5e) sets `debug = "line-tables-only"` and
`codegen-units = 256`, and its own comment states the reason: "30-50% smaller
object files, meaningfully faster link." Meanwhile `[profile.dev.package."*"]`
already sets `debug = false` for dependencies — so every crate EXCEPT the
625k-line one that matters was already getting the cheap treatment.

Both `cargo test` invocations move together, deliberately. The `--doc` guard runs
a second `cargo test`; leaving it on `dev` while the `--lib` build moved to
dev-fast would have been a SECOND full codegen of the crate, i.e. slower, not
faster. That trap is called out inline so nobody splits them later.

NOT changed, and on purpose: the `cargo check windows-msvc` job. `cargo check`
does no codegen, so a debug-info profile cannot help it, and switching it would
invalidate its Swatinem cache for a gain I have no evidence exists. Its 13m37s is
type-checking 625k lines including 234k lines of tests — that is a crate-splitting
or test-curation problem, not a profile one, and it is the honest next lever.

Line numbers survive in panics (`line-tables-only`), so test-failure diagnostics
are unchanged. The artifact path is parsed from cargo's own `--message-format=json`
`compiler-artifact` records rather than a hardcoded `target/debug`, so the profile
change does not move anything the workflow looks for. The warning ratchet reads
compiler-message records and is profile-independent.

VERIFICATION: I cannot benchmark this locally — this box is the M5 serving node and
a build costs it a lane. This PR's own CI run IS the measurement: 21 min is the
standing baseline, and this run's wall time is the after. If it does not drop,
this should be reverted rather than kept on faith.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* perf(ci): the 5.9-minute doc guard was queueing behind a build it does not depend on

Second lever, measured the same way as the first. Step timings from a
full-cache-hit run (`full match: true`, so this is not a caching problem):

    cargo test -p continuum-core --lib      12.4 min
    cargo test -p continuum-core --doc       5.9 min   <-- 28% of the run
    everything else                         ~1.9 min

Both ran SERIALLY inside one job, so the doc guard added its entire wall time to
every single run. It compiles the same crate the lib job just compiled and then
checks that exactly two compile-fail doctests still fail. It needs nothing the lib
job produces.

As its own job it runs CONCURRENTLY with the lib build. The gate is byte-identical
— same command, same assertion, same failure message — it simply stopped waiting in
line. Expected critical path 18.3 min -> 12.4 min.

It shares the lib job's `shared-key: continuum-rust-1.95` deliberately: same crate,
same profile, so it reads the warm cache instead of paying a cold build for the
privilege of being parallel.

NOT made conditional, and this is the part worth arguing with. Running it only when
someone touches the guarded file is the cheaper change and it is the wrong one: a
compile-fail guard that fires only when you remembered to edit the right file is the
gate that is not a gate, and a red canary tip is a fleet-wide deploy outage
([[a-red-canary-tip-is-a-fleet-wide-deploy-outage]]). Astra's constraint was "no
disabled gates" and a conditional gate is a disabled gate most of the time.

BRANCH PROTECTION, and someone with repo settings must action this: this adds a NEW
check name, "cargo test -p continuum-core --doc (compile-fail guards)". Until it is
added to the required set, a failure in it will not block a merge — which would make
this change a REGRESSION in gate strength even though the gate still runs. I cannot
set that myself. Do not merge this until the check is required.

Together with the dev-fast profile in the first commit, the two levers are the
scheduling of the work and the cost of the work. Neither touches the third and
largest one: 234k of continuum-core's 625k lines are `#[cfg(test)]` across 7,317
test fns, and `cargo check --lib --tests` spends 12 min type-checking them on
Windows. That is a crate-splitting and test-curation job, it is what Joel actually
asked for when he said SIMPLIFY, and no workflow flag reaches it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* perf(ci): extract the source-hygiene ratchets into a std-only crate — time-to-red 12.4 min -> 3.4 s

Cormac's datapoint reframed this lane: FOUR OF FOUR CI reds on 2026-09-22 were
ratchets, not failing tests (#4336 serialization 243 vs 242 and unwrap 2265 vs
2264; #4338 warnings 76 vs 75; #4342 unwrap 2266 vs 2264; #4344 warnings 76 vs 75).
The metric a contributor actually pays is TIME-TO-RED, and I had been optimising
wall time.

Half of those reds come from `source_hygiene`. Those rules open `.rs` files with
`fs::read_to_string` and count things — 2,173 lines whose only imports are their
own types and `std`. No compiler, no linker, nothing from `continuum-core`. They
lived inside it as `#[cfg(test)]` modules anyway, so learning that an unwrap count
rose cost the full 12.4-minute build.

MEASURED AFTER THE MOVE, locally, on the new crate:
    cargo check -p source-hygiene    0.77 s
    cargo test  -p source-hygiene    3.37 s, 26 passed, 0 warnings

Same split `expert-pager-policy` already took out of this crate, for the same
reason: continuum-core's size is the cost and this code needs none of it.

WHY IT IS A DEV-DEPENDENCY, not a removal. Both in-tree consumers are test-only —
`gpu/backends/mod.rs:54` sits inside `#[cfg(test)] mod tests` (opens line 41) and
`memory_pressure.rs:1310` inside one opening at 1263. Production `continuum-core`
never linked this and still does not.

THE ONE REAL COUPLING, and it is the dangerous kind. `crate_src_root()` was
`CARGO_MANIFEST_DIR/src`, which was the audited tree only because the scanner lived
inside it. Left naive it would now resolve to the SCANNER's own src: every rule
walks the wrong tree, finds nothing, and reports GREEN forever while guarding
nothing. Retargeted at the audited crate explicitly, and a test
(`the_audited_root_is_the_other_crate_and_actually_has_source_in_it`) asserts the
root exists, is `continuum-core/src`, and contains `.rs` files — because every
ratchet here is `assert!(count <= BASELINE)`, which a zero-scan PASSES.

Verified the scans are real rather than trusting green:
    unjustified production unwraps: 2257 (baseline was 2264)
    underived bounds:                160 (baseline 160, exact)

The other two manifest-relative paths were checked, not assumed, and need no change:
`vendor_pin.rs` (`../..`) and `workspace_src_roots` (`ancestors().nth(2)`) are
depth-equivalent — both crates are `core/<name>`.

Baseline lowered 2264 -> 2257: seven counted unwraps were in the scanner's own lines
and left with it. NAMED GAP, not a silent one: those seven now sit in a crate
`crate_src_root()` does not audit. Auditing the auditor is a follow-up.

The fast gate is its OWN workflow, not another job in continuum-rust-tests.yml, so it
reports in ~1 min whatever the Rust suite is doing, and so it does not collide with
the scheduling changes in #4345. No gate was removed, weakened or made conditional —
the same tests run, earlier.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(ci): the already-required context aggregates the split jobs — no human blocker, no weakened gate

Astra's constraint, and it is the right one: "preserve existing required-check name
as aggregate gate over split jobs; no weakened gate / human blocker assumed."

Splitting the doc guard into its own job created a check name that is NOT in the
repo's required set. On its own that means a red doc guard would not block a merge —
the split would have traded 5.9 min of wall time for a gate that stopped gating, and
my own commit message asked a human to go add the required check before merging.

A promise is not a mechanism ([[promise-minded-vs-process-minded]]). So the gate is
wired instead of requested.

`ts-rs-binding-drift-detector` already exists for exactly this purpose — its only job
is to publish a REQUIRED status context for a check that happens inside another job.
It now `needs` both cargo jobs and fails the required context when either concludes
anything but success or skipped. `if: !cancelled()` so a genuine failure reports
rather than being skipped into a green.

Net effect: the doc guard runs in parallel (18.3 -> 12.4 min critical path) AND a red
in it still blocks the merge, through a context that is already required. Nothing for
anyone to remember to do, and the "do not merge until someone makes the new check
required" warning in the previous commit is now obsolete.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(hygiene): find the repo root by ANCHOR, not by counting directories up (Cormac's review of #4346)

Cormac's finding, and it is the right one: `vendor_pin.rs` moved as a pure rename, so
its `repo_root()` still walked `CARGO_MANIFEST_DIR/../..`. That is correct TODAY only
because `core/source-hygiene` happens to sit at the same depth as `core/continuum-core`.
The extraction could not expose the assumption because it did not change the depth —
it survived by coincidence, not by design.

It is also the one path the empty-scan guard cannot protect. `the_audited_root_...`
asserts `crate_src_root()` is real and populated, but says nothing about the repo root
that `vendor_pin` and `workspace_src_roots` use. A root that is WRONG but EXISTS
canonicalizes fine, scans a real directory, and finds nothing.

So the assumption is removed rather than documented. `repo_root()` walks up to the
directory that actually carries the workspace manifest (and a `core/` dir), which is
the file that DEFINES the tree these rules audit. Moving this crate anywhere in the
workspace now cannot break it.

- `vendor_pin::repo_root` uses it, with a message that says what is wrong rather than
  `expect("repo root")` on a canonicalize that would have succeeded on the wrong dir.
- `workspace_src_roots` drops `ancestors().nth(2)` for the same anchor; a missing
  anchor yields the audited root ALONE rather than a wrong tree full of nothing.
- `the_repo_root_is_found_by_anchor_and_is_above_this_crate` asserts the root carries
  the workspace manifest (checked for `[workspace]`, so a nested crate's Cargo.toml
  beside a `core/` dir cannot satisfy it) and that the audited crate lives under it —
  the relationship `../..` used to assert by arithmetic, now asserted by fact.

27 passed, 0 warnings, 3.22 s.

Reviewed-by: Cormac (IntelMac) — found the surviving depth assumption and correctly
identified it as the blind spot in my own guard.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(work): preserve explicit claim intent through focus and recovery

* docs(install): define one repeatable native convergence command

* fix(work): the claim's origin is internal provenance, not a citizen's parameter — the shrink the agentic-surface ratchet asked for (#333) (#4348)

`a82be1633` added `origin: WorkClaimOrigin` to `WorkClaimParams` to preserve
explicit claim intent. The field is right; projecting it was not. `WorkClaimParams`
derives `JsonSchema`, `sdk_codegen` projects it with `schema_for!`, and `work/claim`
is a declared-NATIVE tool — so the field AND its enum definition ride the catalog
that `describe_tool_tokens` measures. The agentic surface went 12027 -> 12210,
past the 12100 ceiling, and painted three PRs red off one shared base, none of
which had touched cognition.

The ceiling's own instruction is "shrink the surface (#333) or state plainly what
was added and re-pin". This is the shrink, and it costs nothing, because the field
could never have been a citizen's to set. Every `Automatic` setter is Rust-internal
and builds `airc_work::ClaimOrigin` directly:

    commands/benchmark.rs:2424, :2440
    persona/work_focus.rs:91

Not one goes through `WorkClaimParams`. So on the wire the field could only ever be
its default. We were spending catalog tokens in every citizen's turn to advertise a
parameter she must never send — and advertising it is precisely how she could have
declared a deliberate claim `automatic` and falsified the provenance the field was
added to preserve.

`#[schemars(skip)]` takes it out of the projection. `#[serde(default)]` keeps an
omitted field `Explicit`, so the wire contract is unchanged, `WorkState` still sets
it explicitly in Rust, and the ts-rs binding is untouched.

The guard goes in `work.rs`, next to the field, not in the cognition ratchet: a
re-add now fails in one crate's fast test instead of in a surface ceiling nobody
reading this file would think to connect to it.

UNVERIFIED: I have not compiled this. The M5 is serving and a cargo build costs it a
lane; CI is the compiler. The test prints `agentic surface: N guard tokens`, so the
run says whether this clears 12100 or how much is left. If it does not fully clear I
will report the remaining number rather than reach for the ceiling.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Opus 5 <[email protected]>

* perf(ci): extract the CLI's platform lifecycle into a crate — 17 tests stop linking 624,456 lines (LNK1140) (#4350)

* perf(ci): extract the CLI's platform lifecycle into a crate — 17 tests stop linking 624,456 lines (LNK1140)

Astra hit `LINK : fatal error LNK1140` building `cargo test --bin continuum` on
Windows 2026-09-22. The tests never ran. The cause is structural, not a linker
setting: five modules lived as `mod` declarations inside the bin, so exercising
17 tests over 2,420 lines of pure functions linked the whole of continuum-core
and emitted a PDB for 624,456 lines.

Nothing here ever needed the core. Checked BEFORE the move, all five had:

    crate:: / continuum_core:: imports        0
    super:: references outside test mods      0

so the boundary already existed by convention. This makes the compiler enforce
it. Every module moved verbatim — `git mv`, no logic touched.

WHAT THIS WIDENS, stated plainly rather than slipped in: 33 `pub(super)` items
and 1 `pub(crate)` became `pub`. Across a crate boundary `pub(super)` means "the
new crate's root", not "the bin", so they were invisible and the extraction could
not compile without it. That is a real loosening — "only my parent may call this"
becomes "anyone in the workspace may". It is the price of the boundary and a
reviewer should weigh it; the alternative is a facade module re-exporting 34
items, which buys the same link cost back in maintenance.

CI GETS THE ACTUAL WIN. The Windows job used to hand-compile ONE of the five:

    rustc --edition 2021 --test .../bin/continuum/owned_engines.rs

Someone reached for standalone rustc precisely because the cargo path was
unusable. That invocation is replaced by `cargo test -p continuum-cli-lifecycle`
— all 17 tests, linked against 2,420 lines. The msvc_cache.rs helper keeps its
own rustc line; it is not part of this crate.

Cargo.lock is NOT updated here: no cargo on this node (the M5 is serving and a
build costs it a lane), and no CI job uses --locked/--frozen, so cargo resolves
the new path dependency on first build.

UNVERIFIED: I have not compiled this. CI is the compiler. The risk is concentrated
in the visibility sweep — if an item was `pub(super)` inside an `impl` or a nested
module the rewrite may have widened more than the boundary needs, and rustc will
say so.

@cormac: this touches the `mod` block in continuum.rs that your `elevated_teardown`
branch also edits. Your module STAYS in the bin (it calls the root's drain by
injection); only these five move. Conflict is the adjacent mod lines and nothing
deeper — flagged before landing, as promised.

Card: Astra's CLI/test separation request, 2026-09-22.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cli-lifecycle): the five real dependencies, the windows gate, and the stale #[path] — all four caught by building it (Astra's review)

Astra reviewed 23bac7e and found what I had not built. Every item is his:

1. `lib.rs` exported `windows_launch` unconditionally. The bin had
   `#[cfg(windows)]` on that `mod` line; the file imports `std::os::windows` and
   `windows_sys`, so the crate could not compile on macOS or Linux. The gate has
   to move WITH the module. He read the file's imports; I had rewritten the line
   without reading the attribute above it.
2. Five stale `#[path = "continuum/*.rs"]` attributes were left sitting on the
   `use` statements my rewrite produced. They belonged to `mod`, not `use`.
3. Cargo.lock was not updated.
4. "Run leaf tests locally, not CI-as-first-compiler."

(4) was the one that mattered, and he was right that my rule was misapplied: the
no-cargo-on-the-M5 rule exists for the 625k-line core. THIS crate is the whole
point of the extraction — a full build+test is SEVEN SECONDS. Running it found
four missing dependencies that CI would have surfaced one round-trip at a time:

    serde_json   supervisor_install, fully-qualified in tests
    libc         launchd.rs:567, geteuid() — unix only
    tempfile     install_cli / supervisor_install tests
    uuid         test-only, unique temp dirs
    tokio        launchd.rs:470 interval, supervisor_install.rs:502/504
                 process::Command + time::timeout — PRODUCTION CODE

My dependency scan read `use` lines. Every one of these is a fully-qualified
path, so the scan could not see them — I measured what was easy to measure
rather than what I was claiming.

CORRECTING MY OWN DESCRIPTION: I called this a "std-only crate", following the
source-hygiene precedent. It is not. It needs tokio (time, process, rt, macros).
The extraction's value is unchanged — tokio is a dependency, not 624,456 lines —
but the claim was wrong and the commit that made it should not stand uncorrected.

ALSO CORRECTED: the test count is 15, not the 17 I have been quoting. I counted
`#[test]` attributes; two are windows-gated and do not run here.

VERIFIED LOCALLY NOW, which the first version was not:

    cargo test -p continuum-cli-lifecycle
    test result: ok. 15 passed; 0 failed; 0 ignored
    7.1s total

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* docs(cli-lifecycle): module docs carry the boundary rationale, not the conversation that produced it (Astra)

A crate's doc comment is permanent API documentation read by whoever touches it
next, not a changelog of the review that shaped it. Names, who-caught-what and
session narrative do not belong there; the INVARIANT does.

Kept: why the crate exists (624,456 lines linked to test 2,420), why nothing here
may depend on continuum-core, and why platform gating lives at the crate boundary
rather than inside the file.

Removed: attribution prose and the account of how the cfg bug was found.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cli-lifecycle): declare Windows scheduling clock dependency

---------

Co-authored-by: Claude Opus 5 <[email protected]>

* fix(deploy): gate the macOS import, drop the unused one (#4351)

* fix(deploy): the teardown, whole — ordering wired, decision in the leaf, tests once

A previous head landed the decision module on this base and nothing called it:
440 lines of installer wiring lived on the older branch and were never carried
across. The module was correct, its tests were real, and the code under test was
reachable from nothing. This carries both halves onto one base.

THE ORDERING, unchanged from review and now actually wired:
  preflight the teardown authority BEFORE the drain, over the union of the
  pidfile's claim and every core in the process table — the pidfile is absent on
  the node this exists for while its core still answers;
  `request_graceful_stop` takes a `MayDrain` only the preflight produces, so a
  deleted preflight does not weaken a test, it stops compiling;
  the slot write moved AFTER the stop — you cannot overwrite a slot a process is
  executing from, and staging first is what made the recovery unreachable on the
  one node that needs it;
  a refused kill keeps the pidfile and refuses the handoff, proven on the bounded
  deadline rather than an immediate probe;
  Windows absence (ERROR_INVALID_PARAMETER) is absence, not refusal.

THE DECISION LIVES IN THE LEAF, where it runs on any machine in seconds:
  `continuum_cli_lifecycle::elevated_teardown` — TeardownPlan, the digest gate,
  target_is_our_core, HeldCapability + teardown_sequence, elevation_outcome,
  StopOptions, and every fixture. 24 leaf tests pass in 2.5s warm; as bin modules
  the same assertions were a 60-minute link here and LNK1140 on Windows.

THE OS AUTHORITY STAYS IN THE BIN behind one cfg at the mod line: the single
QUERY|TERMINATE handle, the image read through it, terminate, teardown_elevated,
request_elevated_teardown. The root keeps the installer entry and supplies the
drain — injecting it is what let the decision leave at all.

Includes the `PreparedCoreService::query` fix, which only a Windows build could
find: the call is cfg(windows), so no macOS check ever compiled it.

TESTS EXIST ONCE. The pre-move copies are not carried; two copies of a fixture
drift, and the stale one is the one nobody runs.

Receipts: leaf 24/24; cargo check --bin continuum clean.
Still unvalidated anywhere: real UAC recovery and the OS-authority half.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(cli): report executable version without a running core

* fix(deploy): gate the macOS import, drop the unused one

Two from review of the combined head.

1. target_is_our_core was imported into the bin half and never called there —
   teardown_sequence calls it inside the leaf. The import was left over from
   before the split.

2. launchd is the macOS supervisor arm and every call site is already
   cfg(target_os = "macos"); the import was not, so a Windows or Linux build
   carried an unused import. Gated rather than allowed: a blanket allow on this
   block would also hide the NEXT one.

bin warnings 3 -> 1, and the remaining one is a pre-existing ts-rs serde-attribute
parse notice in the lib, not from this change. Leaf 24/24 unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(deploy): justify the four production unwraps the ratchet named

The source-hygiene ratchet went 2257 -> 2261. All four are mine and all four
are in the teardown split; each now carries the same-line reason the ratchet
asks for:

  the short-digest display     — a truncated digest is still a digest
  the image basename           — rsplit always yields once; this is the
                                 no-separator case, where the whole string IS
                                 the name
  the recorded image digest    — RECORDED, never compared, so an unreadable
                                 image must not block an otherwise-proven
                                 teardown
  the elevated child's receipt — an absent receipt is reported as "none"
                                 below, never as success

The last one had its justification in the pre-split file and lost it when the
module was divided; a same-line comment does not survive a line being moved
between files unless you carry it deliberately.

Receipts: cargo test -p source-hygiene 27/27 in 9.9s — the fast crate #4350
extracted, which is why this took ten seconds instead of a CI round trip.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

* Clarify author and reviewer work tool contracts

* chore(warnings): five test-only imports move into their test mods — no deletions, no allows (#4347)

Joel asked for the straightforward warnings cleaned up. These five are the
unambiguous subset: an import used ONLY inside `#[cfg(test)] mod tests`, sitting at
module top level, so the non-test build correctly reports it unused.

The fix is a MOVE, not a deletion. Each import is still there, just scoped to the
code that uses it:

  persona/profile_builder.rs      std::sync::Arc          (uses 254, 262, 306; cfg(test) 217)
  persona/room_doctrine_source.rs airc_core::PeerId       (uses 466, 502; cfg(test) 447)
  persona/spawner.rs              std::sync::Arc          (uses 136, 179; cfg(test) 110)
  routing/grid_capability.rs      airc_core::PeerId       (uses 269+; cfg(test) 244)
  resources/ceiling_prior.rs      Provenance              (uses 138+; cfg(test) 116)

`ceiling_prior` is the one that is not a straight move: the import was
`{FootprintReading, Provenance}` and only Provenance is test-only. FootprintReading
stays at module level (used at 92, 94); Provenance moves, needing the explicit
`super::super::footprint_source::` path because `use super::*` no longer carries it.

METHOD, because it nearly went wrong. The first pass paired warning text to
file:line with `grep -A2` and mismatched them — a textual check then said all four
candidate imports were still USED, which would have meant deleting live code. The
pairing was redone so each warning binds to its OWN `-->` line, and then EVERY site
was confirmed by reading the file: where the `#[cfg(test)]` boundary sits, and
whether the symbol's uses fall after it.

A heuristic classifier written for the remaining sites produced contradictions on the
first run (reporting the import line itself as a production use, and claiming
`docker_tier` uses were production while the compiler said unused). It is not trusted
and not used. Only sites verified by direct reading are in this commit.

NOT DONE, deliberately, and left for individual review rather than bulk-edited on a
heuristic: handle_module.rs, docker_tier.rs, share_controller.rs, experience/source.rs,
service_loop.rs, airc_event_transport.rs, ort_providers.rs (needless `mut`), and the
whole `live/video/bevy_renderer/*` group (12 sites). Several of those are behind
feature gates or are plausibly public re-exports, which Astra explicitly warned
against deleting blindly.

No blanket `#[allow]`, no baseline change, no `cargo fix` sweep. The warning ratchet
baseline stays at 75; this can only lower the count.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Opus 5 <[email protected]>

* probe(cognition): sample the drain's competitor BEFORE the drain, not only at it (card 608875a2) (#4349)

`turn_ingress::in_flight()` decides whether a stop tears a citizen mid-thought. Until now
it was read in exactly two places, both inside `drain()` — so the depth was reported only
at the moment the drain gave up on it, and never before.

That left the question the receipts raise unanswerable. Measured 2026-09-22:

    M5        89 deploys, 76 tearing, 0 clean drains, 432 turns cut
    IntelMac   8 deploys,  7 tearing, 1 clean drain at 1398ms (inside the 1800ms budget)

Cormac's second node is what makes this worth instrumenting rather than guessing: a clean
drain IS reachable, so "the bound cannot be met" is false in its strong form — it cannot be
met WITH TURNS IN FLIGHT. Those two populations want different fixes (a longer bound buys a
node that sometimes idles and buys nothing for one that never does), and nothing in the
tree could tell them apart.

This rides cognition's EXISTING 15s tick: no new task, no new cadence, no new concern — a
`probe!` on a timer that is already ticking, which is what RTOS-DEBUGGER-PROBES asks for at
a load-bearing seam.

SCOPE, stated at the call site so the number is not over-read: this is the SERVICE-LOOP
depth. `cognition/eval` calls the faculties directly and runs UNCOUNTED per `turn_ingress`'s
own contract, so 0 means "no citizen turn", not "nothing executing".

NO TEST, deliberately. `probe!` is a `tracing::event!`; asserting it fired would capture a
subscriber to test the macro, and this repo refuses tests that assert trivia. The probe's
failure mode is "no data appears", which is self-evident on the first query of the class —
and that query is the next step on the card.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Opus 5 <[email protected]>

* Resolve short shell handles within the owning session (#4353)

* Resolve short shell handles within the owning session

* Keep work tool guidance within the existing surface budget

* Regenerate work parameter documentation bindings

* fix(training): the settle path's one untraced exit now names itself (f1771c83) (#4354)

* fix(training): the settle path's one untraced exit now names itself (card f1771c83)

`staged_submission_params` returned `Option`, and `None` skipped a staged revision
with NO probe anywhere. Every other exit on that path emits one. So a citizen's
credit could sit unsettled forever and the only evidence was a row that never moved.

Found while measuring Gate 2 on the M5: 728 `staged_credit` rows across 8 resident
personas, 12 `credit_transfer_intent`, and **0** `credit_transfer_acceptance` — not
one learning credit has ever completed an ownership transfer on this node. Chasing
which of them were silently skipped was impossible, because the skip left nothing.

The function now returns `Result<Value, &'static str>` and every refusal names
itself: a FAIL verdict (a normal discard, not a defect), no claim_id, no owner, an
owner that is a different persona, no role, no served provenance in the receipts, and
no training plan. `settle_staged_row` emits `training.credit.settle_ineligible` with
the reason, the card and the revision.

No behaviour change: every arm that returned `None` still returns `Ok(false)` and
still retains the row. The turn that already happened is never touched. The only
difference is that a stalled credit is now readable instead of invisible.

Naming them separately matters because they are not the same kind of thing. "This
card failed" is the system working. "This row has no served provenance" cannot be
fixed by retrying and is the one worth chasing. A reader who cannot tell them apart
learns nothing from either.

Tests assert the reasons are DISTINGUISHABLE, so collapsing them back into one
silent `None` — or one catch-all string — fails.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(training): the SECOND caller — my search was scoped to the file, not the module

CI caught a compile error I should have caught: `reviewed.rs:518` also calls
`staged_submission_params` and still destructured an `Option`.

The cause is mine and it is a rule I carry: I grepped `training_producer.rs`, the
FILE, when the function lives in a module with a `training_producer/` directory
beside it. A submodule reaches a parent-private item through `super::`, so scoping
the search to one file could never have found it. Searching the tree finds both
callers in one command.

That path is not the silent one this PR is about — it already set
`ReviewedCreditState::IneligibleEvidence`, a named state. What it could not do was
say WHY. It now emits `training.credit.reviewed_ineligible` with the same named
reason, so both callers report the cause and neither changes behaviour.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5 <[email protected]>

* fix(cognition): a tool's own verdict decides the tick — stop rendering ✓ for a command that failed (f6c50a49) (#4352)

* fix(cognition): a tool's own verdict decides the tick — stop rendering ✓ for a command that failed (card f6c50a49)

`is_error` was set ONLY on the transport `Err` arm of the executor. A handler
that returns its failure AS DATA takes the `Ok` arm, so `code/run` reporting
`ok: false` with the compiler's stderr, and `code/shell` reporting a nonzero
exit, both rendered a success tick — to the room glyph, to the persona:act
receipt, and to `Observation::is_err()`, which is what the mind reads back out
of its own working memory. A citizen could fail all night and see six ✓.

The fix is a typed projection at the command's own boundary, not a JSON scan:

- `ToolVerdict { Succeeded, Failed, Running }` + a `ProjectsOutcome` trait whose
  `DeserializeOwned` bound lands on the OPT-IN, never on `ActionCommand::Output`
  — so no other command pays a new bound.
- `register_outcome!(Cmd)` submits a projector to an `inventory` keyed by the
  command's own `NAME`. A command that does not opt in projects nothing and
  keeps byte-for-byte its old behaviour.
- `code/run` reads its declared `ok`. `code/shell` and `code/shell-poll` read
  their declared `ShellExecutionStatus` — the status `shell_session` already
  computes from `ExitStatus::success()`. No key guessing: every field read is
  one the command declares and documents.
- The lookup resolves through `tool_dialect::resolve_wire_name`, the SAME seam
  `runtime::route_command` uses, so a model calling `bash` or `code_run` hits
  the projector instead of silently missing it.

stderr and nonzero shell output still reach the model verbatim; only the outcome
marker changes — the traceback she needs to self-correct is untouched.

NOT fixed here, and explicit in the code rather than swept into a wildcard:
`Running`. `is_error` is a bool, so an ACCEPTED-but-unfinished shell still
renders as it does today. Saying "running" needs a carrier `ai::types::ToolResult`
does not have — 65 struct literals construct it, 42 in one file — and the honest
home is `ToolOutput`, the act seam that already exists to precompute this for
consumers. That is the follow-up, not a freebie.

Six tests pin the projection, including that an undecodable payload yields NO
verdict rather than a manufactured failure, and that execute and poll cannot
disagree about the same execution.

UNVERIFIED locally: this touches continuum-core and the M5 is serving, so CI is
the compiler.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(sdk_codegen): restore register_command's #[macro_export] — my insertion split the attribute from its macro

CI caught it: `cannot find register_command in the crate root`, at every
`crate::register_command!` site in the crate.

The cause was my own edit, not the design. I anchored the new `register_outcome!`
block on `register_command`'s DOC COMMENT, so it landed between that macro's
`#[macro_export]` and its `macro_rules!` body:

    /// Self-register a `CommandSpec` ...   <- register_command's doc
    #[macro_export]                          <- register_command's attribute
    /// Opt a command into TRUTHFUL ...      <- inserted doc
    #[macro_export]                          <- inserted attribute
    macro_rules! register_outcome { ... }    <- absorbed BOTH attributes
    macro_rules! register_command { ... }    <- left with NONE

`register_outcome` was exported twice and `register_command` not at all.

Fix: `register_outcome!` moves below `register_command!` in full, each macro
again directly preceded by its own doc + attribute. Both are `#[macro_export]`,
so declaration order does not affect `$crate::` resolution. No behaviour change
to either macro.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): three states, not two — a verdict the receipt can actually say (Astra's review of #4352)

Astra requested changes. All three are taken, and the sharpest one was right
about a test I wrote: `an_undecodable_payload_yields_no_verdict_rather_than_a_failure`
CODIFIED the fallback instead of guarding against it.

1. A REGISTERED PROJECTOR THAT CANNOT DECODE ITS OWN OUTPUT IS NOT "NO PROJECTOR".
   Collapsing both into `None` meant schema drift rendered as a success tick — the
   exact defect this PR exists to fix, one layer up. `ActVerdict` is now three
   states: `Unprojected` (never opted in — byte-for-byte the old behaviour),
   `Declared(ToolVerdict)`, and `Undecodable`, which emits a
   `tool.call.outcome_undecodable` probe, preserves the payload, and claims
   nothing. The test that blessed the old behaviour is replaced by one that
   asserts `Undecodable != Unprojected`.

2. THE TYPED CARRIER REACHES THE CONSUMERS.
   `NativeBatchOutcome.verdicts` carries one `CallVerdict` per call, keyed by
   `tool_use_id` (never by position), to `ToolOutput.verdict` — the act seam whose
   own doc says it exists so "no consumer re-derives from prose". Carried there and
   not on `ai::types::ToolResult`, which has 65 construction sites and whose
   `is_error` bool cannot express *running* or *undecodable* at all.
   - Derived BEFORE `fold_with_recovery`, from the full value. Ordering is now the
     contract rather than an accident.
   - `presence_glyph::act_line` takes the verdict and has four marks: ✓ ✗ ⋯ ·
     A still-running shell no longer prints a tick.
   - `PersonaActUpdate` GAINS `state` rather than redefining `ok`, so the desktop
     that already consumes `ok` is not silently handed a new meaning.
   - `Observation::is_err()` — the third consumer, which feeds the mind's own
     recency channel — now honours the command's verdict.

3. THE re-PARSE IS GONE, WITH BOTH ITS BUGS.
   `apply.rs` used to recover the shell's running handle by parsing
   `ShellExecuteResponse` out of the result TEXT and matching
   `call.name.replace('_', "/") == "code/shell"`. That missed every call made
   through the declared alias `bash`, and it parsed the FOLDED preview, so a
   flood-sized result stopped decoding. The command now DECLARES its handle
   (`ProjectsOutcome::dispatch_handle`) and the executor decodes it once, from the
   pre-fold value, alongside the verdict. Long calls still register and still
   receive completion.

Tests: projector-level (including that the lookup is by CANONICAL name, so `bash`
and `code_run` resolve), plus consumer-level in `observation.rs` and
`presence_glyph.rs` — a declared failure reads as an error though the transport was
fine, a running act is neither error nor success, an undecodable result claims
neither, an unprojected command is unchanged, and marking a failure does not touch
the stderr the model needs to self-correct.

KNOWN INHERITED RED, not from this change: the agentic-surface ratchet reports
12147 vs ceiling 12100, and the ts-rs drift detector fails. #4353 — a disjoint
change on the same base — reports the IDENTICAL 12147, so both are the base's.
Traced to 14db974 on integration/recovery, which lengthened four citizen-facing
`work/*` descriptions. Those are the right change; the ceiling needs re-pinning in
its own PR with the addition named. Not done here and not silently absorbed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(hygiene): justify the one unwrap this change adds — the ratchet rose 2257 → 2258

`unwrap_or_default()` on a missing CallVerdict is not a swallowed error: absence
of a record means the command never opted in (or a test double built the batch),
and `Unprojected` is the correct answer there — never a failure. Same-line
justification, which is the scan's contract.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(cognition): the RECALL channel said "ok" for work that had not finished (Astra's 2nd review of #4352)

Three from the review, one of them a real bug I missed.

1. THE BUG. `render_act_for_recall` took a bare `is_err: bool`, so its COLLAPSE
   branch printed `"ok — {first line}"` for anything not flagged an error — which
   after this PR includes `Running` and `Undecodable`. It now takes the verdict and
   prints `running —` / `unreadable —`, with `⋯` as its own mark.

   This is the worst place the defect could have survived. The recall channel is what
   the Episodic engram re-injects turn after turn — it is the mind reading its OWN
   past — so a still-running shell remembered as "ok" is worse than the room glyph
   being wrong. Only a LONG body takes that branch (a short one quotes itself
   verbatim and asserts nothing), which is why the regression test builds a 400-char
   body; a short-body test would have passed while the bug stood.

2. THE MACRO DECODED TWICE while its comment claimed once. `OutcomeProjector` now
   holds ONE fn pointer returning `(ActVerdict, Option<Uuid>)`, because both facts
   come from the same `Output`. The comment and the code agree now.

3. EXECUTOR→RECEIPT TESTS, which is what the review actually asked for: constructing
   an `Observation` by hand proves the MAPPING and nothing about the WIRING. Four new
   tests dispatch through the real `execute_native_batch`:
   - a failure returned as DATA comes back `is_error: Some(true)` AND keeps its
     compiler stderr through the fold
   - a running call carries `Running` and its command-declared handle, with
     `is_error` still None (not-finished is not failed)
   - a call made through a declared ALIAS still reaches its own command's projector
   - a command that never opted in is untouched

   The probe command is declared in the test module rather than reusing `code/run`,
   because `code/run` spawns a real interpreter and a CI box without one would make
   the test a coin toss.

At the previous head all 12 projector/consumer tests passed and the lib run was
8408 passed / 1 failed — the one failure being the inherited agentic-surface ceiling
(12147 vs 12100), which is the base's and is card d0d1f8a7.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* test(cognition): the changed handoff, under all three conditions at once (Astra's 3rd review of #4352)

Astra: a batch-only test with a small body under an 8000-char budget cannot
protect the handoff this PR changed. He is right — my executor tests never
FOLD, and the fold is where the old path died.

The new `apply_act` test forces all three conditions that broke the old seam,
simultaneously:

  - the call arrives through the declared ALIAS `bash`, not `code/shell`
  - the result is still RUNNING
  - the body is a head-truncated preview that genuinely does NOT parse

The old code recovered the handle with
`serde_json::from_str::<ShellExecuteResponse>(&typed_result.content)` behind
`call.name.replace('_', "/") == "code/shell"`. Each half fails here on its own:
`bash` never matched the name test, and a folded preview does not deserialize.

The test asserts the handle still registers in working memory — the half that
used to require a successful re-parse, and without which a finished build never
lands in her working memory — and then asserts the fixture's body really is
unparseable, so the test cannot quietly stop proving anything if the fold shape
changes.

`CallVerdict` is re-exported from `tool_executor` alongside `NativeBatchOutcome`
so a test double can build one without reaching into the private module path.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(test): the test double was missing a REQUIRED trait method

`ToolExecutor::store_outcome` is declared with a semicolon and no default body,
so every implementor must provide it. My `FoldedRunningExecutor` implemented
only `execute_native_batch` and `parse_response`.

Diagnosed from the trait definition rather than the CI log — the job log came
back truncated through the API, but the discriminator was cheap: the lib built
(the doc job passed) while the lib TEST build failed, which puts the error in
test-only code, and the only test-only code this head added was that double.
Every other `ToolExecutor` double in the file implements all three methods;
mine implemented two.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant