@inerrata-corporation/errata 2.0.1-dev.52 → 2.0.1-dev.60
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 +83 -6
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -21871,6 +21871,7 @@ var init_client = __esm({
|
|
|
21871
21871
|
}
|
|
21872
21872
|
const merged = { runId, nodes: [], edges: [] };
|
|
21873
21873
|
let pendingEdges = [...batch.edges];
|
|
21874
|
+
const echoedCloudId = /* @__PURE__ */ new Map();
|
|
21874
21875
|
for (const nodeChunk of chunkArray(batch.nodes, INGEST_NODE_CHUNK)) {
|
|
21875
21876
|
const ids = new Set(nodeChunk.map((n) => n.id));
|
|
21876
21877
|
const inChunk = pendingEdges.filter((e) => ids.has(e.from) && ids.has(e.to)).slice(0, MAX_EDGES_PER_PAYLOAD);
|
|
@@ -21881,12 +21882,20 @@ var init_client = __esm({
|
|
|
21881
21882
|
const r = await this.ingestWire(toWirePayload({ ...batch, nodes: nodeChunk, edges: inChunk }, randomUUID()));
|
|
21882
21883
|
merged.nodes.push(...r.nodes);
|
|
21883
21884
|
merged.edges.push(...r.edges);
|
|
21885
|
+
for (const rn of r.nodes) {
|
|
21886
|
+
if (rn.nodeId && rn.nodeId !== rn.canonicalId) echoedCloudId.set(rn.canonicalId, rn.nodeId);
|
|
21887
|
+
}
|
|
21884
21888
|
if (r.patternReconciliation) {
|
|
21885
21889
|
merged.patternReconciliation = { ...merged.patternReconciliation, ...r.patternReconciliation };
|
|
21886
21890
|
}
|
|
21887
21891
|
}
|
|
21888
21892
|
for (const edgeChunk of chunkArray(pendingEdges, MAX_EDGES_PER_PAYLOAD)) {
|
|
21889
|
-
const
|
|
21893
|
+
const rewritten = edgeChunk.map((e) => ({
|
|
21894
|
+
...e,
|
|
21895
|
+
from: echoedCloudId.get(e.from) ?? e.from,
|
|
21896
|
+
to: echoedCloudId.get(e.to) ?? e.to
|
|
21897
|
+
}));
|
|
21898
|
+
const r = await this.ingestWire(toWirePayload({ ...batch, nodes: [], edges: rewritten }, randomUUID()));
|
|
21890
21899
|
merged.edges.push(...r.edges);
|
|
21891
21900
|
}
|
|
21892
21901
|
return { ...summarizeIngestResult(merged), result: merged };
|
|
@@ -51655,7 +51664,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
51655
51664
|
}
|
|
51656
51665
|
|
|
51657
51666
|
// src/engine.ts
|
|
51658
|
-
var DAEMON_VERSION = true ? "2.0.1-dev.
|
|
51667
|
+
var DAEMON_VERSION = true ? "2.0.1-dev.60" : "2.0.0-alpha.0";
|
|
51659
51668
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
51660
51669
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
51661
51670
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -53435,10 +53444,13 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
53435
53444
|
}
|
|
53436
53445
|
if (targets.length === 0) continue;
|
|
53437
53446
|
const dg = digest(targets.map(({ e, wireId }) => `${e.type}>${wireId}`).sort());
|
|
53438
|
-
|
|
53447
|
+
const sourceNode = store.getNode(sourceId);
|
|
53448
|
+
if (sourceNode?.attrs["anchorsContributedDigest"] === dg) continue;
|
|
53439
53449
|
anchorDigests[sourceId] = dg;
|
|
53450
|
+
const skippedCloudId = !seen.has(sourceId) ? sourceNode?.attrs["cloudNodeId"] : void 0;
|
|
53451
|
+
const wireFrom = typeof skippedCloudId === "string" && skippedCloudId.length > 0 ? skippedCloudId : sourceId;
|
|
53440
53452
|
for (const { e, t, wireId } of targets) {
|
|
53441
|
-
anchorEdges.push({ ...e, to: wireId, attrs: {} });
|
|
53453
|
+
anchorEdges.push({ ...e, from: wireFrom, to: wireId, attrs: {} });
|
|
53442
53454
|
if (t.attrs["source"] === "cloud" || contextSeen.has(wireId)) continue;
|
|
53443
53455
|
contextSeen.add(wireId);
|
|
53444
53456
|
contextNodes.push(shareableContext(t, wireId));
|
|
@@ -53450,6 +53462,8 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
53450
53462
|
for (const sourceId of anchorSources) {
|
|
53451
53463
|
const source = store.getNode(sourceId);
|
|
53452
53464
|
if (!source) continue;
|
|
53465
|
+
const skippedCloudId = !seen.has(sourceId) ? source.attrs["cloudNodeId"] : void 0;
|
|
53466
|
+
const wireFrom = typeof skippedCloudId === "string" && skippedCloudId.length > 0 ? skippedCloudId : sourceId;
|
|
53453
53467
|
for (const e of store.outEdges(sourceId, ["ANCHORED_AT"])) {
|
|
53454
53468
|
const target = store.getNode(e.to);
|
|
53455
53469
|
if (!target) continue;
|
|
@@ -53484,7 +53498,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
53484
53498
|
stability: "unstable"
|
|
53485
53499
|
});
|
|
53486
53500
|
}
|
|
53487
|
-
anchorEdges.push({ ...e, to: symId, attrs: {} });
|
|
53501
|
+
anchorEdges.push({ ...e, from: wireFrom, to: symId, attrs: {} });
|
|
53488
53502
|
}
|
|
53489
53503
|
}
|
|
53490
53504
|
}
|
|
@@ -53532,6 +53546,46 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
53532
53546
|
return { ...base, payloadDigest: digest(base), anchorDigests };
|
|
53533
53547
|
}
|
|
53534
53548
|
|
|
53549
|
+
// src/backfill-edges.ts
|
|
53550
|
+
init_src();
|
|
53551
|
+
init_src2();
|
|
53552
|
+
var CAUSAL_LABELS = ["Problem", "Solution", "RootCause"];
|
|
53553
|
+
var CAUSAL_EDGES2 = ["SOLVED_BY", "CAUSED_BY", "FIXED_BY"];
|
|
53554
|
+
function cloudWireId(store, id) {
|
|
53555
|
+
const n = store.getNode(id);
|
|
53556
|
+
if (!n || !CAUSAL_LABELS.includes(n.label)) return null;
|
|
53557
|
+
if (n.label === "Problem" && n.attrs["resolvedAs"] === PROBLEM_RESOLUTION.FALSE_POSITIVE) return null;
|
|
53558
|
+
const cloudNodeId = n.attrs["cloudNodeId"];
|
|
53559
|
+
if (typeof cloudNodeId === "string" && cloudNodeId.length > 0) return cloudNodeId;
|
|
53560
|
+
if (n.attrs["source"] === "cloud") return n.id;
|
|
53561
|
+
return typeof n.attrs["contributedAtSeq"] === "number" ? n.id : null;
|
|
53562
|
+
}
|
|
53563
|
+
function buildCausalEdgeBackfill(store, profile, daemonVersion) {
|
|
53564
|
+
const edges = [];
|
|
53565
|
+
const seenEdge = /* @__PURE__ */ new Set();
|
|
53566
|
+
for (const label of CAUSAL_LABELS) {
|
|
53567
|
+
for (const n of store.findNodesByLabel(label)) {
|
|
53568
|
+
for (const e of store.outEdges(n.id, [...CAUSAL_EDGES2])) {
|
|
53569
|
+
if (seenEdge.has(e.id)) continue;
|
|
53570
|
+
seenEdge.add(e.id);
|
|
53571
|
+
const from = cloudWireId(store, e.from);
|
|
53572
|
+
const to = cloudWireId(store, e.to);
|
|
53573
|
+
if (!from || !to) continue;
|
|
53574
|
+
edges.push({ ...e, from, to, attrs: {} });
|
|
53575
|
+
}
|
|
53576
|
+
}
|
|
53577
|
+
}
|
|
53578
|
+
if (edges.length === 0) return null;
|
|
53579
|
+
const base = {
|
|
53580
|
+
daemonVersion,
|
|
53581
|
+
profile: { stack: profile.stack, languages: profile.languages, domains: profile.domains },
|
|
53582
|
+
originProject: profile.id,
|
|
53583
|
+
nodes: [],
|
|
53584
|
+
edges
|
|
53585
|
+
};
|
|
53586
|
+
return { ...base, payloadDigest: digest(base) };
|
|
53587
|
+
}
|
|
53588
|
+
|
|
53535
53589
|
// src/multi.ts
|
|
53536
53590
|
init_generalize_graph();
|
|
53537
53591
|
init_symbol_summaries();
|
|
@@ -54617,6 +54671,28 @@ async function startMultiDaemon(opts = {}) {
|
|
|
54617
54671
|
}
|
|
54618
54672
|
return { uploaded, ...errors.length > 0 ? { errors } : {} };
|
|
54619
54673
|
},
|
|
54674
|
+
async backfillCausalEdges() {
|
|
54675
|
+
if (!loadConfig().consent.sync) return { accepted: 0, rejected: 0, skipped: "consent-off" };
|
|
54676
|
+
const client = cloudNow();
|
|
54677
|
+
let accepted = 0;
|
|
54678
|
+
let rejected = 0;
|
|
54679
|
+
const errors = [];
|
|
54680
|
+
for (const r of records) {
|
|
54681
|
+
const payload = buildCausalEdgeBackfill(r.engine.store, r.engine.profile, DAEMON_VERSION);
|
|
54682
|
+
if (!payload) continue;
|
|
54683
|
+
try {
|
|
54684
|
+
const res = await client.ingest(payload);
|
|
54685
|
+
accepted += res.accepted;
|
|
54686
|
+
rejected += res.rejected;
|
|
54687
|
+
if (res.rejected > 0) errors.push(...res.violations.slice(0, 5));
|
|
54688
|
+
} catch (err2) {
|
|
54689
|
+
errors.push(
|
|
54690
|
+
`[${r.engine.profile.name ?? r.engine.profile.id}] backfill: ${err2 instanceof Error ? err2.message : String(err2)}`
|
|
54691
|
+
);
|
|
54692
|
+
}
|
|
54693
|
+
}
|
|
54694
|
+
return { accepted, rejected, ...errors.length > 0 ? { errors } : {} };
|
|
54695
|
+
},
|
|
54620
54696
|
async pullTriagePublic() {
|
|
54621
54697
|
if (!loadConfig().consent.sync) return { merged: 0, skipped: "consent-off" };
|
|
54622
54698
|
const stack = /* @__PURE__ */ new Set();
|
|
@@ -54701,7 +54777,8 @@ async function startMultiDaemon(opts = {}) {
|
|
|
54701
54777
|
const principles = await daemon.syncPrinciplesPublic();
|
|
54702
54778
|
const triage = await daemon.syncTriagePublic();
|
|
54703
54779
|
const instances = await daemon.syncInstancesPublic();
|
|
54704
|
-
|
|
54780
|
+
const edgeBackfill = await daemon.backfillCausalEdges();
|
|
54781
|
+
return c.json({ principles, triage, instances, edgeBackfill });
|
|
54705
54782
|
} catch (err2) {
|
|
54706
54783
|
return c.json({ error: err2 instanceof Error ? err2.message : String(err2) }, 500);
|
|
54707
54784
|
}
|