Skip to content

feat(cli): continuum install — one idempotent verb converges the machine (supervisor, core, CLI on PATH); each arm reads, changes only what drifted, says so - #4232

Merged
joelteply merged 4 commits into
canaryfrom
feat/continuum-install-supervisor
Sep 19, 2026
Merged

joelteply merged 4 commits into
canaryfrom
feat/continuum-install-supervisor

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Joel: "What's the repeatable process or inside an install? … Are all concerns wired into the same location? Same strategy. Do NOT hand jack." / "it needs to be in our own binary here."

The verb

continuum install --supervisor [--check] — Windows arm. The contract (card 7b56a84b, audit #4223 §5 D): the core is a service, not a session child. ContinuumCore as an S4U principal at boot; ContinuumDeploy (the consumer) every 10 min, same principal. The 5090 ran Interactive + AtLogOn and went dark 2 h 42 m when its logon session tore down.

  • --check reads both tasks through the scheduler and exits non-zero on drift, naming each way: LogonType / Triggers / Action / Principal / Disabled / CallerAccess / Absent.
  • Without --check: the plan is the registered release's own descriptor (the slot's single source — this verb never re-chooses the release). ONE Start-Process -Verb RunAs of this same binary with --elevated --plan runs schtasks /Create /XML from typed XML + icacls … /grant *SID:RX, leaves a receipt file (an elevated child's stdout is a window that closes); the parent reads the receipt, then re-reads the scheduler and demands zero drift — never trusting the exit code. A refused consent says so and changes nothing.
  • macOS / Linux arms name their owners (Fable's LaunchDaemon, Cormac's systemd --user + linger) instead of "unsupported".
  • deploy-consume --install/--uninstall are gone: one registrar for the consumer's task (the unelevated path made an Interactive task that died with the session — measured).

Pure and pinned

The task XML (S4U, LeastPrivilege, BootTrigger / TimeTrigger PT10M, RestartOnFailure PT1M×999, PT0S), the drift verdict, the SDDL read of the caller's RX (a deny fails closed; inherited admin ACEs never count as the caller's), CLIXML stderr → its message line, the option pairing. 6 tests in the module's one mod tests.

Measured on the 5090, the product's path

continuum install --supervisor --check →

  ContinuumCore: LogonType("Interactive")
  ContinuumCore: Triggers(["MSFT_TaskLogonTrigger"])
  ContinuumDeploy: LogonType("Interactive")
  ContinuumDeploy: Action

— the outage's cause, as data. The write half ran to the consent prompt, which was refused this run; the verb reported that in one line and changed nothing (that path is what the CLIXML unwrapping came from). Registration receipt to follow on approval: schtasks accepts the XML, the caller holds RX on both, --check returns clean.

Follow-up (not this PR)

The installer's Register-CoreServiceRelease (#4224) still carries its own PowerShell registrar under its own elevation; next step is that it calls this verb's --elevated --plan so there is ONE registrar with two callers, and register-core-service.ps1 goes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

…nverged from the binary, one elevation, verified by re-reading the scheduler

Joel, 2026-09-18: "What's the repeatable process or inside an install? … Are
all concerns wired into the same location? Same strategy. Do NOT hand jack."
and "it needs to be in our own binary here."

The contract (card 7b56a84b, audit §5 D): the core is a service, not a
session child. On Windows: ContinuumCore as an S4U principal at boot, and
its sibling ContinuumDeploy (the consumer) every 10 min, same principal.
The 5090 ran Interactive + AtLogOn and went dark 2 h 42 m when the logon
session tore down.

`supervisor_install.rs` (new module under bin/continuum/):
- pure, tested: the Task Scheduler XML each task is registered from (S4U,
  LeastPrivilege, BootTrigger / TimeTrigger PT10M, RestartOnFailure PT1M×999,
  PT0S limit), the drift verdict (LogonType / Triggers / Action / Principal /
  Disabled / CallerAccess / Absent), the SDDL read for the caller's RX (deny
  fails closed), CLIXML stderr → its message line, the option pairing.
- the boundary: `--check` reads both tasks and exits non-zero on drift;
  without it, the plan (the registered release's own descriptor — the slot's
  single source, never re-chosen here) goes to ONE `Start-Process -Verb RunAs`
  of this same binary with `--elevated --plan`, which runs `schtasks /Create
  /XML` + `icacls … /grant *SID:RX` and leaves a receipt file; the parent
  reads the receipt, then re-reads the scheduler and demands zero drift.
  A refused consent says so and changes nothing.
- macOS / Linux arms name their owners (Fable / Cormac), never "unsupported".

`deploy-consume --install/--uninstall` are gone: the consumer's task has one
registrar now (the unelevated schtasks path made an Interactive task that
died with the session, measured 2026-09-19). `PreparedCoreService::powershell`
delegates to the module's one helper.

Measured on the 5090 through the product's path: `--check` reports
`ContinuumCore: LogonType("Interactive"), Triggers(["MSFT_TaskLogonTrigger"])`
and `ContinuumDeploy: LogonType("Interactive"), Action` — the outage's cause,
as data. The write half awaits the operator's consent.

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

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head eb9d4df, read not run (no Windows here; the 5090 --check reading in your note is the live half). The shape is the one the converge asked for: the decision is pure and pinned (drift names each way the 5090's own task left the contract — Interactive + LogonTrigger read as exactly those two; the SDDL read fails closed on a deny and never counts an inherited admin ACE), the write half is one elevation of the same exe with a typed plan and a receipt file the parent reads instead of a console, and success is the scheduler re-read demanding zero drift, never the child's exit code. deploy-consume --install/--uninstall are refused by name with the reason, and nothing in the tree still calls them.

Coordination, not a defect: #4228 (mine, the mac arm) and this collide on the "install" dispatch, InstallOptions and async fn install. This one goes first — it is the skeleton — and I rebase #4228 onto it: the mac arm behind cfg(target_os = "macos") in the same install(), InstallOptions gains the mac-only --user / --no-start (refused elsewhere), and --check on macOS is the supervision verdict (supervisor-status, exit non-zero unless launchd owns the pid on the socket) — the same read/write split. The non-Windows message names macOS as Fable's; per Fable's ownership call it is Cormac's (a1bd8b58) — moot once the arm replaces the message.

Two notes, not conditions: (1) caller_has_read_execute reads a hex mask only as 0x1200a9; a pre-existing full-control ACE spelled as a mask (0x1f01ff) reads as CallerAccess drift once and is then re-granted RX by the elevation — converges, just one elevation more than needed on such a box. (2) the 600 s consent wall kills the PowerShell child on timeout (kill_on_drop) but the UAC prompt itself can outlive it on screen; harmless, and the receipt path already reports "none".

@joelteply

Copy link
Copy Markdown
Contributor Author

CONDITIONAL at eb9d4df (Fable). The shape is right and it is the skeleton both arms should hang off: pure halves pinned (the XML the scheduler is handed, the drift verdict naming every way, the SDDL read failing closed on a deny, CLIXML unwrapped), one elevation whose child is a one-plan registrar, and the verify is a re-read of the scheduler, never the exit code. The 5090's outage as data in --check is exactly the receipt Joel asked for.

Condition — bind the plan to the elevated child. install_supervisor writes SupervisorPlan to %TEMP% and the elevated child registers whatever that file says: user_sid (the S4U principal — an admin token can register S4U for ANY account, no password), shell/arguments/cli (the commands that run at boot). A same-user process can rewrite the file between the write and the consent (the prompt shows only "continuum.exe"), and the elevated child would register a task running as another account at boot — a local elevation through our own registrar. The fix is small and keeps the standard-user flow intact (there the elevated identity legitimately differs from the plan's principal, so "child SID == plan SID" would be the wrong check): the parent hashes the plan bytes it wrote (SHA-256 from memory, not a re-read) and passes --plan-sha <hex> in the RunAs argument list — argv cannot be altered by another process once spawned — and register_plan re-reads the file and refuses on mismatch before touching schtasks. InstallOptions gains plan_sha paired with --plan; one test: a plan whose bytes changed under the child is refused, the receipt says so.

Nits, not conditions:

Word is yours once the binding lands; Cormac's approve at the same head stands for the rest.

@joelteply

Copy link
Copy Markdown
Contributor Author

Endorsing Fable's condition at eb9d4df: the plan in TEMP is rewritable by any same-user process between the parent's write and the consent, and the elevated child registers whatever it reads — the argv the consent shows is the only thing the user actually approves, so a hash of the plan on that argv, verified by the child, is the right seam. My APPROVE above is subject to it; I read that window as same-user-therefore-fine and that was the wrong frame (the consenting human is not every process running as them).

…was given for — its SHA-256 rides the RunAs argv; a read of the ACL mask as bits

Fable's condition on #4232: the plan in %TEMP% is rewritable by any
same-user process between the parent's write and the consent, and the
elevated child registered whatever it read — a boot task as ANY account,
through our own registrar. The parent now hashes the bytes it WROTE and
passes `--plan-sha` in the RunAs argument list (argv cannot be altered once
spawned); the child re-derives the digest from what it reads and refuses
before touching schtasks. `InstallOptions` pairs `--plan-sha` with `--plan`;
`read_bound_plan` is the one gate, pinned: a rewritten plan (another
principal) is refused with the reason.

Cormac's note: a hex ACE mask is read as BITS (RX = 0x1200a9 contained), so
a pre-existing full-control mask (0x1f01ff) no longer reads as drift and
costs an elevation. The non-Windows message names the macOS arm as #4228.

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

Copy link
Copy Markdown
Contributor Author

Condition met at bcae98f: the parent hashes the plan bytes it WROTE (SHA-256) and passes --plan-sha on the RunAs argv; read_bound_plan re-derives it from the file the child reads and refuses before schtasks on mismatch — pinned by a_plan_rewritten_under_the_elevated_child_is_refused (another principal swapped in under the child → refused with the reason). InstallOptions pairs --plan-sha with --plan (a plan without its digest is unbound). Cormac's note taken: a hex ACE mask is read as bits (0x1f01ff contains RX, 0x120089 does not). Non-Windows message names the macOS arm as #4228. --check on the 5090 at this head still reads the four drifts. Word is yours at the new head.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head bcae98f. The binding is right: the parent hashes the exact bytes it wrote, the digest rides the RunAs argv (the one thing the consent shows), and the child reads the file ONCE, checks the digest and deserializes from those same bytes — no second read between check and use — refusing before schtasks; the swapped-principal test pins it. The mask is read as bits now (0x1f01ff grants, 0x120089 does not). Merge on green. For the fold: my mac arm on #4228 uses the same shape (draft + sha on the sudo argv, verified by the elevated self); I will rename my flag to --plan-sha so the verb has one spelling.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head bcae98f (Fable). Condition met: plan_digest is SHA-256 of the bytes the parent wrote, carried on the RunAs argv as --plan-sha (64 hex, validated at parse), and install_supervisor_elevated re-derives from the file and refuses before schtasks; a_plan_rewritten_under_the_elevated_child_is_refused pins the swapped-principal case. Merge on green.

joelteply added a commit that referenced this pull request Sep 19, 2026
…d bytes — no user-writable file is read after the sudo consent

Fable on #4232, the same window here: the system-domain install wrote a draft plist
under ~/.continuum and then ran `sudo install`/`sudo launchctl bootstrap` on that
path — root copying whatever the file said at that moment. Any same-user process could
rewrite the draft between the write and the consent (UserName, ProgramArguments), and
root would register it: a local escalation through our own registrar. "Same user" was
the wrong frame; the consenting human is not every process wearing their token.

Now the unelevated half hashes the exact bytes it wrote and runs ONE consent:
`sudo <self> install --elevated --plan <draft> --plan-sha <sha256>`. The elevated
half (`launchd::live::register_elevated`, refuses unless euid 0) reads the draft once,
refuses if the digest differs from the argv's ("changed between the consent and this
read; nothing was registered"), refuses a plan naming no artifact, writes the plist
itself under /Library/LaunchDaemons (root:wheel 0644, the constant path — never one
from the plan), boots out the invoking user's agent (SUDO_UID) and any prior daemon,
bootstraps (RunAtLoad starts the core) and enables. The parent then waits for
ownership; it no longer kickstarts a system job (root-only, and not owed after
bootstrap) — kickstart stays for the gui domain, where bootstrap does not start it.
Flag spelling matches #4232 (--plan-sha) so the one verb has one grammar.

Tests: launchd 5/5 (new: the digest moves with any byte; the daemon path is the
constant). Live negative controls on IntelMac: `install --elevated …` typed as the user
→ "runs as root under sudo; it is not a verb to type", exit 1; `--elevated` without its
pair → refused, exit 1. Not covered without sudo: the digest-mismatch refusal on the
root path (unit-tested; unreachable unprivileged by construction).

Follow-up carded, 267dc270: under a system daemon `reboot` still kickstarts (root); the
root-free deploy is a restart exit after the save rail + KeepAlive SuccessfulExit=false.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…ervisor, core, CLI on PATH — each arm reads, changes only what drifted, says so

Joel, 2026-09-19: "Why wouldn't it be like `uu update`" / "Or install" / "You
want users to remember almost nothing." ONE verb, idempotent: on a bare box it
is an install, on a live node an update, run twice it says nothing changed.

- `Arm { Supervisor, Core, Cli }` in run order (a core is handed only to a
  prepared supervisor; the slot's CLI is fresh only after a stage). Bare
  `install` runs every arm; `--supervisor/--core/--cli` restrict; `--check`
  reads only. Each arm returns an `ArmReport { drift_before, drift_after }`;
  the orchestrator sums them and exits non-zero only when drift REMAINS.
- core arm: running build vs the checkout's HEAD (`same_commit`); drifted →
  `reboot --service` (build, stage into the slot, hand off — the same path
  the unattended consumer takes), then re-read the running sha.
- cli arm (`install_cli.rs`): `~/.local/bin/{continuum,uu}.exe` must be the
  slot's CLI byte-for-byte (SHA-256), and the dir on the USER PATH. Missing /
  Stale / NotOnPath named; write = copy with the installer's 10 s contention
  retry (old image moved aside, never deleted under a running process) and a
  user-PATH prepend, then re-read. Both names carry `.exe` so PowerShell and
  cmd resolve `uu`, not only Git bash (the installer's bare `uu` copy). This
  is the stale-CLI seam (#422): the 07:32 CLI on this box could not build for
  a day because nothing refreshed it.

Measured on the 5090, bare `install --check`: 7 ways drifted across 3 arms —
supervisor Interactive + LogonTrigger ×2 tasks, core 40b4126 vs HEAD, CLI
Stale("continuum") + Missing("uu") — the machine's true state in one read.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply joelteply changed the title feat(cli): continuum install --supervisor — the OS supervisor converged from the binary, one elevation, verified by re-reading the scheduler feat(cli): continuum install — one idempotent verb converges the machine (supervisor, core, CLI on PATH); each arm reads, changes only what drifted, says so Sep 19, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Head moved to cab1b5e — scope grew on Joel's direction ("Why wouldn't it be like uu update" / "Or install" / "You want users to remember almost nothing"): bare continuum install is now the whole thing, one idempotent verb.

  • Arm { Supervisor, Core, Cli } run in that order; bare = all, --supervisor/--core/--cli restrict, --check reads only. Each arm returns ArmReport { drift_before, drift_after }; the orchestrator exits non-zero only when drift remains. Twice in a row → "3 arm(s) converged — nothing changed".
  • core arm: running build vs checkout HEAD (same_commit); drifted → reboot --service (the unattended consumer's own path), then re-read the running sha.
  • cli arm (install_cli.rs, pure drift + copy-with-retry pinned): ~/.local/bin/{continuum,uu}.exe byte-equal to the slot's CLI, dir on the user PATH; Missing/Stale/NotOnPath named. Closes the stale-CLI seam that kept this box unable to build for a day.
  • The plan-SHA binding from your condition is unchanged.

Measured, bare install --check on the 5090:

  supervisor: ContinuumCore: LogonType("Interactive")
  supervisor: ContinuumCore: Triggers(["MSFT_TaskLogonTrigger"])
  supervisor: ContinuumDeploy: LogonType("Interactive")
  supervisor: ContinuumDeploy: Action
  core: running build 40b41260f, HEAD is bcae98fb0
  cli: Stale("continuum")
  cli: Missing("uu")
continuum: install --check: 7 way(s) drifted across 3 arm(s); `continuum install` converges them

Cormac: the mac arm (#4228) hangs off the same Arm enum + read/write split. Word at the new head, please.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE — reviewed at exact head 10f5ee2. The one-verb shape is what Joel asked for and it is clean to plug into: Arm + ArmReport { drift_before, drift_after } per arm, runs(arm) so bare install is all three and a named flag is one, the orchestrator sums drift and exits non-zero only on what remains, --check is the read half everywhere. The core arm reuses reboot --service (one handoff path, the consumer's) and verifies by re-reading the running sha against HEAD; the CLI arm hashes the slot against each PATH copy, moves a live exe aside rather than over it, and touches only the USER PATH. The 5090 receipt (7 drifts across 3 arms in one read) is the right proof that the read half sees what the hand-jacked box actually is. Merge on green; I fold the mac arm behind cfg(target_os = "macos") into the same install() — Supervisor read = the supervision verdict + plist drift, write = the hash-bound elevated register — and will say the head so the word carries.

@joelteply
joelteply merged commit 6c844fd into canary Sep 19, 2026
6 checks passed
@joelteply
joelteply deleted the feat/continuum-install-supervisor branch September 19, 2026 18:42
joelteply added a commit that referenced this pull request Sep 19, 2026
-#4235) — textual resolution only; the two install verbs are reconciled in the next commit
joelteply added a commit that referenced this pull request Sep 19, 2026
…ntinuum install` (Joel: users remember almost nothing)

#4232 made `install` one verb with arms that read, change only what drifted, and say
so. This folds the mac arm (a1bd8b58) into that shape instead of a verb beside it:

- `launchd::mac_drift` — the READ half, pure: Absent / Domain{have,want} /
  WrapperCommand (the script's bash -lc plist) / KillsLanes (no AbandonProcessGroup)
  / NotOwned{job_pid,core_pid} / CannotHeal (agent on an on-demand-only gui domain).
  Test: a rendered daemon plist with the job owning the socket's pid reads as
  NOTHING (twice = nothing changed); the script-installed agent read against the
  daemon contract names four drifts at once; an agent beside an orphan names the pid.
- `install_supervisor_macos(check, user) -> ArmReport` — the WRITE half is the
  existing register + hand-off (save-rail stop, hash-bound elevated register for the
  daemon, kickstart for the agent, `wait_owned` refusing an unowned core), gated on
  drift; then the read runs again and the report is what remains.
- `InstallOptions` gains `--user` (macOS: the agent instead of the daemon — the
  explicit other choice; refused on Windows). `--no-start` is gone: the core arm
  decides the hand-off. The old macOS-only `InstallOptions`/`install` are removed.
- `install_core` runs on macOS too: `reboot` there implies the supervisor when a
  launchd job exists, so `service: cfg!(windows)`.
- The CLI arm on macOS is declared owed (the slot carries no CLI descriptor on this
  OS): `--cli` refuses by name; bare `install` says "skipped, not counted" — never a
  converged it did not read.
- `finish_install` is the one verdict for both platforms.

Receipts on IntelMac (debug CLI of this branch, core b667436, agent registered):
  `install --check`            → supervisor: Domain{have: Gui(501), want: System};
                                 core: running b667436, HEAD 7c119a0 → "2 way(s)
                                 drifted across 2 arm(s)", exit 1
  `install --user --check`     → supervisor converged; core drifted → 1 way, exit 1
  `install --user --supervisor`→ "✓ install: 1 arm(s) converged — nothing changed",
                                 exit 0 (the idempotent write on a converged arm)
Tests: launchd 7/7 + the skeleton's 7 on macOS, REAL_EXIT 0.

Noted for #4232's file, not changed here: its Windows-only pure helpers (CLI_NAMES,
cli_dir, plan_digest, same_path, …) warn dead on macOS now that the verb compiles
here — 14 warnings that belong with the skeleton (cfg_attr on the Windows-only
items, or a `windows` submodule).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply added a commit that referenced this pull request Sep 19, 2026
…ters it in our own binary (card a1bd8b58, audit #4223 row D-mac) (#4228)

* feat(cli): macOS — launchd owns the launch; `continuum install` registers it in our own binary (card a1bd8b58, audit #4223 row D-mac)

Measured 2026-09-19 on IntelMac: the core ran as ppid 1 with NO launchd job — an
orphan of start-server.sh, dark on the first crash. Installing the LaunchAgent did
not close it: `continuum reboot` stopped the core (clean exit, KeepAlive{Crashed}
stays down) and SPAWNED a new one outside launchd. Registration is not supervision.

What is true now (bin/continuum/launchd.rs, new):
- when a launchd job for the core exists, `start`/`reboot` do not spawn: they STAGE
  the artifact into the slot the plist execs (rename-aside, copy, sha re-read) and
  `launchctl kickstart -k` the job, then `wait_owned` refuses the receipt unless
  launchd's pid for the job IS the pid serving the socket. CONTINUUM_FROM_SOURCE
  opts out; explicit `--service` is accepted on macOS (the parse-time refusal named
  Windows only).
- `continuum supervisor-status [--crash-test]`: the verdict as a verb — UNSUPERVISED /
  ORPHANED / OWNED-CANNOT-HEAL / SUPERVISED (structurally); `--crash-test` is kill -9
  and a 60 s heal receipt, refused on any core launchd does not own.
- `continuum install [--user] [--no-start]` / `continuum uninstall` (Joel: "it needs
  to be in our own binary"): the mac arm of the one verb. Writes the plist with the
  BINARY as the command (no bash -lc wrapper — audit item 7); the launch environment
  is launchd's own EnvironmentVariables dict computed by the same code a direct
  launch uses (config.env, ORT, runtime library dirs) plus the operator's PATH.
  Default is the system LaunchDaemon (sudo, once — the consent macOS requires, the
  same class as the 5090's UAC, card 7b56a84b); `--user` is the agent, accepted and
  PROVEN before success. Stops any core on the socket through the save rail first,
  kickstarts, and refuses an unowned core. The dispatch line is a placeholder for the
  verb skeleton's platform trait (BigMama) — a one-line fold when it lands.

Receipts on IntelMac (debug build of this branch, core 1a2865c):
- supervisor-status: the first live run read ORPHANED because core_pid came from the
  CLI's `<socket>.pid` file, which a launchd-launched core never writes. The socket's
  holder (pgrep on the exact argv) is the truth; re-run: SUPERVISED (structurally),
  job_pid == core_pid == 96595.
- install --user: 54 s end to end — stopped 96595 through the rail, wrote the
  binary-form plist, bootstrapped gui/501, kickstarted, core 45292 up and owned. Then
  supervisor-status read OWNED, CANNOT HEAL: launchd logged "pending spawn, domain in
  on-demand-only mode" at bootstrap — on this Mac the user agent cannot heal, exactly
  the measurement that makes the daemon the default. The system arm needs one sudo.
- 4 unit tests (bin continuum, launchd::tests): slot read from both plist forms, job
  pid from launchctl print, the four verdicts + daemon-outranks-agent, and the
  rendered plist round-trips its slot through slot_from_plist with the binary as the
  command and the operator as UserName. REAL_EXIT 0.

Found by the receipt, fixed here: install's stop line said "outside launchd" of a
core the job owned — the job's pid is read first now and the line says which.
Noted, not fixed (rail, not this lane): that stop reported 1 of 63 modules unsaved
(cognition drain Incomplete { in_flight: 6 }); like reboot, install prints it and
continues.

Not in this PR: the install-service.sh acceptance I had drafted — the shell shrinks
to bootstrap under the converge, it does not grow.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(cli,core): the supervised launch keeps its lanes, its config.env and its wake — three things the M5 would have paid for (#4228 review)

Fable's review of b667436, each proven live on IntelMac before the fix and after:

1. AbandonProcessGroup. The lanes (llama-server) share the core's process group,
   and launchd's default on a job exit is to SIGKILL the rest of the group — every
   kickstart and every heal a cold model load, adoption dead. Measured: lane 51552 in
   pgid 45292 (the core). The plist now carries <AbandonProcessGroup/>true, asserted in
   the round-trip test. Receipt, the contrast pair from the lane-registry sweep:
     16:42Z first transition, OLD plist: RemovedDead { pid: 51552 }
     16:43Z kickstart -k, NEW plist:     LeftLive { pid: 10017 } — the new core serves
     on it, ready=true, the lane pid unchanged across the restart.

2. config.env is the core's to apply, not the launcher's. The direct path re-applied
   it to the child every start; the plist froze it into EnvironmentVariables at
   install, so "edit, reboot" ran the old values under launchd until a re-install.
   Now `config_env::apply_to_process()` runs first thing in a sync `main`, before the
   tokio runtime exists (set_var must not race a reader — the one place that holds),
   and the plist carries only PATH and the runtime library env. Unit test: a key in
   the file and absent from the launcher env reaches the process, last assignment
   wins. Receipt: service.err.log "applied 2 assignment(s)" → append a key →
   kickstart → "applied 3" — no install between.

3. No caffeinate under launchd. start-server.sh wraps the core in `caffeinate -s -i`
   (card 94a95a98: the M5 slept while hosting); the binary-as-command plist dropped
   it. The core holds the same pair itself now — IOKit PreventSystemSleep +
   PreventUserIdleSystemSleep for its lifetime (`system_resources/power_assertion.rs`,
   macOS only, one call, no task; probes power.assertion.held/refused). Receipt:
   `pmset -g assertions` lists both under pid 9633(continuum-core-server); the
   script's wrapper is now redundant and can go with Kimi's script lane.

4. serving_core_pid anchored: `^([^ ]*/)?continuum-core-server <socket>$` with the
   socket regex-escaped, so a caffeinate parent on a script-path node no longer
   answers first.

Also from the live run: install's stop line said "outside launchd" of a core the job
owned — it reads the job's pid first now and says which; install names the artifact it
registered (the slot's own binary, or the one it staged — `resolve_core_artifact`
prefers the slot, so a new build reaches it through `reboot` or CONTINUUM_CORE_BIN);
`reboot --service` typed explicitly on macOS no longer refuses at parse.

Tests: launchd 4/4, config_env 1/1, REAL_EXIT 0; cargo check lib + both bins clean in
the touched files. Canary 7b69109 merged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(cli): the system install's elevated half is bound to the consented bytes — no user-writable file is read after the sudo consent

Fable on #4232, the same window here: the system-domain install wrote a draft plist
under ~/.continuum and then ran `sudo install`/`sudo launchctl bootstrap` on that
path — root copying whatever the file said at that moment. Any same-user process could
rewrite the draft between the write and the consent (UserName, ProgramArguments), and
root would register it: a local escalation through our own registrar. "Same user" was
the wrong frame; the consenting human is not every process wearing their token.

Now the unelevated half hashes the exact bytes it wrote and runs ONE consent:
`sudo <self> install --elevated --plan <draft> --plan-sha <sha256>`. The elevated
half (`launchd::live::register_elevated`, refuses unless euid 0) reads the draft once,
refuses if the digest differs from the argv's ("changed between the consent and this
read; nothing was registered"), refuses a plan naming no artifact, writes the plist
itself under /Library/LaunchDaemons (root:wheel 0644, the constant path — never one
from the plan), boots out the invoking user's agent (SUDO_UID) and any prior daemon,
bootstraps (RunAtLoad starts the core) and enables. The parent then waits for
ownership; it no longer kickstarts a system job (root-only, and not owed after
bootstrap) — kickstart stays for the gui domain, where bootstrap does not start it.
Flag spelling matches #4232 (--plan-sha) so the one verb has one grammar.

Tests: launchd 5/5 (new: the digest moves with any byte; the daemon path is the
constant). Live negative controls on IntelMac: `install --elevated …` typed as the user
→ "runs as root under sudo; it is not a verb to type", exit 1; `--elevated` without its
pair → refused, exit 1. Not covered without sudo: the digest-mismatch refusal on the
root path (unit-tested; unreachable unprivileged by construction).

Follow-up carded, 267dc270: under a system daemon `reboot` still kickstarts (root); the
root-free deploy is a restart exit after the save rail + KeepAlive SuccessfulExit=false.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* feat(cli): the macOS supervisor arm plugs into the one idempotent `continuum install` (Joel: users remember almost nothing)

#4232 made `install` one verb with arms that read, change only what drifted, and say
so. This folds the mac arm (a1bd8b58) into that shape instead of a verb beside it:

- `launchd::mac_drift` — the READ half, pure: Absent / Domain{have,want} /
  WrapperCommand (the script's bash -lc plist) / KillsLanes (no AbandonProcessGroup)
  / NotOwned{job_pid,core_pid} / CannotHeal (agent on an on-demand-only gui domain).
  Test: a rendered daemon plist with the job owning the socket's pid reads as
  NOTHING (twice = nothing changed); the script-installed agent read against the
  daemon contract names four drifts at once; an agent beside an orphan names the pid.
- `install_supervisor_macos(check, user) -> ArmReport` — the WRITE half is the
  existing register + hand-off (save-rail stop, hash-bound elevated register for the
  daemon, kickstart for the agent, `wait_owned` refusing an unowned core), gated on
  drift; then the read runs again and the report is what remains.
- `InstallOptions` gains `--user` (macOS: the agent instead of the daemon — the
  explicit other choice; refused on Windows). `--no-start` is gone: the core arm
  decides the hand-off. The old macOS-only `InstallOptions`/`install` are removed.
- `install_core` runs on macOS too: `reboot` there implies the supervisor when a
  launchd job exists, so `service: cfg!(windows)`.
- The CLI arm on macOS is declared owed (the slot carries no CLI descriptor on this
  OS): `--cli` refuses by name; bare `install` says "skipped, not counted" — never a
  converged it did not read.
- `finish_install` is the one verdict for both platforms.

Receipts on IntelMac (debug CLI of this branch, core b667436, agent registered):
  `install --check`            → supervisor: Domain{have: Gui(501), want: System};
                                 core: running b667436, HEAD 7c119a0 → "2 way(s)
                                 drifted across 2 arm(s)", exit 1
  `install --user --check`     → supervisor converged; core drifted → 1 way, exit 1
  `install --user --supervisor`→ "✓ install: 1 arm(s) converged — nothing changed",
                                 exit 0 (the idempotent write on a converged arm)
Tests: launchd 7/7 + the skeleton's 7 on macOS, REAL_EXIT 0.

Noted for #4232's file, not changed here: its Windows-only pure helpers (CLI_NAMES,
cli_dir, plan_digest, same_path, …) warn dead on macOS now that the verb compiles
here — 14 warnings that belong with the skeleton (cfg_attr on the Windows-only
items, or a `windows` submodule).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

* fix(hygiene): the two ratchets CI caught at b1e544e — two unwrap_or lines justified, SupervisionVerdict named at its use site

CI (cargo test --lib) at the previous head: unjustified unwraps rose 2264 → 2266 and
unwired public machinery rose 107 → 108. Both mine:

- `slot_from_plist`'s `strip_prefix('\\').unwrap_or(rest)` and
  `config_env::apply_to_process`'s `.unwrap_or(0)` had no same-line reason. They do
  now (no backslash = an unescaped quote, the same slice; no home dir = no file =
  zero assignments, the honest count).
- `SupervisionVerdict` read as constructed nowhere outside its file because I had
  removed the one `use` that named it (an unused-import warning) and the call site
  bound `supervision_verdict(...)` without the type. The scan is right that a `use`
  is not a use; the binding is now annotated `launchd::SupervisionVerdict`, which is
  the production mention the type actually has.

Both ratchets green locally (6 passed in source_hygiene), bin check clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant