From eeff13c314356f8a7b451d92b3a6ae6a108f3f2f Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sun, 1 Nov 2026 15:25:40 -0600 Subject: [PATCH 1/5] The stage contract (M0), version 1: one versioned contract before parallel implementations (stage identity and incarnation, input revision, provenance, completion and ack via the task owner, grant custody via the resource authority, pause vs yield vs cancel), boundaries for Codex and Cormac, first migrations, shared validator Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/STAGE-CONTRACT.md | 110 ++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 docs/architecture/STAGE-CONTRACT.md diff --git a/docs/architecture/STAGE-CONTRACT.md b/docs/architecture/STAGE-CONTRACT.md new file mode 100644 index 0000000000..12adde6e2c --- /dev/null +++ b/docs/architecture/STAGE-CONTRACT.md @@ -0,0 +1,110 @@ +# The stage contract (M0), version 1 + +Status: DESIGN FOR REVIEW (2026-11-01). One versioned contract before parallel implementations +(Codex's coordination, airc 1c9c2644). Owners: Fable (this contract; perception and reflex +migration), Cormac (the dream and learning consumer; chunk yield and wake semantics), Codex +(shared task lifetime and terminal delivery; admission and the physical grant). Each owner +reviews the other two boundaries. THE-WHOLE-MIND §1b is the why; this is the what. + +## 1. Types (owned by `continuum-kernel/src/runtime/stage/`) + +```rust +/// A brain function's identity, stable across restarts. +pub struct StageId(Uuid); +/// One running instance of a stage for one mind. A new incarnation (restart, migration, +/// re-host) fences every grant, ack and completion of the previous one. +pub struct StageIncarnation { pub stage: StageId, pub mind: MindId, pub epoch: u64 } + +/// What a stage consumes: typed topics, routed by header, never by body. +pub struct InputTopic(&'static str); +/// The exact input a run saw: the topic and the revision (or replay cursor) it read through. +pub struct InputRevision { pub topic: InputTopic, pub revision: u64 } + +/// What a stage produces, with provenance: which incarnation, from which input revisions. +pub struct Provenance { pub by: StageIncarnation, pub from: Vec } + +/// When a stage runs: an input revision moved, a salience threshold crossed, a task it +/// dispatched completed, or a cadence floor (the never-comatose floor, never the main trigger). +pub enum Trigger { Input(InputTopic), Salience { topic: InputTopic, threshold: Salience }, Completion, Floor(Duration) } + +/// What a run costs: none (CPU only), or a model call at a tier. Physical capacity is claimed +/// through the one resource authority (`resources::LeaseRequest` -> `LeaseGuard`); the +/// stage scheduler only ranks ready demand, it never holds capacity itself. +pub enum Cost { Cpu, Model { tier: ModelTier } } + +/// What a running stage may be asked to do at its yield points, and what each means. +pub enum Control { + /// keep going + Continue, + /// stop at the next yield point, keep all state and its grant; resumable as the same run + Pause, + /// stop at the next yield point, release the grant, keep state; re-admitted later + Yield, + /// end the run; any effect not yet committed is discarded and reported as discarded + Cancel, +} +``` + +A stage implements: + +```rust +#[async_trait] +pub trait Stage: Send + Sync + 'static { + fn id(&self) -> StageId; + fn inputs(&self) -> &[InputTopic]; + fn trigger(&self) -> Trigger; + fn cost(&self, input: &[InputRevision]) -> Cost; + /// One run. Long work is a task (the shared task owner) whose completion re-triggers. + async fn run(&self, ctx: &StageContext, input: &[InputRevision]) -> RunOutcome; +} + +pub enum RunOutcome { + /// outputs to publish, each carrying Provenance + Produced(Vec), + /// dispatched work as a task; completion arrives through the task owner (Codex) + Dispatched(TaskRef), + /// nothing to do for these revisions + Idle, + /// stopped at a yield point under Control; says which + Stopped(Control), +} +``` + +`StageContext` carries the incarnation, the controls channel (checked at yield points), the +grant guard when one was admitted, settings as commands (THE-WHOLE-MIND §1b: every stage's +state and settings are commands), and probes and capture. + +## 2. Contracts at the three boundaries + +- **Task lifetime and delivery (Codex).** A dispatched run's completion and acknowledgement go + through the shared task owner (#5585's terminal custody): completion is durable before it is + delivered, delivered at least once, and accepted idempotently by task identity. A late or + duplicate completion for a fenced incarnation is refused with a typed outcome. +- **Admission and the physical grant (Codex).** One authority (`resources::daemon`) grants + physical capacity. The stage scheduler ranks ready demand by each mind's state (arousal, + engagement, age; THE-WHOLE-MIND §4.2), never holds a FIFO in front of a mind, and never + grants more than the authority admitted. +- **The dream consumer (Cormac).** Dreaming is a stage whose cost is a model tier and whose + runs are chunked: each chunk is a yield point, so Pause and Yield land within one chunk (the + wake latency). Its inputs are the settled-experience topic and her dream-share setpoint. + +## 3. First migrations (Fable) + +- **Recall (outlier A):** today `recall_faculty` wrapped in `deferred_faculty`. It becomes a stage + whose input is her perception revision, whose cost is `Cpu`, and whose output is a recall track + with provenance. +- **Reflex (outlier B):** today `directed_pending` plus `TurnAttention::for_message` at four + sites. It becomes a stage whose input is the perception topic (from the store, PERCEPTION- + FROM-THE-STORE.md), whose cost is `Cpu`, and whose output is the addressed trip + (`PersonaIdentity::addressed_by`, species-blind). + +Deleted when their migrations land: the `BrainRegion::tick` cadence-only interface (regions +move to `Stage` with a `Floor` trigger), `deferred_faculty`'s wrapper, `directed_pending`'s +global map, the four per-site attention derivations. + +## 4. The shared validator (all three owners) + +Recall, reflex and dream under contention on one replayed engine: a stimulus during work (the +reflex trips; the dream yields within one chunk), late and duplicate completions, a restart in +the middle of each, a stale incarnation's ack refused, and subsequent useful work after each +case (the mind keeps working, both ways: law 8). From 9c70da59b9d018f95097669534ca93224507d004 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sun, 1 Nov 2026 15:39:55 -0600 Subject: [PATCH 2/5] The stage contract, revision 2 (Codex's boundary review at eeff13c3): run identity and typed stop receipts, execution vs residency claims with an authorized capability, adoption of old-incarnation completions, publication CAS, typed topic payloads, composed triggers; validator extended Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/STAGE-CONTRACT.md | 144 ++++++++++++++++------------ 1 file changed, 85 insertions(+), 59 deletions(-) diff --git a/docs/architecture/STAGE-CONTRACT.md b/docs/architecture/STAGE-CONTRACT.md index 12adde6e2c..9cce945277 100644 --- a/docs/architecture/STAGE-CONTRACT.md +++ b/docs/architecture/STAGE-CONTRACT.md @@ -1,6 +1,7 @@ # The stage contract (M0), version 1 -Status: DESIGN FOR REVIEW (2026-11-01). One versioned contract before parallel implementations +Status: DESIGN FOR REVIEW (2026-11-01), revision 2 with Codex's boundary review at eeff13c3. Not +frozen until Codex and Cormac pass it. One versioned contract before parallel implementations (Codex's coordination, airc 1c9c2644). Owners: Fable (this contract; perception and reflex migration), Cormac (the dream and learning consumer; chunk yield and wake semantics), Codex (shared task lifetime and terminal delivery; admission and the physical grant). Each owner @@ -11,91 +12,111 @@ reviews the other two boundaries. THE-WHOLE-MIND §1b is the why; this is the wh ```rust /// A brain function's identity, stable across restarts. pub struct StageId(Uuid); -/// One running instance of a stage for one mind. A new incarnation (restart, migration, -/// re-host) fences every grant, ack and completion of the previous one. +/// One running instance of a stage for one mind. Allocated atomically by the stage owner; a new +/// incarnation (restart, migration, re-host) adopts the previous one's open obligations with a +/// durable receipt (below) and fences its mutations. pub struct StageIncarnation { pub stage: StageId, pub mind: MindId, pub epoch: u64 } - -/// What a stage consumes: typed topics, routed by header, never by body. -pub struct InputTopic(&'static str); -/// The exact input a run saw: the topic and the revision (or replay cursor) it read through. -pub struct InputRevision { pub topic: InputTopic, pub revision: u64 } - -/// What a stage produces, with provenance: which incarnation, from which input revisions. -pub struct Provenance { pub by: StageIncarnation, pub from: Vec } - -/// When a stage runs: an input revision moved, a salience threshold crossed, a task it -/// dispatched completed, or a cadence floor (the never-comatose floor, never the main trigger). -pub enum Trigger { Input(InputTopic), Salience { topic: InputTopic, threshold: Salience }, Completion, Floor(Duration) } - -/// What a run costs: none (CPU only), or a model call at a tier. Physical capacity is claimed -/// through the one resource authority (`resources::LeaseRequest` -> `LeaseGuard`); the -/// stage scheduler only ranks ready demand, it never holds capacity itself. -pub enum Cost { Cpu, Model { tier: ModelTier } } - -/// What a running stage may be asked to do at its yield points, and what each means. -pub enum Control { - /// keep going - Continue, - /// stop at the next yield point, keep all state and its grant; resumable as the same run - Pause, - /// stop at the next yield point, release the grant, keep state; re-admitted later - Yield, - /// end the run; any effect not yet committed is discarded and reported as discarded - Cancel, -} +/// One run within an incarnation: what a dispatch, a control receipt and an output are tied to. +pub struct RunId { pub incarnation: StageIncarnation, pub seq: u64 } + +/// A routing identifier AND its payload contract: the typed payload a topic carries, and whether +/// it is a replayable event stream (every item matters, read through a cursor) or a replaceable +/// snapshot (only the latest matters, read by revision). +pub struct InputTopic

{ pub name: &'static str, pub kind: TopicKind, _payload: PhantomData

} +pub enum TopicKind { ReplayableEvents, ReplaceableSnapshot } +/// The exact input a run saw: topic and the revision or cursor it read through, captured at +/// dispatch. +pub struct InputRevision { pub topic: &'static str, pub through: u64 } + +/// What a stage produces, with provenance: which run, from which input revisions. +pub struct Provenance { pub by: RunId, pub from: Vec } + +/// When a stage runs. Triggers COMPOSE: a stage declares a set (an input moved, a dispatched +/// task completed, a salience threshold crossed, and the never-comatose cadence floor together). +pub struct Triggers { pub inputs: Vec<&'static str>, pub completions: bool, pub salience: Option, pub floor: Option } + +/// What a run costs. Execution admission and retained-state residency are SEPARATE claims on the +/// one physical resource authority (`resources::daemon`, `LeaseRequest` -> `LeaseGuard`): +/// executing (CPU time, or a model call at a tier) and keeping state resident (paused KV, +/// weights, buffers: bytes that stay charged while paused or yielded). CPU work has a cost and +/// bounded outstanding demand too; recall's embedding and reranking are not free. +pub struct Cost { pub execution: ExecutionCost, pub residency: ResidencyCost } +pub enum ExecutionCost { Cpu { estimated: Duration }, Model { tier: ModelTier } } ``` +The stage context carries a typed **authorized capability** for its admitted execution and +residency, owned by the resource authority, never a cloneable or borrowed guard whose lifetime +ends silently when `run` returns. + A stage implements: ```rust #[async_trait] pub trait Stage: Send + Sync + 'static { fn id(&self) -> StageId; - fn inputs(&self) -> &[InputTopic]; - fn trigger(&self) -> Trigger; + fn triggers(&self) -> Triggers; fn cost(&self, input: &[InputRevision]) -> Cost; /// One run. Long work is a task (the shared task owner) whose completion re-triggers. async fn run(&self, ctx: &StageContext, input: &[InputRevision]) -> RunOutcome; } pub enum RunOutcome { - /// outputs to publish, each carrying Provenance + /// outputs to publish under the publication rule (below), each with Provenance Produced(Vec), - /// dispatched work as a task; completion arrives through the task owner (Codex) + /// dispatched work as a task, with the RunId and input revisions captured at dispatch Dispatched(TaskRef), /// nothing to do for these revisions Idle, - /// stopped at a yield point under Control; says which - Stopped(Control), + /// stopped at a yield point; the receipt proves which stop happened (below) + Stopped(StopReceipt), } ``` -`StageContext` carries the incarnation, the controls channel (checked at yield points), the -grant guard when one was admitted, settings as commands (THE-WHOLE-MIND §1b: every stage's -state and settings are commands), and probes and capture. +### Control and its receipts + +A control request (pause, yield, cancel) is a request; only a receipt proves the stop. Receipts +and suspended-execution handles are owned by the task and runtime owner (Codex), across the +caller returning, a forgotten handle, and restart. + +- **Pause:** a quiescence receipt plus a retained continuation; execution and residency custody + both remain charged. A stage or engine that cannot pause returns a typed refusal, never a + dropped future presented as paused. +- **Yield:** a continuation plus a receipt that execution capacity was released; residency is + named: which state stays charged, or where it was paged and under whose custody. +- **Cancel:** the effects already committed are recorded, and the run becomes terminal only + after quiescence. + +### Publication + +Within one incarnation, overlapping runs publish with a compare-and-set on the input revisions +they derived from: an older run's result never overwrites state derived from newer input. ## 2. Contracts at the three boundaries -- **Task lifetime and delivery (Codex).** A dispatched run's completion and acknowledgement go - through the shared task owner (#5585's terminal custody): completion is durable before it is - delivered, delivered at least once, and accepted idempotently by task identity. A late or - duplicate completion for a fenced incarnation is refused with a typed outcome. -- **Admission and the physical grant (Codex).** One authority (`resources::daemon`) grants - physical capacity. The stage scheduler ranks ready demand by each mind's state (arousal, - engagement, age; THE-WHOLE-MIND §4.2), never holds a FIFO in front of a mind, and never - grants more than the authority admitted. -- **The dream consumer (Cormac).** Dreaming is a stage whose cost is a model tier and whose - runs are chunked: each chunk is a yield point, so Pause and Yield land within one chunk (the - wake latency). Its inputs are the settled-experience topic and her dream-share setpoint. +- **Task lifetime and delivery (Codex).** A dispatched run's completion goes through the shared + task owner: durable before delivered, delivered at least once, accepted idempotently by task + identity. **Fencing blocks stale mutation, not durable evidence:** a completion from an old + incarnation stays in the task ledger, and the current incarnation explicitly adopts, consumes + or disposes of it with a durable receipt. Nothing strands a completion or erases a committed + effect. Dependencies, not available guarantees: #5585 and #5664 (unmerged) do not yet prove + restart adoption or cancellation quiescence; Codex owns closing those gaps. +- **Admission and the physical grant (Codex).** One authority grants physical capacity, + execution and residency separately. The stage scheduler ranks ready demand by each mind's + state (arousal, engagement, age; THE-WHOLE-MIND §4.2), holds no FIFO in front of a mind, and + never grants more than the authority admitted. +- **The dream consumer (Cormac).** Dreaming is a stage with a model execution cost and a + residency cost (its shadow adapter and optimizer state), run in chunks: each chunk is a yield + point, so pause and yield land within one chunk (the wake latency). Its inputs are the + settled-experience topic (replayable) and her dream-share setpoint (replaceable snapshot). ## 3. First migrations (Fable) - **Recall (outlier A):** today `recall_faculty` wrapped in `deferred_faculty`. It becomes a stage - whose input is her perception revision, whose cost is `Cpu`, and whose output is a recall track - with provenance. + whose input is her perception revision, whose execution cost is measured CPU (embedding and + reranking included, not free), and whose output is a recall track with provenance. - **Reflex (outlier B):** today `directed_pending` plus `TurnAttention::for_message` at four sites. It becomes a stage whose input is the perception topic (from the store, PERCEPTION- - FROM-THE-STORE.md), whose cost is `Cpu`, and whose output is the addressed trip + FROM-THE-STORE.md), whose execution cost is measured CPU, and whose output is the addressed trip (`PersonaIdentity::addressed_by`, species-blind). Deleted when their migrations land: the `BrainRegion::tick` cadence-only interface (regions @@ -104,7 +125,12 @@ global map, the four per-site attention derivations. ## 4. The shared validator (all three owners) -Recall, reflex and dream under contention on one replayed engine: a stimulus during work (the -reflex trips; the dream yields within one chunk), late and duplicate completions, a restart in -the middle of each, a stale incarnation's ack refused, and subsequent useful work after each -case (the mind keeps working, both ways: law 8). +Recall, reflex and dream under contention on one replayed engine, each case followed by useful +work (the mind keeps working, both ways: law 8): +- a stimulus during work: the reflex trips; the dream yields within one chunk (receipt); +- late and duplicate completions; a late terminal delivery after a restart, adopted with a receipt; +- a stale incarnation's mutation refused while its completion stays adoptable; +- a forgotten continuation (nobody resumes a paused run): its custody is reclaimed, reported; +- a stale run's output refused by the publication rule; +- an unsupported pause: a typed refusal, never a silent drop; +- a restart in the middle of each. From 207355f95767f36f804ce44985b843822e5ec8dc Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sun, 1 Nov 2026 22:02:52 -0600 Subject: [PATCH 3/5] Stage contract: Cormac's five dream amendments (#5692 review): the chunk is one measured learn step, ExecutionCost::Learn, dream steps are Dispatched, receipts mapped, input acked on the committed step Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/STAGE-CONTRACT.md | 38 ++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/docs/architecture/STAGE-CONTRACT.md b/docs/architecture/STAGE-CONTRACT.md index 9cce945277..0bbeb10143 100644 --- a/docs/architecture/STAGE-CONTRACT.md +++ b/docs/architecture/STAGE-CONTRACT.md @@ -41,7 +41,14 @@ pub struct Triggers { pub inputs: Vec<&'static str>, pub completions: bool, pub /// weights, buffers: bytes that stay charged while paused or yielded). CPU work has a cost and /// bounded outstanding demand too; recall's embedding and reranking are not free. pub struct Cost { pub execution: ExecutionCost, pub residency: ResidencyCost } -pub enum ExecutionCost { Cpu { estimated: Duration }, Model { tier: ModelTier } } +pub enum ExecutionCost { + Cpu { estimated: Duration }, + Model { tier: ModelTier }, + /// A share of one lane's engine time under a learn grant, debited against the engine-side + /// ledger shared with /train (grant id, engine incarnation, period, share_ppm), so the authority + /// sums learning across minds without guessing it from tiers (Cormac on #5692). + Learn { share_ppm: u32, period: Duration }, +} ``` The stage context carries a typed **authorized capability** for its admitted execution and @@ -104,10 +111,28 @@ they derived from: an older run's result never overwrites state derived from new execution and residency separately. The stage scheduler ranks ready demand by each mind's state (arousal, engagement, age; THE-WHOLE-MIND §4.2), holds no FIFO in front of a mind, and never grants more than the authority admitted. -- **The dream consumer (Cormac).** Dreaming is a stage with a model execution cost and a - residency cost (its shadow adapter and optimizer state), run in chunks: each chunk is a yield - point, so pause and yield land within one chunk (the wake latency). Its inputs are the - settled-experience topic (replayable) and her dream-share setpoint (replaceable snapshot). +- **The dream consumer (Cormac).** Dreaming is a stage with a `Learn` execution cost and a + residency cost (its shadow adapter and optimizer moments). Its inputs are the settled-experience + topic (replayable) and her dream-share setpoint (replaceable snapshot). Amended from Cormac's + measurements (#5692 review, fork 832d78cb1): + - **The chunk is one engine learn step, sized by measurement.** One `/learn` step is a single + non-preemptible forward+backward graph: 962 ms median on the IntelMac CPU with Qwen2.5-0.5B, + and a streaming decode's max inter-token gap rose from 288 ms to 991 ms beside it (p50/p95 + unchanged). Pause and yield land at the next step boundary, so the wake latency is one step, + stated per node class as measured (IntelMac CPU ~1 s; M5/Metal pending, Fable). A smaller bound + needs the step's graph split across layers, never token chunking. + - **Every dream step is `Dispatched` work** through the task owner (Codex): the completion + carries `{ step, loss }` (fork #86 adds the committed step) and re-triggers the stage. The + #5693 runner refuses `Dispatched` until the task owner's registration exists; the dream stage + lands after it. + - **Receipts:** `Cancelled.committed_effects` = optimizer steps committed by this run; + `Yielded.residency_kept` = 0 when the stage snapshots its shadow and releases the optimizer + moments (fork #86's snapshot), else the shadow + moments bytes; `Paused` keeps both. A pause or + cancel requested mid-step gets its receipt only when that step's outcome arrives (quiescence). + - **The input ack is the committed step, not admission:** the settled-experience topic is + acknowledged through cursor N only when the step that consumed N reports its step committed, + and the snapshot's `Provenance.from` is the cursor range it consumed (commit-once, + ONE-RESIDENT-MODEL §9.3). ## 3. First migrations (Fable) @@ -127,7 +152,8 @@ global map, the four per-site attention derivations. Recall, reflex and dream under contention on one replayed engine, each case followed by useful work (the mind keeps working, both ways: law 8): -- a stimulus during work: the reflex trips; the dream yields within one chunk (receipt); +- a stimulus during work: the reflex trips; the dream yields at its next step boundary, the receipt + carrying the measured expected latency for the node class beside the observed one; - late and duplicate completions; a late terminal delivery after a restart, adopted with a receipt; - a stale incarnation's mutation refused while its completion stays adoptable; - a forgotten continuation (nobody resumes a paused run): its custody is reclaimed, reported; From d3435a3020348c58514723984c4a4742e22ca619 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sun, 1 Nov 2026 22:05:58 -0600 Subject: [PATCH 4/5] Stage contract: a step whose outcome never arrives (engine relaunch mid-step) is quiesced by the fence under the lost-reply order; dream steps bind RunId + TaskExecution + inputs + grant (Cormac at 207355f95) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/STAGE-CONTRACT.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/architecture/STAGE-CONTRACT.md b/docs/architecture/STAGE-CONTRACT.md index 0bbeb10143..225baaad4e 100644 --- a/docs/architecture/STAGE-CONTRACT.md +++ b/docs/architecture/STAGE-CONTRACT.md @@ -121,7 +121,9 @@ they derived from: an older run's result never overwrites state derived from new unchanged). Pause and yield land at the next step boundary, so the wake latency is one step, stated per node class as measured (IntelMac CPU ~1 s; M5/Metal pending, Fable). A smaller bound needs the step's graph split across layers, never token chunking. - - **Every dream step is `Dispatched` work** through the task owner (Codex): the completion + - **Every dream step is `Dispatched` work** through the task owner (Codex), bound before any + effect to the stage `RunId` (provenance), the task owner's `TaskExecution` (custody), its input + revisions and the admitted grant. The completion carries `{ step, loss }` (fork #86 adds the committed step) and re-triggers the stage. The #5693 runner refuses `Dispatched` until the task owner's registration exists; the dream stage lands after it. @@ -129,6 +131,13 @@ they derived from: an older run's result never overwrites state derived from new `Yielded.residency_kept` = 0 when the stage snapshots its shadow and releases the optimizer moments (fork #86's snapshot), else the shadow + moments bytes; `Paused` keeps both. A pause or cancel requested mid-step gets its receipt only when that step's outcome arrives (quiescence). + If the engine's incarnation changes mid-step, that outcome never arrives, so quiescence is + proved by the fence, never by waiting: fork #88 stamps each learn with `{ execution, base_step, + engine_incarnation }`, a step under an old incarnation can no longer commit, and + `committed_effects` comes from `/learn/receipt` for that execution, else from the adapter's + `base_step` against the step the run dispatched, under #5695's lost-reply order (task terminal, + then the same-incarnation receipt, then redispatch, then rewind to the binding snapshot, else + unresolved). - **The input ack is the committed step, not admission:** the settled-experience topic is acknowledged through cursor N only when the step that consumed N reports its step committed, and the snapshot's `Provenance.from` is the cursor range it consumed (commit-once, @@ -154,6 +163,8 @@ Recall, reflex and dream under contention on one replayed engine, each case foll work (the mind keeps working, both ways: law 8): - a stimulus during work: the reflex trips; the dream yields at its next step boundary, the receipt carrying the measured expected latency for the node class beside the observed one; +- the engine relaunches mid-step: the dream's cancel receipt arrives with the committed count from + the fence, and nothing re-applies the step; - late and duplicate completions; a late terminal delivery after a restart, adopted with a receipt; - a stale incarnation's mutation refused while its completion stays adoptable; - a forgotten continuation (nobody resumes a paused run): its custody is reclaimed, reported; From 130fb67c3d4b1a6fd07300727ff279d0e37ea148 Mon Sep 17 00:00:00 2001 From: Joel Teply Date: Sun, 1 Nov 2026 22:24:27 -0600 Subject: [PATCH 5/5] Stage contract (Codex at d3435a302): #5585 superseded #5664; the relaunch validator splits proven fence evidence from missing evidence, which stays Unresolved with custody retained Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo --- docs/architecture/STAGE-CONTRACT.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/architecture/STAGE-CONTRACT.md b/docs/architecture/STAGE-CONTRACT.md index 225baaad4e..7e8aebaa40 100644 --- a/docs/architecture/STAGE-CONTRACT.md +++ b/docs/architecture/STAGE-CONTRACT.md @@ -105,7 +105,7 @@ they derived from: an older run's result never overwrites state derived from new identity. **Fencing blocks stale mutation, not durable evidence:** a completion from an old incarnation stays in the task ledger, and the current incarnation explicitly adopts, consumes or disposes of it with a durable receipt. Nothing strands a completion or erases a committed - effect. Dependencies, not available guarantees: #5585 and #5664 (unmerged) do not yet prove + effect. Dependencies, not available guarantees: #5585 (unmerged; it superseded #5664) do not yet prove restart adoption or cancellation quiescence; Codex owns closing those gaps. - **Admission and the physical grant (Codex).** One authority grants physical capacity, execution and residency separately. The stage scheduler ranks ready demand by each mind's @@ -133,7 +133,7 @@ they derived from: an older run's result never overwrites state derived from new cancel requested mid-step gets its receipt only when that step's outcome arrives (quiescence). If the engine's incarnation changes mid-step, that outcome never arrives, so quiescence is proved by the fence, never by waiting: fork #88 stamps each learn with `{ execution, base_step, - engine_incarnation }`, a step under an old incarnation can no longer commit, and + engine_incarnation }`, a step under an old incarnation can no longer commit once its physical executor is proven stopped (a new incarnation id alone is not that proof), and `committed_effects` comes from `/learn/receipt` for that execution, else from the adapter's `base_step` against the step the run dispatched, under #5695's lost-reply order (task terminal, then the same-incarnation receipt, then redispatch, then rewind to the binding snapshot, else @@ -163,8 +163,11 @@ Recall, reflex and dream under contention on one replayed engine, each case foll work (the mind keeps working, both ways: law 8): - a stimulus during work: the reflex trips; the dream yields at its next step boundary, the receipt carrying the measured expected latency for the node class beside the observed one; -- the engine relaunches mid-step: the dream's cancel receipt arrives with the committed count from - the fence, and nothing re-applies the step; +- the engine relaunches mid-step, two cases: (a) the fence's evidence is present (`/learn/receipt` + for the execution, or `base_step` read from the adapter): the cancel receipt carries the proven + committed count and nothing re-applies the step; (b) that evidence is missing: the run stays + `Unresolved` with its custody retained, never a cancel receipt or a guessed count. A new + incarnation id alone does not prove the old executor stopped; - late and duplicate completions; a late terminal delivery after a restart, adopted with a receipt; - a stale incarnation's mutation refused while its completion stays adoptable; - a forgotten continuation (nobody resumes a paused run): its custody is reclaimed, reported;