@inerrata-corporation/errata 2.0.6-dev.2029 → 2.0.6-dev.2063
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 +82 -44
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -77047,7 +77047,7 @@ function createWatchBreaker(deps) {
|
|
|
77047
77047
|
}
|
|
77048
77048
|
|
|
77049
77049
|
// src/engine.ts
|
|
77050
|
-
var DAEMON_VERSION = true ? "2.0.6-dev.
|
|
77050
|
+
var DAEMON_VERSION = true ? "2.0.6-dev.2063" : "2.0.0-alpha.0";
|
|
77051
77051
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
77052
77052
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
77053
77053
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -80487,42 +80487,12 @@ async function ensureProjectLink(root, profile, client) {
|
|
|
80487
80487
|
}
|
|
80488
80488
|
|
|
80489
80489
|
// src/project-hydrate.ts
|
|
80490
|
-
|
|
80491
|
-
async function hydrateProject(opts) {
|
|
80492
|
-
const { root, profile, store, cloud } = opts;
|
|
80493
|
-
if (!profile.projectId) return { hydrated: false, reason: "no-project" };
|
|
80494
|
-
if (profile.projectHydratedAt) return { hydrated: false, reason: "already-hydrated" };
|
|
80495
|
-
try {
|
|
80496
|
-
const res = await cloud.getProjectPriors(profile.projectId, opts.limit ?? DEFAULT_LIMIT);
|
|
80497
|
-
let landedNodes = 0;
|
|
80498
|
-
for (const n of res.nodes) {
|
|
80499
|
-
if (store.getNode(n.id)) continue;
|
|
80500
|
-
store.mergeNode(n);
|
|
80501
|
-
landedNodes++;
|
|
80502
|
-
}
|
|
80503
|
-
let landedEdges = 0;
|
|
80504
|
-
for (const e of res.edges) {
|
|
80505
|
-
if (!store.getNode(e.from) || !store.getNode(e.to)) continue;
|
|
80506
|
-
if (store.getEdge(e.id)) continue;
|
|
80507
|
-
store.mergeEdge(e);
|
|
80508
|
-
landedEdges++;
|
|
80509
|
-
}
|
|
80510
|
-
profile.projectHydratedAt = Date.now();
|
|
80511
|
-
saveProfile(root, profile);
|
|
80512
|
-
return { hydrated: true, nodes: landedNodes, edges: landedEdges };
|
|
80513
|
-
} catch (err2) {
|
|
80514
|
-
return {
|
|
80515
|
-
hydrated: false,
|
|
80516
|
-
reason: "error",
|
|
80517
|
-
detail: err2 instanceof Error ? err2.message : String(err2)
|
|
80518
|
-
};
|
|
80519
|
-
}
|
|
80520
|
-
}
|
|
80490
|
+
init_src11();
|
|
80521
80491
|
|
|
80522
80492
|
// src/project-reanchor.ts
|
|
80523
80493
|
init_src();
|
|
80524
80494
|
init_src11();
|
|
80525
|
-
var
|
|
80495
|
+
var DEFAULT_LIMIT = 50;
|
|
80526
80496
|
var ANCHOR_SYMBOL_KINDS = [
|
|
80527
80497
|
"Function",
|
|
80528
80498
|
"Class",
|
|
@@ -80556,6 +80526,10 @@ function buildReverseSymbolMap(opts) {
|
|
|
80556
80526
|
}
|
|
80557
80527
|
return reverse;
|
|
80558
80528
|
}
|
|
80529
|
+
function anchorConfidence(attrs) {
|
|
80530
|
+
const v = typeof attrs["extractionConfidence"] === "number" ? attrs["extractionConfidence"] : attrs["confidence"];
|
|
80531
|
+
return typeof v === "number" && Number.isFinite(v) ? Math.max(0, Math.min(1, v)) : null;
|
|
80532
|
+
}
|
|
80559
80533
|
var ANCHOR_SOURCE_KINDS = [
|
|
80560
80534
|
"Problem",
|
|
80561
80535
|
"Solution",
|
|
@@ -80635,7 +80609,7 @@ async function reanchorProject(opts) {
|
|
|
80635
80609
|
const reverse = buildReverseSymbolMap({ store, salt, projectId: profile.projectId });
|
|
80636
80610
|
if (reverse.size === 0) return { reanchored: false, reason: "no-local-symbols" };
|
|
80637
80611
|
try {
|
|
80638
|
-
const res = await cloud.getProjectPriors(profile.projectId, opts.limit ??
|
|
80612
|
+
const res = await cloud.getProjectPriors(profile.projectId, opts.limit ?? DEFAULT_LIMIT);
|
|
80639
80613
|
const now = Date.now();
|
|
80640
80614
|
const own = lazy2(() => buildOwnKnowledgeMap({ store, salt }));
|
|
80641
80615
|
let anchors = 0;
|
|
@@ -80658,7 +80632,7 @@ async function reanchorProject(opts) {
|
|
|
80658
80632
|
from,
|
|
80659
80633
|
to: localTo,
|
|
80660
80634
|
type: "ANCHORED_AT",
|
|
80661
|
-
confidence:
|
|
80635
|
+
confidence: anchorConfidence(a.attrs) ?? 0.5,
|
|
80662
80636
|
extractionSource: "agent-observed",
|
|
80663
80637
|
createdAt: now,
|
|
80664
80638
|
lastSeenAt: now,
|
|
@@ -80739,7 +80713,7 @@ async function syncProjectAnchors(opts) {
|
|
|
80739
80713
|
from,
|
|
80740
80714
|
to: localTo,
|
|
80741
80715
|
type: "ANCHORED_AT",
|
|
80742
|
-
confidence:
|
|
80716
|
+
confidence: anchorConfidence(a.attrs) ?? existing?.confidence ?? 0.5,
|
|
80743
80717
|
extractionSource: "agent-observed",
|
|
80744
80718
|
createdAt: existing?.createdAt ?? now,
|
|
80745
80719
|
lastSeenAt: now,
|
|
@@ -80770,6 +80744,50 @@ async function syncProjectAnchors(opts) {
|
|
|
80770
80744
|
}
|
|
80771
80745
|
}
|
|
80772
80746
|
|
|
80747
|
+
// src/project-hydrate.ts
|
|
80748
|
+
var DEFAULT_LIMIT2 = 50;
|
|
80749
|
+
async function hydrateProject(opts) {
|
|
80750
|
+
const { root, profile, store, cloud, salt } = opts;
|
|
80751
|
+
if (!profile.projectId) return { hydrated: false, reason: "no-project" };
|
|
80752
|
+
if (profile.projectHydratedAt) return { hydrated: false, reason: "already-hydrated" };
|
|
80753
|
+
try {
|
|
80754
|
+
const res = await cloud.getProjectPriors(profile.projectId, opts.limit ?? DEFAULT_LIMIT2);
|
|
80755
|
+
const own = buildOwnKnowledgeMap({ store, salt });
|
|
80756
|
+
const localId = (id) => store.getNode(id) ? id : own.get(id) ?? null;
|
|
80757
|
+
let landedNodes = 0;
|
|
80758
|
+
let ownNodes = 0;
|
|
80759
|
+
for (const n of res.nodes) {
|
|
80760
|
+
if (store.getNode(n.id)) continue;
|
|
80761
|
+
if (own.has(n.id)) {
|
|
80762
|
+
ownNodes++;
|
|
80763
|
+
continue;
|
|
80764
|
+
}
|
|
80765
|
+
store.mergeNode(n);
|
|
80766
|
+
landedNodes++;
|
|
80767
|
+
}
|
|
80768
|
+
let landedEdges = 0;
|
|
80769
|
+
for (const e of res.edges) {
|
|
80770
|
+
const from = localId(e.from);
|
|
80771
|
+
const to = localId(e.to);
|
|
80772
|
+
if (!from || !to) continue;
|
|
80773
|
+
if (store.outEdges(from, [e.type]).some((x) => x.to === to)) continue;
|
|
80774
|
+
const id = from === e.from && to === e.to ? e.id : edgeId(from, e.type, to);
|
|
80775
|
+
if (store.getEdge(id)) continue;
|
|
80776
|
+
store.mergeEdge({ ...e, id, from, to });
|
|
80777
|
+
landedEdges++;
|
|
80778
|
+
}
|
|
80779
|
+
profile.projectHydratedAt = Date.now();
|
|
80780
|
+
saveProfile(root, profile);
|
|
80781
|
+
return { hydrated: true, nodes: landedNodes, edges: landedEdges, own: ownNodes };
|
|
80782
|
+
} catch (err2) {
|
|
80783
|
+
return {
|
|
80784
|
+
hydrated: false,
|
|
80785
|
+
reason: "error",
|
|
80786
|
+
detail: err2 instanceof Error ? err2.message : String(err2)
|
|
80787
|
+
};
|
|
80788
|
+
}
|
|
80789
|
+
}
|
|
80790
|
+
|
|
80773
80791
|
// src/project-history.ts
|
|
80774
80792
|
init_src7();
|
|
80775
80793
|
init_src();
|
|
@@ -82225,6 +82243,7 @@ async function spineForUnit(git3, root, unit) {
|
|
|
82225
82243
|
const wire = (d) => ({ ecosystem: d.ecosystem, name: d.name, version: d.version, kind: d.kind, manifest: d.manifest });
|
|
82226
82244
|
return { declared: rings.declared.map(wire), context: rings.context.map(wire) };
|
|
82227
82245
|
}
|
|
82246
|
+
var HEX_BODY_HASH = /^[0-9a-f]{8,64}$/;
|
|
82228
82247
|
function anchorsFor(pathTokens, ignoreLines, projectId, anchors) {
|
|
82229
82248
|
if (!anchors) return void 0;
|
|
82230
82249
|
const out2 = {};
|
|
@@ -82236,7 +82255,12 @@ function anchorsFor(pathTokens, ignoreLines, projectId, anchors) {
|
|
|
82236
82255
|
for (const n of nodes) {
|
|
82237
82256
|
const qname = n.attrs["qname"];
|
|
82238
82257
|
if (typeof qname !== "string") continue;
|
|
82239
|
-
|
|
82258
|
+
const bodyHash = n.attrs["bodyHash"];
|
|
82259
|
+
list.push({
|
|
82260
|
+
symbolId: projectSymbolId(anchors.salt, projectId, relPath, qname, n.label),
|
|
82261
|
+
kind: n.label,
|
|
82262
|
+
...typeof bodyHash === "string" && HEX_BODY_HASH.test(bodyHash) ? { contentHash: bodyHash } : {}
|
|
82263
|
+
});
|
|
82240
82264
|
if (list.length >= MAX_ANCHORS_PER_TOKEN) break;
|
|
82241
82265
|
}
|
|
82242
82266
|
if (list.length > 0) out2[token] = list;
|
|
@@ -82344,7 +82368,10 @@ async function runHistoryWalk(root, input, client, opts = {}) {
|
|
|
82344
82368
|
const spine = await spineForUnit(git3, root, u);
|
|
82345
82369
|
if (spine) body2.spine = spine;
|
|
82346
82370
|
const anchors = anchorsFor(bundle.pathTokens, ignoreLines, projectId, opts.anchors);
|
|
82347
|
-
if (anchors)
|
|
82371
|
+
if (anchors) {
|
|
82372
|
+
body2.anchors = anchors;
|
|
82373
|
+
body2.observedAtCommit = headSha;
|
|
82374
|
+
}
|
|
82348
82375
|
profile = stage(profile, { state: dryRun ? "extracting" : "contributing", unitsDone: doneSoFar - 1, lastError: void 0 }, now);
|
|
82349
82376
|
persist(profile);
|
|
82350
82377
|
response = await reportHistoryStage(client, profile, log);
|
|
@@ -83809,18 +83836,29 @@ async function startMultiDaemon(opts = {}) {
|
|
|
83809
83836
|
} else if (out2.reason === "error") {
|
|
83810
83837
|
console.warn(`[errata] project link failed for ${r.engine.profile.name}: ${out2.detail}`);
|
|
83811
83838
|
}
|
|
83812
|
-
|
|
83839
|
+
let primeSalt = null;
|
|
83840
|
+
if (r.engine.profile.projectId && !r.engine.profile.projectHydratedAt) {
|
|
83841
|
+
try {
|
|
83842
|
+
primeSalt = (await resolveProjectSymbolSalt(client, r.engine.profile.projectId)).salt;
|
|
83843
|
+
} catch (err2) {
|
|
83844
|
+
console.warn(
|
|
83845
|
+
`[errata] project prime deferred for ${r.engine.profile.name}: salt unavailable (${err2 instanceof Error ? err2.message : String(err2)})`
|
|
83846
|
+
);
|
|
83847
|
+
}
|
|
83848
|
+
}
|
|
83849
|
+
const hyd = primeSalt ? await hydrateProject({
|
|
83813
83850
|
root: r.root,
|
|
83814
83851
|
profile: r.engine.profile,
|
|
83815
83852
|
store: r.engine.store,
|
|
83816
|
-
cloud: client
|
|
83817
|
-
|
|
83818
|
-
|
|
83853
|
+
cloud: client,
|
|
83854
|
+
salt: primeSalt
|
|
83855
|
+
}) : null;
|
|
83856
|
+
if (hyd?.hydrated) {
|
|
83819
83857
|
r.engine.markContextDirty();
|
|
83820
83858
|
console.log(
|
|
83821
|
-
`[errata] primed ${r.engine.profile.name} from project \u2014 ${hyd.nodes} priors, ${hyd.edges} links`
|
|
83859
|
+
`[errata] primed ${r.engine.profile.name} from project \u2014 ${hyd.nodes} priors, ${hyd.edges} links (${hyd.own} already this checkout's own)`
|
|
83822
83860
|
);
|
|
83823
|
-
} else if (hyd.reason === "error") {
|
|
83861
|
+
} else if (hyd && !hyd.hydrated && hyd.reason === "error") {
|
|
83824
83862
|
console.warn(`[errata] project prime failed for ${r.engine.profile.name}: ${hyd.detail}`);
|
|
83825
83863
|
}
|
|
83826
83864
|
if (r.engine.profile.projectId) {
|