@inerrata-corporation/errata 2.0.0-dev.82 → 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/errata.mjs +115 -2
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -21604,7 +21604,14 @@ var init_client = __esm({
|
|
|
21604
21604
|
"GET",
|
|
21605
21605
|
`/v2/projects/${encodeURIComponent(projectId)}/priors?limit=${String(limit)}`
|
|
21606
21606
|
);
|
|
21607
|
-
|
|
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 ?? [] };
|
|
21608
21615
|
}
|
|
21609
21616
|
/** Pull cloud-induced skills + the session-bootstrap prime payload. `seed` is the
|
|
21610
21617
|
* canonical ids of the agent's recent problems — the cloud ranks the skills whose
|
|
@@ -43522,7 +43529,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
43522
43529
|
}
|
|
43523
43530
|
|
|
43524
43531
|
// src/engine.ts
|
|
43525
|
-
var DAEMON_VERSION = true ? "2.0.0-dev.
|
|
43532
|
+
var DAEMON_VERSION = true ? "2.0.0-dev.83" : "2.0.0-alpha.0";
|
|
43526
43533
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
43527
43534
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
43528
43535
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -45596,6 +45603,91 @@ async function hydrateProject(opts) {
|
|
|
45596
45603
|
}
|
|
45597
45604
|
}
|
|
45598
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
|
+
|
|
45599
45691
|
// src/adopt.ts
|
|
45600
45692
|
import { existsSync as existsSync22 } from "node:fs";
|
|
45601
45693
|
import { dirname as dirname8, join as join25 } from "node:path";
|
|
@@ -46051,6 +46143,27 @@ async function startMultiDaemon(opts = {}) {
|
|
|
46051
46143
|
} else if (hyd.reason === "error") {
|
|
46052
46144
|
console.warn(`[errata] project prime failed for ${r.engine.profile.name}: ${hyd.detail}`);
|
|
46053
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
|
+
}
|
|
46054
46167
|
}
|
|
46055
46168
|
};
|
|
46056
46169
|
void ambientLinkAll();
|