Skip to content

A core handoff closes in-engine training admission before its hold read, so no run starts between the guard and the stop (card 91921d0f) - #5553

Merged
joelteply merged 2 commits into
canaryfrom
91921d0f/a-core-handoff-closes-in-engine-training
Oct 28, 2026
Merged

joelteply merged 2 commits into
canaryfrom
91921d0f/a-core-handoff-closes-in-engine-training

Conversation

@joelteply

@joelteply joelteply commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

How this serves the minds: a persona's training run is never started into a core that's about to stop, so a deploy can't kill a run that #5551's guard didn't see coming. This advances the lifecycle work (deploys that preserve work) and goal 8, whose runs these are. It completes the race Codex scoped out of #5551, card 91921d0f.

Why

#5551's guard reads the node's training hold (serving/status held_for) once, then stops the core. A run admitted after that read and before the stop was killed anyway (Codex on #5551).

The engine's last gate before POST /train is the serving lifecycle gate. training_admission::wait_for_training_memory_bound takes it, leases memory, and records the engine residency that held_for reads, all under the gate. A refusal there means "wait and retry", never "fail". So closing admission there, and only then reading the hold, makes the read final.

system/shutdown-drain can't do this job: it is one-way by design (AdmissionGate::close, ShutdownOperation.started), and a refused handoff has to admit again.

Change

  • Engine (serving_lifecycle.rs, new serving_lifecycle/handoff.rs): LifecycleGate holds a reversible handoff close, owned by a process identified by pid plus OS start time.
    • Close: close_for_handoff takes the gate, so an admission deciding right now finishes and publishes its hold first. Every later admission is refused with GateRefusal::Handoff, a wait.
    • Reopen: reopen_after_handoff(token) releases it, or the owner's verified death does. A reused pid counts as dead; an unreadable process table does not. A stale token never reopens a newer close.
    • Relaunches are unaffected: the close holds the gate only for the instant it sets the flag.
  • Commands (continuum-serving, both Privileged):
    • serving/handoff-close {ownerPid} returns one of:
      • Closed { token };
      • Busy: a serving operation holds the gate, and nothing is closed;
      • NoServing: this core admits no in-engine training.
    • serving/handoff-reopen {token} returns { reopened }.
    • The ts-rs bindings are generated.
  • Decision (continuum-cli-lifecycle deploy_hold::verdict(close, observed, force), pure):
    • A free hold proceeds only with admission closed, or with nothing to close.
    • A busy or failed close defers. --force overrides it and says so.
    • A core that predates the close proceeds on the hold read alone, and says the window stays open. The CLI asks the running core's own commands/list for the command by name, so a deploy away from an old core is never blocked.
  • reboot() (continuum-core bin):
    • It closes admission before observe_engine_hold.
    • A thin wrapper reopens admission on any error. A handoff that didn't stop the core must admit again. Past the stop the core is gone, and a restored or new one boots open and ignores the stale token.
    • running_core_call now carries params; running_core_provenance is it with none.

Tests

Test Crate What it pins
handoff::only_a_verified_dead_owner_releases_a_close engine Open, closed by a live owner, owner exited, pid reused, and unreadable (stays closed).
serving_lifecycle::a_handoff_close_refuses_admission_until_its_own_token_reopens_it engine Closed gives Handoff. A stale token reopens nothing. The right token reopens. A close waits for an admission that is deciding.
deploy_hold::a_free_hold_proceeds_only_with_admission_closed_or_nothing_to_close lifecycle Busy or failed defers, forceable. An old core proceeds and says so. Live work still defers on an old core. No core means nothing to close.
handoff::name_and_access_wired serving Both commands are Privileged.
  • Proven by mutation: with the gate ignoring a standing close, the gate test fails ("closed by a live owner: waits").
  • Local results (macOS x86_64, at 2e30920): engine 2/2, lifecycle 2/2 (the existing deploy_hold test is updated to the new signature), serving 5/5.
  • Ratchets: 68/68 (exit 0).
  • CI only: the continuum-core binary.

Measured after deploy

Owner: Cormac, with Codex on the consumer. When: the first deploy on a node that has this build.

What it should show:

  • serving.handoff.closed, then the hold read, then either the stop, or a refusal followed by training admission reopened.
  • A training dispatch inside that window logs core_handoff as its admission refusal, then admits on the new core.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…ad, so no run starts between the guard and the stop (card 91921d0f)

Codex on #5551: the deploy's hold guard was one preflight read, so a training run
admitted after it and before the stop was still killed.

- Engine (serving_lifecycle + new serving_lifecycle/handoff.rs): LifecycleGate holds a
  reversible handoff close owned by a process (pid + OS start time).
  close_for_handoff takes the gate, so an admission deciding now finishes and publishes
  its hold first; every later admission is refused GateRefusal::Handoff (a wait, never a
  failure) until reopen_after_handoff(token) or the owner's verified death (a reused pid
  is dead; an unreadable table is not). A stale token never reopens a newer close.
- serving/handoff-close {ownerPid} -> Closed{token} | Busy (a serving operation holds
  the gate) | NoServing; serving/handoff-reopen {token} -> {reopened}. Privileged.
- deploy_hold::verdict(close, observed, force): a free hold proceeds only with admission
  closed or nothing to close; a busy or failed close defers (forceable, said); a core
  that predates the close (asked by name through its commands/list) proceeds on the read
  alone and says the window stays open.
- reboot(): closes before observe_engine_hold; a thin wrapper reopens on any error, since
  a handoff that did not stop the core must admit again (past the stop the core is gone,
  and a restored or new one boots open). running_core_call carries params;
  running_core_provenance is it with none.

Tests (local): handoff::only_a_verified_dead_owner_releases_a_close,
serving_lifecycle::a_handoff_close_refuses_admission_until_its_own_token_reopens_it
(mutant ignoring the close fails it), deploy_hold::a_free_hold_proceeds_only_with_
admission_closed_or_nothing_to_close, serving handoff::name_and_access_wired.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…at its own path, and a malformed command list is a failure (Codex on #5553)

At 2e30920:
- continuum.rs put #[path = "continuum/reboot.rs"] on mod handoff_admission, leaving
  mod reboot without its path (E0583 in CI). Each module now has its own path.
- close_for_handoff replaced any standing close, so handoff B could close then reopen
  (or die) while handoff A, which had already read a free hold, went on to its stop with
  admission open. A close held by a live or unverifiable owner is now never replaced
  (HandoffCloseOutcome::Taken, serving/handoff-close -> taken{ownerPid}, which the CLI
  defers on); only a verified-dead owner's close is. Another handoff's token never
  reopens it.
- A commands/list reply without a commands array mapped to NotSupported (proceed on the
  read alone); only a well-formed list lacking the command is an older core, anything
  else is Failed (defers).

Regression: serving_lifecycle::a_second_handoff_never_releases_a_live_owners_close (a
mutant that replaces a live close fails it).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@github-actions github-actions Bot added size: XL and removed size: L labels Oct 28, 2026
@joelteply
joelteply merged commit 172100a into canary Oct 28, 2026
33 checks passed
@joelteply
joelteply deleted the 91921d0f/a-core-handoff-closes-in-engine-training branch October 28, 2026 07:00
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