Repository navigation
An engine's stderr is read by a relay in its own process group, so a core restart keeps its log and fault watchers (card 1d7d6d4c, part b) - #5536
Merged
joelteply merged 6 commits intoOct 27, 2026
Conversation
…core restart keeps its log and fault watchers (card 1d7d6d4c, part b) The engine is spawned first, as before (process_group(0)); its relay, the core binary in `--log-relay` mode, is spawned second, inside the engine's group, with the engine's stderr as its stdin. PGID stays the engine pid, so every existing stop, reap and orphan-sweep path is unchanged; a group kill of the engine takes its relay. The relay names the engine from arguments the spawning core passes, so the merged control-handle bind is deleted. The core follows each engine's relay, spawned or adopted alike: every line goes through the same watch chain (wedge, offload banner, debug build), and its heartbeats keep the engine's silence clock, which exists only while a current heartbeat names that incarnation. The relay holds the lines from before its first subscriber (the spawning core) so the load banner still reaches the placement and debug-build gates; later subscribers never get a replay. A relay that cannot start fails the launch and the engine is killed and reaped through the existing retire path: no in-core fallback. Windows keeps the in-core pump; the choice lives in continuum-host::output_handoff, so launch holds no OS branch. The relay's stderr::Incarnation is replaced by engine_residency::EngineIncarnation (one owner). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…matched readiness before launch accepts it (Codex on #5536) attach took a successful OS spawn as readiness, so a relay that failed its bind left the engine serving with nobody reading it. Now the spawning core waits, within a 10 s ceiling, for a connection whose opening heartbeat names this engine's incarnation. That connection is the relay's first subscription, so it is also where the held startup lines go, and the follower keeps reading it. A relay that exits first, an endpoint answering for another engine, or the time passing fails the launch; the relay is killed and reaped, and launch kills and reaps the engine as before. A launch cancelled while it waits still reaps and follows the relay through a drop guard, since the engine it reads is owned. Tests: a relay exiting before it serves is refused; an endpoint for another incarnation is refused, and a matching one delivers the held banner to the follower. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…the connect too; custody never waits (Codex on #5536) - reap awaited a relay's exit on a spawn_blocking thread, and a runtime drop waits for running blocking tasks: with any engine alive the core could not shut down. The relay is now a tokio child (continuum-host::output_handoff hands one back) whose exit is an ordinary task, dropped at shutdown; the relay outlives the core by design and is then init's to reap. Test: a runtime with a live, reaped relay shuts down within 5 s (proven by mutation: the blocking reap fails it at 5.02 s). - follow::ready awaited the connect outside its deadline; the connect and the opening heartbeat now share it. Test: an endpoint that accepts into its backlog and never speaks is refused at a 300 ms bound. - local_stream custody took a blocking lock(); it now try_locks and refuses AddrInUse at once when another binder holds it. - Tests that spawn processes are unix-only, and each live-engine test runs its own stand-in engine process, so silence clocks keyed by pid never cross tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…o the engine's group, readiness, core exit and re-follow (Codex's gate on #5536) continuum-core/tests/log_relay_e2e.rs drives `continuum-core-server --log-relay` (CARGO_BIN_EXE) for a stand-in engine (sh writing a banner then a line every 100 ms, in its own process group): - the relay's pgid is the engine's pid; - follow::ready proves it serves this incarnation, and the spawning core's follower gets the held banner first, then lines, and keeps the silence clock; - the core exits (its follower task ends): the clock goes with it; - a restarted core follows the same relay through the adoption path (follow::follow): new lines and a clock, never the banner replayed; - the archive under HOME holds the engine's lines from the first; - the engine is killed and the relay ends cleanly within 10 s. CI runs it in the existing core integration step beside capability_grant_e2e, one cargo invocation sharing that build. follow_ready returns its follower's task (as follow_at does) so a test can end it the way a core exit does. Not run locally: continuum-core is CI's on this node (a resident host). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…or custody, then is refused (Linux CI on #5536) The immediate try_lock refusal (ac5d370) dropped the serialization #5533's concurrent_binders_of_a_stale_endpoint_leave_exactly_one_owner pins: on Linux CI all 8 concurrent binders of a stale endpoint were refused and none owned it (job 122423021477). Codex's ask was a bounded wait, not no wait: custody now polls try_lock every 2 ms until a 2 s ceiling, so binders of one stale endpoint still take turns (exactly one reclaims), and a holder that never releases leaves the binder refused AddrInUse rather than blocked. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…nother test's socket into the child (14/60 host lib runs) a_live_owner_is_refused_and_an_old_cleanup_spares_its_successor failed on Linux CI (job 122427234721) and locally in 14 of 60 runs of the continuum-host lib tests, always "a stale endpoint ... is served by a live owner": its dropped listener still answered. Without the output-handoff test (which forks sh and cat) it failed 0 of 60, and 0 of 60 single-threaded: a fork landing while another test creates a socket carries it into the child (on macOS close-on-exec is set after the socket exists), so a gone server's endpoint stays served for the child's life. Production is not exposed this way: only the relay binds these listeners, and it forks nothing. The fork test moves to continuum-host/tests/output_handoff.rs (its own process), and CI runs it in a continuum-host step. After the move: lib tests 0/60, the moved test passes; the engine's relay tests, whose forks share a binary with their listeners, failed 0 of 40 stress runs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply
deleted the
68914f75/an-engine-s-stderr-relay-in-its-own-proc
branch
October 27, 2026 20:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this serves the minds
An engine adopted across a core restart had no reader for its stderr. On enrico on 2026-10-27, engine-c ran from 03:35Z to 10:44Z with no log, and its stall at 08:27Z could not be read. The wedge, offload-placement and debug-build watchers were blind to every adopted engine, and its silence clock read as unknown. This advances plan line 3b (one live engine, never relaunched to be understood) and the S2 detector's evidence (#5528).
Part (a), the relay and its socket protocol, merged as #5533. This is part (b): launch switches to the relay.
What changes
Spawn order (plan agreed with Codex on airc, 10-27):
process_group(0). PGID stays the engine pid, so every existing stop, reap and orphan-sweep path is unchanged. The one group signal on an engine iskill_pid_tree'skill(-pid)(bin/continuum/processes.rs:428), and it now also takes the engine's relay.--log-relay <port> <pid> <start_s>mode, dispatched first inmainbefore config, tracing or sockets.read_bind,binds_refused) is deleted.Followers:
stderr_relay::follow), whether it spawned the engine or adopted it.ensure_model_serving_if_currentcallsfollow_engine_logon everyAlreadyServing; following is deduplicated per incarnation.stderr_sink::stderr_watch, its one owner.child_log's per-pid silence clock, which exists only while a current heartbeat names that incarnation. A drop guard retires the clock when the follower ends, including on abort, soengine_stallis unchanged.Startup lines: the relay holds the lines from before its first subscriber (bounded by
Config::queue, overflow counted) and delivers them once to that subscriber, the spawning core. Without this, the offload banner (#441 readback) and the debug-build announcement would be printed before anyone subscribed, and both gates would go blind. Later subscribers start at the next line and never get a replay.Failure is loud, with no fallback (readiness added after Codex's review of 9ef5cf0):
follow::ready). That connection is also the relay's first subscription, so the held startup lines go to it and the follower keeps reading it.kill_child→retire_page_owner→collect_exited).Pending), since the engine it reads is owned and may serve on.OS seam: new
continuum-host::output_handoff. On unix it hands the pipe to a reader in the writer's group. On Windows it returns the stderr (Handoff::Kept), and launch drains it with the in-core pump as before. Launch holds no OS branch.stderr_relay::Incarnationis replaced byengine_residency::EngineIncarnation, so there is one owner of the type.Spawn ratchet: the relay's
Command::newlives incontinuum-host, which the hygiene scan does not cover. Spawning the reader is that seam's capability, so it belongs there. I'm stating this so a reviewer can judge it; it is not a reduction in spawn sites.Tests (worktree, macOS x86_64, at 9ef5cf0's tree)
continuum-host:the_reader_joins_the_writers_group_reads_every_line_and_ends_with_it. A realshwriter andcatreader:ps -o pgid=of the reader equals the writer pid, every line arrives, and the reader exits on EOF once the writer exits.stderr_relay::follow::a_restarted_follower_picks_up_the_relay_and_its_silence_lives_only_with_it:then_somebuilt the claim guard eagerly, and the guard'sDropre-took the lock it was dropped under. A process sample showed the thread parked at follow.rs:50 → :56. Fixed withthen, with the lock released first.stderr_relay::follow::a_relay_that_exits_before_serving_is_refusedandan_endpoint_answering_for_another_engine_is_refused_and_a_matching_one_is_followed(the readiness handshake; 87 passed at b3fdabd).stderr_relay::tests::the_first_subscriber_gets_the_banner_and_later_ones_never_a_replay(replaces the old nobody-connected test), plus the existing relay tests adapted.stderr_relay::process: the arguments round-trip and malformed ones are refused.cargo test -j 1 -p continuum-engine --features metal --lib -- stderr_relay child_log llama_server::testsgave 85 passed, 0 failed. The host run gave 1 passed.cargo check --libof host and engine raised no new warnings.ratchets -- origin/canarypassed 68/68, exit 0.main.rsdispatch) and the Windows build. CI compiles both.Measured after deploy (owner: Cormac, deadline: the first enrico deploy carrying this)
On enrico after deploy:
ps -o pid,pgid,commandshows eachllama-serverwith acontinuum-core-server --log-relayin its group;continuum rebootthat adopts the engine, new engine lines still reach~/.continuum/logs/llama-server-<port>.log, and the adopting core'schild_log::silent_msisSome;serving.llama.relay_endedprobe in the 15 minutes after deploy.Card 68914f75 stays open until that receipt is posted.
Removed / added
17 files, +583 / −154. Removed: the control-handle bind and
binds_refused, launch's inline watch chain and drain match, and the duplicateIncarnationtype.🤖 Generated with Claude Code
https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE