@inerrata-corporation/errata 2.0.0-dev.80 → 2.0.0-dev.83
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/consolidate-worker.mjs +8 -0
- package/errata.mjs +260 -133
- package/package.json +1 -1
- package/pass-worker.mjs +8 -0
package/consolidate-worker.mjs
CHANGED
|
@@ -15355,6 +15355,13 @@ var init_project_symbol = __esm({
|
|
|
15355
15355
|
}
|
|
15356
15356
|
});
|
|
15357
15357
|
|
|
15358
|
+
// ../../packages/shared/src/lockfile.ts
|
|
15359
|
+
var init_lockfile = __esm({
|
|
15360
|
+
"../../packages/shared/src/lockfile.ts"() {
|
|
15361
|
+
"use strict";
|
|
15362
|
+
}
|
|
15363
|
+
});
|
|
15364
|
+
|
|
15358
15365
|
// ../../packages/shared/src/nlp/canonicalize.ts
|
|
15359
15366
|
var init_canonicalize = __esm({
|
|
15360
15367
|
"../../packages/shared/src/nlp/canonicalize.ts"() {
|
|
@@ -15391,6 +15398,7 @@ var init_src = __esm({
|
|
|
15391
15398
|
init_symbol_intent();
|
|
15392
15399
|
init_repo_locator();
|
|
15393
15400
|
init_project_symbol();
|
|
15401
|
+
init_lockfile();
|
|
15394
15402
|
init_hash();
|
|
15395
15403
|
init_error_signature();
|
|
15396
15404
|
init_canonicalize();
|
package/errata.mjs
CHANGED
|
@@ -15656,6 +15656,144 @@ var init_project_symbol = __esm({
|
|
|
15656
15656
|
}
|
|
15657
15657
|
});
|
|
15658
15658
|
|
|
15659
|
+
// ../../packages/shared/src/lockfile.ts
|
|
15660
|
+
function npmPurl(name2, version2) {
|
|
15661
|
+
return `pkg:npm/${name2}@${version2}`;
|
|
15662
|
+
}
|
|
15663
|
+
function component(name2, version2) {
|
|
15664
|
+
return { purl: npmPurl(name2, version2), name: name2, version: version2, ecosystem: "npm" };
|
|
15665
|
+
}
|
|
15666
|
+
function parsePackageLockJson(jsonText) {
|
|
15667
|
+
let doc;
|
|
15668
|
+
try {
|
|
15669
|
+
doc = JSON.parse(jsonText);
|
|
15670
|
+
} catch {
|
|
15671
|
+
return { components: [], dependencies: [] };
|
|
15672
|
+
}
|
|
15673
|
+
const packages = doc.packages ?? {};
|
|
15674
|
+
const components = [];
|
|
15675
|
+
const hoisted = /* @__PURE__ */ new Map();
|
|
15676
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
15677
|
+
for (const [path2, meta3] of Object.entries(packages)) {
|
|
15678
|
+
if (path2 === "" || meta3.link === true) continue;
|
|
15679
|
+
const ix = path2.lastIndexOf("node_modules/");
|
|
15680
|
+
if (ix === -1) continue;
|
|
15681
|
+
const name2 = path2.slice(ix + "node_modules/".length);
|
|
15682
|
+
const version2 = typeof meta3.version === "string" ? meta3.version : "";
|
|
15683
|
+
if (!name2 || !version2) continue;
|
|
15684
|
+
components.push(component(name2, version2));
|
|
15685
|
+
byPath.set(path2, { name: name2, version: version2 });
|
|
15686
|
+
const depth = path2.split("node_modules/").length;
|
|
15687
|
+
const prev = hoisted.get(name2);
|
|
15688
|
+
if (!prev || depth < prev.depth) hoisted.set(name2, { version: version2, depth });
|
|
15689
|
+
}
|
|
15690
|
+
const dependencies = [];
|
|
15691
|
+
for (const [path2, meta3] of Object.entries(packages)) {
|
|
15692
|
+
const self = byPath.get(path2);
|
|
15693
|
+
if (!self) continue;
|
|
15694
|
+
const deps = meta3.dependencies;
|
|
15695
|
+
if (!deps || typeof deps !== "object") continue;
|
|
15696
|
+
const dependsOn = [];
|
|
15697
|
+
for (const depName of Object.keys(deps)) {
|
|
15698
|
+
const target = hoisted.get(depName);
|
|
15699
|
+
if (target) dependsOn.push(npmPurl(depName, target.version));
|
|
15700
|
+
}
|
|
15701
|
+
if (dependsOn.length > 0)
|
|
15702
|
+
dependencies.push({ ref: npmPurl(self.name, self.version), dependsOn });
|
|
15703
|
+
}
|
|
15704
|
+
return { components, dependencies: dedupeRefs(dependencies) };
|
|
15705
|
+
}
|
|
15706
|
+
function splitPnpmKey(raw2) {
|
|
15707
|
+
let k = raw2.trim().replace(/^['"]|['"]$/g, "");
|
|
15708
|
+
if (k.startsWith("/")) k = k.slice(1);
|
|
15709
|
+
const paren = k.indexOf("(");
|
|
15710
|
+
if (paren !== -1) k = k.slice(0, paren);
|
|
15711
|
+
if (k.startsWith("link:") || k.startsWith("file:") || k.includes("://")) return null;
|
|
15712
|
+
const at = k.lastIndexOf("@");
|
|
15713
|
+
if (at <= 0) return null;
|
|
15714
|
+
const name2 = k.slice(0, at);
|
|
15715
|
+
const version2 = k.slice(at + 1);
|
|
15716
|
+
if (!name2 || !version2) return null;
|
|
15717
|
+
return { name: name2, version: version2 };
|
|
15718
|
+
}
|
|
15719
|
+
function parsePnpmLock(text) {
|
|
15720
|
+
const lines = text.split(/\r?\n/);
|
|
15721
|
+
const components = [];
|
|
15722
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15723
|
+
const dependencies = [];
|
|
15724
|
+
let section = null;
|
|
15725
|
+
let currentPkg = null;
|
|
15726
|
+
let inDepsBlock = false;
|
|
15727
|
+
let currentDeps = [];
|
|
15728
|
+
const flushDeps = () => {
|
|
15729
|
+
if (currentPkg && currentDeps.length > 0) {
|
|
15730
|
+
dependencies.push({
|
|
15731
|
+
ref: npmPurl(currentPkg.name, currentPkg.version),
|
|
15732
|
+
dependsOn: currentDeps.slice()
|
|
15733
|
+
});
|
|
15734
|
+
}
|
|
15735
|
+
currentDeps = [];
|
|
15736
|
+
};
|
|
15737
|
+
for (const line of lines) {
|
|
15738
|
+
if (!line.trim() || line.trimStart().startsWith("#")) continue;
|
|
15739
|
+
const indent = line.length - line.trimStart().length;
|
|
15740
|
+
if (indent === 0) {
|
|
15741
|
+
flushDeps();
|
|
15742
|
+
currentPkg = null;
|
|
15743
|
+
inDepsBlock = false;
|
|
15744
|
+
section = line === "packages:" ? "packages" : line === "snapshots:" ? "snapshots" : null;
|
|
15745
|
+
continue;
|
|
15746
|
+
}
|
|
15747
|
+
if (!section) continue;
|
|
15748
|
+
if (indent === 2 && line.trimEnd().endsWith(":")) {
|
|
15749
|
+
flushDeps();
|
|
15750
|
+
inDepsBlock = false;
|
|
15751
|
+
const key = line.trim().slice(0, -1);
|
|
15752
|
+
currentPkg = splitPnpmKey(key);
|
|
15753
|
+
if (currentPkg && section === "packages") {
|
|
15754
|
+
const purl = npmPurl(currentPkg.name, currentPkg.version);
|
|
15755
|
+
if (!seen.has(purl)) {
|
|
15756
|
+
seen.add(purl);
|
|
15757
|
+
components.push(component(currentPkg.name, currentPkg.version));
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
15760
|
+
continue;
|
|
15761
|
+
}
|
|
15762
|
+
if (!currentPkg) continue;
|
|
15763
|
+
if (indent === 4) {
|
|
15764
|
+
inDepsBlock = line.trim() === "dependencies:";
|
|
15765
|
+
continue;
|
|
15766
|
+
}
|
|
15767
|
+
if (inDepsBlock && indent === 6) {
|
|
15768
|
+
const t = line.trim();
|
|
15769
|
+
const at = t.indexOf(": ");
|
|
15770
|
+
if (at === -1) continue;
|
|
15771
|
+
const depName = t.slice(0, at).replace(/^['"]|['"]$/g, "");
|
|
15772
|
+
let depVersion = t.slice(at + 2).trim().replace(/^['"]|['"]$/g, "");
|
|
15773
|
+
const paren = depVersion.indexOf("(");
|
|
15774
|
+
if (paren !== -1) depVersion = depVersion.slice(0, paren);
|
|
15775
|
+
if (depName && depVersion && !depVersion.startsWith("link:"))
|
|
15776
|
+
currentDeps.push(npmPurl(depName, depVersion));
|
|
15777
|
+
}
|
|
15778
|
+
}
|
|
15779
|
+
flushDeps();
|
|
15780
|
+
return { components, dependencies: dedupeRefs(dependencies) };
|
|
15781
|
+
}
|
|
15782
|
+
function dedupeRefs(deps) {
|
|
15783
|
+
const byRef = /* @__PURE__ */ new Map();
|
|
15784
|
+
for (const d of deps) {
|
|
15785
|
+
const set2 = byRef.get(d.ref) ?? /* @__PURE__ */ new Set();
|
|
15786
|
+
for (const t of d.dependsOn) set2.add(t);
|
|
15787
|
+
byRef.set(d.ref, set2);
|
|
15788
|
+
}
|
|
15789
|
+
return [...byRef.entries()].map(([ref, set2]) => ({ ref, dependsOn: [...set2] }));
|
|
15790
|
+
}
|
|
15791
|
+
var init_lockfile = __esm({
|
|
15792
|
+
"../../packages/shared/src/lockfile.ts"() {
|
|
15793
|
+
"use strict";
|
|
15794
|
+
}
|
|
15795
|
+
});
|
|
15796
|
+
|
|
15659
15797
|
// ../../packages/shared/src/nlp/canonicalize.ts
|
|
15660
15798
|
function canonicalize(value) {
|
|
15661
15799
|
return value.normalize("NFC").trim().toLowerCase().replace(/\s+/g, " ");
|
|
@@ -15774,9 +15912,12 @@ __export(src_exports, {
|
|
|
15774
15912
|
normalizePredicate: () => normalizePredicate,
|
|
15775
15913
|
normalizeRepoLocator: () => normalizeRepoLocator,
|
|
15776
15914
|
normalizeSymbolPath: () => normalizeSymbolPath,
|
|
15915
|
+
npmPurl: () => npmPurl,
|
|
15777
15916
|
packageCanonicalId: () => packageCanonicalId,
|
|
15778
15917
|
pagerankEdgeTypes: () => pagerankEdgeTypes,
|
|
15918
|
+
parsePackageLockJson: () => parsePackageLockJson,
|
|
15779
15919
|
parsePackageRef: () => parsePackageRef,
|
|
15920
|
+
parsePnpmLock: () => parsePnpmLock,
|
|
15780
15921
|
prefilterEntities: () => prefilterEntities,
|
|
15781
15922
|
problemIdFromError: () => problemIdFromError,
|
|
15782
15923
|
projectSymbolId: () => projectSymbolId,
|
|
@@ -15785,6 +15926,7 @@ __export(src_exports, {
|
|
|
15785
15926
|
resolveCanonicalId: () => resolveCanonicalId,
|
|
15786
15927
|
sha256: () => sha256,
|
|
15787
15928
|
sha256Short: () => sha256Short,
|
|
15929
|
+
splitPnpmKey: () => splitPnpmKey,
|
|
15788
15930
|
substituteSymbolSummaries: () => substituteSymbolSummaries,
|
|
15789
15931
|
summarizeIngestResult: () => summarizeIngestResult,
|
|
15790
15932
|
summaryRejectionReason: () => summaryRejectionReason,
|
|
@@ -15802,6 +15944,7 @@ var init_src = __esm({
|
|
|
15802
15944
|
init_symbol_intent();
|
|
15803
15945
|
init_repo_locator();
|
|
15804
15946
|
init_project_symbol();
|
|
15947
|
+
init_lockfile();
|
|
15805
15948
|
init_hash();
|
|
15806
15949
|
init_error_signature();
|
|
15807
15950
|
init_canonicalize();
|
|
@@ -21461,7 +21604,14 @@ var init_client = __esm({
|
|
|
21461
21604
|
"GET",
|
|
21462
21605
|
`/v2/projects/${encodeURIComponent(projectId)}/priors?limit=${String(limit)}`
|
|
21463
21606
|
);
|
|
21464
|
-
|
|
21607
|
+
const { nodes, edges } = this.toCastalia(res);
|
|
21608
|
+
const anchorEdges = (res.anchorEdges ?? []).map((a) => ({
|
|
21609
|
+
from: a.fromCanonicalId,
|
|
21610
|
+
toSymbolId: a.toSymbolId,
|
|
21611
|
+
type: a.type,
|
|
21612
|
+
attrs: a.attrs ?? {}
|
|
21613
|
+
}));
|
|
21614
|
+
return { nodes, edges, anchorEdges, symbolIds: res.symbolIds ?? [] };
|
|
21465
21615
|
}
|
|
21466
21616
|
/** Pull cloud-induced skills + the session-bootstrap prime payload. `seed` is the
|
|
21467
21617
|
* canonical ids of the agent's recent problems — the cloud ranks the skills whose
|
|
@@ -43379,7 +43529,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
43379
43529
|
}
|
|
43380
43530
|
|
|
43381
43531
|
// src/engine.ts
|
|
43382
|
-
var DAEMON_VERSION = true ? "2.0.0-dev.
|
|
43532
|
+
var DAEMON_VERSION = true ? "2.0.0-dev.83" : "2.0.0-alpha.0";
|
|
43383
43533
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
43384
43534
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
43385
43535
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -44823,6 +44973,7 @@ async function syncPrinciples(store, cloud, opts) {
|
|
|
44823
44973
|
init_reconcile();
|
|
44824
44974
|
|
|
44825
44975
|
// src/lockfile-auto.ts
|
|
44976
|
+
init_src();
|
|
44826
44977
|
import { existsSync as existsSync20, readFileSync as readFileSync18 } from "node:fs";
|
|
44827
44978
|
import { join as join24 } from "node:path";
|
|
44828
44979
|
|
|
@@ -44949,137 +45100,7 @@ function buildContextIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
44949
45100
|
}
|
|
44950
45101
|
|
|
44951
45102
|
// src/lockfile-auto.ts
|
|
44952
|
-
|
|
44953
|
-
return `pkg:npm/${name2}@${version2}`;
|
|
44954
|
-
}
|
|
44955
|
-
function component(name2, version2) {
|
|
44956
|
-
return { purl: npmPurl(name2, version2), name: name2, version: version2, ecosystem: "npm" };
|
|
44957
|
-
}
|
|
44958
|
-
function parsePackageLockJson(jsonText) {
|
|
44959
|
-
let doc;
|
|
44960
|
-
try {
|
|
44961
|
-
doc = JSON.parse(jsonText);
|
|
44962
|
-
} catch {
|
|
44963
|
-
return { components: [], dependencies: [] };
|
|
44964
|
-
}
|
|
44965
|
-
const packages = doc.packages ?? {};
|
|
44966
|
-
const components = [];
|
|
44967
|
-
const hoisted = /* @__PURE__ */ new Map();
|
|
44968
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
44969
|
-
for (const [path2, meta3] of Object.entries(packages)) {
|
|
44970
|
-
if (path2 === "" || meta3.link === true) continue;
|
|
44971
|
-
const ix = path2.lastIndexOf("node_modules/");
|
|
44972
|
-
if (ix === -1) continue;
|
|
44973
|
-
const name2 = path2.slice(ix + "node_modules/".length);
|
|
44974
|
-
const version2 = typeof meta3.version === "string" ? meta3.version : "";
|
|
44975
|
-
if (!name2 || !version2) continue;
|
|
44976
|
-
components.push(component(name2, version2));
|
|
44977
|
-
byPath.set(path2, { name: name2, version: version2 });
|
|
44978
|
-
const depth = path2.split("node_modules/").length;
|
|
44979
|
-
const prev = hoisted.get(name2);
|
|
44980
|
-
if (!prev || depth < prev.depth) hoisted.set(name2, { version: version2, depth });
|
|
44981
|
-
}
|
|
44982
|
-
const dependencies = [];
|
|
44983
|
-
for (const [path2, meta3] of Object.entries(packages)) {
|
|
44984
|
-
const self = byPath.get(path2);
|
|
44985
|
-
if (!self) continue;
|
|
44986
|
-
const deps = meta3.dependencies;
|
|
44987
|
-
if (!deps || typeof deps !== "object") continue;
|
|
44988
|
-
const dependsOn = [];
|
|
44989
|
-
for (const depName of Object.keys(deps)) {
|
|
44990
|
-
const target = hoisted.get(depName);
|
|
44991
|
-
if (target) dependsOn.push(npmPurl(depName, target.version));
|
|
44992
|
-
}
|
|
44993
|
-
if (dependsOn.length > 0)
|
|
44994
|
-
dependencies.push({ ref: npmPurl(self.name, self.version), dependsOn });
|
|
44995
|
-
}
|
|
44996
|
-
return { components, dependencies: dedupeRefs(dependencies) };
|
|
44997
|
-
}
|
|
44998
|
-
function splitPnpmKey(raw2) {
|
|
44999
|
-
let k = raw2.trim().replace(/^['"]|['"]$/g, "");
|
|
45000
|
-
if (k.startsWith("/")) k = k.slice(1);
|
|
45001
|
-
const paren = k.indexOf("(");
|
|
45002
|
-
if (paren !== -1) k = k.slice(0, paren);
|
|
45003
|
-
if (k.startsWith("link:") || k.startsWith("file:") || k.includes("://")) return null;
|
|
45004
|
-
const at = k.lastIndexOf("@");
|
|
45005
|
-
if (at <= 0) return null;
|
|
45006
|
-
const name2 = k.slice(0, at);
|
|
45007
|
-
const version2 = k.slice(at + 1);
|
|
45008
|
-
if (!name2 || !version2) return null;
|
|
45009
|
-
return { name: name2, version: version2 };
|
|
45010
|
-
}
|
|
45011
|
-
function parsePnpmLock(text) {
|
|
45012
|
-
const lines = text.split(/\r?\n/);
|
|
45013
|
-
const components = [];
|
|
45014
|
-
const seen = /* @__PURE__ */ new Set();
|
|
45015
|
-
const dependencies = [];
|
|
45016
|
-
let section = null;
|
|
45017
|
-
let currentPkg = null;
|
|
45018
|
-
let inDepsBlock = false;
|
|
45019
|
-
let currentDeps = [];
|
|
45020
|
-
const flushDeps = () => {
|
|
45021
|
-
if (currentPkg && currentDeps.length > 0) {
|
|
45022
|
-
dependencies.push({
|
|
45023
|
-
ref: npmPurl(currentPkg.name, currentPkg.version),
|
|
45024
|
-
dependsOn: currentDeps.slice()
|
|
45025
|
-
});
|
|
45026
|
-
}
|
|
45027
|
-
currentDeps = [];
|
|
45028
|
-
};
|
|
45029
|
-
for (const line of lines) {
|
|
45030
|
-
if (!line.trim() || line.trimStart().startsWith("#")) continue;
|
|
45031
|
-
const indent = line.length - line.trimStart().length;
|
|
45032
|
-
if (indent === 0) {
|
|
45033
|
-
flushDeps();
|
|
45034
|
-
currentPkg = null;
|
|
45035
|
-
inDepsBlock = false;
|
|
45036
|
-
section = line === "packages:" ? "packages" : line === "snapshots:" ? "snapshots" : null;
|
|
45037
|
-
continue;
|
|
45038
|
-
}
|
|
45039
|
-
if (!section) continue;
|
|
45040
|
-
if (indent === 2 && line.trimEnd().endsWith(":")) {
|
|
45041
|
-
flushDeps();
|
|
45042
|
-
inDepsBlock = false;
|
|
45043
|
-
const key = line.trim().slice(0, -1);
|
|
45044
|
-
currentPkg = splitPnpmKey(key);
|
|
45045
|
-
if (currentPkg && section === "packages") {
|
|
45046
|
-
const purl = npmPurl(currentPkg.name, currentPkg.version);
|
|
45047
|
-
if (!seen.has(purl)) {
|
|
45048
|
-
seen.add(purl);
|
|
45049
|
-
components.push(component(currentPkg.name, currentPkg.version));
|
|
45050
|
-
}
|
|
45051
|
-
}
|
|
45052
|
-
continue;
|
|
45053
|
-
}
|
|
45054
|
-
if (!currentPkg) continue;
|
|
45055
|
-
if (indent === 4) {
|
|
45056
|
-
inDepsBlock = line.trim() === "dependencies:";
|
|
45057
|
-
continue;
|
|
45058
|
-
}
|
|
45059
|
-
if (inDepsBlock && indent === 6) {
|
|
45060
|
-
const t = line.trim();
|
|
45061
|
-
const at = t.indexOf(": ");
|
|
45062
|
-
if (at === -1) continue;
|
|
45063
|
-
const depName = t.slice(0, at).replace(/^['"]|['"]$/g, "");
|
|
45064
|
-
let depVersion = t.slice(at + 2).trim().replace(/^['"]|['"]$/g, "");
|
|
45065
|
-
const paren = depVersion.indexOf("(");
|
|
45066
|
-
if (paren !== -1) depVersion = depVersion.slice(0, paren);
|
|
45067
|
-
if (depName && depVersion && !depVersion.startsWith("link:"))
|
|
45068
|
-
currentDeps.push(npmPurl(depName, depVersion));
|
|
45069
|
-
}
|
|
45070
|
-
}
|
|
45071
|
-
flushDeps();
|
|
45072
|
-
return { components, dependencies: dedupeRefs(dependencies) };
|
|
45073
|
-
}
|
|
45074
|
-
function dedupeRefs(deps) {
|
|
45075
|
-
const byRef = /* @__PURE__ */ new Map();
|
|
45076
|
-
for (const d of deps) {
|
|
45077
|
-
const set2 = byRef.get(d.ref) ?? /* @__PURE__ */ new Set();
|
|
45078
|
-
for (const t of d.dependsOn) set2.add(t);
|
|
45079
|
-
byRef.set(d.ref, set2);
|
|
45080
|
-
}
|
|
45081
|
-
return [...byRef.entries()].map(([ref, set2]) => ({ ref, dependsOn: [...set2] }));
|
|
45082
|
-
}
|
|
45103
|
+
init_src();
|
|
45083
45104
|
function runLockfilePass(opts) {
|
|
45084
45105
|
const ts = Date.now();
|
|
45085
45106
|
const languages = mintLanguageNodes(opts.store, opts.languages, opts.workspaceId, ts);
|
|
@@ -45582,6 +45603,91 @@ async function hydrateProject(opts) {
|
|
|
45582
45603
|
}
|
|
45583
45604
|
}
|
|
45584
45605
|
|
|
45606
|
+
// src/project-reanchor.ts
|
|
45607
|
+
init_src();
|
|
45608
|
+
init_src11();
|
|
45609
|
+
var DEFAULT_LIMIT2 = 50;
|
|
45610
|
+
var ANCHOR_SYMBOL_KINDS = [
|
|
45611
|
+
"Function",
|
|
45612
|
+
"Class",
|
|
45613
|
+
"Method",
|
|
45614
|
+
"Module",
|
|
45615
|
+
"Interface",
|
|
45616
|
+
"Const",
|
|
45617
|
+
"Enum",
|
|
45618
|
+
"TypeAlias",
|
|
45619
|
+
"Namespace",
|
|
45620
|
+
"Property"
|
|
45621
|
+
];
|
|
45622
|
+
function buildReverseSymbolMap(opts) {
|
|
45623
|
+
const { store, salt, projectId } = opts;
|
|
45624
|
+
const reverse = /* @__PURE__ */ new Map();
|
|
45625
|
+
for (const kind of ANCHOR_SYMBOL_KINDS) {
|
|
45626
|
+
for (const n of store.findNodesByLabel(kind)) {
|
|
45627
|
+
const relPath = n.attrs["relPath"];
|
|
45628
|
+
const qname = n.attrs["qname"];
|
|
45629
|
+
if (typeof relPath !== "string" || typeof qname !== "string") continue;
|
|
45630
|
+
const sym = projectSymbolId(salt, projectId, relPath, qname, n.label);
|
|
45631
|
+
if (!reverse.has(sym)) reverse.set(sym, n.id);
|
|
45632
|
+
}
|
|
45633
|
+
}
|
|
45634
|
+
return reverse;
|
|
45635
|
+
}
|
|
45636
|
+
async function reanchorProject(opts) {
|
|
45637
|
+
const { root, profile, store, cloud, salt } = opts;
|
|
45638
|
+
if (!profile.projectId) return { reanchored: false, reason: "no-project" };
|
|
45639
|
+
if (profile.projectReanchoredAt) return { reanchored: false, reason: "already-reanchored" };
|
|
45640
|
+
if (!profile.projectHydratedAt) return { reanchored: false, reason: "not-hydrated" };
|
|
45641
|
+
const reverse = buildReverseSymbolMap({ store, salt, projectId: profile.projectId });
|
|
45642
|
+
if (reverse.size === 0) return { reanchored: false, reason: "no-local-symbols" };
|
|
45643
|
+
try {
|
|
45644
|
+
const res = await cloud.getProjectPriors(profile.projectId, opts.limit ?? DEFAULT_LIMIT2);
|
|
45645
|
+
const now = Date.now();
|
|
45646
|
+
let anchors = 0;
|
|
45647
|
+
let dropped = 0;
|
|
45648
|
+
for (const a of res.anchorEdges) {
|
|
45649
|
+
const localTo = reverse.get(a.toSymbolId);
|
|
45650
|
+
if (!localTo) {
|
|
45651
|
+
dropped++;
|
|
45652
|
+
continue;
|
|
45653
|
+
}
|
|
45654
|
+
if (!store.getNode(a.from)) {
|
|
45655
|
+
dropped++;
|
|
45656
|
+
continue;
|
|
45657
|
+
}
|
|
45658
|
+
const id = edgeId(a.from, "ANCHORED_AT", localTo);
|
|
45659
|
+
if (store.getEdge(id)) continue;
|
|
45660
|
+
const edge2 = {
|
|
45661
|
+
id,
|
|
45662
|
+
from: a.from,
|
|
45663
|
+
to: localTo,
|
|
45664
|
+
type: "ANCHORED_AT",
|
|
45665
|
+
confidence: typeof a.attrs["confidence"] === "number" ? Math.max(0, Math.min(1, a.attrs["confidence"])) : 0.5,
|
|
45666
|
+
extractionSource: "agent-observed",
|
|
45667
|
+
createdAt: now,
|
|
45668
|
+
lastSeenAt: now,
|
|
45669
|
+
navSuccesses: 0,
|
|
45670
|
+
navFailures: 0,
|
|
45671
|
+
// Tagged `source: 'cloud'` (C7 — never re-shipped outward). GUARDRAIL 2 holds
|
|
45672
|
+
// by construction: we merge the EDGE onto the LOCAL node id, never the `sym_`
|
|
45673
|
+
// Symbol node — that stayed a translation key and never enters the store.
|
|
45674
|
+
attrs: { ...a.attrs, source: "cloud" }
|
|
45675
|
+
};
|
|
45676
|
+
store.mergeEdge(edge2);
|
|
45677
|
+
anchors++;
|
|
45678
|
+
}
|
|
45679
|
+
profile.projectReanchoredAt = Date.now();
|
|
45680
|
+
saveProfile(root, profile);
|
|
45681
|
+
return { reanchored: true, anchors, dropped };
|
|
45682
|
+
} catch (err2) {
|
|
45683
|
+
return {
|
|
45684
|
+
reanchored: false,
|
|
45685
|
+
reason: "error",
|
|
45686
|
+
detail: err2 instanceof Error ? err2.message : String(err2)
|
|
45687
|
+
};
|
|
45688
|
+
}
|
|
45689
|
+
}
|
|
45690
|
+
|
|
45585
45691
|
// src/adopt.ts
|
|
45586
45692
|
import { existsSync as existsSync22 } from "node:fs";
|
|
45587
45693
|
import { dirname as dirname8, join as join25 } from "node:path";
|
|
@@ -46037,6 +46143,27 @@ async function startMultiDaemon(opts = {}) {
|
|
|
46037
46143
|
} else if (hyd.reason === "error") {
|
|
46038
46144
|
console.warn(`[errata] project prime failed for ${r.engine.profile.name}: ${hyd.detail}`);
|
|
46039
46145
|
}
|
|
46146
|
+
if (r.engine.profile.projectId) {
|
|
46147
|
+
try {
|
|
46148
|
+
const { salt } = await resolveProjectSymbolSalt(client, r.engine.profile.projectId);
|
|
46149
|
+
const re = await reanchorProject({
|
|
46150
|
+
root: r.root,
|
|
46151
|
+
profile: r.engine.profile,
|
|
46152
|
+
store: r.engine.store,
|
|
46153
|
+
cloud: client,
|
|
46154
|
+
salt
|
|
46155
|
+
});
|
|
46156
|
+
if (re.reanchored) {
|
|
46157
|
+
r.engine.markContextDirty();
|
|
46158
|
+
console.log(
|
|
46159
|
+
`[errata] reanchored ${r.engine.profile.name} \u2014 ${re.anchors} anchors onto local code (${re.dropped} unresolved, dropped)`
|
|
46160
|
+
);
|
|
46161
|
+
} else if (re.reason === "error") {
|
|
46162
|
+
console.warn(`[errata] project reanchor failed for ${r.engine.profile.name}: ${re.detail}`);
|
|
46163
|
+
}
|
|
46164
|
+
} catch {
|
|
46165
|
+
}
|
|
46166
|
+
}
|
|
46040
46167
|
}
|
|
46041
46168
|
};
|
|
46042
46169
|
void ambientLinkAll();
|
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -15210,6 +15210,13 @@ var init_project_symbol = __esm({
|
|
|
15210
15210
|
}
|
|
15211
15211
|
});
|
|
15212
15212
|
|
|
15213
|
+
// ../../packages/shared/src/lockfile.ts
|
|
15214
|
+
var init_lockfile = __esm({
|
|
15215
|
+
"../../packages/shared/src/lockfile.ts"() {
|
|
15216
|
+
"use strict";
|
|
15217
|
+
}
|
|
15218
|
+
});
|
|
15219
|
+
|
|
15213
15220
|
// ../../packages/shared/src/nlp/canonicalize.ts
|
|
15214
15221
|
var init_canonicalize = __esm({
|
|
15215
15222
|
"../../packages/shared/src/nlp/canonicalize.ts"() {
|
|
@@ -15236,6 +15243,7 @@ var init_src = __esm({
|
|
|
15236
15243
|
init_symbol_intent();
|
|
15237
15244
|
init_repo_locator();
|
|
15238
15245
|
init_project_symbol();
|
|
15246
|
+
init_lockfile();
|
|
15239
15247
|
init_hash();
|
|
15240
15248
|
init_error_signature();
|
|
15241
15249
|
init_canonicalize();
|