opencode-swarm 7.200.9 → 7.200.11

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 (119) hide show
  1. package/.opencode/skills/ci-fix-monitor/SKILL.md +49 -0
  2. package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +11 -2
  3. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  4. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  5. package/dist/background/completion-observer.d.ts +2 -1
  6. package/dist/background/pending-delegations.d.ts +9 -1
  7. package/dist/background/pr-review-contract.d.ts +8 -0
  8. package/dist/cli/{attest-task-79gp34gf.js → attest-task-y0n69zgb.js} +78 -76
  9. package/dist/cli/{auto-checkpoint-kt9mr7ma.js → auto-checkpoint-hyaksmtg.js} +12 -12
  10. package/dist/cli/{capability-probe-dwqn2609.js → capability-probe-qjndmx6z.js} +1 -1
  11. package/dist/cli/{checkpoint-e7t1zbz2.js → checkpoint-t0p781sc.js} +23 -23
  12. package/dist/cli/{coder-settlement-rehndcey.js → coder-settlement-nh88s6es.js} +14 -13
  13. package/dist/cli/{config-doctor-hcemxnra.js → config-doctor-sf7hc0q4.js} +19 -19
  14. package/dist/cli/{core-k8mvhsty.js → core-p168fw3r.js} +6 -3
  15. package/dist/cli/{curation-policy-gy868ec3.js → curation-policy-1a23ftnv.js} +6 -6
  16. package/dist/cli/{curator-ayenbz0y.js → curator-5ayzhk7v.js} +53 -52
  17. package/dist/cli/{curator-drift-fwzrv9tw.js → curator-drift-jx9kyndc.js} +10 -10
  18. package/dist/cli/curator-llm-factory-ytfkvtxs.js +83 -0
  19. package/dist/cli/{doctor-knowledge-receipt-phase-id-jdy6651j.js → doctor-knowledge-receipt-phase-id-2gjvxndy.js} +10 -10
  20. package/dist/cli/{evidence-summary-service-4jm1hd1r.js → evidence-summary-service-972sqht5.js} +26 -25
  21. package/dist/cli/{gate-evidence-anef2bqv.js → gate-evidence-n1m842gj.js} +10 -9
  22. package/dist/cli/guardrail-explain-6yv78gmk.js +84 -0
  23. package/dist/cli/{guardrail-log-pv3bq9hj.js → guardrail-log-z5pzgkcv.js} +8 -8
  24. package/dist/cli/{guardrail-reset-k8b9yrec.js → guardrail-reset-w0nxcs6a.js} +53 -52
  25. package/dist/cli/{hive-promoter-zqscx6pb.js → hive-promoter-3q0738xg.js} +53 -52
  26. package/dist/cli/{index-4krkevgc.js → index-001tkp0j.js} +1 -1
  27. package/dist/cli/{index-zy943kpp.js → index-0an54fza.js} +18 -13
  28. package/dist/cli/{index-czsx86m5.js → index-0g0x9ets.js} +53 -52
  29. package/dist/cli/{index-rdyfrdcp.js → index-2n7a184b.js} +201 -33
  30. package/dist/cli/{index-4fr3r8k5.js → index-2vj8d8te.js} +1 -1
  31. package/dist/cli/{index-hhq5f82z.js → index-5k88v1e7.js} +81 -36
  32. package/dist/cli/{index-c2k7q723.js → index-6cppzd9c.js} +1 -1
  33. package/dist/cli/{index-yyrnkc3a.js → index-6m551cng.js} +2 -2
  34. package/dist/cli/{index-y16v2q1x.js → index-814q5t5s.js} +5 -5
  35. package/dist/cli/{index-08jd4gz2.js → index-8g9rn3rp.js} +121 -40
  36. package/dist/cli/{index-8srvdpw6.js → index-8xtdxy91.js} +2 -2
  37. package/dist/cli/{index-mn75z39t.js → index-9qy3tzt5.js} +1 -1
  38. package/dist/cli/{index-6q2s7r67.js → index-aj41bscz.js} +8 -8
  39. package/dist/cli/{index-2c4hjeea.js → index-bnbhqvsn.js} +8 -8
  40. package/dist/cli/{index-9jty56xr.js → index-bv9tqmpm.js} +5 -5
  41. package/dist/cli/{index-casbh4y7.js → index-ce6qarfq.js} +13032 -12437
  42. package/dist/cli/{index-y7c4hqcj.js → index-ck7jpn0y.js} +1 -1
  43. package/dist/cli/{index-p2dst45x.js → index-ckq78kq1.js} +1 -1
  44. package/dist/cli/{index-8mrentmw.js → index-dp6hy23p.js} +58 -53
  45. package/dist/cli/{index-4fkxdnc7.js → index-erp7fk72.js} +1 -1
  46. package/dist/cli/{index-qawbxp81.js → index-gkvk9et2.js} +17 -17
  47. package/dist/cli/{index-kxp43wbw.js → index-h1chaf63.js} +29 -29
  48. package/dist/cli/{index-4ya4krts.js → index-hhzwfyd7.js} +611 -1376
  49. package/dist/cli/{index-x3rxa3sh.js → index-jt9j02tm.js} +6 -6
  50. package/dist/cli/{index-tecp3a77.js → index-kd1n3ne2.js} +9 -9
  51. package/dist/cli/{index-ss8nfrbb.js → index-ke881z7m.js} +15 -15
  52. package/dist/cli/{index-9ws7m02r.js → index-krjamprc.js} +2 -2
  53. package/dist/cli/{index-f8nb470m.js → index-kzr3nby8.js} +4 -4
  54. package/dist/cli/{index-02vgzrpg.js → index-mq4eyhtf.js} +7 -7
  55. package/dist/cli/{index-4tpzdegx.js → index-njg8zvqe.js} +7 -7
  56. package/dist/cli/{index-hh87yny7.js → index-nnc23ddw.js} +6 -6
  57. package/dist/cli/{index-7c4gckzq.js → index-nzhfhpng.js} +5 -5
  58. package/dist/cli/{index-q8vfw61p.js → index-pjrx4jkq.js} +1 -1
  59. package/dist/cli/{index-xhxbv7mz.js → index-qdz6zysj.js} +11 -11
  60. package/dist/cli/{index-mhd6kdzr.js → index-qyj4383m.js} +1 -1
  61. package/dist/cli/index-r097ettz.js +1330 -0
  62. package/dist/cli/{index-tvdn9gr0.js → index-ra3erqpk.js} +15 -15
  63. package/dist/cli/{index-2x015vjy.js → index-rck7v4r4.js} +1 -1
  64. package/dist/cli/{index-vtpt8yns.js → index-rjsqf4hv.js} +2 -2
  65. package/dist/cli/{index-bk8r4m9j.js → index-rpvp88js.js} +2 -2
  66. package/dist/cli/{index-2k5348b6.js → index-ssp4t8g6.js} +58 -57
  67. package/dist/cli/{index-v839c9mv.js → index-tggyracy.js} +1 -1
  68. package/dist/cli/{index-hzy6n59p.js → index-ve74c3a8.js} +6 -6
  69. package/dist/cli/{index-4ph7ad0b.js → index-vx1j2t5p.js} +2 -2
  70. package/dist/cli/{index-7h22y3ew.js → index-w0afnznk.js} +2 -2
  71. package/dist/cli/{index-xh50xsgf.js → index-x8sh8v4a.js} +8 -8
  72. package/dist/cli/{index-6901y99d.js → index-xht6gprr.js} +35 -22
  73. package/dist/cli/{index-qw2wfz92.js → index-yn6jrxen.js} +18 -20
  74. package/dist/cli/{index-94s844qn.js → index-yq73sd3w.js} +4 -4
  75. package/dist/cli/index.js +57 -56
  76. package/dist/cli/{knowledge-escalator-m4b4q218.js → knowledge-escalator-2e92rdsx.js} +18 -18
  77. package/dist/cli/{knowledge-events-wwg0cc7m.js → knowledge-events-gzqwr94e.js} +15 -15
  78. package/dist/cli/{knowledge-link-13t3nfrz.js → knowledge-link-r7e2t5c1.js} +5 -5
  79. package/dist/cli/{knowledge-store-07fwtdzy.js → knowledge-store-6j8d1gm4.js} +7 -7
  80. package/dist/cli/{knowledge-validator-8492vmn3.js → knowledge-validator-wt2tcfg7.js} +9 -9
  81. package/dist/cli/{mcp-b1wyrebx.js → mcp-ky6xn6ys.js} +1 -1
  82. package/dist/cli/{model-preflight-315wr8nt.js → model-preflight-ajt55s59.js} +56 -55
  83. package/dist/cli/{pending-delegations-tpa7wpny.js → pending-delegations-wry31649.js} +14 -14
  84. package/dist/cli/{pr-subscriptions-ev2bkbrz.js → pr-subscriptions-dsdjbfr4.js} +13 -13
  85. package/dist/cli/{pr-workflow-gate-3cg64r61.js → pr-workflow-gate-0vcq1m95.js} +53 -52
  86. package/dist/cli/{runner-q1g9atrv.js → runner-s4422dq4.js} +6 -6
  87. package/dist/cli/{scan-cursor-3pfx6mbh.js → scan-cursor-1zgrg7kp.js} +8 -8
  88. package/dist/cli/{schema-km0fywpx.js → schema-q9xbwkec.js} +2 -2
  89. package/dist/cli/{scope-persistence-xctbs0aj.js → scope-persistence-4wwmytwh.js} +18 -18
  90. package/dist/cli/{server-d1mcxa8s.js → server-q8ydxk7z.js} +79 -69
  91. package/dist/cli/{skill-generator-tce30v8g.js → skill-generator-b1eqcxej.js} +20 -20
  92. package/dist/cli/{snapshot-coordination-init-t7vfaqhw.js → snapshot-coordination-init-0yva5015.js} +53 -52
  93. package/dist/cli/{speckit-checkoff-tcn1dqt0.js → speckit-checkoff-sh9w7j5b.js} +5 -5
  94. package/dist/cli/{telemetry-cr8q16wk.js → telemetry-j7zr1dht.js} +1 -1
  95. package/dist/cli/workflow-wal-file-a2c8e920.js +32 -0
  96. package/dist/cli/{workspace-snapshot-7hws89e9.js → workspace-snapshot-ksdspd74.js} +3 -3
  97. package/dist/cli/{worktree-collision-ownership-5jb0p5aa.js → worktree-collision-ownership-xr6crt8c.js} +15 -15
  98. package/dist/cli/{worktree-isolation-cxg8fgba.js → worktree-isolation-0126b5e7.js} +53 -52
  99. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +3 -0
  100. package/dist/hooks/delegation-gate.d.ts +6 -0
  101. package/dist/hooks/guardrails/audit-log.d.ts +2 -0
  102. package/dist/hooks/guardrails/cmd-delete-grammar.d.ts +47 -0
  103. package/dist/hooks/guardrails/destructive-command.d.ts +11 -3
  104. package/dist/hooks/guardrails/shell-audit-store.d.ts +2 -0
  105. package/dist/hooks/guardrails/tool-before.d.ts +16 -0
  106. package/dist/hooks/shell-write-detect.d.ts +10 -0
  107. package/dist/index.js +689 -687
  108. package/dist/memory/redaction.d.ts +13 -3
  109. package/dist/pr-review/legacy-transcript-adapter.d.ts +15 -4
  110. package/dist/sandbox/macos/sandbox-exec-executor.d.ts +24 -0
  111. package/dist/workflow/coder-settlement.d.ts +5 -0
  112. package/dist/worktree/core.d.ts +3 -0
  113. package/dist/worktree/merge.d.ts +15 -1
  114. package/dist/worktree/ownership.d.ts +3 -0
  115. package/dist/worktree/settlement-artifact-lifecycle.d.ts +32 -0
  116. package/dist/worktree/settlement-source-recovery.d.ts +12 -0
  117. package/package.json +1 -1
  118. package/dist/cli/curator-llm-factory-kja1c81k.js +0 -82
  119. package/dist/cli/guardrail-explain-agaet7r5.js +0 -83
@@ -1,13 +1,19 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-4krkevgc.js";
4
+ } from "./index-001tkp0j.js";
5
+ import {
6
+ assertProjectRoot
7
+ } from "./index-t7hmqgjy.js";
5
8
  import {
6
9
  canonicalRootKeyFresh
7
10
  } from "./index-te9hq2f4.js";
11
+ import {
12
+ tryAcquireLock
13
+ } from "./index-ejhxgyvm.js";
8
14
  import {
9
15
  atomicWriteSwarmFileSync
10
- } from "./index-mn75z39t.js";
16
+ } from "./index-9qy3tzt5.js";
11
17
  import {
12
18
  advisoryWarn,
13
19
  init_git_executable,
@@ -35,7 +41,7 @@ init_constants();
35
41
  import * as fs2 from "fs";
36
42
  import * as fsPromises from "fs/promises";
37
43
  import * as os from "os";
38
- import * as path from "path";
44
+ import * as path2 from "path";
39
45
 
40
46
  // src/config/swarm-branch.ts
41
47
  init_constants();
@@ -222,12 +228,160 @@ function listLiveLaneOwners(directory) {
222
228
  init_warning_buffer();
223
229
  init_bun_compat();
224
230
  init_git_executable();
231
+
232
+ // src/worktree/settlement-artifact-lifecycle.ts
233
+ import { lstat, opendir, realpath } from "fs/promises";
234
+ import * as path from "path";
235
+ init_warning_buffer();
236
+ var MAX_INVENTORY_ENTRIES = 200;
237
+ var LIFECYCLE_TARGET = "locks/coder-settlement-artifacts";
238
+
239
+ class SettlementArtifactLifecycleError extends Error {
240
+ code;
241
+ constructor(code, detail) {
242
+ super(`${code}: ${detail}`);
243
+ this.code = code;
244
+ this.name = "SettlementArtifactLifecycleError";
245
+ }
246
+ }
247
+ function isSettlementArtifactLifecycleError(error) {
248
+ return error instanceof SettlementArtifactLifecycleError;
249
+ }
250
+ async function readWal(filePath, taskId) {
251
+ const { readWorkflowWalFile } = await import("./workflow-wal-file-a2c8e920.js");
252
+ return readWorkflowWalFile("coder-settlement", filePath, taskId);
253
+ }
254
+ async function canonicalizeArtifact(filePath) {
255
+ if (!path.isAbsolute(filePath))
256
+ throw uncertain("artifact path is not absolute");
257
+ let candidate = path.resolve(filePath);
258
+ const missing = [];
259
+ for (let depth = 0;depth < 256; depth++) {
260
+ try {
261
+ const physical = await _internals2.realpath(candidate);
262
+ const resolved = path.join(physical, ...missing.reverse());
263
+ return process.platform === "win32" ? resolved.toLowerCase() : resolved;
264
+ } catch (error) {
265
+ if (error.code !== "ENOENT" && error.code !== "ENOTDIR")
266
+ throw error;
267
+ const parent = path.dirname(candidate);
268
+ if (parent === candidate)
269
+ throw error;
270
+ missing.push(path.basename(candidate));
271
+ candidate = parent;
272
+ }
273
+ }
274
+ throw uncertain("artifact ancestry exceeds the identity bound");
275
+ }
225
276
  var _internals2 = {
277
+ tryAcquireLock,
278
+ opendir,
279
+ lstat,
280
+ realpath,
281
+ readWal,
282
+ canonicalize: canonicalizeArtifact,
283
+ assertProjectRoot
284
+ };
285
+ function uncertain(detail) {
286
+ return new SettlementArtifactLifecycleError("CODER_SETTLEMENT_ARTIFACT_UNCERTAIN", detail);
287
+ }
288
+ async function withSettlementArtifactLifecycle(directory, operation) {
289
+ let root;
290
+ let admission;
291
+ try {
292
+ _internals2.assertProjectRoot(directory);
293
+ root = await _internals2.realpath(directory);
294
+ validateSwarmPath(root, LIFECYCLE_TARGET);
295
+ admission = await _internals2.tryAcquireLock(root, LIFECYCLE_TARGET, "coder-settlement-artifact-lifecycle", "coder-settlement-artifact-lifecycle");
296
+ } catch (error) {
297
+ throw uncertain(`cannot acquire lifecycle admission (${error instanceof Error ? error.message : String(error)})`);
298
+ }
299
+ if (!admission.acquired)
300
+ throw uncertain("lifecycle admission is busy: a concurrent removal or dispatch holds the lifecycle lock; retry once it completes");
301
+ try {
302
+ return await operation();
303
+ } finally {
304
+ try {
305
+ await admission.lock._release?.();
306
+ } catch (error) {
307
+ advisoryWarn(`[worktree] settlement artifact lifecycle lock release failed (${error instanceof Error ? error.message : String(error)})`);
308
+ }
309
+ }
310
+ }
311
+ async function matchesPendingWal(wal, target, targetPath) {
312
+ if (wal.state !== "DISPATCHED" && wal.state !== "PREPARED")
313
+ return false;
314
+ if (target.branch && (wal.worktree?.branchName === target.branch || wal.mergeProvenance?.branchName === target.branch))
315
+ return true;
316
+ return Boolean(targetPath && wal.worktree && await _internals2.canonicalize(wal.worktree.worktreePath) === targetPath);
317
+ }
318
+ async function assertSettlementArtifactsRemovable(directory, target) {
319
+ if (!target.path && !target.branch)
320
+ throw uncertain("missing artifact identity");
321
+ let handle;
322
+ let failure;
323
+ try {
324
+ const inventoryPath = validateSwarmPath(directory, "coder-settlements");
325
+ try {
326
+ const stat = await _internals2.lstat(inventoryPath);
327
+ if (stat.isSymbolicLink() || !stat.isDirectory())
328
+ throw uncertain("settlement inventory is not a direct directory");
329
+ } catch (error) {
330
+ if (error.code === "ENOENT")
331
+ return;
332
+ throw error;
333
+ }
334
+ const targetPath = target.path ? await _internals2.canonicalize(target.path) : undefined;
335
+ handle = await _internals2.opendir(inventoryPath);
336
+ let count = 0;
337
+ while (true) {
338
+ const entry = await handle.read();
339
+ if (!entry)
340
+ break;
341
+ if (entry.isSymbolicLink())
342
+ throw uncertain("settlement inventory contains a symbolic entry");
343
+ if (!entry.name.endsWith(".json"))
344
+ continue;
345
+ if (++count > MAX_INVENTORY_ENTRIES)
346
+ throw uncertain(`settlement inventory exceeds ${MAX_INVENTORY_ENTRIES} records; run \`/swarm close\` to archive settled coder settlements`);
347
+ const filePath = path.join(inventoryPath, entry.name);
348
+ const stat = await _internals2.lstat(filePath);
349
+ if (!stat.isFile() || stat.isSymbolicLink())
350
+ throw uncertain("settlement record is not a direct regular file");
351
+ const wal = await _internals2.readWal(filePath, entry.name.slice(0, -5));
352
+ if (!wal)
353
+ throw uncertain("settlement record disappeared during inventory");
354
+ const after = await _internals2.lstat(filePath);
355
+ if (after.dev !== stat.dev || after.ino !== stat.ino || after.size !== stat.size || after.mtimeMs !== stat.mtimeMs)
356
+ throw uncertain("settlement record changed during inspection");
357
+ if (await matchesPendingWal(wal, target, targetPath)) {
358
+ throw new SettlementArtifactLifecycleError("CODER_SETTLEMENT_ARTIFACT_PROTECTED", `task ${wal.taskId} has a ${wal.state} settlement; preserve its lane artifacts`);
359
+ }
360
+ }
361
+ } catch (error) {
362
+ failure = isSettlementArtifactLifecycleError(error) ? error : uncertain(`cannot verify settlement inventory (${error instanceof Error ? error.message : String(error)})`);
363
+ } finally {
364
+ if (handle) {
365
+ try {
366
+ await handle.close();
367
+ } catch {
368
+ failure ??= uncertain("cannot close settlement inventory");
369
+ }
370
+ }
371
+ }
372
+ if (failure)
373
+ throw failure;
374
+ }
375
+
376
+ // src/worktree/core.ts
377
+ var _internals3 = {
378
+ withSettlementArtifactLifecycle,
379
+ assertSettlementArtifactsRemovable,
226
380
  clearLiveLaneOwner,
227
381
  bunSpawn,
228
382
  resolveGitExecutable,
229
383
  platform: process.platform,
230
- sleep: (ms) => new Promise((resolve2) => setTimeout(resolve2, ms)),
384
+ sleep: (ms) => new Promise((resolve3) => setTimeout(resolve3, ms)),
231
385
  osTmpdir: () => os.tmpdir(),
232
386
  getCoreLongPaths: async (directory) => {
233
387
  const result = await runGit(["config", "core.longpaths"], directory);
@@ -244,7 +398,7 @@ var _internals2 = {
244
398
  symlinkSync: fs2.symlinkSync
245
399
  },
246
400
  writeScopeToDisk: async (directory, taskId, files) => {
247
- const { writeScopeToDisk: realWrite } = await import("./scope-persistence-xctbs0aj.js");
401
+ const { writeScopeToDisk: realWrite } = await import("./scope-persistence-4wwmytwh.js");
248
402
  return realWrite(directory, taskId, files);
249
403
  },
250
404
  writeLaneProfileToDisk: async (_worktreePath, _laneIndex, _envOverrides) => {
@@ -273,15 +427,15 @@ async function writeLaneProfileToDiskReal(worktreePath, laneIndex, envOverrides)
273
427
  }
274
428
  if (lines.length === 0)
275
429
  return;
276
- const lanesDir = path.join(worktreePath, ".swarm", "lanes");
430
+ const lanesDir = path2.join(worktreePath, ".swarm", "lanes");
277
431
  await fs2.promises.mkdir(lanesDir, { recursive: true });
278
- const envPath = path.join(lanesDir, `${laneIndex}.env`);
432
+ const envPath = path2.join(lanesDir, `${laneIndex}.env`);
279
433
  await fs2.promises.writeFile(envPath, `${lines.join(`
280
434
  `)}
281
435
  `, "utf-8");
282
436
  }
283
437
  async function removeLaneProfileFromDiskReal(worktreePath, laneIndex) {
284
- const envPath = path.join(worktreePath, ".swarm", "lanes", `${laneIndex}.env`);
438
+ const envPath = path2.join(worktreePath, ".swarm", "lanes", `${laneIndex}.env`);
285
439
  try {
286
440
  await fs2.promises.unlink(envPath);
287
441
  } catch (err) {
@@ -297,7 +451,7 @@ var GIT_SPAWN_FAILURE_EXIT_CODE = 1;
297
451
  async function runGit(args, cwd, timeoutMs = WORKTREE_TIMEOUT_MS) {
298
452
  let proc;
299
453
  try {
300
- proc = _internals2.bunSpawn([_internals2.resolveGitExecutable(), ...args], {
454
+ proc = _internals3.bunSpawn([_internals3.resolveGitExecutable(), ...args], {
301
455
  cwd,
302
456
  timeout: timeoutMs,
303
457
  stdin: "ignore",
@@ -330,19 +484,19 @@ async function runGit(args, cwd, timeoutMs = WORKTREE_TIMEOUT_MS) {
330
484
  }
331
485
  }
332
486
  async function checkPathBudget(worktreeRoot, directory) {
333
- if (_internals2.platform !== "win32") {
487
+ if (_internals3.platform !== "win32") {
334
488
  return { ok: true };
335
489
  }
336
490
  let longPaths;
337
491
  try {
338
- longPaths = await _internals2.getCoreLongPaths(directory);
492
+ longPaths = await _internals3.getCoreLongPaths(directory);
339
493
  } catch {}
340
494
  if (longPaths === "true") {
341
495
  return { ok: true };
342
496
  }
343
497
  let proc;
344
498
  try {
345
- proc = _internals2.bunSpawn([_internals2.resolveGitExecutable(), "ls-files"], {
499
+ proc = _internals3.bunSpawn([_internals3.resolveGitExecutable(), "ls-files"], {
346
500
  cwd: directory,
347
501
  timeout: WORKTREE_TIMEOUT_MS,
348
502
  stdin: "ignore",
@@ -384,23 +538,23 @@ async function checkPathBudget(worktreeRoot, directory) {
384
538
  }
385
539
  }
386
540
  function shortenWorktreePath(_directory, sessionId, laneId) {
387
- let tmp = _internals2.osTmpdir();
541
+ let tmp = _internals3.osTmpdir();
388
542
  try {
389
543
  tmp = fs2.realpathSync(tmp);
390
544
  } catch {}
391
- return path.join(tmp, "swwt", sessionId, laneId);
545
+ return path2.join(tmp, "swwt", sessionId, laneId);
392
546
  }
393
547
  function makeWorktreeBranchName(sessionId, id, options) {
394
548
  return buildSwarmBranchName(sessionId, id, options.purpose, options.branchStyle === "legacy-lane" && options.purpose === "lane");
395
549
  }
396
550
  function resolveWorktreeBaseDir(directory, worktreeDir) {
397
- return worktreeDir ? path.resolve(directory, worktreeDir) : path.resolve(directory, SWARM_WORKTREE_DIR_NAME);
551
+ return worktreeDir ? path2.resolve(directory, worktreeDir) : path2.resolve(directory, SWARM_WORKTREE_DIR_NAME);
398
552
  }
399
553
  function isPathUnderSwarmWorktreeBase(targetPath, directory, worktreeDirOverrides = []) {
400
554
  const caseInsensitive = process.platform === "win32";
401
555
  let realTarget;
402
556
  try {
403
- realTarget = fs2.realpathSync(path.resolve(directory, targetPath));
557
+ realTarget = fs2.realpathSync(path2.resolve(directory, targetPath));
404
558
  } catch {
405
559
  return false;
406
560
  }
@@ -414,13 +568,13 @@ function isPathUnderSwarmWorktreeBase(targetPath, directory, worktreeDirOverride
414
568
  try {
415
569
  realBase = fs2.realpathSync(base);
416
570
  } catch {
417
- realBase = path.resolve(base);
571
+ realBase = path2.resolve(base);
418
572
  }
419
573
  const cmpBase = caseInsensitive ? realBase.toLowerCase() : realBase;
420
574
  if (cmpTarget === cmpBase)
421
575
  return true;
422
- const rel = path.relative(cmpBase, cmpTarget);
423
- return rel.length > 0 && !rel.startsWith("..") && !path.isAbsolute(rel);
576
+ const rel = path2.relative(cmpBase, cmpTarget);
577
+ return rel.length > 0 && !rel.startsWith("..") && !path2.isAbsolute(rel);
424
578
  });
425
579
  }
426
580
  async function provisionWorktree(directory, id, sessionId, options) {
@@ -430,7 +584,7 @@ async function provisionWorktree(directory, id, sessionId, options) {
430
584
  error: `Refusing to provision worktree: branch "${branchName}" does not match the swarm lane grammar, so lane permission scoping could not recognise it and the lane would hang on the first external-directory prompt. This is almost always an invalid sessionId ("${sessionId}"); it must look like "ses_" followed by letters/digits, and the execution-unit id ("${id}") must be a single path segment.`
431
585
  };
432
586
  }
433
- let worktreePath = path.resolve(resolveWorktreeBaseDir(directory, options.worktreeDir), sessionId, id);
587
+ let worktreePath = path2.resolve(resolveWorktreeBaseDir(directory, options.worktreeDir), sessionId, id);
434
588
  const budgetResult = await checkPathBudget(worktreePath, directory);
435
589
  if (budgetResult.ok === false) {
436
590
  if (options.worktreeDir) {
@@ -575,18 +729,18 @@ async function provisionWorktree(directory, id, sessionId, options) {
575
729
  }
576
730
  const strategy = options.depsStrategy ?? "skip";
577
731
  if (strategy !== "skip") {
578
- const hostDepDir = path.join(directory, "node_modules");
579
- const laneDepDir = path.join(worktreePath, "node_modules");
580
- if (_internals2.fs.existsSync(hostDepDir)) {
732
+ const hostDepDir = path2.join(directory, "node_modules");
733
+ const laneDepDir = path2.join(worktreePath, "node_modules");
734
+ if (_internals3.fs.existsSync(hostDepDir)) {
581
735
  try {
582
736
  if (strategy === "copy") {
583
- await _internals2.fs.cp(hostDepDir, laneDepDir, {
737
+ await _internals3.fs.cp(hostDepDir, laneDepDir, {
584
738
  recursive: true,
585
739
  force: true
586
740
  });
587
741
  } else if (strategy === "link") {
588
- const isWindows = _internals2.platform === "win32";
589
- _internals2.fs.symlinkSync(hostDepDir, laneDepDir, isWindows ? "junction" : "dir");
742
+ const isWindows = _internals3.platform === "win32";
743
+ _internals3.fs.symlinkSync(hostDepDir, laneDepDir, isWindows ? "junction" : "dir");
590
744
  }
591
745
  } catch (e) {
592
746
  log(`[swarm] deps_strategy '${strategy}' preparation failed for ${id}: ${e instanceof Error ? e.message : String(e)}`);
@@ -599,12 +753,12 @@ async function provisionWorktree(directory, id, sessionId, options) {
599
753
  }
600
754
  if (options.scope?.taskId && Array.isArray(options.scope.files)) {
601
755
  try {
602
- await _internals2.writeScopeToDisk(worktreePath, options.scope.taskId, options.scope.files);
756
+ await _internals3.writeScopeToDisk(worktreePath, options.scope.taskId, options.scope.files);
603
757
  } catch {}
604
758
  }
605
759
  if (options.laneProfile) {
606
760
  try {
607
- await _internals2.writeLaneProfileToDisk(worktreePath, options.laneProfile.laneIndex, options.laneProfile.envOverrides);
761
+ await _internals3.writeLaneProfileToDisk(worktreePath, options.laneProfile.laneIndex, options.laneProfile.envOverrides);
608
762
  } catch {}
609
763
  }
610
764
  return {
@@ -616,14 +770,28 @@ async function provisionWorktree(directory, id, sessionId, options) {
616
770
  };
617
771
  }
618
772
  async function removeWorktree(worktreePath, projectRoot, options) {
619
- const isWindows = _internals2.platform === "win32";
773
+ try {
774
+ return await _internals3.withSettlementArtifactLifecycle(projectRoot, async () => {
775
+ await _internals3.assertSettlementArtifactsRemovable(projectRoot, {
776
+ path: worktreePath
777
+ });
778
+ return removeWorktreeUnderLifecycleLock(worktreePath, projectRoot, options);
779
+ });
780
+ } catch (error) {
781
+ return {
782
+ error: `CODER_SETTLEMENT_ARTIFACT_REMOVAL_REFUSED: ${error instanceof Error ? error.message : String(error)}`
783
+ };
784
+ }
785
+ }
786
+ async function removeWorktreeUnderLifecycleLock(worktreePath, projectRoot, options) {
787
+ const isWindows = _internals3.platform === "win32";
620
788
  const MAX_RETRIES = 4;
621
789
  const RETRY_DELAY_MS = 2000;
622
790
  let lastError = "";
623
791
  for (let attempt = 0;attempt < MAX_RETRIES; attempt++) {
624
792
  const result = await runGit(["worktree", "remove", worktreePath], projectRoot);
625
793
  if (result.exitCode === 0) {
626
- _internals2.clearLiveLaneOwner(projectRoot, worktreePath);
794
+ _internals3.clearLiveLaneOwner(projectRoot, worktreePath);
627
795
  if (fs2.existsSync(worktreePath)) {
628
796
  const trusted = isPathUnderSwarmWorktreeBase(worktreePath, projectRoot, options?.worktreeDir ? [options.worktreeDir] : []);
629
797
  if (!trusted) {
@@ -648,13 +816,13 @@ async function removeWorktree(worktreePath, projectRoot, options) {
648
816
  }
649
817
  lastError = result.stderr.trim() || result.stdout.trim();
650
818
  if (isWindows && (lastError.includes("EBUSY") || lastError.includes("EPERM")) && attempt < MAX_RETRIES - 1) {
651
- await _internals2.sleep(RETRY_DELAY_MS);
819
+ await _internals3.sleep(RETRY_DELAY_MS);
652
820
  continue;
653
821
  }
654
822
  if (options?.force && isPathUnderSwarmWorktreeBase(worktreePath, projectRoot, options.worktreeDir ? [options.worktreeDir] : [])) {
655
823
  const forced = await runGit(["worktree", "remove", "--force", worktreePath], projectRoot);
656
824
  if (forced.exitCode === 0) {
657
- _internals2.clearLiveLaneOwner(projectRoot, worktreePath);
825
+ _internals3.clearLiveLaneOwner(projectRoot, worktreePath);
658
826
  if (fs2.existsSync(worktreePath)) {
659
827
  try {
660
828
  fs2.rmSync(worktreePath, { recursive: true, force: true });
@@ -788,4 +956,4 @@ async function assertCleanWorkingTree(directory) {
788
956
  return { clean: true };
789
957
  }
790
958
 
791
- export { recordLiveLaneOwner, listLiveLaneOwners, _internals2 as _internals, writeLaneProfileToDiskReal, removeLaneProfileFromDiskReal, checkPathBudget, shortenWorktreePath, makeWorktreeBranchName, resolveWorktreeBaseDir, isPathUnderSwarmWorktreeBase, provisionWorktree, removeWorktree, isCleanWorktree, autoCommitDirty, cleanUntrackedFiles, assertCleanWorkingTree };
959
+ export { recordLiveLaneOwner, listLiveLaneOwners, withSettlementArtifactLifecycle, assertSettlementArtifactsRemovable, _internals3 as _internals, writeLaneProfileToDiskReal, removeLaneProfileFromDiskReal, checkPathBudget, shortenWorktreePath, makeWorktreeBranchName, resolveWorktreeBaseDir, isPathUnderSwarmWorktreeBase, provisionWorktree, removeWorktree, isCleanWorktree, autoCommitDirty, cleanUntrackedFiles, assertCleanWorkingTree };
@@ -4,7 +4,7 @@ import {
4
4
  readShellAuditTail,
5
5
  redactPath,
6
6
  redactShellCommand
7
- } from "./index-hhq5f82z.js";
7
+ } from "./index-5k88v1e7.js";
8
8
 
9
9
  // src/services/guardrail-log-service.ts
10
10
  var BLOCK_TYPES = new Set([
@@ -1,7 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  observeStoreHealth
4
- } from "./index-8srvdpw6.js";
4
+ } from "./index-8xtdxy91.js";
5
+ import {
6
+ init_schema,
7
+ stripKnownSwarmPrefix
8
+ } from "./index-814q5t5s.js";
5
9
  import {
6
10
  getPathFlavor,
7
11
  init_path_identity,
@@ -14,7 +18,7 @@ import {
14
18
  } from "./index-9rwhas09.js";
15
19
  import {
16
20
  telemetry
17
- } from "./index-c2k7q723.js";
21
+ } from "./index-6cppzd9c.js";
18
22
  import {
19
23
  init_git_executable,
20
24
  resolveGitExecutable
@@ -26,10 +30,6 @@ import {
26
30
  init_logger,
27
31
  warn
28
32
  } from "./index-zgwm4ryv.js";
29
- import {
30
- init_schema,
31
- stripKnownSwarmPrefix
32
- } from "./index-y16v2q1x.js";
33
33
  import {
34
34
  init_constants
35
35
  } from "./index-xfzkq1k4.js";
@@ -277,7 +277,7 @@ var require_scan = __commonJS((exports, module) => {
277
277
  var scan = (input, options) => {
278
278
  const opts = options || {};
279
279
  const length = input.length - 1;
280
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
280
+ const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
281
281
  const slashes = [];
282
282
  const tokens = [];
283
283
  const parts = [];
@@ -384,14 +384,18 @@ var require_scan = __commonJS((exports, module) => {
384
384
  negatedExtglob = true;
385
385
  }
386
386
  if (scanToEnd === true) {
387
+ let parens = 0;
387
388
  while (eos() !== true && (code = advance())) {
388
389
  if (code === CHAR_BACKWARD_SLASH) {
389
390
  backslashes = token.backslashes = true;
390
- code = advance();
391
+ advance();
391
392
  continue;
392
393
  }
393
- if (code === CHAR_RIGHT_PARENTHESES) {
394
- isGlob = token.isGlob = true;
394
+ if (code === CHAR_LEFT_PARENTHESES) {
395
+ parens++;
396
+ continue;
397
+ }
398
+ if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
395
399
  finished = true;
396
400
  break;
397
401
  }
@@ -446,13 +450,18 @@ var require_scan = __commonJS((exports, module) => {
446
450
  if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
447
451
  isGlob = token.isGlob = true;
448
452
  if (scanToEnd === true) {
453
+ let parens = 1;
449
454
  while (eos() !== true && (code = advance())) {
450
- if (code === CHAR_LEFT_PARENTHESES) {
455
+ if (code === CHAR_BACKWARD_SLASH) {
451
456
  backslashes = token.backslashes = true;
452
- code = advance();
457
+ advance();
453
458
  continue;
454
459
  }
455
- if (code === CHAR_RIGHT_PARENTHESES) {
460
+ if (code === CHAR_LEFT_PARENTHESES) {
461
+ parens++;
462
+ continue;
463
+ }
464
+ if (code === CHAR_RIGHT_PARENTHESES && --parens === 0) {
456
465
  finished = true;
457
466
  break;
458
467
  }
@@ -526,32 +535,31 @@ var require_scan = __commonJS((exports, module) => {
526
535
  if (opts.parts === true || opts.tokens === true) {
527
536
  let prevIndex;
528
537
  for (let idx = 0;idx < slashes.length; idx++) {
529
- const n = prevIndex ? prevIndex + 1 : start;
538
+ const n2 = prevIndex !== undefined ? prevIndex + 1 : start;
530
539
  const i = slashes[idx];
531
- const value = input.slice(n, i);
540
+ const value2 = input.slice(n2, i);
532
541
  if (opts.tokens) {
533
542
  if (idx === 0 && start !== 0) {
534
543
  tokens[idx].isPrefix = true;
535
544
  tokens[idx].value = prefix;
536
545
  } else {
537
- tokens[idx].value = value;
546
+ tokens[idx].value = value2;
538
547
  }
539
548
  depth(tokens[idx]);
540
549
  state.maxDepth += tokens[idx].depth;
541
550
  }
542
- if (idx !== 0 || value !== "") {
543
- parts.push(value);
551
+ if (i >= start) {
552
+ parts.push(value2);
553
+ prevIndex = i;
544
554
  }
545
- prevIndex = i;
546
555
  }
547
- if (prevIndex && prevIndex + 1 < input.length) {
548
- const value = input.slice(prevIndex + 1);
549
- parts.push(value);
550
- if (opts.tokens) {
551
- tokens[tokens.length - 1].value = value;
552
- depth(tokens[tokens.length - 1]);
553
- state.maxDepth += tokens[tokens.length - 1].depth;
554
- }
556
+ const n = prevIndex !== undefined ? prevIndex + 1 : start;
557
+ const value = input.slice(n);
558
+ parts.push(value);
559
+ if (opts.tokens && prevIndex && prevIndex + 1 < input.length) {
560
+ tokens[tokens.length - 1].value = value;
561
+ depth(tokens[tokens.length - 1]);
562
+ state.maxDepth += tokens[tokens.length - 1].depth;
555
563
  }
556
564
  state.slashes = slashes;
557
565
  state.parts = parts;
@@ -737,7 +745,11 @@ var require_parse = __commonJS((exports, module) => {
737
745
  }
738
746
  }
739
747
  };
740
- var getStarExtglobSequenceOutput = (pattern) => {
748
+ var buildCharClassStar = (chars) => {
749
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
750
+ return `${source}*`;
751
+ };
752
+ var getStarExtglobSequenceChars = (pattern) => {
741
753
  let index = 0;
742
754
  const chars = [];
743
755
  while (index < pattern.length) {
@@ -759,8 +771,7 @@ var require_parse = __commonJS((exports, module) => {
759
771
  if (chars.length < 1) {
760
772
  return;
761
773
  }
762
- const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
763
- return `${source}*`;
774
+ return chars;
764
775
  };
765
776
  var repeatedExtglobRecursion = (pattern) => {
766
777
  let depth = 0;
@@ -784,15 +795,29 @@ var require_parse = __commonJS((exports, module) => {
784
795
  return { risky: true };
785
796
  }
786
797
  }
798
+ const safeChars = [];
799
+ let sawStarSequence = false;
800
+ let combinable = true;
787
801
  for (const branch of branches) {
788
- const safeOutput = getStarExtglobSequenceOutput(branch);
789
- if (safeOutput) {
790
- return { risky: true, safeOutput };
802
+ const chars = getStarExtglobSequenceChars(branch);
803
+ if (chars) {
804
+ sawStarSequence = true;
805
+ safeChars.push(...chars);
806
+ continue;
791
807
  }
808
+ const literal = normalizeSimpleBranch(branch);
809
+ if (literal && literal.length === 1) {
810
+ safeChars.push(literal);
811
+ continue;
812
+ }
813
+ combinable = false;
792
814
  if (repeatedExtglobRecursion(branch) > max) {
793
815
  return { risky: true };
794
816
  }
795
817
  }
818
+ if (sawStarSequence) {
819
+ return combinable ? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) } : { risky: true };
820
+ }
796
821
  return { risky: false };
797
822
  };
798
823
  var parse = (input, options) => {
@@ -1376,6 +1401,7 @@ var require_parse = __commonJS((exports, module) => {
1376
1401
  rest = rest.slice(3);
1377
1402
  consume("/**", 3);
1378
1403
  }
1404
+ const isEnd = eos() || state.parens > 0 && rest === ")".repeat(state.parens) && !extglobs.some((extglob) => extglob.type === "negate");
1379
1405
  if (prior.type === "bos" && eos()) {
1380
1406
  prev.type = "globstar";
1381
1407
  prev.value += value;
@@ -1385,7 +1411,7 @@ var require_parse = __commonJS((exports, module) => {
1385
1411
  consume(value);
1386
1412
  continue;
1387
1413
  }
1388
- if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1414
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && isEnd) {
1389
1415
  state.output = state.output.slice(0, -(prior.output + prev.output).length);
1390
1416
  prior.output = `(?:${prior.output}`;
1391
1417
  prev.type = "globstar";
@@ -1648,9 +1674,9 @@ var require_picomatch = __commonJS((exports, module) => {
1648
1674
  }
1649
1675
  return { isMatch: Boolean(match), match, output };
1650
1676
  };
1651
- picomatch.matchBase = (input, glob, options) => {
1677
+ picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
1652
1678
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1653
- return regex.test(utils.basename(input));
1679
+ return regex.test(utils.basename(input, { windows: posix }));
1654
1680
  };
1655
1681
  picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
1656
1682
  picomatch.parse = (pattern, options) => {
@@ -2977,6 +3003,7 @@ var SHELL_AUDIT_LIMITS = {
2977
3003
  maxLineBytes: 64 * 1024,
2978
3004
  maxCommandChars: 4096,
2979
3005
  maxReasonChars: 1024,
3006
+ maxPathChars: 320,
2980
3007
  migrationMaxBytes: 8 * 1024 * 1024
2981
3008
  };
2982
3009
  function decisionClassOf(event) {
@@ -3637,10 +3664,21 @@ var SHELL_AUDIT_FIELD_CLASSES = Object.freeze({
3637
3664
  resolvedScope: "redacted-path",
3638
3665
  declaredScope: "redacted-path",
3639
3666
  action: "enum",
3667
+ operator: "free-text-redacted",
3640
3668
  destructiveCategory: "enum",
3641
3669
  executorMechanism: "enum",
3642
3670
  skipReason: "enum"
3643
3671
  });
3672
+ function truncateUtf8Safe(text, maxChars) {
3673
+ if (text.length <= maxChars)
3674
+ return text;
3675
+ const cut = text.slice(0, maxChars);
3676
+ const last = cut.charCodeAt(cut.length - 1);
3677
+ if (last >= 55296 && last <= 56319) {
3678
+ return `${cut.slice(0, -1)}\u2026[truncated]`;
3679
+ }
3680
+ return `${cut}\u2026[truncated]`;
3681
+ }
3644
3682
  function hashRedactedCommand(redacted) {
3645
3683
  return createHash("sha256").update(redacted, "utf-8").digest("hex").slice(0, 16);
3646
3684
  }
@@ -3707,6 +3745,13 @@ function redactDecisionLineForArchive(line) {
3707
3745
  changed = true;
3708
3746
  }
3709
3747
  }
3748
+ if (typeof record.operator === "string") {
3749
+ const redacted = truncateUtf8Safe(redactEmbeddedPaths(record.operator), 32);
3750
+ if (redacted !== record.operator) {
3751
+ record.operator = redacted;
3752
+ changed = true;
3753
+ }
3754
+ }
3710
3755
  for (const field of ["declaredScope", "resolvedScope"]) {
3711
3756
  if (typeof record[field] === "string") {
3712
3757
  const redacted = redactPath(record[field]);
@@ -408,7 +408,7 @@ var CATALOG_SOURCE = [
408
408
  category: "gate",
409
409
  severity: "info",
410
410
  privacyClass: "pseudonymous",
411
- producer: "src/pr-review/legacy-transcript-adapter.ts:1032",
411
+ producer: "src/pr-review/legacy-transcript-adapter.ts:1063",
412
412
  consumers: NO_CONSUMERS,
413
413
  futureOwnerIssue: ISSUE_SINK,
414
414
  retentionOwnerIssue: ISSUE_LIFECYCLE_RETENTION