Skip to content

An act ends the moment its engine is condemned, so a quarantine's drain is not held to its next checkpoint (card 4d2a64a2) - #5500

Merged
joelteply merged 2 commits into
canaryfrom
4d2a64a2/replacement-after-an-uncertain-kv-restor
Oct 27, 2026
Merged

joelteply merged 2 commits into
canaryfrom
4d2a64a2/replacement-after-an-uncertain-kv-restor

Conversation

@joelteply

@joelteply joelteply commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Rebased onto canary 01b93bb after #5498 merged; this PR's own commits are f8b6b61 and 2b23a7f.

Why

While a relaunch drains, no mind on the node gets a lane. An act that holds its guard on a condemned engine therefore keeps the whole node dark, and it held until the act's next checkpoint, up to a full act bound later. This is plan path step 1 (fast) and an in-flight item under circle-the-wagons. Card 4d2a64a2.

The case (enrico, 2026-10-26, core 839f702)

  • 21:08:32Z: a KV page restore on slot 0 stops progressing. At 21:10:02 kv_page.uncertain fires: "endpoint quarantined until verified engine replacement". The daemon publishes not-ready (serving_daemon/reconcile.rs, the paging_recovery_required branch).
  • 21:10:04: the replacement starts (serving.server_version). launch_prepared -> transition_if -> gate.write_owned().await waits for every admitted turn's EndpointAdmission read guard, with no bound. The code says so itself: progress.rs on engine_condemned, citing 25 and 46 min outages on 2026-09-27.
  • Eitan's act (turn from 20:18:14, 1500 s bounds) reads engine_condemned() only at a checkpoint: 20:43:18, 21:08:18, then 21:33:18. serving.reconcile.wedged step=ensure_serving reached age_ms=1368532 against a 180 s bound; serving was ready at 21:33:26, eight seconds after his act ended.

What

  • llama_server::until_condemned(): resolves the moment a ready snapshot turns not-ready. A node that was never ready is not condemned; a closed channel never resolves. Pure core: until_condemned_on(rx).
  • until_act_stalls selects on it beside the step and the checkpoint sleep (through until_act_stalls_or, so a test can raise it). A condemnation ends the act at once with settle.tick.condemned and Abandoned { dispatched } (A generation the act deadline drops in flight is a failed act, never a lane wait (card 843d5570) #5498).

No new task, no lock, and no constant: one more select arm on the existing deadline loop, reading the existing watch.

Verified (enrico, at c9f3422)

  • cargo check for continuum-engine and continuum-cognition, --lib and --profile test (--features metal): exit 0. The engine warnings printed (expert_container.rs, llamacpp_scheduler.rs, heuristic_adapter.rs) are all in files this PR does not touch.
  • a_wait_hears_the_engine_condemned_the_moment_it_happens (engine): not-ready at the start waits, ready waits, ready -> not-ready resolves at once, and a closed channel never resolves. llama_server::tests::progress: 6 passed.
  • a_condemned_engine_ends_the_act_at_once_not_at_its_checkpoint (cognition): condemned at 120 s, the act ends at exactly 120 s (paused time) with dispatched: true, not at 1500 s. act_observe::settle: 14 passed.
  • Mutation: with the condemnation arm replaced by a never-resolving future, that test FAILS. Restored, it passes.
  • source-hygiene ratchets -- origin/canary: exit 0, no row changed.

Revision 9b48a8e (Fable's finding)

"Not ready" isn't the same as "condemned". The daemon also publishes not-ready while the engine stays up (AlreadyServing with a 0 /props window, a transient read under saturated prefill). The first version would have ended every in-flight act on each such hiccup.

  • The engine keeps a dedicated condemnation generation (llama_server::condemn / condemnations, a watch<u64>). It advances at the ONE place the daemon commits to an engine transition: publish_lifecycle_admission, used by relaunch, quarantine replacement, convergence, retirement and the academy teacher switch. Each of those drains the admitted turns in transition_if. Probe: serving.engine.condemned {generation, reason}.
  • until_condemned subscribes when the act starts and resolves at the next advance. It reads no snapshot, so a readiness flip can never end an act.
  • Fixtures:
    • a_wait_hears_the_next_condemnation_the_moment_it_happens: an earlier condemnation is not heard, a closed channel never resolves.
    • an_admitted_lifecycle_transition_condemns_the_engine (serving).
    • a_condemned_engine_ends_the_act_at_once_not_at_its_checkpoint (unchanged).
  • Mutation: with condemn() removed from publish_lifecycle_admission, the serving fixture FAILS.
  • Checks at 9b48a8e: engine, cognition and serving, --lib and --profile test, all exit 0. Tests: engine progress 6, settle 14, serving 1. Ratchets: exit 0.
  • The checkpoint path (engine_condemned(), readiness-based) is unchanged: it still ends an act at a checkpoint on any not-ready, as before this PR.

Measured after deploy

Owner Cormac, by 10-27 18:00Z, on enrico: the next kv_page.uncertain or relaunch gives serving.reconcile.wedged age under the 180 s bound, with a settle.tick.condemned row per act that was in flight. If no quarantine occurs in that window, the card stays open and I'll say so.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply

Copy link
Copy Markdown
Contributor Author

Fable at c9f3422: changes requested (one finding).

The mechanism is right: a select arm so a condemned engine ends the act at once instead of at its next checkpoint, with until_condemned_on waiting for ready and then not-ready. That's exactly enrico's 23-minute wedge.

Finding: 'not ready' isn't the same as 'condemned'. ready=false is also published when nothing is being relaunched. serving_daemon/publication.rs publishes a not-ready snapshot for EnsureOutcome::AlreadyServing when the served window read back as 0 ("the server stays up and the next reconcile re-reads /props"), i.e. a transient /props failure. That's most likely exactly when the engine is saturated in prefill, which on the M5 is most of the time ("lane proven alive by real work … skipped the smoke probe" every minute tonight). With this PR, every such hiccup abandons every in-flight act on the node, and the residents redo up to ~100k tokens of prefill each. That's a far larger loss than the wedge it fixes, and it would look like random act failures. Degraded("serving intent superseded") and the LOADING arm are other not-ready publishes worth checking.

Suggested shape: listen for the condemnation itself, not the readiness bit. Wherever the daemon actually decides to tear the engine down (quarantine, relaunch, convergence; the place that flips not-ready before the drain), publish a distinct signal, e.g. a monotonic condemned_generation on the snapshot, or a dedicated watch. until_condemned then resolves on that generation advancing. Add the regression: a not-ready snapshot from an unreadable /props window (AlreadyServing, window 0) does not end an act, while a quarantine does.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply added a commit that referenced this pull request Oct 27, 2026
…nsient not-ready (Fable on #5500)

until_condemned resolved on any ready -> not-ready, but the daemon also publishes not-ready
while the engine stays up (AlreadyServing with a 0 /props window, most likely when the engine
is saturated in prefill): every such hiccup would have abandoned every in-flight act on the node.

Now the engine keeps a dedicated condemnation generation (llama_server::condemn / condemnations,
a watch<u64>), advanced at the ONE place the daemon commits to an engine transition:
publish_lifecycle_admission (relaunch, quarantine replacement, convergence, retirement, the
academy teacher switch), each of which drains the endpoint's admitted turns in transition_if.
until_condemned subscribes and resolves at the next advance after the act began; it reads no
snapshot. Probe: serving.engine.condemned {generation, reason}.

Fixtures: the wait hears the next condemnation and not an earlier one, never on a closed
channel; an admitted lifecycle transition condemns the engine. Mutation: removing condemn()
from publish_lifecycle_admission fails the daemon fixture.

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

Copy link
Copy Markdown
Contributor Author

Fable: exact-head source PASS at 9b48a8e. My finding is resolved and verified: until_condemned now waits on a dedicated CONDEMNATIONS generation (progress.rs), subscribed fresh per act so only a LATER condemnation ends it. The only condemn() call is publish_lifecycle_admission (serving_daemon/publication.rs:218), i.e. a transition that will drain transition_if, so an AlreadyServing 0-window not-ready no longer ends an act.

Non-blocking, pre-existing (not introduced here): engine_condemned() still reads the readiness bit (!rx.borrow().ready) and is consulted at checkpoints (tick_deadline.rs:87, admission_clock.rs:150, engine_probe), so a transient /props not-ready can still end a wait at its next checkpoint. Worth moving those to the same generation in a follow-up so 'condemned' has one meaning; please card it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply and others added 2 commits October 26, 2026 20:19
…in is not held to its next checkpoint (card 4d2a64a2)

Serves every resident on the node: while a relaunch drains, no mind gets a lane, so each
second an act holds its guard on a condemned engine is the whole node dark. Plan path step 1
(fast) and circle-the-wagons item: finish what is in flight.

enrico, 2026-10-26 (core 839f702): an uncertain KV restore quarantined the endpoint at
21:10:02Z; the daemon published not-ready, and the replacement's transition_if (a write on the
endpoint gate) waited for every admitted turn's read guard. Eitan's act learned of the
condemnation only at its next checkpoint, 21:33:18 (1500 s bounds from 20:18:14), so
serving.reconcile.wedged step=ensure_serving ran 1368 s against a 180 s bound, ready 21:33:26.

llama_server::until_condemned resolves the moment a ready snapshot turns not-ready (never for
a node that never served, never on a closed channel). until_act_stalls selects on it beside the
step and the checkpoint sleep, ending the act at once with settle.tick.condemned (and
Abandoned { dispatched } from #5498). Stacked on #5498.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…nsient not-ready (Fable on #5500)

until_condemned resolved on any ready -> not-ready, but the daemon also publishes not-ready
while the engine stays up (AlreadyServing with a 0 /props window, most likely when the engine
is saturated in prefill): every such hiccup would have abandoned every in-flight act on the node.

Now the engine keeps a dedicated condemnation generation (llama_server::condemn / condemnations,
a watch<u64>), advanced at the ONE place the daemon commits to an engine transition:
publish_lifecycle_admission (relaunch, quarantine replacement, convergence, retirement, the
academy teacher switch), each of which drains the endpoint's admitted turns in transition_if.
until_condemned subscribes and resolves at the next advance after the act began; it reads no
snapshot. Probe: serving.engine.condemned {generation, reason}.

Fixtures: the wait hears the next condemnation and not an earlier one, never on a closed
channel; an admitted lifecycle transition condemns the engine. Mutation: removing condemn()
from publish_lifecycle_admission fails the daemon fixture.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply force-pushed the 4d2a64a2/replacement-after-an-uncertain-kv-restor branch from 9b48a8e to 2b23a7f Compare October 27, 2026 01:25
@joelteply

Copy link
Copy Markdown
Contributor Author

Fable: exact-head PASS at 2b23a7f on green. Rebased onto #5498 with the code unchanged from my PASS at 9b48a8e; the one conflict (two tests at the same anchor in settle/tests.rs) keeps both.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply
joelteply merged commit e653e46 into canary Oct 27, 2026
28 checks passed
@joelteply
joelteply deleted the 4d2a64a2/replacement-after-an-uncertain-kv-restor branch October 27, 2026 01:35
joelteply added a commit that referenced this pull request Oct 27, 2026
…nswered (card 9c67e5fe) (#5508)

* 'Condemned' has one meaning: a decided teardown no ready engine has answered (card 9c67e5fe)

Serves every resident: engine_condemned() read the readiness bit, so a transient not-ready (a 0
/props window under AlreadyServing, most likely while the engine is saturated in prefill) still
ended acts at their act-bound checkpoint (tick_deadline), stalled queue waits (admission_clock)
and paging waits (engine_probe), after #5500 had fixed the same thing for until_condemned.

The condemnation state is one owner, Condemnations (the generation #5500 added, plus the
generation the last ready publish answered). engine_condemned() = a condemnation no ready engine
has answered since. The daemon's emit_serving, which every snapshot publish passes, answers them
on a ready snapshot (note_serving_ready). The three readers are unchanged; they now read the
decision, never the readiness bit. engine_condemned no longer reads SERVING_STATE.

Fixture: a ready publish alone condemns nothing; two condemnations are pending until a ready
engine answers them. Mutation: dropping the recovery comparison fails it.

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

* The ready-publish invariant note_serving_ready relies on is written where it is called (Fable on #5508)

Comment-only.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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