Skip to content

fix(lifecycle): start reclaims-or-refuses instead of binding blindly (#420 tail) - #2291

Merged
joelteply merged 1 commit into
canaryfrom
fix/start-reclaim-or-refuse
Aug 14, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/start-reclaim-or-refuse

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Closes the remaining half of #420. stop learned in #2287 that the pidfile names ONE core; start never did.

The missing constraint

start's only guard was "does a core answer ping?". A core that is running but not answering — wedged, mid-boot, or bound where this CLI can't reach — was invisible, so start launched a second one on top of it. Same shape as #2287 on the other side of the lifecycle, and the same as airc #355: reclaim belongs in BOTH shutdown and start.

A second core is never benign: both hold the same socket path (the later one unlinks and re-binds it), and whichever the kernel hands a connection to is the one that answers — so a shipped fix looks intermittently broken and an unshipped one intermittently fixed.

The fix — ONE primitive, not a second ad-hoc check

runtime/core_bind_guard::decide(ping_ok, running_pids) — pure, exhaustive 4-row truth table: Free / AlreadyServing / Occupied.

It lives in the lib, not the bin, because CI runs cargo test -p continuum-core --lib; a truth table tested inside a bin wouldn't be covered by the gate that guards it.

caller Free AlreadyServing Occupied
start launch no-op refuse, naming pids (--force reclaims)
ensure_core_running launch ok refuse — never reclaims

Refuse, not auto-kill. reboot guards destructive restarts behind live-training and live-benchmark leases; a start that silently reaped a core would route around them. start --force is the explicit reclaim and says plainly that it checks no lease. An implicit autostart never reclaims at all — a command that merely wants a live core has no business killing one.

The ping bound is load-bearing, not defensive

An unbounded ping doesn't fail against an unresponsive core, it hangs: the kernel completes connect() into the listen backlog whether or not the process is scheduled, then the read waits for a reply that never comes. Without PING_BUDGET the Occupied arm was unreachable on the live path despite green unit tests. 5s against a measured 20ms round trip.

Verification

Unit: 4 truth-table tests, --lib (the CI gate). Live, on this box:

  • SIGSTOP every core, run start — unbounded: no output, still hung at 90s. Bounded: exit 1 in 8s with the refusal naming both live pids; cores resume unharmed on SIGCONT.
  • Unserved socket, two live cores: exit 1 in 0s, both pids named.
  • Healthy core: still a no-op. Idempotence preserved.
  • Found while testing: two cores were live on this machine at once (a debug build and the installed release, 78s apart, both holding /tmp/continuum-core.sock) — the fix(lifecycle): stop reaps EVERY running core, not just the one the pidfile names #2287 condition, in the wild.

Note for whoever picks this up

continuum reboot sets CONTINUUM_SKIP_SELF_BUILD and so never rebuilds the continuum CLI itself, meaning a CLI-only fix does not reach an operator via reboot. Proven here: the installed CLI's stop left a survivor that the freshly-built stop then reaped with SPLIT BRAIN.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

#420 tail)

`stop` learned in #2287 that the pidfile names ONE core and is not evidence that
only one is running. `start` never learned it. Its only guard was "does a core
answer `ping`?", so a core that is RUNNING but NOT answering — wedged, mid-boot,
or bound where this CLI cannot reach — was invisible, and `start` launched a
second one on top of it. Same missing constraint as #2287, on the other side of
the lifecycle, and the same as airc #355: reclaim belongs in BOTH shutdown and
start.

A second core is never benign. Both hold the same socket path (the later one
unlinks and re-binds it) and whichever the kernel hands a connection to is the
one that answers, so a shipped fix looks intermittently broken and an unshipped
one intermittently fixed.

The fix is ONE primitive both launch paths call, not a second ad-hoc check:
`runtime/core_bind_guard::decide(ping_ok, running_pids)` — a pure, exhaustive
4-row truth table (Free / AlreadyServing / Occupied). It lives in the LIB, not
the bin, because CI runs `cargo test -p continuum-core --lib`; a truth table
tested inside a bin would not be covered by the gate that guards it.

  - `start`: Free launches, AlreadyServing no-ops, Occupied REFUSES and names the
    pids with the three ways out. Refuse rather than auto-kill: `reboot` guards
    destructive restarts behind live-training and live-benchmark leases, and a
    `start` that silently reaped a core would route around those guards.
    `start --force` is the explicit reclaim, and says plainly that it checks no
    lease.
  - `ensure_core_running` (implicit autostart): same guard, no reclaim arm. A
    command that merely wants a live core has no business killing one.

Also bounds the ping (`PING_BUDGET`, 5s against a measured 20ms round trip).
That is load-bearing, not defensive: an unbounded ping does not fail against an
unresponsive core, it HANGS — the kernel completes connect() into the listen
backlog whether or not the process is scheduled, and the read then waits for a
reply that never comes. Without the bound the Occupied arm was unreachable on
the live path despite green unit tests.

Live, on this box:
  - SIGSTOP every core, run `start` — unbounded: no output, still hung at 90s.
    Bounded: exits 1 in 8s with the refusal naming both live pids, and the cores
    resume unharmed on SIGCONT.
  - Unserved socket with two live cores: exit 1 in 0s, both pids named.
  - Healthy core: `start` still no-ops. Idempotence preserved.
  - Found while testing: TWO cores were live on this machine at once (a debug
    build and the installed release, 78s apart, both holding
    /tmp/continuum-core.sock) — the #2287 condition, present in the wild.

Note for whoever picks this up: `continuum reboot` sets CONTINUUM_SKIP_SELF_BUILD
and so never rebuilds the `continuum` CLI itself. A CLI-only fix therefore does
not reach an operator via reboot — proven here, where the installed CLI's `stop`
left a survivor that the freshly-built `stop` then reaped with SPLIT BRAIN.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit e2e780e into canary Aug 14, 2026
5 checks passed
@joelteply
joelteply deleted the fix/start-reclaim-or-refuse branch August 14, 2026 09:09
joelteply added a commit that referenced this pull request Aug 14, 2026
…finally CI-covered (#422) (#2292)

Two defects, one root: deploy-verify only ever looked at the CORE, and the pure
logic that decides its verdict was tested where CI does not look.

## It was half-blind

`reboot` sets CONTINUUM_SKIP_SELF_BUILD and so never rebuilds the `continuum`
CLI. That is deliberate — a running image cannot be replaced on Windows, and
letting the start script build it failed the whole cargo invocation and skipped
the CORE build (772s to that failure on BIGMAMA). The consequence was never
written down: a fix that lives in the CLI cannot reach an operator through the
documented deploy path, and deploy-verify printed its green checkmark anyway.

Measured 2026-08-14, same machine, minutes apart: the installed CLI's `stop`
reaped only the pidfile core and left pid 6453 alive and silent; the
freshly-built CLI's `stop` then printed SPLIT BRAIN and reaped it. #2287 had
merged and had NOT reached the installed CLI — while deploy-verify reported
"✅ core is running build 1de9ceb". Every lifecycle fix shipped this week
(#2287 stop-reaps-all, #2288 config.env, #2291 start reclaim-or-refuse) lives in
the CLI; none was provably running. That is #194 one tier up.

`cli_staleness_note` now rides alongside the core verdict on BOTH outcomes.
It WARNS rather than failing: the core verdict is about whether the swap took,
CLI staleness is a separate fact, and making it fatal would break deploy-verify
for every operator whose CLI predates their core — today, all of them. Silence
when it matches, so the note means something when it fires. Unjudgeable
provenance (built outside a git tree) is stated, not swallowed, and never
claims staleness it cannot prove.

## And its tests were unreachable

`deploy_verdict` and `sha_matches` were pure and unit-tested — inside
`bin/continuum.rs`. CI runs `cargo test -p continuum-core --lib`, which does not
compile bin test mods, so the #194 guard was protected by tests nothing ran.
Exactly the trap #2291 documented for the bind guard, sitting one function away
the whole time.

Moved to `runtime/deploy_provenance.rs` with their tests, plus new coverage for
the CLI note and for sha_matches rejecting junk in both directions. The bin keeps
everything impure (ping, git rev-parse, artifact resolution, process
description) and delegates the verdicts. 4 tests, all under the --lib gate.


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

Co-authored-by: Claude Opus 5 (1M context) <[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