Skip to content

The stop's checkpoint condemns the acts it handed back, and one owner awaits a process's exit as an event (card b5b9bef3) - #5988

Merged
joelteply merged 3 commits into
canaryfrom
fable/stop-ends-in-the-cores-exit
Nov 14, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/stop-ends-in-the-cores-exit

Conversation

@joelteply

@joelteply joelteply commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

How this serves the minds: continuum stop kept the M5's core serving residents for minutes after it was asked to stop, so serving could not come down and back up near-immediately. This advances plan line 3b: one live engine, a dynamic lifecycle. This PR fixes the stall itself and adds the one owner that lets every stop wait on a process's exit as an event.

Measured (the defect, M5, ~/.continuum/logs/continuum-core-server.log*)

Stop Settle system:shutdown first published Outcome
2026-11-13 19:19Z — — the core fed minds for 7 min, then a manual SIGTERM
22:43Z — — 30 s, ok
23:40:21.999Z cognition.turns.settled + kv_page.settled 23:42:00.495Z (the manual SIGTERM) 99 s, then a manual SIGTERM
2026-11-14 00:51:56.248Z in_flight_at_close=4 handed_back=4 waited_ms=0 00:53:34.674Z (the manual SIGTERM) 98 s, then a manual SIGTERM

The SIGTERM path's own save and exit takes ~2.2 s ("65 modules stopped, all state durable, 2233ms"). "Stopping N modules" (runtime.rs:14) never logged after either settle, so Runtime::shutdown was never entered. Meanwhile cognition.turn_ingress.depth in_flight=4 kept sampling every 15 s.

Trace (file:line on canary 7a29474)

  1. The CLI stop runs stop_with_policy (stop.rs:152). On unix, target is forced to None (stop.rs:170, cfg!(windows)), so the stop goes through system/shutdown (graceful_stop.rs:354) and the CLI kills the core after the receipt (stop.rs:260).
  2. The core runs begin_shutdown(TURN_SETTLE_CAP) (shutdown.rs:171), then settle_before_stop (service_profile.rs:261), then rt.shutdown().
  3. TurnsSettle hands the 4 confirmed turns back at once (turn_ingress.rs:184). PageIoSettle (page_io.rs:62) then calls checkpoint_every_endpoint with ~300 s of cap left (page_io.rs:72).
  4. The stall: checkpoint_endpoint → transition_for_generation (page_io.rs:118) → gate.write_owned().await (engine_generation.rs:182). The writer waits for every admitted act's read guard. The settle had just handed those turns back, but nothing ended their acts, so the stop waited on their decodes. A relaunch already solves this exact shape with drain_for_replacement (engine_generation.rs:221): condemn first, then take the writer.
  5. The CLI waited up to GRACEFUL_STOP_BUDGET (320 s) for the receipt, and the operator gave up first.

Fix (this PR)

  • Root: the stop's checkpoint drains through drain_for_replacement, so acts let go on condemnation before the writer is taken. The condemnation is injected, so a test drives a local one.

  • One owner for "a process exited": continuum_host::process_exit::exited(pid) -> ExitObserved. The OS adapters hold only the diff:

    • macOS: kqueue EVFILT_PROC/NOTE_EXIT
    • Linux: pidfd_open + poll(-1)
    • Windows: OpenProcess(SYNCHRONIZE) + WaitForSingleObject(INFINITE)

    The wait runs on a detached thread, so a caller's watchdog never pins its runtime's drop. The owner has no timer of its own; a caller's bound only reports. It merges into the existing process_exit module, next to exited_unreaped.

  • First caller: the adopted engine's retirement (adopted_retirement.rs::await_adopted_exit) waits on the exit event, then re-reads the identity. It used to poll liveness every 100 ms.

  • The page-IO settle waits on an event: AdmissionGate::drained(), a Notify published by the release that empties a closed gate. The 50 ms poll is deleted.

  • A stall names its step: extensions::settling() records the participant being waited on. The SIGTERM path's 8 s stall message now says "stalled in the page_io settle", which was the M5's exact case: a manual SIGTERM joining a stalled stop.

Tests (each with // what this catches:)

  • slots::tests::stop_checkpoint::the_stop_checkpoint_condemns_held_acts_before_it_takes_the_writer: 4 acts that let go only on condemnation. The checkpoint gets past the writer instead of running into its cap. This is the incident's regression test.
  • process_exit::tests::exited_resolves_on_the_childs_exit_and_not_before: a spawned child; the wait is pending while the child runs and resolves on its exit. Nothing in the test sleeps.
  • process_exit::tests::an_absent_pid_has_already_exited: resolves at once.
  • admission_gate::tests::drained_is_published_by_the_last_release_of_a_closed_gate
  • extensions::tests::the_participant_a_stop_waits_on_is_named_until_the_settle_ends
  • adopted_retirement::tests::adopted_exit_wait_retains_custody_until_observed_exit (existing) now runs on the exit event.

Lines

+452 / −26 across 12 files. The host seam is ~200 lines and the tests ~150. Removed: two poll loops (page IO, adopted retirement). No production unwrap, OS branch outside continuum-host, or swallowed error was added.

Follow-ups: next PR, same owner (Fable)

The touched-file ratchets (os_branches, private_probes, unjustified_unwraps, required_inputs) require each file to end clean. The first push of this PR touched these files and failed on 29 + 12 + 6 + 1 pre-existing sites, so the cleanup comes first:

  • C1 graceful_stop.rs:273 exited_within (200 ms poll) → process_exit::exited, behind a watchdog that only reports. Needs teardown_authority moved into continuum-host and the Windows-only items moved into elevated_teardown.
  • C2 processes.rs:439, 503 TERM → 100 ms × 30 poll → KILL. The drain receipt should decide, with the kill as the error path only. Needs the 12 sysinfo sites moved to the process-table owner.
  • C3 core_service.rs:653-659 (macOS reboot), plus C4 (:748-785, Windows).
  • The stop protocol: one receipt-bound drain + commit (the core exits itself, as on SIGTERM) on every platform, replacing the unix-only system/shutdown + CLI kill (stop.rs:170). Needs the stop.rs elevated-consent branches behind an adapter. Draft written; it waits on the cleanups above.
  • continuum_process::confirm_gone (owned.rs:173, doubling poll), plus the other inventory rows: launch.rs:137-147, code_shell_kill_result.rs:297, and the bounded_command.rs try_wait loops.
  • TurnsSettle (turn_ingress.rs:207, 200 ms poll): its predicate reads the turn ledger, so the ledger has to publish confirmations first.

Not compiled locally

This machine serves live minds. CI is the compiler.

Live receipt (after deploy)

On the M5, continuum stop --engine should show kv_page.stop_checkpoint within seconds of kv_page.settled, then "Stopping N modules", and the core's exit, with no manual SIGTERM. Owner: whoever deploys next. The card stays open until it is posted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… handed back, and every wait is an event (card b5b9bef3)

The stop's resident checkpoint (page_io.rs) took the endpoint's writer while the
turns the settle had just handed back still held their act guards, with nothing
to end them: the M5 stopped saving at 00:51:56Z and 23:40:21Z (4 turns handed
back, waited_ms=0) and the core served minds until a manual SIGTERM 100 s later
(7 min at 19:19Z). It now goes through drain_for_replacement: condemn first,
then the writer, as a relaunch already does.

One graceful stop on every platform: drain, receipt, commit, and the core exits
itself through the same _exit its SIGTERM path takes (unix used to save, then
kill from the CLI). The CLI waits on the core's exit EVENT
(continuum-host::process_exit_event: kqueue NOTE_EXIT, pidfd, a signalled
process handle), never a poll, and reports stop-requested -> exited as the
lifecycle.stop.exited probe.

Polls in the stop path replaced by events: the CLI's 200 ms exit poll, the
kill's 30 x 100 ms TERM wait, confirm_gone's doubling poll (the engine's exit
under --engine), and the page-IO settle's 50 ms poll (AdmissionGate::drained).
A watchdog that fires names its step (extensions::settling).

Not compiled locally: this machine serves live minds; CI is the compiler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… their ratchet cleanup (card b5b9bef3)

The coordinator's timer audit: nothing in core could await another process's
exit, so every stop, reboot, kill and engine retirement polled pid_alive.
continuum_host::process_exit::exited(pid) -> ExitObserved is that one owner
(kqueue NOTE_EXIT, pidfd, a signalled process handle, on a detached thread),
replacing the separate process_exit_event module. Its first caller is the
adopted engine's retirement (adopted_retirement.rs), which polled liveness
every 100 ms.

The CLI stop path (graceful_stop.rs, stop.rs, processes.rs) and
continuum_process::confirm_gone are reverted to canary here: touching those
files requires them to end with no OS branches, private sysinfo probes or
unjustified unwraps (29 + 12 + 6 sites), a refactor of its own. They are the
next PR's rows (C1, C2, C3, confirm_gone). The SIGTERM path's 8 s stall now
names the settle step it was stuck in.

Not compiled locally: this machine serves live minds; CI is the compiler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply joelteply changed the title The stop ends in the core's exit: its checkpoint condemns the acts it handed back, and every wait is an event (card b5b9bef3) The stop's checkpoint condemns the acts it handed back, and one owner awaits a process's exit as an event (card b5b9bef3) Nov 14, 2026
@github-actions github-actions Bot added size: L and removed size: XL labels Nov 14, 2026
…he test binds its client (card b5b9bef3)

Both fixtures hold no acts, and the process-wide condemnation would end other
tests' acts in the same binary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit 958ea30 into canary Nov 14, 2026
74 of 77 checks passed
@joelteply
joelteply deleted the fable/stop-ends-in-the-cores-exit branch November 14, 2026 02:37
joelteply added a commit that referenced this pull request Nov 14, 2026
…e ratchets

Rule 10/11 text: canary's #5986 wording kept, plus the shape-ratchet section, its
baselines and the correction that time_bounds and wall_clock never counted sleeps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Nov 14, 2026
…6004)

Live receipt for #5987 on the M5 (canary 7f875cc, 2026-11-14 07:48-07:53Z): the stop's
checkpoint saved one resident of four (07:48:28Z, slot 3, Benchy); the new engine (fork pin
b5534b531) and core attached the ledger (loaded=1) and restored Benchy, while Aiko, Aris and
Atlas came up cold (cold_turn cause="no_page"). The key matched (same fingerprint; Benchy
restored) and the page store evicted nothing (every pass declined page_io_busy). The cause:
the stop condemns acts in flight (#5988), and a cut act's drop forgets her attribution
(TurnAdmission::drop -> forget_resident), so checkpoint_pool, which saved only `holders`,
had nobody to save in those slots.

KvSlotPool::stop_residents is the checkpoint's resident set: every attributed resident, plus
each slot still holding a sequence of a mind attributed nowhere (LiveSequences::held): a
confirmed sequence when at least as new as her page, an unconfirmed one (her cut act) only
when she has no page. One save per page.

Test: a_mind_whose_act_the_stop_cut_is_saved_and_restores_after_the_boot (engine A, a cut
act, the stop, engine B and a new core: both minds restore what their slots held).

Not compiled locally (the M5 is serving); CI is the compiler.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

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