pi-crew 0.11.11 → 0.11.13

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/index.mjs +551 -519
  3. package/package.json +1 -1
  4. package/src/config/config-validation.ts +9 -0
  5. package/src/config/defaults.ts +7 -0
  6. package/src/config/env-vars.ts +24 -0
  7. package/src/config/types.ts +11 -0
  8. package/src/extension/registration/tool-registration.ts +7 -0
  9. package/src/extension/registration/verify-gate-tool.ts +263 -0
  10. package/src/extension/team-tool/run-deadline.ts +22 -1
  11. package/src/extension/team-tool/run.ts +38 -2
  12. package/src/extension/team-tool-types.ts +4 -0
  13. package/src/extension/team-tool.ts +31 -3
  14. package/src/prompt/inbox-poll.ts +141 -3
  15. package/src/runtime/broker/crew-broker.ts +48 -2
  16. package/src/runtime/broker/protocol/lock-busy.ts +47 -1
  17. package/src/runtime/broker/protocol/request-parsers.ts +8 -1
  18. package/src/runtime/budget-enforcement.ts +36 -20
  19. package/src/runtime/child-pi/child-pi-constants.ts +24 -0
  20. package/src/runtime/child-pi/child-pi-kill.ts +59 -2
  21. package/src/runtime/child-pi/child-pi-rpc.ts +1021 -0
  22. package/src/runtime/child-pi/child-pi-steering.ts +10 -8
  23. package/src/runtime/child-pi/child-pi-streams.ts +69 -19
  24. package/src/runtime/child-pi/child-pi.ts +29 -30
  25. package/src/runtime/child-pi/owned-process.ts +434 -0
  26. package/src/runtime/child-pi/postmortem-registry.ts +134 -0
  27. package/src/runtime/classifier/ambient-noise-gate.ts +126 -0
  28. package/src/runtime/classifier/classifier-service.ts +277 -61
  29. package/src/runtime/dispatch-batch.ts +32 -0
  30. package/src/runtime/live-session/live-agent-control.ts +2 -0
  31. package/src/runtime/live-session/live-agent-manager.ts +72 -2
  32. package/src/runtime/live-session/live-session-runtime.ts +435 -40
  33. package/src/runtime/merge-loop.ts +63 -35
  34. package/src/runtime/recovery/crash-recovery.ts +141 -3
  35. package/src/runtime/recovery/retry-executor.ts +29 -0
  36. package/src/runtime/run-tracker.ts +28 -0
  37. package/src/runtime/stale-reconciler.ts +36 -1
  38. package/src/runtime/task-runner.ts +103 -0
  39. package/src/runtime/verification/classifier-pre-gate.ts +262 -0
  40. package/src/runtime/verification/verification-gates.ts +5 -1
  41. package/src/runtime/verification/verify-gate.ts +394 -0
  42. package/src/schema/config-schema.ts +13 -0
  43. package/src/state/contracts.ts +18 -0
  44. package/src/state/coordination/mailbox.ts +203 -55
  45. package/src/state/stores/sqlite-run-state.ts +378 -0
  46. package/src/state/stores/state-store.ts +134 -6
  47. package/src/ui/agents-jobs-browser.ts +154 -8
  48. package/src/ui/events-state-source.ts +358 -0
  49. package/src/ui/run-snapshot-cache.ts +87 -3
  50. package/src/ui/widget/widget-model.ts +13 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,107 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.13] — Reliability: runner survives run.lock contention + 2 fixes from live wave runs (2026-10-10)
4
+
5
+ Three reliability fixes discovered while shipping Waves 1-3 of the upgrade-spec
6
+ program (each bug reproduced live against a real team run today).
7
+
8
+ ### Fixed
9
+
10
+ - **Runner death on run.lock contention (critical)** — the background runner
11
+ died with an unhandled rejection when `mergeUnitResult` hit
12
+ `Run 'run.lock' is locked by another operation`, which stopped heartbeats
13
+ and let the stale-reconciler mass-cancel workers as pid_dead (killed the
14
+ Wave-3 run mid-flight). Merge sites now treat lock-contention as retryable
15
+ (backoff + event log); fatal errors still reach the deadletter path. New
16
+ 2-writer contention tests (merge-loop-lock-contention.test.ts).
17
+ - **Chain/foreground watch-timeout no longer cancels child runs** — a 60-min
18
+ watch window expiring now reports partial-watch only; the child run keeps
19
+ running (previously: chain steps got their run cancelled).
20
+ - **`resume` reports real status** — resuming a run replied "Status:
21
+ completed" instantly while the work continued for hours; it now reports
22
+ the actual state and re-queued work.
23
+
24
+ # Changelog
25
+
26
+ ## [0.11.12] — Upgrade Wave 2: U4 live-session v2, U5 mailbox dedup, U6A classifier triage, U14 rpc mode, U15 OwnedProcess (2026-10-10)
27
+
28
+ Wave 2 of the upgrade-spec program. One commit per spec; test:critical 120/0,
29
+ full npm test 0 fail (unit 8842/8845 + integration 139/143, gated skips only),
30
+ bundle rebuilt fresh; wave-2 review 0 MAJOR with MINOR-1..4 pool/env hardening
31
+ landed as follow-up. Waves 2+3 released together as 0.11.12.
32
+
33
+ ### Changed
34
+
35
+ - **U4** — live-session v2: shared services bundle (one lazy build, sessions
36
+ from `createAgentSessionFromServices` — measured init drop ~2240ms → <50ms
37
+ via `session_created.elapsedMs`), two-layer recursion guard (loader-level
38
+ noExtensions + foreign-extension assert), `streamingBehavior` on every
39
+ prompt path, normalized dispose (drain pendingSteers, terminated handles
40
+ reject steer), D4 planning-window steer-loss fix (placeholder session
41
+ queues and replays to the real session), hung-tool drop-reference escape.
42
+ - **U5** — mailbox `requestId` dedup: every send carries a unique requestId,
43
+ receivers dedup by (direction, requestId) durably, resend-after-resume is
44
+ idempotent (7/7 tests).
45
+ - **U14** — child-pi protocol v2: `--mode rpc` transport (steer receipts,
46
+ isStreaming-gated steer + clear_queue before prompt, type-filtered event
47
+ subscription, absolute bundle cliPath), 18/18 tests; pool reuse opt-in
48
+ (`PI_CREW_CHILD_PI_POOL`, default off). MINOR-1..4: busy-alive pool entries
49
+ never evicted, drain ceiling gated on pool flag, run-scoped named listeners
50
+ detached in settle(), env-splice canary.
51
+ - **U15** — OwnedProcess port: process-group ownership (detached spawn →
52
+ group-kill), escalating dispose with hard cap, root-exit drain-reconcile,
53
+ pid-recycle guard, postmortem registry; 11/11 tests.
54
+
55
+ ### Added
56
+
57
+ - **U6A** — classifier retry-triage flag (`classifierEnabled`, default off):
58
+ confidence passthrough + histogram + `task.noise_gate` events, soft-fail on
59
+ every branch (12 tests).
60
+
61
+
62
+ ## [0.11.12] — Upgrade Wave 3 (con't): U7 events view layer, U8 sqlite state, U9 reconcile-at-open, U6B classifier pre-gate, U13 verify_gate (2026-10-10)
63
+
64
+ Wave 3 of the upgrade-spec program (`pi-crew-upgrade-spec-2026-10-09.md`), branch
65
+ `upgrade/wave-3`, one commit per spec. Final gate: unit 8934 tests (8925 pass;
66
+ 4 shard/snapshot registrations fixed and re-verified green; 2 load-flakes green in
67
+ isolation), integration 144/0 fail, typecheck + lint clean, `dist/index.mjs` rebuilt
68
+ fresh with every wave-3 string-literal marker verified in-bundle.
69
+
70
+ ### Added
71
+
72
+ - **U7** — events state source view layer: `eventsStateSource(runId)`
73
+ CommittedStateSource adapter (snapshot = one full parse to the current seq; frames =
74
+ `readEventsCursor` tail-follow batches; >100-frame backlog or inode change → ONE
75
+ root-replacement resync). `run-snapshot-cache` opt-in `{ eventsState: { pollMs } }`
76
+ shares ONE unref'd poll interval per entry; browser tick CPU 6.98ms → 0.41ms.
77
+ `events.jsonl` is never written — pure derived view. (665b443a)
78
+ - **U8** — opt-in sqlite run-state backend: `PI_CREW_STATE_BACKEND=sqlite` stores
79
+ manifest + tasks + worker-status in `<runId>/state.sqlite` via `node:sqlite` with
80
+ ONE transaction per batch write (all-or-nothing); JSON files stay written as
81
+ read-side mirrors for legacy consumers while loads read the db. The `events.jsonl`
82
+ audit spine is unchanged in both modes. (ae49628f)
83
+ - **U9** — reconcile-at-open fast-path: crashed runs with NO live claim (dead async
84
+ pid + no live registry entry) requeue `running`→`queued` in ONE locked pass
85
+ (attempt / checkpoint / deps / partial state preserved) and the run is marked
86
+ `failed`-for-resume; the verdict tree now only runs for live-claim runs. Interrupted-
87
+ run detection latency 300000ms → 1-9ms. New reconcile verdict `requeued_no_claim`.
88
+ (456c9283)
89
+ - **U6B** — classifier verifier pre-gate: score-question variant consults the ambient
90
+ classifier before a verifier-role spawn (block score ≥ 0.9 / confidence ≥ 0.8);
91
+ soft-fail — every classifier error path escalates to the LLM verifier. (6b6c0aca)
92
+ - **U13** — deterministic `verify_gate` pre-gate + tool: verifier-role spawns first run
93
+ the package.json-script checks (typecheck / test:critical) via
94
+ `ctx.executeTool("bash", ...)` with per-check timeout (`PI_CREW_VERIFY_GATE`,
95
+ `PI_CREW_VERIFY_GATE_TIMEOUT_MS`, default 120s); PASS skips the LLM verifier spawn,
96
+ FAILED/INCONCLUSIVE spawns it with the gate results in the prompt. (ef67cd04)
97
+
98
+ ### Fixed (wave-3 gate remediation)
99
+
100
+ - env-vars registry snapshot now includes the wave-3 keys (`PI_CREW_STATE_BACKEND`,
101
+ `PI_CREW_VERIFY_GATE`, `PI_CREW_VERIFY_GATE_TIMEOUT_MS`).
102
+ - shard-partition table registers the new `test/unit/registration/` dir (U13 test).
103
+ - import sort in `sqlite-run-state.test.ts` (biome organizeImports).
104
+
3
105
  ## [0.11.11] — Upgrade Wave 1: U1 dead-option, U2 buffered events, U3 key-free E2E, U10 measured-token handoff (2026-10-10)
4
106
 
5
107
  Wave 1 of the upgrade-spec program (`pi-crew-upgrade-spec-2026-10-09.md`, verified over