Ledger · instance-stop-528
<task-notification> <task-id>aa4f6b09d00fff073</task-id> <tool-use-id>toolu_01AQC7EUhmPePbjk5h2UqhRu</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/57f7b202-ce27-4792-9462-b99ef5f502c4/tasks/aa4f6b09d00fff073.output</output-file> <status>completed</status> <summary>Agent "Fix 2: #528 PrivatePIDs stop" is waiting on its own background work</summary> <note>This agent stopped with background work of its own still running. It may resume on its own when that work completes or reports, and the same task-id notifies again if it does; the result below may be interim.</note> <result>Fix 2 (#528) is not merged. I stopped under stopping rule 2 and need your ruling. The cause is found and fixed on the branch, and the real-box witness passes. Astra's second round raised a new P1 that it says belongs to the same fault family as its first, which is the point where the brief says to escalate rather than decide. **Root cause.** - With `PrivatePIDs=yes`, systemd 257 forks once more, and the parent sends the child's PID to the manager and exits. If the manager checks the PID before that parent has exited, it marks the main process "not our child" (alien). - At stop, `unit_kill_context_one()` returns 0 for an alien main. `KillMode=mixed` signals nothing else in the SIGTERM phase, so `service_enter_signal()` goes straight to SIGKILL. The app gets no grace and the unit ends `Result=signal`. - Checked in the systemd v257.9 source; upstream `main` still has this code. - Journal evidence, matching each stop result to its own start: every `signal` failure was an alien start. Demo box: 17 of 17 failures alien, 27 of 27 non-alien stops clean. sophie's generation units: 73 of 73 failures alien, 259 of 259 non-alien stops clean. **Fix on branch `instance-stop-528`** (tip `4f7a8d207234f8b6818e8e2f83f2d42d228085db`, origin/main `f4d9b095` merged in): - `KillMode=control-group` on the 11 tenant templates and `claimBoundTemplate`. systemd now signals the app directly as well, so it always has a process to wait on. - `Environment=CARLOS_INIT_STOP=cgroup` in those templates, so the trampoline doesn't forward a second SIGTERM. Astra R1 found that a double SIGTERM is a real P1: a Go app using `NotifyContext` can die mid-drain on the second. - A claims-on generation's `Retire` now sends `instancectl.RetireSignal` (SIGPWR), which the trampoline turns into one SIGTERM. - An invariant test refuses any other `KillMode` beside `PrivatePIDs=yes`, and requires the env line wherever the trampoline runs. - New unit tests cover the trampoline and the `Retire` signal. **Witness.** `TestRootInstanceStopUnderPrivatePIDs` on the root runner, run 20261108T160744-e76dbf: PASS. - With the old template restored, the race reproduces: 3 of 40 starts alien, 3 of 40 stops `Result=signal`. - With the shipped template, 40 draining stops and 40 fast-exit stops are all `Result=success`, exit 0, with exactly one SIGTERM each, alien starts included. - A retire signal drains the app on one SIGTERM. - An app that ignores SIGTERM is killed at 3.3 s with `TimeoutStopSec=3`, and every cgroup is gone or empty after its stop. - No runner instances were left running. **Reviews and census.** - Astra R1: NOT READY; its P1s and P2s are fixed. - Astra R2: NOT READY, with one new P1 and one P2: - **P1, version mixing during a roll or rollback.** An old trampoline under the new unit gives the app two SIGTERMs. A new trampoline under a rolled-back `mixed` unit gives it no SIGTERM, so it is SIGKILLed after 20 s. Astra recommends refusing up front: gate the install and the rollback until running instances have stopped under their original policy. - **P2.** The witness should require at least one alien fast-exit start. That is a one-line fix I haven't made yet. - Census: `make census-propose NAME=instance-stop-528` was re-run on the merged tree; the seal now chains after instance-syscall-filter's. Astra's cross-family verdict is APPROVE for all 12 units and all 5 envelopes, recorded on #280 for this tip. Any later tip needs a fresh census-propose and a new verdict. - CI was still running on `4f7a8d20` when I stopped. **Your data point.** It matches the code and changes nothing here: an app run as PID 1 under PrivatePIDs drops SIGTERM, which is why the templates run the trampoline as PID 1. That is a separate issue from the alien race. **What I need from you.** A ruling on the R2 P1: gate the roll as Astra suggests, accept the brief double or missing SIGTERM while a roll or rollback is in progress, or another approach. After that I'll fix the P2, re-run census-propose, do Astra R3 (the last allowed round), wait for green CI and squash-merge. There is no merged SHA yet to pass to 8a3d302. **Recorded and kept.** The root cause and status are on #528. The branch handoff and tasks 666–669 are on [instance-stop-528](https://amadan.net/carlos/platform/-/branch/instance-stop-528). Review outputs and runner logs are in `~/.cache/tmp/f528/` until the branch lands. **Commits on the branch:** - `e2e06843`: templates and invariant test - `ce423ca0`: witness - `17917e6d`: witness fixes - `a5a05cb5`: merge of origin/main - `5771a1ca`: census proposal - `4f7a8d20`: single SIGTERM and the retire signal</result> <usage><subagent_tokens>368828</subagent_tokens><tool_uses>144</tool_uses><duration_ms>5031046</duration_ms></usage> </task-notification>
<task-notification> <task-id>aa4f6b09d00fff073</task-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/57f7b202-ce27-4792-9462-b99ef5f502c4/tasks/aa4f6b09d00fff073.output</output-file> <status>completed</status> <summary>Agent "Fix 2: #528 PrivatePIDs stop" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>That notice is about an old wait loop I'd started for Astra's first review. It hit its time limit after the review had already finished, so nothing was lost and it doesn't need restarting. My report above still stands: Fix 2 is not merged and is waiting on your ruling about the roll/rollback P1.</result> <usage><subagent_tokens>367538</subagent_tokens><tool_uses>144</tool_uses><duration_ms>5177304</duration_ms></usage> </task-notification>
Check the Fix 2 fork (branch instance-stop-528, worktree .claude/worktrees/instance-stop-528); when it reports a merged SHA, verify it on origin/main, send it to 8a3d302 (paseo send 8a3d302a-eac7-407c-b61c-f5ccc66b5544) and report to 55f1f6a; continue the brief ~/.cache/start-hardening/BRIEF.md.
<task-notification> <task-id>aa4f6b09d00fff073</task-id> <tool-use-id>toolu_014To2FB414Ys8eDtqpjtmCz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/57f7b202-ce27-4792-9462-b99ef5f502c4/tasks/aa4f6b09d00fff073.output</output-file> <status>completed</status> <summary>Agent "Fix 2: #528 PrivatePIDs stop" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I fixed both and pushed. The new tip is `eb0e15281b33a505ad4d6053d7c47b14c72511ee`; CI is queued on it. I haven't merged or started R3. - **9B8 re-pin:** I updated only the `claimBoundTemplate` row in `internal/provision/plan14_e_write_census_test.go`. Its digest moves from `9ff0f840…` to `f27e8b84…`; the row's kinds (`lit:instances`) are unchanged. I computed the new value the way `plan9_b8_census_test.go:189` does: sha256 of the whole `const claimBoundTemplate` declaration. The same calculation on origin/main gives the old pinned `9ff0f840…`, so the method matches the test. Locally, `TestPlan9B8RecordWriteCensus` and `TestPlan14RootReadCensus` both pass. - **R2 P2:** the witness now fails if none of the 40 fast-exit cycles had an alien start. That is a test-only change, so I didn't re-run the root runner; the last run (20261108T160744-e76dbf) had 4 of 40 fast-exit starts alien, so it would have passed. I've noted both items for the R3 brief in `~/.cache/tmp/f528/R3-NOTES.md`, including asking Astra to review the re-pin and citing 7d0f26c as the precedent. I'll start R3 once you relay 55f1f6a's ruling on the roll-mixing P1. If that fix touches the templates or the envelopes again, I'll re-run census-propose first.</result> <usage><subagent_tokens>374375</subagent_tokens><tool_uses>6</tool_uses><duration_ms>86179</duration_ms></usage> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="55f1f6a4-252a-4d89-af7b-a8a460b2b81d" message-id="e77693ce-a608-40b7-a96e-ebd9137b997b"> Coordinator 55f1f6a: Paul RULED (A) refuse up front for #528: the new stop policy (unit install and rollback) only takes effect for an instance after it has stopped under the policy it started with; running instances never see a mixed old/new trampoline and unit. Fix the P2 (witness requires an alien fast-exit start), re-run census-propose, Astra R3 (the last allowed; brief it with rounds 1-2 and Paul's ruling), green CI, squash-merge, then give 8a3d302 the SHA for v0.34.29. If R3 finds another P1 in the same family, stop and report to me rather than fixing. </paseo-system>
Check the Fix 2 fork (branch instance-stop-528, worktree .claude/worktrees/instance-stop-528); when it reports a merged SHA, verify it on origin/main, send it to 8a3d302 (paseo send 8a3d302a-eac7-407c-b61c-f5ccc66b5544) and report to 55f1f6a; continue the brief ~/.cache/start-hardening/BRIEF.md.
<task-notification> <task-id>aa4f6b09d00fff073</task-id> <tool-use-id>toolu_01MgCNvmnAr7QQQ5wLMCUodR</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/57f7b202-ce27-4792-9462-b99ef5f502c4/tasks/aa4f6b09d00fff073.output</output-file> <status>completed</status> <summary>Agent "Fix 2: #528 PrivatePIDs stop" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I stopped without merging. Astra R3 (the last round allowed) came back NOT READY, with five P1s in the same fault family as R1/R2, so per your instruction I fixed none of them. There's no merged SHA. The tip is `754b1e832673a6ebbcbe1af91f81f76bdba06ce1` (origin/main `3933abe8` merged in). CI failed on it; I couldn't pull the log from the CLI, so I haven't looked at the cause: [https://amadan.net/carlos/platform/-/ci/754b1e832673a6ebbcbe1af91f81f76bdba06ce1](https://amadan.net/carlos/platform/-/ci/754b1e832673a6ebbcbe1af91f81f76bdba06ce1). **What I built for ruling A, test-first:** - **Pins:** before the reload that loads new templates, the installer pins each running `carlos-instance*@` unit whose template's stop policy is about to change. The pin is a runtime drop-in, `99-carlos-stop-pin.conf`, holding the policy the unit is running under. This runs in `installUnits`, which apply and rollback both use, and in a live bootstrap. - **Clearing:** instance-control's systemctl removes a unit's pin and reloads just before it next starts that unit. - **One window:** an exclusive lock covers the binary swap through to the reload, and each start takes it shared. - **Witness:** I re-ran it with a new phase that checks the gate on real systemd. Run 20261108T171416-57ae01 passed. A running unit kept `mixed` across the reload and got one SIGTERM; its next start cleared the pin and stopped cleanly under `control-group`. **Census:** I re-ran census-propose and got Astra's cross-family verdict, recorded on #280 for `754b1e83`. Every row and envelope is approved (19 unit rows, including the new `pinStopPoliciesOf` and `LockStopPolicy`, and 5 envelopes). The two 9B8 re-digests (`claimBoundTemplate` and `bootstrapWithGroup`) and the removal-guard allowance are approved too. **R3 P1s in the same fault family:** - **First upgrade and recovery skip the gate.** A self-update runs the *installed* updater, so the step that installs the new templates runs pre-#528 code with no pins. Recovery can run a pre-#528 `carlos.prev`. And `update-platform-binary.sh` in both infra repos copies the units and reloads them directly, bypassing bootstrap. - **Another reload can get in first.** instance-control's `daemon-reload` during a generation start isn't covered by the lock. It can land after the templates are rewritten but before the pins exist, and the installer then sees no change and skips the pin. - **Some starts and restarts bypass the shared lock.** - **Rollback leaves pins nobody clears.** The restored, older instance-control doesn't know to remove them. - **A repeated start of a running unit clears its pin** while the old invocation keeps running. **R3 findings outside that family:** - **P1:** instance-control can't open the new lock. It runs with `ProtectSystem=strict`, and `/opt/carlos/system/stop-policy.lock` isn't on its writable paths, so every start and readiness probe would fail with EROFS. This alone means the tip must not ship. It's small to fix, but I left it because the branch can't merge anyway. - **P2:** the gate phase in the witness calls the pin helper directly. It doesn't exercise a real install or rollback, either direction of an old/new binary transition, or the races above. **My read:** ruling A can't be met from the installer side alone. On the first transition, the code doing the install is the old build. It needs a different transition design, for example a build that ships the gate first with no policy change, followed later by the policy change. That is a call for you and Paul, and another review round needs Paul's authorization. The root cause, the steady-state fix, and the census approvals all still stand. Everything is recorded on the [branch page](https://amadan.net/carlos/platform/-/branch/instance-stop-528): the handoff and task 669 show where it stopped. The R1–R3 review outputs and runner logs rr1–rr8 are in `~/.cache/tmp/f528/`.</result> <usage><subagent_tokens>466488</subagent_tokens><tool_uses>61</tool_uses><duration_ms>2873901</duration_ms></usage> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="55f1f6a4-252a-4d89-af7b-a8a460b2b81d" message-id="4ced53b5-6628-4cbd-a055-4913f17f2834"> Coordinator 55f1f6a: Paul RULED (2) and authorised a FRESH Astra review series for it: build the mix-safe fix on a new branch (ExecStop as root sends one SIGTERM to MAINPID and waits within the stop budget; KillMode=mixed and the trampoline unchanged; no pins, locks or rollback state). Design note first (short spec with the full old/new mix matrix and why each cell gets exactly one SIGTERM or today's behaviour), Astra spec review, then build, root-runner witness (alien fast-exit start required; old/new mixes covered), census, branch review (max 3 rounds, stopping rule 2 still applies: escalate to me), green CI, squash-merge, SHA to 8a3d302. The /start demo window WAITS for v0.34.29 with both fixes (Paul keeps 'fix first'). Close or park branch instance-stop-528 with a note on #528 pointing at the new branch; don't merge it. </paseo-system>
<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="8fedfe3f-309f-4dcb-804d-b433c6e33345"> Agent manager 8a3d302: renumbering. v0.34.29 went to a dev-console-only release (claim page fixes, Paul approved). The combined #528 + syscall filter release with the flagship edge roll and demo window is now v0.34.30, same plan. </paseo-system>
<task-notification> <task-id>aa4f6b09d00fff073</task-id> <tool-use-id>toolu_014EczR4Y6qwkXfWS3hzG1Cz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/57f7b202-ce27-4792-9462-b99ef5f502c4/tasks/aa4f6b09d00fff073.output</output-file> <status>completed</status> <summary>Agent "Fix 2: #528 PrivatePIDs stop" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>The #528 fix is merged to main as `fe8df2156fadb82bb1a407235a2b1f36e6726455` (Paul's option 2). It isn't released yet and rides v0.34.30. **What it does:** the instance run, generation and sidecar templates, plus the claim-bound template, gain a root `ExecStop` that runs a new `carlos instance-stop $MAINPID` verb. That verb sends the main process one SIGTERM (and a SIGCONT) through a pidfd, waits up to 18 s, then sends SIGKILL. The templates also gain `TimeoutStopFailureMode=kill`, so a stop that runs past 20 s ends in SIGKILL, never a second SIGTERM. `KillMode=mixed` and the trampoline are unchanged. There are no pins, locks or rollback state. **What settled the traps:** a probe on the root runner (run 20261108T174833-c5142a) showed: - A `+` ExecStop runs as root in the host PID namespace, so `$MAINPID` names the right process. - It sits in the unit's own cgroup. - The tenant syscall filter does not apply to it (`Seccomp: 0`). - `RuntimeMaxSec=` expiry runs the ExecStop. - An older binary answers the unknown verb with exit 2, and the `-` prefix ignores that, so the stop falls back to today's behaviour. The helper only signals a process in the unit's own cgroup, so a reused PID can't reach a stranger. **Witness:** `TestRootInstanceStopExecStop` passed at the merged tip (run 20261108T183451-994df0), using real `carlos` binaries built from the branch and from origin/main: | Case | Result | | --- | --- | | Old unit, new binary | the bug reproduces: 6 of 40 alien starts ended `Result=signal` | | New unit and binary, draining app | 40 of 40 clean, one SIGTERM each, 9 alien starts | | New unit and binary, fast-exit app | 40 of 40 clean, one SIGTERM each, 9 alien starts | | App ignores SIGTERM | one SIGTERM, SIGKILL at 18.1 s | | New unit, old binary | today's behaviour, never two SIGTERMs | | Roll under running instances (old trampoline started, new unit at stop) | clean, one SIGTERM each | | Rollback under running instances | today's behaviour | | `RuntimeMaxSec=` expiry, stopped (SIGSTOP) main, app exits by itself | all as designed | | systemd's timer fires before the helper signals | SIGKILL, no SIGTERM | | systemd's timer fires after the helper's SIGTERM | exactly one SIGTERM, then SIGKILL | Every case also checked the final unit result, the exit record and that the cgroup was empty. No runner instances are left running. **Reviews and census:** - Spec review R1 and R2 were NOT READY. Their findings are fixed: the manager-timeout second SIGTERM, missing stop paths, SIGCONT, `instance-stop` dispatch in the root-runner test binary, and the `cli.md` heading. - Branch review R1 came back READY, with two P2s that are now applied. No P1 recurred, so stopping rule 2 never applied. - Astra's cross-family census verdict approves all 5 units, 4 envelopes and two 9B8 re-digests (`main.go:main` and `claimBoundTemplate`); it's recorded on #280. - CI passed on the exact tip, and I re-checked origin/main before merging. **Still open:** - The new `carlos instance-stop` entry in `docs/site/cli.md` is three plain sentences of user-facing copy that hasn't been through copy review. It's merged as written; Paul may want to look at it. - The rootfs templates and stopping a oneshot while it runs are out of scope. They keep today's behaviour and are noted on #528 as follow-ups. `instance-stop-528` is parked unmerged, with a handoff saying it is superseded and a reply on #528 naming Paul's option (2). I removed the merged branch's worktree. The parked branch's worktree stays, and the review outputs and runner logs are in `~/.cache/tmp/f528` and `~/.cache/tmp/f528x`.</result> <usage><subagent_tokens>584783</subagent_tokens><tool_uses>69</tool_uses><duration_ms>3557188</duration_ms></usage> </task-notification>