opencode-swarm 7.166.1 → 7.166.3

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 (115) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/background/candidate-contract.d.ts +14 -0
  4. package/dist/background/pr-subscriptions.d.ts +33 -1
  5. package/dist/background/workspace-snapshot.d.ts +41 -0
  6. package/dist/cli/{coder-settlement-x0h3h6vd.js → coder-settlement-nx8ff9k1.js} +13 -13
  7. package/dist/cli/{config-doctor-pjcjeh8f.js → config-doctor-n9cjh11e.js} +4 -4
  8. package/dist/cli/{core-v11pd1yk.js → core-cbwrwhcz.js} +2 -2
  9. package/dist/cli/{curation-policy-jtzwz6bc.js → curation-policy-bvxf5pxv.js} +11 -6
  10. package/dist/cli/{curator-ssvd7evd.js → curator-c7amtass.js} +40 -39
  11. package/dist/cli/{curator-drift-jpdfwae9.js → curator-drift-20m2ab5w.js} +6 -6
  12. package/dist/cli/curator-llm-factory-2gv6kt1v.js +71 -0
  13. package/dist/cli/{dispatch-591v13pp.js → dispatch-tmb929w8.js} +2 -2
  14. package/dist/cli/{evidence-summary-service-mw6tnsp9.js → evidence-summary-service-5th3zm9c.js} +17 -17
  15. package/dist/cli/{gate-evidence-jymaxb82.js → gate-evidence-py8v0w28.js} +9 -8
  16. package/dist/cli/guardrail-explain-qzhjhtyk.js +72 -0
  17. package/dist/cli/{guardrail-log-kzq2sktb.js → guardrail-log-rtdpk545.js} +9 -9
  18. package/dist/cli/{guardrail-reset-ea1g3g7d.js → guardrail-reset-s27fehv6.js} +40 -39
  19. package/dist/cli/{hive-promoter-ghjbgsms.js → hive-promoter-56mfysq6.js} +40 -39
  20. package/dist/cli/{index-52xdezsh.js → index-0jpv5z94.js} +5 -5
  21. package/dist/cli/{index-8hqkrd2j.js → index-1aex5zd9.js} +1 -1
  22. package/dist/cli/{index-6chhqq2n.js → index-251vrmge.js} +94 -3
  23. package/dist/cli/{index-w11whwn3.js → index-2c7eabkr.js} +9 -9
  24. package/dist/cli/{index-edm41q4j.js → index-2w0beg3s.js} +2 -2
  25. package/dist/cli/{index-nph5g4em.js → index-3a2xznmd.js} +2 -2
  26. package/dist/cli/{index-2y4kargd.js → index-3f1tr4ha.js} +4 -4
  27. package/dist/cli/{index-xezfx7ge.js → index-3nm1b3t2.js} +47 -13
  28. package/dist/cli/{index-gr8ppbq3.js → index-4c50tm9j.js} +3 -3
  29. package/dist/cli/{index-wf12wckd.js → index-4mgggb8x.js} +8 -3
  30. package/dist/cli/{index-17yszqs5.js → index-5bd84nxc.js} +1 -1
  31. package/dist/cli/{index-jx9f4ke1.js → index-6d4dc99f.js} +1 -1
  32. package/dist/cli/{index-79sr3fd1.js → index-75f9jj3h.js} +2 -2
  33. package/dist/cli/{index-ybcxvv17.js → index-87wqes24.js} +2 -2
  34. package/dist/cli/{index-bkd3450m.js → index-8cky7ksv.js} +36 -10
  35. package/dist/cli/{index-1zqf2pny.js → index-9wv6a3jx.js} +2 -2
  36. package/dist/cli/{index-fc1dqzjp.js → index-b7ra4hwj.js} +1 -1
  37. package/dist/cli/{index-6rff2h8x.js → index-bwvbj3fp.js} +4 -4
  38. package/dist/cli/{index-j29nkq5d.js → index-ch293kd3.js} +4 -4
  39. package/dist/cli/{index-gerkwyrr.js → index-d5gvr6z4.js} +1 -1
  40. package/dist/cli/{index-399nq780.js → index-dvhecfa9.js} +3839 -3182
  41. package/dist/cli/{index-hwj25q9r.js → index-f6zgz02s.js} +70 -53
  42. package/dist/cli/{index-3tyym20r.js → index-gbv76wf7.js} +2 -2
  43. package/dist/cli/{index-8fr2wn18.js → index-gk1w1h9k.js} +5 -1
  44. package/dist/cli/{index-13egyjgv.js → index-h92cqbqa.js} +5 -5
  45. package/dist/cli/{index-k5w284js.js → index-hfrb77tj.js} +17 -17
  46. package/dist/cli/{index-gy0nyfbw.js → index-m21x1bkx.js} +78 -25
  47. package/dist/cli/{index-hvk3zs62.js → index-m3tx1q9v.js} +1 -1
  48. package/dist/cli/{index-xwkn5hse.js → index-ms16gaa4.js} +7 -7
  49. package/dist/cli/{index-066xxa4q.js → index-qa7t42e7.js} +96 -31
  50. package/dist/cli/{index-2v17wb75.js → index-qd619x3r.js} +2 -2
  51. package/dist/cli/{index-axf65x87.js → index-qd726agw.js} +5 -5
  52. package/dist/cli/{index-c20gf089.js → index-qww0h314.js} +11 -6
  53. package/dist/cli/{index-aftapk6j.js → index-rk10x4zr.js} +3 -3
  54. package/dist/cli/{index-bfr392e7.js → index-sahf5yz3.js} +13 -6
  55. package/dist/cli/{index-a7rw4g4s.js → index-t8tw1bhs.js} +3 -3
  56. package/dist/cli/{index-0g5v4s0x.js → index-t9kjxzdr.js} +14 -14
  57. package/dist/cli/{index-zha9bdj9.js → index-tzq6t9wc.js} +11 -11
  58. package/dist/cli/index-vzm6zre7.js +167 -0
  59. package/dist/cli/{index-crjx4sx0.js → index-w50dk71y.js} +42 -41
  60. package/dist/cli/{index-yt25kpvz.js → index-xn16akay.js} +4 -4
  61. package/dist/cli/index.js +40 -39
  62. package/dist/cli/{knowledge-escalator-3pjed4tq.js → knowledge-escalator-stnveccq.js} +15 -14
  63. package/dist/cli/{knowledge-events-a5dwkg30.js → knowledge-events-ph6txm8h.js} +12 -12
  64. package/dist/cli/{knowledge-link-1zykfk1p.js → knowledge-link-w1fwqts4.js} +6 -4
  65. package/dist/cli/{knowledge-store-h85efsak.js → knowledge-store-tgyhr9nf.js} +10 -5
  66. package/dist/cli/{knowledge-validator-76qrf1ev.js → knowledge-validator-2g547bcn.js} +10 -7
  67. package/dist/cli/{pending-delegations-zgwfqfac.js → pending-delegations-873dtyw6.js} +14 -13
  68. package/dist/cli/{pr-subscriptions-fzy3ks1k.js → pr-subscriptions-xmxdrj1z.js} +20 -13
  69. package/dist/cli/{pr-workflow-gate-1gtsn7f0.js → pr-workflow-gate-h7644byf.js} +40 -39
  70. package/dist/cli/{runner-j3acybhs.js → runner-nmrjv7te.js} +8 -5
  71. package/dist/cli/{scan-cursor-ahwkxa8j.js → scan-cursor-tx72gxp0.js} +9 -6
  72. package/dist/cli/{schema-27sedbfk.js → schema-cpc92vq0.js} +4 -2
  73. package/dist/cli/{scope-persistence-q792yfxh.js → scope-persistence-xy3xs55f.js} +17 -15
  74. package/dist/cli/{skill-generator-g8wbjw6v.js → skill-generator-4f1v5zwx.js} +17 -16
  75. package/dist/cli/{snapshot-coordination-init-y6spakwm.js → snapshot-coordination-init-w2nw33pn.js} +40 -39
  76. package/dist/cli/{telemetry-9h1z2w9d.js → telemetry-ce0tx41h.js} +5 -1
  77. package/dist/cli/{workspace-snapshot-6z9rk7xw.js → workspace-snapshot-0kxj2grt.js} +11 -1
  78. package/dist/cli/{worktree-collision-ownership-pmpnftkd.js → worktree-collision-ownership-1g1qz8wc.js} +15 -14
  79. package/dist/cli/{worktree-isolation-4053n0px.js → worktree-isolation-jwxtrh3z.js} +40 -39
  80. package/dist/commands/close.d.ts +82 -0
  81. package/dist/config/schema.d.ts +9 -0
  82. package/dist/context-map/capsule-persistence.d.ts +13 -8
  83. package/dist/evidence/phase-participation.d.ts +1 -1
  84. package/dist/hooks/delegate-ack-collector.d.ts +7 -0
  85. package/dist/hooks/guardrails/execution-stall.d.ts +10 -5
  86. package/dist/hooks/hive-promoter.d.ts +28 -5
  87. package/dist/hooks/knowledge-store.d.ts +7 -0
  88. package/dist/hooks/repo-graph-builder.d.ts +14 -0
  89. package/dist/hooks/review-receipt.d.ts +29 -1
  90. package/dist/hooks/system-enhancer.d.ts +21 -0
  91. package/dist/index.js +578 -573
  92. package/dist/knowledge/curation-policy.d.ts +7 -0
  93. package/dist/memory/consolidation-log.d.ts +9 -0
  94. package/dist/memory/injector.d.ts +7 -0
  95. package/dist/memory/run-log.d.ts +8 -0
  96. package/dist/observability/catalog.d.ts +1 -1
  97. package/dist/retention/caps.d.ts +33 -0
  98. package/dist/retention/dir-prune.d.ts +72 -0
  99. package/dist/retention/jsonl-cap.d.ts +84 -0
  100. package/dist/retention/sweep.d.ts +67 -0
  101. package/dist/services/compaction-service.d.ts +14 -0
  102. package/dist/services/skill-changelog.d.ts +20 -0
  103. package/dist/session/snapshot-writer.d.ts +42 -0
  104. package/dist/summaries/manager.d.ts +41 -4
  105. package/dist/telemetry.d.ts +31 -1
  106. package/dist/test-impact/history-store.d.ts +16 -0
  107. package/dist/turbo/epic/calibration.d.ts +16 -1
  108. package/dist/turbo/epic/divergence-recorder.d.ts +11 -0
  109. package/dist/utils/atomic-write.d.ts +32 -0
  110. package/dist/utils/swarm-artifact-cache.d.ts +6 -0
  111. package/opencode-swarm.schema.json +15 -0
  112. package/package.json +1 -1
  113. package/dist/cli/curator-llm-factory-da5q3gg6.js +0 -70
  114. package/dist/cli/guardrail-explain-eva1yrtf.js +0 -71
  115. package/dist/cli/{index-2sqgbmtq.js → index-d5qf7hvh.js} +3 -3
@@ -6,40 +6,41 @@ import {
6
6
  WORKTREE_PROVISIONING_OWNER_LEASE_MS,
7
7
  removeWorktreeProvisioningOwner,
8
8
  scanWorktreeProvisioningOwnersForRecovery
9
- } from "./index-1zqf2pny.js";
9
+ } from "./index-9wv6a3jx.js";
10
10
  import {
11
11
  scanDelegationFallbacksForRecovery,
12
12
  scanDelegationsForRecovery
13
- } from "./index-w11whwn3.js";
14
- import"./index-bfr392e7.js";
15
- import"./index-ee6ydtfe.js";
13
+ } from "./index-2c7eabkr.js";
14
+ import"./index-sahf5yz3.js";
16
15
  import {
17
16
  bunSpawn
18
17
  } from "./index-p612v1mv.js";
19
- import"./index-79sr3fd1.js";
20
- import"./index-jx9f4ke1.js";
21
- import"./index-aftapk6j.js";
18
+ import"./index-75f9jj3h.js";
19
+ import"./index-6d4dc99f.js";
20
+ import"./index-rk10x4zr.js";
22
21
  import"./index-ry16d01s.js";
23
22
  import"./index-n4fzmqz8.js";
24
- import"./index-axf65x87.js";
25
- import"./index-bkd3450m.js";
23
+ import"./index-qd726agw.js";
24
+ import"./index-8cky7ksv.js";
25
+ import"./index-vzm6zre7.js";
26
26
  import"./index-ae75rja9.js";
27
- import"./index-a7rw4g4s.js";
27
+ import"./index-t8tw1bhs.js";
28
+ import"./index-2w0beg3s.js";
29
+ import"./index-m21x1bkx.js";
30
+ import"./index-f6zgz02s.js";
28
31
  import {
29
32
  canonicalRootKeyFresh
30
33
  } from "./index-7qefgq4j.js";
31
- import"./index-edm41q4j.js";
32
- import"./index-gy0nyfbw.js";
33
- import"./index-hwj25q9r.js";
34
+ import"./index-ee6ydtfe.js";
34
35
  import"./index-7g4c7s5r.js";
35
36
  import {
36
37
  init_git_executable,
37
38
  resolveGitExecutable
38
39
  } from "./index-9e6fdz2h.js";
39
40
  import"./index-4rhhvd1a.js";
40
- import"./index-zpsr8rpc.js";
41
41
  import"./index-bk5tah7q.js";
42
42
  import"./index-bpmtbmy9.js";
43
+ import"./index-zpsr8rpc.js";
43
44
  import"./index-zgwm4ryv.js";
44
45
  import"./index-a76rekgs.js";
45
46
 
@@ -21,68 +21,69 @@ import {
21
21
  sanitizeWorktreeTaskId,
22
22
  standardWorktreeByCallID,
23
23
  standardWorktreeSerializationSessions
24
- } from "./index-399nq780.js";
25
- import"./index-2sqgbmtq.js";
26
- import"./index-hvk3zs62.js";
27
- import"./index-gr8ppbq3.js";
28
- import"./index-8fr2wn18.js";
29
- import"./index-0g5v4s0x.js";
30
- import"./index-17yszqs5.js";
24
+ } from "./index-dvhecfa9.js";
25
+ import"./index-d5qf7hvh.js";
26
+ import"./index-m3tx1q9v.js";
27
+ import"./index-4c50tm9j.js";
28
+ import"./index-gk1w1h9k.js";
29
+ import"./index-t9kjxzdr.js";
30
+ import"./index-5bd84nxc.js";
31
31
  import"./index-txdagbh7.js";
32
32
  import"./index-cw912re7.js";
33
- import"./index-066xxa4q.js";
34
- import"./index-13egyjgv.js";
35
- import"./index-ybcxvv17.js";
33
+ import"./index-qa7t42e7.js";
34
+ import"./index-h92cqbqa.js";
35
+ import"./index-87wqes24.js";
36
36
  import"./index-70ha9e09.js";
37
- import"./index-8hqkrd2j.js";
37
+ import"./index-1aex5zd9.js";
38
38
  import"./index-9ss2m4rs.js";
39
- import"./index-xezfx7ge.js";
39
+ import"./index-3nm1b3t2.js";
40
40
  import"./index-zsrtt42s.js";
41
- import"./index-k5w284js.js";
42
- import"./index-6chhqq2n.js";
43
- import"./index-1zqf2pny.js";
41
+ import"./index-hfrb77tj.js";
42
+ import"./index-251vrmge.js";
43
+ import"./index-9wv6a3jx.js";
44
44
  import"./index-b43rt5ph.js";
45
45
  import"./index-q7sjgr1y.js";
46
- import"./index-yt25kpvz.js";
47
- import"./index-fc1dqzjp.js";
48
- import"./index-w11whwn3.js";
49
- import"./index-zha9bdj9.js";
50
- import"./index-bfr392e7.js";
51
- import"./index-ee6ydtfe.js";
46
+ import"./index-xn16akay.js";
47
+ import"./index-b7ra4hwj.js";
48
+ import"./index-2c7eabkr.js";
49
+ import"./index-tzq6t9wc.js";
50
+ import"./index-sahf5yz3.js";
52
51
  import"./index-p612v1mv.js";
53
- import"./index-6rff2h8x.js";
54
- import"./index-c20gf089.js";
52
+ import"./index-bwvbj3fp.js";
53
+ import"./index-qww0h314.js";
55
54
  import"./index-rtry5xyf.js";
56
55
  import {
57
56
  resolveWorktreeIsolationConfig
58
- } from "./index-nph5g4em.js";
57
+ } from "./index-3a2xznmd.js";
59
58
  import"./index-3qf1vxtb.js";
60
59
  import"./index-n832052r.js";
61
- import"./index-xwkn5hse.js";
62
- import"./index-2y4kargd.js";
63
- import"./index-2v17wb75.js";
64
- import"./index-79sr3fd1.js";
65
- import"./index-jx9f4ke1.js";
66
- import"./index-aftapk6j.js";
60
+ import"./index-ms16gaa4.js";
61
+ import"./index-3f1tr4ha.js";
62
+ import"./index-qd619x3r.js";
63
+ import"./index-75f9jj3h.js";
64
+ import"./index-6d4dc99f.js";
65
+ import"./index-rk10x4zr.js";
67
66
  import"./index-ry16d01s.js";
68
67
  import"./index-n4fzmqz8.js";
69
- import"./index-axf65x87.js";
70
- import"./index-bkd3450m.js";
68
+ import"./index-qd726agw.js";
69
+ import"./index-8cky7ksv.js";
70
+ import"./index-vzm6zre7.js";
71
71
  import"./index-ae75rja9.js";
72
- import"./index-a7rw4g4s.js";
72
+ import"./index-t8tw1bhs.js";
73
+ import"./index-2w0beg3s.js";
74
+ import"./index-m21x1bkx.js";
75
+ import"./index-f6zgz02s.js";
73
76
  import"./index-7qefgq4j.js";
74
- import"./index-edm41q4j.js";
75
- import"./index-gy0nyfbw.js";
76
- import"./index-hwj25q9r.js";
77
+ import"./index-ee6ydtfe.js";
77
78
  import"./index-7g4c7s5r.js";
78
- import"./index-52xdezsh.js";
79
+ import"./index-0jpv5z94.js";
79
80
  import"./index-9e6fdz2h.js";
80
81
  import"./index-4rhhvd1a.js";
81
- import"./index-wf12wckd.js";
82
+ import"./index-4mgggb8x.js";
82
83
  import"./index-0tc0pcmh.js";
83
- import"./index-zpsr8rpc.js";
84
84
  import"./index-bk5tah7q.js";
85
85
  import"./index-bpmtbmy9.js";
86
+ import"./index-zpsr8rpc.js";
86
87
  import"./index-q1r1cfww.js";
87
88
  import"./index-yzjaj53h.js";
88
89
  import"./index-zgwm4ryv.js";
@@ -157,6 +157,77 @@ declare function countSessionKnowledgeEntries(entries: CloseKnowledgeEntry[], se
157
157
  * Use copyDirRecursiveWithFailures when per-file failure tracking is needed.
158
158
  */
159
159
  declare function copyDirRecursive(src: string, dest: string): Promise<number>;
160
+ /**
161
+ * Flat-file artifacts to include in the archive bundle.
162
+ * Each entry is a relative path under .swarm/.
163
+ *
164
+ * plan-ledger.jsonl is included so the archive bundle is a self-contained
165
+ * forensic snapshot of the session: the ledger holds the full audit trail of
166
+ * task state transitions and snapshot events that plan.json/plan.md don't
167
+ * preserve.
168
+ */
169
+ export declare const ARCHIVE_ARTIFACTS: string[];
170
+ /**
171
+ * Active-state flat files to clean after archiving so future swarms start clean.
172
+ *
173
+ * plan.json, plan.md, and plan-ledger.jsonl are all removed so the next /swarm
174
+ * session starts with a clean slate. The user's original ask for /swarm close
175
+ * was to "archive plan files so future swarms aren't confused" — leaving a
176
+ * terminal-state plan.json in place violates that invariant because the next
177
+ * session's loadPlan() would pick it up as if it were still active.
178
+ *
179
+ * CRITICAL: the ledger must also be removed. Without this, loadPlan()'s Step 4
180
+ * would see no plan.json but a surviving ledger, call replayFromLedger(), and
181
+ * materialize the CLOSED plan back into plan.json on the next session. The
182
+ * ledger is a second backing store for the same "terminal-state plan" and
183
+ * leaving it behind re-enables the exact bug this cleanup is meant to fix.
184
+ * The archive-first guard below ensures we only delete files we successfully
185
+ * copied to the archive bundle, so the audit trail is preserved in the bundle.
186
+ *
187
+ * knowledge-rejected.jsonl, repo-graph.json, doc-manifest.json,
188
+ * dark-matter.md, telemetry.jsonl, and swarm.db are
189
+ * session-generated artifacts that do not persist meaningfully across sessions —
190
+ * they are recreated on next session init and must be removed to avoid stale-state
191
+ * interference.
192
+ *
193
+ * The SQLite WAL sidecars swarm.db-shm and swarm.db-wal are deliberately NOT in
194
+ * either list (the archive-first guard would preserve them anyway): since #2483
195
+ * they are removed immediately AFTER the swarm.db unlink by
196
+ * removeSqliteSidecarsAfterClose, deliberately reversing #1692. Post-unlink the
197
+ * sidecar paths are meaningless for future opens (no new opener can attach),
198
+ * live processes keep their already-open fds so deleting the PATH cannot
199
+ * corrupt them, and a Windows open-handle collision yields EBUSY which the
200
+ * helper skips fail-open.
201
+ *
202
+ * Note: knowledge.jsonl is intentionally NOT cleaned because it contains cumulative
203
+ * project knowledge (lessons learned) that should persist across sessions and finalize
204
+ * cycles. The archive step still creates a backup for safety.
205
+ * close-summary.md is NOT cleaned because it is written as the final close output
206
+ * AFTER the clean stage runs. spec.md IS cleaned: it is single-session state coupled
207
+ * to the plan lifecycle (the plan it produced is removed above), so leaving it behind
208
+ * makes the next session pick up a stale spec via readEffectiveSpecSync and mis-route
209
+ * the architect into CLARIFY-SPEC/overwrite prompts. It is archived first (archive-first
210
+ * guard), so the forensic copy is preserved in the bundle. The earlier "spec.md may not
211
+ * exist" rationale was wrong — handoff.md is equally optional and is cleaned the same way.
212
+ * session-reflection.md is a single-session snapshot (not cumulative like
213
+ * knowledge.jsonl) so it IS cleaned to maintain the clean-slate invariant.
214
+ * spec-staleness.json and spec-snapshot.md are the same class of single-session
215
+ * spec-drift state as spec.md. spec-staleness.json is an existence-only gate
216
+ * checked unconditionally by enforceSpecDriftGate, which hard-blocks the core
217
+ * write tools (save_plan, update_task_status, phase_complete,
218
+ * lean_turbo_run_phase, lean_turbo_acquire_locks) with SPEC_DRIFT_BLOCK — a
219
+ * survivor would block the NEXT session against drift that no longer applies.
220
+ * spec-snapshot.md is its companion diff source, feeding the mismatch shown in
221
+ * the SPEC_DRIFT_BLOCK message. Both are archived first (archive-first guard),
222
+ * then cleaned so the next session starts drift-free.
223
+ */
224
+ export declare const ACTIVE_STATE_TO_CLEAN: string[];
225
+ /**
226
+ * Active-state directories to archive and clean after archiving.
227
+ * These contain session-generated data that must be removed so future
228
+ * swarms start clean. Each entry is a relative path under .swarm/.
229
+ */
230
+ export declare const ACTIVE_STATE_DIRS_TO_CLEAN: string[];
160
231
  /**
161
232
  * Guarantee all phases and tasks in a plan are marked complete/closed.
162
233
  * Mutates planData in place. Returns actual IDs of newly closed phases and
@@ -226,6 +297,16 @@ export declare function runArchiveEvidenceRetention(ctx: ArchiveStageContext): P
226
297
  * 375 ms so `/swarm close` remains responsive.
227
298
  */
228
299
  declare function unlinkActiveStateFileWithRetry(filePath: string): Promise<void>;
300
+ /**
301
+ * Remove the SQLite WAL sidecars (swarm.db-wal / swarm.db-shm) immediately
302
+ * after the clean stage unlinks swarm.db (#2483, deliberately reversing the
303
+ * #1692 preserve decision): once the main db is unlinked the sidecar paths
304
+ * are meaningless for future opens — no new opener can attach — and live
305
+ * processes keep their already-open fds, so deleting the PATH cannot corrupt
306
+ * them. Best-effort and per-file fail-open: ENOENT (already gone) and EBUSY
307
+ * (Windows open-handle collision) are skipped silently.
308
+ */
309
+ export declare function removeSqliteSidecarsAfterClose(swarmDir: string): void;
229
310
  export declare function runCleanStage(ctx: CloseStageContext): Promise<CleanStageResult>;
230
311
  /**
231
312
  * STAGE 4: ALIGN
@@ -282,6 +363,7 @@ export declare const _internals: {
282
363
  closeRepoMemory: typeof closeRepoMemory;
283
364
  unlinkActiveStateFileWithRetry: typeof unlinkActiveStateFileWithRetry;
284
365
  unlink: typeof fsSync.promises.unlink;
366
+ unlinkSidecarSync: typeof fsSync.unlinkSync;
285
367
  sleep: typeof sleep;
286
368
  collectGarbageBestEffort: typeof collectGarbageBestEffort;
287
369
  ACTIVE_STATE_DIRS_TO_CLEAN: string[];
@@ -445,6 +445,11 @@ export declare const SummaryConfigSchema: z.ZodObject<{
445
445
  exempt_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
446
446
  }, z.core.$strip>;
447
447
  export type SummaryConfig = z.infer<typeof SummaryConfigSchema>;
448
+ export declare const RetentionConfigSchema: z.ZodPrefault<z.ZodObject<{
449
+ enabled: z.ZodDefault<z.ZodBoolean>;
450
+ dry_run: z.ZodDefault<z.ZodBoolean>;
451
+ }, z.core.$strip>>;
452
+ export type RetentionConfig = z.infer<typeof RetentionConfigSchema>;
448
453
  export declare const ReviewPassesConfigSchema: z.ZodObject<{
449
454
  always_security_review: z.ZodDefault<z.ZodBoolean>;
450
455
  security_globs: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -2218,6 +2223,10 @@ export declare const PluginConfigSchema: z.ZodObject<{
2218
2223
  retention_days: z.ZodDefault<z.ZodNumber>;
2219
2224
  exempt_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
2220
2225
  }, z.core.$strip>>;
2226
+ retention: z.ZodPrefault<z.ZodObject<{
2227
+ enabled: z.ZodDefault<z.ZodBoolean>;
2228
+ dry_run: z.ZodDefault<z.ZodBoolean>;
2229
+ }, z.core.$strip>>;
2221
2230
  review_passes: z.ZodOptional<z.ZodObject<{
2222
2231
  always_security_review: z.ZodDefault<z.ZodBoolean>;
2223
2232
  security_globs: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -29,6 +29,7 @@ export declare const _internals: {
29
29
  readonly existsSync: typeof fs.existsSync;
30
30
  readonly mkdirSync: typeof fs.mkdirSync;
31
31
  readonly readdirSync: typeof fs.readdirSync;
32
+ readonly statSync: fs.StatSyncFn;
32
33
  readonly unlinkSync: typeof fs.unlinkSync;
33
34
  readonly renameSync: typeof fs.renameSync;
34
35
  };
@@ -50,17 +51,21 @@ export declare function saveCapsule(capsule: ContextCapsule, directory: string):
50
51
  */
51
52
  export declare function loadCapsule(taskId: string, directory: string): ContextCapsule | null;
52
53
  /**
53
- * Delete a capsule from `.swarm/capsules/{task_id}.json`.
54
- *
55
- * Returns `true` if the file was deleted, `false` if it didn't exist.
56
- * Never throws.
54
+ * Listing cap for `.swarm/capsules/` enumeration (issue #2483 §2, R12): the
55
+ * list returns NEWEST-first (mtime descending, code-unit filename
56
+ * tie-break never localeCompare) and is capped, so every listing read is
57
+ * O(cap), not O(unbounded capsule history). The effective value resolves
58
+ * through `resolveRetentionCap` so the #2483 acceptance checks can shrink it.
57
59
  */
58
- export declare function deleteCapsule(taskId: string, directory: string): boolean;
60
+ export declare const MAX_CAPSULES_LISTED = 500;
59
61
  /**
60
- * List all saved capsule task IDs in `.swarm/capsules/`.
62
+ * List saved capsule task IDs in `.swarm/capsules/`, newest-first.
61
63
  *
62
64
  * Returns an array of task IDs derived from filenames (stripping the
63
- * `.json` extension). Returns an empty array if the directory doesn't
64
- * exist. Never throws.
65
+ * `.json` extension), ordered by capsule file mtime descending (code-unit
66
+ * filename tie-break) and capped at {@link MAX_CAPSULES_LISTED} entries.
67
+ * A capsule whose file cannot be `stat`-ed sorts oldest (fail-open per
68
+ * entry). Returns an empty array if the directory doesn't exist. Never
69
+ * throws.
65
70
  */
66
71
  export declare function listCapsules(directory: string): string[];
@@ -40,5 +40,5 @@ export declare function completeBackgroundPhaseParticipation(input: {
40
40
  record: BackgroundDelegationRecord;
41
41
  resultText: string;
42
42
  }): Promise<boolean>;
43
- export declare function readPhaseParticipation(directory: string, plan: Plan, phase: number, role: string): ParticipationReadResult;
43
+ export declare function readPhaseParticipation(directory: string, plan: Plan, phase: number, role: string): Promise<ParticipationReadResult>;
44
44
  export declare function resetPhaseParticipationForTests(): void;
@@ -39,6 +39,13 @@ export interface DelegateAckOutput {
39
39
  }
40
40
  /** Best-effort extraction of a task id from a delegation prompt envelope. */
41
41
  export declare function resolveDelegateAckTaskId(args: Record<string, unknown>, knownPlanTaskIds?: ReadonlySet<string>, planContextOverLimit?: boolean): string | undefined;
42
+ /**
43
+ * Global FIFO cap on the unacknowledged-criticals audit stream (issue #2483
44
+ * §2). Enforcement resolves the effective value through `resolveRetentionCap`
45
+ * so the #2483 acceptance checks can shrink the cap below this default and
46
+ * prove the writer clamps.
47
+ */
48
+ export declare const MAX_UNACKNOWLEDGED_CRITICALS = 500;
42
49
  export interface CollectDelegateAcksResult {
43
50
  emitted: Array<{
44
51
  id: string;
@@ -92,7 +92,7 @@
92
92
  * escalates to the STOP directive.
93
93
  */
94
94
  import type { BackgroundWorkspaceSnapshot } from '../../background/pending-delegations.js';
95
- import { captureWorkspaceSnapshot, changedFilesSinceSnapshot } from '../../background/workspace-snapshot.js';
95
+ import { captureWorkspaceSnapshotAsync, changedFilesSinceSnapshotAsync } from '../../background/workspace-snapshot.js';
96
96
  /** Default advisory rung (mirrors `guardrails.execution_stall_warn_calls`). */
97
97
  export declare const DEFAULT_EXECUTION_STALL_WARN_CALLS = 30;
98
98
  /** Default hard rung (mirrors `guardrails.execution_stall_stop_calls`). */
@@ -251,6 +251,9 @@ export declare function enforceExecutionStallDenial(params: {
251
251
  * `tool.execute.after`. Records progress events, arms on a successful
252
252
  * `update_task_status(in_progress)`, and runs the periodic workspace probe.
253
253
  * NEVER throws.
254
+ *
255
+ * Async (issue #2472 W7): the workspace captures route through the async
256
+ * snapshot twin, so callers (guardrails' `toolAfter`) must await it.
254
257
  */
255
258
  export declare function recordExecutionStallToolAfter(params: {
256
259
  sessionID: string;
@@ -260,18 +263,20 @@ export declare function recordExecutionStallToolAfter(params: {
260
263
  output: unknown;
261
264
  directory: string;
262
265
  options?: ExecutionStallOptions;
263
- }): void;
266
+ }): Promise<void>;
264
267
  /**
265
268
  * Test/DI seam (AGENTS.md invariant 7). `now` is the fake-clock seam the
266
269
  * idleness-lapse tests drive; the two workspace functions are indirected so a
267
270
  * test never spawns git, and `readPlanOpenTaskState` so a test can drive the
268
271
  * disarm edge without a plan fixture (the disarm tests exercise the REAL reader
269
- * against a real `.swarm/plan.json` as well).
272
+ * against a real `.swarm/plan.json` as well). The capture seam carries the
273
+ * ASYNC twin (issue #2472 W7) — hook paths must never reach the sync
274
+ * spawn-based capture.
270
275
  */
271
276
  export declare const _internals: {
272
277
  now: () => number;
273
- captureWorkspaceSnapshot: typeof captureWorkspaceSnapshot;
274
- changedFilesSinceSnapshot: typeof changedFilesSinceSnapshot;
278
+ captureWorkspaceSnapshotAsync: typeof captureWorkspaceSnapshotAsync;
279
+ changedFilesSinceSnapshotAsync: typeof changedFilesSinceSnapshotAsync;
275
280
  ensureArchitectSession: typeof ensureArchitectSession;
276
281
  readPlanOpenTaskState: typeof readPlanOpenTaskState;
277
282
  };
@@ -21,7 +21,7 @@
21
21
  * This module is NOT imported on the plugin-init path (invariant 1): promotion
22
22
  * runs only on the lazy `/swarm promote`, close, curate, and postmortem paths.
23
23
  */
24
- import { resolveCohortId } from '../knowledge/cohort-identity.js';
24
+ import type { CohortIdentity } from '../knowledge/cohort-identity.js';
25
25
  import { authorizeCuration } from '../knowledge/curation-policy.js';
26
26
  import { appendCuratorRecommendation, readCuratorSummary } from './curator.js';
27
27
  import { transactHiveStore } from './hive-transaction.js';
@@ -65,19 +65,21 @@ export declare function countDistinctProjects(confirmedBy: ProjectConfirmationRe
65
65
  * new canonical-cohort confirmations. Returns a summary for curator state.
66
66
  *
67
67
  * `directory` is required (#1847) to resolve the canonical cohort identity
68
- * (#1846) for cross-project distinctness.
68
+ * (#1846) for cross-project distinctness. `sessionID` (#2472 W2) is optional:
69
+ * when present, cohort resolution reuses the session's cached cohort id (see
70
+ * the `_internals.resolveCohortId` default).
69
71
  *
70
72
  * @note The 'hive-fast-track' tag is privileged — it bypasses the 3-phase
71
73
  * confirmation requirement inside the eligibility_route gate. It should only
72
74
  * be set by authorized tooling (inferTags() never produces it automatically).
73
75
  */
74
- export declare function checkHivePromotions(swarmEntries: SwarmKnowledgeEntry[], config: KnowledgeConfig, directory: string): Promise<HivePromotionSummary>;
76
+ export declare function checkHivePromotions(swarmEntries: SwarmKnowledgeEntry[], config: KnowledgeConfig, directory: string, sessionID?: string): Promise<HivePromotionSummary>;
75
77
  export declare const _internals: {
76
78
  readSwarmEntries: (directory: string) => Promise<SwarmKnowledgeEntry[]>;
77
79
  checkHivePromotions: typeof checkHivePromotions;
78
80
  readCuratorSummary: typeof readCuratorSummary;
79
81
  appendCuratorRecommendation: typeof appendCuratorRecommendation;
80
- resolveCohortId: typeof resolveCohortId;
82
+ resolveCohortId: (directory: string, sessionID?: string) => Promise<CohortIdentity>;
81
83
  transactHiveStore: typeof transactHiveStore;
82
84
  validateLesson: typeof validateLesson;
83
85
  authorizeCuration: typeof authorizeCuration;
@@ -146,10 +148,31 @@ export declare const _internals: {
146
148
  synonym_map_max_pairs: number;
147
149
  } | undefined;
148
150
  };
151
+ /** #2472 W2 cadence clock (PRR-021 DI seam, invariant 7): the promotion
152
+ * cadence floor reads time through this seam so tests can advance the
153
+ * 60s floor deterministically without real sleeping or raw wall-clock
154
+ * polling. Everything else (entry timestamps, audit timestamps) stays on
155
+ * `new Date().toISOString()` — only the cadence decision is time-driven
156
+ * control flow. */
157
+ now: () => number;
158
+ /** Test-only: clears the #2472 W2 hook-gating state (per-directory cadence
159
+ * map + curator-migration guard). Production code never calls this; it
160
+ * exists so test files sharing one Bun process start from a clean slate. */
161
+ resetPromoterGatingState: () => void;
149
162
  };
150
163
  /**
151
164
  * Create a hook that promotes swarm entries to the hive.
152
- * The hook fires unconditionally - the caller decides when to invoke it.
165
+ *
166
+ * #2472 W2 gating — the hook self-gates instead of running unconditionally:
167
+ * 1. Write-class tools only (`PROMOTER_WRITE_TOOL_NAMES`): a read-only tool
168
+ * call returns before even the swarm-store read.
169
+ * 2. Empty-candidates gate: when no swarm entry has ACTIVE status the hook
170
+ * returns BEFORE cohort resolution, evidence loading, the hive
171
+ * transaction, and the curator-summary read. The one-time legacy
172
+ * curator-summary migration read stays reachable — at most once per
173
+ * directory per process (critic Round 2 item 1).
174
+ * 3. Cadence floor: a second qualifying invocation inside
175
+ * `PROMOTION_CADENCE_FLOOR_MS` returns before the promotion body.
153
176
  */
154
177
  export declare function createHivePromoterHook(directory: string, config: KnowledgeConfig): (input: unknown, output: unknown) => Promise<void>;
155
178
  /** Options for manual promotion (override semantics, #1847 §4). */
@@ -29,6 +29,13 @@ export interface KnowledgeRetractionRecord {
29
29
  matched_swarm_ids: string[];
30
30
  matched_hive_ids: string[];
31
31
  }
32
+ /**
33
+ * Global FIFO cap on the retraction audit stream (issue #2483 §2). Enforcement
34
+ * resolves the effective value through {@link resolveRetentionCap} so the
35
+ * #2483 acceptance checks can shrink the cap below this default and prove the
36
+ * writer clamps.
37
+ */
38
+ export declare const MAX_RETRACTION_RECORDS = 500;
32
39
  export declare function readRetractionRecords(directory: string): Promise<KnowledgeRetractionRecord[]>;
33
40
  export declare function appendRetractionRecord(directory: string, record: KnowledgeRetractionRecord): Promise<void>;
34
41
  /**
@@ -14,6 +14,14 @@
14
14
  * the async builder, yields to the event loop before doing any work, and
15
15
  * exposes the init promise so `toolAfter` can serialize incremental
16
16
  * updates after the initial scan completes.
17
+ *
18
+ * Issue #2472 (REPOGRAPH-1): `toolAfter` runs its entire cheap synchronous
19
+ * filter chain (enabled flag, write-tool membership, path extraction and
20
+ * validation, exclude-dir scoping) BEFORE awaiting the init promise, so a
21
+ * non-write tool call settles immediately even while the startup scan is
22
+ * pending — only write tools that will actually mutate the graph wait for
23
+ * the scan. The startup scan itself is bounded by an overall wall-clock
24
+ * budget (STARTUP_SCAN_BUDGET_MS) that resolves fail-open on timeout.
17
25
  */
18
26
  import { type BuildWorkspaceGraphOptions, type RepoGraph } from '../tools/repo-graph';
19
27
  import { type FreshnessOptions, type FreshnessProbe } from '../tools/repo-graph/freshness';
@@ -51,6 +59,12 @@ export interface RepoGraphBuilderOptions {
51
59
  maxFiles?: number;
52
60
  walkBudgetMs?: number;
53
61
  excludeDirs?: readonly string[];
62
+ /**
63
+ * Overall wall-clock budget (ms) for the startup scan (issue #2472).
64
+ * Defaults to STARTUP_SCAN_BUDGET_MS. Additive DI/test knob so the
65
+ * fail-open timeout path can be exercised without waiting 30 s.
66
+ */
67
+ scanBudgetMs?: number;
54
68
  }
55
69
  /**
56
70
  * Rebase a realpath'd file onto the lexical workspace root so the incremental
@@ -224,6 +224,25 @@ export declare function persistReviewReceipt(directory: string, receipt: ReviewR
224
224
  * orphan file, never a dangling index entry that points at missing evidence.
225
225
  */
226
226
  export declare function removeReviewReceipt(directory: string, receiptPath: string, receiptId: string): Promise<void>;
227
+ export interface PruneDanglingReceiptIndexEntriesOptions {
228
+ /** Count dangling entries without rewriting the index (sweep dry-run). */
229
+ dryRun?: boolean;
230
+ }
231
+ /**
232
+ * Drop index entries whose receipt file no longer exists (issue #2483).
233
+ *
234
+ * The retention sweep prunes receipt FILES by age/count; without this pass
235
+ * the manifest keeps naming pruned evidence forever. Entries whose
236
+ * `filename` is not a bare basename (the poisoned-entry class the read path
237
+ * already refuses) count as dangling and are dropped with the rest.
238
+ *
239
+ * The rewrite is atomic (temp+rename via {@link writeReceiptIndex}) under
240
+ * the same `_indexLockChain` as appends, so an interleaved append is never
241
+ * lost. Returns the number of entries dropped (or, with `dryRun`, the
242
+ * number that WOULD be dropped). A missing/unparseable index, or a receipts
243
+ * directory that does not exist, is a 0 — this helper never creates state.
244
+ */
245
+ export declare function pruneDanglingReceiptIndexEntries(directory: string, options?: PruneDanglingReceiptIndexEntriesOptions): Promise<number>;
227
246
  /**
228
247
  * Atomically attach independent finding-validation results to an existing
229
248
  * receipt. The receipt identity and index entry remain unchanged.
@@ -238,9 +257,18 @@ export declare function readReceiptById(directory: string, receiptId: string): P
238
257
  * Useful for drift verification to find prior reviews of the same scope.
239
258
  */
240
259
  export declare function readReceiptsByScopeHash(directory: string, scopeHash: string): Promise<ReviewReceipt[]>;
260
+ /**
261
+ * Read cap for the receipts index reader (issue #2483 §2, R12): the index is
262
+ * append-ordered (newest last), so bounding the read to the LAST
263
+ * {@link MAX_RECEIPTS_READ} entries keeps every read O(cap) while still
264
+ * returning the newest receipts. The effective value resolves through
265
+ * `resolveRetentionCap` so the #2483 acceptance checks can shrink it.
266
+ */
267
+ export declare const MAX_RECEIPTS_READ = 1000;
241
268
  /**
242
269
  * Read all receipts from the index (all verdicts, latest first).
243
- * Useful for drift verification context.
270
+ * Useful for drift verification context. Bounded to the newest
271
+ * {@link MAX_RECEIPTS_READ} index entries (see the constant's docblock).
244
272
  */
245
273
  export declare function readAllReceipts(directory: string): Promise<ReviewReceipt[]>;
246
274
  /**
@@ -40,6 +40,27 @@ declare function maybeAppendSpecDriftAdvisory(output: {
40
40
  * Returns null if no valid retrospective found.
41
41
  */
42
42
  export declare function buildRetroInjection(directory: string, currentPhaseNumber: number, currentPlanTitle?: string): Promise<string | null>;
43
+ /**
44
+ * #2472 W4 (PR #2588 bot finding 7): dispose fence for a project root's
45
+ * deferred maintenance scans. Called best-effort from the plugin's
46
+ * `dispose` so a scheduled-but-not-yet-fired (or in-flight) doc-index /
47
+ * dark-matter background task cannot fire into — or keep writing `.swarm`
48
+ * artifacts for — a project whose plugin instance is being torn down.
49
+ *
50
+ * (i) Future scheduling for `directory` is suppressed: the resolved root
51
+ * is added to `cancelledDeferredScanDirs`, and
52
+ * `scheduleDeferredMaintenanceScans` is a no-op for cancelled roots.
53
+ * (ii) Any already-scheduled or in-flight task for `directory` aborts:
54
+ * the root's deferred-scan generation is bumped, and every task
55
+ * captured the pre-bump value and re-checks it before its first
56
+ * statement and before each major scan step, so even a long-running
57
+ * dark-matter git scan stops before its next write.
58
+ *
59
+ * A NEW system-enhancer instance created for the same directory (plugin
60
+ * re-init — the restart-safe lifecycle of issue #2472) removes the
61
+ * cancellation marker, so fresh instances schedule scans normally again.
62
+ */
63
+ export declare function cancelDeferredMaintenanceScans(directory: string): void;
43
64
  /**
44
65
  * Creates the experimental.chat.system.transform hook for system enhancement.
45
66
  */