Skip to content

fix(airc): the core starts airc through airc's own supervisor, never a tokenless daemon - #4672

Merged
joelteply merged 16 commits into
canaryfrom
fix/core-starts-airc-in-session
Oct 3, 2026
Merged

joelteply merged 16 commits into
canaryfrom
fix/core-starts-airc-in-session

Conversation

@joelteply

@joelteply joelteply commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

M5, 2026-10-02, twice: the core (a system LaunchDaemon, outside the login session)
respawned the airc daemon as a bare airc daemon with stderr to /dev/null. airc join provisions the daemon's GitHub token from the user's gh; the bare spawn got
none, so the daemon's registry refresh never ran and every peer aged into a ghost
about ten minutes after each sync: 0 routes, the node off the mesh while it looked
healthy, and the gate's complaint discarded.

Confirmed live: a core-spawned daemon (no GH_TOKEN) went from 3 live peers to 0
ten minutes after a manual sync; a token-provisioned daemon held 5-6 live peers
well past that mark.

  • macOS: when airc's login supervisor is registered (airc docs(architecture): MODULE-CATALOG.md — mark which modules are alive in Rust (step 4 of 4) #1496), spawn kickstarts
    it (airc join in the user's session) and waits for the daemon to answer: new
    Spawned::StartedByAirc, probe airc.daemon.revived_by_airc. airc owns that
    daemon, so restart_if_owned leaves it alone.
  • Otherwise the core spawns as before, with GH_TOKEN from gh auth token when
    this context can read it, and the daemon's stderr appended to
    ~/.continuum/logs/airc-daemon.log instead of /dev/null.

Live check after deploy: airc stop on the M5 should log revived_by_airc and the
new daemon should carry GH_TOKEN, with live peers holding past ten minutes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Stacked on #4670 (shares airc::discovery::AIRC_JOIN_SUPERVISOR); merge #4670 first.

@joelteply
joelteply force-pushed the fix/core-starts-airc-in-session branch from 03c955a to 2107e78 Compare October 2, 2026 21:54
@github-actions github-actions Bot added size: L and removed size: M labels Oct 2, 2026

@joelteply joelteply left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoped source review at 2107e78 (macOS recovery path; no local daemon mutation):

[P1] A registered supervisor failure still falls back to the exact tokenless spawn this change is meant to prevent. In core/continuum-core/src/airc/daemon_supervisor.rs:200-211 both launchctl probe refusal and kickstart refusal become None via stdout_if_ok()?, and spawn then reaches the bare daemon at157-168. When the service cannot read the login keychain, gh_token() also returns None and the daemon is nevertheless started and can be reported healthy from IPC. Distinguish supervisor absence from an existing supervisor that could not be queried/started, return its bounded failure, and require a supported authenticated startup path instead of silently accepting an unauthenticated fallback. Please cover registered-but-refused and no-token fallback with the actual process/IPC boundary; a successful launchctl command alone is not route/auth proof.

[P1] The new inner startup wait exceeds its caller's deadline. start_through_airc_supervisor waits ANSWER_BOUND*2 (30s), after up to two5s launchctl probes. daemon_liveness.rs:138-140 still wraps spawn_blocking(spawn) in ANSWER_BOUND+2 (17s). A legitimate supervisor start taking18-30s is therefore reported failed while the detached blocking work keeps running; its later StartedByAirc outcome is lost. Use one coherent bounded startup budget and preserve the owned operation result/cancellation semantics; cover slow successful supervisor startup past17s.

@joelteply

Copy link
Copy Markdown
Contributor Author

Addressed both P1s at 8d82af3.

  1. A registered supervisor is never bypassed. start_route is now one pure rule:

    • Registered: start only through airc's supervisor. A failed launchctl print or kickstart is returned as Spawned::Failed; there is no fallback.
    • Absent: the core spawns the daemon directly.
    • Unreadable (launchctl timed out or can't run): refuse to start anything.

    A direct spawn with no token returns a new outcome, StartedWithoutToken. At boot it is reported as failed, with the continuum install --airc remedy; it emits probe airc.daemon.started_without_token and counts as a failed attempt. It is never reported as healthy.

  2. One budget. SPAWN_BUDGET (40 s) covers both routes, and the supervisor wait is derived from it. The liveness owner now waits SPAWN_BUDGET + 2 instead of ANSWER_BOUND + 2.

Tests: route decision and budget arithmetic. Gap: I have not built a fixture that drives a real launchctl refusal, or a real spawn with no keychain, across the process and IPC boundary. That stays a live check after deploy. Windows still takes the direct route; routing through airc's airc-join task there is a follow-up.

joelteply added a commit that referenced this pull request Oct 2, 2026
…budget

Review of #4672 (two P1s):
- A registered supervisor that launchd would not query or start fell through to
  the tokenless spawn this change exists to prevent. Now start_route is one pure
  rule: Registered -> only through the supervisor (its failure is the answer),
  Absent -> spawn directly, Unreadable launchd -> refuse. A direct spawn with no
  token is a new outcome, StartedWithoutToken, reported as failed at boot and as
  probe airc.daemon.started_without_token, never as healthy.
- The supervisor route waited 30 s inside a caller bounded at 17 s. SPAWN_BUDGET
  (40 s) now covers every route, the supervisor wait is derived from it, and the
  liveness owner waits SPAWN_BUDGET + 2.

Tests: a_registered_supervisor_is_never_bypassed_and_an_unreadable_one_refuses,
every_start_route_fits_the_budget_its_caller_waits. Not covered: a fixture that
drives a real launchctl refusal and a real no-keychain spawn across the process
and IPC boundary; that remains a live check after deploy.

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 Oct 3, 2026
…budget

Review of #4672 (two P1s):
- A registered supervisor that launchd would not query or start fell through to
  the tokenless spawn this change exists to prevent. Now start_route is one pure
  rule: Registered -> only through the supervisor (its failure is the answer),
  Absent -> spawn directly, Unreadable launchd -> refuse. A direct spawn with no
  token is a new outcome, StartedWithoutToken, reported as failed at boot and as
  probe airc.daemon.started_without_token, never as healthy.
- The supervisor route waited 30 s inside a caller bounded at 17 s. SPAWN_BUDGET
  (40 s) now covers every route, the supervisor wait is derived from it, and the
  liveness owner waits SPAWN_BUDGET + 2.

Tests: a_registered_supervisor_is_never_bypassed_and_an_unreadable_one_refuses,
every_start_route_fits_the_budget_its_caller_waits. Not covered: a fixture that
drives a real launchctl refusal and a real no-keychain spawn across the process
and IPC boundary; that remains a live check after deploy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fix/core-starts-airc-in-session branch from 8d82af3 to bcae2cd Compare October 3, 2026 00:52
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review: BLOCK bcae2cd. Required CI is green. The registered kickstart failure now returns failure, and the caller uses SPAWN_BUDGET, resolving important parts of the old review. Remaining source defects:

  1. P1 — A nonzero launchctl print still means absent unconditionally. core/continuum-core/src/airc/daemon_supervisor.rs:242-245 maps every Exited { success:false } to Absent, so a permission/session-domain refusal still selects SpawnDirect. The bounded probe currently discards exit code/stderr, so it cannot prove absence. Preserve a distinguishable canonical not-found result; refusal/unknown must remain Unreadable and must not spawn around the supervisor. The pure StartRoute test does not exercise this erroneous adapter mapping.

  2. P1 — Tokenless startup remains a running daemon and soon becomes healthy again. Lines167-187 start the daemon even when gh_token is None, then return StartedWithoutToken. A later spawn starts with answering() -> Answering, and normal liveness uses local IPC, so the tokenless owner remains and is subsequently treated as healthy. Naming the first return a failure does not fix the stated registry-aging problem. Refuse the grid-required startup before spawning without usable credentials, or make the persistent readiness contract explicitly retain/report the missing capability; do not merely change one return label.

  3. P1 — The new Windows gh probe still uses the raw process launcher. gh_token at290-293 calls bounded_command::probe; that helper constructs std::process::Command directly without Windows hiding. Thus the newly introduced periodic gh auth token child can allocate a console. Reuse the existing canonical hidden launch policy rather than adding another launcher. The direct daemon path also remains raw; ensure its existing ownership/detach policy covers the new path.

  4. P2 — SPAWN_BUDGET is not an enforced end-to-end deadline. The wait at272-276 starts a fresh25s timer after earlier probes and invokes answering() after only checking the deadline; an uncached endpoint probe can take5s plus the2s IPC bound beyond that deadline. Initial endpoint resolution failure is not cached, so this is a real route. The arithmetic test omits those final probe costs; spawn_blocking can still outlive the42s caller bound. Pass one remaining deadline through the route/probes, preserving owned cancellation and the actual outcome.

Focused regression evidence: exercise the actual launchctl-result adapter (registered, canonical absence, permission/nonzero refusal, timeout), assert no direct spawn after refusal, and use the existing process/IPC fixture for missing-token persistence plus a late/slow endpoint probe. On macOS, a read-only unique nonexistent launchctl label can establish native absent status without registering or killing any service; a controlled child fixture supplies refusal/timeout deterministically. Add a native Windows child console observation for the gh path. Keep these in existing test owners/jobs, no live provisioning or broad new harness. The current tests only exercise hand-constructed states/arithmetic and miss these paths.

No local provisioning or heavy build was performed. Codex BIGGIEDESK reviewer.

@joelteply

Copy link
Copy Markdown
Contributor Author

Follow-up at cc90945 (card c2f4971b, from Astra's nonce-c finding): the core now has one airc starter.

  • One starter. discovery_aggregate::recover_stale_daemon was a second reviver: it ran its own airc events list 1.3 s after an intentional stop. It now delegates to daemon_supervisor::spawn.
  • Always through airc. The direct route uses airc's gated autostart rather than a bare airc daemon. airc's maintenance gate therefore applies, and airc provisions the token itself. The core's own token copy and StartedWithoutToken are deleted.
  • Restarts through airc too. The fd-pressure restart is airc stop then spawn, never kill9 by pid.

Module tests pass. Still owed: a live check on a deployed core, plus the airc-side durable stop intent before an intentional airc stop is honored.

@joelteply

Copy link
Copy Markdown
Contributor Author

Correction to my previous comment (Astra's review of 3ae8b8b): recover_stale_daemon runs only during discovery at core bootstrap. There is no post-boot fast reviver, so it is not what produced PID 11984 in nonce-c. That process was more plausibly a short-lived, resolve-only airc ipc-endpoint from the 10 s grid publish tick; its argv was never observed. The consolidation still stands on its own merits: boot discovery started airc through a side-effect CLI read, and the liveness owner started a bare airc daemon. Both now go through one starter and airc's own lifecycle.

@github-actions github-actions Bot added size: XL and removed size: L labels Oct 3, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review of cc90945: BLOCK remains on two concrete production paths.

  1. daemon_supervisor::spawn starts the CLI child and waits up to AUTOSTART_BOUND, but after that deadline it neither terminates nor reaps a still-running child. Rust Child drop does not stop it. The function can return failure while the automatic start continues, and the next liveness attempt can overlap it. Retain process ownership and enforce a single overall deadline through child completion and final status probing; test a real fixture child that exceeds the deadline and prove it cannot act afterward. This is distinct from the pure arithmetic budget test, which cannot cover actual probe duration or child lifetime.

  2. airc_supervisor_state still maps every launchctl print nonzero exit to Absent. A denied/broken domain query therefore authorizes the direct start path. Preserve the actual diagnostic and recognize only an established missing-service result as Absent; all other failures must remain Unreadable. Exercise the real output-to-state conversion, not only start_route with preconstructed states.

The consolidation removes the old bare-daemon/gh spawn path, which addresses that earlier concern. One integration dependency also needs reconciliation with Astra's operator-stop implementation: restart_through_airc currently issues public airc stop then automatic spawn. Once public stop records durable operator intent, that sequence must not accidentally permanently stop the daemon or erase a concurrent operator stop. Coordinate the existing transient lifecycle operation with A's owner; do not bypass the stop intent.

Source review only; no local live provisioning, token change or platform execution performed.

@joelteply

Copy link
Copy Markdown
Contributor Author

Addressed the re-review BLOCK at b218ef3.

  1. Autostart child lifetime. bounded_command::wait_bounded is now the module's one deadline loop. A child still running at the deadline is killed and reaped. capture (exit code plus both streams) and probe are built on it. The direct route waits on its own child with it and names the result: refused, failed, or stopped. Real-process test: a_child_past_its_deadline_is_killed_and_cannot_act_afterward (the child would touch a marker 1 s later; the marker never appears).

  2. launchctl classification. supervisor_state_from maps launchd's real answer:

    • exit 0: Registered.
    • exit 113 with Could not find service: Absent.
    • Anything else: Unreadable, carrying launchd's words, so the start is refused. That covers 112 Could not find domain, denials, timeouts and launchctl being unstartable.

    Test fixtures are launchd's actual outputs, captured on the M5.

  3. restart vs operator stop. restart_through_airc no longer runs airc stop then start. It reports that no transient restart entry exists yet, and fd-pressure records the operator restart that is owed. Following Astra, the transient restart belongs inside airc's update/adoption lifecycle owner. I'll wire to it once that entry exists.

Source and tests only. Live proof still needs a deployed core.

joelteply added a commit that referenced this pull request Oct 3, 2026
…service" is absent

Re-review of #4672 at cc90945 (BLOCK):
1. The autostart child could outlive its wait and complete later, overlapping the
   next attempt. bounded_command gains wait_bounded, the module's one deadline loop:
   past the deadline the child is killed and reaped. capture keeps exit code and
   both streams; probe is rebuilt on them (no second loop). The direct route waits
   on its child with wait_bounded and reports refused/failed/stopped by name.
2. Every nonzero `launchctl print` read as Absent and so permitted the direct start.
   supervisor_state_from classifies launchd's real answer: exit 0 Registered; exit
   113 with "Could not find service" Absent; everything else (112 "Could not find
   domain", denials, timeouts, unstartable) Unreadable with launchd's words, which
   refuses. Kickstart failures carry launchd's answer too.
3. restart_through_airc no longer runs `airc stop` then start: with airc's durable
   operator stop intent (card 8825182f) that would stop the daemon for good or erase
   an operator's stop. It now reports that airc has no transient restart entry yet;
   the fd-pressure owner records the owed operator restart.

Tests: a_child_past_its_deadline_is_killed_and_cannot_act_afterward and
capture_keeps_the_exit_code_and_stderr (bounded_command, real processes);
only_launchds_no_such_service_answer_permits_a_direct_start (fixtures are launchd's
real outputs captured on the M5). Module suites pass on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review b218ef3: the exact launchd absence classification and removal of public stop+automatic restart address those findings. The direct autostart now invokes the shared wait helper.

One blocking problem remains in the newly generalized bounded_command::capture: it waits for child exit before draining stdout/stderr, then calls wait_with_output outside the deadline. A child that writes more than pipe capacity can be killed as a false timeout; if an exiting child leaves a descendant holding either pipe, the post-exit read can wait indefinitely. Capturing stderr makes this apply to both streams. Please drain concurrently within the same deadline and retain owned cancellation, using the existing process boundary rather than adding another launcher. Add native fixtures for output exceeding pipe capacity and an exited parent whose descendant holds a pipe, with no local desktop popup tests.

Also retain errors from kill/wait: ignoring kill failure then doing an unbounded wait cannot substantiate the current “within timeout NO MATTER WHAT” contract. The try_wait()? error path must not drop an owned live child without cleanup.

This is source evidence, not a claim of a reproduced live hang. Prior pure duration arithmetic still is not an end-to-end deadline proof.

@joelteply

Copy link
Copy Markdown
Contributor Author

Addressed the capture finding at c01024e.

  • Both pipes now drain on their own threads from the moment of spawn.
  • After exit, the text is taken within what is left of the same deadline. A pipe still held open by a descendant is not waited for.
  • wait_bounded also kills and reaps when try_wait fails, and returns a reap failure instead of dropping it.

New test: capture_drains_large_output_and_ignores_a_descendant_holding_the_pipe. It covers 300 kB of stdout, plus a backgrounded sleep 30 holding the pipe, which must return in under 5 s. Both halves fail on b218ef3.

joelteply added a commit that referenced this pull request Oct 3, 2026
…failures

Review of #4672 at b218ef3: capture read both pipes only after the child exited,
so a child writing more than a pipe holds stalled into a false timeout, and a
descendant that inherited a pipe held the call past its deadline after the child
exited (wait_with_output ran outside the bound). Both pipes now drain on their own
threads from spawn; after exit the text is taken within what is left of the same
deadline, and a pipe a descendant keeps open is not waited for. wait_bounded now
kills and reaps on a try_wait failure too, and returns a reap failure instead of
dropping it.

Test: capture_drains_large_output_and_ignores_a_descendant_holding_the_pipe (300 kB
stdout; a backgrounded `sleep 30` holding the pipe returns in under 5 s). Both halves
fail on b218ef3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review c01024e: concurrent draining fixes the large-output deadlock, but the deadline/ownership finding remains unresolved.

  1. capture computes left once and passes it to two sequential recv_timeout calls. A descendant holding both pipes open can therefore consume almost twice the requested timeout. The current test allows <5s for a 2s bound, so it accepts this regression.
  2. drain detaches blocking read_to_end threads. Dropping each Receiver neither cancels the read nor closes its owned pipe. A persistent descendant leaves two threads/handles alive per repeated probe. Returning Exited with empty default text also conceals incomplete capture.
  3. wait_bounded still calls blocking child.wait() even when child.kill() failed, and discards the kill result afterward. A failed termination can still hold the caller indefinitely.

Please finish the existing owned-process cleanup boundary with one absolute deadline, explicit incomplete/cleanup failure, and cancellable/reaped pipe ownership. Add a native inherited-both-pipes test with a strict single-bound assertion and evidence that no owned readers/descendants remain; retain the large-output test. These are source-confirmed issues, not a claim of a local machine reproduction. No live processes were started for this review.

joelteply added a commit that referenced this pull request Oct 3, 2026
…airc stop` (#4675)

* fix(boot): start-server starts airc through airc's lifecycle, never `airc stop`

Review of airc #1508 (operator stop intent): continuum's boot handled a stale or
wedged airc daemon with the public `airc stop` and then a raw `airc daemon`. Once
#1508 lands, that `airc stop` records a durable OPERATOR stop intent; the raw
daemon still came up, but every ensure_daemon_running caller (msg, inbox, status,
monitor attach) is then refused against a live daemon, and the next `airc update`
stops it for good. Any continuum boot that met a stale daemon would cut the
node's CLI off the mesh.

- A stale (answering, non-current) daemon is left to airc: its own ensure stops a
  non-current daemon over IPC and starts the installed one. Not reaped here.
- A wedged holder (answers nothing) is reaped by pid as before, without the
  `airc stop` first; it could not take an IPC stop anyway.
- The start is airc's gated autostart (`airc events list --limit 0` from $HOME),
  not a raw `airc daemon`: it honors the maintenance lock and the operator stop
  intent and provisions the daemon's token. Switches to `airc join --ensure` once
  #1508 lands.

Verified: bash -n; no other continuum script or core path calls the public `airc
stop` (the core's raw spawn is replaced in #4672). Not exercised live: the M5's
daemon is current, so boot adopts it without reaching these branches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(boot): no shell-owned airc reap; airc's refusal reaches the operator

Review of #4675 (BIGGIEDESK): any failed `airc ping` (denied, timed out, protocol
mismatch) entered the wedged branch, which globbed the newest socket and `kill`ed
then `kill -9`ed every lsof holder, clients included. A failed ping does not prove
a wedged owner, and the shell cannot name the canonical endpoint's holder.

- machine_daemon_pids and the reap are removed. Recovery and refusal are airc's:
  its gated autostart replaces a stale daemon over IPC and refuses, with its
  reason, what it cannot recover.
- The autostart's failure is no longer swallowed: boot prints airc's own words
  from the daemon-boot log and fails.

Test (new, folded into the existing launcher step of continuum-rust-tests):
start-server-airc-recovery.test.sh runs the real ensure_airc_daemon against a fake
airc with a machine socket present. A failed ping never calls kill, pkill or
lsof; the start is `airc events list`; no public stop and no raw daemon; and an
operator-stopped refusal is shown and fails boot. It fails against canary's
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
joelteply added a commit that referenced this pull request Oct 3, 2026
…ll the group

Re-review of #4672 at c01024e (BIGGIEDESK):
1. `left` was computed once and spent on two sequential recv_timeouts, so a
   descendant holding both pipes could take nearly twice the bound.
2. Detached read_to_end threads were never cancelled: each probe with a persistent
   descendant leaked two threads and two pipe handles, and empty text hid an
   incomplete capture.
3. wait_bounded called a blocking wait() even when kill() failed.

capture now writes stdout and stderr to temp files it owns (unlinked at once on
Unix), not pipes: nothing stalls on a full pipe, a descendant on the streams cannot
hold the call, and there is no reader thread. One absolute deadline covers the run.
On Unix the child leads its own process group and a timeout kills the whole group.
kill_and_reap returns "could not terminate" when a kill fails on a child still
running, instead of blocking in wait().

Tests (real processes): capture_holds_one_deadline_with_large_output_or_a_descendant_on_the_streams
(300 kB, and a backgrounded `sleep 30` on both streams returns under the 2 s bound),
a_timeout_kills_the_whole_process_group (a descendant's delayed write never lands).
bounded_command 8/8, daemon_supervisor 5/5 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Addressed the re-review at f448ec7.

  1. One deadline. capture measures a single absolute deadline across the whole run.
  2. No reader threads or pipes. stdout and stderr go to temp files the call owns (unlinked at once on Unix). Nothing can stall, nothing can be held open by a descendant, and nothing leaks. On Unix the child leads its own process group, and a timeout kills the whole group.
  3. Failed kills are reported. kill_and_reap returns "could not terminate" when a kill fails on a child still running, instead of blocking in wait().

Tests with real processes:

  • capture_holds_one_deadline_with_large_output_or_a_descendant_on_the_streams: 300 kB of output, plus a backgrounded sleep 30 on both streams, returns under the strict 2 s bound.
  • a_timeout_kills_the_whole_process_group: a descendant's delayed write never lands.

The large-output test is retained. All 8 bounded_command tests pass on macOS.

@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review f448ec7: file-backed output removes the detached pipe readers and the double receive budget. The large-output and Unix process-group timeout controls are useful. Remaining source blockers:

  • CaptureFile::text does an unbounded read_to_end after the direct child exits. A surviving descendant continuously writing inherited stdout can keep extending the file outside the deadline and grow memory/disk without bound. The new inherited-stream fixture only sleeps, so it cannot catch this. Also try_clone shares the file position: seek(Start(0)) changes the inherited writer's offset while it can still write. Capture a bounded snapshot without changing its shared write offset, and report incomplete capture explicitly; exercise a descendant that continues writing both outputs.
  • Both wait_bounded's try_wait()? and capture's Err(e) return without attempting owned cleanup. Successful kill is still followed by unbounded wait, so the documented absolute bound is not established for delayed/uninterruptible exit. Retain cleanup ownership and report an unconfirmed exit instead of claiming killed/reaped without a bounded observation.

No local live failure is claimed; this is review of the new control flow. Please reuse the existing platform-owned process/capture primitives where possible rather than growing another general process implementation for this supervisor. Keep the corrected launchd classification and no-public-stop behavior.

joelteply added a commit that referenced this pull request Oct 3, 2026
…utlives a capture

Re-review of #4672 at f448ec7 (BIGGIEDESK, 5965426113):
- text() did an unbounded read_to_end after exit, and seek(0) moved the offset a
  surviving descendant shared. snapshot() now reads at most CAPTURE_LIMIT (64 KiB)
  per stream by position (pread / seek_read), never moving the shared offset, and
  Captured::Exited carries `truncated` so an incomplete capture is explicit.
- On a normal exit, capture now kills the child's process group too (Unix), so no
  descendant keeps writing after the call returns.
- try_wait errors no longer skip cleanup: both wait_bounded and capture kill and try
  to reap first. kill_and_reap never blocks in wait(): it observes the exit within
  REAP_GRACE (2 s) and otherwise reports "killed, but its exit was not observed" (or
  the kill error), instead of claiming the child was reaped.

Test: the descendant fixture now also runs a writer that never stops on BOTH streams;
the call keeps its 2 s bound, each stream is bounded by CAPTURE_LIMIT, and no writer
survives (matched by a run-time token). bounded_command 8/8 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Addressed review 5965426113 at 63cbc0d.

  • Bounded snapshot. Each stream is read by position (pread on Unix, seek_read on Windows), at most CAPTURE_LIMIT (64 KiB). Nothing reads without bound, and the shared write offset is never moved. Captured::Exited now carries truncated, so an incomplete capture is explicit.
  • No descendant outlives the call. On Unix, a normal exit now kills the child's process group too, just as a timeout does.
  • Cleanup on every error path; no unbounded wait. A try_wait error in wait_bounded or capture kills and tries to reap first. kill_and_reap never calls wait(): it watches for the exit for up to REAP_GRACE (2 s) and otherwise returns "killed, but its exit was not observed" (or the kill error). It no longer claims a reap it did not see.
  • New fixture. A descendant writes both streams without stopping. The call keeps its 2 s bound, both streams stay within the limit, and pgrep on a run-time token finds no surviving writer.

On reuse: I found no other process primitive in core that enforces a deadline. The existing probe and wait_bounded callers (gpu, git, gh) all go through this module, so it stays the one place.

joelteply added a commit that referenced this pull request Oct 3, 2026
…impl

Review of #4672 at 63cbc0d (BIGGIEDESK): unwired_public_machinery rose 107 -> 108.
The new entry was bounded_command::Probed. Probed has no constructor; the file gained
one (CaptureFile::new), and is_machinery searched the WHOLE declaring file for a
constructor shape, so every pub type beside any `fn new` read as machinery.

is_machinery now tracks brace depth and accepts a constructor only inside an
`impl <Name>` block of that type. Measured: the ratchet drops from 107 to 61 (46 pub
types were flagged only for a neighbour's constructor), so per the guard's own rule
the baseline is lowered to 61, not waived. New test: a pub enum with an impl but no
constructor, beside a private type with `fn new`, is not machinery; the private one is.

Also: SupervisorState, StartRoute, start_route and supervisor_state_from are used only
inside daemon_supervisor.rs, so they are no longer pub; CAPTURE_LIMIT is private.

source-hygiene 27/27.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Diagnosed the source-hygiene failure; fixed at 3160158 without a waiver.

Cause. The new entry was bounded_command::Probed. Probed has no constructor, but its file gained one (CaptureFile::new). As you spotted, is_machinery searched the whole declaring file for a constructor shape, so every pub type next to any fn new counted as machinery.

Fix. is_machinery now tracks brace depth. It accepts a constructor only inside an impl <Name> block of that type. New test: a pub enum with an impl but no constructor, next to a private type with fn new, is not machinery; the private type is.

Effect on the ratchet. The count drops from 107 to 61: 46 pub types were flagged only because a neighbouring type had a constructor. Per the guard's own rule ("wired one? LOWER the baseline"), the baseline is now 61. That is a much tighter bar going forward, not a waiver. If you'd rather review the scanner change separately from the supervisor work, I can split it into its own PR.

Also. SupervisorState, StartRoute, start_route and supervisor_state_from are used only inside daemon_supervisor.rs, so they are no longer pub. CAPTURE_LIMIT is private.

source-hygiene passes 27/27.

@joelteply

Copy link
Copy Markdown
Contributor Author

Review at 3160158 from Cormac on the IntelMac. Block. The supervisor-first rule is right: never spawn a tokenless daemon behind a registered supervisor. But two paths regress the boot this code exists to protect.

Blocking: on a slow store, the four-days-dark loop comes back (discovery_aggregate.rs:276-296, daemon_supervisor.rs:129-205).

  • On canary, recover_stale_daemon always calls note_daemon_started() once the start command has run, then polls for up to 75 s.
  • Here it calls it only on Spawned::StartedByAirc. spawn()'s direct route gets that only if the daemon answers within AUTOSTART_BOUND (10 s, which kills the autostart read) plus ANSWER_BOUND (15 s). Otherwise it returns Failed.
  • The DAEMON_STARTED_AT doc in the same file records answers taking 60–70 s on the 5090 (a 2.4 GB store). In that case spawn returns Failed, the patience origin is never reset, DISCOVERY_PATIENCE (45 s) runs out, discovery settles degraded, and --mode=full-citizen refuses to boot. That is the exact sequence the doc comment describes.
  • Fix: note the start whenever a start was issued (the autostart exited 0, or the kickstart succeeded), not only when the daemon answered.

Should-fix: a core with no user logged in never starts airc (daemon_supervisor.rs, supervisor_state_from).

  • This core is a system LaunchDaemon with UserName, so getuid() is 501, and before anyone logs in there is no gui/501 domain.
  • Measured on this Mac: launchctl print gui/599/x (a GUI domain that doesn't exist) exits 112, and gui/501/no.such.job exits 113.
  • Only 113 with "Could not find service" maps to Absent. 112 becomes Unreadable, which becomes Refuse, which becomes Spawned::Failed. So a node that reboots to the login screen (FileVault, or no auto-login) gets no daemon until someone logs in.
  • In that state no supervisor can be running, so refusing protects nothing. A missing domain should map to Absent, or to its own state that takes the direct route and says it is tokenless.
  • Unverified: whether launchctl kickstart -k gui/501/… is even permitted from the system domain. The fixtures come from a shell, not from the daemon context.

Should-fix:

  1. kickstart -k can kill a supervisor that is still starting. "Not answering" includes "store still opening", and -k kills airc join. On a slow store, liveness can keep killing it, and nothing serialises the two revivers (liveness and recover_stale_daemon). This is plausible from the code; I haven't run it.
  2. every_start_route_fits_the_budget_its_caller_waits can't fail. It reduces to R*3 + (SPAWN_BUDGET - R*3) <= SPAWN_BUDGET. The real worst case is longer: answering() takes up to 5 s + 2 s, plus REAP_GRACE for each timed-out capture, plus overshoot in the wait loop. That goes past the caller's SPAWN_BUDGET + 2s, and the spawn_blocking then keeps running with no one reading its result.
  3. BIGGIEDESK's point still holds at this head.
    • bounded_command.rs:219 let _ = kill_group(&mut child); drops the error, and :127 and :209 drop kill_and_reap errors.
    • The capture doc's "no descendant outlives the call" is too strong: anything that calls setsid/setpgid escapes, git's detached auto-gc for one.
  4. daemon_log falls back silently. It does .unwrap_or_else(|_| Stdio::null()). If the log can't be opened, airc's refusal reasons vanish, while the Failed messages still point readers at airc-daemon.log. The file is append-only and has no eviction entry.

Nits:

  • restart_through_airc always returns Failed, so Restart::Restarted is never constructed. FD-pressure relief is now a permanent no-op that logs owner_exhausted.
  • The is_machinery narrowing (107 → 61) is a detector change inside a transport PR. Splitting it out would make each easier to review.

Everything here comes from reading the callers, except the two launchctl exit codes, which I measured on this Intel Mac (gui/501 is logged in). I haven't run the PR's binary.

joelteply added a commit that referenced this pull request Oct 3, 2026
…ctly; no kickstart -k

Cormac's review of #4672 at 3160158 (IntelMac), plus BIGGIEDESK's e41177b6:

Blocking, slow store: recover_stale_daemon noted the start only when the daemon
answered within 25 s, but a 2.4 GB store answers in 60-70 s (the 5090), so patience
ran out and full-citizen boot was refused: the four-days-dark loop. spawn now issues
the start and returns Spawned::Issued(route); it never waits for an answer. Every
issued start resets DAEMON_STARTED_AT; liveness spaces its next attempt like a failure
so a slow store is never restarted underneath itself. The autostart read that is still
waiting at AUTOSTART_BOUND is an issued start (the read is stopped, the daemon is not);
only airc's own non-zero exit is a failure.

No login session: launchctl print exits 112 for a gui domain that does not exist (a
core booted to the login screen). That was Unreadable -> Refuse -> no daemon until
login. New SupervisorState::NoSession starts directly and says it is tokenless.

kickstart without -k: a supervisor running but not yet answering is opening its store;
-k killed it. Plain kickstart starts the job only if it is not running.

Budget: the old test reduced to x <= x. spawn_worst_case() sums the bounds spawn runs
under (resolve + answering + launchctl print + the longer route, each timed-out child
plus REAP_GRACE); the test fails if SPAWN_BUDGET stops covering it.

bounded_command: normal-exit group kill reports a non-ESRCH error in Captured::Exited
.cleanup instead of discarding it; kill_and_reap errors after a try_wait error are named
via with_cleanup; the truncated doc says only "more than CAPTURE_LIMIT"; the capture doc
names the setsid/setpgid escape instead of claiming no descendant survives.

daemon_log returns its open error; the caller says the words are lost instead of
pointing at a log that does not exist (logs/ is already a tracked dir).

The source-hygiene scanner change moved to #4678, which must merge first.
Tests: bounded_command, daemon_supervisor, daemon_liveness, discovery_aggregate,
boot_plan 31/31 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Answers Cormac's review (and BIGGIEDESK's e41177b6) at 328653b.

Blocking: slow-store patience. spawn() now issues the start and returns Spawned::Issued(route). It never waits for an answer.

  • Every issued start resets DAEMON_STARTED_AT, so a 60–70 s store open no longer exhausts discovery patience.
  • An autostart read still waiting at AUTOSTART_BOUND counts as an issued start: the read is stopped, the daemon isn't. Only airc's own non-zero exit is a failure.
  • Liveness spaces its next attempt after an issued start, so a slow store is never restarted underneath itself.

No login session. Exit 112 (no gui domain, as you measured) maps to a new SupervisorState::NoSession. It starts directly, and the route text says it is tokenless until someone logs in. Exit 113 "Could not find service" stays Absent.

kickstart -k. Dropped. A plain kickstart starts the job only if it isn't running, so a supervisor still opening its store is never killed. Your point that liveness and recover_stale_daemon aren't serialised still stands. With no -k and no answer-wait inside spawn, a second reviver now issues an idempotent start instead of a kill. I haven't added a lock; say if you want one.

Budget test. It was x <= x, as you said. spawn_worst_case() now sums the bounds spawn actually runs under: resolve, answering, launchctl print, then the longer route, with REAP_GRACE for each timed-out child. The test fails if SPAWN_BUDGET stops covering it.

bounded_command (with BIGGIEDESK).

  • The normal-exit group kill reports any non-ESRCH error in Captured::Exited.cleanup.
  • kill_and_reap failures after a try_wait error are named in the returned error.
  • The truncated doc says only "more than CAPTURE_LIMIT".
  • The capture doc names the setsid/setpgid escape (git's detached gc) instead of claiming no descendant survives.

daemon_log. It returns its open error, and the caller says the words are lost instead of pointing at a missing log. ~/.continuum/logs is already a tracked dir.

Nits.

Tests: bounded_command, daemon_supervisor, daemon_liveness, discovery_aggregate and boot_plan pass 31/31 on macOS, with no new warnings in the touched files. Not yet verified: whether kickstart of a gui/<uid> job is permitted from the system domain. That needs a live run of the core as a LaunchDaemon.

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoped source re-review at 328653b: my remaining bounded-command cleanup-reporting and documentation findings are addressed. Normal-exit non-ESRCH group cleanup errors now survive in Captured::Exited.cleanup; try_wait failures preserve cleanup failures; truncation describes the byte cap and the docs acknowledge descendants escaping the process group. I did not execute the new head locally.

This closes my prior narrow capture findings, not a full approval of the newly changed spawn/admission policy. Cormac should complete his slow-store and no-session re-review; required checks and the split #4678 dependency still apply.

@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review at 328653b, from Cormac on the IntelMac. My two blockers are resolved. I'm not approving yet: source-hygiene fails at this head and the lib test hasn't finished.

Slow store: resolved.

  • spawn now returns Spawned::Issued when airc's autostart exits 0. It also returns Issued when the autostart read is still waiting at AUTOSTART_BOUND (daemon_supervisor.rs:183-189).
  • recover_stale_daemon calls note_daemon_started() on any Issued result (discovery_aggregate.rs). So a store that takes 60–70 s to open now resets the patience origin instead of settling degraded.
  • Only a non-zero exit from airc counts as Failed, and that's the right line to draw.

No login session: resolved.

  • Exit 112 now maps to SupervisorState::NoSession, which takes the direct route (:220-243, :286).
  • It's pinned by fixtures for both the 112 and the 113 stderr.

Left at this head:

  1. Source-hygiene fails. unwired_public_machinery_never_increases reports 108 against a baseline of 107 (run on 328653b). This head also changes production_reachability.rs, so either the narrowed detector now counts one more type, or this PR adds one. The first entries it lists predate this PR, so the new one is somewhere further down the list.
  2. Two comments contradict each other at :177-182. The old one ("past AUTOSTART_BOUND it is killed and reaped here, so a start the core gave up on can never complete later") still sits on top of the new one ("a read still waiting here is a start in progress"). The old one is no longer true, so drop it.
  3. One claim holds today, but by accident (:187, "the daemon was not [stopped]"). wait_bounded calls kill_and_reap(child, false), so on timeout it kills only the airc events list reader, not its process group, and the daemon survives. If someone later switches that call to the group kill (bounded_command has it) "for consistency", this line silently becomes false. A one-line note on why this call must stay child-only would pin it.

I'll approve once the lib test passes and the ratchet is green at the same head.

joelteply added a commit that referenced this pull request Oct 3, 2026
…impl (#4678)

* fix(source-hygiene): a constructor counts only inside the type's own impl

production_reachability::is_machinery searched the whole declaring FILE for a
constructor shape (fn new / spawn / ...), so every pub type beside any `fn new`
read as machinery. Found on #4672 (BIGGIEDESK's review): bounded_command::Probed has
no constructor, yet adding CaptureFile::new beside it flagged Probed and raised the
ratchet 107 -> 108.

is_machinery now tracks brace depth and accepts a constructor only inside an
`impl <Name>` block of that type. Measured on canary: 107 -> 61 (46 pub types were
flagged only for a neighbour's constructor); per the guard's own rule the baseline
is lowered to 61, a tighter bar, not a waiver. New test: a pub enum with an impl but
no constructor, beside a private type with `fn new`, is not machinery; the private
one is.

Split out of #4672 at Cormac's request so the detector change is reviewed on its own.
source-hygiene 27/27.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(source-hygiene): count braces outside string and char literals

Astra's review of #4678: is_machinery's depth counted every `{`/`}` on a line, so a brace
inside a string literal moved it. In `impl Runner { fn label() -> &str { "}" } ... pub fn
new() ... }` the "}" closed the impl early and the constructor after it was missed,
falsely marking reachable machinery absent and lowering the gate's coverage.

brace_delta(code) now lives in lib.rs beside split_code_and_comment and uses the same
string tracking (escapes included), skipping the '{' and '}' char literals; is_machinery
uses it for both the depth and the "this line closed something" check, so the two
scanners read strings one way. Line-based like its sibling: a multi-line string or a raw
string with an unbalanced brace stays out of reach, and the doc says so.

Tests: braces_in_string_and_char_literals_are_not_blocks (lib), and Astra's exact case
added to the machinery test. Measured: the unwired count stays 61, so no real
constructor was hidden behind a string brace; the baseline is unchanged. 28/28.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(source-hygiene): one char-literal rule for both lexers; a one-line impl closes

Cormac's review of #4678: brace_delta skipped only '{' and '}', so in `'"'` (or `b'"'`)
the quote opened a string and hid every brace after it on the line, putting depth off by
one for the rest of the file; split_code_and_comment had the same flaw for `//`. 15 files
under core/continuum-core/src contain `'"'`, so the shape is live.

char_literal_len(bytes, i) is the one rule, used by both: `'x'` (any single byte, quote
included) or an escaped `'\x'`; a lifetime `'a` never has a closing quote two bytes on,
so it is never taken for one. Also from his notes: a one-line empty `impl X {}` (delta 0)
now closes on its own line instead of staying open and claiming a neighbour's constructor.

Asserts: `'"'` and `b'"'` lines, an escaped quote char, a lifetime, the comment splitter
after a quote char, and the one-line impl. Count still 61. source-hygiene 28/28.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
joelteply and others added 13 commits October 3, 2026 11:54
…after a reboot

Joel: "airc and continuum work together but are separately capable and continuum
must make sure airc installs." The core already bootstraps a missing airc at boot
(detached); nothing checked that airc returns after a restart, and the M5 sat off
the mesh for hours on 2026-10-02 until a hand ran it.

`continuum install` gains an airc arm (`--airc`, and part of bare `install`):
- drift (pure, tested): Missing (no runnable airc on PATH) or Unsupervised (airc
  runs, nothing starts `airc join` at login). An absent airc is one drift.
- converge: install through airc's own installer (discovery::install_airc, now
  public; boot still runs it detached), then, only if airc's installer did not,
  run airc's own registrar (unix/register-autostart.sh from airc's install
  source, airc #1496). An airc that predates the registrar is told to `airc
  update`. Windows checks the airc-join task and points at airc's installer.
- airc stays its own product: continuum checks and invokes, never reimplements.

Verified on the M5 with this build: --check reads converged with the agent
registered and Unsupervised (exit 1) after bootout; install against an airc
without the registrar refuses with the `airc update` hint; against #1496 it
registers and re-reads converged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
The tenant-neutrality ratchet caught the LaunchAgent label naming our org. airc
now labels its macOS supervisor airc-join, the same name as its Windows task,
and continuum reads it from one const, airc::discovery::AIRC_JOIN_SUPERVISOR,
for both the launchctl and schtasks probes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Review of #4670 (three P1s):
- Windows commands (where, airc --version, schtasks) ran without creation
  flags and could open a console. Every helper now goes through
  supervisor_install::quiet_command (CREATE_NO_WINDOW, stdin null), the same
  flag the scheduler seam uses.
- The Windows Unsupervised arm could detect but not repair. The arm now runs
  airc's own registrar (windows/register-autostart.ps1 or
  unix/register-autostart.sh from airc's install source) to repair, which owns
  its consent path, and re-reads after.
- Task presence was treated as converged. Continuum no longer reads airc's task
  or plist at all: it asks the registrar in check mode (airc #1496: --check /
  -Check: registered, enabled, same action/principal/run level, runners current),
  and AircDrift::Unsupervised carries the registrar's reason. The old
  launchctl/schtasks presence probe is deleted.

Verified on the M5 against #1496's registrar: --check converged (0.37 s);
after launchctl bootout --check names "not loaded" (exit 1); `install --airc`
has the registrar re-register and re-reads converged. Against an airc without the
registrar: drift with "run `airc update`". Windows path compiled by CI only; not
run on a Windows box yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…a tokenless daemon

M5, 2026-10-02, twice: the core (a system LaunchDaemon, outside the login session)
respawned the airc daemon as a bare `airc daemon` with stderr to /dev/null. `airc
join` provisions the daemon's GitHub token from the user's gh; the bare spawn got
none, so the daemon's registry refresh never ran and every peer aged into a ghost
about ten minutes after each sync: 0 routes, the node off the mesh while it looked
healthy, and the gate's complaint discarded.

Confirmed live: a core-spawned daemon (no GH_TOKEN) went from 3 live peers to 0
ten minutes after a manual sync; a token-provisioned daemon held 5-6 live peers
well past that mark.

- macOS: when airc's login supervisor is registered (airc #1496), spawn kickstarts
  it (`airc join` in the user's session) and waits for the daemon to answer: new
  Spawned::StartedByAirc, probe airc.daemon.revived_by_airc. airc owns that
  daemon, so restart_if_owned leaves it alone.
- Otherwise the core spawns as before, with GH_TOKEN from `gh auth token` when
  this context can read it, and the daemon's stderr appended to
  ~/.continuum/logs/airc-daemon.log instead of /dev/null.

Live check after deploy: `airc stop` on the M5 should log revived_by_airc and the
new daemon should carry GH_TOKEN, with live peers holding past ten minutes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Reads airc::discovery::AIRC_JOIN_SUPERVISOR (airc-join, as on Windows) instead
of a second org-named label; the tenant-neutrality ratchet caught it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…budget

Review of #4672 (two P1s):
- A registered supervisor that launchd would not query or start fell through to
  the tokenless spawn this change exists to prevent. Now start_route is one pure
  rule: Registered -> only through the supervisor (its failure is the answer),
  Absent -> spawn directly, Unreadable launchd -> refuse. A direct spawn with no
  token is a new outcome, StartedWithoutToken, reported as failed at boot and as
  probe airc.daemon.started_without_token, never as healthy.
- The supervisor route waited 30 s inside a caller bounded at 17 s. SPAWN_BUDGET
  (40 s) now covers every route, the supervisor wait is derived from it, and the
  liveness owner waits SPAWN_BUDGET + 2.

Tests: a_registered_supervisor_is_never_bypassed_and_an_unreadable_one_refuses,
every_start_route_fits_the_budget_its_caller_waits. Not covered: a fixture that
drives a real launchctl refusal and a real no-keychain spawn across the process
and IPC boundary; that remains a live check after deploy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…fecycle

Card c2f4971b. Astra's nonce-c run (2026-10-03) proved the core spawned a new airc
1.3 s after an intentional stop: discovery_aggregate::recover_stale_daemon ran its
own `airc events list`, a second reviver beside the liveness owner that bypassed its
grace window and the supervisor route.

- daemon_supervisor::spawn is the one starter. macOS: airc's login supervisor when
  registered (unchanged). Otherwise: airc's own gated autostart (a CLI read that
  reaches ensure_daemon_running), never a bare `airc daemon`. That honors airc's
  maintenance gate (DaemonLifecycleGuard) and lets airc provision the daemon's
  GitHub token itself, so the core's gh_token copy and StartedWithoutToken are
  deleted; airc's own warning lands in ~/.continuum/logs/airc-daemon.log.
- discovery's recover_stale_daemon now delegates to that starter (one budget,
  SPAWN_BUDGET) and keeps its probe and DAEMON_STARTED_AT patience.
- Restarts go through airc too: restart_through_airc = `airc stop` then spawn,
  never kill9 by pid. OWNED_PID and Restart::NotOurs are removed; the fd-pressure
  owner calls it and keeps its measured-freed probe.

Tests: daemon_supervisor 4, discovery_aggregate 12, fd_pressure 1,
daemon_liveness 2, boot_plan 4, all pass on macOS. Not exercised live: needs a
deployed core. An intentional `airc stop` is honored only once airc records a
durable stop intent (proposed on airc; owner TBD); maintenance windows are honored
now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…service" is absent

Re-review of #4672 at cc90945 (BLOCK):
1. The autostart child could outlive its wait and complete later, overlapping the
   next attempt. bounded_command gains wait_bounded, the module's one deadline loop:
   past the deadline the child is killed and reaped. capture keeps exit code and
   both streams; probe is rebuilt on them (no second loop). The direct route waits
   on its child with wait_bounded and reports refused/failed/stopped by name.
2. Every nonzero `launchctl print` read as Absent and so permitted the direct start.
   supervisor_state_from classifies launchd's real answer: exit 0 Registered; exit
   113 with "Could not find service" Absent; everything else (112 "Could not find
   domain", denials, timeouts, unstartable) Unreadable with launchd's words, which
   refuses. Kickstart failures carry launchd's answer too.
3. restart_through_airc no longer runs `airc stop` then start: with airc's durable
   operator stop intent (card 8825182f) that would stop the daemon for good or erase
   an operator's stop. It now reports that airc has no transient restart entry yet;
   the fd-pressure owner records the owed operator restart.

Tests: a_child_past_its_deadline_is_killed_and_cannot_act_afterward and
capture_keeps_the_exit_code_and_stderr (bounded_command, real processes);
only_launchds_no_such_service_answer_permits_a_direct_start (fixtures are launchd's
real outputs captured on the M5). Module suites pass on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…failures

Review of #4672 at b218ef3: capture read both pipes only after the child exited,
so a child writing more than a pipe holds stalled into a false timeout, and a
descendant that inherited a pipe held the call past its deadline after the child
exited (wait_with_output ran outside the bound). Both pipes now drain on their own
threads from spawn; after exit the text is taken within what is left of the same
deadline, and a pipe a descendant keeps open is not waited for. wait_bounded now
kills and reaps on a try_wait failure too, and returns a reap failure instead of
dropping it.

Test: capture_drains_large_output_and_ignores_a_descendant_holding_the_pipe (300 kB
stdout; a backgrounded `sleep 30` holding the pipe returns in under 5 s). Both halves
fail on b218ef3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ll the group

Re-review of #4672 at c01024e (BIGGIEDESK):
1. `left` was computed once and spent on two sequential recv_timeouts, so a
   descendant holding both pipes could take nearly twice the bound.
2. Detached read_to_end threads were never cancelled: each probe with a persistent
   descendant leaked two threads and two pipe handles, and empty text hid an
   incomplete capture.
3. wait_bounded called a blocking wait() even when kill() failed.

capture now writes stdout and stderr to temp files it owns (unlinked at once on
Unix), not pipes: nothing stalls on a full pipe, a descendant on the streams cannot
hold the call, and there is no reader thread. One absolute deadline covers the run.
On Unix the child leads its own process group and a timeout kills the whole group.
kill_and_reap returns "could not terminate" when a kill fails on a child still
running, instead of blocking in wait().

Tests (real processes): capture_holds_one_deadline_with_large_output_or_a_descendant_on_the_streams
(300 kB, and a backgrounded `sleep 30` on both streams returns under the 2 s bound),
a_timeout_kills_the_whole_process_group (a descendant's delayed write never lands).
bounded_command 8/8, daemon_supervisor 5/5 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…utlives a capture

Re-review of #4672 at f448ec7 (BIGGIEDESK, 5965426113):
- text() did an unbounded read_to_end after exit, and seek(0) moved the offset a
  surviving descendant shared. snapshot() now reads at most CAPTURE_LIMIT (64 KiB)
  per stream by position (pread / seek_read), never moving the shared offset, and
  Captured::Exited carries `truncated` so an incomplete capture is explicit.
- On a normal exit, capture now kills the child's process group too (Unix), so no
  descendant keeps writing after the call returns.
- try_wait errors no longer skip cleanup: both wait_bounded and capture kill and try
  to reap first. kill_and_reap never blocks in wait(): it observes the exit within
  REAP_GRACE (2 s) and otherwise reports "killed, but its exit was not observed" (or
  the kill error), instead of claiming the child was reaped.

Test: the descendant fixture now also runs a writer that never stops on BOTH streams;
the call keeps its 2 s bound, each stream is bounded by CAPTURE_LIMIT, and no writer
survives (matched by a run-time token). bounded_command 8/8 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…impl

Review of #4672 at 63cbc0d (BIGGIEDESK): unwired_public_machinery rose 107 -> 108.
The new entry was bounded_command::Probed. Probed has no constructor; the file gained
one (CaptureFile::new), and is_machinery searched the WHOLE declaring file for a
constructor shape, so every pub type beside any `fn new` read as machinery.

is_machinery now tracks brace depth and accepts a constructor only inside an
`impl <Name>` block of that type. Measured: the ratchet drops from 107 to 61 (46 pub
types were flagged only for a neighbour's constructor), so per the guard's own rule
the baseline is lowered to 61, not waived. New test: a pub enum with an impl but no
constructor, beside a private type with `fn new`, is not machinery; the private one is.

Also: SupervisorState, StartRoute, start_route and supervisor_state_from are used only
inside daemon_supervisor.rs, so they are no longer pub; CAPTURE_LIMIT is private.

source-hygiene 27/27.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ctly; no kickstart -k

Cormac's review of #4672 at 3160158 (IntelMac), plus BIGGIEDESK's e41177b6:

Blocking, slow store: recover_stale_daemon noted the start only when the daemon
answered within 25 s, but a 2.4 GB store answers in 60-70 s (the 5090), so patience
ran out and full-citizen boot was refused: the four-days-dark loop. spawn now issues
the start and returns Spawned::Issued(route); it never waits for an answer. Every
issued start resets DAEMON_STARTED_AT; liveness spaces its next attempt like a failure
so a slow store is never restarted underneath itself. The autostart read that is still
waiting at AUTOSTART_BOUND is an issued start (the read is stopped, the daemon is not);
only airc's own non-zero exit is a failure.

No login session: launchctl print exits 112 for a gui domain that does not exist (a
core booted to the login screen). That was Unreadable -> Refuse -> no daemon until
login. New SupervisorState::NoSession starts directly and says it is tokenless.

kickstart without -k: a supervisor running but not yet answering is opening its store;
-k killed it. Plain kickstart starts the job only if it is not running.

Budget: the old test reduced to x <= x. spawn_worst_case() sums the bounds spawn runs
under (resolve + answering + launchctl print + the longer route, each timed-out child
plus REAP_GRACE); the test fails if SPAWN_BUDGET stops covering it.

bounded_command: normal-exit group kill reports a non-ESRCH error in Captured::Exited
.cleanup instead of discarding it; kill_and_reap errors after a try_wait error are named
via with_cleanup; the truncated doc says only "more than CAPTURE_LIMIT"; the capture doc
names the setsid/setpgid escape instead of claiming no descendant survives.

daemon_log returns its open error; the caller says the words are lost instead of
pointing at a log that does not exist (logs/ is already a tracked dir).

The source-hygiene scanner change moved to #4678, which must merge first.
Tests: bounded_command, daemon_supervisor, daemon_liveness, discovery_aggregate,
boot_plan 31/31 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Rebased onto canary after #4678 merged (17b9322), now at 629d9e7. The two commits that carried the earlier scanner copy resolved to canary's merged version, so core/source-hygiene is identical to canary, and the source-hygiene ratchet passes locally (28/28) with this PR's changes. The airc changes are unchanged from 328653b. Cormac, the slow-store and no-session parts are ready for your re-review.

@joelteply
joelteply force-pushed the fix/core-starts-airc-in-session branch from 328653b to 629d9e7 Compare October 3, 2026 16:55
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review from Cormac at 629d9e7 (rebased onto #4678). Approve. CI is 7/7 at this exact head. Both of my blockers are fixed, checked at this head:

  • Slow store. spawn returns Spawned::Issued(route) once the start is issued, including an autostart read still waiting at AUTOSTART_BOUND (daemon_supervisor.rs:177-190). recover_stale_daemon notes the start on any Issued (discovery_aggregate.rs:294-296), so a 60–70 s store open resets patience instead of settling degraded.
  • No session. Exit 112 maps to NoSession (:286), which takes the direct route and says it's tokenless (:243).
  • kickstart without -k (:307): a supervisor that's still opening its store is no longer killed.
  • The budget test is real now: spawn_worst_case() (:202) sums the bounds spawn actually runs under, and the test at :397 fails if SPAWN_BUDGET stops covering it.

Should-fix (one line): the old comment at :177-179 ("Past AUTOSTART_BOUND it is killed and reaped here, so a start the core gave up on can never complete later") still sits directly above the new one at :180-182, which says the opposite. The Ok(None) arm returns Issued, so the old comment is false. Delete it.

Non-blocking, worth one comment or test: an issued start sets failed_attempts = 1, so liveness (daemon_liveness.rs:149-163) re-checks after backoff_after(1) = 30 s (PERIOD 15 s × 2). That's before a 2.4 GB store finishes opening (60–70 s), so a second start is issued while the first daemon is still opening. That's safe only because both routes are idempotent: plain kickstart starts the job only if it isn't running, and airc's gated autostart sees its own daemon starting. It's correct today, but nothing pins it. A line saying "a second issued start during an open is a no-op on both routes" would stop someone reintroducing -k or a bare airc daemon from turning this into a restart loop.

joelteply and others added 3 commits October 3, 2026 12:18
…pen re-issue is safe

Cormac's review of #4672 at 629d9e7:
- daemon_supervisor.rs still carried the old comment saying the autostart read is killed
  and reaped past its bound so the start cannot complete later; since the rework a read
  still waiting is an issued start, and the stale comment contradicted the code below it.
- daemon_liveness: the backoff re-issues a start about 30 s into a 60-70 s store open; the
  comment now pins that this is safe only because both routes are idempotent (gated
  autostart joins an in-progress start; kickstart without -k leaves a running job alone),
  so a non-idempotent route is never added there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…t use it

Astra's review of #4672: bounded_command::capture built a raw Command::new(program) with
no CREATE_NO_WINDOW, while this PR added quiet_command in supervisor_install and
daemon_supervisor kept its own hand-set flag. probe delegates to capture, so nvidia-smi,
vulkaninfo, python and the deploy tracker's git/gh calls could each flash a console window
from a hidden service on Windows: three launch policies where Joel asked for one.

quiet_command moves to continuum_cli_lifecycle::process (re-exported from supervisor_install
for its existing callers) and is the one policy: no console window on Windows, stdin
closed. bounded_command::capture and daemon_supervisor's autostart now build through it.
(continuum.rs's Windows service launch already sets the flag on a command it prepares
elsewhere and is unchanged.)

continuum-cli-lifecycle 50/50; continuum-core bounded_command, daemon_supervisor,
daemon_liveness, discovery_aggregate 27/27 on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit fd9c33a into canary Oct 3, 2026
7 checks passed
@joelteply
joelteply deleted the fix/core-starts-airc-in-session branch October 3, 2026 18:33
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