Repository navigation
fix(cognition): prove grounding-deferral by control flow, not by a stopwatch - #2330
Merged
Merged
Conversation
…opwatch `deferring_grounding_removes_its_deliver_cost_from_the_critical_path` asserted `deferred_critical_path < 30ms` on a LIVE cognition cycle. `FacultyTiming.elapsed_us` is real wall clock and, by its own doc, "includes scheduling waits" — so under `cargo test`'s parallelism the number measures the runner, not grounding. On PR #2329's CI (a changed-file set that never touches this module) the deferred fork clocked 99,798µs against the synchronous fork's 62,427µs: the fork that pays NO grounding cost measured HIGHER than the one that pays a 60ms deliver. That is arithmetically impossible for a grounding measurement and can only be scheduler stall — the run had a 60s+ CPU-hog test executing alongside it. Solo locally the same fork reads 784µs. The code was never wrong; the assertion was unfalsifiable. The invariant is structural, not temporal — `DeferredFaculty::contribute` returns reprojected last-good and never awaits the inner faculty on a warm ambient tick — so it is now proven that way, split into its two honest halves: * Structural (persona_workspace.rs): `SlowGrounding`'s sleep becomes `GatedGrounding`, whose `deliver()` parks until the TEST opens a gate. With the gate held shut the deferred fork's warm tick must still COMPLETE (only possible by serving last-good), while the synchronous fork's warm tick must run INTO deliver and park there — the control that makes the completion mean something. A future parked on a shut gate cannot complete however loaded the machine is, so neither assertion has a timing tolerance to blow. The two remaining timeouts are 30s liveness bounds that only fire on a genuine hang, never perf thresholds. * Cost (workspace_dashboard.rs): the `max(perception) + max(deliberation)` barrier arithmetic is extracted into a pure `critical_path_us(&[FacultyTiming])` and table-tested with the timings as parameters — including that the barrier is a MAX, so a second slow perception faculty means deferral is correctly credited nothing. Same shape as the pure verdict fns in `inference/llama_server.rs`. Verified with teeth: mutating the deferred fork back onto the barrier fails with the intended diagnostic. Full lib suite green twice (7194 passed, 0 failed). The test also drops from 450ms to ~10ms — the sleeps it needed are gone with the stopwatch. Also removes a pre-existing unused `ToolExecutor` import in the file (boy-scout). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
added a commit
that referenced
this pull request
Aug 16, 2026
…im (evaluator <10ms flake) (#2333) `test_all_gates_pass_normal_message` failed CI at 10.72971ms against a hardcoded `decision_time_ms < 10.0`. The gates did not regress — the runner was busy. It is red on PR #2331, whose diff is CI workflow config and cannot possibly have touched persona gating. A correctness test that a loaded machine can fail is not measuring the code, it is measuring the machine. Worse, it spends the reviewer's trust every time it flakes: the next red is assumed to be noise, and eventually a real one is. The performance claim is real and worth keeping, so it is NOT deleted — it MOVES to a `#[cfg(feature = "stress-tests")]` block (CLAUDE.md § test rules, item 2), where default `cargo test` does not run it and a quiet machine can. The stress version also takes the MEDIAN of 50 runs instead of trusting one sample, since a single timing of a live system is not a fact about it — one scheduler hiccup is not a regression. The correctness test keeps its correctness assertion (`should_respond`) and now asserts nothing about the clock. Same treatment as the grounding-cost flake in PR #2330 — second instance of this class, so it is a missing constraint, not two bugs. Surveyed the rest of the tree: 3 siblings exist (command_executor <500ms, rag/engine <250ms, sentinel/parallel <180ms). Deliberately NOT touched — none is failing and each has 20-50x more headroom than the 10ms budget that broke. Named in a comment at the fix site so the next person has the map instead of rediscovering it. cargo test persona::evaluator: 33 passed, 0 failed. cargo check --features stress-tests --profile test: clean (the gated block builds). Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo Co-authored-by: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The failure
PR #2329 was CI-red on exactly one test —
cognition::persona_workspace::tests::deferring_grounding_removes_its_deliver_cost_from_the_critical_path— despite that PR's only changed file beingcognition/swe_bench.rs, which does not touch this module.Root cause: the assertion was unfalsifiable, not the code
The test asserted
deferred_critical_path < 30mson a live cognition cycle.critical_path_usis built fromFacultyTiming.elapsed_us, which is real wall clock and by its own doc "includes scheduling waits, which is honest: it's the latency the barrier actually saw". Undercargo test's parallelism that number measures the runner, not grounding.The CI numbers prove it rather than merely suggesting it:
defer_grounding=false(pays a 60ms deliver)defer_grounding=true(pays none)The fork that pays no grounding cost measured higher than the one that pays 60ms. That is impossible for a grounding measurement — it can only be scheduler stall, and the same run has
capacity::trace_tail::tests::k3_fixture_measured_schedulable_coveragelogging "has been running for over 60 seconds" concurrently. Solo on this machine the same fork reads 784µs, ~127× under the CI value.So: class (a) — non-deterministic by construction. The production path is correct;
DeferredFaculty::contributereturns reprojected last-good and never awaits the inner faculty on a warm ambient tick (deferred_faculty.rs, thereturn servedbranch). The invariant is control flow, and it was being probed with a stopwatch.The fix — split into its two honest halves, both clock-free
Structural (
persona_workspace.rs):SlowGrounding'ssleepbecomesGatedGrounding, whosedeliver()parks until the test opens a gate. With the gate held shut:deliver();deliver()and park there — the control that makes the completion above evidence of anything.A future parked on a shut gate cannot complete no matter how loaded the machine is, so neither assertion has a timing tolerance to blow. The two remaining
timeouts are 30s liveness bounds that only fire on a genuine hang — never perf thresholds. (One real bug found while building this:watch::Sender::sendsilently leaves the value unchanged when no receiver is parked, which made the gate a no-op;send_replaceis the repo idiom, asDashboardCaptureSinkalready documents.)Cost (
workspace_dashboard.rs): themax(perception) + max(deliberation)barrier arithmetic is lifted out ofrecord()into a purecritical_path_us(&[FacultyTiming])and table-tested with the timings as parameters — including that the barrier is a MAX, so a second slow perception faculty means deferral is correctly credited nothing. Same shape as the pure verdict fns ininference/llama_server.rs.Verification
cargo test -p continuum-core --lib --features metal,accelerate: 7194 passed, 0 failed — twice.cargo check --all-targetsclean; no new warnings (one pre-existing unusedToolExecutorimport removed, boy-scout).No
#[ignore], no loosened threshold, no retry, no new test mod (both tests extend the existingmod testsin their file).Unblocks #2329 (django runner seam + astropy sdist build deps + era pins), which is the #1 scoreboard blocker.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo