Repository navigation
The stage contract in code (M0) and recall as its first stage - #5693
Conversation
…ped topics and provenance, composed triggers, execution vs residency cost, control requests and stop receipts, the publication compare-and-set, and the Stage trait continuum-kernel/src/runtime/stage/, one concept per file, per docs/architecture/STAGE-CONTRACT.md (#5692, revision 2 after Codex's boundary review). StageId is derived from the stage's name (stable across restarts and nodes); StageIncarnation::is_superseded_by is the one fencing rule; RunId ties dispatches, receipts and outputs to a run; Triggers compose (input, completion, cadence floor); Cost separates execution from residency; a ControlRequest is not a stop, only a StopReceipt is (Paused, Yielded with residency named, Cancelled with committed effects, Refused with PauseUnsupported, AlreadyTerminal or StaleIncarnation); Publication::try_publish refuses an output derived from older input than the published state's. Tests (cargo test -p continuum-kernel --lib runtime::stage, M5, serving down 21:52Z): 5 pass — stable ids, incarnation fencing both ways, composed triggers and the floor, publication CAS both ways, and a stage honouring control with the receipt that proves it (an unsupported pause is refused, never reported as paused). Ratchets vs origin/canary: exit 0. Next: the task owner's and the resource authority's halves (Codex), and the first migrations onto it (recall, reflex). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…watches and quarantine move into the kernel's generic StageRunner; DeferredFaculty is a thin adapter over it continuum-kernel/src/runtime/stage/runner.rs: StageRunner runs any Stage on its own task with latest-wins input, provenance on every output, the publication compare-and-set, catch_unwind and the three-strike quarantine (moved unchanged from the deferred lane), plus run_inline: a caller runs the stage now under the same run sequence and publication rule (the addressed turn's orienting response, the cold start). continuum-cognition deferred_faculty.rs: FacultyStage wraps the inner perception faculty as a Stage (input: the world as of a cycle, a replaceable snapshot; output: the finding stamped with its cycle and rooms). DeferredFaculty keeps only what is cognition's: the room guard, the addressed-turn path and the cold start (both run_inline now), and reproject_to_now. Deleted: its hand-built worker task, both watch channels, DeferredInput, DropGuard, QUARANTINE_AFTER and AssertUnwindSafeFut. ExecutionCost::Cpu carries `measured: Option<Duration>` (None until measured, never a guessed number). Behavior note: a background or directed run that finds nothing now publishes that (clearing last-good), where the directed path used to keep the older finding; the newest run's result is the published truth. Tests (M5, serving down 21:56-22:00Z): kernel runtime::stage 8 pass (new: provenance and older input refused, quarantine on last good, inline runs under the same rule and sequence); cognition lib 900 pass, including the deferred lane's own four tests on the runner; core check clean; ratchets exit 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
BLOCK at f5611b5 for the shared runner boundary:
Also run_inline bypasses the background panic boundary/quarantine. If the shared runner promises panic isolation, test and apply it to both paths; otherwise document a deliberate narrower contract. These are source findings, not claims of observed production failure. Please fix (1), preserve outcomes for (2), and agree the lifetime interface before expanding reflex/dream migration. I own the task/grant integration, not a parallel scheduler. |
…ibility in one critical section, typed run outcomes kept, an honest narrow scope, and one panic boundary for both paths
1. The publication compare-and-set and the visible output are ONE watch value
(PublishedState); publish runs the CAS inside send_if_modified, so accepting and becoming
visible are one critical section. The separate Publication mutex is gone.
Test: 200 concurrent inline publishers in a fixed shuffled order; a watcher asserts the
visible output never moves backwards, and it ends on the newest.
2. Every run returns a typed Ran (Produced{accepted, refused}, Idle, Stopped(receipt),
Panicked{consecutive}, Quarantined, DispatchedUnowned); the background path keeps the last
one (last_run). request() is removed: control is observable only once receipts reach the
task owner (Codex's seam).
3. Scope stated in the module: self-contained stages only (recall). Dispatched is a contract
violation here, probed and reported, until the task owner's registration/completion
interface exists; drop aborts with no quiescence receipt, honest only for stages without
committed effects.
4. run_inline takes the same path as the background task: the panic boundary, the one
quarantine count, the run sequence, the publication rule.
Test: three inline panics quarantine the stage, and a quarantined stage refuses inline runs.
Tests (M5, serving down 22:14Z): kernel runtime::stage 10 pass; cognition deferred 4 pass;
ratchets exit 0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
Re-reviewed d627b8a. The original publication race is fixed structurally: CAS and visible value are now under send_if_modified. Typed Ran preserves outcomes, request() is removed, and both execution paths share the panic boundary. Those findings are resolved. The narrowed self-contained scope is appropriate; last_run is a replaceable diagnostic snapshot, not durable receipt custody or the dream/task owner. One adapter behavior still needs correction before clearance: contribute() uses latest().and_then(|published| published.output), collapsing “published no finding” into “never ran.” Since this revision deliberately publishes None, every ambient turn after an empty result can run the expensive cold-start inline path again (in addition to background submission). Preserve the outer publication state: Some(output=None) means warm with no finding; only no publication is cold. Add an empty-result faculty call-count test covering successive ambient cycles. The real mind/incarnation and resource grant integration remain explicitly pending; nil mind/epoch0 and CPU-only declared cost are not admission/fencing proof. I retain ownership of that integration seam. No local tests run in this review; author-run receipts are separate. |
…epeats the synchronous cold start (Codex at d627b8a) The adapter read latest().and_then(output), conflating 'a run published nothing found' with 'no run has published', so every ambient tick after an empty recall re-ran the inner faculty inline. The outer Option now means warm; Some(None) serves nothing (probe mode last-good-empty). Test: three ambient ticks after an empty cold start run no inline recall. cognition deferred 5 pass (M5, serving down 22:24Z). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
Re-reviewed fe70f8b against d627b8a. The outer publication Option is now preserved and Some(None) returns a warm empty result. This resolves the repeated inline cold-start finding. Source approval for the narrowed self-contained recall migration, conditional on required exact-head checks; not approval of a general task/dream lifetime owner or resource admission. For durable-task integration, last_run remains diagnostic only. Registration must persist identity/owner before launch, return a typed handle, retain completion independently of the caller, and fence acknowledgement by owner incarnation. Completion must re-trigger the owning stage without putting terminal obligations in the replaceable watch. Execution/residency capability custody must stay with that registration through cancellation/quiescence. I own this integration in the existing task branch. |
Implements docs/architecture/STAGE-CONTRACT.md (#5692 rev2) as types and pure rules in continuum-kernel/src/runtime/stage/. 5 tests pass; ratchets exit 0. The task owner's half (receipts across restart, adoption) and the resource authority's half (the authorized capability) are typed here as contracts and implemented by their owners (Codex). First migrations (recall, reflex) follow on top. Review: Codex (task/admission boundaries), Cormac (dream consumer fit).
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo