Repository navigation
An engine-stderr relay that outlives the core, its signals on a local socket (card 1d7d6d4c, part a) - #5533
Merged
joelteply merged 4 commits intoOct 27, 2026
Conversation
…d on a local socket (card 1d7d6d4c, part a)
The core drained each engine's stderr itself, so a core restart that adopted a
running engine left nobody reading it (enrico 2026-10-27: engine-c 03:35Z to
10:44Z with no log; its 08:27Z stall unreadable). This is the relay, alone;
launch switches to it in part (b).
- inference::stderr_relay::run(stderr, control, log, socket, config): drains
stderr through child_log's pump (now generic over AsyncRead) into the same
capped archive, and serves frames on a per-engine local socket:
a heartbeat first, then each line (sequenced, cut at line_bytes with a
truncated flag; the archive keeps it whole), and a heartbeat each period
with {seq_last, dropped_slow, missed_disconnected, last_line_ms,
relay_started_ms, incarnation, binds_refused, expires_at_ms}.
- Signals are separate from the archive: a failing disk still delivers every
line. A slow subscriber loses the oldest frames, counted; lines drained with
nobody connected are counted; a subscriber starts at the next line, so an old
fault is never replayed as new.
- The incarnation is taken once, only from the control handle (the spawning
core's inherited pipe); later binds are refused and counted. Until bound,
silence reads as unavailable. stderr_relay::silent_ms answers only for a
current heartbeat naming the expected incarnation.
- continuum_host::local_stream: the endpoint as a host capability (a Unix
domain socket file at 0600, a Windows named pipe), so the relay holds no OS
branch. continuum-host gains a tokio dependency.
Tests: lines reach a subscriber after a heartbeat and the relay ends with its
writers; one bind from the control handle; nobody-connected lines counted and
never replayed; a slow subscriber's losses counted while the archive keeps all;
a long line cut in its frame and whole in the archive; an unwritable archive
still delivers; silence only for the current, bound incarnation.
continuum-host: a client reaches the server and a successor takes over the
path.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…point refuses a live owner and cleans up only its own (Codex on #5533) - serve() runs subscribers in a JoinSet, at most Config::subscribers (one more is refused and counted, subscribers_refused); on shutdown every subscriber is aborted, blocked writes included, and joined before the endpoint goes, so an existing connection sees the end, never heartbeats from a relay that has gone. A subscriber also ends at once when its client hangs up. - continuum_host::local_stream::Listener::bind refuses a live owner (AddrInUse) and reclaims only an endpoint whose server is gone (a connect that is refused); it returns an Owned token that removes the socket file only while it is still this listener's (device and inode), so a predecessor's cleanup never removes its successor's endpoint. Windows: first_pipe_instance already refuses a live owner; a pipe leaves nothing to remove. - Tests check readiness through the host seam, not the filesystem; an existing subscription ends with the relay; a connection past the bound is refused and counted; a live owner is refused and an old cleanup spares its successor. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…one step, reclaim only on a refused connect (Codex on #5533) local_stream (unix): who serves a path is decided under std's File::lock on a sidecar <path>.lock. An existing file must be a socket; a successful connect is a live owner (AddrInUse); only ConnectionRefused proves the server gone and reclaims; NotFound means another already removed it; any other answer refuses, leaving the endpoint as it was. Bind, mode 0600 and the identity record happen under the same lock, and Owned::remove takes it before its identity check, so a check/unlink race between binders or cleanups cannot remove a live listener. Tests: eight concurrent binders of a stale endpoint leave exactly one owner, which still serves (without the lock this failed 4 of 5 runs); a socket that answers with permission denied is never reclaimed (reclaiming on any error fails it). 10/10 real runs pass. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…t has a total deadline (Codex on #5533) CI hung on a_long_line_is_cut_in_its_frame_and_whole_in_the_archive and an_unwritable_archive_still_delivers_every_line (job 122322260147, cancelled for its log): each wrote a line straight after connect, before the relay's subscriber task had subscribed, so the line was drained with nobody subscribed (counted as missed) and the test waited for it forever while heartbeats kept each per-read timeout from firing. A subscribe() helper waits for the opening heartbeat, which the relay sends after subscribing; next_line and heartbeat_where have a 20 s total deadline and report the last heartbeat seen. Subscription's doc states the contract: lines are those drained after its first heartbeat. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
Contributor
Author
|
PASS on exact3009fafaf92a7f20c5c8fb6d0752e5ae41b0c185 for isolated relay part(a). Reviewed bounded subscribers and joined shutdown, serialized socket custody with refused-only reclamation, incarnation binding, loss counters, and corrected opening-heartbeat/total-deadline fixtures. Independently verified31 passing checks and2 intentional skips, including engine/host tests. Launch wiring, actual child process lifecycle, bounded custody waits and live restart continuity remain part(b); this merge does not establish those deployment properties. |
joelteply
deleted the
1d7d6d4c/a-relaunched-engine-logs-nowhere-engine
branch
October 27, 2026 17:48
joelteply
added a commit
that referenced
this pull request
Oct 27, 2026
…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
joelteply
added a commit
that referenced
this pull request
Oct 27, 2026
…core restart keeps its log and fault watchers (card 1d7d6d4c, part b) (#5536) * 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) 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 * A relay counts only once it serves this engine: bounded, incarnation-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 relay's exit is awaited, never a parked thread; readiness bounds 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 * The engine log relay is tested as the shipped binary in CI: spawn into 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 * Custody serializes binders again, bounded: a binder waits up to 2 s for 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 * The output-handoff fork test runs in its own binary: a fork carried another 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 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
Oct 27, 2026
…, not dev/ino (card 005e1676) (#5544) * A local endpoint's cleanup spares its successor by an ownership token, not dev/ino (card 005e1676) local_stream::Owned::remove decided whether the endpoint was still its own by the socket's (dev, ino). Linux reuses an inode number at once, so a predecessor's cleanup removed its successor's socket: a_live_owner_is_refused_and_an_old_cleanup_spares_its_successor failed at mod.rs:134 on canary 107af91 and on every PR's host job (#5543 at cbba67a). Now each bind writes a fresh ownership token (pid, clock, per-process count) to the custody sidecar, under custody, and Owned keeps it. remove deletes the socket only while the sidecar still holds that token, then clears it; a successor's bind writes its own, so a late predecessor cleanup spares it whatever inode the socket got. A crashed owner's leftover token is harmless: the next binder reclaims the stale endpoint and writes its own. The custody wait stays bounded (2 ms poll, 2 s ceiling). The successor test no longer depends on inode reuse, so it is deterministic on every OS: 60 of 60 stress runs pass on macOS; Linux is CI's. Taken back from Fable: part a (#5533) is my code. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * Cleanup requires both the socket identity and the ownership token: a replacement is spared as well as a successor (Codex on #5544) The token alone (ee9c615) let an old owner's cleanup remove whatever replaced its socket outside custody: a regular file, a symlink, or a listener that never wrote the sidecar. Owned now keeps the socket's (dev, ino) again beside the token, and remove deletes the path only while it is still a socket with that identity AND the sidecar holds this bind's token: the identity spares any replacement, the token a successor whose socket reused the inode number. Test: an_old_cleanup_never_removes_what_replaced_its_socket (a regular file and a symlink at the path survive the old cleanup). Proven by mutation: with the identity check removed it fails ("a regular file at the path survives"). The token's doc no longer claims absolute uniqueness; the stale Owned doc is fixed. Host: 10 lib + 1 integration pass, 60/60 stress. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
An engine adopted across a core restart logs nowhere: its stderr pipe was read by the old core, and that reader died with it. On enrico on 2026-10-27, engine-c ran from 03:35Z to 10:44Z with no log, and its 08:27Z stall could not be read. This is plan line 6 (every fast-path miss loud) and card 1d7d6d4c.
This is part (a), the relay on its own. Part (b) moves launch onto it. The design was reviewed on airc with Codex over three rounds before any code.
What
inference::stderr_relay::run(stderr, control, log, socket, config)drains stderr throughchild_log's pump (now generic overAsyncRead) into the same capped archive, and serves frames on a per-engine local socket:line_bytesis cut in its frame and flagged, while the archive keeps it whole;{seq_last, dropped_slow, missed_disconnected, last_line_ms, relay_started_ms, incarnation, binds_refused, expires_at_ms}.dropped_slow);missed_disconnected);stderr_relay::silent_msanswers only for a current heartbeat that names the expected incarnation, never a predecessor's clock.continuum_host::local_streamis the endpoint as a host capability: a Unix domain socket file at mode 0600, or a Windows named pipe. The relay holds no OS branch.continuum-hostgains atokiodependency.For part (b), as Codex noted: the relay leads a new process group and the engine is spawned into it. That relay-led group id goes into custody, and every stop, reap and adopt path that assumes the group id is the engine pid gets updated. The bind goes over an inherited control pipe.
Verified (enrico, 2026-10-27, head 4a4c8db)
cargo test -p continuum-host --lib local_stream: 1 passed. A client reaches the server, and a successor takes over the path. Run locally, sincecontinuum-hostis a leaf crate.derived-or-floor:reasons;EpochMs;continuum-engine. enrico's residents are CPU-bound, so CI is the compile. Its relay tests:lines_reach_a_subscriber_after_a_heartbeat_and_the_relay_ends_with_its_writersthe_incarnation_is_bound_once_from_the_control_handlelines_with_nobody_connected_are_counted_and_never_replayeda_slow_subscriber_loses_the_oldest_frames_counteda_long_line_is_cut_in_its_frame_and_whole_in_the_archivean_unwritable_archive_still_delivers_every_linesilence_is_only_this_incarnations_and_only_while_currentCarried into part (b), owner Cormac (from Codex's review of cf291a4)
local_stream::bindandOwned::remove. A held lock or a probe that never answers must not block launch or shutdown forever.🤖 Generated with Claude Code
https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE