opencode-swarm 7.163.1 → 7.164.0

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 (87) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/{coder-settlement-f1gtvcy8.js → coder-settlement-84je6bza.js} +8 -8
  3. package/dist/cli/{config-doctor-0fnqzqz1.js → config-doctor-vfze38e1.js} +2 -2
  4. package/dist/cli/{core-w81fk5sc.js → core-q5hv8e2w.js} +1 -1
  5. package/dist/cli/{curation-policy-j12j2gvc.js → curation-policy-a2zty4br.js} +5 -5
  6. package/dist/cli/{curator-as495r18.js → curator-4pckmmyf.js} +32 -32
  7. package/dist/cli/{curator-drift-g6w4ga1q.js → curator-drift-wy7ejcvw.js} +105 -37
  8. package/dist/cli/{curator-llm-factory-v8vwz20c.js → curator-llm-factory-msbj3hpn.js} +32 -32
  9. package/dist/cli/{evidence-summary-service-51dxfcn5.js → evidence-summary-service-b15yes21.js} +14 -14
  10. package/dist/cli/{gate-evidence-nb1e8hz0.js → gate-evidence-70h0w4tb.js} +5 -5
  11. package/dist/cli/{guardrail-explain-z2qb6v67.js → guardrail-explain-kksdy032.js} +33 -33
  12. package/dist/cli/{guardrail-log-2kwntcqw.js → guardrail-log-7rxbd20p.js} +6 -6
  13. package/dist/cli/{guardrail-reset-mrxrc56j.js → guardrail-reset-3b4gs357.js} +32 -32
  14. package/dist/cli/{hive-promoter-c62x2ncb.js → hive-promoter-s80g1gwb.js} +32 -32
  15. package/dist/cli/index-0515j0cz.js +403 -0
  16. package/dist/cli/{index-ma52g2pq.js → index-12f1tsn2.js} +3 -3
  17. package/dist/cli/{index-2zgjcmmc.js → index-1b1h770t.js} +3 -3
  18. package/dist/cli/{index-9ss2m4rs.js → index-1hpjwz3s.js} +410 -1
  19. package/dist/cli/{index-kvra3nv1.js → index-1z4jzwja.js} +3 -3
  20. package/dist/cli/{index-0103w5pf.js → index-2s4s9n82.js} +2 -2
  21. package/dist/cli/{index-9crtmnqg.js → index-36nt17m8.js} +1 -1
  22. package/dist/cli/{index-g3znh2yd.js → index-4afh2cz7.js} +5 -5
  23. package/dist/cli/{index-2n1ym7jb.js → index-4jersar8.js} +4 -4
  24. package/dist/cli/{index-n67vx5zw.js → index-70bfj3v1.js} +1 -1
  25. package/dist/cli/{index-zjme8atd.js → index-7r9vpkwa.js} +4 -4
  26. package/dist/cli/{index-8ada7ag7.js → index-93sepnc9.js} +2 -2
  27. package/dist/cli/{index-qynqyfgj.js → index-9sy65e94.js} +3 -3
  28. package/dist/cli/{index-f923njwh.js → index-bm73pych.js} +6 -6
  29. package/dist/cli/{index-xyhmt813.js → index-c4pynht5.js} +1 -1
  30. package/dist/cli/{index-m1fvbah1.js → index-c69jbpex.js} +2 -2
  31. package/dist/cli/{index-t34daffb.js → index-e3hwzcjv.js} +2 -2
  32. package/dist/cli/{index-r56f3f81.js → index-g64154pd.js} +1 -1
  33. package/dist/cli/{index-08y8pccg.js → index-gxd8fwyt.js} +4 -4
  34. package/dist/cli/{index-d3azve4r.js → index-hyq20s2v.js} +118 -296
  35. package/dist/cli/{index-7n9jznv0.js → index-ma8w6pfp.js} +3 -3
  36. package/dist/cli/{index-tnpf9wwv.js → index-nhxaa9j5.js} +1 -1
  37. package/dist/cli/{index-d9gdwh34.js → index-nzrhw31r.js} +1 -1
  38. package/dist/cli/{index-n985274d.js → index-pvgcex0d.js} +3 -3
  39. package/dist/cli/{index-etvq73mp.js → index-qkk2skff.js} +34 -34
  40. package/dist/cli/{index-2v06a1yh.js → index-t5t82jy8.js} +5 -5
  41. package/dist/cli/{index-5056zmpt.js → index-t90gjc0k.js} +1 -1
  42. package/dist/cli/{index-66073kej.js → index-t9rhtvy9.js} +2 -2
  43. package/dist/cli/{index-hm239n1p.js → index-tb1k8jya.js} +1 -1
  44. package/dist/cli/{index-x2f1f011.js → index-td6n935w.js} +3 -2
  45. package/dist/cli/{index-swgy9xvk.js → index-v3a9rmyh.js} +3 -3
  46. package/dist/cli/{index-cqgpvx2d.js → index-wdtckfnf.js} +1 -1
  47. package/dist/cli/{index-0tervb1m.js → index-xk0kc1py.js} +522 -358
  48. package/dist/cli/{index-n2mhyect.js → index-ynqp3jb6.js} +1 -1
  49. package/dist/cli/{index-n249fbw7.js → index-zaab1wz9.js} +5 -0
  50. package/dist/cli/{index-4p0wyz5p.js → index-zbpcpsk0.js} +8 -8
  51. package/dist/cli/index.js +32 -32
  52. package/dist/cli/{knowledge-escalator-fq7dm2g4.js → knowledge-escalator-sttdnwf8.js} +11 -11
  53. package/dist/cli/{knowledge-events-3zanyfkr.js → knowledge-events-4h88stj7.js} +9 -9
  54. package/dist/cli/{knowledge-link-vmdj5e5d.js → knowledge-link-yykmxdyw.js} +4 -4
  55. package/dist/cli/{knowledge-store-vhehnw52.js → knowledge-store-j832fxpx.js} +5 -5
  56. package/dist/cli/{knowledge-validator-0tt0pe6b.js → knowledge-validator-edbg761g.js} +7 -7
  57. package/dist/cli/{pending-delegations-b92pecbj.js → pending-delegations-sphntrs0.js} +4 -4
  58. package/dist/cli/{pr-subscriptions-2mkdt0ak.js → pr-subscriptions-1a4gcnzv.js} +4 -4
  59. package/dist/cli/{runner-3gw2njnx.js → runner-d294h1by.js} +5 -5
  60. package/dist/cli/{scan-cursor-1c8a3b0m.js → scan-cursor-5frvp7nb.js} +6 -6
  61. package/dist/cli/{schema-c554j5c8.js → schema-9xkt5hvd.js} +1 -1
  62. package/dist/cli/{scope-persistence-vtbcszvv.js → scope-persistence-gk55h3sp.js} +8 -8
  63. package/dist/cli/{skill-generator-0es21fck.js → skill-generator-sxxf7jbb.js} +13 -13
  64. package/dist/cli/{sqlite-loader-c92413n7.js → sqlite-loader-8zefc142.js} +1 -1
  65. package/dist/cli/{telemetry-x4zggfd7.js → telemetry-q51s6tyt.js} +1 -1
  66. package/dist/cli/{worktree-collision-ownership-043dg8gg.js → worktree-collision-ownership-7kj2ryt1.js} +4 -4
  67. package/dist/cli/{worktree-isolation-hk42yxw7.js → worktree-isolation-67fs6rz9.js} +32 -32
  68. package/dist/db/canonical-project.d.ts +31 -0
  69. package/dist/db/db-errors.d.ts +24 -0
  70. package/dist/db/driver-parity.d.ts +31 -0
  71. package/dist/db/durability.d.ts +40 -0
  72. package/dist/db/group-commit-writer.d.ts +117 -0
  73. package/dist/db/health.d.ts +35 -0
  74. package/dist/db/insight-candidate-store.d.ts +61 -0
  75. package/dist/db/legacy-import.d.ts +77 -0
  76. package/dist/db/phase-report-store.d.ts +45 -0
  77. package/dist/db/project-db.d.ts +35 -8
  78. package/dist/db/qa-gate-profile.d.ts +2 -0
  79. package/dist/hooks/curator-drift.d.ts +9 -5
  80. package/dist/hooks/curator-types.d.ts +1 -0
  81. package/dist/hooks/knowledge-curator.d.ts +5 -3
  82. package/dist/hooks/micro-reflector.d.ts +12 -7
  83. package/dist/index.js +619 -567
  84. package/dist/memory/schema.d.ts +4 -4
  85. package/dist/prm/index.d.ts +3 -1
  86. package/package.json +3 -2
  87. package/dist/cli/index-c8s9a3zh.js +0 -73
@@ -6,7 +6,7 @@ import {
6
6
  PluginConfigSchema,
7
7
  init_schema,
8
8
  stripKnownSwarmPrefix
9
- } from "./index-x2f1f011.js";
9
+ } from "./index-td6n935w.js";
10
10
  import {
11
11
  ALL_AGENT_NAMES,
12
12
  init_constants
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  authorizeCuration
4
- } from "./index-hm239n1p.js";
4
+ } from "./index-tb1k8jya.js";
5
5
  import {
6
6
  findNearDuplicate,
7
7
  inferTags,
@@ -9,13 +9,13 @@ import {
9
9
  resolveSwarmKnowledgePath,
10
10
  resolveSwarmRejectedPath,
11
11
  transactKnowledge
12
- } from "./index-f923njwh.js";
12
+ } from "./index-bm73pych.js";
13
13
  import {
14
14
  resolveKnowledgeStoreDir
15
- } from "./index-n2mhyect.js";
15
+ } from "./index-ynqp3jb6.js";
16
16
  import {
17
17
  atomicWriteFile
18
- } from "./index-n67vx5zw.js";
18
+ } from "./index-70bfj3v1.js";
19
19
  import {
20
20
  require_proper_lockfile
21
21
  } from "./index-7g4c7s5r.js";
@@ -3,13 +3,14 @@ import {
3
3
  EvaluationRunV1Schema,
4
4
  GateAuditResultV1Schema,
5
5
  getProtectedEvaluationRunIds
6
- } from "./index-0103w5pf.js";
6
+ } from "./index-2s4s9n82.js";
7
7
  import {
8
- loadDatabaseCtor
9
- } from "./index-n249fbw7.js";
10
- import {
11
- readEffectiveSpecSync
12
- } from "./index-9ss2m4rs.js";
8
+ DURABILITY_CLASSES,
9
+ getProjectDb,
10
+ projectDbExists,
11
+ readEffectiveSpecSync,
12
+ withDurabilityClass
13
+ } from "./index-1hpjwz3s.js";
13
14
  import {
14
15
  getWorktreeMergeFailure
15
16
  } from "./index-zsrtt42s.js";
@@ -23,7 +24,7 @@ import {
23
24
  readTaskEvidence,
24
25
  readTaskEvidenceRaw,
25
26
  sanitizeTaskId
26
- } from "./index-zjme8atd.js";
27
+ } from "./index-7r9vpkwa.js";
27
28
  import {
28
29
  LedgerStaleWriterError,
29
30
  appendLedgerEvent,
@@ -43,10 +44,10 @@ import {
43
44
  replayFromLedgerWithStatus,
44
45
  takeSnapshotEvent,
45
46
  takeSnapshotWithRetry
46
- } from "./index-kvra3nv1.js";
47
+ } from "./index-1z4jzwja.js";
47
48
  import {
48
49
  appendCoreEventSync
49
- } from "./index-8ada7ag7.js";
50
+ } from "./index-93sepnc9.js";
50
51
  import {
51
52
  init_executor,
52
53
  isUntrustedEnvKey,
@@ -70,7 +71,7 @@ import {
70
71
  } from "./index-r3mvsbtq.js";
71
72
  import {
72
73
  PlanSchema
73
- } from "./index-tnpf9wwv.js";
74
+ } from "./index-nhxaa9j5.js";
74
75
  import {
75
76
  GIT_BINARY_ENV_VAR,
76
77
  describeGitResolution,
@@ -81,10 +82,10 @@ import {
81
82
  assertProjectRoot,
82
83
  tryAcquireLock,
83
84
  withEvidenceLock
84
- } from "./index-9crtmnqg.js";
85
+ } from "./index-36nt17m8.js";
85
86
  import {
86
87
  emit
87
- } from "./index-2zgjcmmc.js";
88
+ } from "./index-1b1h770t.js";
88
89
  import {
89
90
  invalidateCachedArtifact,
90
91
  readCachedParsedFile
@@ -104,9 +105,9 @@ import {
104
105
  import {
105
106
  closeSync,
106
107
  copyFileSync,
107
- existsSync as existsSync4,
108
+ existsSync as existsSync3,
108
109
  fsyncSync,
109
- mkdirSync as mkdirSync3,
110
+ mkdirSync as mkdirSync2,
110
111
  openSync,
111
112
  readdirSync,
112
113
  renameSync as renameSync2,
@@ -118,195 +119,6 @@ import * as path5 from "path";
118
119
 
119
120
  // src/db/task-checkpoint-receipt.ts
120
121
  import { createHash } from "crypto";
121
-
122
- // src/db/project-db.ts
123
- import { existsSync, mkdirSync } from "fs";
124
- import { join, resolve } from "path";
125
- var MIGRATIONS = [
126
- {
127
- version: 1,
128
- name: "create_project_constraints",
129
- sql: `CREATE TABLE project_constraints (
130
- id INTEGER PRIMARY KEY AUTOINCREMENT,
131
- constraint_type TEXT NOT NULL,
132
- content TEXT NOT NULL,
133
- created_at TEXT NOT NULL DEFAULT (datetime('now'))
134
- )`
135
- },
136
- {
137
- version: 2,
138
- name: "create_qa_gate_profile",
139
- sql: `CREATE TABLE qa_gate_profile (
140
- id INTEGER PRIMARY KEY AUTOINCREMENT,
141
- plan_id TEXT NOT NULL UNIQUE,
142
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
143
- project_type TEXT,
144
- gates TEXT NOT NULL DEFAULT '{}',
145
- locked_at TEXT,
146
- locked_by_snapshot_seq INTEGER
147
- )`
148
- },
149
- {
150
- version: 3,
151
- name: "create_qa_gate_profile_immutability_trigger",
152
- sql: `CREATE TRIGGER IF NOT EXISTS trg_qa_gate_profile_no_update_after_lock
153
- BEFORE UPDATE ON qa_gate_profile
154
- WHEN OLD.locked_at IS NOT NULL
155
- BEGIN
156
- SELECT RAISE(ABORT, 'qa_gate_profile row is locked and cannot be modified after critic approval');
157
- END`
158
- },
159
- {
160
- version: 4,
161
- name: "add_qa_gate_profile_raw_swarm",
162
- sql: "ALTER TABLE qa_gate_profile ADD COLUMN raw_swarm TEXT"
163
- },
164
- {
165
- version: 5,
166
- name: "add_qa_gate_profile_raw_title",
167
- sql: "ALTER TABLE qa_gate_profile ADD COLUMN raw_title TEXT"
168
- },
169
- {
170
- version: 6,
171
- name: "add_qa_gate_profile_identity_hash",
172
- sql: "ALTER TABLE qa_gate_profile ADD COLUMN identity_hash TEXT"
173
- },
174
- {
175
- version: 7,
176
- name: "create_qa_gate_profile_identity_hash_index",
177
- sql: `CREATE UNIQUE INDEX IF NOT EXISTS idx_qa_gate_profile_identity_hash
178
- ON qa_gate_profile(identity_hash)
179
- WHERE identity_hash IS NOT NULL`
180
- },
181
- {
182
- version: 8,
183
- name: "create_qa_gate_profile_identity",
184
- sql: `CREATE TABLE qa_gate_profile_identity (
185
- identity_hash TEXT PRIMARY KEY,
186
- profile_id INTEGER NOT NULL UNIQUE REFERENCES qa_gate_profile(id) ON DELETE CASCADE,
187
- raw_swarm TEXT NOT NULL,
188
- raw_title TEXT NOT NULL,
189
- readable_plan_id TEXT NOT NULL
190
- )`
191
- },
192
- {
193
- version: 9,
194
- name: "create_qa_gate_profile_identity_readable_plan_index",
195
- sql: `CREATE INDEX idx_qa_gate_profile_identity_readable_plan_id
196
- ON qa_gate_profile_identity(readable_plan_id)`
197
- },
198
- {
199
- version: 10,
200
- name: "backfill_qa_gate_profile_identity_from_legacy_columns",
201
- sql: `INSERT INTO qa_gate_profile_identity (
202
- identity_hash,
203
- profile_id,
204
- raw_swarm,
205
- raw_title,
206
- readable_plan_id
207
- )
208
- SELECT
209
- identity_hash,
210
- id,
211
- raw_swarm,
212
- raw_title,
213
- plan_id
214
- FROM qa_gate_profile
215
- WHERE identity_hash IS NOT NULL
216
- AND raw_swarm IS NOT NULL
217
- AND raw_title IS NOT NULL
218
- AND NOT EXISTS (
219
- SELECT 1
220
- FROM qa_gate_profile_identity AS qi
221
- WHERE qi.profile_id = qa_gate_profile.id
222
- )`
223
- },
224
- {
225
- version: 11,
226
- name: "create_task_checkpoint_receipt",
227
- sql: `CREATE TABLE task_checkpoint_receipt (
228
- plan_identity_hash TEXT NOT NULL,
229
- task_id TEXT NOT NULL,
230
- label TEXT NOT NULL,
231
- state TEXT NOT NULL CHECK(state IN ('pending', 'committed', 'logged')),
232
- sha TEXT,
233
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
234
- updated_at TEXT NOT NULL DEFAULT (datetime('now')),
235
- PRIMARY KEY(plan_identity_hash, task_id)
236
- )`
237
- },
238
- {
239
- version: 12,
240
- name: "add_task_checkpoint_receipt_completion_generation",
241
- sql: `ALTER TABLE task_checkpoint_receipt
242
- ADD COLUMN generation INTEGER NOT NULL DEFAULT 1;
243
- ALTER TABLE task_checkpoint_receipt
244
- ADD COLUMN completion_active INTEGER NOT NULL DEFAULT 1
245
- CHECK(completion_active IN (0, 1))`
246
- },
247
- {
248
- version: 13,
249
- name: "bind_task_checkpoint_receipt_to_completion_ledger_seq",
250
- sql: `ALTER TABLE task_checkpoint_receipt
251
- ADD COLUMN completion_ledger_seq INTEGER
252
- CHECK(completion_ledger_seq IS NULL OR completion_ledger_seq >= 0)`
253
- }
254
- ];
255
- var _projectDbs = new Map;
256
- function runProjectMigrations(db) {
257
- db.run(`CREATE TABLE IF NOT EXISTS schema_migrations (
258
- version INTEGER PRIMARY KEY,
259
- name TEXT NOT NULL,
260
- applied_at TEXT NOT NULL DEFAULT (datetime('now'))
261
- )`);
262
- const row = db.query("SELECT MAX(version) as version FROM schema_migrations").get();
263
- const currentVersion = row?.version ?? 0;
264
- for (const migration of MIGRATIONS) {
265
- if (migration.version <= currentVersion)
266
- continue;
267
- const apply = db.transaction(() => {
268
- db.run(migration.sql);
269
- db.run("INSERT INTO schema_migrations (version, name) VALUES (?, ?)", [
270
- migration.version,
271
- migration.name
272
- ]);
273
- });
274
- apply();
275
- }
276
- }
277
- function projectDbPath(directory) {
278
- return join(resolve(directory), ".swarm", "swarm.db");
279
- }
280
- function projectDbExists(directory) {
281
- return existsSync(projectDbPath(directory));
282
- }
283
- function getProjectDb(directory) {
284
- const key = resolve(directory);
285
- const existing = _projectDbs.get(key);
286
- if (existing)
287
- return existing;
288
- const swarmDir = join(key, ".swarm");
289
- mkdirSync(swarmDir, { recursive: true });
290
- const Db = loadDatabaseCtor();
291
- const db = new Db(join(swarmDir, "swarm.db"));
292
- db.run("PRAGMA journal_mode = WAL;");
293
- db.run("PRAGMA synchronous = NORMAL;");
294
- db.run("PRAGMA busy_timeout = 5000;");
295
- db.run("PRAGMA foreign_keys = ON;");
296
- runProjectMigrations(db);
297
- _projectDbs.set(key, db);
298
- return db;
299
- }
300
- function closeProjectDb(directory) {
301
- const key = resolve(directory);
302
- const db = _projectDbs.get(key);
303
- if (db) {
304
- db.close();
305
- _projectDbs.delete(key);
306
- }
307
- }
308
-
309
- // src/db/task-checkpoint-receipt.ts
310
122
  var TASK_COMPLETION_HASH_LENGTH = 16;
311
123
  function taskReceiptLabelSuffix(planIdentityHash, taskId, generation) {
312
124
  return createHash("sha256").update(JSON.stringify(generation === 1 ? [planIdentityHash, taskId] : [planIdentityHash, taskId, generation]), "utf8").digest("hex").slice(0, TASK_COMPLETION_HASH_LENGTH);
@@ -340,47 +152,49 @@ function ensureTaskCheckpointReceipt(directory, planIdentityHash, taskId, comple
340
152
  }
341
153
  const db = getProjectDb(directory);
342
154
  const initial = buildTaskCompletionDescriptor(planIdentityHash, taskId, 1);
343
- db.transaction(() => {
344
- db.run(`INSERT OR IGNORE INTO task_checkpoint_receipt
345
- (plan_identity_hash, task_id, label, state, sha, generation,
346
- completion_active, completion_ledger_seq)
347
- VALUES (?, ?, ?, 'pending', NULL, 1, 1, ?)`, [planIdentityHash, taskId, initial.label, completionLedgerSeq]);
348
- const row2 = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
349
- if (!row2)
350
- return;
351
- if (row2.completion_ledger_seq === null) {
352
- db.run(`UPDATE task_checkpoint_receipt
353
- SET completion_ledger_seq = ?, completion_active = 1,
354
- updated_at = datetime('now')
355
- WHERE plan_identity_hash = ? AND task_id = ?
356
- AND completion_ledger_seq IS NULL`, [completionLedgerSeq, planIdentityHash, taskId]);
357
- return;
358
- }
359
- if (row2.completion_ledger_seq !== completionLedgerSeq) {
360
- const nextGeneration = row2.generation + 1;
361
- const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, nextGeneration);
362
- db.run(`UPDATE task_checkpoint_receipt
363
- SET label = ?, state = 'pending', sha = NULL, generation = ?,
364
- completion_active = 1, completion_ledger_seq = ?,
365
- updated_at = datetime('now')
366
- WHERE plan_identity_hash = ? AND task_id = ?
367
- AND completion_ledger_seq = ?`, [
368
- descriptor.label,
369
- nextGeneration,
370
- completionLedgerSeq,
371
- planIdentityHash,
372
- taskId,
373
- row2.completion_ledger_seq
374
- ]);
375
- return;
376
- }
377
- if (row2.completion_active === 0) {
378
- db.run(`UPDATE task_checkpoint_receipt
379
- SET completion_active = 1, updated_at = datetime('now')
380
- WHERE plan_identity_hash = ? AND task_id = ?
381
- AND completion_ledger_seq = ? AND completion_active = 0`, [planIdentityHash, taskId, completionLedgerSeq]);
382
- }
383
- })();
155
+ withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
156
+ db.transaction(() => {
157
+ db.run(`INSERT OR IGNORE INTO task_checkpoint_receipt
158
+ (plan_identity_hash, task_id, label, state, sha, generation,
159
+ completion_active, completion_ledger_seq)
160
+ VALUES (?, ?, ?, 'pending', NULL, 1, 1, ?)`, [planIdentityHash, taskId, initial.label, completionLedgerSeq]);
161
+ const row2 = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
162
+ if (!row2)
163
+ return;
164
+ if (row2.completion_ledger_seq === null) {
165
+ db.run(`UPDATE task_checkpoint_receipt
166
+ SET completion_ledger_seq = ?, completion_active = 1,
167
+ updated_at = datetime('now')
168
+ WHERE plan_identity_hash = ? AND task_id = ?
169
+ AND completion_ledger_seq IS NULL`, [completionLedgerSeq, planIdentityHash, taskId]);
170
+ return;
171
+ }
172
+ if (row2.completion_ledger_seq !== completionLedgerSeq) {
173
+ const nextGeneration = row2.generation + 1;
174
+ const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, nextGeneration);
175
+ db.run(`UPDATE task_checkpoint_receipt
176
+ SET label = ?, state = 'pending', sha = NULL, generation = ?,
177
+ completion_active = 1, completion_ledger_seq = ?,
178
+ updated_at = datetime('now')
179
+ WHERE plan_identity_hash = ? AND task_id = ?
180
+ AND completion_ledger_seq = ?`, [
181
+ descriptor.label,
182
+ nextGeneration,
183
+ completionLedgerSeq,
184
+ planIdentityHash,
185
+ taskId,
186
+ row2.completion_ledger_seq
187
+ ]);
188
+ return;
189
+ }
190
+ if (row2.completion_active === 0) {
191
+ db.run(`UPDATE task_checkpoint_receipt
192
+ SET completion_active = 1, updated_at = datetime('now')
193
+ WHERE plan_identity_hash = ? AND task_id = ?
194
+ AND completion_ledger_seq = ? AND completion_active = 0`, [planIdentityHash, taskId, completionLedgerSeq]);
195
+ }
196
+ })();
197
+ });
384
198
  const row = readTaskCheckpointReceipt(directory, planIdentityHash, taskId);
385
199
  if (!row) {
386
200
  throw new Error(`Failed to create or read task checkpoint receipt for ${taskId}`);
@@ -391,34 +205,38 @@ function activateTaskCheckpointReceipt(directory, planIdentityHash, taskId) {
391
205
  if (!projectDbExists(directory))
392
206
  return null;
393
207
  const db = getProjectDb(directory);
394
- db.transaction(() => {
395
- const row = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
396
- if (!row || row.completion_active === 1)
397
- return;
398
- const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, row.generation);
399
- db.run(`UPDATE task_checkpoint_receipt
400
- SET label = ?, state = 'pending', sha = NULL, completion_active = 1,
401
- updated_at = datetime('now')
402
- WHERE plan_identity_hash = ? AND task_id = ? AND completion_active = 0`, [descriptor.label, planIdentityHash, taskId]);
403
- })();
208
+ withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
209
+ db.transaction(() => {
210
+ const row = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
211
+ if (!row || row.completion_active === 1)
212
+ return;
213
+ const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, row.generation);
214
+ db.run(`UPDATE task_checkpoint_receipt
215
+ SET label = ?, state = 'pending', sha = NULL, completion_active = 1,
216
+ updated_at = datetime('now')
217
+ WHERE plan_identity_hash = ? AND task_id = ? AND completion_active = 0`, [descriptor.label, planIdentityHash, taskId]);
218
+ })();
219
+ });
404
220
  return readTaskCheckpointReceipt(directory, planIdentityHash, taskId);
405
221
  }
406
222
  function advanceTaskCheckpointReceiptGeneration(directory, planIdentityHash, taskId) {
407
223
  if (!projectDbExists(directory))
408
224
  return null;
409
225
  const db = getProjectDb(directory);
410
- db.transaction(() => {
411
- const row = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
412
- if (!row || row.completion_active === 0)
413
- return;
414
- const nextGeneration = row.generation + 1;
415
- const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, nextGeneration);
416
- db.run(`UPDATE task_checkpoint_receipt
417
- SET label = ?, state = 'pending', sha = NULL, generation = ?,
418
- completion_active = 0, completion_ledger_seq = NULL,
419
- updated_at = datetime('now')
420
- WHERE plan_identity_hash = ? AND task_id = ? AND completion_active = 1`, [descriptor.label, nextGeneration, planIdentityHash, taskId]);
421
- })();
226
+ withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
227
+ db.transaction(() => {
228
+ const row = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
229
+ if (!row || row.completion_active === 0)
230
+ return;
231
+ const nextGeneration = row.generation + 1;
232
+ const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, nextGeneration);
233
+ db.run(`UPDATE task_checkpoint_receipt
234
+ SET label = ?, state = 'pending', sha = NULL, generation = ?,
235
+ completion_active = 0, completion_ledger_seq = NULL,
236
+ updated_at = datetime('now')
237
+ WHERE plan_identity_hash = ? AND task_id = ? AND completion_active = 1`, [descriptor.label, nextGeneration, planIdentityHash, taskId]);
238
+ })();
239
+ });
422
240
  return readTaskCheckpointReceipt(directory, planIdentityHash, taskId);
423
241
  }
424
242
  function repairTaskCheckpointReceiptForCompletion(directory, planIdentityHash, taskId) {
@@ -435,21 +253,25 @@ function repairTaskCheckpointReceiptForCompletion(directory, planIdentityHash, t
435
253
  }
436
254
  function updateTaskCheckpointReceipt(directory, descriptor, state, sha) {
437
255
  const db = getProjectDb(directory);
438
- db.run(`UPDATE task_checkpoint_receipt
439
- SET state = ?, sha = ?, updated_at = datetime('now')
440
- WHERE plan_identity_hash = ? AND task_id = ?
441
- AND generation = ? AND completion_active = 1`, [
442
- state,
443
- sha,
444
- descriptor.planIdentityHash,
445
- descriptor.taskId,
446
- descriptor.generation
447
- ]);
448
- const row = readTaskCheckpointReceipt(directory, descriptor.planIdentityHash, descriptor.taskId);
449
- if (!row || row.generation !== descriptor.generation || row.completion_active !== 1) {
256
+ const rowAfter = withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
257
+ db.transaction(() => {
258
+ db.run(`UPDATE task_checkpoint_receipt
259
+ SET state = ?, sha = ?, updated_at = datetime('now')
260
+ WHERE plan_identity_hash = ? AND task_id = ?
261
+ AND generation = ? AND completion_active = 1`, [
262
+ state,
263
+ sha,
264
+ descriptor.planIdentityHash,
265
+ descriptor.taskId,
266
+ descriptor.generation
267
+ ]);
268
+ })();
269
+ return db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(descriptor.planIdentityHash, descriptor.taskId) ?? null;
270
+ });
271
+ if (!rowAfter || rowAfter.generation !== descriptor.generation || rowAfter.completion_active !== 1) {
450
272
  throw new Error(`Task checkpoint receipt generation changed for ${descriptor.taskId}`);
451
273
  }
452
- return row;
274
+ return rowAfter;
453
275
  }
454
276
 
455
277
  // src/git/branch.ts
@@ -762,7 +584,7 @@ async function resetToRemoteBranch(cwd, options) {
762
584
  let lastError;
763
585
  for (let retry = 0;retry < 4; retry++) {
764
586
  if (retry > 0 && process.platform === "win32") {
765
- await new Promise((resolve2) => setTimeout(resolve2, 500));
587
+ await new Promise((resolve) => setTimeout(resolve, 500));
766
588
  }
767
589
  try {
768
590
  gitExec(["reset", "--hard", targetBranch], cwd);
@@ -972,7 +794,7 @@ async function resetToMainAfterMerge(cwd, options) {
972
794
  let discardSucceeded = false;
973
795
  for (let retry = 0;retry < 4; retry++) {
974
796
  if (retry > 0 && process.platform === "win32") {
975
- await new Promise((resolve2) => setTimeout(resolve2, 500));
797
+ await new Promise((resolve) => setTimeout(resolve, 500));
976
798
  }
977
799
  try {
978
800
  _internals.gitExec(["checkout", "--", "."], cwd);
@@ -1665,7 +1487,7 @@ var _internals4 = {
1665
1487
  gitHeadSha: (cwd) => {
1666
1488
  return _internals.gitExec(["rev-parse", "HEAD"], cwd).trim();
1667
1489
  },
1668
- sleep: (ms) => new Promise((resolve4) => setTimeout(resolve4, ms)),
1490
+ sleep: (ms) => new Promise((resolve3) => setTimeout(resolve3, ms)),
1669
1491
  hasExistingTaskCommit: (cwd, taskId) => {
1670
1492
  const safeId = scrubTaskIdForGitSubject(taskId);
1671
1493
  const escaped = safeId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -1830,7 +1652,7 @@ function readTaskScopes(directory, taskId) {
1830
1652
  // src/utils/spec-hash.ts
1831
1653
  import { createHash as createHash3 } from "crypto";
1832
1654
  import * as fsSync2 from "fs";
1833
- import { join as join5 } from "path";
1655
+ import { join as join4 } from "path";
1834
1656
  async function computeSpecHash(directory) {
1835
1657
  const spec = _internals5.readEffectiveSpecSync(directory);
1836
1658
  if (!spec)
@@ -1859,7 +1681,7 @@ async function isSpecStale(directory, plan) {
1859
1681
  return { stale: false };
1860
1682
  }
1861
1683
  function isObligationPreserving(directory) {
1862
- const snapshotPath = join5(directory, ".swarm", "spec-snapshot.md");
1684
+ const snapshotPath = join4(directory, ".swarm", "spec-snapshot.md");
1863
1685
  try {
1864
1686
  let recordedContent;
1865
1687
  try {
@@ -1905,7 +1727,7 @@ var _internals5 = {
1905
1727
  readEffectiveSpecSync
1906
1728
  };
1907
1729
  function computeSpecDiff(directory) {
1908
- const snapshotPath = join5(directory, ".swarm", "spec-snapshot.md");
1730
+ const snapshotPath = join4(directory, ".swarm", "spec-snapshot.md");
1909
1731
  let recordedContent;
1910
1732
  try {
1911
1733
  const snapshotSize = fsSync2.statSync(snapshotPath).size;
@@ -2109,7 +1931,7 @@ async function retryCasWithBackoff(directory, eventInput, options) {
2109
1931
  expectedHashPrefix: currentExpected.slice(0, 8),
2110
1932
  delayMs
2111
1933
  });
2112
- await new Promise((resolve5) => setTimeout(resolve5, delayMs));
1934
+ await new Promise((resolve4) => setTimeout(resolve4, delayMs));
2113
1935
  if (options.verifyValid) {
2114
1936
  const stillValid = await options.verifyValid();
2115
1937
  if (!stillValid)
@@ -2583,7 +2405,7 @@ async function savePlan(directory, plan, options) {
2583
2405
  const oldLedgerPath = path5.join(swarmDir2, "plan-ledger.jsonl");
2584
2406
  const oldLedgerBackupPath = path5.join(swarmDir2, `plan-ledger.backup-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
2585
2407
  let backupExists = false;
2586
- if (existsSync4(oldLedgerPath)) {
2408
+ if (existsSync3(oldLedgerPath)) {
2587
2409
  try {
2588
2410
  options?.preCommitCheck?.();
2589
2411
  renameSync2(oldLedgerPath, oldLedgerBackupPath);
@@ -2602,11 +2424,11 @@ async function savePlan(directory, plan, options) {
2602
2424
  const errorMessage2 = String(initErr);
2603
2425
  if (errorMessage2.includes("already initialized")) {
2604
2426
  try {
2605
- if (existsSync4(oldLedgerBackupPath))
2427
+ if (existsSync3(oldLedgerBackupPath))
2606
2428
  unlinkSync2(oldLedgerBackupPath);
2607
2429
  } catch {}
2608
2430
  } else {
2609
- if (existsSync4(oldLedgerBackupPath)) {
2431
+ if (existsSync3(oldLedgerBackupPath)) {
2610
2432
  try {
2611
2433
  renameSync2(oldLedgerBackupPath, oldLedgerPath);
2612
2434
  } catch {
@@ -2628,13 +2450,13 @@ async function savePlan(directory, plan, options) {
2628
2450
  } catch (renameErr) {
2629
2451
  warn(`[savePlan] Could not archive old ledger (rename failed: ${renameErr instanceof Error ? renameErr.message : String(renameErr)}). Old ledger may still exist at ${oldLedgerBackupPath}.`);
2630
2452
  try {
2631
- if (existsSync4(oldLedgerBackupPath))
2453
+ if (existsSync3(oldLedgerBackupPath))
2632
2454
  unlinkSync2(oldLedgerBackupPath);
2633
2455
  } catch {}
2634
2456
  }
2635
2457
  } else if (!initSucceeded && backupExists) {
2636
2458
  try {
2637
- if (existsSync4(oldLedgerBackupPath))
2459
+ if (existsSync3(oldLedgerBackupPath))
2638
2460
  unlinkSync2(oldLedgerBackupPath);
2639
2461
  } catch {}
2640
2462
  }
@@ -2932,7 +2754,7 @@ async function rebuildPlan(directory, plan, options) {
2932
2754
  const swarmDir = path5.join(directory, ".swarm");
2933
2755
  const planPath = path5.join(swarmDir, "plan.json");
2934
2756
  const mdPath = path5.join(swarmDir, "plan.md");
2935
- mkdirSync3(swarmDir, { recursive: true });
2757
+ mkdirSync2(swarmDir, { recursive: true });
2936
2758
  const tempPlanPath = path5.join(swarmDir, `plan.json.rebuild.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
2937
2759
  {
2938
2760
  const fd = openSync(tempPlanPath, "w");
@@ -3472,7 +3294,7 @@ function migrateLegacyPlan(planContent, swarmId) {
3472
3294
  // src/evidence/manager.ts
3473
3295
  init_zod();
3474
3296
  import {
3475
- mkdirSync as mkdirSync4,
3297
+ mkdirSync as mkdirSync3,
3476
3298
  readdirSync as readdirSync2,
3477
3299
  realpathSync as realpathSync2,
3478
3300
  renameSync as renameSync3,
@@ -3669,7 +3491,7 @@ async function atomicRenameWithRetry(src, dst, renameFn = fsp.rename) {
3669
3491
  throw err;
3670
3492
  }
3671
3493
  if (attempt < RENAME_MAX_ATTEMPTS - 1) {
3672
- await new Promise((resolve5) => setTimeout(resolve5, RENAME_BACKOFF_MS));
3494
+ await new Promise((resolve4) => setTimeout(resolve4, RENAME_BACKOFF_MS));
3673
3495
  }
3674
3496
  }
3675
3497
  }
@@ -3956,7 +3778,7 @@ async function saveEvidence(directory, taskId, evidence, abortSignal) {
3956
3778
  if (bundleJson.length > EVIDENCE_MAX_JSON_BYTES) {
3957
3779
  throw new Error(`Evidence bundle size (${bundleJson.length} bytes) exceeds maximum (${EVIDENCE_MAX_JSON_BYTES} bytes)`);
3958
3780
  }
3959
- mkdirSync4(evidenceDir, { recursive: true });
3781
+ mkdirSync3(evidenceDir, { recursive: true });
3960
3782
  const tempPath = path7.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
3961
3783
  try {
3962
3784
  await bunWrite(tempPath, bundleJson);
@@ -4344,4 +4166,4 @@ function mergeDurableGateEntriesFromEvidence(taskId, entries, evidence) {
4344
4166
  return merged;
4345
4167
  }
4346
4168
 
4347
- export { projectDbExists, getProjectDb, closeProjectDb, normalizePath, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, containsPathTraversal, containsControlChars, validateSymlinkBoundary, validateTargetWithinRoot, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, updateTaskStatus, derivePlanMarkdown, isValidEvidenceType, isSecretscanEvidence, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
4169
+ export { normalizePath, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, containsPathTraversal, containsControlChars, validateSymlinkBoundary, validateTargetWithinRoot, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, updateTaskStatus, derivePlanMarkdown, isValidEvidenceType, isSecretscanEvidence, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
@@ -4,16 +4,16 @@ import {
4
4
  } from "./index-dtn0pne5.js";
5
5
  import {
6
6
  observeStoreHealth
7
- } from "./index-cqgpvx2d.js";
7
+ } from "./index-wdtckfnf.js";
8
8
  import {
9
9
  withEvidenceLock
10
- } from "./index-9crtmnqg.js";
10
+ } from "./index-36nt17m8.js";
11
11
  import {
12
12
  atomicWriteSwarmFileSync
13
13
  } from "./index-3b762978.js";
14
14
  import {
15
15
  telemetry
16
- } from "./index-2zgjcmmc.js";
16
+ } from "./index-1b1h770t.js";
17
17
  import {
18
18
  exports_external,
19
19
  init_zod
@@ -6,7 +6,7 @@ import {
6
6
  PluginConfigSchema,
7
7
  init_schema,
8
8
  resolveExternalSkillsConfig
9
- } from "./index-x2f1f011.js";
9
+ } from "./index-td6n935w.js";
10
10
  import {
11
11
  GIT_BINARY_ENV_VAR,
12
12
  init_git_executable