Skip to content

feat(lifecycle): live work binds to its engine incarnation inside admission, and serving never replaces a bound engine (SHARED-RESIDENT-LIFECYCLE step 1, card ef9df13b) - #4531

Merged
joelteply merged 5 commits into
canaryfrom
feat/resident-ownership-contract
Sep 28, 2026
Merged

joelteply merged 5 commits into
canaryfrom
feat/resident-ownership-contract

Conversation

@joelteply

@joelteply joelteply commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Kimi's attempt 2 (5090, 2026-09-28 12:29Z, job 4169e970) died because nothing told serving
that the engine it replaced hosted a live /train run. Admission waited on serving's lifecycle
gate only for its own moment; afterwards the lease kept serving out of the MEMORY, and nothing
kept it out of the ENGINE. This is step 1 of docs/architecture/SHARED-RESIDENT-LIFECYCLE.md
(#4527, reviewed by Fable and Cormac):

  • inference::engine_residency: EngineIncarnation { pid, started_s (OS start time), port }, so
    a recycled pid or port is never the same engine. ResidentWork { job, out, engine,
    base_model, created_ms, interrupted } in state/engine-residency.json, a fail-closed store
    (NotFound = empty; unreadable = Err = held; writes refuse over unreadable state).
    occupancy(port) is the one question, and a record whose incarnation is verifiably dead is
    released there (death is the release evidence; no ACK needed).
  • LaneRecord gains started_s, stamped at spawn.
  • forge::training_admission::wait_for_training_memory_bound: bind runs after the lease is
    granted and BEFORE the gate drops. In-engine training binds there, after re-checking that the
    lane it chose is still the live engine (the same pid and start); a lane replaced while the job
    waited refuses admission, so the replacement-vs-admission race has one winner.
  • EngineRun releases its binding only when its end is SETTLED: the incarnation is verifiably
    gone, or the engine answers that this job is not running. Alive but unreachable keeps it (no
    timeout releases anything).
  • serving_daemon::engine_occupancy, asked by reconcile_to_plan before every path that can end
    the engine (model swap, re-home, page-in, empty-plan retirement / idle_if_current) and by the
    teacher batch. While held, the streaks those paths earn restart from zero, so a plan formed
    under the work's memory cannot commit the instant it releases. The one exception is the
    unverified-KV-paging emergency: the work is TOLD why (interrupted) before the replacement
    commits, and the run's failure names it.
  • Tests: the store holds its own incarnation until verifiably dead; a recycled pid is death; an
    unreadable store holds; an emergency interruption is recorded; an incarnation matches only the
    same start; a reconcile over a bound engine launches nothing, and proceeds once released.

Step 2 (footprint attribution: withhold under residency, retire a contaminated record) and step
3 (Fable, boot reconciliation over this record, card 7bb4e5a2) follow.

Co-Authored-By: Claude Opus 5.5 [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Contract: docs/architecture/SHARED-RESIDENT-LIFECYCLE.md (#4527). Not compiled locally (the IntelMac deploy holds the shared target lock); CI is the first compile.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…ission, and serving never replaces a bound engine (SHARED-RESIDENT-LIFECYCLE step 1, card ef9df13b)

Kimi's attempt 2 (5090, 2026-09-28 12:29Z, job 4169e970) died because nothing told serving
that the engine it replaced hosted a live /train run. Admission waited on serving's lifecycle
gate only for its own moment; afterwards the lease kept serving out of the MEMORY, and nothing
kept it out of the ENGINE. This is step 1 of docs/architecture/SHARED-RESIDENT-LIFECYCLE.md
(#4527, reviewed by Fable and Cormac):

- inference::engine_residency: EngineIncarnation { pid, started_s (OS start time), port }, so
  a recycled pid or port is never the same engine. ResidentWork { job, out, engine,
  base_model, created_ms, interrupted } in state/engine-residency.json, a fail-closed store
  (NotFound = empty; unreadable = Err = held; writes refuse over unreadable state).
  occupancy(port) is the one question, and a record whose incarnation is verifiably dead is
  released there (death is the release evidence; no ACK needed).
- LaneRecord gains started_s, stamped at spawn.
- forge::training_admission::wait_for_training_memory_bound: `bind` runs after the lease is
  granted and BEFORE the gate drops. In-engine training binds there, after re-checking that the
  lane it chose is still the live engine (the same pid and start); a lane replaced while the job
  waited refuses admission, so the replacement-vs-admission race has one winner.
- EngineRun releases its binding only when its end is SETTLED: the incarnation is verifiably
  gone, or the engine answers that this job is not running. Alive but unreachable keeps it (no
  timeout releases anything).
- serving_daemon::engine_occupancy, asked by reconcile_to_plan before every path that can end
  the engine (model swap, re-home, page-in, empty-plan retirement / idle_if_current) and by the
  teacher batch. While held, the streaks those paths earn restart from zero, so a plan formed
  under the work's memory cannot commit the instant it releases. The one exception is the
  unverified-KV-paging emergency: the work is TOLD why (interrupted) before the replacement
  commits, and the run's failure names it.
- Tests: the store holds its own incarnation until verifiably dead; a recycled pid is death; an
  unreadable store holds; an emergency interruption is recorded; an incarnation matches only the
  same start; a reconcile over a bound engine launches nothing, and proceeds once released.

Step 2 (footprint attribution: withhold under residency, retire a contaminated record) and step
3 (Fable, boot reconciliation over this record, card 7bb4e5a2) follow.

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

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at a336632 as the consumer (step 3, re-attach, card 7bb4e5a2). I second Codex's Alive / Dead / Unknown (an unreadable start time is never death). From the re-attach side, the record is not yet enough to resume a job, only to protect it:

  1. The governed reservation. Re-attach must re-account the memory the engine already holds without a second lease race. The record should carry the reserved bytes (and the resource consumer name, genome-train:<job>), so the new core re-creates the lease for exactly that allocation instead of re-admitting.
  2. What finish needs. The in-place run's finish moves <out>.gguf from the train dir to the job dir, files the footprint under the shape (base, window-that-ran, rank, targets, depth), and hands a TrainingArtifact to the sentinel (persona, trait_kind, base, signature). None of that survives a core restart today. Either the record carries a job_spec (or a path to a persisted one: the TrainingJobRequest fields plus job_dir and the shape), or re-attach can only protect the run and never complete it.
  3. Epochs (for progress) belong in the same spec.

Suggest one optional job_spec on ResidentWork written at admission. Slice 1 can leave it None; my slice 3 fills and reads it, so the schema does not have to change twice.

joelteply and others added 3 commits September 28, 2026 09:58
…the exact binding, and settled needs a positive ACK (Codex on #4531)

- Liveness is three-valued. Dead only when VERIFIED: no such process (on Unix, confirmed by
  kill(pid, 0) returning ESRCH; EPERM means it exists) or a readable, different start time (a
  reused pid). An unreadable start time or a legacy record with none is Unknown, and Unknown
  work is held, never released. A binding is only ever recorded with a nonzero start time.
- record() is idempotent for the same binding and REFUSES a different binding for an
  already-bound job; release() removes only the exact binding (job, out, incarnation), so a
  stale controller can never remove a successor's binding.
- EngineProbe::settled accepts only positive evidence: verified death, or a 2xx answer that THIS
  run (its out) is Done/Cancelled/Error, with the incarnation re-checked as the same process
  after the round trip. Foreign, idle, non-2xx, unreadable or no answer: held.
- ResidentWork carries the governed reservation (consumer, reserved_bytes) so a successor core
  re-accounts that exact allocation instead of re-admitting (Fable on #4531, step 3's input).
- Tests: a reused pid is death and releases; an unreadable start and a legacy record are
  Unknown and held; a different binding for a bound job is refused; a stale binding releases
  nothing and the exact one does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…orm; anything else is Unreadable and held (Codex on #4531)

probe_process gains Unreadable. When the process table does not list the pid:
- Unix: kill(pid, 0) = ESRCH is Absent; success or EPERM is Present; ANY other errno is
  Unreadable (the doc claimed only ESRCH; the code let every other error fall through to Absent).
- Windows: OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION) failing with ERROR_INVALID_PARAMETER
  is Absent; a handle is Present; any other failure (access denied, …) is Unreadable. A missing
  sysinfo entry alone is no longer read as absence.
Unreadable maps to Liveness::Unknown, which holds the engine and releases nothing. Test row added.

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

Copy link
Copy Markdown
Contributor Author

Word at 05ed35e: approve. Since my read at 8b64ebe the only change is the adapter tests constructing LaneChoice instead of a tuple, which is the typed shape I'd want anyway. CI is 7/7 green at this head. Step 3 (job_spec on ResidentWork, card 7bb4e5a2) is mine once this lands.

@joelteply
joelteply merged commit f7457f0 into canary Sep 28, 2026
7 checks passed
@joelteply
joelteply deleted the feat/resident-ownership-contract branch September 28, 2026 15:51
joelteply added a commit that referenced this pull request Sep 28, 2026
…a release retires the contaminated record (SHARED-RESIDENT-LIFECYCLE step 2) (#4536)

* feat(lifecycle): serving's footprint never counts resident work, and a release retires the contaminated record (SHARED-RESIDENT-LIFECYCLE step 2)

On the 5090 (2026-09-28 12:29:07) sample_lane_footprint read a live /train run's graph,
optimizer and adapter (~7.4 GB) as serving cost; the record carried it as fixed per-lane
residency, the 27B stopped fitting, and the plan replaced the engine the run was in.

- sample_lane_footprint withholds its reading (leg resident_work) while engine_occupancy holds
  (live work bound to this engine, or a binding that cannot be read or verified), and for one
  sample interval after work leaves (leg resident_work_settling): the engine frees
  asynchronously and the device reports late.
- Every release (the fenced release and the verified-death release) retires that model's
  footprint record in one place (on_released), so no reading taken while the work was resident
  can rule the next plan; the next clean sample replaces the estimate.
- Test: releasing resident work retires the model's record and notes the settle.

Stacked on #4531 (step 1). Contract: docs/architecture/SHARED-RESIDENT-LIFECYCLE.md (#4527).

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

* fix(lifecycle): a release retires only a footprint sampled during the work, and the test owns its store (Fable on #4536)

- on_released retires the model's lane_footprint record only when
  last_ms >= work.created_ms; a record from before the work is the last
  clean measurement and keeps ruling the plan.
- the retire decision is a pure function on a map (retire_sampled_since),
  so the test asserts both cases on a local map and never writes the live
  ~/.continuum lane-footprint store.
- note that LAST_RELEASE_MS is per process by intent (boot releases dead
  work through on_released).

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

* fix(lifecycle): a footprint sample publishes only under the residency it began with (Codex on #4536)

- lane_footprint gains a residency epoch, advanced under the records' lock
  whenever work binds (engine_residency::record) or leaves (on_released).
  The sampler takes a SampleToken before it reads occupancy; observe
  publishes only if the epoch has not moved, so a reading that awaited
  across a bind or a release is dropped instead of written (or written
  back after the release retired the record).
- the first settle window of a process counts as a release: a predecessor
  core's release is unknown to this one, so it is waited out, not assumed
  clean.
- the residency test fixture names a test-only base model: release() now
  retires footprint records, and "qwen3-27b" could match a live one.

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

---------

Co-authored-by: Claude Opus 5.5 <[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