pi-crew 0.5.14 → 0.5.17

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 (90) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +1 -1
  3. package/docs/pi-crew-v0.5.16-audit-fix-plan.md +35 -0
  4. package/docs/pi-crew-v0.5.17-audit-fix-plan.md +80 -0
  5. package/docs/skills/REFERENCE.md +11 -0
  6. package/package.json +1 -1
  7. package/skills/artifact-analysis-loop/SKILL.md +1 -0
  8. package/skills/async-worker-recovery/SKILL.md +1 -0
  9. package/skills/child-pi-spawning/SKILL.md +1 -0
  10. package/skills/context-artifact-hygiene/SKILL.md +1 -0
  11. package/skills/delegation-patterns/SKILL.md +1 -0
  12. package/skills/detection-pipeline-design/SKILL.md +2 -1
  13. package/skills/event-log-tracing/SKILL.md +1 -0
  14. package/skills/git-master/SKILL.md +1 -0
  15. package/skills/hunting-investigation-loop/SKILL.md +1 -0
  16. package/skills/incident-playbook-construction/SKILL.md +1 -0
  17. package/skills/iterative-audit/SKILL.md +331 -0
  18. package/skills/live-agent-lifecycle/SKILL.md +1 -0
  19. package/skills/mailbox-interactive/SKILL.md +1 -0
  20. package/skills/model-routing-context/SKILL.md +2 -1
  21. package/skills/multi-perspective-review/SKILL.md +1 -0
  22. package/skills/observability-reliability/SKILL.md +1 -0
  23. package/skills/orchestration/SKILL.md +2 -1
  24. package/skills/ownership-session-security/SKILL.md +1 -0
  25. package/skills/pi-extension-lifecycle/SKILL.md +3 -2
  26. package/skills/post-mortem/SKILL.md +1 -0
  27. package/skills/read-only-explorer/SKILL.md +1 -0
  28. package/skills/requirements-to-task-packet/SKILL.md +1 -0
  29. package/skills/resource-discovery-config/SKILL.md +2 -1
  30. package/skills/runtime-state-reader/SKILL.md +1 -0
  31. package/skills/safe-bash/SKILL.md +1 -0
  32. package/skills/scrutinize/SKILL.md +1 -0
  33. package/skills/secure-agent-orchestration-review/SKILL.md +1 -0
  34. package/skills/security-review/SKILL.md +1 -0
  35. package/skills/state-mutation-locking/SKILL.md +1 -0
  36. package/skills/systematic-debugging/SKILL.md +1 -0
  37. package/skills/threat-hypothesis-framework/SKILL.md +1 -0
  38. package/skills/ui-render-performance/SKILL.md +2 -1
  39. package/skills/verification-before-done/SKILL.md +1 -0
  40. package/skills/widget-rendering/SKILL.md +2 -1
  41. package/skills/workspace-isolation/SKILL.md +1 -0
  42. package/skills/worktree-isolation/SKILL.md +1 -0
  43. package/src/config/types.ts +1 -0
  44. package/src/extension/management.ts +1 -1
  45. package/src/extension/plan-orchestrate.ts +0 -1
  46. package/src/extension/register.ts +16 -7
  47. package/src/extension/registration/viewers.ts +1 -1
  48. package/src/extension/run-index.ts +1 -1
  49. package/src/extension/team-tool/explain.ts +0 -1
  50. package/src/extension/team-tool/handle-schedule.ts +0 -1
  51. package/src/extension/team-tool/health-monitor.ts +0 -1
  52. package/src/extension/team-tool/orchestrate.ts +12 -4
  53. package/src/extension/team-tool/run.ts +2 -2
  54. package/src/extension/team-tool/status.ts +1 -1
  55. package/src/extension/team-tool.ts +2 -30
  56. package/src/observability/exporters/otlp-exporter.ts +11 -1
  57. package/src/runtime/adaptive-plan.ts +18 -2
  58. package/src/runtime/child-pi.ts +18 -6
  59. package/src/runtime/crash-recovery.ts +1 -1
  60. package/src/runtime/crew-agent-records.ts +23 -3
  61. package/src/runtime/crew-hooks.ts +1 -1
  62. package/src/runtime/dynamic-script-runner.ts +14 -1
  63. package/src/runtime/handoff-manager.ts +0 -1
  64. package/src/runtime/heartbeat-watcher.ts +1 -1
  65. package/src/runtime/live-session-runtime.ts +0 -1
  66. package/src/runtime/loop-gates.ts +0 -1
  67. package/src/runtime/mcp-proxy.ts +2 -2
  68. package/src/runtime/pipeline-runner.ts +1 -2
  69. package/src/runtime/sandbox.ts +8 -0
  70. package/src/runtime/task-packet.ts +124 -0
  71. package/src/runtime/task-runner/live-executor.ts +1 -2
  72. package/src/runtime/task-runner/prompt-builder.ts +4 -1
  73. package/src/runtime/task-runner.ts +2 -2
  74. package/src/schema/config-schema.ts +1 -0
  75. package/src/state/event-log.ts +7 -0
  76. package/src/state/jsonl-writer.ts +24 -0
  77. package/src/state/locks.ts +66 -35
  78. package/src/state/run-metrics.ts +1 -2
  79. package/src/state/schedule.ts +13 -5
  80. package/src/state/state-store.ts +1 -1
  81. package/src/tools/safe-bash-extension.ts +1 -1
  82. package/src/tools/safe-bash.ts +10 -1
  83. package/src/ui/crew-widget.ts +2 -2
  84. package/src/ui/render-diff.ts +1 -1
  85. package/src/ui/run-dashboard.ts +1 -2
  86. package/src/ui/tool-render.ts +20 -3
  87. package/src/utils/conflict-detect.ts +0 -1
  88. package/src/utils/gh-protocol.ts +0 -2
  89. package/src/workflows/workflow-config.ts +3 -0
  90. package/src/worktree/worktree-manager.ts +75 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,176 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.17] — Security Hardening + ECC Patterns + Skill Review (2026-06-03)
4
+
5
+ ### Highlights
6
+ - **3 CRITICAL security fixes**: path traversal, sandbox escape, executeUnchecked bypass
7
+ - **3 HIGH security fixes**: allowPatterns bypass, safe-bash fallback message, mock mode
8
+ - **3 MEDIUM security fixes**: home hooks visibility, API keys documentation, sync lock deprecation
9
+ - **2 new features** from ECC/dmux patterns: seedPaths overlay + structured handoff template
10
+ - **2 gap fills**: handoff parser + per-step seedPaths
11
+ - **36 skills reviewed**: origin fields, broken refs fixed, verify-skill.ts updated
12
+ - **1 bug fix**: adaptive-plan parser strips markdown code fences
13
+ - **1 regression fix**: mock mode NODE_ENV gate reverted
14
+ - **41 new tests** across 6 test files
15
+
16
+ ### Security Fixes
17
+
18
+ #### CRITICAL
19
+ 1. `orchestrate.ts`: Path traversal — planPath validated with `resolveContainedPath()`
20
+ 2. `sandbox.ts`: Prototype pollution — `Object.freeze` on prototypes, `globalThis`/`global` in FORBIDDEN_PATTERNS
21
+ 3. `dynamic-script-runner.ts`: `executeUnchecked` → private, `__test_executeUnchecked` test-only export
22
+
23
+ #### HIGH
24
+ 4. `safe-bash.ts`: allowPatterns validation rejects `/.*/` and permissive catch-all patterns
25
+ 5. `safe-bash-extension.ts`: Error message no longer suggests bypassing safe-bash
26
+ 6. `child-pi.ts`: Mock mode requires `PI_CREW_ALLOW_MOCK=1` (set in parent process only)
27
+
28
+ #### MEDIUM
29
+ 7. `worktree-manager.ts`: `logInternalError` warning when home directory hooks accepted
30
+ 8. `child-pi.ts`: SECURITY WARNING JSDoc on API key allow-list trade-off
31
+ 9. `event-log.ts`: Expanded deprecation notice on `withEventLogLockSync` blocking behavior
32
+
33
+ ### Features (ECC/dmux patterns)
34
+
35
+ - **seedPaths**: Overlay local/uncommitted files into worktrees via config (`worktree.seedPaths`) or per-step (`WorkflowStep.seedPaths`). Path traversal validation, dedup, recursive copy.
36
+ - **Structured Handoff Template**: `HANDOFF_TEMPLATE` constant + `parseHandoffFromOutput()` parser. Agents receive handoff format instructions automatically.
37
+
38
+ ### Skill Review
39
+ - All 36 skills: added `origin` YAML frontmatter field
40
+ - Fixed `widget-rendering` wrong file path
41
+ - Fixed `orchestration` + `detection-pipeline-design` broken cross-skill references
42
+ - Fixed 4 skills with wrong `source/pi-mono/` paths
43
+ - `verify-skill.ts` now validates `origin` field
44
+
45
+ ### Bug Fixes
46
+ - `adaptive-plan.ts`: `stripCodeFence()` strips markdown code fences inside ADAPTIVE_PLAN markers — fixes planner output parsing for non-frontier models
47
+ - Mock mode regression: reverted NODE_ENV gate, uses PI_CREW_ALLOW_MOCK only (child processes don't inherit NODE_ENV)
48
+
49
+ ### Stats
50
+ - Test suite: 2698 pass + 1 skip, 0 fail (was 2657 in v0.5.16; +41 net)
51
+ - TypeScript: 0 errors
52
+ - New test files: 6 (worktree-seed-paths, task-handoff-template, task-handoff-parser, adaptive-plan +3 safe-bash tests)
53
+ - Files touched: 50+
54
+ - Security issues fixed: 9 (3 CRITICAL + 3 HIGH + 3 MEDIUM)
55
+ - False positives verified: 2
56
+
57
+ ## [0.5.16] — Rounds 22–31 Audit Fixes (2026-06-02)
58
+
59
+ ### Highlights
60
+ - **1 bug fix**: OTLP exporter `dispose()` now awaits in-flight push (bounded by 10s timeout)
61
+ - **269 new unit tests** across 16 previously-untested modules (Pattern #3)
62
+ - **72 unused imports removed** across 28 source files (Pattern #6)
63
+ - **2 defensive caps** for unbounded Maps (Pattern #2)
64
+ - **1 L1 fix**: `console.warn` → `logInternalError` in crew-hooks
65
+
66
+ ### Round 22: Defensive Caps (commit 85b3be6)
67
+ - Bounded `autoRecoveryLast` and `agentEventSeqCache` Maps to 1000 entries
68
+ - Eviction uses insertion-order oldest-first pattern
69
+
70
+ ### Round 23: Resource Cleanup (commit 4be2c4e)
71
+ - OTLP exporter `dispose()` now async, awaits in-flight push with 10s timeout
72
+ - Surveyed all setInterval/setTimeout, process.on, file watchers, event listeners, AbortControllers — all clean
73
+
74
+ ### Round 24: Test Coverage — discover-agents, markers, tiered-eval (commit cfe5242)
75
+ - 50 new tests: `sanitizeAgentSystemPrompt` (6 rules), `sanitizeGuidanceContent` (5 rules), `TieredEvalRunner` class
76
+
77
+ ### Round 25: Test Coverage — adaptive-plan, group-join (commit 89e1cf1)
78
+ - 42 new tests: `slug`, `extractAdaptivePlanJson`, `parseAdaptivePlan`, `repairAdaptivePlan`, `GroupJoinManager`
79
+
80
+ ### Round 26: Test Coverage — pi-args, i18n (commit 3669f24)
81
+ - 38 new tests: `applyThinkingSuffix`, `resolveCrewMaxDepth`, `t()`, `addTranslations`, `listLocales`
82
+
83
+ ### Round 27: Test Coverage — validation-types, live-extension-bridge (commit 44a2366)
84
+ - 36 new tests: `validateWithSeverity` strict/lenient modes, `buildExtensionBridge` mock session
85
+
86
+ ### Round 28: Test Coverage — direct-run, live-session-health (commit 339ac7d)
87
+ - 17 new tests: `isDirectRun`, `directTeamAndWorkflowFromRun`, `collectLiveSessionHealth`
88
+
89
+ ### Round 29: Test Coverage — process-status, task-claims (commit 405e05d)
90
+ - 43 new tests: `checkProcessLiveness`, `isActiveRunStatus`, full claim lifecycle
91
+
92
+ ### Round 30: Test Coverage — task-display, green-contract, session-utils (commit 7d065ca)
93
+ - 43 new tests: `shouldMaterializeAgent`, `taskById`, `waitingReason`, `greenLevelSatisfies`, `assertValidSessionId`
94
+
95
+ ### Round 31: Code Quality — unused imports + L1 fix (commit 35cc0e7)
96
+ - 72 unused imports removed across 28 source files
97
+ - `crew-hooks.ts`: `console.warn` → `logInternalError` for unknown event types
98
+
99
+ ### Stats
100
+ - Test suite: 2657 pass + 1 skip, 0 fail (was 2370 in v0.5.14; +287 net)
101
+ - TypeScript: 0 errors
102
+ - New test files: 13
103
+ - Files touched: 58
104
+
105
+ ## [0.5.15] — Round 20 + 21 Audit Fixes (2026-06-02)
106
+
107
+ ### Source tour
108
+ - Pulled latest `can1357/oh-my-pi` (1751 new commits since 2026-05-11) to working copy
109
+ - Surveyed extensibility, skill system, and security/performance changes via 3 parallel explorer agents
110
+ - Distilled 2 high-impact, immediately applicable patterns (Round 20)
111
+ - Identified 5 more upgrade opportunities; applied 5 in Round 21
112
+
113
+ ### Round 20: Lock token guard + tool-error sanitization (commit f448d7d)
114
+
115
+ #### 1. Per-process lock tokens (src/state/locks.ts)
116
+ - **Pattern source**: oh-my-pi commit `cd578a86d` (`file-lock.ts:13-152`)
117
+ - **Bug fixed**: "Losing contender wipes winner's lock" race when one process times out and steals a stale lock that the original holder is about to release
118
+ - Lock file now carries a UUID token. `releaseLock` refuses to `fs.rm` unless the stored token matches.
119
+ - 3 new tests in `test/unit/locks-race.test.ts`
120
+
121
+ #### 2. Tool-error sanitization (src/ui/tool-render.ts)
122
+ - **Pattern source**: oh-my-pi `render-utils.ts:177-185` (`replaceTabs(truncateToWidth(clean, LINE_CAP))`)
123
+ - **Bug fixed**: Embedded tabs/newlines/long strings in tool errors break TUI border alignment
124
+ - Applied to `renderAgentProgress` and `renderAgentToolResult` (2 places)
125
+ - `replaceTabs` is now exported from `src/ui/render-diff.ts` for reuse
126
+ - 2 new tests in `test/unit/tool-render.test.ts`
127
+
128
+ ### Round 21: L1 cleanup, lock kind, JSONL per-line cap, in-place loader test (commit 1bf120b)
129
+
130
+ #### 1. L1 cleanup in src/state/schedule.ts
131
+ - `console.warn` → `logInternalError` (consistency with rest of codebase)
132
+ - `require("node:fs")` → top-level `fs`/`path` imports
133
+ - 3 new tests in `test/unit/schedule-store.test.ts`
134
+
135
+ #### 2. Dead code sweep in src/state/locks.ts
136
+ - Removed misleadingly-named `readLockStateAsync` (sync I/O, called from async path) and its redundant call site
137
+ - Async path now mirrors sync path exactly: stale-check + release + sleep
138
+
139
+ #### 3. Lock file `kind` discriminator (forward compat)
140
+ - Lock JSON now includes `kind: "run" | "file"`
141
+ - `withRunLock` writes `kind="run"`; `withFileLockSync` writes `kind="file"`
142
+ - Old locks (no `kind` field) still work — `releaseLock` only reads `token`, so the discriminator is purely additive
143
+ - 3 new tests (kind for run, kind for file, back-compat with legacy locks)
144
+
145
+ #### 4. JSONL per-line cap (defensive, src/state/jsonl-writer.ts)
146
+ - Single huge line could exhaust memory during `redactJsonLine`
147
+ - New `DEFAULT_MAX_LINE_BYTES = 1MB`. Lines exceeding the cap are dropped and counted
148
+ - `logInternalError` fires on the first drop and every 100th drop thereafter
149
+ - 2 new tests in `test/unit/jsonl-writer.test.ts`
150
+
151
+ #### 5. In-place extension loader integration test
152
+ - **Pattern source**: oh-my-pi commit `c5e3698f4` (changed how extensions are loaded)
153
+ - This test verifies pi-crew's `import.meta.url`-based skill path resolution still works with the new in-place loader
154
+ - 2 new tests in `test/integration/extension-skill-resolution.test.ts`
155
+
156
+ ### Summary
157
+ - **2 rounds** (Round 20 + 21)
158
+ - **2 commits**: `f448d7d` (Round 20) + `1bf120b` (Round 21)
159
+ - **10 new tests** across 4 test files
160
+ - **Total tests**: 50 pass + 1 skip, **0 fail** (was 49 in v0.5.14)
161
+ - **TypeScript**: 0 errors
162
+ - **Patterns adopted**: 5 from `can1357/oh-my-pi` post-2026-05-11
163
+
164
+ ### Patterns surveyed but not applied (low applicability for pi-crew)
165
+ - **Streaming JSON throttle** (3a733c480) — pi-crew has no streaming JSON parser
166
+ - **In-place state mutation** (3a733c480) — pi-crew's spreads are bounded (small N), not hot paths
167
+ - **Bounded row probing** (b522fde56) — pi-crew has no SQL queries
168
+ - **MCP reconnect storm circuit breaker** — pi-crew has no MCP reconnect logic
169
+ - **Drop `args` global from eval** (4ab40764d) — pi-crew's `dynamic-script-runner.ts` already safe
170
+ - **Shell-injection rejection in git specs** (22e564a85) — pi-crew has no plugin install path
171
+ - **NPM registry pinning** (9abce6e97) — pi-crew's `install.mjs` is config-only; user runs `pi install npm:pi-crew`
172
+ - **Extension flag shadow** (1fbc2cbd7) — pi-crew has no `registerFlag` calls
173
+
3
174
  ## [0.5.14] — Round 19 Audit Fixes (2026-06-02)
4
175
 
5
176
  ### Phase 1: Path validation in checkpoint.ts (MEDIUM security)
package/README.md CHANGED
@@ -9,7 +9,7 @@ npm: pi-crew
9
9
  repo: https://github.com/baphuongna/pi-crew
10
10
  ```
11
11
 
12
- **v0.5.14**: See [CHANGELOG.md](CHANGELOG.md).
12
+ **v0.5.15**: See [CHANGELOG.md](CHANGELOG.md).
13
13
 
14
14
  ### Security highlights (v0.5.5)
15
15
 
@@ -0,0 +1,35 @@
1
+ # Round 22 Audit Fix Plan (Defensive Caps)
2
+
3
+ ## Findings
4
+
5
+ ### Issue 1: `autoRecoveryLast` Map grows unboundedly (MEDIUM, MEMORY)
6
+ - **File**: `src/extension/register.ts:484`
7
+ - **What**: Module-level `Map<string, number>` keyed by `${kind}_${runId}`. Holds cooldown timestamps for "recovery notifications" (5-minute gate per key).
8
+ - **Bug**: Entries are NEVER removed during a session. Each run contributes up to 4 keys (one per `maybeNotifyHealth` kind). Long-running pi sessions that run 1000+ teams accumulate 4000+ entries (~32KB).
9
+ - **Severity**: MEDIUM — silent memory growth in long-running process. Not a security issue.
10
+ - **Fix**: Add `AUTO_RECOVERY_LAST_MAX_ENTRIES` cap. Evict oldest insertion (matches the 5-min cooldown gate semantics — once the gate has expired, the entry is irrelevant). The eviction loop runs on each `set()` to amortize the cost.
11
+
12
+ ### Issue 2: `agentEventSeqCache` Map grows unboundedly (MEDIUM, MEMORY)
13
+ - **File**: `src/runtime/crew-agent-records.ts:265`
14
+ - **What**: Module-level `Map<string, { size, mtimeMs, seq }>` keyed by `filePath` (each agent event log). Caches the `.seq` sidecar value.
15
+ - **Bug**: Entries are NEVER removed. Each new agent task creates a new event log file, adding a cache entry. A long-running pi-crew process that spawns 1000s of agents accumulates 1000s of entries.
16
+ - **Severity**: MEDIUM — silent memory growth. Plus, stale entries mask filesystem changes (mtime/size won't reflect a re-created file).
17
+ - **Fix**: Add `AGENT_EVENT_SEQ_CACHE_MAX_ENTRIES` cap. Evict oldest insertion first (mirrors the `asyncAgentReaderCache` pattern at line 134-136 in the same file).
18
+
19
+ ## Plan (2 phases)
20
+
21
+ ### Phase 1: `autoRecoveryLast` defensive cap
22
+ - `src/extension/register.ts:484` — add `AUTO_RECOVERY_LAST_MAX_ENTRIES = 1000` constant
23
+ - Modify the `set()` site at line 1534 to evict oldest entries before inserting when size > cap
24
+ - Add test in `test/unit/auto-recovery-cap.test.ts`
25
+
26
+ ### Phase 2: `agentEventSeqCache` defensive cap
27
+ - `src/runtime/crew-agent-records.ts:265` — add `AGENT_EVENT_SEQ_CACHE_MAX_ENTRIES = 1000` constant
28
+ - Add helper function `setAgentEventSeqCache()` that wraps the `.set()` and evicts oldest entries
29
+ - Add test in `test/unit/crew-agent-records.test.ts` (or new file)
30
+
31
+ ## Expected impact
32
+ - 2 new tests, 0 regressions
33
+ - Total: 2 MEDIUM memory-leak fixes
34
+ - No public API changes
35
+ - Pattern: follows existing `NotificationRouter.SEEN_MAP_MAX_SIZE` and `asyncAgentReaderCache` patterns in the codebase
@@ -0,0 +1,80 @@
1
+ # Round 23 Audit Findings (Resource Cleanup)
2
+
3
+ ## Skill: iterative-audit (Pattern #7: Resource Cleanup)
4
+
5
+ ## Findings
6
+
7
+ ### Issue 1: OTLP exporter `inFlight` push not awaited on dispose (LOW)
8
+ - **File**: `src/observability/exporters/otlp-exporter.ts:80-86, 127-130`
9
+ - **What**: When `dispose()` is called, the interval timer is cleared but the in-flight `push()` continues to run until the 10s fetch timeout. The result is lost (not awaited).
10
+ - **Severity**: LOW — bounded by 10s fetch timeout. Not a real leak, just orphaned work.
11
+ - **Fix**: Make `dispose()` async. Await the in-flight push before returning.
12
+ - **Test**: 1 new test verifies `dispose()` waits for the in-flight push.
13
+
14
+ ## Patterns surveyed (all VERIFIED clean from source)
15
+
16
+ ### setInterval / setTimeout cleanup
17
+ | File | Resource | Cleanup | Status |
18
+ |------|----------|---------|--------|
19
+ | `register.ts:411` | `autoRepairTimer` | cleared on line 308, 402, 1102 | OK |
20
+ | `register.ts:442` | `tempReconcileTimer` | cleared on line 308, 402, 1102 | OK |
21
+ | `result-watcher.ts:80` | `pollTimer` | cleared in `stopPolling()` | OK |
22
+ | `result-watcher.ts:96` | `restartTimer` | cleared in `scheduleRestart()` and `stop()` | OK |
23
+ | `async-notifier.ts:101` | `state.interval` | cleared in `stopAsyncRunNotifier()` | OK |
24
+ | `subagent-tools.ts:228` | `timer` | cleanup function returned to caller | OK |
25
+ | `team-tool.ts:160` | `timer` | `stop()` method clears it | OK |
26
+ | `live-conversation-overlay.ts:55` | `pollTimer` | cleared in `close()` / `dispose()` | OK |
27
+ | `loaders.ts:127` | `timer` | cleared in `dispose()` | OK |
28
+ | `theme-adapter.ts:145` | `pollTimer` | cleared in unsubscribe (line 169) | OK |
29
+ | `delivery-coordinator.ts:169` | `ttlTimer` | cleared in `dispose()` | OK |
30
+ | `parent-guard.ts:61` | `guardInterval` | cleared in `stopParentGuard()` | OK |
31
+ | `scheduler.ts:88` | `t` (timer) | cleared on job removal | OK |
32
+ | `otlp-exporter.ts:80` | `timer` | cleared in `dispose()` (Round 23: also awaits inFlight) | OK |
33
+ | `team-runner.ts:67` | `interval` | local scope (per-run) | OK |
34
+ | `metric-sink.ts:68` | `timer` | cleared in `dispose()` (also closes fd) | OK |
35
+ | `handoff-manager.ts:203` | `cleanupTimer` | cleared in `dispose()` (also clears Maps) | OK |
36
+ | `live-session-runtime.ts:487` | `controlTimer` | cleared in `finally` block | OK |
37
+ | `budget-tracker.ts:231` | `abortInterval` | cleared on abort/exhausted | OK |
38
+ | `background-runner.ts:52, 74` | `interval` | local scope (process entry point) | OK |
39
+
40
+ ### process.on() signal handler registration
41
+ | File | Handlers | Guard | Status |
42
+ |------|----------|-------|--------|
43
+ | `crew-cleanup.ts:79, 84` | SIGTERM, SIGHUP | `signalHandlersRegistered` flag (Round 16) | OK |
44
+ | `background-runner.ts:107, 148, 175, 181, 194, 198` | many | process entry point (registered once per process) | OK |
45
+ | `event-log.ts:490-492` | exit, SIGTERM, SIGINT | module-level (ESM caches) | OK |
46
+ | `atomic-write.ts:265-267` | exit, SIGTERM, SIGINT | module-level (ESM caches) | OK |
47
+
48
+ ### File watchers
49
+ | File | Watcher | Cleanup | Status |
50
+ |------|---------|---------|--------|
51
+ | `register.ts:682, 686` | `crewWatcher`, `userCrewWatcher` | `closeWatcher()` in cleanup paths | OK |
52
+ | `result-watcher.ts` | `watcher` | `closeWatcher()` in `stop()` | OK |
53
+
54
+ ### Event listeners
55
+ | File | Listener | Cleanup | Status |
56
+ |------|----------|---------|--------|
57
+ | `event-bus.ts:on()` | deduped via Set | cleanup function returned | OK |
58
+ | `run-event-bus.ts:onAny()` etc. | deduped via Sets | cleanup function returned | OK |
59
+ | `phase-tracker.ts:dispose()` | EventEmitter | `removeAllListeners()` | OK |
60
+ | `team-tool.ts:72` | signal listener | `removeEventListener` in `finally` | OK |
61
+
62
+ ### AbortController
63
+ | File | Controller | Cleanup | Status |
64
+ |------|-----------|---------|--------|
65
+ | `team-tool.ts:68` | per-tool | aborted via signal listener, removed in `finally` | OK |
66
+ | `subagent-manager.ts:290` | per-run | cleaned in `cleanupRunSignal()` | OK |
67
+ | `cancellation-token.ts:17` | per-token | aborted via `#controller.abort()` | OK |
68
+ | `otlp-exporter.ts:106` | per-push | cleared in `finally` block | OK (also: dispose awaits inFlight) |
69
+
70
+ ## Plan (1 phase)
71
+
72
+ ### Phase 1: OTLP exporter `dispose()` awaits inFlight
73
+ - `src/observability/exporters/otlp-exporter.ts:127-130` — make `dispose()` async, await `this.inFlight`
74
+ - 1 new test in `test/unit/otlp-exporter.test.ts`
75
+
76
+ ## Expected impact
77
+ - 1 new test, 0 regressions
78
+ - Total: 1 LOW severity improvement
79
+ - No public API change (callers that don't await still get synchronous timer clear)
80
+ - Pattern: matches the existing `await` patterns elsewhere in the codebase
@@ -38,6 +38,16 @@ multi-perspective-review (8-pass deep review)
38
38
  secure-agent-orchestration-review (security focus)
39
39
  ```
40
40
 
41
+ ### Multi-Round Audit (5-20 rounds)
42
+
43
+ ```
44
+ iterative-audit (round planning, 7 patterns, diminishing-returns)
45
+
46
+ multi-perspective-review (per round, optional)
47
+
48
+ verification-before-done (per round)
49
+ ```
50
+
41
51
  ---
42
52
 
43
53
  ## When to Invoke
@@ -48,6 +58,7 @@ secure-agent-orchestration-review (security focus)
48
58
  | Before claiming done | `verification-before-done` |
49
59
  | Code review (quick) | `scrutinize` |
50
60
  | Code review (deep) | `multi-perspective-review` |
61
+ | Multi-round audit (5-20 rounds) | `iterative-audit` |
51
62
  | Task delegation | `delegation-patterns` |
52
63
  | Complex multi-phase work | `orchestration` |
53
64
  | After bug is fixed | `post-mortem` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-crew",
3
- "version": "0.5.14",
3
+ "version": "0.5.17",
4
4
  "description": "Pi extension for coordinated AI teams, workflows, worktrees, and async task orchestration",
5
5
  "author": "baphuongna",
6
6
  "license": "MIT",
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: artifact-analysis-loop
3
3
  description: "Systematic artifact examination for code, files, and binaries."
4
+ origin: distilled:anthropic-cybersecurity-skills
4
5
  triggers:
5
6
  - "analyze this artifact"
6
7
  - "examine file"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: async-worker-recovery
3
3
  description: Background worker, heartbeat, stale-run, crash-recovery, and deadletter workflow. Use when debugging stuck/dead workers or changing async run reliability.
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "worker crashed"
6
7
  - "stale run"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: child-pi-spawning
3
3
  description: "Child Pi worker spawning, lifecycle callbacks, and failure modes."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "worker crashed"
6
7
  - "worker blink"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: context-artifact-hygiene
3
3
  description: "Use when constructing worker prompts, reading artifacts/logs, summarizing runs, compacting context, or handing work between agents."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "construct prompt"
6
7
  - "read artifact"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: delegation-patterns
3
3
  description: "Subagent/team delegation workflow."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "delegate this"
6
7
  - "split this task"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: detection-pipeline-design
3
3
  description: "Design data pipelines for security monitoring and threat intelligence."
4
+ origin: distilled:anthropic-cybersecurity-skills
4
5
  triggers:
5
6
  - "build pipeline"
6
7
  - "design detection"
@@ -282,4 +283,4 @@ npx tsc --noEmit
282
283
  node --experimental-strip-types --test test/unit/detection-pipeline.test.ts
283
284
  ```
284
285
 
285
- *See also: `detection-signature-authoring` (in security-review) for detection rule patterns.*
286
+ *See also: `security-review` skill for detection rule patterns and signature authoring guidance.*
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: event-log-tracing
3
3
  description: "Structured event logging for worker lifecycle, live agents, crash recovery."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "event log"
6
7
  - "trace events"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: git-master
3
3
  description: "Commit and release hygiene for safe version-control work."
4
+ origin: pi-crew
4
5
  triggers:
5
6
  - "commit this"
6
7
  - "tag release"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: hunting-investigation-loop
3
3
  description: "Active hypothesis-driven investigation and threat hunting."
4
+ origin: distilled:anthropic-cybersecurity-skills
4
5
  triggers:
5
6
  - "hunt for"
6
7
  - "find evidence of"
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: incident-playbook-construction
3
3
  description: "Build structured incident response playbooks and runbooks."
4
+ origin: distilled:anthropic-cybersecurity-skills
4
5
  triggers:
5
6
  - "build playbook"
6
7
  - "create runbook"