@inerrata-corporation/errata 2.0.17-dev.3504 → 2.0.17-dev.3527

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.
package/errata.mjs CHANGED
@@ -1153,9 +1153,9 @@ function parsePackageRef(ref) {
1153
1153
  }
1154
1154
  const at = rest2.lastIndexOf("@");
1155
1155
  const name2 = at > 0 ? rest2.slice(0, at) : rest2;
1156
- const version2 = at > 0 ? rest2.slice(at + 1) || null : null;
1157
- const slug2 = (version2 ? `${name2}@${version2}` : name2).toLowerCase();
1158
- return { name: name2, version: version2, slug: slug2 };
1156
+ const version3 = at > 0 ? rest2.slice(at + 1) || null : null;
1157
+ const slug2 = (version3 ? `${name2}@${version3}` : name2).toLowerCase();
1158
+ return { name: name2, version: version3, slug: slug2 };
1159
1159
  }
1160
1160
  var DESIGN_PROBLEM_PREFIX, DESIGN_PROBLEM_ID_LENGTH, DIAGNOSTIC_PROBLEM_PREFIX, DIAGNOSTIC_HASH_LENGTH, TRIAGE_PREFIX, TRIAGE_ID_LENGTH, SAFE_TOOL_NAME, OS_NAME;
1161
1161
  var init_identity = __esm({
@@ -2285,10 +2285,10 @@ var init_regexes = __esm({
2285
2285
  duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
2286
2286
  extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
2287
2287
  guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
2288
- uuid = (version2) => {
2289
- if (!version2)
2288
+ uuid = (version3) => {
2289
+ if (!version3)
2290
2290
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
2291
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
2291
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
2292
2292
  };
2293
2293
  uuid4 = /* @__PURE__ */ uuid(4);
2294
2294
  uuid6 = /* @__PURE__ */ uuid(6);
@@ -15097,10 +15097,10 @@ function fromJSONSchema(schema, params) {
15097
15097
  if (typeof schema === "boolean") {
15098
15098
  return schema ? z.any() : z.never();
15099
15099
  }
15100
- const version2 = detectVersion(schema, params?.defaultTarget);
15100
+ const version3 = detectVersion(schema, params?.defaultTarget);
15101
15101
  const defs = schema.$defs || schema.definitions || {};
15102
15102
  const ctx = {
15103
- version: version2,
15103
+ version: version3,
15104
15104
  defs,
15105
15105
  refs: /* @__PURE__ */ new Map(),
15106
15106
  processing: /* @__PURE__ */ new Set(),
@@ -15829,6 +15829,169 @@ var init_history_evidence = __esm({
15829
15829
  }
15830
15830
  });
15831
15831
 
15832
+ // ../../packages/shared/src/history-dependencies.ts
15833
+ function mentions(text, name2) {
15834
+ const escaped = name2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
15835
+ return new RegExp(`(^|[^a-z0-9_@/.-])${escaped}($|[^a-z0-9_/-])`, "i").test(text);
15836
+ }
15837
+ function namedHistoryDependency(text, name2) {
15838
+ if (name2.length < 3) return mentions(text, `\`${name2}\``);
15839
+ if (["node", "graph", "types", "test", "core", "privacy", "next"].includes(name2.toLowerCase())) {
15840
+ return mentions(text, `\`${name2}\``) || name2 === "node" && /\bnode\.js\b/i.test(text) || name2 === "next" && /\bnext\.js\b/i.test(text);
15841
+ }
15842
+ return mentions(text, name2);
15843
+ }
15844
+ function selectHistoryDependencies(context, input) {
15845
+ if (!context) return void 0;
15846
+ const paths = new Set(input.evidence.flatMap((e) => e.pathToken ? [e.pathToken] : []));
15847
+ const sides = new Set(input.evidence.map((e) => e.side));
15848
+ const both = sides.has("mixed") || sides.has("narrative") || sides.has("context") || sides.size === 0;
15849
+ const dependencies = context.dependencies.filter((d) => (both || sides.has(d.side)) && (paths.size === 0 || d.pathTokens.some((p) => paths.has(p)))).map((d) => ({ ...d, binding: namedHistoryDependency(input.text, d.name) ? "named" : d.importTokens.some((p) => paths.has(p)) ? "import" : "environment" }));
15850
+ const statedVersions = [];
15851
+ for (const d of dependencies) {
15852
+ if (d.binding === "environment") continue;
15853
+ const escaped = d.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
15854
+ const match2 = new RegExp(`(?:^|[^a-z0-9_@/.-])${escaped}\\s+(?:v(?:ersion)?\\s*)?(\\d+(?:\\.\\d+){0,2})(?!\\d)`, "i").exec(input.text);
15855
+ if (match2 && !statedVersions.some((v) => v.packageId === d.packageId && v.version === match2[1])) statedVersions.push({ packageId: d.packageId, version: match2[1] });
15856
+ }
15857
+ const conflict = statedVersions.some((v) => !dependencies.some((d) => d.packageId === v.packageId && (d.resolvedVersion ?? d.declaredRange)?.replace(/^[~^=v\s]+/, "").split(".").slice(0, v.version.split(".").length).join(".") === v.version));
15858
+ return { schemaVersion: "history-deps-1", complete: context.complete, dependencies, statedVersions, conflict };
15859
+ }
15860
+ function historyDependencyIdentity(raw2) {
15861
+ const parsed = HistoryDependencyContextSchema.safeParse(raw2);
15862
+ if (!parsed.success || !parsed.data.complete || parsed.data.conflict) return null;
15863
+ if (parsed.data.dependencies.some((d) => !exactHistoryDependencyVersion(d))) return null;
15864
+ return digest(parsed.data.dependencies.map((d) => [d.packageId, d.manifestId, d.side, d.declaredRange, d.resolvedVersion]).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))));
15865
+ }
15866
+ function exactHistoryDependencyVersion(d) {
15867
+ return d.resolvedVersion ?? (/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(d.declaredRange ?? "") ? d.declaredRange : null);
15868
+ }
15869
+ function preservedHistoryDependencies(old, current, atCommit) {
15870
+ const a = HistoryDependencyContextSchema.safeParse(old), b = HistoryDependencyContextSchema.safeParse(current);
15871
+ if (!a.success || !a.data.complete || a.data.conflict || !b.success || !b.data.complete || b.data.conflict) return false;
15872
+ const exact = exactHistoryDependencyVersion;
15873
+ return a.data.dependencies.every((d) => {
15874
+ if (d.side !== "after" || !exact(d)) return false;
15875
+ const matches = b.data.dependencies.filter((n) => n.side === "after" && n.packageId === d.packageId && n.manifestId === d.manifestId);
15876
+ return matches.length === 1 && (!atCommit || matches[0].sourceCommit === atCommit) && exact(matches[0]) === exact(d);
15877
+ });
15878
+ }
15879
+ function historyDependencyVersions(context) {
15880
+ const versions = /* @__PURE__ */ new Map();
15881
+ for (const d of context?.dependencies ?? []) {
15882
+ if (d.binding === "environment") continue;
15883
+ const set2 = versions.get(d.packageId) ?? /* @__PURE__ */ new Set();
15884
+ versions.set(d.packageId, set2);
15885
+ set2.add(d.resolvedVersion ?? d.declaredRange ?? "");
15886
+ }
15887
+ const result = Object.fromEntries([...versions].filter(([, v]) => v.size === 1 && !v.has("")).map(([k, v]) => [k, [...v][0]]));
15888
+ return Object.keys(result).length ? result : null;
15889
+ }
15890
+ function pnpmEntry(locks, path2, importer, name2) {
15891
+ let files = pnpmIndexes.get(locks);
15892
+ if (!files) {
15893
+ files = /* @__PURE__ */ new Map();
15894
+ pnpmIndexes.set(locks, files);
15895
+ }
15896
+ let index = files.get(path2);
15897
+ if (!index) {
15898
+ index = /* @__PURE__ */ new Map();
15899
+ files.set(path2, index);
15900
+ let inImporters = false, workspace = "", dep = "", spec = null;
15901
+ for (const line of locks[path2].split(/\r?\n/)) {
15902
+ if (/^\S/.test(line)) {
15903
+ inImporters = line === "importers:";
15904
+ continue;
15905
+ }
15906
+ if (!inImporters) continue;
15907
+ const item2 = /^ (\S.*):\s*$/.exec(line);
15908
+ if (item2) {
15909
+ workspace = item2[1].replace(/^['"]|['"]$/g, "");
15910
+ dep = "";
15911
+ continue;
15912
+ }
15913
+ const entry = /^ (\S.*):\s*$/.exec(line);
15914
+ if (entry) {
15915
+ dep = entry[1].replace(/^['"]|['"]$/g, "");
15916
+ spec = null;
15917
+ continue;
15918
+ }
15919
+ const declared = /^ specifier: (.+)$/.exec(line);
15920
+ if (declared) spec = declared[1].replace(/^['"]|['"]$/g, "");
15921
+ const resolved = /^ version: (.+)$/.exec(line);
15922
+ if (resolved) index.set(JSON.stringify([workspace, dep]), { spec, version: resolved[1].replace(/^['"]|['"]$/g, "") });
15923
+ }
15924
+ }
15925
+ return index.get(JSON.stringify([importer, name2]));
15926
+ }
15927
+ function resolveHistoricalNpmVersion(name2, manifest, declared, locks) {
15928
+ const dir = manifest.includes("/") ? manifest.slice(0, manifest.lastIndexOf("/")) : ".";
15929
+ const exact = (v) => typeof v === "string" ? /^(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:\(|$)/.exec(v)?.[1] ?? null : null;
15930
+ const lockPaths = Object.keys(locks).filter((p) => {
15931
+ const root = p.includes("/") ? p.slice(0, p.lastIndexOf("/")) : ".";
15932
+ return root === "." || dir === root || dir.startsWith(root + "/");
15933
+ }).sort((a, b) => b.split("/").length - a.split("/").length);
15934
+ for (const path2 of lockPaths) {
15935
+ const root = path2.includes("/") ? path2.slice(0, path2.lastIndexOf("/")) : ".";
15936
+ const importer = root === "." ? dir : dir === root ? "." : dir.slice(root.length + 1);
15937
+ if (path2.endsWith("pnpm-lock.yaml")) {
15938
+ const entry = pnpmEntry(locks, path2, importer, name2);
15939
+ if (entry?.spec === declared) return exact(entry.version);
15940
+ } else if (path2.endsWith("package-lock.json")) {
15941
+ try {
15942
+ const json2 = JSON.parse(locks[path2]);
15943
+ const key = importer === "." ? "" : importer, owner = json2.packages?.[key];
15944
+ if (!owner || ![owner.dependencies?.[name2], owner.devDependencies?.[name2], owner.optionalDependencies?.[name2]].includes(declared ?? void 0)) continue;
15945
+ let parent = key;
15946
+ for (; ; ) {
15947
+ const installed = json2.packages?.[`${parent ? parent + "/" : ""}node_modules/${name2}`];
15948
+ if (installed) return exact(installed.version);
15949
+ if (!parent) break;
15950
+ parent = parent.includes("/") ? parent.slice(0, parent.lastIndexOf("/")) : "";
15951
+ }
15952
+ } catch {
15953
+ }
15954
+ }
15955
+ }
15956
+ return null;
15957
+ }
15958
+ var version2, HistoryDependencySchema, HistoryDependencyContextSchema, HISTORY_RECONCILE_BUILD, historyManifestId, pnpmIndexes, historyDependencyPackageId;
15959
+ var init_history_dependencies = __esm({
15960
+ "../../packages/shared/src/history-dependencies.ts"() {
15961
+ "use strict";
15962
+ init_zod();
15963
+ init_hash();
15964
+ init_identity();
15965
+ version2 = external_exports.string().max(160).nullable();
15966
+ HistoryDependencySchema = external_exports.object({
15967
+ packageId: external_exports.string().startsWith("pkg:").max(300),
15968
+ ecosystem: external_exports.string().min(1).max(20),
15969
+ name: external_exports.string().min(1).max(200),
15970
+ kind: external_exports.enum(["package", "sdk", "engine", "runtime", "image"]),
15971
+ manifestId: external_exports.string().regex(/^hmanifest_[a-f0-9]{32}$/),
15972
+ sourceCommit: external_exports.string().regex(/^[a-f0-9]{7,64}$/),
15973
+ side: external_exports.enum(["before", "after"]),
15974
+ /** Environment-only entries constrain applicability but never mint a package edge. */
15975
+ binding: external_exports.enum(["named", "import", "environment"]).optional(),
15976
+ declaredRange: version2,
15977
+ resolvedVersion: version2,
15978
+ pathTokens: external_exports.array(external_exports.string().regex(/^p\d+$/)).max(500),
15979
+ importTokens: external_exports.array(external_exports.string().regex(/^p\d+$/)).max(500)
15980
+ }).refine((d) => d.packageId === packageCanonicalId({ ecosystem: d.ecosystem, name: d.name }), "package identity must match its evidence");
15981
+ HistoryDependencyContextSchema = external_exports.object({
15982
+ schemaVersion: external_exports.literal("history-deps-1"),
15983
+ complete: external_exports.boolean(),
15984
+ dependencies: external_exports.array(HistoryDependencySchema).max(256),
15985
+ statedVersions: external_exports.array(external_exports.object({ packageId: external_exports.string().max(300), version: external_exports.string().max(80) })).max(64).optional(),
15986
+ conflict: external_exports.boolean().optional()
15987
+ });
15988
+ HISTORY_RECONCILE_BUILD = "history-reconcile-2";
15989
+ historyManifestId = (path2) => `hmanifest_${digest(path2.replace(/\\/g, "/")).slice(0, 32)}`;
15990
+ pnpmIndexes = /* @__PURE__ */ new WeakMap();
15991
+ historyDependencyPackageId = (ecosystem, name2) => packageCanonicalId({ ecosystem, name: name2 });
15992
+ }
15993
+ });
15994
+
15832
15995
  // ../../packages/shared/src/edge-rules.ts
15833
15996
  function isValidEdge(from, type, to) {
15834
15997
  const rule = EDGE_RULES[type];
@@ -16148,6 +16311,7 @@ var init_wire = __esm({
16148
16311
  "use strict";
16149
16312
  init_zod();
16150
16313
  init_history_evidence();
16314
+ init_history_dependencies();
16151
16315
  init_castalia();
16152
16316
  init_edge_rules();
16153
16317
  init_symbol_intent();
@@ -16276,6 +16440,7 @@ var init_wire = __esm({
16276
16440
  extractedBy: external_exports.enum(INGEST_EXTRACTION_SOURCES).optional(),
16277
16441
  sourceSupport: external_exports.literal("supported").optional(),
16278
16442
  historicalAnchors: external_exports.array(HistoryAnchorSourceSchema).max(160).optional(),
16443
+ dependencyEvidence: external_exports.array(HistoryDependencySchema).max(256).optional(),
16279
16444
  evidence: external_exports.array(HistoryEvidenceRefSchema).max(12).optional(),
16280
16445
  verificationEvidence: external_exports.array(HistoryEvidenceRefSchema).max(12).optional(),
16281
16446
  verifierBuild: external_exports.string().max(80).optional(),
@@ -16410,16 +16575,16 @@ var init_project_symbol = __esm({
16410
16575
  // ../../packages/shared/src/lockfile.ts
16411
16576
  function rankDirect(raw2, ecosystem = "npm") {
16412
16577
  const byName = /* @__PURE__ */ new Map();
16413
- for (const { name: name2, version: version2 } of raw2) {
16578
+ for (const { name: name2, version: version3 } of raw2) {
16414
16579
  const prev = byName.get(name2);
16415
16580
  if (prev) {
16416
16581
  prev.importers++;
16417
16582
  continue;
16418
16583
  }
16419
16584
  byName.set(name2, {
16420
- purl: `pkg:${ecosystem}/${name2}@${version2}`,
16585
+ purl: `pkg:${ecosystem}/${name2}@${version3}`,
16421
16586
  name: name2,
16422
- version: version2,
16587
+ version: version3,
16423
16588
  ecosystem,
16424
16589
  importers: 1
16425
16590
  });
@@ -16428,11 +16593,11 @@ function rankDirect(raw2, ecosystem = "npm") {
16428
16593
  (a, b) => b.importers - a.importers || a.name.localeCompare(b.name)
16429
16594
  );
16430
16595
  }
16431
- function npmPurl(name2, version2) {
16432
- return `pkg:npm/${name2}@${version2}`;
16596
+ function npmPurl(name2, version3) {
16597
+ return `pkg:npm/${name2}@${version3}`;
16433
16598
  }
16434
- function component(name2, version2) {
16435
- return { purl: npmPurl(name2, version2), name: name2, version: version2, ecosystem: "npm" };
16599
+ function component(name2, version3) {
16600
+ return { purl: npmPurl(name2, version3), name: name2, version: version3, ecosystem: "npm" };
16436
16601
  }
16437
16602
  function isNpmImporterPath(path2) {
16438
16603
  return path2 === "" || !path2.includes("node_modules/");
@@ -16453,13 +16618,13 @@ function parsePackageLockJson(jsonText) {
16453
16618
  const ix = path2.lastIndexOf("node_modules/");
16454
16619
  if (ix === -1) continue;
16455
16620
  const name2 = path2.slice(ix + "node_modules/".length);
16456
- const version2 = typeof meta3.version === "string" ? meta3.version : "";
16457
- if (!name2 || !version2) continue;
16458
- components.push(component(name2, version2));
16459
- byPath.set(path2, { name: name2, version: version2 });
16621
+ const version3 = typeof meta3.version === "string" ? meta3.version : "";
16622
+ if (!name2 || !version3) continue;
16623
+ components.push(component(name2, version3));
16624
+ byPath.set(path2, { name: name2, version: version3 });
16460
16625
  const depth = path2.split("node_modules/").length;
16461
16626
  const prev = hoisted.get(name2);
16462
- if (!prev || depth < prev.depth) hoisted.set(name2, { version: version2, depth });
16627
+ if (!prev || depth < prev.depth) hoisted.set(name2, { version: version3, depth });
16463
16628
  }
16464
16629
  const dependencies = [];
16465
16630
  for (const [path2, meta3] of Object.entries(packages)) {
@@ -16502,9 +16667,9 @@ function splitPnpmKey(raw2) {
16502
16667
  const at = k.lastIndexOf("@");
16503
16668
  if (at <= 0) return null;
16504
16669
  const name2 = k.slice(0, at);
16505
- const version2 = k.slice(at + 1);
16506
- if (!name2 || !version2) return null;
16507
- return { name: name2, version: version2 };
16670
+ const version3 = k.slice(at + 1);
16671
+ if (!name2 || !version3) return null;
16672
+ return { name: name2, version: version3 };
16508
16673
  }
16509
16674
  function parsePnpmImporters(lines) {
16510
16675
  const DEP_SECTIONS = /* @__PURE__ */ new Set(["dependencies:", "devDependencies:", "optionalDependencies:"]);
@@ -16540,14 +16705,14 @@ function parsePnpmImporters(lines) {
16540
16705
  if (indent === 8 && depName) {
16541
16706
  const t = line.trim();
16542
16707
  if (!t.startsWith("version:")) continue;
16543
- let version2 = t.slice("version:".length).trim().replace(/^['"]|['"]$/g, "");
16544
- const paren = version2.indexOf("(");
16545
- if (paren !== -1) version2 = version2.slice(0, paren);
16546
- if (!version2 || version2.startsWith("link:") || version2.startsWith("file:") || version2.includes("://")) {
16708
+ let version3 = t.slice("version:".length).trim().replace(/^['"]|['"]$/g, "");
16709
+ const paren = version3.indexOf("(");
16710
+ if (paren !== -1) version3 = version3.slice(0, paren);
16711
+ if (!version3 || version3.startsWith("link:") || version3.startsWith("file:") || version3.includes("://")) {
16547
16712
  depName = null;
16548
16713
  continue;
16549
16714
  }
16550
- raw2.push({ name: depName, version: version2 });
16715
+ raw2.push({ name: depName, version: version3 });
16551
16716
  depName = null;
16552
16717
  }
16553
16718
  }
@@ -16663,19 +16828,19 @@ function parseGemfileLock(text) {
16663
16828
  const spec = specLine.exec(line);
16664
16829
  if (spec) {
16665
16830
  const name2 = spec[1];
16666
- const version2 = (spec[2] ?? "").trim();
16831
+ const version3 = (spec[2] ?? "").trim();
16667
16832
  if (section === "path-or-git") {
16668
16833
  nonRegistry.add(name2);
16669
16834
  currentGem = null;
16670
16835
  continue;
16671
16836
  }
16672
- if (!version2) continue;
16673
- currentGem = { name: name2, version: version2 };
16674
- registryVersions.set(name2, version2);
16675
- const purl = `pkg:gem/${name2}@${version2}`;
16837
+ if (!version3) continue;
16838
+ currentGem = { name: name2, version: version3 };
16839
+ registryVersions.set(name2, version3);
16840
+ const purl = `pkg:gem/${name2}@${version3}`;
16676
16841
  if (!seen.has(purl)) {
16677
16842
  seen.add(purl);
16678
- components.push({ purl, name: name2, version: version2, ecosystem: "gem" });
16843
+ components.push({ purl, name: name2, version: version3, ecosystem: "gem" });
16679
16844
  }
16680
16845
  continue;
16681
16846
  }
@@ -16755,8 +16920,8 @@ function parseGodot(path2, text) {
16755
16920
  const m = /config\/features=PackedStringArray\(([^)]*)\)/.exec(text);
16756
16921
  if (!m) return [];
16757
16922
  const feats = (m[1] ?? "").split(",").map((f) => f.trim().replace(/^"|"$/g, "")).filter((f) => f.length > 0);
16758
- const version2 = feats.find((f) => /^\d+\.\d+/.test(f)) ?? null;
16759
- return [{ ecosystem: "godot", name: "godot", version: version2, kind: "engine", manifest: path2 }];
16923
+ const version3 = feats.find((f) => /^\d+\.\d+/.test(f)) ?? null;
16924
+ return [{ ecosystem: "godot", name: "godot", version: version3, kind: "engine", manifest: path2 }];
16760
16925
  }
16761
16926
  function parsePackageJson(path2, text) {
16762
16927
  let obj;
@@ -16771,8 +16936,8 @@ function parsePackageJson(path2, text) {
16771
16936
  const section = obj[key];
16772
16937
  if (!section || typeof section !== "object") continue;
16773
16938
  for (const [name2, ver] of Object.entries(section)) {
16774
- const version2 = ver ? String(ver) : null;
16775
- deps.push({ ecosystem: "npm", name: name2, version: version2, kind: "package", manifest: path2 });
16939
+ const version3 = ver ? String(ver) : null;
16940
+ deps.push({ ecosystem: "npm", name: name2, version: version3, kind: "package", manifest: path2 });
16776
16941
  }
16777
16942
  }
16778
16943
  return deps;
@@ -16877,12 +17042,12 @@ function parseGradle(path2, text) {
16877
17042
  const re = new RegExp(`\\b(?:${GRADLE_CONFIGS})\\s*(?:\\(\\s*)?["']([^"']+)["']`, "g");
16878
17043
  for (const m of text.matchAll(re)) {
16879
17044
  const parts2 = (m[1] ?? "").split(":");
16880
- const [group, artifact, version2] = parts2;
17045
+ const [group, artifact, version3] = parts2;
16881
17046
  if (!group || !artifact || parts2.length < 2) continue;
16882
17047
  deps.push({
16883
17048
  ecosystem: "maven",
16884
17049
  name: mavenName(group, artifact),
16885
- version: version2?.trim() || null,
17050
+ version: version3?.trim() || null,
16886
17051
  kind: "package",
16887
17052
  manifest: path2
16888
17053
  });
@@ -16896,18 +17061,18 @@ function parseVersionCatalog(path2, text) {
16896
17061
  for (const line of (section[1] ?? "").split(/\r?\n/)) {
16897
17062
  if (!line.trim() || line.trimStart().startsWith("#")) continue;
16898
17063
  const module2 = /module\s*=\s*["']([^"']+)["']/.exec(line)?.[1];
16899
- const version2 = /version(?:\.ref)?\s*=\s*["']([^"']+)["']/.exec(line)?.[1] ?? null;
17064
+ const version3 = /version(?:\.ref)?\s*=\s*["']([^"']+)["']/.exec(line)?.[1] ?? null;
16900
17065
  if (module2) {
16901
17066
  const [group2, artifact2] = module2.split(":");
16902
17067
  if (group2 && artifact2) {
16903
- deps.push({ ecosystem: "maven", name: mavenName(group2, artifact2), version: version2, kind: "package", manifest: path2 });
17068
+ deps.push({ ecosystem: "maven", name: mavenName(group2, artifact2), version: version3, kind: "package", manifest: path2 });
16904
17069
  }
16905
17070
  continue;
16906
17071
  }
16907
17072
  const group = /\bgroup\s*=\s*["']([^"']+)["']/.exec(line)?.[1];
16908
17073
  const artifact = /\bname\s*=\s*["']([^"']+)["']/.exec(line)?.[1];
16909
17074
  if (group && artifact) {
16910
- deps.push({ ecosystem: "maven", name: mavenName(group, artifact), version: version2, kind: "package", manifest: path2 });
17075
+ deps.push({ ecosystem: "maven", name: mavenName(group, artifact), version: version3, kind: "package", manifest: path2 });
16911
17076
  }
16912
17077
  }
16913
17078
  return deps;
@@ -17134,7 +17299,9 @@ function historyReadPolicy(node2, options = {}) {
17134
17299
  const q = raw2 && typeof raw2 === "object" ? raw2 : {};
17135
17300
  const source = q["sourceSupport"] ?? "unreviewed";
17136
17301
  const applicability = q["applicability"] ?? "unknown";
17137
- const current = options.atCommit !== void 0 && q["evaluatedAtCommit"] === options.atCommit;
17302
+ const proof = q["reconciliationEvidence"];
17303
+ const environmentKnown = historyDependencyIdentity(q["dependencyContext"]) !== null && proof?.["build"] === HISTORY_RECONCILE_BUILD;
17304
+ const current = options.atCommit !== void 0 && q["evaluatedAtCommit"] === options.atCommit && environmentKnown;
17138
17305
  const invalid = source === "contradicted" || source === "quarantined";
17139
17306
  const passive = options.mode === "passive";
17140
17307
  const validation = node2.validationSource ?? attrs["validationSource"];
@@ -17144,12 +17311,13 @@ function historyReadPolicy(node2, options = {}) {
17144
17311
  return {
17145
17312
  allow,
17146
17313
  history: true,
17147
- notice: `History-derived${at}; source ${String(source)}; applicability ${current ? String(applicability) : "unknown at this checkout"}; ${independentlyValidated ? "separate validation recorded" : "not independently validated"}.`
17314
+ notice: `History-derived${at}; source ${String(source)}; applicability ${current ? String(applicability) : "unknown at this checkout"}; ${environmentKnown ? "dependency context checked" : "dependency applicability unverified"}; ${independentlyValidated ? "separate validation recorded" : "not independently validated"}.`
17148
17315
  };
17149
17316
  }
17150
17317
  var init_history_read = __esm({
17151
17318
  "../../packages/shared/src/history-read.ts"() {
17152
17319
  "use strict";
17320
+ init_history_dependencies();
17153
17321
  }
17154
17322
  });
17155
17323
 
@@ -17234,11 +17402,14 @@ function historySemanticKey(projectId, o) {
17234
17402
  const q = o.quality;
17235
17403
  const anchors = q["historicalAnchors"];
17236
17404
  if (q["sourceSupport"] !== "supported" || !anchors?.length || anchors.some((a) => !a.symbolId)) return null;
17237
- return digest([projectId, o.label, o.statement, q["claimKind"] ?? null, q["qualifier"], q["conditions"], q["rationale"], [...new Set(anchors.map((a) => a.symbolId))].sort()]);
17405
+ const dependencies = historyDependencyIdentity(q["dependencyContext"]);
17406
+ if (!dependencies) return null;
17407
+ return digest([projectId, o.label, o.statement, q["claimKind"] ?? null, q["qualifier"], q["conditions"], q["rationale"], dependencies, [...new Set(anchors.map((a) => a.symbolId))].sort()]);
17238
17408
  }
17239
17409
  function preservedHistoryOccurrence(o, observed, atCommit, ancestor) {
17240
17410
  const q = o.quality, source = occurrenceSourceCommit(o);
17241
17411
  if (!source || ancestor(source, atCommit) !== true || q["sourceSupport"] !== "supported" || !observed) return false;
17412
+ if (!preservedHistoryDependencies(q["dependencyContext"], observed.dependencyContext, atCommit)) return false;
17242
17413
  const parsed = external_exports.array(HistoryEvidenceRefSchema).safeParse(q["evidence"]);
17243
17414
  if (!parsed.success || !parsed.data.length || parsed.data.some((e) => e.sourceKind !== "diff" || !["after", "context"].includes(e.side))) return false;
17244
17415
  const anchors = q["historicalAnchors"];
@@ -17252,6 +17423,7 @@ var init_history_revision = __esm({
17252
17423
  init_zod();
17253
17424
  init_hash();
17254
17425
  init_history_evidence();
17426
+ init_history_dependencies();
17255
17427
  Sha = external_exports.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/);
17256
17428
  HistoryRevisionRequestSchema = external_exports.strictObject({
17257
17429
  atCommit: Sha,
@@ -17260,7 +17432,8 @@ var init_history_revision = __esm({
17260
17432
  occurrenceId: external_exports.string().min(1).max(100),
17261
17433
  symbols: external_exports.array(external_exports.strictObject({ symbolId: external_exports.string().regex(/^sym_[a-f0-9]{8,64}$/), bodyHash: external_exports.string().regex(/^[a-f0-9]{8,64}$/) })).max(32),
17262
17434
  /** Scrubbed, tokenized net change from this occurrence's source to atCommit. */
17263
- diff: external_exports.string().max(16e3).optional()
17435
+ diff: external_exports.string().max(16e3).optional(),
17436
+ dependencyContext: HistoryDependencyContextSchema.optional()
17264
17437
  })).max(50)
17265
17438
  });
17266
17439
  }
@@ -17350,10 +17523,13 @@ __export(src_exports, {
17350
17523
  HISTORY_EVIDENCE_SCHEMA_VERSION: () => HISTORY_EVIDENCE_SCHEMA_VERSION,
17351
17524
  HISTORY_MAX_SPINE_DEPS: () => HISTORY_MAX_SPINE_DEPS,
17352
17525
  HISTORY_MAX_TEXT_CHARS: () => HISTORY_MAX_TEXT_CHARS,
17526
+ HISTORY_RECONCILE_BUILD: () => HISTORY_RECONCILE_BUILD,
17353
17527
  HISTORY_SCRUBBER_VERSION: () => HISTORY_SCRUBBER_VERSION,
17354
17528
  HistoryAnchorSourceSchema: () => HistoryAnchorSourceSchema,
17355
17529
  HistoryCandidateBatchSchema: () => HistoryCandidateBatchSchema,
17356
17530
  HistoryCandidateSchema: () => HistoryCandidateSchema,
17531
+ HistoryDependencyContextSchema: () => HistoryDependencyContextSchema,
17532
+ HistoryDependencySchema: () => HistoryDependencySchema,
17357
17533
  HistoryEvidenceRefSchema: () => HistoryEvidenceRefSchema,
17358
17534
  HistoryEvidenceSelectionSchema: () => HistoryEvidenceSelectionSchema,
17359
17535
  HistoryRelationCandidateSchema: () => HistoryRelationCandidateSchema,
@@ -17417,9 +17593,14 @@ __export(src_exports, {
17417
17593
  digest: () => digest,
17418
17594
  errorSignatureEqual: () => errorSignatureEqual,
17419
17595
  evaluateHistoryApplicability: () => evaluateHistoryApplicability,
17596
+ exactHistoryDependencyVersion: () => exactHistoryDependencyVersion,
17420
17597
  extractIdentifierTokens: () => extractIdentifierTokens,
17421
17598
  genericCanonicalId: () => genericCanonicalId,
17422
17599
  historyDag: () => historyDag,
17600
+ historyDependencyIdentity: () => historyDependencyIdentity,
17601
+ historyDependencyPackageId: () => historyDependencyPackageId,
17602
+ historyDependencyVersions: () => historyDependencyVersions,
17603
+ historyManifestId: () => historyManifestId,
17423
17604
  historyReadFields: () => historyReadFields,
17424
17605
  historyReadPolicy: () => historyReadPolicy,
17425
17606
  historySemanticKey: () => historySemanticKey,
@@ -17444,6 +17625,7 @@ __export(src_exports, {
17444
17625
  isValidEdge: () => isValidEdge,
17445
17626
  isValidEdgeType: () => isValidEdgeType,
17446
17627
  languageCanonicalId: () => languageCanonicalId,
17628
+ namedHistoryDependency: () => namedHistoryDependency,
17447
17629
  nearestDeps: () => nearestDeps,
17448
17630
  normalizeExtractionSource: () => normalizeExtractionSource,
17449
17631
  normalizePredicate: () => normalizePredicate,
@@ -17463,6 +17645,7 @@ __export(src_exports, {
17463
17645
  parsePackageRef: () => parsePackageRef,
17464
17646
  parsePnpmLock: () => parsePnpmLock,
17465
17647
  prefilterEntities: () => prefilterEntities,
17648
+ preservedHistoryDependencies: () => preservedHistoryDependencies,
17466
17649
  preservedHistoryOccurrence: () => preservedHistoryOccurrence,
17467
17650
  problemIdFromError: () => problemIdFromError,
17468
17651
  projectSaltedNodeId: () => projectSaltedNodeId,
@@ -17471,11 +17654,13 @@ __export(src_exports, {
17471
17654
  provenanceBand: () => provenanceBand,
17472
17655
  resolveCanonical: () => resolveCanonical,
17473
17656
  resolveCanonicalId: () => resolveCanonicalId,
17657
+ resolveHistoricalNpmVersion: () => resolveHistoricalNpmVersion,
17474
17658
  resolveHistoryEvidence: () => resolveHistoryEvidence,
17475
17659
  resolveUnambiguousCanonicalId: () => resolveUnambiguousCanonicalId,
17476
17660
  retrievalTokens: () => retrievalTokens,
17477
17661
  scrubHistoryText: () => scrubHistoryText,
17478
17662
  scrubHistoryValue: () => scrubHistoryValue,
17663
+ selectHistoryDependencies: () => selectHistoryDependencies,
17479
17664
  sha256: () => sha256,
17480
17665
  sha256Short: () => sha256Short,
17481
17666
  sidecarDropBucket: () => sidecarDropBucket,
@@ -17512,6 +17697,7 @@ var init_src = __esm({
17512
17697
  init_history_temporal();
17513
17698
  init_history_revision();
17514
17699
  init_history_evidence();
17700
+ init_history_dependencies();
17515
17701
  init_hash();
17516
17702
  init_error_signature();
17517
17703
  init_canonicalize();
@@ -19256,8 +19442,8 @@ CREATE INDEX IF NOT EXISTS nodes_anchor_hint_path ON nodes(json_extract(attrs_js
19256
19442
  freezeNode(liveId, t) {
19257
19443
  const live3 = this.getNode(liveId);
19258
19444
  if (!live3) return null;
19259
- const version2 = live3.version ?? 1;
19260
- const frozenId = `${liveId}@v${version2}`;
19445
+ const version3 = live3.version ?? 1;
19446
+ const frozenId = `${liveId}@v${version3}`;
19261
19447
  if (this.getNode(frozenId)) {
19262
19448
  this.stmts.advanceLive.run({ live_id: liveId, t });
19263
19449
  return frozenId;
@@ -19605,7 +19791,7 @@ function evaluateDependency(attrs, newVersion) {
19605
19791
  }
19606
19792
  return { revisit: false, reason: "" };
19607
19793
  }
19608
- function findOrCreatePackage(store, name2, version2, ts) {
19794
+ function findOrCreatePackage(store, name2, version3, ts) {
19609
19795
  const existing = store.findNodesByLabel("Package").find((n) => n.attrs["name"] === name2 || n.description === name2);
19610
19796
  if (existing) return existing;
19611
19797
  const node2 = {
@@ -19625,7 +19811,7 @@ function findOrCreatePackage(store, name2, version2, ts) {
19625
19811
  isLandmark: false,
19626
19812
  community: null,
19627
19813
  stability: "unstable",
19628
- attrs: { version: version2 }
19814
+ attrs: { version: version3 }
19629
19815
  };
19630
19816
  store.mergeNode(node2);
19631
19817
  return node2;
@@ -20144,13 +20330,13 @@ function linkProblemToPackages(store, problemId, text, ts, index) {
20144
20330
  if (idx.size === 0) return { linked: [] };
20145
20331
  const already = new Set(store.outEdges(problemId, ["DEPENDS_ON"]).map((e) => e.to));
20146
20332
  const linked = [];
20147
- for (const { node: node2, version: version2 } of matchPackagesInText(text, idx)) {
20333
+ for (const { node: node2, version: version3 } of matchPackagesInText(text, idx)) {
20148
20334
  if (already.has(node2.id)) continue;
20149
20335
  addDependency(store, {
20150
20336
  fromId: problemId,
20151
20337
  toId: node2.id,
20152
20338
  relation: "depends-on",
20153
- evidence: version2 ? `named in problem (@${version2})` : "named in problem statement",
20339
+ evidence: version3 ? `named in problem (@${version3})` : "named in problem statement",
20154
20340
  ts,
20155
20341
  extractionSource: "daemon-extracted"
20156
20342
  });
@@ -20448,8 +20634,8 @@ import { mkdirSync as mkdirSync3, existsSync as existsSync4 } from "node:fs";
20448
20634
  import { homedir } from "node:os";
20449
20635
  import { dirname as dirname4, join as join3 } from "node:path";
20450
20636
  import { createRequire } from "node:module";
20451
- function semanticFloorFor(version2) {
20452
- if (version2 === EMBEDDING_VERSION || version2 === MODEL_EMBEDDING_VERSION) return 0.25;
20637
+ function semanticFloorFor(version3) {
20638
+ if (version3 === EMBEDDING_VERSION || version3 === MODEL_EMBEDDING_VERSION) return 0.25;
20453
20639
  return 0.5;
20454
20640
  }
20455
20641
  function noteHashFallback() {
@@ -39644,10 +39830,10 @@ ${JSON.stringify(symbolNames, null, 2)}`);
39644
39830
  this.language = null;
39645
39831
  } else if (language.constructor === Language) {
39646
39832
  address = language[0];
39647
- const version2 = C._ts_language_abi_version(address);
39648
- if (version2 < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version2) {
39833
+ const version3 = C._ts_language_abi_version(address);
39834
+ if (version3 < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version3) {
39649
39835
  throw new Error(
39650
- `Incompatible language version ${version2}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
39836
+ `Incompatible language version ${version3}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
39651
39837
  );
39652
39838
  }
39653
39839
  this.language = language;
@@ -55596,36 +55782,36 @@ var require_diagnostics = __commonJS({
55596
55782
  const debuglog = fetchDebuglog.enabled ? fetchDebuglog : undiciDebugLog;
55597
55783
  diagnosticsChannel.channel("undici:client:beforeConnect").subscribe((evt) => {
55598
55784
  const {
55599
- connectParams: { version: version2, protocol, port, host }
55785
+ connectParams: { version: version3, protocol, port, host }
55600
55786
  } = evt;
55601
55787
  debuglog(
55602
55788
  "connecting to %s using %s%s",
55603
55789
  `${host}${port ? `:${port}` : ""}`,
55604
55790
  protocol,
55605
- version2
55791
+ version3
55606
55792
  );
55607
55793
  });
55608
55794
  diagnosticsChannel.channel("undici:client:connected").subscribe((evt) => {
55609
55795
  const {
55610
- connectParams: { version: version2, protocol, port, host }
55796
+ connectParams: { version: version3, protocol, port, host }
55611
55797
  } = evt;
55612
55798
  debuglog(
55613
55799
  "connected to %s using %s%s",
55614
55800
  `${host}${port ? `:${port}` : ""}`,
55615
55801
  protocol,
55616
- version2
55802
+ version3
55617
55803
  );
55618
55804
  });
55619
55805
  diagnosticsChannel.channel("undici:client:connectError").subscribe((evt) => {
55620
55806
  const {
55621
- connectParams: { version: version2, protocol, port, host },
55807
+ connectParams: { version: version3, protocol, port, host },
55622
55808
  error: error48
55623
55809
  } = evt;
55624
55810
  debuglog(
55625
55811
  "connection to %s using %s%s errored - %s",
55626
55812
  `${host}${port ? `:${port}` : ""}`,
55627
55813
  protocol,
55628
- version2,
55814
+ version3,
55629
55815
  error48.message
55630
55816
  );
55631
55817
  });
@@ -55674,31 +55860,31 @@ var require_diagnostics = __commonJS({
55674
55860
  const debuglog = undiciDebugLog.enabled ? undiciDebugLog : websocketDebuglog;
55675
55861
  diagnosticsChannel.channel("undici:client:beforeConnect").subscribe((evt) => {
55676
55862
  const {
55677
- connectParams: { version: version2, protocol, port, host }
55863
+ connectParams: { version: version3, protocol, port, host }
55678
55864
  } = evt;
55679
55865
  debuglog(
55680
55866
  "connecting to %s%s using %s%s",
55681
55867
  host,
55682
55868
  port ? `:${port}` : "",
55683
55869
  protocol,
55684
- version2
55870
+ version3
55685
55871
  );
55686
55872
  });
55687
55873
  diagnosticsChannel.channel("undici:client:connected").subscribe((evt) => {
55688
55874
  const {
55689
- connectParams: { version: version2, protocol, port, host }
55875
+ connectParams: { version: version3, protocol, port, host }
55690
55876
  } = evt;
55691
55877
  debuglog(
55692
55878
  "connected to %s%s using %s%s",
55693
55879
  host,
55694
55880
  port ? `:${port}` : "",
55695
55881
  protocol,
55696
- version2
55882
+ version3
55697
55883
  );
55698
55884
  });
55699
55885
  diagnosticsChannel.channel("undici:client:connectError").subscribe((evt) => {
55700
55886
  const {
55701
- connectParams: { version: version2, protocol, port, host },
55887
+ connectParams: { version: version3, protocol, port, host },
55702
55888
  error: error48
55703
55889
  } = evt;
55704
55890
  debuglog(
@@ -55706,7 +55892,7 @@ var require_diagnostics = __commonJS({
55706
55892
  host,
55707
55893
  port ? `:${port}` : "",
55708
55894
  protocol,
55709
- version2,
55895
+ version3,
55710
55896
  error48.message
55711
55897
  );
55712
55898
  });
@@ -64934,7 +65120,7 @@ var require_mock_interceptor = __commonJS({
64934
65120
  var require_mock_client = __commonJS({
64935
65121
  "../../node_modules/.pnpm/undici@6.24.1/node_modules/undici/lib/mock/mock-client.js"(exports, module2) {
64936
65122
  "use strict";
64937
- var { promisify: promisify5 } = __require("node:util");
65123
+ var { promisify: promisify6 } = __require("node:util");
64938
65124
  var Client = require_client();
64939
65125
  var { buildMockDispatch } = require_mock_utils();
64940
65126
  var {
@@ -64974,7 +65160,7 @@ var require_mock_client = __commonJS({
64974
65160
  return new MockInterceptor(opts, this[kDispatches]);
64975
65161
  }
64976
65162
  async [kClose]() {
64977
- await promisify5(this[kOriginalClose])();
65163
+ await promisify6(this[kOriginalClose])();
64978
65164
  this[kConnected] = 0;
64979
65165
  this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
64980
65166
  }
@@ -64987,7 +65173,7 @@ var require_mock_client = __commonJS({
64987
65173
  var require_mock_pool = __commonJS({
64988
65174
  "../../node_modules/.pnpm/undici@6.24.1/node_modules/undici/lib/mock/mock-pool.js"(exports, module2) {
64989
65175
  "use strict";
64990
- var { promisify: promisify5 } = __require("node:util");
65176
+ var { promisify: promisify6 } = __require("node:util");
64991
65177
  var Pool = require_pool();
64992
65178
  var { buildMockDispatch } = require_mock_utils();
64993
65179
  var {
@@ -65027,7 +65213,7 @@ var require_mock_pool = __commonJS({
65027
65213
  return new MockInterceptor(opts, this[kDispatches]);
65028
65214
  }
65029
65215
  async [kClose]() {
65030
- await promisify5(this[kOriginalClose])();
65216
+ await promisify6(this[kOriginalClose])();
65031
65217
  this[kConnected] = 0;
65032
65218
  this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
65033
65219
  }
@@ -75757,14 +75943,14 @@ async function chat(req) {
75757
75943
  try {
75758
75944
  if (provider === "azure") {
75759
75945
  const endpoint = (process.env["AZURE_OPENAI_ENDPOINT"] ?? "").replace(/\/+$/, "");
75760
- const version2 = process.env["AZURE_OPENAI_API_VERSION"] ?? "2024-10-21";
75946
+ const version3 = process.env["AZURE_OPENAI_API_VERSION"] ?? "2024-10-21";
75761
75947
  const deployment = deploymentFor(req.model);
75762
75948
  if (!endpoint || !deployment) {
75763
75949
  console.warn("[errata] llm: azure selected but endpoint/deployment missing \u2014 skipping");
75764
75950
  return null;
75765
75951
  }
75766
75952
  const resp2 = await fetch(
75767
- `${endpoint}/openai/deployments/${deployment}/chat/completions?api-version=${version2}`,
75953
+ `${endpoint}/openai/deployments/${deployment}/chat/completions?api-version=${version3}`,
75768
75954
  {
75769
75955
  method: "POST",
75770
75956
  headers: {
@@ -79450,9 +79636,9 @@ function rankCandidates(cs) {
79450
79636
  var VCS_HOST_SHORTHAND = /^(?:github|gitlab|bitbucket|gist):/;
79451
79637
  var SCP_STYLE_REMOTE = /^[\w.-]+@[\w.-]+:/;
79452
79638
  var BARE_REPO_SHORTHAND = /^[a-z0-9_.-]+\/[a-z0-9_.-]+(?:#.*)?$/;
79453
- function isLocalSpec(version2) {
79454
- if (!version2) return false;
79455
- const v = version2.trim().toLowerCase();
79639
+ function isLocalSpec(version3) {
79640
+ if (!version3) return false;
79641
+ const v = version3.trim().toLowerCase();
79456
79642
  return v.startsWith("workspace:") || v.startsWith("link:") || v.startsWith("file:") || v.startsWith("portal:") || v.startsWith("path:") || v.startsWith("git:") || v.startsWith("git+") || v.includes("://") || VCS_HOST_SHORTHAND.test(v) || SCP_STYLE_REMOTE.test(v) || BARE_REPO_SHORTHAND.test(v);
79457
79643
  }
79458
79644
  function retrievalStackTokens(input) {
@@ -82246,7 +82432,7 @@ function createWatchBreaker(deps) {
82246
82432
  }
82247
82433
 
82248
82434
  // src/engine.ts
82249
- var DAEMON_VERSION = true ? "2.0.17-dev.3504" : "2.0.0-alpha.0";
82435
+ var DAEMON_VERSION = true ? "2.0.17-dev.3527" : "2.0.0-alpha.0";
82250
82436
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
82251
82437
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
82252
82438
  var GIT_OP_MUTE_MS = 4e3;
@@ -86502,8 +86688,8 @@ async function lookupPublished(channel, timeoutMs = 4e3) {
86502
86688
  });
86503
86689
  if (!res.ok) return { error: `http ${res.status}` };
86504
86690
  const body2 = await res.json();
86505
- const version2 = body2["dist-tags"]?.[channel];
86506
- return version2 ? { version: version2 } : { error: "no-tag" };
86691
+ const version3 = body2["dist-tags"]?.[channel];
86692
+ return version3 ? { version: version3 } : { error: "no-tag" };
86507
86693
  } catch {
86508
86694
  return { error: ctrl.signal.aborted ? "timeout" : "unreachable" };
86509
86695
  } finally {
@@ -87064,11 +87250,115 @@ async function hydrateProject(opts) {
87064
87250
  // src/history-reconcile.ts
87065
87251
  init_src11();
87066
87252
  init_src();
87253
+ import { execFile as execFile5 } from "node:child_process";
87254
+ import { promisify as promisify4 } from "node:util";
87255
+ import { extname as extname3 } from "node:path";
87256
+
87257
+ // src/history-dependency-snapshot.ts
87258
+ init_src();
87067
87259
  import { execFile as execFile4 } from "node:child_process";
87068
87260
  import { promisify as promisify3 } from "node:util";
87069
- import { extname as extname3 } from "node:path";
87070
- init_profile2();
87071
87261
  var exec = promisify3(execFile4);
87262
+ async function readHistoryDependencySnapshot(opts) {
87263
+ const git3 = opts.git ?? (async (args2) => (await exec("git", ["-C", opts.root, ...args2], { windowsHide: true, maxBuffer: 16 * 1024 * 1024 })).stdout);
87264
+ const read2 = opts.readBlob ?? (async (oid) => git3(["show", oid]));
87265
+ let complete = true;
87266
+ const tree = await git3(["ls-tree", "-r", opts.commit]).catch(() => null);
87267
+ if (tree === null) return { schemaVersion: "history-deps-1", complete: false, dependencies: [] };
87268
+ const entries = tree.split("\n").flatMap((line) => {
87269
+ const match2 = /^\d+ blob ([a-f0-9]+)\t(.+)$/.exec(line);
87270
+ if (!match2) return [];
87271
+ const path2 = match2[2].replace(/^"|"$/g, "");
87272
+ if (path2.includes("\\") || /[\r\n]/.test(path2)) {
87273
+ complete = false;
87274
+ return [];
87275
+ }
87276
+ return [{ path: path2, oid: match2[1] }];
87277
+ });
87278
+ const manifests = {}, locks = {};
87279
+ for (const { path: path2, oid } of entries) {
87280
+ const lock = /(?:^|\/)(?:pnpm-lock.yaml|package-lock.json)$/.test(path2);
87281
+ if (!lock && (!isManifestPath(path2) || opts.manifestIds && !opts.manifestIds.has(historyManifestId(path2)))) continue;
87282
+ if (opts.paths && !Object.values(opts.paths).some((p) => !path2.includes("/") || p.startsWith(path2.slice(0, path2.lastIndexOf("/") + 1)))) continue;
87283
+ if (opts.allowPath && !opts.allowPath(path2)) {
87284
+ complete = false;
87285
+ continue;
87286
+ }
87287
+ try {
87288
+ const text = await read2(oid);
87289
+ if (text === null || text.length > 8e6) {
87290
+ complete = false;
87291
+ continue;
87292
+ }
87293
+ if (!lock && path2.endsWith("package.json")) {
87294
+ const json2 = JSON.parse(text);
87295
+ if (!json2 || typeof json2 !== "object" || Array.isArray(json2)) {
87296
+ complete = false;
87297
+ continue;
87298
+ }
87299
+ }
87300
+ if (lock) locks[path2] = text;
87301
+ else manifests[path2] = text;
87302
+ } catch {
87303
+ complete = false;
87304
+ }
87305
+ }
87306
+ const spine = buildSpine(opts.commit, Object.keys(manifests), (p) => manifests[p]);
87307
+ const sources = /* @__PURE__ */ new Map();
87308
+ for (const [token, path2] of Object.entries(opts.paths ?? {})) {
87309
+ if (opts.allowPath && !opts.allowPath(path2)) continue;
87310
+ const file2 = entries.find((e) => e.path === path2);
87311
+ if (!file2) continue;
87312
+ try {
87313
+ const text = await read2(file2.oid);
87314
+ if (text !== null && text.length <= 1e6) sources.set(token, text);
87315
+ else complete = false;
87316
+ } catch {
87317
+ complete = false;
87318
+ }
87319
+ }
87320
+ const dependencies = /* @__PURE__ */ new Map();
87321
+ const paths = opts.paths ? Object.entries(opts.paths) : [["", ""]];
87322
+ for (const [token, path2] of paths) {
87323
+ if (path2 && opts.allowPath && !opts.allowPath(path2)) continue;
87324
+ const governing = Object.entries(spine.manifests).filter(([m]) => !opts.paths || !m.includes("/") || path2.startsWith(m.slice(0, m.lastIndexOf("/") + 1))).sort(([a], [b]) => b.split("/").length - a.split("/").length || a.localeCompare(b));
87325
+ const chosen = /* @__PURE__ */ new Set();
87326
+ for (const [manifest, deps] of governing) for (const d of deps) {
87327
+ const packageId = historyDependencyPackageId(d.ecosystem, d.name);
87328
+ if (opts.paths && chosen.has(packageId)) continue;
87329
+ chosen.add(packageId);
87330
+ const manifestId = historyManifestId(manifest), key = `${packageId}:${manifestId}`;
87331
+ let dependency = dependencies.get(key);
87332
+ if (!dependency) {
87333
+ const declaredRange = !d.directRef && d.version && !/[:/\\@]/.test(d.version) ? d.version : null;
87334
+ dependency = {
87335
+ packageId,
87336
+ ecosystem: d.ecosystem,
87337
+ name: d.name,
87338
+ kind: d.kind,
87339
+ manifestId,
87340
+ sourceCommit: opts.commit,
87341
+ side: opts.side,
87342
+ declaredRange,
87343
+ resolvedVersion: d.ecosystem === "npm" && declaredRange ? resolveHistoricalNpmVersion(d.name, manifest, declaredRange, locks) : null,
87344
+ pathTokens: [],
87345
+ importTokens: []
87346
+ };
87347
+ dependencies.set(key, dependency);
87348
+ }
87349
+ if (token && !dependency.pathTokens.includes(token)) dependency.pathTokens.push(token);
87350
+ const source = sources.get(token) ?? "";
87351
+ const modules = [...source.matchAll(/(?:\bfrom\s*|\bimport\s*(?:\(\s*)?|\brequire\s*\(\s*)['"]([^'"\r\n]+)['"]/g)].map((m) => m[1]);
87352
+ if (token && d.ecosystem === "npm" && modules.some((m) => m === d.name || m.startsWith(d.name + "/")) && !dependency.importTokens.includes(token)) dependency.importTokens.push(token);
87353
+ }
87354
+ }
87355
+ const values = [...dependencies.values()].sort((a, b) => a.packageId.localeCompare(b.packageId) || a.manifestId.localeCompare(b.manifestId));
87356
+ return { schemaVersion: "history-deps-1", complete: complete && values.length <= 128, dependencies: values.slice(0, 128) };
87357
+ }
87358
+
87359
+ // src/history-reconcile.ts
87360
+ init_profile2();
87361
+ var exec2 = promisify4(execFile5);
87072
87362
  var KINDS = { function: "Function", class: "Class", method: "Method", interface: "Interface", const: "Const", enum: "Enum", typealias: "TypeAlias", namespace: "Namespace", property: "Property" };
87073
87363
  var inFlight = /* @__PURE__ */ new Map();
87074
87364
  async function syncHistoryRevision(opts) {
@@ -87098,7 +87388,7 @@ async function syncHistoryRevisionPage(opts) {
87098
87388
  const { root, profile, store, cloud, salt } = opts;
87099
87389
  if (!profile.projectId) return { changed: 0, remaining: false };
87100
87390
  const projectId = profile.projectId;
87101
- const git3 = opts.git ?? (async (args2) => (await exec("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
87391
+ const git3 = opts.git ?? (async (args2) => (await exec2("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
87102
87392
  const atCommit = (await git3(["rev-parse", "--verify", "HEAD"])).trim();
87103
87393
  if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(atCommit)) throw new Error("history revision is not a full Git object id");
87104
87394
  const oldCursor = profile.historyRevisionCursor;
@@ -87117,6 +87407,16 @@ async function syncHistoryRevisionPage(opts) {
87117
87407
  const providers = defaultProviders();
87118
87408
  const parsedFiles = /* @__PURE__ */ new Map();
87119
87409
  const observations = [];
87410
+ const contexts = page.occurrences.map((o) => HistoryDependencyContextSchema.safeParse(o.quality["dependencyContext"]));
87411
+ const manifestIds = new Set(contexts.flatMap((c) => c.success ? c.data.dependencies.map((d) => d.manifestId) : []));
87412
+ const currentDependencies = manifestIds.size ? await readHistoryDependencySnapshot({
87413
+ root,
87414
+ commit: atCommit,
87415
+ side: "after",
87416
+ manifestIds,
87417
+ git: git3,
87418
+ allowPath: (p) => pathAllowedByFloor(p) && !isPathBlocked(ignore2, p)
87419
+ }) : void 0;
87120
87420
  for (const occurrence of page.occurrences) {
87121
87421
  const anchors = occurrence.quality["historicalAnchors"];
87122
87422
  const paths = /* @__PURE__ */ new Set(), symbols = [];
@@ -87157,7 +87457,13 @@ async function syncHistoryRevisionPage(opts) {
87157
87457
  }, { maxTokens: 4e3, ignorePatterns: profile.ignoreExtra ?? [] }).catch(() => null);
87158
87458
  if (bundle && !bundle.truncated) diff = bundle.diff;
87159
87459
  }
87160
- observations.push({ occurrenceId: occurrence.occurrenceId, symbols, ...diff ? { diff } : {} });
87460
+ const old = HistoryDependencyContextSchema.safeParse(occurrence.quality["dependencyContext"]);
87461
+ const dependencyContext = old.success ? {
87462
+ schemaVersion: "history-deps-1",
87463
+ complete: old.data.dependencies.length === 0 || currentDependencies?.complete === true,
87464
+ dependencies: currentDependencies?.dependencies.filter((d) => old.data.dependencies.some((o) => o.packageId === d.packageId && o.manifestId === d.manifestId)) ?? []
87465
+ } : void 0;
87466
+ observations.push({ occurrenceId: occurrence.occurrenceId, symbols, ...diff ? { diff } : {}, ...dependencyContext ? { dependencyContext } : {} });
87161
87467
  }
87162
87468
  const response = page.occurrences.length ? await cloud.reconcileHistory(projectId, { atCommit, parents, observations }) : { atCommit, receipts: [] };
87163
87469
  if (response.atCommit !== atCommit || response.receipts.length !== page.occurrences.length || new Set(response.receipts.map((r) => r.occurrenceId)).size !== response.receipts.length || response.receipts.some((r) => r.atCommit !== atCommit || !observations.some((o) => o.occurrenceId === r.occurrenceId))) throw new Error("incomplete history reconciliation response");
@@ -87168,7 +87474,7 @@ async function syncHistoryRevisionPage(opts) {
87168
87474
  if (!node2 || node2.attrs["source"] !== "cloud" || node2.attrs["historyQuality"]?.["sourceSupport"] === "quarantined") continue;
87169
87475
  const receipt = response.receipts.find((r) => r.occurrenceId === occurrence.occurrenceId);
87170
87476
  const previous = node2.attrs["historyQuality"];
87171
- if (previous?.["evaluatedAtCommit"] === atCommit && previous["applicability"] === "applicable" && receipt.verdict !== "applicable") continue;
87477
+ if (previous?.["evaluatedAtCommit"] === atCommit && previous["applicability"] === "applicable" && receipt.verdict !== "applicable" && previous["reconciliationEvidence"]?.["build"] === HISTORY_RECONCILE_BUILD) continue;
87172
87478
  store.mergeNode({ ...node2, attrs: { ...node2.attrs, historyQuality: {
87173
87479
  ...occurrence.quality,
87174
87480
  evaluatedAtCommit: atCommit,
@@ -87185,10 +87491,10 @@ async function syncHistoryRevisionPage(opts) {
87185
87491
  // src/project-history.ts
87186
87492
  init_src7();
87187
87493
  init_src();
87188
- import { execFile as execFile5 } from "node:child_process";
87494
+ import { execFile as execFile6 } from "node:child_process";
87189
87495
  import { readFileSync as readFileSync35 } from "node:fs";
87190
87496
  import { join as join39 } from "node:path";
87191
- import { promisify as promisify4 } from "node:util";
87497
+ import { promisify as promisify5 } from "node:util";
87192
87498
 
87193
87499
  // src/history-walk.ts
87194
87500
  var LOCKFILE_NAMES = /* @__PURE__ */ new Set([
@@ -87722,7 +88028,7 @@ async function historicalAnchors(input) {
87722
88028
 
87723
88029
  // src/project-history.ts
87724
88030
  init_profile2();
87725
- var execFileAsync2 = promisify4(execFile5);
88031
+ var execFileAsync2 = promisify5(execFile6);
87726
88032
  var HISTORY_EXTRACTOR_VERSION = "history-2";
87727
88033
  var LEASE_POLL_MS = 2e4;
87728
88034
  var RECOVERY_DEADLINE_MS = 15 * 6e4;
@@ -87909,6 +88215,8 @@ async function walk10(root, input, client, opts, readBlob) {
87909
88215
  return { profile, processed: 0, state: "done" };
87910
88216
  }
87911
88217
  const ignoreLines = readIgnoreLines(root, profile);
88218
+ const dependencyIgnore = loadRepoIgnore(root, ignoreLines);
88219
+ const allowDependencyPath = (path2) => pathAllowedByFloor(path2) && !isPathBlocked(dependencyIgnore, path2);
87912
88220
  let counts = profile.historyStage?.counts ?? {};
87913
88221
  let processed = 0;
87914
88222
  const byIndex = /* @__PURE__ */ new Map();
@@ -87963,6 +88271,29 @@ async function walk10(root, input, client, opts, readBlob) {
87963
88271
  };
87964
88272
  const spine = await spineForUnit(git3, root, u, readBlob, (line) => log(`[errata] history ${u.sha.slice(0, 12)}/${u.subIndex}: ${line}`));
87965
88273
  if (spine) body2.spine = spine;
88274
+ const dependencyAfter = await readHistoryDependencySnapshot({
88275
+ root,
88276
+ commit: u.sha,
88277
+ side: "after",
88278
+ paths: bundle.pathTokens,
88279
+ git: (args2) => git3(root, args2),
88280
+ readBlob,
88281
+ allowPath: allowDependencyPath
88282
+ });
88283
+ const dependencyBefore = u.parents[0] ? await readHistoryDependencySnapshot({
88284
+ root,
88285
+ commit: u.parents[0],
88286
+ side: "before",
88287
+ paths: bundle.pathTokens,
88288
+ git: (args2) => git3(root, args2),
88289
+ readBlob,
88290
+ allowPath: allowDependencyPath
88291
+ }) : { complete: true, dependencies: [] };
88292
+ body2.dependencyContext = {
88293
+ schemaVersion: "history-deps-1",
88294
+ complete: dependencyAfter.complete && dependencyBefore.complete,
88295
+ dependencies: [...dependencyBefore.dependencies, ...dependencyAfter.dependencies]
88296
+ };
87966
88297
  const anchors = opts.anchors ? await historicalAnchors({
87967
88298
  root,
87968
88299
  projectId,
@@ -92010,9 +92341,9 @@ var OPENCODE_PLUGIN_MARKER = "// @inerrata opencode plugin \u2014 errata-managed
92010
92341
  var OPENCODE_D1_CONTRACT = "Behavioral contract: (1) On ANY error, call search() BEFORE debugging \u2014 costs ~400 tokens vs 5,000\u201350,000 cold. (2) After solving non-trivial problems, contribute back: if your harness emits typed nodes (canonicalId + label + attrs), use ingest \u2014 the typed door; otherwise call contribute(), the prose fallback. (3) Before web search, try search() first \u2014 graph is 2\u201315\xD7 cheaper. (4) At session end, review what you solved and contribute anything novel.";
92011
92342
  var OPENCODE_TOOL_FAILURE_NUDGE = "[inerrata] This tool call failed \u2014 call search() with the error message BEFORE debugging from scratch (~400 tokens vs 5,000\u201350,000 cold).";
92012
92343
  function buildOpencodePluginSource(port, opts = {}) {
92013
- const version2 = opts.version ?? "dev";
92344
+ const version3 = opts.version ?? "dev";
92014
92345
  return `${OPENCODE_PLUGIN_MARKER}
92015
- // Generated by errata ${version2}. Re-run \`errata install-hooks opencode\` to update; edits here are overwritten.
92346
+ // Generated by errata ${version3}. Re-run \`errata install-hooks opencode\` to update; edits here are overwritten.
92016
92347
  // What it does: mirrors each OpenCode session's OWN message record to a JSONL
92017
92348
  // file the errata daemon can parse, and tells the daemon on every turn boundary.
92018
92349
  // It has no dependencies and never throws into OpenCode.