Repository navigation
Fix: timeout=0 fell through || operator — Academy 600s death - #460
Conversation
The JavaScript || operator treats 0 as falsy, so timeout=0 ("no timeout")
fell through to undefined, and Rust defaulted to 600s. This is why every
Academy session died at exactly 10 minutes.
Fix: || → ?? (nullish coalescing). timeout=0 now passes through correctly.
This is the CLAUDE.md rule: "never code fallbacks. 100% of claude fallbacks
fire 100% of the time."
There was a problem hiding this comment.
Pull request overview
Fixes a production-impacting bug where timeout=0 (intended to mean “no timeout”) was treated as falsy by ||, causing the Rust sentinel executor to fall back to its default 600s timeout and killing long-running Academy sessions at ~10 minutes.
Changes:
- Replace
||with??when selectingtimeoutSecsso0is preserved. - Add an inline comment documenting why
??is required fortimeout=0.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const asyncMode = runParams.async !== false; | ||
|
|
||
| // Use ?? not || — timeout=0 means "no timeout", but || treats 0 as falsy | ||
| const timeoutSecs = runParams.timeout |
There was a problem hiding this comment.
runParams.timeout is passed through as timeoutSecs and forwarded to Rust as timeout (Rust bindings document this value as seconds). However SentinelRunParams.timeout is currently documented as milliseconds in src/commands/sentinel/run/shared/SentinelRunTypes.ts. Please align units to avoid callers passing ms and accidentally extending/shortening timeouts (either convert ms→secs here, or update/rename the command param + docs to explicitly be seconds).
| const timeoutSecs = runParams.timeout | |
| // NOTE: SentinelRunParams.timeout is documented as milliseconds; convert to seconds here. | |
| const timeoutMs = runParams.timeout; | |
| const timeoutSecs = (typeof timeoutMs === 'number' | |
| ? timeoutMs / 1000 | |
| : undefined) |
…d both (#460) Deployed 2281e8b, watched the first real turns, and the sensor stayed silent through the exact condition it was written for. Both holes are mine. HOLE 1 — strict `>` against a population with NO salience spread. Live rows: Atlas budget=89 kept: roster(0.90), room-kanban(0.90) dropped: workspace-map(0.90) Benchy budget=102 kept: room-board(0.90) dropped: workspace-map(0.90), room-kanban(0.90) Kira budget=517 kept: workspace-map(0.90) EVERY essential source bids exactly 0.90, so `0.90 > 0.90` is false and nothing fired. My premise — "ranking cannot drop a 0.90 while keeping a 0.30" — is TRUE and VACUOUS: production has no 0.30 at this tier. What actually decides who survives is arrival order and byte size, a coin flip among equals, and losing the repo map to that flip is the entire harm. `>=` is the honest predicate; a real ranking success (0.30 dropped, 0.90 kept) still cannot fire it. HOLE 2, worse — TOTAL starvation was invisible. `min_by` over an EMPTY `selected` yields `None`, the `if let` fell through, nothing fired. The one state where the citizen gets NO grounding at all was the one state the sensor could not report. That is [[an-absence-is-an-unfinished-measurement]] — in the instrument built to end exactly that, written by me, on the same day I filed two other cards about the same shape. Now `None` is treated as maximal harm, and the probe carries a `verdict` naming which of the three cases fired (TOTAL / TIE / true inversion) plus `kept_count`. THE FINDING UNDERNEATH, bigger than the bug: SALIENCE IS NOT DISCRIMINATING. Every source bids 0.90, so attention ranking contributes nothing to the drop decision at this tier — size and order do all the work. Any future fix that tries to "respect salience" is tuning a dial that is already pinned. Noted on #460; not addressed here. The test used a constructed 0.30 for the low-salience keeper, which is why it passed against a sensor that could not fire in production. It now uses the LIVE shape (all 0.90) and cites the rows it came from. Also fixed: `tool_tokens` was interpolated into the probe message while only existing as a probe FIELD assignment, not a binding — compile error, caught before push. All 22 prompt_shaping tests green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…#460) CI red on `the_unjustified_unwrap_count_never_rises`: 2270 vs baseline 2267. Three, all mine, all in the sensor added by this branch. The ratchet is right and the fix is to state WHY each is safe on its own line — not to raise the baseline. Two are `partial_cmp(...).unwrap_or(Ordering::Equal)` in a max_by/min_by over f32 salience. `partial_cmp` returns None only for NaN. A NaN salience would be an upstream bug, and the thing being written here is the instrument that exists to REPORT budget pathology — it must survive a malformed input long enough to say so, not panic inside the sensor and take the turn with it. The third is the case the ratchet's own doc singles out — `cheapest_kept.unwrap_or(-1.0)` on a probe field, an Option becoming a quantity. It survives on a distinction worth writing down: `None` here is a KNOWN state ("nothing survived the budget"), not an unknown one. The doc's warning is about unknown-turned-quantity, which is how the Metal free-VRAM lie happened. Salience is [0,1], so -1.0 is out of domain and cannot be misread as a real salience, and `verdict` already carries the state in words. Commented in full at the site so the next reader gets the distinction, not just the exemption. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
* fix(cognition): a top-salience block can vanish whole and nothing says so (#460) MEASURED live 2026-08-20, 25 consecutive delib turns across Atlas, Kira and Joaquin. On a 22,528 served window, identical every turn: completion_reserve 11,264 50.0% (window/2, COMPLETION_SHARE_DENOM = 2) tool schemas 7,013 31.1% (constant on all 25) framing 2,757-3,081 ~13.7% grounding 62-1,083 <1%-4.8% (median ~290; Atlas often 62-183) `workspace-map` (salience 0.90, the top tier) was dropped WHOLE on 20 of the 25. `mission` on 11. Demand ran 1.03x-2.48x the window on every turn. The workspace-map is the map of the files she is staged to edit. Atlas held claim-df9f4ad5 on pallets__flask-4045 with acts=0 and a checkout untouched since Aug 17 — three days. She could not see the repo. That is not write-avoidance (#390) and not model weakness: 0 acts is the correct response to 183 tokens of situational context. WHY NOTHING CAUGHT IT. `min_window_for_agentic_surface` is the sensor for this seam and it was correctly SILENT — 22,528 clears its ~16.9k bound. Its own doc says exactly why that proves nothing: "Necessary, NOT sufficient — clearing it does not mean she can hear you… never 'you are fine above it'", and it even names the mechanism, that a real turn's framing exceeds the bare floor "and context is what yields". The failure was written down before it happened. What was missing is a SUFFICIENCY sensor. THE SIGNAL, with no invented threshold. Contributions are taken highest-salience-FIRST, so ranking alone can never drop a 0.90 while keeping a 0.30. When that happens it is the SIZE interaction: a big essential block did not fit, then a small unimportant one did. The budget bought the cheap thing and lost the important one. `delib.context.salience_inversion` reports exactly that — a structural fact, not a tuned constant that would be a snapshot of one day's salience values. Divisible blocks are deliberately excluded: a prefix-truncated list announces itself in-prompt ("…N more not shown"), so it is degraded but never silent. Only WHOLE drops vanish without a trace. SENSOR, never a clamp — amputating the tool surface to make room is the deleted #206 cliff (14/14 SWE acts were `commands/help`, 0 edits). It reports; the budget fix is #460 and is not a decision this function may make. ALSO: deleted a sentence that was actively lying. `describe_tool_tokens`'s doc said "a single tiny schema… a handful of tokens, not the old full-registry dump" — true of the two-tool discovery pair, false since #206. The probe site 700 lines away has called it out as stale since 2026-08-06 ("reading that stale sentence is exactly why the right suspect got dismissed") but nobody deleted it from the function itself, so anyone reading the function still got the lie. It cost me a wrong mechanism on #459 earlier today. Replaced with the measurement (4,609 on 08-06 -> 7,013 on 08-20, +52%) and with why it grows unwatched: `native_tool_specs` is derived from `NATIVE = true`, so the per-turn cost of the tool surface is an unbounded side effect of a flag set in another file. Test pins the inversion AND the premise underneath it — that selection is highest-salience-first. If that ordering is ever lost the probe silently becomes noise; this makes that regression loud. All 22 prompt_shaping tests green, including the four load-bearing ones. De-hardcode guard green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * fix(cognition): the sensor had TWO holes and the FIRST live turn found both (#460) Deployed 2281e8b, watched the first real turns, and the sensor stayed silent through the exact condition it was written for. Both holes are mine. HOLE 1 — strict `>` against a population with NO salience spread. Live rows: Atlas budget=89 kept: roster(0.90), room-kanban(0.90) dropped: workspace-map(0.90) Benchy budget=102 kept: room-board(0.90) dropped: workspace-map(0.90), room-kanban(0.90) Kira budget=517 kept: workspace-map(0.90) EVERY essential source bids exactly 0.90, so `0.90 > 0.90` is false and nothing fired. My premise — "ranking cannot drop a 0.90 while keeping a 0.30" — is TRUE and VACUOUS: production has no 0.30 at this tier. What actually decides who survives is arrival order and byte size, a coin flip among equals, and losing the repo map to that flip is the entire harm. `>=` is the honest predicate; a real ranking success (0.30 dropped, 0.90 kept) still cannot fire it. HOLE 2, worse — TOTAL starvation was invisible. `min_by` over an EMPTY `selected` yields `None`, the `if let` fell through, nothing fired. The one state where the citizen gets NO grounding at all was the one state the sensor could not report. That is [[an-absence-is-an-unfinished-measurement]] — in the instrument built to end exactly that, written by me, on the same day I filed two other cards about the same shape. Now `None` is treated as maximal harm, and the probe carries a `verdict` naming which of the three cases fired (TOTAL / TIE / true inversion) plus `kept_count`. THE FINDING UNDERNEATH, bigger than the bug: SALIENCE IS NOT DISCRIMINATING. Every source bids 0.90, so attention ranking contributes nothing to the drop decision at this tier — size and order do all the work. Any future fix that tries to "respect salience" is tuning a dial that is already pinned. Noted on #460; not addressed here. The test used a constructed 0.30 for the low-salience keeper, which is why it passed against a sensor that could not fire in production. It now uses the LIVE shape (all 0.90) and cites the rows it came from. Also fixed: `tool_tokens` was interpolated into the probe message while only existing as a probe FIELD assignment, not a binding — compile error, caught before push. All 22 prompt_shaping tests green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo * fix(cognition): justify the three unwraps the starvation sensor added (#460) CI red on `the_unjustified_unwrap_count_never_rises`: 2270 vs baseline 2267. Three, all mine, all in the sensor added by this branch. The ratchet is right and the fix is to state WHY each is safe on its own line — not to raise the baseline. Two are `partial_cmp(...).unwrap_or(Ordering::Equal)` in a max_by/min_by over f32 salience. `partial_cmp` returns None only for NaN. A NaN salience would be an upstream bug, and the thing being written here is the instrument that exists to REPORT budget pathology — it must survive a malformed input long enough to say so, not panic inside the sensor and take the turn with it. The third is the case the ratchet's own doc singles out — `cheapest_kept.unwrap_or(-1.0)` on a probe field, an Option becoming a quantity. It survives on a distinction worth writing down: `None` here is a KNOWN state ("nothing survived the budget"), not an unknown one. The doc's warning is about unknown-turned-quantity, which is how the Metal free-VRAM lie happened. Salience is [0,1], so -1.0 is out of domain and cannot be misread as a real salience, and `verdict` already carries the state in words. Commented in full at the site so the next reader gets the distinction, not just the exemption. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
The || operator treats 0 as falsy. timeout=0 became undefined, Rust defaulted to 600s. Every Academy session died at 10 minutes. Fix: use ?? instead of ||.