Skip to content

An engine whose launch timed out but came up late is finished as the same generation (card ea6c9aff) - #5545

Merged
joelteply merged 5 commits into
canaryfrom
ea6c9aff/an-engine-whose-launch-timed-out-but-cam
Oct 28, 2026
Merged

joelteply merged 5 commits into
canaryfrom
ea6c9aff/an-engine-whose-launch-timed-out-but-cam

Conversation

@joelteply

@joelteply joelteply commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

Windows, d85388c, 2026-10-27: engine 3548 (port 58057) loaded its weights from an HDD (D: is WDC WD161KFGX, MediaType HDD, per Codex's receipts). Load progress sat at 0.0 for minutes, past wait_ready's stall allowance. launch_prepared returned NotReady before transition.ready published the generation's pool and ledger.

The engine was healthy by about 22:29 (/health 200, mmproj 1.0). But every later reconcile saw the endpoint unready (active_model → Unreachable), tried to replace the engine, and stopped at the same refusal: checkpoint_before_replacement → capture_suspension returned "cannot suspend an unknown or uncertain live ledger". The only writer of pool_generation is ready(), and its only caller was that launch. So serving stayed down, with no residents, behind a healthy engine.

The fix was specified by Codex: recover the same loading generation, verify generation, incarnation, intent and contract before publishing, never reset the ledger, and refuse a stale incarnation or intent.

Change

  • llama_server/ready_tail.rs (new): the publication tail after wait_ready moves here as publish_ready(&transition, ReadyTail). It is the debug-build and placement gates, the page dir, the live slot geometry, transition.ready, the ledger stamp, and record_verified_target. The move is verbatim; launch.rs drops from 607 to 394 lines.
  • llama_server/late_ready.rs (new):
    • A NotReady wait with the child alive (not a restore) keeps a LoadingLaunch (serving.late_ready.kept).
    • The next launch_prepared checks it right after its transition admits the current intent (transition_if(current)) and before the replacement checkpoint. It finishes the engine only when the owned engine is still the same one (same generation, not exited, same pid) and the request is the same launch (engine program, weights, model id, adapter paths, and the exact LaneInvocation argv and environment).
    • It then waits for readiness again and publishes through the same transition.ready. Nothing is reset.
    • Anything else is refused and probed (serving.late_ready.refused), and the late engine is never published.
  • launch.rs: wires in the two calls and the kept-launch field (process.rs).

Deployment boundary (traced at file:line, Codex's question)

  • A restarted core adopts a healthy engine it never spawned, with no predecessor memory.
    • SlotDirectory::endpoint starts a new endpoint ready (engine_generation.rs:588), so the first reconcile's serve_or_adopt decode-probes the engine and returns AlreadyServing.
    • The ledger is adopted lazily on the first turn (ensure_slot_pool → adopt_engine_ledger). A never-stamped engine gets an empty ledger stamped with its own pid and start time.
  • Under the Windows service, the engine dies with the core.
    • The service runs the core in a KILL_ON_JOB_CLOSE job (continuum-cli-lifecycle windows_launch.rs:112-153, plus unelevated_service.rs), and llama-server inherits that job (prepared_launch.rs:51-54, no breakaway).
    • So deploying this build relaunches the engine. A slow cold load there is recovered by this change on the next reconcile.
    • No claim is made that the live node is repaired until that deploy shows it. Unchecked: whether the Windows deploy flow restarts inside the same job or ends the task (the engine dies either way under the service).

Tests (late_ready.rs, local, macOS x86_64)

Fixture What it pins
only_the_same_live_engine_for_the_same_launch_is_finished The pure decision: no engine, another generation, exited, another pid, unknown pid, another window and another model are each refused.
a_timed_out_launch_finishes_its_late_engine_and_a_changed_request_does_not Through the real launch_prepared, against an axum fake engine with a live stand-in child under a started but unpublished generation. capture_suspension refuses before; after the same request, the same generation's ledger is published and the pid is unchanged. A changed request on another endpoint does not publish, and the engine is not killed.
a_restarted_core_adopts_a_healthy_engine_it_never_spawned A fresh process (no child, no kept launch) adopts a healthy engine through ensure_model_serving_if_current (AlreadyServing, no spawn).
  • Proven by mutation: with the recovery entry disabled, the launch-level test fails with Spawn("cannot suspend an unknown or uncertain live ledger"), the exact Windows error.
  • Engine: late_ready + llama_server::tests gave 73 passed, 3 runs in a row.
  • Fixture hygiene: the fixtures release their stand-in children before dropping the process. A process dropped with a live child retires it through the shared page-dir guard, and that made a sibling pages test's census read incomplete until I fixed it.
  • Other checks: cargo check --lib is clean and the ratchets pass 68/68.

Not in this PR (named follow-up)

The stall allowance itself. Llama-server's load progress can sit at 0.0 for minutes while the engine reads a cold HDD. Counting the engine's own disk reads as load progress would avoid the timeout in the first place. This PR makes a timeout recoverable; that one would make it rarer.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…same generation (card ea6c9aff)

Windows d85388c, 2026-10-27: engine 3548 loaded its weights from an HDD with
load progress at 0.0 past wait_ready's stall allowance, so launch_prepared returned
NotReady before transition.ready published the generation's pool and ledger. The
engine was healthy by 22:29, but every later reconcile saw the endpoint unready,
tried to replace it, and checkpoint_before_replacement -> capture_suspension refused
("cannot suspend an unknown or uncertain live ledger"): serving stayed down behind a
healthy engine.

- The publication tail (gates, page dir, geometry, transition.ready, the ledger
  stamp, the verified target) moves verbatim from launch.rs to ready_tail.rs as
  publish_ready (launch.rs 607 -> 394 lines).
- A NotReady wait with the child alive (not restoring) keeps a LoadingLaunch.
- The next launch_prepared, after its transition admits the intent and before the
  replacement checkpoint, finishes that engine when it is still the same one (the
  same generation, not exited, the same pid) and the request is the same launch
  (engine program, weights, model, adapters, exact LaneInvocation): it waits again
  and publishes through the same transition.ready. Anything else is refused, probed
  (serving.late_ready.refused), and the late engine is never published. No ledger
  is reset.

Deployment boundary (traced): a restarted core adopts a healthy engine it never
spawned through the normal reconcile (a new endpoint starts ready; the ledger is
adopted lazily); under the Windows service the engine shares the core's
kill-on-close job and dies with it, so a deploy relaunches and this recovery covers
a slow load there.

Fixtures: the recovery decision over every refusal; through launch_prepared, a
timed-out launch's late engine is finished (same pid, the generation's ledger
published) and a changed request is not (proven by mutation: with recovery
disabled it fails with the Windows error string); a restarted core adopts a
healthy engine it never spawned. Engine: 73 pass (late_ready + llama_server::tests),
3 runs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply and others added 3 commits October 27, 2026 18:26
… the stand-in engine runs on every platform (Codex on #5545)

- recovery_refusal returns a kind. EngineGone (another generation, exited,
  another pid, an unknown kept pid) drops the kept launch, whose engine can never
  be finished; OtherLaunch (the same live engine, a different request) refuses
  publication and KEEPS it, so the launch it was started for can still finish it.
  Before, one changed-window request dropped the only kept launch and stranded the
  engine forever.
- wait_and_publish holds the kept launch in a guard across the readiness wait:
  only a finished wait consumes it, a slow wait keeps it (settle), and a cancelled
  wait puts it back on drop. Both the first launch and a recovery wait through it.
  The owned engine is read before the kept launch's lock; the locks never nest.
- Fixtures through launch_prepared now use the test binary itself as the
  stand-in engine (re-run for one test, blocking on stdin, the retirement
  fixture's pattern), not `sleep`, so they run on Windows, the platform this
  repairs: a changed request is refused, the launch stays kept, and the original
  request finishes the same pid with the generation's ledger published; a
  recovery cancelled mid-wait keeps the launch, and once the engine is ready the
  next launch finishes it. Proven by mutation: dropping on OtherLaunch fails the
  first ("stays kept"), not reinserting on drop fails the second ("put the launch
  back"). Engine: 74 pass.

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

wait_and_publish consumed the kept launch before publish_ready, whose awaits before
transition.ready (weight residency, adapter scales, the /props geometry, the
install receipt, the inputs) could each be cancelled and lose the only kept launch,
recreating the trap. publish_ready now borrows the launch; the keeper is disarmed
only once publication returns Ok (the ledger committed). A publication that fails,
or is cancelled at any await before the ledger, puts the launch back while its
engine lives.

Fixture: a_publication_cancelled_before_its_ledger_keeps_the_launch. The engine
answers ready but holds /props, so publication stalls at the geometry read; the
abort there leaves the launch kept and nothing committed; once /props opens the
original retry finishes the same pid with the generation's ledger published.
Proven by mutation: disarming before publish fails it ("the cancelled publication
put the launch back"). Engine: 75 pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
… they repair (Codex on #5545)

Each runs --exact in the Windows engine job and must report '1 passed', so the
log is execution evidence, not compilation: the changed-request, cancelled-wait
and cancelled-publication fixtures (the test binary as the stand-in engine) and
the restarted-core adoption.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply joelteply added the windows Run existing Windows core and lifecycle contracts label Oct 27, 2026
…el (no source change)

The windows-core-contract job runs on a canary PR only when it is labelled
'windows'; the label was added after 23535a9's run, and the workflow does not
trigger on 'labeled'. This empty commit is the synchronize that runs it, so the
late-ready fixtures execute on Windows.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply
joelteply merged commit 84386a0 into canary Oct 28, 2026
33 checks passed
@joelteply
joelteply deleted the ea6c9aff/an-engine-whose-launch-timed-out-but-cam branch October 28, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XL windows Run existing Windows core and lifecycle contracts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant