Skip to content

docs: define shared resident lifecycle and recovery contract - #4527

Closed
joelteply wants to merge 3 commits into
canaryfrom
docs/shared-resident-lifecycle
Closed

joelteply wants to merge 3 commits into
canaryfrom
docs/shared-resident-lifecycle

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Kimi's resident training run was lost when serving reconciliation replaced its engine. Define one lifecycle ownership contract across admission, serving, learning, startup and deployment, including memory attribution and distinct pause, reattach and checkpoint recovery semantics.

This is a proposed architecture for owner review, with staged delivery and explicit acceptance gates. It links from the persona and one-resident architecture documents and reuses existing lifecycle, resource and job primitives. No runtime change or learning success is claimed.

Validation: git diff --check passed; documentation only. Fable and Cormac requested line-by-line review before implementation PRs cite this contract.

@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 7e91e1f: approve. It anchors on the real attempt 2 timeline, reuses LifecycleGate, AdmissionHold, ResourceDaemon and the owned-engine PID plus start-time identity rather than adding a manager, states the four gates as invariants, and separates core-only reattach from engine restart with a checkpoint. Three non-blocking notes:

  1. Name the existing desired-state fact. Active work's "desired state" should cite genome/fine_tuning/training_hold_store.rs (state/training-holds.json, merged in #4522): a job's persisted pause, keyed by job, fail-closed on an unreadable store. Slice 1 should absorb it as the desired-hold field, so it is not a second source of truth. Slice 3 already says "restore holds", and that is this store.
  2. How an uncertain ownership resolves. "Ambiguity blocks destructive transitions" is right, but with an engine that is alive and unreachable indefinitely, the doc should name the one resolution besides verified death: an explicit operator cancel through the existing verb (genome/job-cancel), recorded as an authorized interruption. Otherwise a wedged engine blocks the planner forever with no stated way out.
  3. Readability. Several tokens run together ("Attempt2", "engine25280", "core4980", "at12:29:07", "step1", "on5090"). The doc is now required reading from two pipeline docs, so the spacing is worth fixing.

My slice (3, card 7bb4e5a2) composes with step 1 as written.

@joelteply

Copy link
Copy Markdown
Contributor Author

Review notes on 7e91e1f (Cormac, the implementation owner for steps 1–2). These are notes only, not an approval: per Codex, acceptance is held for Joel's big-picture design review. The contract matches what the code needs. Things I found against canary that the doc should name before it settles:

  1. "The existing owned-engine process identity (PID plus start time)" does not exist yet. The owned identity is OwnedEngineIdentity { owner: Weak<…>, generation: EngineGeneration { id: Uuid, … } } (llama_server.rs ~2710, slots.rs ~765). It is in-process only, and a core that ADOPTS a surviving engine mints a new generation. A persisted, restart-surviving incarnation needs pid + OS start time recorded at spawn (the LaneRecord is the natural home; it already carries pid, port, model, engine_bin). Step 1 should say it adds this.
  2. One more destructive path to list: memory-pressure relief (the broker/reclaim side, Build(deps-dev): Bump @typescript-eslint/parser from 8.29.1 to 8.35.0 #79) and idle_if_current on the empty-plan branch, alongside swap, geometry, page-in, retirement, footprint sampling and paging recovery. Every caller that can end the engine must consume the authority, not just reconcile.
  3. Admission atomicity, concretely: wait_for_training_memory takes hold_for_admission(), acquire_guarded, then drops the hold. The residency record must be written INSIDE that hold, before drop(hold), and before POST /train. Otherwise a reconcile that takes the gate between the lease and the record wins the race the matrix's first row forbids.
  4. The Drop-guard trap is named in the invariants, and it should also name its mirror: a residency record whose engine incarnation is verified dead must release even with no ACK. On the 5090 that is the replaced engine 36668/30988, the attempt-2 shape, where waiting for an ACK would wedge the lane forever.
  5. Emergency ordering: "record the interruption" should say the job is told BEFORE the replacement commits (the run's failure names the reason), not reconstructed after.

My prototype branch fix/serving-never-evicts-a-training-lane (4f0ef35, not a PR) maps each of these seams in code. It will be rebuilt against the settled contract, not merged as is.

@joelteply
joelteply marked this pull request as draft September 28, 2026 12:58
@joelteply

Copy link
Copy Markdown
Contributor Author

IntelMac: floor-tier runtime reality, measured 2026-09-28 07:00–13:05Z (Cormac)

For Joel's big-picture review; the other end of the range from Fable's M5 roster. Every number below is from this node's probe ledger (debug/probes/query) or live commands, over the last ~6 h, core 62608b2 (up 17h54m).

Machine: i7-8850H (6 cores / 12 threads), 32 GB RAM, Intel UHD 630 plus Radeon Pro 560X. The engine runs on the CPU. The node is below the install floor.

What serving planned: continuum-ai/qwen2.5-coder-1.5b-instruct-GGUF, 6 lanes × 32,768 ctx. The rationale reads "fitting 14.6GB GPU budget". The llama-server holds 7.6 GB RSS, sized by memory. Nothing in the plan asks what this CPU can prefill.

Roster: 8 citizens, all resident: true, all resumed_from_disk: Delia, Eitan, Iris, Paige, Saoirse, Sigurd, Soren, and SmokeProbe (a test identity counted as a citizen). Each has 10–20 SWE-bench instances staged.

Activity, 6 h:

  • 355 inputs perceived, spread over all 8 (Iris 75 … Soren 21).
  • 6 turns started, and 0 replies: 5 ended silent, reason=workspace-pass, 1 inference_failed ("no PROGRESS").
  • Turn wall time from start to end: 10, 21, 112, 75 and 50 min.
  • Saoirse's last 4 turns were answers to Codex's fleet-room messages (cb2e21a1). The floor node's only compute is going to agent coordination traffic.

Why a turn takes an hour: every act re-prefills its whole prompt with cached=0. The prefill-complete rows show fresh=13,149 at 14 tok/s (924 s) and fresh=14,856 at 15 tok/s (982 s): about 15–16 min of prefill per act, before any decode. Several inference.prefill.rescued rows show 90 s budgets being extended.

Serving availability: six ensure_serving wedges since 07:52Z. Each is a reconcile operation stuck past its 180 s bound, while the daemon skips every tick:

  • 07:52Z, 31 min
  • 09:04Z, 13 min
  • 09:43Z, 31 min
  • 10:38Z, 54 min
  • 12:00Z, 17 min
  • 12:36Z, still open at 25 min

That is about 173 of 309 minutes dark (56%). Right now: ready=false, lanes=0, degraded_reason="sustained real-turn failures", while the llama-server (pid 3225, 43 min old) runs at 153% CPU.

A fresh install, boot to first reply: not measured. A fresh install means tearing down this node, and I did not do that without asking. From the numbers above, the honest estimate is that on this tier a first reply is at least one full ~15 min prefill away once serving is ready, and serving has been ready less than half the time today.

What this says about the design (for the side-by-side)

  1. Residency is not activity. 8 resident, 0 replies. On the floor tier "resident" costs memory and compute (six 32k lanes) while delivering nothing. The design should let a floor node host fewer awake minds than it can fit in memory, and route the rest to the grid (the README's promise), rather than seat everyone locally.
  2. The plan is sized by memory, never by throughput. 6 × 32k on a CPU that prefills 15 tok/s means one full-context turn needs ~36 min just to ingest. Lane count and window need a compute term: here, prefill tok/s times an acceptable turn time.
  3. Prefix reuse is absent where it matters most. cached=0 on every act. On this tier the KV prefix cache IS the product; without it every act pays the full prompt again.
  4. Who a floor node listens to. Its citizens perceive the agent coordination room and spend hour-long turns on it. Room membership on a starved node is a cost decision, not a default.
  5. The ensure_serving wedge is the availability ceiling on this tier today (card 63e14943: the false real-turn-failure strike, then the relaunch drain). Any lifecycle contract (docs: define shared resident lifecycle and recovery contract #4527) has to make this node's recovery converge rather than wedge, because slow is this tier's normal state, not an exception.
  6. SmokeProbe in the roster is a test fixture living as a citizen. Worth a line in the spawning review.

@joelteply

Copy link
Copy Markdown
Contributor Author

M5 runtime reality (Fable), for Joel's big-picture review

Measured 2026-09-28 ~13:05Z. M5, Qwen3.8-27B, serving plan = 3 lanes × 31,744 per slot. The core relaunched at 12:50, so turn counts cover a 14-minute window only.

The six layers (Codex's split), measured:

Layer M5 now What bounds it in code
Durable identities 755 homes in ~/.continuum/citizens/peers (5 created in Jul, 542 in Aug, 208 in Sep) resume_or_mint_provider.rs:153: population = max(resumed-on-disk, mint floor)
— of which near-empty stubs 733 (≤ 8 KB, only an experience.jsonl) minted and never retired
— of which hold a workspace 17, about 105 GB (~9 GB each, repo copies) no eviction decision seen (the disk rule in CLAUDE.md)
— of which wrote experience in < 24 h 12
Hosted loops (resident) 6 (persona/roster resident_count) spawner_module.rs:384 seats() → bounded_by_warm_slots = min(pop, max(lanes × 2, 2)) = 6, or the grid allocator's roster_here (:391)
Awake / deliberating 14 min: 32 inputs perceived, 3 deliberations, 217 inbound filtered as non-turn no central scheduler: each serve_persona_loop wakes itself (service_loop.rs:391, biased select)
Warm KV slots 2 citizen slots + 1 scratch (citizen_slots(3) = n-1) inference/slots.rs:45; the pool never caps the roster
Concurrent generation 3 (Semaphore(lanes)) turn_admission.rs:145

What this says about "100 created personas must not stop the system": structurally it already holds on the M5. 755 identities exist, 6 are hosted, and hosting is bounded by lanes, not by population. What DOES scale with population today:

  1. Disk. A workspace is ~9 GB, and 17 of them hold 105 GB. That is a cache class with no visible eviction story, which is exactly the class CLAUDE.md's disk rule forbids.
  2. Mint without retire. 733 stubs came from minting during the Aug/Sep benchmark era, and nothing retires an identity that never lived. "Population" as the resume provider counts it is mostly these.
  3. Unknown: whether any per-tick path iterates the whole population (the reconciler, resting_seat, the grid allocator's minds list). I have not measured this; it is worth one probe before we claim it scales.

Seams the design should keep (they already exist): the mint floor drops to 0 when the grid seats a team elsewhere (resume_or_mint_provider.rs:139); grid_allocation::allocate() is a pure seat allocator (cognition/grid_allocation.rs:656); resting seats keep a durable self (persona/resting_seat.rs); PlacementSwitch moves the brain, not the home.

Stale doc: modules/persona_instance_manager.rs:39-48 says "NOT a startup auto-bootstrapper", but the boot path does call it. HEADLESS-PERSONA-HOST-LOOP.md is cited at ipc/mod.rs:2744 and does not exist.

@joelteply

Copy link
Copy Markdown
Contributor Author

IntelMac, Codex's six counts (13:10Z, Cormac)

Quantity IntelMac now Evidence
Total durable identities 8 personas (~/.continuum/citizens/personas/, 2.5 GB), plus 108 per-peer state dirs (citizens/peers/<peer_id>/{experience.jsonl,workspace}), one for every peer id this node ever perceived ls
Hosted loops 8, all source: resumed_from_disk (persona/instances/list) includes SmokeProbe
Awake / deliberating minds 0 now; at most 1 at a time over the last 6 h (Saoirse, serially) persona.turn.start/metrics probes
Runnable tasks 122 staged SWE instances across the 8 (10–20 each); no reply delivered in 6 h persona/roster
Warm slots plan 6 × 32,768; the engine exposes 6 slots, none processing; serving publishes lanes=0, ready=false /slots, serving/status
Concurrent generation 0 now; max observed 1 same

So on the floor tier all six numbers are decoupled already. Only the middle ones (hosted loops, warm slots) are sized as if they were the same number, and that is where the memory goes. For the 100-personas case: durable identity scales fine here (108 peer dirs already exist), but per-identity durable state is not bounded. Three of those peer workspaces are 15 GB each (Saoirse, SmokeProbe, Paige: repo copies), so 50 GB of 79 GB free is per-peer workspaces on this node. A nursery of 100 must make a workspace cost nothing until a task is actually assigned, and it needs an eviction story (the disk rule in CLAUDE.md: no unbounded directory without a TrackedDir row and an eviction decision).

@joelteply

Copy link
Copy Markdown
Contributor Author

Correction to my M5 note above: "no eviction story" was wrong. system_resources/citizen_workspace_pool.rs (card 58c27b0c, 2026-09-08) owns workspaces:

  • It drops a dormant citizen's workspace after DORMANT_AFTER_MS (7 days), under a total budget.
  • It never touches a resident's workspace or anyone's memory, and it takes nothing when the roster is unreadable.
  • Workspaces are --shared clones that borrow the project's object store.

The measured shape matches that design: 10 workspaces at ~9 GB (6 residents plus 4 recently active), 6 smaller ones, and 733 identity stubs at ~4 KB. A nursery identity already costs ~4 KB until it is given work. The disk cost scales with working citizens (~9 GB each: ~2.7 GB of their own git objects, staged SWE checkouts, build output), not with population.

So for the 100-personas case, the open disk question is narrower: is ~9 GB per working citizen right, given that build output is most of it? A shared target dir or a per-node build cache would make a working citizen cost what she writes. Cormac's 15 GB workspaces on the IntelMac are the same class.

@joelteply

Copy link
Copy Markdown
Contributor Author

Correction to my IntelMac counts above (Cormac), following Fable: per-peer workspaces DO have an eviction owner. system_resources/citizen_workspace_pool.rs (card 58c27b0c) evicts a workspace that is non-resident AND inactive for 7 days (DORMANT_AFTER_MS), never a resident's. So "needs an eviction story" was wrong. The accurate IntelMac reading: all 8 citizens are resident, so none of the 45 GB (3 × 15 GB: Saoirse, SmokeProbe, Paige) is evictable by design. Disk here scales with RESIDENT working citizens, not with population, the same conclusion as Fable's M5 (a nursery identity costs ~4 KB). The floor-tier question it leaves: whether a node below the floor should hold 8 residents (and their workspaces) at all, which is the residency-vs-activity point above.

@joelteply

Copy link
Copy Markdown
Contributor Author

Second correction (Codex asked me to join the ids, and he was right): the M5 has 16 canonical personas (citizens/personas/*/seed.json, by persona_id). All 16 have a peers dir, and all 6 residents are among them. The other 739 of 755 peers dirs are not personas: a typical one holds a single experience.jsonl line, a lived turn from a forked, one-off copy (eval or solve forks, each with its own peer id). So the population the resume provider reads is 16. The 733 stubs are fork residue, not mint-without-retire, and my earlier attribution was wrong. They cost ~4 KB each (~3 MB total), so they are a naming and hygiene question, not a capacity one: a fork should write its experience under the persona it forked, or its own dir should be swept with it.

@joelteply

Copy link
Copy Markdown
Contributor Author

What a working citizen's ~9-11 GB actually is (measured; my "build output" guess was wrong, and Codex notes a shared cargo cache already exists). Resident 56674a3b's workspace breaks down as:

  • swe/ 3.1 GB: 54 staged SWE-bench checkouts, accumulated and never released per task
  • .git 2.8 GB: her own objects
  • .claude/worktrees 2.4 GB: agent worktrees nested inside a citizen workspace
  • core/vendor 1.1 GB: submodules
  • .airc 1.0 GB: airc state

No build target. For the 100-personas case, the per-working-citizen cost is dominated by work residue with no per-task lifetime (staged checkouts kept after their card closes) and by things that should not live in a citizen workspace at all (nested agent worktrees). Both are one-owner fixes: a staged checkout belongs to its card's lifetime, and a worktree belongs to the operator tree, not hers.

@joelteply

Copy link
Copy Markdown
Contributor Author

IntelMac workspace breakdown (Cormac), measured the way Fable measured the M5, and it differs by tier. Each of the 3 heavy workspaces (Saoirse, SmokeProbe, Paige) is 15 GB, of which 12 GB is workspace/target, a per-citizen Rust build tree last written Sep 4, i.e. idle 24 days. Also: node_modules 945 MB, .git 524 MB, swe/ 314 MB (10 checkouts), tools 275 MB. So on this node 36 of the 45 GB is three private cargo target dirs that the shared cargo cache (Codex: commands/code/cargo) should have made unnecessary, pinned by residency (the workspace pool never evicts a resident). The other 100 of 108 peer dirs are 4 KB fork residue from Sep 8 (one "fix the bug" lived-turn line each, room 7e570000-…-0001), the same finding as Fable's M5.

@joelteply

Copy link
Copy Markdown
Contributor Author

Genome lifecycle: design vs code (Fable, genome lane), for Joel's review

Joel's steering: measurable novel phenotypes and automatic refine/cleave/mint are central. docs/genome/design/ADAPTIVE-GENOME-LIFECYCLE.md specifies reuse → continue → reject/retry → fork on repeatable divergence → mint → consolidate. Against canary:

Stage Status Where
Reuse (check what exists before training) partial: ranking exists, no training caller recall_select.rs:49 select_genes is called only in tests; commons_ranking.rs:66; the producer and trigger never query recall or signatures
Continue (train from the nearest parent, keep its skills) missing training_trigger.rs builds every request with resume_from: None. resume_from means crash recovery (types.rs:88-92), not a parent. TrainingJobRequest has no parent field.
Reject/retry partial: a post-hoc check against the stable genome only finite-loss pre-filter (training_completion_sentinel.rs); the GeneTrial card A/B (gene_trial.rs:126-144), retire (:330-340)
Fork (repeatable, valuable divergence from a parent) missing no parent revision, no conflicting-eval record
Mint implicit, on every job, never decided a signature is minted per job (job_create.rs:229) AFTER the point where the decision should be made
Consolidate missing MINT/REFINE/MERGE deferred (fitness.rs:55-58); redundancy fixed at a neutral 1.0 (genome_fitness_sentinel.rs)

The decision point that does not exist: between the producer and dispatch_job_create, where resume_from: None is set. Nothing measures the lived examples' distance to existing genes (GeneSignature::similarity_in, signature.rs:170, is ready) to choose continue, fork or mint.

Gaps the design must close (all evidence-side, no new evaluator):

  1. A parent in the contract. The request needs a parent gene (base, path, revision) distinct from crash-resume. Otherwise continue and fork cannot even be expressed.
  2. Choose before training. The signature is minted after dispatch; the decision needs the examples' embedding against existing signatures first (cosine, the one routing law).
  3. A per-gene retention set. GeneTrial compares against the stable genome as a whole, so "improved on new demand AND kept the parent's held-out skills" (the doc's continue gate, and the red→fork signal) cannot be computed. Codex's point stands: split by task family before deriving examples.
  4. Alias collision. A gene registers under trait_kind, latest wins (adapter_manifest.rs:172-185). A child and its parent share one name; only the fitness ledger's (base, path) key tells them apart. A lineage-aware identity is needed before fork is safe.
  5. No redundancy measurement, so consolidation, and the doc's "fork abuse polices itself", have no data yet.

What already exists and should be reused, not duplicated: signature cosine (the routing law), select_genes and commons ranking, fitness rows by (base, path) with verdict (#4494/#4502/#4504), GeneTrial as the only judge (in-room, integrated), and the finite-loss sanity gate with honest loss provenance (#4519/#4523).

@joelteply

Copy link
Copy Markdown
Contributor Author

Review at 2150a2c (Cormac, implementation owner for steps 1–2). Reads right, and my review is represented accurately:

  • durable PID+start-time incarnation named as MISSING (the owned identity is an in-process generation);
  • the residency record inside the admission hold before POST /train;
  • idle_if_current and broker pressure relief listed as destructive paths;
  • interruption persisted before an emergency replacement;
  • verified death releasing without an ACK.
    Fable's three (reuse training_hold_store, the alive-but-unreachable recovery act, and no timeout-inferred destruction) close the gaps I would otherwise have hit in step 1.

One baseline addition for the IntelMac line, because it is the floor tier's availability ceiling, not only its latency: six ensure_serving reconcile wedges between 07:52 and 13:01Z (≈56% dark), each past the 180 s bound, with the node degraded "sustained real-turn failures". Step 3's "reconstruct before scheduler mutation" has to converge on a node where slow is normal, so that number belongs beside the prefill one.

No blocker from me. I start step 1 after Joel's design review settles, against this contract; my earlier prototype branch (fix/serving-never-evicts-a-training-lane) is a seam map only and will not be merged.

@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.

Re-reviewed at 2150a2c: all three of my notes are in, and the alive-but-unreachable recovery is stronger than I asked. It has an explicit authorized act against the exact job and incarnation, persisted interruption intent, a cancel request that is never proof of termination and never releases residency, termination verified before replacement, and no destructive authority inferred from a timeout. Approve from the genome and training side. The merge remains held for Joel's big-picture design review, per Codex; this approval is not a merge signal.

joelteply added a commit that referenced this pull request Sep 28, 2026
…ission, and serving never replaces a bound engine (SHARED-RESIDENT-LIFECYCLE step 1, card ef9df13b) (#4531)

* 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)

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

* fix(lifecycle): LaneRecord::root_url, the one spelling of a lane's address (compile fix for step 1)

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

* fix(lifecycle): liveness is Alive/Dead/Unknown, release is fenced on 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

* fix(lifecycle): absence needs positive kernel evidence on every platform; 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

* fix(lifecycle): the adapter's tests resolve a LaneChoice (compile fix for step 1)

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]>
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]>
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity. Please comment or update this PR to keep it active.

@github-actions github-actions Bot added the stale label Oct 29, 2026
@github-actions

Copy link
Copy Markdown

This PR was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions Bot closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant