opencode-swarm 7.130.1 → 7.131.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 (77) hide show
  1. package/dist/cli/{config-doctor-489wej17.js → config-doctor-rjvb0hhn.js} +2 -2
  2. package/dist/cli/{curation-policy-aaz0hap6.js → curation-policy-f5bybzmh.js} +2 -2
  3. package/dist/cli/{curator-by14m5fc.js → curator-kjzqa5m7.js} +14 -14
  4. package/dist/cli/{curator-llm-factory-7rz7mvcr.js → curator-llm-factory-ezq4fakt.js} +14 -14
  5. package/dist/cli/{evidence-summary-service-hf7qq777.js → evidence-summary-service-jfagmvrh.js} +1 -1
  6. package/dist/cli/{guardrail-explain-mvct2n9f.js → guardrail-explain-n93qh8k6.js} +15 -15
  7. package/dist/cli/{guardrail-log-2cejc33f.js → guardrail-log-h4tmcjwx.js} +3 -3
  8. package/dist/cli/{hive-promoter-trezcyrd.js → hive-promoter-mammxe5p.js} +14 -14
  9. package/dist/cli/{index-jvyn76xe.js → index-01nyrk95.js} +3 -3
  10. package/dist/cli/{index-kzvwb2se.js → index-03zyn94g.js} +110 -85
  11. package/dist/cli/{index-xa29259t.js → index-1atz85c8.js} +1 -1
  12. package/dist/cli/{index-j0py44fv.js → index-6vg0qczz.js} +2 -2
  13. package/dist/cli/{index-zft4hp35.js → index-cnwh164k.js} +1 -1
  14. package/dist/cli/{index-hjar4crm.js → index-cq22pnd2.js} +1 -1
  15. package/dist/cli/{index-4qrbvrz5.js → index-d2tgc580.js} +2689 -1241
  16. package/dist/cli/{index-jxha73tm.js → index-fepakwhp.js} +1 -1
  17. package/dist/cli/{index-f2y46pda.js → index-h3k62043.js} +20 -6
  18. package/dist/cli/{index-5xxgeksy.js → index-hynbzh7s.js} +46 -2
  19. package/dist/cli/{index-p6qgjkbt.js → index-kbfhyxtv.js} +9 -1
  20. package/dist/cli/{index-3rnkyb60.js → index-m6zfm7cm.js} +5 -5
  21. package/dist/cli/{index-s8h2cedv.js → index-pft1qxqh.js} +1 -1
  22. package/dist/cli/{index-ts9wh1ba.js → index-q68sprcy.js} +60 -8
  23. package/dist/cli/{index-agte9w1e.js → index-szkswbqf.js} +2 -2
  24. package/dist/cli/{index-nr5pr54q.js → index-tw33v84d.js} +1 -1
  25. package/dist/cli/{index-xdx5b4s1.js → index-xhd797bz.js} +16 -16
  26. package/dist/cli/{index-wy3q73j2.js → index-xv2ydncg.js} +18 -14
  27. package/dist/cli/index.js +14 -14
  28. package/dist/cli/{knowledge-escalator-1ypz0266.js → knowledge-escalator-cf1kkmfe.js} +3 -3
  29. package/dist/cli/{knowledge-events-yvcczmja.js → knowledge-events-p8t5ev44.js} +1 -1
  30. package/dist/cli/{knowledge-store-h8bp9eje.js → knowledge-store-vpdmcwem.js} +3 -1
  31. package/dist/cli/{knowledge-validator-sz9v1fdq.js → knowledge-validator-w1t0sw5f.js} +4 -4
  32. package/dist/cli/{scan-cursor-k9zyt374.js → scan-cursor-z4c51902.js} +2 -2
  33. package/dist/cli/{schema-fkpn2r1s.js → schema-yqzzfavj.js} +5 -1
  34. package/dist/cli/{skill-generator-a6a9jxfd.js → skill-generator-aaabj00n.js} +5 -5
  35. package/dist/cli/{workspace-snapshot-jwkjg790.js → workspace-snapshot-35qc0y8a.js} +1 -1
  36. package/dist/commands/consolidate.d.ts +14 -0
  37. package/dist/commands/curate.d.ts +2 -0
  38. package/dist/commands/promote.d.ts +25 -0
  39. package/dist/commands/registry.d.ts +2 -2
  40. package/dist/config/schema.d.ts +101 -0
  41. package/dist/consensus/contracts.d.ts +479 -0
  42. package/dist/consensus/corpus.d.ts +261 -0
  43. package/dist/consensus/miner.d.ts +200 -0
  44. package/dist/consensus/public-api.d.ts +42 -0
  45. package/dist/consensus/store.d.ts +119 -0
  46. package/dist/evidence/immutable-store.d.ts +86 -0
  47. package/dist/evidence/manager.d.ts +31 -1
  48. package/dist/hooks/actionability-predicate.d.ts +36 -0
  49. package/dist/hooks/curator.d.ts +3 -0
  50. package/dist/hooks/hive-policy.d.ts +11 -0
  51. package/dist/hooks/hive-promoter.d.ts +27 -1
  52. package/dist/hooks/knowledge-dedup-sweep.d.ts +145 -0
  53. package/dist/hooks/knowledge-injector.d.ts +4 -0
  54. package/dist/hooks/knowledge-store.d.ts +26 -0
  55. package/dist/hooks/knowledge-types.d.ts +6 -0
  56. package/dist/hooks/knowledge-validator.d.ts +10 -14
  57. package/dist/hooks/micro-reflector.d.ts +106 -2
  58. package/dist/hooks/realtime-learning-nudge.d.ts +19 -0
  59. package/dist/index.js +427 -419
  60. package/dist/knowledge/entry-merge.d.ts +112 -0
  61. package/dist/knowledge/family-migration.d.ts +6 -2
  62. package/dist/learning/admission.d.ts +154 -0
  63. package/dist/learning/candidate-queue.d.ts +178 -0
  64. package/dist/learning/fingerprint.d.ts +56 -0
  65. package/dist/learning/prm-pattern-support.d.ts +124 -0
  66. package/dist/learning/provenance.d.ts +86 -0
  67. package/dist/prm/index.d.ts +46 -1
  68. package/dist/services/recommendation-ledger.d.ts +266 -0
  69. package/dist/services/skill-improver.d.ts +4 -0
  70. package/dist/services/status-service.d.ts +13 -0
  71. package/dist/services/trajectory-cluster.d.ts +65 -2
  72. package/dist/tools/consensus-mine.d.ts +172 -0
  73. package/dist/tools/index.d.ts +1 -0
  74. package/dist/tools/knowledge-add.d.ts +34 -0
  75. package/dist/tools/manifest.d.ts +1 -0
  76. package/dist/tools/tool-metadata.d.ts +4 -0
  77. package/package.json +1 -1
@@ -3432,11 +3432,11 @@ import {
3432
3432
  } from "fs";
3433
3433
  import * as fs7 from "fs/promises";
3434
3434
  import * as os4 from "os";
3435
- import * as path12 from "path";
3435
+ import * as path13 from "path";
3436
3436
 
3437
3437
  // src/evaluation/retention.ts
3438
3438
  import * as fs5 from "fs/promises";
3439
- import * as path11 from "path";
3439
+ import * as path12 from "path";
3440
3440
 
3441
3441
  // src/evaluation/contracts.ts
3442
3442
  init_zod();
@@ -3811,14 +3811,55 @@ var TaskSetSnapshotV1Schema = exports_external.object({
3811
3811
  }).strict();
3812
3812
 
3813
3813
  // src/evaluation/store.ts
3814
- import { mkdir, readdir, readFile as readFile2 } from "fs/promises";
3815
- import * as path10 from "path";
3814
+ import { mkdir as mkdir2, readdir, readFile as readFile3 } from "fs/promises";
3815
+ import * as path11 from "path";
3816
+
3817
+ // src/evidence/immutable-store.ts
3818
+ import { mkdir, readFile } from "fs/promises";
3819
+ import * as path9 from "path";
3820
+ async function readOptionalFile(filePath) {
3821
+ try {
3822
+ return await readFile(filePath, "utf8");
3823
+ } catch (error2) {
3824
+ if (error2.code === "ENOENT")
3825
+ return;
3826
+ throw error2;
3827
+ }
3828
+ }
3829
+ async function writeImmutableArtifact(options) {
3830
+ await mkdir(path9.dirname(options.filePath), { recursive: true });
3831
+ return withEvidenceLock(options.directory, options.relativeLockPath, options.agent, options.taskId, async () => {
3832
+ const desired = options.serialize(options.value);
3833
+ const existing = await readOptionalFile(options.filePath);
3834
+ if (existing !== undefined) {
3835
+ let parsed;
3836
+ try {
3837
+ parsed = options.parse(JSON.parse(existing));
3838
+ } catch (error2) {
3839
+ throw options.conflictError({
3840
+ kind: "corrupt",
3841
+ filePath: options.filePath,
3842
+ cause: error2
3843
+ });
3844
+ }
3845
+ if (options.serialize(parsed) === desired || options.isEquivalent?.(parsed, options.value)) {
3846
+ return parsed;
3847
+ }
3848
+ throw options.conflictError({
3849
+ kind: "divergent",
3850
+ filePath: options.filePath
3851
+ });
3852
+ }
3853
+ await atomicWriteFile(options.filePath, desired);
3854
+ return options.value;
3855
+ });
3856
+ }
3816
3857
 
3817
3858
  // src/evaluation/hashing.ts
3818
3859
  import { createHash as createHash2 } from "crypto";
3819
3860
  import { lstatSync, realpathSync } from "fs";
3820
- import { lstat, opendir, readFile, realpath } from "fs/promises";
3821
- import * as path9 from "path";
3861
+ import { lstat, opendir, readFile as readFile2, realpath } from "fs/promises";
3862
+ import * as path10 from "path";
3822
3863
  function canonicalize(value, ancestors) {
3823
3864
  if (value === null || typeof value === "string" || typeof value === "boolean") {
3824
3865
  return value;
@@ -3909,7 +3950,7 @@ async function hashTree(projectRoot, relativePath, budget) {
3909
3950
  }
3910
3951
  if (!entryAlreadyCharged)
3911
3952
  chargeHashEntry(budget);
3912
- const relative2 = path9.relative(canonicalRoot, absolutePath).replace(/\\/g, "/");
3953
+ const relative2 = path10.relative(canonicalRoot, absolutePath).replace(/\\/g, "/");
3913
3954
  if (stat.isDirectory()) {
3914
3955
  entries.push({ path: relative2, type: "directory" });
3915
3956
  const children = [];
@@ -3926,7 +3967,7 @@ async function hashTree(projectRoot, relativePath, budget) {
3926
3967
  await closeDirectory(directory);
3927
3968
  }
3928
3969
  for (const child of children.sort()) {
3929
- await visit(path9.join(absolutePath, child), true);
3970
+ await visit(path10.join(absolutePath, child), true);
3930
3971
  }
3931
3972
  return;
3932
3973
  }
@@ -3969,10 +4010,10 @@ async function computeTaskLineageInputHash(projectRoot, task, limits = {}) {
3969
4010
  const normalizedTree = async (relativePath) => {
3970
4011
  const canonicalRoot = await _internals9.realpath(projectRoot);
3971
4012
  const target = await resolveContainedExistingPathAsync(projectRoot, relativePath);
3972
- const targetRelative = path9.relative(canonicalRoot, target).replace(/\\/g, "/");
4013
+ const targetRelative = path10.relative(canonicalRoot, target).replace(/\\/g, "/");
3973
4014
  return (await hashTree(projectRoot, relativePath, budget)).map((entry) => ({
3974
4015
  ...entry,
3975
- path: path9.posix.relative(targetRelative, entry.path) || "."
4016
+ path: path10.posix.relative(targetRelative, entry.path) || "."
3976
4017
  }));
3977
4018
  };
3978
4019
  const scorerArgv = [...task.scorer.argv];
@@ -4001,11 +4042,11 @@ function computeManifestContentHash(manifest) {
4001
4042
  return contentHashWithout(manifest, ["contentHash"]);
4002
4043
  }
4003
4044
  function isWithin(root, candidate) {
4004
- const relative2 = path9.relative(root, candidate);
4005
- return relative2 === "" || !relative2.startsWith("..") && !path9.isAbsolute(relative2);
4045
+ const relative2 = path10.relative(root, candidate);
4046
+ return relative2 === "" || !relative2.startsWith("..") && !path10.isAbsolute(relative2);
4006
4047
  }
4007
4048
  function resolveContainedExistingPath(root, relativePath) {
4008
- if (path9.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4049
+ if (path10.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4009
4050
  throw new Error("evaluation path must be a non-NUL relative path");
4010
4051
  }
4011
4052
  const segments = relativePath.replace(/\\/g, "/").split("/").filter(Boolean);
@@ -4017,7 +4058,7 @@ function resolveContainedExistingPath(root, relativePath) {
4017
4058
  for (const segment of segments) {
4018
4059
  if (segment === ".")
4019
4060
  continue;
4020
- cursor = path9.join(cursor, segment);
4061
+ cursor = path10.join(cursor, segment);
4021
4062
  const stat = lstatSync(cursor);
4022
4063
  if (stat.isSymbolicLink()) {
4023
4064
  throw new Error(`evaluation path contains a symlink or reparse point: ${relativePath}`);
@@ -4030,7 +4071,7 @@ function resolveContainedExistingPath(root, relativePath) {
4030
4071
  return canonicalCandidate;
4031
4072
  }
4032
4073
  async function resolveContainedExistingPathAsync(root, relativePath) {
4033
- if (path9.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4074
+ if (path10.isAbsolute(relativePath) || /^(?:[A-Za-z]:[\\/]|[\\/]{1,2})/.test(relativePath) || relativePath.includes("\x00")) {
4034
4075
  throw new Error("evaluation path must be a non-NUL relative path");
4035
4076
  }
4036
4077
  const segments = relativePath.replace(/\\/g, "/").split("/").filter(Boolean);
@@ -4042,7 +4083,7 @@ async function resolveContainedExistingPathAsync(root, relativePath) {
4042
4083
  for (const segment of segments) {
4043
4084
  if (segment === ".")
4044
4085
  continue;
4045
- cursor = path9.join(cursor, segment);
4086
+ cursor = path10.join(cursor, segment);
4046
4087
  const stat = await _internals9.lstat(cursor);
4047
4088
  if (stat.isSymbolicLink()) {
4048
4089
  throw new Error(`evaluation path contains a symlink or reparse point: ${relativePath}`);
@@ -4057,14 +4098,14 @@ async function resolveContainedExistingPathAsync(root, relativePath) {
4057
4098
  var _internals9 = {
4058
4099
  lstat,
4059
4100
  opendir,
4060
- readFile,
4101
+ readFile: readFile2,
4061
4102
  realpath
4062
4103
  };
4063
4104
 
4064
4105
  // src/evaluation/store.ts
4065
4106
  var AGENT = "evaluation-store";
4066
- var TEST_LEDGER_RELATIVE = path10.join("evolution", "test-consumption.jsonl");
4067
- var TASK_SPLIT_REGISTRY_RELATIVE = path10.join("evolution", "tasks", "split-registry.json");
4107
+ var TEST_LEDGER_RELATIVE = path11.join("evolution", "test-consumption.jsonl");
4108
+ var TASK_SPLIT_REGISTRY_RELATIVE = path11.join("evolution", "tasks", "split-registry.json");
4068
4109
 
4069
4110
  class EvaluationConflictError extends Error {
4070
4111
  constructor(message) {
@@ -4073,7 +4114,7 @@ class EvaluationConflictError extends Error {
4073
4114
  }
4074
4115
  }
4075
4116
  function swarmPath(directory, ...segments) {
4076
- return path10.join(directory, ".swarm", ...segments);
4117
+ return path11.join(directory, ".swarm", ...segments);
4077
4118
  }
4078
4119
  function serialized(value) {
4079
4120
  return `${canonicalJson(value)}
@@ -4112,34 +4153,15 @@ function parseTaskSplitRegistry(content) {
4112
4153
  });
4113
4154
  return { v: 1, entries };
4114
4155
  }
4115
- async function readOptional(filePath) {
4116
- try {
4117
- return await readFile2(filePath, "utf8");
4118
- } catch (error2) {
4119
- if (error2.code === "ENOENT")
4120
- return;
4121
- throw error2;
4122
- }
4156
+ function evaluationConflictError(conflict) {
4157
+ return conflict.kind === "corrupt" ? new EvaluationConflictError(`existing evaluation artifact is corrupt: ${conflict.filePath}: ${String(conflict.cause)}`) : new EvaluationConflictError(`immutable evaluation artifact conflicts with existing content: ${conflict.filePath}`);
4123
4158
  }
4124
- async function writeImmutable(options) {
4125
- await mkdir(path10.dirname(options.filePath), { recursive: true });
4126
- return withEvidenceLock(options.directory, options.relativeLockPath, AGENT, options.taskId, async () => {
4127
- const desired = serialized(options.value);
4128
- const existing = await readOptional(options.filePath);
4129
- if (existing !== undefined) {
4130
- let parsed;
4131
- try {
4132
- parsed = options.parse(JSON.parse(existing));
4133
- } catch (error2) {
4134
- throw new EvaluationConflictError(`existing evaluation artifact is corrupt: ${options.filePath}: ${String(error2)}`);
4135
- }
4136
- if (serialized(parsed) === desired || options.isEquivalent?.(parsed, options.value)) {
4137
- return parsed;
4138
- }
4139
- throw new EvaluationConflictError(`immutable evaluation artifact conflicts with existing content: ${options.filePath}`);
4140
- }
4141
- await atomicWriteFile(options.filePath, desired);
4142
- return options.value;
4159
+ function writeImmutable(options) {
4160
+ return writeImmutableArtifact({
4161
+ ...options,
4162
+ agent: AGENT,
4163
+ serialize: serialized,
4164
+ conflictError: evaluationConflictError
4143
4165
  });
4144
4166
  }
4145
4167
  function validateTaskInputs(directory, task) {
@@ -4150,8 +4172,8 @@ function validateTaskInputs(directory, task) {
4150
4172
  if (!executable)
4151
4173
  throw new Error("project scorer requires an executable");
4152
4174
  const scorerPath = resolveContainedExistingPath(directory, executable);
4153
- const relative3 = path10.relative(environmentRoot, scorerPath);
4154
- if (!relative3 || relative3 === ".." || relative3.startsWith(`..${path10.sep}`) || path10.isAbsolute(relative3)) {
4175
+ const relative3 = path11.relative(environmentRoot, scorerPath);
4176
+ if (!relative3 || relative3 === ".." || relative3.startsWith(`..${path11.sep}`) || path11.isAbsolute(relative3)) {
4155
4177
  throw new Error("project scorer executable must be inside the admitted task environment");
4156
4178
  }
4157
4179
  }
@@ -4163,13 +4185,13 @@ async function admitEvaluationTask(directory, input, inputRoot = directory) {
4163
4185
  }
4164
4186
  validateTaskInputs(inputRoot, task);
4165
4187
  const lineageInputHash = await computeTaskLineageInputHash(inputRoot, task);
4166
- const relative3 = path10.join("evolution", "tasks", task.split, `${task.id}.json`);
4188
+ const relative3 = path11.join("evolution", "tasks", task.split, `${task.id}.json`);
4167
4189
  const admissionLock = TASK_SPLIT_REGISTRY_RELATIVE;
4168
4190
  const filePath = swarmPath(directory, relative3);
4169
- await mkdir(path10.dirname(filePath), { recursive: true });
4191
+ await mkdir2(path11.dirname(filePath), { recursive: true });
4170
4192
  return withEvidenceLock(directory, admissionLock, AGENT, task.id, async () => {
4171
4193
  const registryPath = swarmPath(directory, TASK_SPLIT_REGISTRY_RELATIVE);
4172
- const registry = parseTaskSplitRegistry(await readOptional(registryPath));
4194
+ const registry = parseTaskSplitRegistry(await readOptionalFile(registryPath));
4173
4195
  const existingTaskEntry = registry.entries.find((entry) => entry.taskIds.includes(task.id));
4174
4196
  if (existingTaskEntry && existingTaskEntry.split !== task.split) {
4175
4197
  throw new EvaluationConflictError(`task ${task.id} is already admitted to a different split`);
@@ -4185,12 +4207,12 @@ async function admitEvaluationTask(directory, input, inputRoot = directory) {
4185
4207
  for (const split of ["train", "validation", "test"]) {
4186
4208
  if (split === task.split)
4187
4209
  continue;
4188
- if (await readOptional(swarmPath(directory, "evolution", "tasks", split, `${task.id}.json`))) {
4210
+ if (await readOptionalFile(swarmPath(directory, "evolution", "tasks", split, `${task.id}.json`))) {
4189
4211
  throw new EvaluationConflictError(`task ${task.id} is already admitted to a different split`);
4190
4212
  }
4191
4213
  }
4192
4214
  const desired = serialized(task);
4193
- const existing = await readOptional(filePath);
4215
+ const existing = await readOptionalFile(filePath);
4194
4216
  if (existing !== undefined) {
4195
4217
  const parsed = EvaluationTaskV1Schema.parse(JSON.parse(existing));
4196
4218
  if (serialized(parsed) === desired) {
@@ -4254,7 +4276,7 @@ async function saveTaskSetSnapshot(directory, input, inputRoot = directory) {
4254
4276
  if (computeTaskSetContentHash(snapshot) !== snapshot.contentHash) {
4255
4277
  throw new Error("task-set content hash does not match its canonical inputs");
4256
4278
  }
4257
- const relative3 = path10.join("evolution", "task-sets", `${snapshot.contentHash}.json`);
4279
+ const relative3 = path11.join("evolution", "task-sets", `${snapshot.contentHash}.json`);
4258
4280
  return writeImmutable({
4259
4281
  directory,
4260
4282
  relativeLockPath: relative3,
@@ -4267,7 +4289,7 @@ async function saveTaskSetSnapshot(directory, input, inputRoot = directory) {
4267
4289
  }
4268
4290
  async function saveGateAuditResult(directory, input) {
4269
4291
  const result = GateAuditResultV1Schema.parse(input);
4270
- const relative3 = path10.join("evidence", "gate-audit", result.runId, "results.json");
4292
+ const relative3 = path11.join("evidence", "gate-audit", result.runId, "results.json");
4271
4293
  return writeImmutable({
4272
4294
  directory,
4273
4295
  relativeLockPath: relative3,
@@ -4279,7 +4301,7 @@ async function saveGateAuditResult(directory, input) {
4279
4301
  }
4280
4302
  async function saveGateAuditManifest(directory, input) {
4281
4303
  const manifest = GateAuditManifestV1Schema.parse(input);
4282
- const relative3 = path10.join("evolution", "gate-audit-manifests", `${manifest.id}.json`);
4304
+ const relative3 = path11.join("evolution", "gate-audit-manifests", `${manifest.id}.json`);
4283
4305
  return writeImmutable({
4284
4306
  directory,
4285
4307
  relativeLockPath: relative3,
@@ -4290,11 +4312,11 @@ async function saveGateAuditManifest(directory, input) {
4290
4312
  });
4291
4313
  }
4292
4314
  async function readGateAuditManifest(directory, runId) {
4293
- const content = await readOptional(swarmPath(directory, "evolution", "gate-audit-manifests", `${runId}.json`));
4315
+ const content = await readOptionalFile(swarmPath(directory, "evolution", "gate-audit-manifests", `${runId}.json`));
4294
4316
  return content === undefined ? undefined : GateAuditManifestV1Schema.parse(JSON.parse(content));
4295
4317
  }
4296
4318
  async function readGateAuditResult(directory, runId) {
4297
- const content = await readOptional(swarmPath(directory, "evidence", "gate-audit", runId, "results.json"));
4319
+ const content = await readOptionalFile(swarmPath(directory, "evidence", "gate-audit", runId, "results.json"));
4298
4320
  return content === undefined ? undefined : GateAuditResultV1Schema.parse(JSON.parse(content));
4299
4321
  }
4300
4322
  async function listGateAuditResults(directory) {
@@ -4315,7 +4337,7 @@ async function listGateAuditResults(directory) {
4315
4337
  continue;
4316
4338
  }
4317
4339
  try {
4318
- const parsed = GateAuditResultV1Schema.parse(JSON.parse(await readFile2(path10.join(root, entry.name, "results.json"), "utf8")));
4340
+ const parsed = GateAuditResultV1Schema.parse(JSON.parse(await readFile3(path11.join(root, entry.name, "results.json"), "utf8")));
4319
4341
  if (parsed.runId !== entry.name)
4320
4342
  throw new Error("run id/path mismatch");
4321
4343
  results.push(parsed);
@@ -4336,7 +4358,7 @@ function parseTestLedger(content) {
4336
4358
  }
4337
4359
  async function getProtectedEvaluationRunIds(directory) {
4338
4360
  const protectedIds = new Set;
4339
- const ledger = await readOptional(swarmPath(directory, TEST_LEDGER_RELATIVE));
4361
+ const ledger = await readOptionalFile(swarmPath(directory, TEST_LEDGER_RELATIVE));
4340
4362
  for (const claim of parseTestLedger(ledger ?? ""))
4341
4363
  protectedIds.add(claim.runId);
4342
4364
  const decisionsDirectory = swarmPath(directory, "evolution", "decisions");
@@ -4348,7 +4370,7 @@ async function getProtectedEvaluationRunIds(directory) {
4348
4370
  throw error2;
4349
4371
  }
4350
4372
  for (const filename of files.filter((value) => value.endsWith(".json")).sort()) {
4351
- const decision = PromotionDecisionV1Schema.parse(JSON.parse(await readFile2(path10.join(decisionsDirectory, filename), "utf8")));
4373
+ const decision = PromotionDecisionV1Schema.parse(JSON.parse(await readFile3(path11.join(decisionsDirectory, filename), "utf8")));
4352
4374
  protectedIds.add(decision.runId);
4353
4375
  protectedIds.add(decision.lineage.baselineRunId);
4354
4376
  if (decision.lineage.historicalBestRunId !== "unavailable") {
@@ -4366,7 +4388,7 @@ function validId(value) {
4366
4388
  return /^[A-Za-z0-9][A-Za-z0-9._-]{0,159}$/.test(value);
4367
4389
  }
4368
4390
  async function evaluationRunCandidates(directory) {
4369
- const root = path11.join(directory, ".swarm", "evolution", "runs");
4391
+ const root = path12.join(directory, ".swarm", "evolution", "runs");
4370
4392
  let entries = [];
4371
4393
  try {
4372
4394
  entries = await fs5.readdir(root, { withFileTypes: true });
@@ -4385,7 +4407,7 @@ async function evaluationRunCandidates(directory) {
4385
4407
  if (!validId(id))
4386
4408
  continue;
4387
4409
  const artifact = { namespace: "evaluation-run", id };
4388
- const target = path11.join(root, entry.name);
4410
+ const target = path12.join(root, entry.name);
4389
4411
  try {
4390
4412
  const run = EvaluationRunV1Schema.parse(JSON.parse(await fs5.readFile(target, "utf8")));
4391
4413
  if (run.runId !== id)
@@ -4403,7 +4425,7 @@ async function evaluationRunCandidates(directory) {
4403
4425
  return { candidates, corrupt };
4404
4426
  }
4405
4427
  async function gateAuditCandidates(directory) {
4406
- const root = path11.join(directory, ".swarm", "evidence", "gate-audit");
4428
+ const root = path12.join(directory, ".swarm", "evidence", "gate-audit");
4407
4429
  let entries = [];
4408
4430
  try {
4409
4431
  entries = await fs5.readdir(root, { withFileTypes: true });
@@ -4419,9 +4441,9 @@ async function gateAuditCandidates(directory) {
4419
4441
  if (!entry.isDirectory() || !validId(entry.name))
4420
4442
  continue;
4421
4443
  const artifact = { namespace: "gate-audit", id: entry.name };
4422
- const target = path11.join(root, entry.name);
4444
+ const target = path12.join(root, entry.name);
4423
4445
  try {
4424
- const result = GateAuditResultV1Schema.parse(JSON.parse(await fs5.readFile(path11.join(target, "results.json"), "utf8")));
4446
+ const result = GateAuditResultV1Schema.parse(JSON.parse(await fs5.readFile(path12.join(target, "results.json"), "utf8")));
4425
4447
  if (result.runId !== entry.name)
4426
4448
  throw new Error("run id/path mismatch");
4427
4449
  candidates.push({
@@ -4462,7 +4484,7 @@ var _retentionInternals = {
4462
4484
  removeCandidate
4463
4485
  };
4464
4486
  async function archiveEvaluationArtifacts(args) {
4465
- return withEvidenceLock(args.directory, path11.join("evolution", "retention-index"), "evaluation-retention", "archive", async () => {
4487
+ return withEvidenceLock(args.directory, path12.join("evolution", "retention-index"), "evaluation-retention", "archive", async () => {
4466
4488
  const inventory = await retentionCandidates(args.directory);
4467
4489
  let protectedKeys = await _retentionInternals.protectedArtifacts(args.directory);
4468
4490
  const protectedRefs = inventory.candidates.filter((candidate) => protectedKeys.has(artifactKey(candidate.artifact))).map((candidate) => candidate.artifact);
@@ -4785,8 +4807,8 @@ function isWeakConfigContainerRoot(directory) {
4785
4807
  const resolved = realpathSync2(directory);
4786
4808
  return resolved === realpathSync2(os4.tmpdir()) || resolved === realpathSync2(os4.homedir());
4787
4809
  } catch {
4788
- const resolved = path12.resolve(directory);
4789
- return resolved === path12.resolve(os4.tmpdir()) || resolved === path12.resolve(os4.homedir());
4810
+ const resolved = path13.resolve(directory);
4811
+ return resolved === path13.resolve(os4.tmpdir()) || resolved === path13.resolve(os4.homedir());
4790
4812
  }
4791
4813
  }
4792
4814
  function hasAccessibleProjectIndicator(directory, options = {}) {
@@ -4796,7 +4818,7 @@ function hasAccessibleProjectIndicator(directory, options = {}) {
4796
4818
  continue;
4797
4819
  }
4798
4820
  try {
4799
- const indicatorStat = statSync2(path12.join(directory, indicator));
4821
+ const indicatorStat = statSync2(path13.join(directory, indicator));
4800
4822
  if (indicatorStat.isFile() || indicatorStat.isDirectory()) {
4801
4823
  return true;
4802
4824
  }
@@ -4818,14 +4840,14 @@ function validateProjectRoot(directory) {
4818
4840
  if (depth >= MAX_DEPTH)
4819
4841
  break;
4820
4842
  depth++;
4821
- const parent = path12.dirname(current);
4843
+ const parent = path13.dirname(current);
4822
4844
  if (parent === current)
4823
4845
  break;
4824
- if (path12.dirname(parent) === parent) {
4846
+ if (path13.dirname(parent) === parent) {
4825
4847
  current = parent;
4826
4848
  continue;
4827
4849
  }
4828
- const parentSwarm = path12.join(parent, ".swarm");
4850
+ const parentSwarm = path13.join(parent, ".swarm");
4829
4851
  try {
4830
4852
  if (statSync2(parentSwarm).isDirectory()) {
4831
4853
  if (hasAccessibleProjectIndicator(parent, {
@@ -4846,12 +4868,12 @@ function validateProjectRoot(directory) {
4846
4868
  async function saveEvidence(directory, taskId, evidence) {
4847
4869
  _internals11.validateProjectRoot(directory);
4848
4870
  const sanitizedTaskId = sanitizeTaskId2(taskId);
4849
- const relativePath = path12.join("evidence", sanitizedTaskId, "evidence.json");
4871
+ const relativePath = path13.join("evidence", sanitizedTaskId, "evidence.json");
4850
4872
  validateSwarmPath(directory, relativePath);
4851
4873
  _internals11.validateEvidence(evidence);
4852
4874
  return withEvidenceLock(directory, relativePath, "evidence-manager", sanitizedTaskId, async () => {
4853
4875
  const evidencePath = validateSwarmPath(directory, relativePath);
4854
- const evidenceDir = path12.dirname(evidencePath);
4876
+ const evidenceDir = path13.dirname(evidencePath);
4855
4877
  let bundle;
4856
4878
  const existingContent = await readSwarmFileAsync(directory, relativePath);
4857
4879
  if (existingContent !== null) {
@@ -4894,7 +4916,7 @@ async function saveEvidence(directory, taskId, evidence) {
4894
4916
  throw new Error(`Evidence bundle size (${bundleJson.length} bytes) exceeds maximum (${EVIDENCE_MAX_JSON_BYTES} bytes)`);
4895
4917
  }
4896
4918
  mkdirSync5(evidenceDir, { recursive: true });
4897
- const tempPath = path12.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4919
+ const tempPath = path13.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4898
4920
  try {
4899
4921
  await bunWrite(tempPath, bundleJson);
4900
4922
  await fs7.rename(tempPath, evidencePath);
@@ -4936,9 +4958,9 @@ function wrapFlatRetrospective(flatEntry, taskId) {
4936
4958
  entries: [remappedEntry]
4937
4959
  };
4938
4960
  }
4939
- async function loadEvidence(directory, taskId) {
4961
+ async function loadEvidence(directory, taskId, options) {
4940
4962
  const sanitizedTaskId = sanitizeTaskId2(taskId);
4941
- const relativePath = path12.join("evidence", sanitizedTaskId, "evidence.json");
4963
+ const relativePath = path13.join("evidence", sanitizedTaskId, "evidence.json");
4942
4964
  if (relativePath.length > 4096) {
4943
4965
  return { status: "not_found" };
4944
4966
  }
@@ -4957,11 +4979,14 @@ async function loadEvidence(directory, taskId) {
4957
4979
  const wrappedBundle = _internals11.wrapFlatRetrospective(parsed, sanitizedTaskId);
4958
4980
  try {
4959
4981
  const validated = EvidenceBundleSchema.parse(wrappedBundle);
4982
+ if (options?.migrate === false) {
4983
+ return { status: "found", bundle: validated };
4984
+ }
4960
4985
  try {
4961
4986
  await withEvidenceLock(directory, relativePath, "evidence-loader", sanitizedTaskId, async () => {
4962
- const evidenceDir = path12.dirname(evidencePath);
4987
+ const evidenceDir = path13.dirname(evidencePath);
4963
4988
  const bundleJson = JSON.stringify(validated);
4964
- const tempPath = path12.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4989
+ const tempPath = path13.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
4965
4990
  try {
4966
4991
  await bunWrite(tempPath, bundleJson);
4967
4992
  await fs7.rename(tempPath, evidencePath);
@@ -5006,7 +5031,7 @@ async function listEvidenceTaskIds(directory) {
5006
5031
  }
5007
5032
  const taskIds = [];
5008
5033
  for (const entry of entries) {
5009
- const entryPath = path12.join(evidenceBasePath, entry);
5034
+ const entryPath = path13.join(evidenceBasePath, entry);
5010
5035
  try {
5011
5036
  const stats = statSync2(entryPath);
5012
5037
  if (!stats.isDirectory()) {
@@ -5024,7 +5049,7 @@ async function listEvidenceTaskIds(directory) {
5024
5049
  }
5025
5050
  async function deleteEvidence(directory, taskId) {
5026
5051
  const sanitizedTaskId = sanitizeTaskId2(taskId);
5027
- const relativePath = path12.join("evidence", sanitizedTaskId);
5052
+ const relativePath = path13.join("evidence", sanitizedTaskId);
5028
5053
  const evidenceDir = validateSwarmPath(directory, relativePath);
5029
5054
  try {
5030
5055
  statSync2(evidenceDir);
@@ -5040,8 +5065,8 @@ async function deleteEvidence(directory, taskId) {
5040
5065
  }
5041
5066
  }
5042
5067
  async function checkRequirementCoverage(phase, directory) {
5043
- const relativePath = path12.join("evidence", `req-coverage-phase-${phase}.json`);
5044
- const absolutePath = path12.resolve(directory, ".swarm", relativePath);
5068
+ const relativePath = path13.join("evidence", `req-coverage-phase-${phase}.json`);
5069
+ const absolutePath = path13.resolve(directory, ".swarm", relativePath);
5045
5070
  try {
5046
5071
  await fs7.access(absolutePath);
5047
5072
  return { exists: true, path: absolutePath };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-rtry5xyf.js";
5
5
  import {
6
6
  readKnowledgeEvents
7
- } from "./index-jxha73tm.js";
7
+ } from "./index-fepakwhp.js";
8
8
  import {
9
9
  isLinked,
10
10
  readLinkPointer,
@@ -12,14 +12,14 @@ import {
12
12
  detectPosixWrites,
13
13
  detectWindowsWrites,
14
14
  resolveWriteTargets
15
- } from "./index-4qrbvrz5.js";
15
+ } from "./index-d2tgc580.js";
16
16
  import {
17
17
  checkFileAuthority,
18
18
  classifyFile,
19
19
  isInDeclaredScope,
20
20
  redactPath,
21
21
  redactShellCommand
22
- } from "./index-hjar4crm.js";
22
+ } from "./index-cq22pnd2.js";
23
23
 
24
24
  // src/services/guardrail-explain-service.ts
25
25
  import path from "path";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  redactPath,
4
4
  redactShellCommand
5
- } from "./index-hjar4crm.js";
5
+ } from "./index-cq22pnd2.js";
6
6
 
7
7
  // src/services/guardrail-log-service.ts
8
8
  import * as fs from "fs/promises";
@@ -3,7 +3,7 @@ import {
3
3
  init_constants,
4
4
  init_schema,
5
5
  stripKnownSwarmPrefix
6
- } from "./index-5xxgeksy.js";
6
+ } from "./index-hynbzh7s.js";
7
7
  import {
8
8
  init_logger,
9
9
  warn