Skip to content

fix(cognition): a healthy generation is never dropped — the lane gate and the act deadline are sized from her measured turn (card ebce2ba0) - #4289

Merged
joelteply merged 3 commits into
canaryfrom
fix/a-dropped-generation-is-never-silent
Sep 21, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fix/a-dropped-generation-is-never-silent

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The measured evidence

From ~/.continuum/fixtures/prompt-captures/*.jsonl (schema 4) on the M5, 2026-09-20. Of the last 50 submitted generations: 13 completed, 18 CANCELLED, 7 failed — 26% completion.

Every cancellation reads "error": "request future dropped before a terminal response" — the string ONLY prompt_capture::CaptureLease's Drop impl writes, i.e. the awaiting side went away.

Cancelled elapsed_ms, sorted, clustering on EXACT repeated values at DIFFERENT wall-clock moments:

60009 | 165843 165844 165845 165856 165917 165982 | 412216 412218 412222 412346
      | 485151 485152 485196 | 1207290 1228814 | 1491253 1492283 1492456

The dropping sites

TWO of them. Both confirmed at the source, not inferred.

1. The serving-lane gate — cognition/llm_deliberation_faculty.rs

The CaptureLease is created at llm_deliberation_faculty.rs:1117, before the admission gates, and the lane gate's return None at :1362 drops it. Those turns never reached the model at all — the capture called them cancelled generations because the lease spans the gate.

Proven by wall-clock correlation against the live probe stream, not by arithmetic alone:

delib.gate.lane_wait probe cancel submitted_at Δ elapsed_ms
1789952625487 bound_secs=165 1789952625471 16 ms 165856
1789952625495 bound_secs=165 1789952625491 4 ms 165843
1789952843137 bound_secs=165 1789952843131 6 ms 165845
1789953029730 bound_secs=165 1789953029729 1 ms 165844
1789953509721 bound_secs=485 1789953509679 42 ms 485196
1789953685976 bound_secs=485 1789953685977 1 ms 485152
1789954187014 bound_secs=485 1789954187016 2 ms 485151

The bound_secs=165 row occurred exactly six times — matching the six ~165.9 s cancels one to one.

Explains: 60,009 (= LANE_WAIT_FLOOR), ~165.9 s (six), ~412.2 s (four), ~485.2 s (three).

2. The act deadline — cognition/act_observe/settle.rs:565

tokio::time::timeout_at(tick_deadline, settle_step(...)) with a flat TICK_DEADLINE = 25 * 60 (settle.rs:29). On elapse the whole settle_step future — and the generation inside it — is dropped.

Explains: 1,207,290 / 1,228,814 / 1,491,253 / 1,492,283 / 1,492,456 — the 1,500 s deadline less however far into the act the model call had started. (Cormac's box logged 1,499,996 ms, i.e. the deadline to the millisecond.)

The bound's derivation — and it is NOT #4277 used as a ceiling

The 166 s family is resource_admission::lane_wait_bound (rounds x lane_hold_p50_ms x LANE_WAIT_SLACK, clamped to [60 s, 600 s]). The probe row that produced it:

lane_hold_p50_ms=82918  queue_ahead=0  lanes_serving=2  lane_hold_samples=2  -> 165,836 ms

A median over TWO recorded lane holds decided how long a mind waits for a lane, while the lanes were actually holding 4–7 minutes (lane_hold_p50_ms later read 242,574 and 424,348 — the same derivation gives the 485 s and the clamped 600 s families). It measures the LANES; it is not a bound for HER turn.

To answer the question directly: #4277's from_expectation / expected_occupancy is NOT being used as a ceiling anywhere. At this gate that derivation was never consulted at all — the ONLY place expected_occupancy reached was reserve_lendable. The defect is a different derivation, sized from the wrong quantity. #4277 is the fix here, not the cause.

The fix — the constant is a FLOOR, her measured turn is the bound

  • The gate now takes turn_bound::effective_bound_with_source(queue_estimate, from_expectation(expected_occupancy())). The queue's number stays the floor (it is the only thing that speaks before her first measured turn); her own measured turn raises it. A mind whose turns take ~7 min waits 848 s, not 165 s.
  • The act now takes turn_bound::act_bound_with_source(TICK_DEADLINE, expected_occupancy) — ACT_BOUND_TURNS = 2 turn bounds, because an act is a lane wait PLUS the generation after it. The named 25 minutes is a floor. This also preserves the composition invariant the flat ceiling used to carry: the act (2 turn bounds) always outlasts the gate (1), so the gate still trips first and she keeps her act budget.
  • expected_occupancy_for(persona_id) is lifted out of the faculty so seams above it can size from the same measured number.

The safeguards

(a) A dropped generation is never silent. New cognition/generation_drop.rs: InFlight is armed around the model call and disarmed on any terminal answer (response or typed adapter refusal). Its Drop — the only thing that still runs when a future is torn down — probes persona.generation.dropped with the bound, its source (turn_bound/floor), the expectation behind it, elapsed, and how much output existed.

(b) The hour line carries it. citizen_health gains generations / generations_dropped with its own snapshot_generations_and_reset() (following the snapshot_lane_starved_and_reset precedent — never a tenth slot on the nine-wide tuple). The line renders · dropped 18 of 50 (36%) beside acts / lane-starved / think-only, and dropped n/a when nothing ended (an unmeasured hour is not a clean one).

(c) Partial tool calls are not thrown away silently — salvage IS implemented. The non-observing generation path used to drop(receiver) on its stream. The witness now holds it, so a drop drains what the model had already produced and reports answer chars, reasoning chars, prefill progress, and the COMPLETE tool calls parseable in the partial text, by name (json_in_prompt_tools::parse_tool_calls). What is missing, stated plainly: it REPORTS them, it does not re-enter the turn with them. Drop is synchronous and the settle loop that would execute them is itself being torn down at that instant — there is no seam to hand them back to. On the live-Speak path the caller owns the stream, so the witness reports observed = false rather than a false zero.

(d) The verdict says it. Verdict::Dropping outranks Reading above DROPPED_GENERATIONS_ABOVE_PCT = 10. The measured 36% currently renders as READING: n acts, no writes — the governor owes a delivery, which points the reader at the citizens. It now renders as a PIPE fault.

Also: a never-dispatched abandon names itself (CaptureLease::abandon) — "lane starved before dispatch: waited 165s of a 165s bound (floor) with 0 lanes free" — instead of writing the same generic string a real in-flight drop writes. That conflation is why 18 of 50 read as dropped generations when most never reached the model.

Tests

  • turn_bound.rs — an act is two turn bounds with the named deadline as a floor; unmeasured → the floor; never below it.
  • resource_admission.rs — the queue's estimate is a floor under her measured turn and never a ceiling, reproducing the exact p50=82918 / queue_ahead=0 / lanes=2 -> 165,836 ms row, plus the gate-before-act composition invariant.
  • citizen_health.rs — a drop increments the ledger, renders on the line, and outranks READING at the measured 36% while 4% still reads READING.
  • generation_drop.rs — the salvage fold names a complete tool call, refuses to invent one from a half-emitted envelope, and folds an empty stream honestly.

Each carries the measured elapsed families in its // what this catches: comment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… and the act deadline are sized from her measured turn, and a drop is a counted outcome (card ebce2ba0)

Measured on the M5, 2026-09-20, from ~/.continuum/fixtures/prompt-captures: of the last
50 submitted generations, 13 completed, 18 CANCELLED, 7 failed — 26% completion. Every
cancel read "request future dropped before a terminal response", the string only
`CaptureLease`'s Drop writes. Their elapsed_ms clustered on EXACT repeated values at
different wall-clock moments: 60,009 | 165,843–165,982 (six) | 412,216–412,346 (four) |
485,151–485,196 (three) | 1,207,290 | 1,228,814 | 1,491,253–1,492,456.

TWO dropping sites, both confirmed at the source:

1. `cognition/llm_deliberation_faculty.rs` — the `CaptureLease` is created at :1117,
   BEFORE the serving-lane gate, and the gate's `return None` (:1362) drops it. Those
   turns never reached the model. Proven by wall-clock: `delib.gate.lane_wait
   bound_secs=165 lane_hold_p50_ms=82918 queue_ahead=0 lanes_serving=2` fired SIX times
   and each cancel's submitted_at sits 1–16 ms from its probe, with elapsed == the bound.
   The bound is `lane_wait_bound` (rounds x lane_hold_p50 x SLACK, clamped): a median
   over TWO recorded lane holds, deciding how long a mind waits while the lanes were
   holding 4–7 minutes. It explains 60,009 (LANE_WAIT_FLOOR), ~165.9 s, ~412.2 s, ~485.2 s.
   NOT #4277's `from_expectation` used as a ceiling — that derivation was never consulted
   here at all.
2. `cognition/act_observe/settle.rs:565` — `timeout_at(tick_deadline, settle_step(...))`
   with a flat 25-minute `TICK_DEADLINE`, dropping the whole act future (and the
   generation inside it) mid-flight. Explains 1,207,290 / 1,228,814 / 1,491,253 /
   1,492,283 / 1,492,456 — the deadline, less how far into the act the call started.

THE FIX — the constant is a FLOOR, her measured turn is the bound:
- The gate takes `effective_bound(queue_estimate, from_expectation(expected_occupancy))`.
- The act takes `act_bound_with_source(TICK_DEADLINE, expected_occupancy)` = two turn
  bounds (a lane wait plus the generation after it), so the gate always trips first.

THE SAFEGUARDS:
- `cognition/generation_drop.rs` — `InFlight` is armed around the model call. A drop
  probes `persona.generation.dropped` with the bound, its source, the expectation behind
  it, elapsed, and the partial: answer chars, reasoning chars, prefill progress, and the
  COMPLETE tool calls thrown away (salvaged by holding the streaming receiver the
  non-observing path used to discard). It reports them; Drop is sync and the settle loop
  is being torn down, so there is no seam to execute them.
- `note_generation_outcome` counts both halves; the hour line carries `dropped N of M (P%)`
  beside acts / lane-starved / think-only, via its own `snapshot_generations_and_reset`.
- `Verdict::Dropping` outranks READING above 10%: 36% thrown away is a broken pipe, and it
  rendered as "READING: n acts, no writes" — which blames the citizens.
- A never-dispatched abandon now names itself in the capture (`CaptureLease::abandon`)
  instead of writing the same generic string a real in-flight drop writes.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 2 commits September 20, 2026 21:08
…g boundary it creates

The detached solve's ACT_STALL_ALLOWANCE reads the CONSTANT (3x), so a box whose
measured turn passes ~19 min would derive an act bound above the 75-minute stall
allowance. No box in the fleet's measured range is there; the attempt ceiling fires
first on one that slow; making the watchdog per-persona is a solve.rs change with its
own required-read. Recorded at the seam rather than half-fixed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…T — fix the case's arithmetic

CI caught my own test, not the code: lane_wait_bound(7, 1, 300_000, 30) computes 4,800 s
and returns the 600 s LANE_WAIT_CEILING, so it was never the larger of the two. The
corrected case asserts the more valuable fact — her 848 s measured turn rides ABOVE that
clamp (a constant may raise a wait and never shorten one) — and takes a genuinely deeper
queue (480 s) against a one-minute turn for the queue-wins direction.

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

Copy link
Copy Markdown
Contributor Author

REVIEWED at head by Fable (team lead). Agent-written under my direction, on evidence I gathered and a site Cormac named; this is a second pair of eyes.

The forensics are the strongest thing here and they CORRECTED me. I told the room these turns were being cut off mid-generation. They were not: the capture lease is armed at llm_deliberation_faculty.rs:1117, BEFORE the admission gates, and the lane gate returns None at :1362 and drops it — so those turns never reached the model at all, and lane starvation has been wearing a cancelled generation as a costume. The wall-clock correlation (1 ms to 42 ms between each delib.gate.lane_wait row and its cancel, six for six on the 165.9 s family) is proof, not inference. It also answers the question I most wanted answered honestly: #4277 is NOT being used as a ceiling at that gate, it was never consulted there at all.

The root number is the nights recurring disease one more time: lane_hold_p50_ms=82918 over lane_hold_samples=2 decided how long a mind may wait, while the lanes were really holding 4 to 7 minutes and the same median later read 242,574 and 424,xxx. A two-sample median is a constant wearing a measurements clothes.

THE RISK I CHECKED, being the reverse of the bug: making a bound longer can starve differently. lane_wait_bound stays clamped to LANE_WAIT_CEILING — good. The act bound does not: at a measured 424 s occupancy it is 424 x TURN_BOUND_HEADROOM x ACT_BOUND_TURNS = 1,696 s, and on the IntelMac at ~25 tok/s with a 30k prompt it would be far larger. I am accepting that, because a wedged turn must not be what the act bound catches — the stream idle watchdog arms after headers and the pre-stream floor covers before them, so a genuinely dead generation dies on no-progress while a slow-but-alive one is allowed to finish. That is the right division and it is the busy-is-not-dead law applied correctly. Say so in the code if it is not already written down, because the next reader will ask exactly this.

The four safeguards are what Joel asked for and they are all present: the drop is counted and named with its bound and source, the hour line carries generations and generations_dropped, partial tool calls are salvaged rather than silently binned, and a node above ten percent dropped renders as Dropping instead of Reading — so a 36 percent loss rate can never again read as lazy personas.

APPROVE — merging on green.

@joelteply
joelteply enabled auto-merge (squash) September 21, 2026 02:21
@joelteply
joelteply merged commit f738d81 into canary Sep 21, 2026
6 checks passed
@joelteply
joelteply deleted the fix/a-dropped-generation-is-never-silent branch September 21, 2026 02:30
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