opencode-swarm 7.164.6 → 7.164.8

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 (96) hide show
  1. package/README.md +1 -1
  2. package/dist/background/pending-delegations.d.ts +3 -0
  3. package/dist/background/pr-subscriptions.d.ts +1 -8
  4. package/dist/cli/{coder-settlement-6qgvzx40.js → coder-settlement-qrtjv4jk.js} +14 -14
  5. package/dist/cli/{config-doctor-d1cbh67h.js → config-doctor-hp9dj0fg.js} +5 -3
  6. package/dist/cli/{core-g0cvvj3b.js → core-bmmrm36k.js} +2 -2
  7. package/dist/cli/{curation-policy-7f8x9yg6.js → curation-policy-de7emfqc.js} +7 -6
  8. package/dist/cli/{curator-drift-0r0scc8r.js → curator-drift-5sykmtf5.js} +8 -6
  9. package/dist/cli/{curator-q3qn89wn.js → curator-k8xdr1mn.js} +40 -38
  10. package/dist/cli/curator-llm-factory-pe61p0r6.js +68 -0
  11. package/dist/cli/{dispatch-q4v8x2pk.js → dispatch-dqybvj8v.js} +10 -6
  12. package/dist/cli/{evidence-summary-service-3meyb8rc.js → evidence-summary-service-qzpkdv7a.js} +20 -17
  13. package/dist/cli/{gate-evidence-mhc0w7vp.js → gate-evidence-jmns4e76.js} +14 -8
  14. package/dist/cli/guardrail-explain-vzwbmvyf.js +69 -0
  15. package/dist/cli/{guardrail-log-0nd1eqvz.js → guardrail-log-kckc7cg4.js} +9 -8
  16. package/dist/cli/{guardrail-reset-mzeyd6jh.js → guardrail-reset-acndbsv9.js} +40 -38
  17. package/dist/cli/hive-promoter-wvt5kk99.js +83 -0
  18. package/dist/cli/{index-x6zyc38w.js → index-0zjwnbze.js} +1 -1
  19. package/dist/cli/{index-x76mprg2.js → index-29w778rw.js} +185 -376
  20. package/dist/cli/{index-fxxja498.js → index-2czt53wz.js} +1 -1
  21. package/dist/cli/{index-pvp5tnn2.js → index-3sv8t7ca.js} +2 -2
  22. package/dist/cli/{index-kvb4dwgf.js → index-4pm3v7yc.js} +12 -6
  23. package/dist/cli/{index-jzvrvdmr.js → index-4v28t7jh.js} +4 -4
  24. package/dist/cli/{index-935ww10s.js → index-52m9kter.js} +1236 -1193
  25. package/dist/cli/index-7qefgq4j.js +71 -0
  26. package/dist/cli/{index-zfwd65c2.js → index-8ntf8jnj.js} +19 -18
  27. package/dist/cli/{index-m1nrd3yd.js → index-8psybzzf.js} +1 -1
  28. package/dist/cli/{index-2c3np82d.js → index-8tqqmsav.js} +1 -1
  29. package/dist/cli/{index-tegp2mny.js → index-93znbdam.js} +9 -5
  30. package/dist/cli/{index-hdapetg1.js → index-9ek9d96g.js} +3 -3
  31. package/dist/cli/{index-p56xc59p.js → index-9ydhzegh.js} +28 -17
  32. package/dist/cli/{index-ew99d4y6.js → index-apdp9bc1.js} +1 -1
  33. package/dist/cli/{index-12xzj0hm.js → index-b10yvv6h.js} +4 -4
  34. package/dist/cli/{index-zjg5ajf5.js → index-bv90qkyw.js} +72 -48
  35. package/dist/cli/{index-zypacgjc.js → index-bz8vsc8r.js} +5 -5
  36. package/dist/cli/{index-4k16cz8r.js → index-bzesypf5.js} +36 -27
  37. package/dist/cli/{index-ay9cr8tr.js → index-chcv8c7n.js} +1 -1
  38. package/dist/cli/index-cw912re7.js +200 -0
  39. package/dist/cli/{index-ty3vtqe2.js → index-espcjyrx.js} +4 -4
  40. package/dist/cli/{index-gwg7a00b.js → index-g2e8b3wm.js} +20 -15
  41. package/dist/cli/{index-rysxqae0.js → index-ghnbpez3.js} +7 -7
  42. package/dist/cli/{index-t1nkr7cz.js → index-gkqrk8dd.js} +2 -2
  43. package/dist/cli/{index-1dz8hv7p.js → index-kvq1e82k.js} +3 -3
  44. package/dist/cli/{index-ze5zyv28.js → index-mr3h3sm5.js} +2 -2
  45. package/dist/cli/{index-zaab1wz9.js → index-n4fzmqz8.js} +3 -1
  46. package/dist/cli/{index-g5714mpv.js → index-px4a2ve0.js} +17 -8
  47. package/dist/cli/index-ry16d01s.js +107 -0
  48. package/dist/cli/{index-j3hsjynw.js → index-s3z936wh.js} +100 -97
  49. package/dist/cli/{index-yh8wxegw.js → index-s6ejwhew.js} +21 -11
  50. package/dist/cli/{index-b0m3efpf.js → index-sxxh4ams.js} +2 -2
  51. package/dist/cli/{index-cyhw0der.js → index-t1qzjhnj.js} +13 -13
  52. package/dist/cli/{index-3f7hqtgg.js → index-w3gtqey0.js} +4 -1
  53. package/dist/cli/{index-9qvmsyab.js → index-wgqeqy68.js} +2 -2
  54. package/dist/cli/{index-y4z0rhsa.js → index-whz6am0v.js} +42 -40
  55. package/dist/cli/{index-g94qqwnz.js → index-wtnx33hz.js} +2 -2
  56. package/dist/cli/{index-j645xpsm.js → index-y6s0gpn3.js} +12 -5
  57. package/dist/cli/{index-6f9yvd67.js → index-ya4ta1pd.js} +2 -2
  58. package/dist/cli/{index-5p1tzpwh.js → index-ypjffdrg.js} +3 -2
  59. package/dist/cli/{index-59hvr3f4.js → index-yscwyq3t.js} +9 -6
  60. package/dist/cli/{index-7v3bb0h3.js → index-yzn1fm9a.js} +1 -1
  61. package/dist/cli/{index-qdbgc16x.js → index-z39vxvdx.js} +20 -12
  62. package/dist/cli/index.js +40 -38
  63. package/dist/cli/{knowledge-escalator-aca0nhqg.js → knowledge-escalator-h9834mrp.js} +15 -14
  64. package/dist/cli/{knowledge-events-n5t313ht.js → knowledge-events-e8hrmjf0.js} +13 -12
  65. package/dist/cli/{knowledge-link-8ea4ksda.js → knowledge-link-hhnmc4g1.js} +6 -5
  66. package/dist/cli/{knowledge-store-j97ejf6a.js → knowledge-store-w3w9gchr.js} +7 -6
  67. package/dist/cli/{knowledge-validator-01evhydg.js → knowledge-validator-exd900vc.js} +9 -8
  68. package/dist/cli/{model-preflight-pmnbfzjv.js → model-preflight-bq035tfh.js} +1 -1
  69. package/dist/cli/{pending-delegations-w73abdk3.js → pending-delegations-p4ak2e86.js} +7 -7
  70. package/dist/cli/{pr-subscriptions-05dzvavk.js → pr-subscriptions-73fs8y3n.js} +7 -6
  71. package/dist/cli/{pr-workflow-gate-t0tnkx5f.js → pr-workflow-gate-pvt2ra6e.js} +40 -38
  72. package/dist/cli/{runner-fh7t0mn9.js → runner-5qqh83e2.js} +6 -6
  73. package/dist/cli/{scan-cursor-63zx2qd8.js → scan-cursor-ysd8b563.js} +8 -7
  74. package/dist/cli/{schema-t1scx08g.js → schema-mbb9g4w4.js} +2 -2
  75. package/dist/cli/{scope-persistence-1a5qmchf.js → scope-persistence-jrbnhxvx.js} +12 -10
  76. package/dist/cli/{skill-generator-7werbwgv.js → skill-generator-b4ng5xky.js} +17 -16
  77. package/dist/cli/{sqlite-loader-8zefc142.js → sqlite-loader-xrnf6bq8.js} +1 -1
  78. package/dist/cli/{telemetry-j14cj552.js → telemetry-85gxedng.js} +1 -1
  79. package/dist/cli/{workspace-snapshot-yq0tc49d.js → workspace-snapshot-eh18vgkn.js} +2 -1
  80. package/dist/cli/{worktree-collision-ownership-wzdzky33.js → worktree-collision-ownership-ns8p2fks.js} +12 -15
  81. package/dist/cli/{worktree-isolation-m02ay3kg.js → worktree-isolation-j6zxhjab.js} +40 -38
  82. package/dist/db/canonical-project.d.ts +10 -3
  83. package/dist/db/driver-parity.d.ts +12 -0
  84. package/dist/db/project-db.d.ts +4 -0
  85. package/dist/evidence/task-gate-repair.d.ts +1 -1
  86. package/dist/gate-evidence.d.ts +19 -1
  87. package/dist/index.js +581 -581
  88. package/dist/plan/ledger.d.ts +2 -0
  89. package/dist/tools/pre-check-batch.d.ts +1 -1
  90. package/dist/utils/canonical-root.d.ts +21 -1
  91. package/dist/utils/filesystem-identity.d.ts +59 -0
  92. package/package.json +2 -1
  93. package/dist/cli/curator-llm-factory-dw7md4nr.js +0 -66
  94. package/dist/cli/guardrail-explain-6cbszhw1.js +0 -67
  95. package/dist/cli/hive-promoter-w7g879cm.js +0 -81
  96. package/dist/cli/index-ddszzne4.js +0 -42
@@ -2,30 +2,28 @@
2
2
  import {
3
3
  captureWorkspaceSnapshot,
4
4
  changedFilesSinceSnapshot
5
- } from "./index-3f7hqtgg.js";
5
+ } from "./index-w3gtqey0.js";
6
6
  import {
7
7
  removeWorktreeProvisioningOwner
8
- } from "./index-b0m3efpf.js";
8
+ } from "./index-sxxh4ams.js";
9
9
  import {
10
10
  SOURCE_WORKTREE_GONE_STAGE,
11
+ ensureTaskGateRequirementsReceiptForSettledTransition,
11
12
  getTaskWorkflowSnapshot,
12
13
  readWorkflowWalFile,
13
14
  reconcileLandedMerge,
14
15
  withTaskEvidenceTransaction,
15
16
  writeWorkflowWalFile
16
- } from "./index-g5714mpv.js";
17
- import {
18
- canonicalRootKeyFresh
19
- } from "./index-ddszzne4.js";
17
+ } from "./index-px4a2ve0.js";
20
18
  import {
21
19
  appendCoreEventSync
22
- } from "./index-pvp5tnn2.js";
20
+ } from "./index-3sv8t7ca.js";
23
21
  import {
24
22
  isPathWithinDeclaredScope
25
23
  } from "./index-556ja8an.js";
26
24
  import {
27
25
  validateSwarmPath
28
- } from "./index-2c3np82d.js";
26
+ } from "./index-8tqqmsav.js";
29
27
  import {
30
28
  init_git_executable,
31
29
  resolveGitExecutable
@@ -34,9 +32,12 @@ import {
34
32
  advisoryWarn,
35
33
  init_warning_buffer
36
34
  } from "./index-4rhhvd1a.js";
35
+ import {
36
+ canonicalRootKeyFresh
37
+ } from "./index-7qefgq4j.js";
37
38
  import {
38
39
  tryAcquireLock
39
- } from "./index-fxxja498.js";
40
+ } from "./index-2czt53wz.js";
40
41
  import {
41
42
  criticalWarn,
42
43
  init_logger
@@ -171,6 +172,23 @@ function scopedObservedFiles(directory, context) {
171
172
  return null;
172
173
  return observed.filter((filePath) => isPathWithinDeclaredScope(filePath, context.declaredFiles ?? [], directory));
173
174
  }
175
+ function settlementTransitionEvent(wal) {
176
+ return wal.accepted ? {
177
+ type: "accepted_mutation",
178
+ agentType: "coder",
179
+ context: {
180
+ testEngineerExempt: wal.testEngineerExempt === true,
181
+ settlementFailed: wal.settlementFailed === true
182
+ },
183
+ expectedGeneration: wal.expectedGeneration,
184
+ transitionId: wal.transitionId
185
+ } : {
186
+ type: "dispatch_no_mutation",
187
+ agentType: "coder",
188
+ expectedGeneration: wal.expectedGeneration,
189
+ transitionId: wal.transitionId
190
+ };
191
+ }
174
192
  async function commitPrepared(directory, wal) {
175
193
  return withTaskEvidenceTransaction(directory, wal.taskId, wal.actor, async (transaction) => {
176
194
  let lockedWal = await readWal(walPath(directory, wal.taskId), wal.taskId);
@@ -179,9 +197,14 @@ async function commitPrepared(directory, wal) {
179
197
  if (lockedWal.transitionId !== wal.transitionId) {
180
198
  throw new Error("CODER_SETTLEMENT_WAL_REPLACED");
181
199
  }
200
+ const transitionEvent = settlementTransitionEvent(lockedWal);
182
201
  const snapshot = getTaskWorkflowSnapshot(transaction.read());
183
202
  const evidenceAlreadySettled = lockedWal.accepted === true ? snapshot.authoritative && snapshot.state === (lockedWal.settlementFailed === true ? "rework_required" : "coder_delegated") && snapshot.generation === lockedWal.expectedGeneration + 1 && snapshot.lastOutcome === (lockedWal.settlementFailed === true ? "accepted_mutation_failed" : "accepted_mutation") && snapshot.lastTransitionId === lockedWal.transitionId : snapshot.generation === lockedWal.expectedGeneration && snapshot.lastOutcome === "dispatch_no_mutation" && snapshot.lastTransitionId === lockedWal.transitionId;
184
203
  if (evidenceAlreadySettled) {
204
+ const evidence2 = transaction.read();
205
+ if (lockedWal.accepted === true) {
206
+ await ensureTaskGateRequirementsReceiptForSettledTransition(directory, lockedWal.taskId, evidence2, transitionEvent);
207
+ }
185
208
  if (lockedWal.state !== "COMMITTED") {
186
209
  lockedWal = {
187
210
  ...lockedWal,
@@ -194,7 +217,7 @@ async function commitPrepared(directory, wal) {
194
217
  });
195
218
  }
196
219
  return {
197
- evidence: transaction.read(),
220
+ evidence: evidence2,
198
221
  accepted: lockedWal.accepted === true,
199
222
  alreadyApplied: true
200
223
  };
@@ -202,21 +225,7 @@ async function commitPrepared(directory, wal) {
202
225
  if (lockedWal.state !== "PREPARED") {
203
226
  throw new Error("CODER_SETTLEMENT_NOT_PREPARED");
204
227
  }
205
- const evidence = await transaction.transition(lockedWal.accepted ? {
206
- type: "accepted_mutation",
207
- agentType: "coder",
208
- context: {
209
- testEngineerExempt: lockedWal.testEngineerExempt === true,
210
- settlementFailed: lockedWal.settlementFailed === true
211
- },
212
- expectedGeneration: lockedWal.expectedGeneration,
213
- transitionId: lockedWal.transitionId
214
- } : {
215
- type: "dispatch_no_mutation",
216
- agentType: "coder",
217
- expectedGeneration: lockedWal.expectedGeneration,
218
- transitionId: lockedWal.transitionId
219
- });
228
+ const evidence = await transaction.transition(transitionEvent);
220
229
  lockedWal = {
221
230
  ...lockedWal,
222
231
  state: "COMMITTED",
@@ -478,7 +487,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
478
487
  awaitingMergeByCallID,
479
488
  cleanupStandardWorktreeForCallId,
480
489
  standardWorktreeByCallID
481
- } = await import("./worktree-isolation-m02ay3kg.js");
490
+ } = await import("./worktree-isolation-j6zxhjab.js");
482
491
  standardWorktreeByCallID.delete(descriptor.callID);
483
492
  if (hasResidue)
484
493
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -602,7 +611,7 @@ async function recoverCoderSettlement(directory, taskId) {
602
611
  awaitingMergeByCallID,
603
612
  finishStandardWorktreeDispatch,
604
613
  standardWorktreeByCallID
605
- } = await import("./worktree-isolation-m02ay3kg.js");
614
+ } = await import("./worktree-isolation-j6zxhjab.js");
606
615
  const descriptor = wal.worktree;
607
616
  const reconstructedDispatch = {
608
617
  callID: descriptor.callID,
@@ -4,7 +4,7 @@ import {
4
4
  readShellAuditTail,
5
5
  redactPath,
6
6
  redactShellCommand
7
- } from "./index-12xzj0hm.js";
7
+ } from "./index-b10yvv6h.js";
8
8
 
9
9
  // src/services/guardrail-log-service.ts
10
10
  var BLOCK_TYPES = new Set([
@@ -0,0 +1,200 @@
1
+ // @bun
2
+ import {
3
+ canonicalExistingFilesystemPath
4
+ } from "./index-ry16d01s.js";
5
+
6
+ // src/utils/path-security.ts
7
+ import * as fs from "fs";
8
+ import * as path from "path";
9
+ function containsPathTraversal(str) {
10
+ if (/\.\.[/\\]/.test(str))
11
+ return true;
12
+ if (/(?:^|[/\\])\.\.(?:[/\\]|$)/.test(str))
13
+ return true;
14
+ if (/%2e%2e/i.test(str))
15
+ return true;
16
+ if (/%2e\./i.test(str))
17
+ return true;
18
+ if (/%2e/i.test(str) && /\.\./.test(str))
19
+ return true;
20
+ if (/%252e%252e/i.test(str))
21
+ return true;
22
+ if (/\uff0e/.test(str))
23
+ return true;
24
+ if (/\u3002/.test(str))
25
+ return true;
26
+ if (/\uff65/.test(str))
27
+ return true;
28
+ if (/%2f/i.test(str))
29
+ return true;
30
+ if (/%5c/i.test(str))
31
+ return true;
32
+ return false;
33
+ }
34
+ function containsControlChars(str) {
35
+ for (const ch of str) {
36
+ const code = ch.codePointAt(0);
37
+ if (code === undefined)
38
+ continue;
39
+ if (code <= 31 || code >= 127 && code <= 159)
40
+ return true;
41
+ if (code >= 8234 && code <= 8238)
42
+ return true;
43
+ if (code >= 8294 && code <= 8297)
44
+ return true;
45
+ }
46
+ return false;
47
+ }
48
+ function validateWorkspaceRoot(directory) {
49
+ validateProjectDirectory(directory);
50
+ }
51
+ function validateDirectory(directory) {
52
+ if (!directory || directory.trim() === "") {
53
+ throw new Error("Invalid directory: empty");
54
+ }
55
+ if (containsPathTraversal(directory)) {
56
+ throw new Error("Invalid directory: path traversal detected");
57
+ }
58
+ if (containsControlChars(directory)) {
59
+ throw new Error("Invalid directory: control characters detected");
60
+ }
61
+ if (directory.startsWith("/") || directory.startsWith("\\")) {
62
+ throw new Error("Invalid directory: absolute path");
63
+ }
64
+ if (/^[A-Za-z]:[/\\]/.test(directory)) {
65
+ throw new Error("Invalid directory: Windows absolute path");
66
+ }
67
+ }
68
+ function validateProjectDirectory(directory) {
69
+ if (!directory || directory.trim() === "") {
70
+ throw new Error("Invalid project directory: empty");
71
+ }
72
+ if (containsPathTraversal(directory)) {
73
+ throw new Error("Invalid project directory: path traversal detected");
74
+ }
75
+ if (containsControlChars(directory)) {
76
+ throw new Error("Invalid project directory: control characters detected");
77
+ }
78
+ if (!path.isAbsolute(directory) && !/^[A-Za-z]:[/\\]/.test(directory)) {
79
+ throw new Error("Invalid project directory: must be an absolute path");
80
+ }
81
+ assertNotSystemLocation(directory);
82
+ }
83
+ var DENIED_ROOT_SUBTREES = new Set([
84
+ "etc",
85
+ "usr",
86
+ "bin",
87
+ "sbin",
88
+ "lib",
89
+ "lib64",
90
+ "boot",
91
+ "dev",
92
+ "proc",
93
+ "sys",
94
+ "windows",
95
+ "winnt",
96
+ "program files",
97
+ "program files (x86)",
98
+ "programdata",
99
+ "system volume information"
100
+ ]);
101
+ var DENIED_EXACT_ROOT_CHILDREN = new Set(["users", "home", "root"]);
102
+ function assertNotSystemLocation(directory) {
103
+ for (const parser of [path.win32, path.posix]) {
104
+ if (!parser.isAbsolute(directory))
105
+ continue;
106
+ const normalized = parser.normalize(directory);
107
+ const { root } = parser.parse(normalized);
108
+ const segments = normalized.slice(root.length).split(/[/\\]/).filter((segment) => segment.length > 0);
109
+ if (segments.length === 0) {
110
+ throw new Error(`Invalid project directory: filesystem root is not a project root (${directory})`);
111
+ }
112
+ const first = (segments[0] ?? "").toLowerCase();
113
+ if (DENIED_ROOT_SUBTREES.has(first) || segments.length === 1 && DENIED_EXACT_ROOT_CHILDREN.has(first)) {
114
+ throw new Error(`Invalid project directory: system location is not a project root (${directory})`);
115
+ }
116
+ }
117
+ }
118
+ function resolveNearestExistingCanonical(inputPath, resolver) {
119
+ try {
120
+ return resolver(inputPath);
121
+ } catch {}
122
+ const lexicallyResolved = path.resolve(inputPath);
123
+ let probe = lexicallyResolved;
124
+ const tail = [];
125
+ for (let i = 0;i < 4096; i++) {
126
+ const parent = path.dirname(probe);
127
+ if (parent === probe) {
128
+ return lexicallyResolved;
129
+ }
130
+ tail.unshift(path.basename(probe));
131
+ probe = parent;
132
+ try {
133
+ const canonicalAncestor = resolver(probe);
134
+ return path.normalize(path.join(canonicalAncestor, ...tail));
135
+ } catch {}
136
+ }
137
+ return lexicallyResolved;
138
+ }
139
+ function validateSymlinkBoundary(targetPath, rootPath) {
140
+ const realTarget = resolveNearestExistingCanonical(targetPath, _internals.realpathSync);
141
+ const realRoot = resolveNearestExistingCanonical(rootPath, _internals.realpathSync);
142
+ const normalizedTarget = path.normalize(realTarget);
143
+ const normalizedRoot = path.normalize(realRoot);
144
+ if (!normalizedTarget.startsWith(normalizedRoot + path.sep) && normalizedTarget !== normalizedRoot) {
145
+ throw new Error(`Symlink resolution escaped boundary: ${realTarget} is not within ${realRoot}`);
146
+ }
147
+ }
148
+ function isCanonicalPathWithinRoot(targetPath, rootPath) {
149
+ const canonicalRoot = canonicalExistingFilesystemPath(rootPath);
150
+ if (canonicalRoot === null)
151
+ return false;
152
+ const rootPrefix = canonicalRoot.endsWith("/") ? canonicalRoot : `${canonicalRoot}/`;
153
+ let probe = path.resolve(targetPath);
154
+ for (let i = 0;i < 4096; i++) {
155
+ const canonicalProbe = canonicalExistingFilesystemPath(probe);
156
+ if (canonicalProbe !== null) {
157
+ return canonicalProbe === canonicalRoot || canonicalProbe.startsWith(rootPrefix);
158
+ }
159
+ const parent = path.dirname(probe);
160
+ if (parent === probe)
161
+ return false;
162
+ probe = parent;
163
+ }
164
+ return false;
165
+ }
166
+ function validateTargetWithinRoot(filePath, root) {
167
+ if (!filePath || filePath.trim() === "") {
168
+ return "Empty path";
169
+ }
170
+ if (path.isAbsolute(filePath) || /^[A-Za-z]:[/\\]/.test(filePath)) {
171
+ return `Absolute path rejected: ${filePath}`;
172
+ }
173
+ if (containsPathTraversal(filePath)) {
174
+ return `Path traversal detected: ${filePath}`;
175
+ }
176
+ if (containsControlChars(filePath)) {
177
+ return `Control characters detected in path: ${filePath}`;
178
+ }
179
+ const resolved = path.resolve(root, filePath);
180
+ const relative2 = path.relative(root, resolved);
181
+ if (relative2.startsWith("..") || path.isAbsolute(relative2)) {
182
+ return `Path escapes root: ${filePath}`;
183
+ }
184
+ if (!isCanonicalPathWithinRoot(resolved, root)) {
185
+ return `Path escapes root via symlink/junction: ${filePath}`;
186
+ }
187
+ return null;
188
+ }
189
+ var _internals = {
190
+ realpathSync: fs.realpathSync,
191
+ containsPathTraversal,
192
+ containsControlChars,
193
+ validateDirectory,
194
+ validateProjectDirectory,
195
+ validateSymlinkBoundary,
196
+ isCanonicalPathWithinRoot,
197
+ validateTargetWithinRoot
198
+ };
199
+
200
+ export { containsPathTraversal, containsControlChars, validateWorkspaceRoot, validateSymlinkBoundary, isCanonicalPathWithinRoot, validateTargetWithinRoot };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  _internals,
4
4
  resolveWorktreeIsolationConfig
5
- } from "./index-hdapetg1.js";
5
+ } from "./index-9ek9d96g.js";
6
6
  import {
7
7
  ApprovalEvidenceSchema,
8
8
  BaseEvidenceSchema,
@@ -44,7 +44,7 @@ import {
44
44
  loadPluginConfigWithMeta,
45
45
  loadPluginConfigWithMetaAsync,
46
46
  resetConfigAdvisoryDedup
47
- } from "./index-ew99d4y6.js";
47
+ } from "./index-apdp9bc1.js";
48
48
  import {
49
49
  AUTO_REVIEW_V8_BURN_IN_DECISION,
50
50
  AgentOverrideConfigSchema,
@@ -68,7 +68,7 @@ import {
68
68
  TurboConfigSchema,
69
69
  WorktreeIsolationConfigSchema,
70
70
  resolveAutoReviewConfig
71
- } from "./index-5p1tzpwh.js";
71
+ } from "./index-ypjffdrg.js";
72
72
  import"./index-9e6fdz2h.js";
73
73
  import"./index-4rhhvd1a.js";
74
74
  import {
@@ -80,7 +80,7 @@ import {
80
80
  QA_AGENTS,
81
81
  isQAAgent,
82
82
  isSubagent
83
- } from "./index-m1nrd3yd.js";
83
+ } from "./index-8psybzzf.js";
84
84
  import"./index-zjygnfay.js";
85
85
  import"./index-bk5tah7q.js";
86
86
  import"./index-bpmtbmy9.js";
@@ -1,32 +1,35 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-2c3np82d.js";
4
+ } from "./index-8tqqmsav.js";
5
5
  import {
6
6
  loadPluginConfigWithMeta
7
- } from "./index-ew99d4y6.js";
7
+ } from "./index-apdp9bc1.js";
8
8
  import {
9
9
  KnowledgeConfigSchema,
10
10
  init_schema
11
- } from "./index-5p1tzpwh.js";
11
+ } from "./index-ypjffdrg.js";
12
12
  import {
13
13
  observeReceiptTransition
14
- } from "./index-p56xc59p.js";
14
+ } from "./index-9ydhzegh.js";
15
15
  import {
16
16
  resolveHiveEventsPath
17
17
  } from "./index-ae75rja9.js";
18
18
  import {
19
19
  resolveKnowledgeStoreDir
20
- } from "./index-tegp2mny.js";
20
+ } from "./index-93znbdam.js";
21
21
  import {
22
22
  atomicWriteFile
23
- } from "./index-ze5zyv28.js";
23
+ } from "./index-mr3h3sm5.js";
24
+ import {
25
+ canonicalRootKey
26
+ } from "./index-7qefgq4j.js";
24
27
  import {
25
28
  assertProjectRoot
26
- } from "./index-fxxja498.js";
29
+ } from "./index-2czt53wz.js";
27
30
  import {
28
31
  emit
29
- } from "./index-1dz8hv7p.js";
32
+ } from "./index-kvq1e82k.js";
30
33
  import {
31
34
  require_proper_lockfile
32
35
  } from "./index-7g4c7s5r.js";
@@ -2437,10 +2440,11 @@ async function buildCounterRollupCacheKey(directory) {
2437
2440
  return `${eventsKey}|${legacyKey}|${baselineKey}`;
2438
2441
  }
2439
2442
  function setCounterRollupCache(directory, key, rollups) {
2440
- if (counterRollupCache.has(directory)) {
2441
- counterRollupCache.delete(directory);
2443
+ const cacheKey = canonicalRootKey(directory);
2444
+ if (counterRollupCache.has(cacheKey)) {
2445
+ counterRollupCache.delete(cacheKey);
2442
2446
  }
2443
- counterRollupCache.set(directory, {
2447
+ counterRollupCache.set(cacheKey, {
2444
2448
  key,
2445
2449
  rollups: cloneRollupMap(rollups)
2446
2450
  });
@@ -2646,10 +2650,11 @@ async function countEntryContradictionsInWindow(directory, entryId, windowDays,
2646
2650
  async function readKnowledgeCounterRollups(directory) {
2647
2651
  try {
2648
2652
  const cacheKey = await buildCounterRollupCacheKey(directory);
2649
- const cached = counterRollupCache.get(directory);
2653
+ const directoryKey = canonicalRootKey(directory);
2654
+ const cached = counterRollupCache.get(directoryKey);
2650
2655
  if (cached?.key === cacheKey) {
2651
- counterRollupCache.delete(directory);
2652
- counterRollupCache.set(directory, cached);
2656
+ counterRollupCache.delete(directoryKey);
2657
+ counterRollupCache.set(directoryKey, cached);
2653
2658
  return cloneRollupMap(cached.rollups);
2654
2659
  }
2655
2660
  const [events, legacyRecords, baseline] = await Promise.all([
@@ -2810,7 +2815,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
2810
2815
  }
2811
2816
  let bumps = 0;
2812
2817
  if (deltas.length > 0) {
2813
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-j97ejf6a.js");
2818
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-w3w9gchr.js");
2814
2819
  bumps = await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
2815
2820
  }
2816
2821
  return {
@@ -6,17 +6,17 @@ import {
6
6
  } from "./index-ae75rja9.js";
7
7
  import {
8
8
  resolveKnowledgeStoreDir
9
- } from "./index-tegp2mny.js";
9
+ } from "./index-93znbdam.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-ze5zyv28.js";
12
+ } from "./index-mr3h3sm5.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus
16
16
  } from "./index-bk5tah7q.js";
17
17
  import {
18
18
  readCachedParsedFile
19
- } from "./index-cyhw0der.js";
19
+ } from "./index-t1qzjhnj.js";
20
20
  import {
21
21
  require_proper_lockfile
22
22
  } from "./index-7g4c7s5r.js";
@@ -713,7 +713,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
713
713
  const {
714
714
  readAuthoritativeKnowledgeCounterRollups,
715
715
  effectiveRetrievalOutcomes
716
- } = await import("./knowledge-events-n5t313ht.js");
716
+ } = await import("./knowledge-events-e8hrmjf0.js");
717
717
  const rollups = await readAuthoritativeKnowledgeCounterRollups(directory);
718
718
  const flagIds = new Set;
719
719
  for (const e of atFloor) {
@@ -780,11 +780,11 @@ async function applyConfidenceFloorAction(directory, touched, options) {
780
780
  });
781
781
  }
782
782
  if (action === "quarantine" && toQuarantine.length > 0) {
783
- const { quarantineEntry } = await import("./knowledge-validator-01evhydg.js");
784
- const { KnowledgeConfigSchema } = await import("./schema-t1scx08g.js");
783
+ const { quarantineEntry } = await import("./knowledge-validator-exd900vc.js");
784
+ const { KnowledgeConfigSchema } = await import("./schema-mbb9g4w4.js");
785
785
  let config;
786
786
  try {
787
- const { loadPluginConfigWithMeta } = await import("./index-ty3vtqe2.js");
787
+ const { loadPluginConfigWithMeta } = await import("./index-espcjyrx.js");
788
788
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
789
789
  config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
790
790
  } catch {
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  SWARM_WORKTREE_DIR_NAME,
15
15
  init_constants
16
- } from "./index-m1nrd3yd.js";
16
+ } from "./index-8psybzzf.js";
17
17
  import {
18
18
  log
19
19
  } from "./index-zgwm4ryv.js";
@@ -92,7 +92,7 @@ var _internals = {
92
92
  symlinkSync: fs.symlinkSync
93
93
  },
94
94
  writeScopeToDisk: async (directory, taskId, files) => {
95
- const { writeScopeToDisk: realWrite } = await import("./scope-persistence-1a5qmchf.js");
95
+ const { writeScopeToDisk: realWrite } = await import("./scope-persistence-jrbnhxvx.js");
96
96
  return realWrite(directory, taskId, files);
97
97
  },
98
98
  writeLaneProfileToDisk: async (_worktreePath, _laneIndex, _envOverrides) => {
@@ -665,7 +665,7 @@ var CATALOG_SOURCE = [
665
665
  category: "plan",
666
666
  severity: "notice",
667
667
  privacyClass: "operational",
668
- producer: "src/plan/manager.ts:345",
668
+ producer: "src/plan/manager.ts:346",
669
669
  consumers: NO_CONSUMERS,
670
670
  futureOwnerIssue: ISSUE_SINK,
671
671
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -678,7 +678,7 @@ var CATALOG_SOURCE = [
678
678
  category: "plan",
679
679
  severity: "warning",
680
680
  privacyClass: "sensitive",
681
- producer: "src/plan/manager.ts:1853",
681
+ producer: "src/plan/manager.ts:1854",
682
682
  consumers: NO_CONSUMERS,
683
683
  futureOwnerIssue: ISSUE_SINK,
684
684
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -691,7 +691,7 @@ var CATALOG_SOURCE = [
691
691
  category: "plan",
692
692
  severity: "error",
693
693
  privacyClass: "sensitive",
694
- producer: "src/plan/ledger.ts:1167",
694
+ producer: "src/plan/ledger.ts:1176",
695
695
  consumers: NO_CONSUMERS,
696
696
  futureOwnerIssue: ISSUE_SINK,
697
697
  retentionOwnerIssue: ISSUE_PLAN_EVIDENCE_RETENTION,
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  withEvidenceLock
4
- } from "./index-fxxja498.js";
4
+ } from "./index-2czt53wz.js";
5
5
  import {
6
6
  atomicWriteFileAnyRoot
7
- } from "./index-cyhw0der.js";
7
+ } from "./index-t1qzjhnj.js";
8
8
 
9
9
  // src/evidence/task-file.ts
10
10
  import * as path from "path";
@@ -18,10 +18,12 @@ function createNodeDatabaseCtor(DatabaseSyncCtor) {
18
18
  }
19
19
  return stmt;
20
20
  }
21
+ static CHANGES_PROBE_SQL = "SELECT changes() AS c, last_insert_rowid() AS r";
21
22
  run(sql, ...rest) {
22
23
  if (rest.length === 0) {
23
24
  this.raw.exec(sql);
24
- return;
25
+ const row = this.statement(NodeSqliteDatabase.CHANGES_PROBE_SQL).get();
26
+ return { changes: Number(row?.c ?? 0), lastInsertRowid: row?.r ?? 0 };
25
27
  }
26
28
  const params = rest.length === 1 && Array.isArray(rest[0]) ? rest[0] : rest;
27
29
  return this.statement(sql).run(...params);
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  autoCommitDirty,
4
4
  cleanUntrackedFiles
5
- } from "./index-t1nkr7cz.js";
5
+ } from "./index-gkqrk8dd.js";
6
6
  import {
7
7
  isPathWithinDeclaredScope,
8
8
  unsafePathTextReason
9
9
  } from "./index-556ja8an.js";
10
10
  import {
11
11
  validateSwarmPath
12
- } from "./index-2c3np82d.js";
12
+ } from "./index-8tqqmsav.js";
13
13
  import {
14
14
  bunSpawn,
15
15
  classifySpawnFailure
@@ -26,13 +26,13 @@ import {
26
26
  atomicWriteFile,
27
27
  taskEvidencePath,
28
28
  withTaskEvidenceLock
29
- } from "./index-ze5zyv28.js";
29
+ } from "./index-mr3h3sm5.js";
30
30
  import {
31
31
  assertProjectRoot
32
- } from "./index-fxxja498.js";
32
+ } from "./index-2czt53wz.js";
33
33
  import {
34
34
  telemetry
35
- } from "./index-1dz8hv7p.js";
35
+ } from "./index-kvq1e82k.js";
36
36
  import {
37
37
  exports_external,
38
38
  init_zod
@@ -1557,6 +1557,9 @@ async function writeWorkflowWalFile(kind, filePath, wal) {
1557
1557
  }
1558
1558
 
1559
1559
  // src/gate-evidence.ts
1560
+ var _internals3 = {
1561
+ appendTaskGateRequirementsReceiptIfNeeded
1562
+ };
1560
1563
  var TASK_WORKFLOW_SCHEMA_MARKER = "exact-task-v1";
1561
1564
  var TASK_WORKFLOW_STATES = [
1562
1565
  "idle",
@@ -1585,6 +1588,7 @@ var TASK_WORKFLOW_OUTCOMES = [
1585
1588
  "task_closed",
1586
1589
  "repair_idle"
1587
1590
  ];
1591
+ var TASK_GATE_REQUIREMENTS_RECONSTRUCTION_SENTINEL = "requirements_reconstruction";
1588
1592
  function assertTaskEvidenceWriteAllowed(directory, taskId, event) {
1589
1593
  assertValidTaskId(taskId);
1590
1594
  const coderWalPath = validateSwarmPath(directory, `coder-settlements/${taskId}.json`);
@@ -1720,7 +1724,7 @@ function maybeExpandRequiredGates(existing, event) {
1720
1724
  if (event.type === "accepted_mutation") {
1721
1725
  const agentType = event.agentType;
1722
1726
  if (typeof agentType === "string" && agentType.trim() !== "") {
1723
- return existing ? expandRequiredGates(existing.required_gates, agentType, event.context ?? {}) : deriveRequiredGates(agentType, event.context ?? {});
1727
+ return existing ? expandRequiredGates(existing.required_gates.filter((gate) => gate !== TASK_GATE_REQUIREMENTS_RECONSTRUCTION_SENTINEL), agentType, event.context ?? {}) : deriveRequiredGates(agentType, event.context ?? {});
1724
1728
  }
1725
1729
  }
1726
1730
  if (event.type === "stage_b_completed" && event.ensureDefaultStageB === true) {
@@ -2031,7 +2035,7 @@ async function withTaskEvidenceTransaction(directory, taskId, agent, callback) {
2031
2035
  });
2032
2036
  await atomicWriteFile(evidencePath, JSON.stringify(validated, null, 2));
2033
2037
  if (event) {
2034
- await appendTaskGateRequirementsReceiptIfNeeded(directory, taskId, current, validated, event);
2038
+ await _internals3.appendTaskGateRequirementsReceiptIfNeeded(directory, taskId, current, validated, event);
2035
2039
  }
2036
2040
  current = validated;
2037
2041
  return validated;
@@ -2048,6 +2052,11 @@ async function withTaskEvidenceTransaction(directory, taskId, agent, callback) {
2048
2052
  });
2049
2053
  });
2050
2054
  }
2055
+ async function ensureTaskGateRequirementsReceiptForSettledTransition(directory, taskId, evidence, event) {
2056
+ assertValidTaskId(taskId);
2057
+ const validated = TaskEvidenceSchema.parse({ ...evidence, taskId });
2058
+ await _internals3.appendTaskGateRequirementsReceiptIfNeeded(directory, taskId, null, validated, event);
2059
+ }
2051
2060
  async function recordGateEvidence(directory, taskId, gate, sessionId, turbo, options = {}) {
2052
2061
  assertValidTaskId(taskId);
2053
2062
  if (shouldTreatGateAsStageB(gate) && typeof options.expectedGeneration !== "number") {
@@ -2121,4 +2130,4 @@ function compareTaskWorkflowStateRank(left, right) {
2121
2130
  return WORKFLOW_STATE_RANK[left] - WORKFLOW_STATE_RANK[right];
2122
2131
  }
2123
2132
 
2124
- export { isStrictTaskId, sanitizeTaskId, listRecoveryRecords, GitBinaryMissingError, GitSpawnCwdError, isGitBinaryMissing, isSpawnCwdMissing, isSpawnCwdUnreadable, _internals, SOURCE_WORKTREE_GONE_STAGE, SOURCE_WORKTREE_UNCERTAIN_STAGE, getMergeStrategy, recoverMergeBackFromImmutableCoordinates, reconcileLandedMerge, postMergeCleanup, pruneStaleWorktreeMetadata, attemptMergeBackFromDirty, cleanupOrphanedBranches, startupOrphanRecovery, readWorkflowWalFile, writeWorkflowWalFile, TASK_WORKFLOW_SCHEMA_MARKER, assertTaskEvidenceWriteAllowed, parseTaskEvidence, DEFAULT_REQUIRED_GATES, isValidTaskId, getTaskWorkflowSnapshot, reduceTaskWorkflowSnapshot, deriveRequiredGates, expandRequiredGates, transitionTaskWorkflowEvidence, withTaskEvidenceTransaction, recordGateEvidence, recordAgentDispatch, readTaskEvidence, readTaskEvidenceRaw, hasPassedAllGates, compareTaskWorkflowStateRank };
2133
+ export { isStrictTaskId, sanitizeTaskId, listRecoveryRecords, GitBinaryMissingError, GitSpawnCwdError, isGitBinaryMissing, isSpawnCwdMissing, isSpawnCwdUnreadable, _internals, SOURCE_WORKTREE_GONE_STAGE, SOURCE_WORKTREE_UNCERTAIN_STAGE, getMergeStrategy, recoverMergeBackFromImmutableCoordinates, reconcileLandedMerge, postMergeCleanup, pruneStaleWorktreeMetadata, attemptMergeBackFromDirty, cleanupOrphanedBranches, startupOrphanRecovery, readWorkflowWalFile, writeWorkflowWalFile, _internals3 as _internals1, TASK_WORKFLOW_SCHEMA_MARKER, TASK_GATE_REQUIREMENTS_RECONSTRUCTION_SENTINEL, assertTaskEvidenceWriteAllowed, parseTaskEvidence, DEFAULT_REQUIRED_GATES, isValidTaskId, getTaskWorkflowSnapshot, reduceTaskWorkflowSnapshot, deriveRequiredGates, expandRequiredGates, transitionTaskWorkflowEvidence, withTaskEvidenceTransaction, ensureTaskGateRequirementsReceiptForSettledTransition, recordGateEvidence, recordAgentDispatch, readTaskEvidence, readTaskEvidenceRaw, hasPassedAllGates, compareTaskWorkflowStateRank };