pi-crew 0.11.38 → 0.11.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/index.mjs +522 -518
- package/package.json +2 -2
- package/skills/real-test-pi-crew/SKILL.md +9 -1
- package/src/config/env-allowlist-registry.ts +14 -1
- package/src/config/env-vars.ts +12 -0
- package/src/extension/registration/lifecycle-handlers.ts +12 -0
- package/src/extension/team-tool/doctor.ts +125 -1
- package/src/runtime/child-pi/child-pi-kill.ts +68 -2
- package/src/runtime/child-pi/child-pi-spawn.ts +4 -0
- package/src/runtime/heartbeat/worker-heartbeat.ts +4 -0
- package/src/runtime/process/orphan-reaper.ts +197 -22
- package/src/runtime/process/proc-stat.ts +8 -0
- package/src/runtime/process/reap-group.ts +499 -0
- package/src/runtime/process/run-descendant-sweep.ts +744 -0
- package/src/runtime/recovery/crash-recovery.ts +202 -0
- package/src/runtime/rpc/frame-client.ts +21 -1
- package/src/runtime/stale-reconciler.ts +343 -2
- package/src/runtime/task-runner/child-executor.ts +12 -1
- package/src/runtime/task-runner/state-helpers.ts +28 -1
- package/src/state/stores/state-store.ts +8 -0
- package/src/state/types.ts +42 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.11.39] — fix wave 11: worker descendant reaping (2026-10-24)
|
|
6
|
+
|
|
7
|
+
Closes the leak that motivated the wave: run `team_20261022110510_cefb9164af126460` reached `completed` on
|
|
8
|
+
2026-10-22 and six grandchild processes (`dpi-backend` ×5 + `caddy`, ~390 MB RSS) were still alive 24 h later.
|
|
9
|
+
Root cause (SPEC `fixwave11-worker-reaping-2026-10-24` GAP-0): pi's bash tool spawns EVERY command with
|
|
10
|
+
`detached: true`, so a worker's bash grandchildren own a process group that a group kill rooted at the worker can
|
|
11
|
+
never reach.
|
|
12
|
+
|
|
13
|
+
**11a — identity-proven group kill (F1–F4).**
|
|
14
|
+
|
|
15
|
+
- `src/runtime/process/reap-group.ts` is now the ONE place that may signal a process group: a refusal ladder
|
|
16
|
+
(POSIX only, `pgid > 1`, never our own real pgrp, live-identity-or-leader-proof, same uid, member of the requested
|
|
17
|
+
group, starttime present + matching) plus a bounded SIGTERM → SIGKILL escalation. SIGTERM is delivered
|
|
18
|
+
synchronously; the SIGKILL rung is handed back as `pending` and owned by `drainReapEscalations()`
|
|
19
|
+
(stale reconciler) or `flushReapEscalationsSync()` (shutdown), never dropped.
|
|
20
|
+
- `child-pi-kill.ts` (F1): an exited ROOT no longer means "nothing left" — when the snapshot proves the root led its
|
|
21
|
+
own group, the group is reaped.
|
|
22
|
+
- `orphan-reaper.ts` (F2): recorded workers are reaped through the guarded group ladder when a pgid is known,
|
|
23
|
+
identity-proven candidates bypass the zombie-scan gate, and a scanner throw is now fail-open for proven candidates
|
|
24
|
+
instead of a blanket no-op.
|
|
25
|
+
- `state/types.ts` + `child-executor.ts` (F3): `pgid`/`starttime`/`uid` are persisted on the checkpoint and worker
|
|
26
|
+
heartbeat (all optional — old records load unchanged), which is what makes identity proof real on the next run.
|
|
27
|
+
- `frame-client.ts` (F4): the prototype RPC frame client spawns detached. The production RPC path uses the SDK
|
|
28
|
+
`RpcClient`, which exposes no spawn knob — those workers stay non-leaders.
|
|
29
|
+
|
|
30
|
+
**11b — run-scoped descendant sweep (F7, the actual cure for GAP-0).**
|
|
31
|
+
|
|
32
|
+
- New `src/runtime/process/run-descendant-sweep.ts`: `collectRunDescendants()` / `reapRunDescendants()` enumerate
|
|
33
|
+
`/proc`, match the pi-crew env markers a descendant INHERITED, and reap only through a group that can be proven.
|
|
34
|
+
Markers used (verified in src, none invented): `PI_CREW_BROKER_RUN_ID` (`child-pi-spawn.ts:382`) ⇒ `run-id`;
|
|
35
|
+
`PI_CREW_KIND=subagent` + `PI_CREW_TASK_ID` + `PI_CREW_PARENT_PID` in the recorded set ⇒ `task-id`;
|
|
36
|
+
a `PI_CREW_PARENT_PID` that is a recorded worker pid and is dead ⇒ `parent-pid`. `PI_CREW_RUN_ID` is deliberately
|
|
37
|
+
NOT matched (registry: `test-only`, no src writer).
|
|
38
|
+
- Guards: Linux `/proc` only (else `[]`, fail-open); never self, never an ancestor, same uid only; the candidate must
|
|
39
|
+
have started no earlier than the run (> 60 s of pre-run clock skew rejected); the candidate's group must not be ours;
|
|
40
|
+
one signal per group per leader incarnation (idempotent across reconciler ticks); and an extra rung — a group whose
|
|
41
|
+
LEADER is alive and carries no marker is skipped (`leader-alive-unmatched`), so a live session's group is never hit.
|
|
42
|
+
- Call sites: `stale-reconciler.ts` sweeps ONLY when the run is terminal, the process is not a worker
|
|
43
|
+
(`PI_CREW_KIND`/crew depth 0), and every recorded runner/worker pid is dead; `team-tool/doctor.ts` (`focus=zombies`)
|
|
44
|
+
reports the survivors as `runDescendants` — report-only, `dryRun: true`, nothing killed.
|
|
45
|
+
- Kill switches: `PI_CREW_REAP_GROUP` (11a) and `PI_CREW_REAP_RUN_DESCENDANTS` (11b), both boolean, default ON, both
|
|
46
|
+
forwarded to the detached background runner (never to a worker) so a disable actually takes effect where the reaping
|
|
47
|
+
runs.
|
|
48
|
+
|
|
49
|
+
**Known limitations** (unchanged by design, documented on the module and in the SPEC): a descendant that calls
|
|
50
|
+
`setsid()` or runs inside its own container/init (`docker`, `systemd-run`) has a group we cannot prove and is left
|
|
51
|
+
alone; pi's bash tool remains the primary source of detached grandchildren — the upstream fix (tracked, non-detached
|
|
52
|
+
children for tool commands, or a cgroup/subreaper for the worker tree) is what would make this sweep unnecessary;
|
|
53
|
+
and the sweep can only match processes that still carry the markers (a scrubbed env is invisible).
|
|
54
|
+
|
|
55
|
+
**11c — sync-run descent proof + test pin (leader-approved options (a) + F1 fix).**
|
|
56
|
+
|
|
57
|
+
- Record sync-run `manifest.sessionPid` so foreground-run leaks satisfy the descent proof (wave 11c): a sync run has no `async.pid`, so a leaked worker grandchild whose `PI_CREW_PARENT_PID` points at the session pi itself could never be proven and was skipped forever; `sessionPid` is recorded at creation and treated as a recorded parent (dead-only, like the others). Also pin `PI_CREW_REAP_RUN_DESCENDANTS` in the sweep suite's setup so the tests no longer depend on the ambient kill-switch state. Battery addendum: `docs/real-test/reports/real-test-2026-10-24-wave11-battery-addendum.md` (F1/F2 closed, verdict PASS).
|
|
58
|
+
|
|
5
59
|
## [0.11.38] — Wave 10: pi-subagents lessons (10 ports) + watchdog hung-alert hardening (WD-DEDUP / WD-STALE-RECORD / WD-DELIVER-GUARD)
|
|
6
60
|
|
|
7
61
|
### Fixed — watchdog alerts for FINISHED runs: delivery-time guard (WD-DELIVER-GUARD, root-caused 2026-10-23)
|