@inerrata-corporation/errata 2.0.8 → 2.0.10
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 +84 -13
- package/errata.mjs +380 -125
- package/package.json +1 -1
- package/pass-worker.mjs +46 -1
package/consolidate-worker.mjs
CHANGED
|
@@ -15351,7 +15351,7 @@ function anchorLabelAttrs(attrs) {
|
|
|
15351
15351
|
...typeof line === "number" && Number.isInteger(line) && line >= 1 && line <= 1e7 ? { labelLine: line } : {}
|
|
15352
15352
|
};
|
|
15353
15353
|
}
|
|
15354
|
-
var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, FILE_ANCHOR_QNAME, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
|
|
15354
|
+
var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, FILE_ANCHOR_QNAME, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, TRIAGE_DISCRIMINATOR_MAX_LENGTH, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
|
|
15355
15355
|
var init_wire = __esm({
|
|
15356
15356
|
"../../packages/shared/src/wire.ts"() {
|
|
15357
15357
|
"use strict";
|
|
@@ -15470,6 +15470,7 @@ var init_wire = __esm({
|
|
|
15470
15470
|
FILE_ANCHOR_QNAME = "";
|
|
15471
15471
|
ANCHOR_LABEL_PATH_RE = /^(?![/])(?![A-Za-z]:)(?!(?:.*\/)?\.\.(?:\/|$))[^\x00-\x1f\x7f\\`]{1,512}$/;
|
|
15472
15472
|
ANCHOR_LABEL_QNAME_RE = /^[^\x00-\x1f\x7f`]{1,256}$/;
|
|
15473
|
+
TRIAGE_DISCRIMINATOR_MAX_LENGTH = 2e3;
|
|
15473
15474
|
CastaliaIngestEdgeSchema = external_exports.object({
|
|
15474
15475
|
fromCanonicalId: external_exports.string().min(6).max(160),
|
|
15475
15476
|
toCanonicalId: external_exports.string().min(6).max(160),
|
|
@@ -15480,6 +15481,8 @@ var init_wire = __esm({
|
|
|
15480
15481
|
/** Triage route per-context counts (T3 induction). Carried as structured data
|
|
15481
15482
|
* here; stored JSON-encoded on the Neo4j rel (`perContextJson`). */
|
|
15482
15483
|
perContext: external_exports.record(external_exports.string(), RouteContextCountWireSchema).optional(),
|
|
15484
|
+
/** Scrubbed diagnostic check for a triage route, re-scanned at the cloud door. */
|
|
15485
|
+
discriminator: external_exports.string().trim().min(1).max(TRIAGE_DISCRIMINATOR_MAX_LENGTH).optional(),
|
|
15483
15486
|
/** PJ-anchor-version: WHICH version of a symbol an `ANCHORED_AT` was
|
|
15484
15487
|
* witnessed against. Both opaque — the observing checkout's HEAD sha and
|
|
15485
15488
|
* the indexer's 16-hex sha256 of the symbol body. Neither is reversible
|
|
@@ -16137,6 +16140,12 @@ CREATE UNIQUE INDEX IF NOT EXISTS edges_triple ON edges(from_id, type, to_id);
|
|
|
16137
16140
|
`;
|
|
16138
16141
|
var TEMPORAL_INDEX_SQL = `
|
|
16139
16142
|
CREATE INDEX IF NOT EXISTS nodes_live ON nodes(label, valid_to);
|
|
16143
|
+
-- Covering + partial index for labelFingerprint over the instance labels: the
|
|
16144
|
+
-- live-push probe runs it per workspace on a timer, and each hit used to read
|
|
16145
|
+
-- its table row. Partial, so it maintains a few thousand rows instead of adding
|
|
16146
|
+
-- a write to every node write. Its label list is FINGERPRINT_INDEXED_LABELS.
|
|
16147
|
+
DROP INDEX IF EXISTS nodes_live_fingerprint;
|
|
16148
|
+
CREATE INDEX IF NOT EXISTS nodes_instance_fingerprint ON nodes(label, last_updated_at, last_reinforced_at_seq, created_at_seq) WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause');
|
|
16140
16149
|
CREATE INDEX IF NOT EXISTS nodes_logical ON nodes(logical_id, version);
|
|
16141
16150
|
CREATE INDEX IF NOT EXISTS edges_live ON edges(valid_to);
|
|
16142
16151
|
-- Expression index on the per-node relPath (stored in attrs_json) so the
|
|
@@ -16207,6 +16216,7 @@ function rowToEdge(r) {
|
|
|
16207
16216
|
attrs: JSON.parse(r.attrs_json)
|
|
16208
16217
|
};
|
|
16209
16218
|
}
|
|
16219
|
+
var FINGERPRINT_INDEXED_LABELS = ["Problem", "Solution", "RootCause"];
|
|
16210
16220
|
var SqliteGraphStore = class {
|
|
16211
16221
|
db;
|
|
16212
16222
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -16683,6 +16693,32 @@ var SqliteGraphStore = class {
|
|
|
16683
16693
|
attrs: JSON.parse(r.attrs_json)
|
|
16684
16694
|
}));
|
|
16685
16695
|
}
|
|
16696
|
+
*iterateNodeIdentitiesByLabel(label, pageSize = 2e3) {
|
|
16697
|
+
const page = this.db.prepare(
|
|
16698
|
+
"SELECT rowid AS rid, id, json_extract(attrs_json, '$.relPath') AS relPath, json_extract(attrs_json, '$.qname') AS qname FROM nodes WHERE rowid > ? AND label = ? AND valid_to IS NULL ORDER BY rowid LIMIT ?"
|
|
16699
|
+
);
|
|
16700
|
+
let after = 0;
|
|
16701
|
+
for (; ; ) {
|
|
16702
|
+
const rows = page.all(after, label, pageSize);
|
|
16703
|
+
for (const r of rows) {
|
|
16704
|
+
yield {
|
|
16705
|
+
id: r.id,
|
|
16706
|
+
relPath: typeof r.relPath === "string" ? r.relPath : null,
|
|
16707
|
+
qname: typeof r.qname === "string" ? r.qname : null
|
|
16708
|
+
};
|
|
16709
|
+
}
|
|
16710
|
+
if (rows.length < pageSize) return;
|
|
16711
|
+
after = rows[rows.length - 1].rid;
|
|
16712
|
+
}
|
|
16713
|
+
}
|
|
16714
|
+
recentNodeIds(label, limit) {
|
|
16715
|
+
const rows = this.db.prepare("SELECT id FROM nodes WHERE label = ? AND valid_to IS NULL ORDER BY last_updated_at DESC LIMIT ?").all(label, Math.max(0, limit));
|
|
16716
|
+
return rows.map((r) => r.id);
|
|
16717
|
+
}
|
|
16718
|
+
hasLiveNodes() {
|
|
16719
|
+
const r = this.db.prepare("SELECT EXISTS(SELECT 1 FROM nodes WHERE valid_to IS NULL) AS e").get();
|
|
16720
|
+
return r.e === 1;
|
|
16721
|
+
}
|
|
16686
16722
|
findNodeIdentitiesByLabel(label) {
|
|
16687
16723
|
const rows = this.stmts.identitiesByLabel.all(label);
|
|
16688
16724
|
return rows.map((r) => ({
|
|
@@ -16830,6 +16866,15 @@ var SqliteGraphStore = class {
|
|
|
16830
16866
|
}
|
|
16831
16867
|
labelFingerprint(labels) {
|
|
16832
16868
|
if (labels.length === 0) return "0";
|
|
16869
|
+
if (labels.length === FINGERPRINT_INDEXED_LABELS.length && FINGERPRINT_INDEXED_LABELS.every((l) => labels.includes(l))) {
|
|
16870
|
+
const r2 = this.db.prepare(
|
|
16871
|
+
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
16872
|
+
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
16873
|
+
FROM nodes INDEXED BY nodes_instance_fingerprint
|
|
16874
|
+
WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause')`
|
|
16875
|
+
).get();
|
|
16876
|
+
return `${r2.n}:${r2.t ?? 0}:${r2.s ?? 0}`;
|
|
16877
|
+
}
|
|
16833
16878
|
const r = this.db.prepare(
|
|
16834
16879
|
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
16835
16880
|
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
@@ -18174,6 +18219,15 @@ function generalize(text, opts = {}) {
|
|
|
18174
18219
|
// src/instance-ingest.ts
|
|
18175
18220
|
init_src();
|
|
18176
18221
|
|
|
18222
|
+
// src/instance-receipts.ts
|
|
18223
|
+
function receiptMap(attrs) {
|
|
18224
|
+
const value = attrs["instanceReceipts"];
|
|
18225
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
18226
|
+
}
|
|
18227
|
+
function instanceReceipt(n, destination) {
|
|
18228
|
+
return destination ? receiptMap(n.attrs)[destination] ?? {} : n.attrs;
|
|
18229
|
+
}
|
|
18230
|
+
|
|
18177
18231
|
// src/contribution-ready.ts
|
|
18178
18232
|
function cosine2(a, b) {
|
|
18179
18233
|
if (a.length === 0 || a.length !== b.length) return 0;
|
|
@@ -19043,8 +19097,8 @@ function stripCodebaseScope(scope) {
|
|
|
19043
19097
|
delete s["codebase"];
|
|
19044
19098
|
return s;
|
|
19045
19099
|
}
|
|
19046
|
-
function contributedWireId(n) {
|
|
19047
|
-
const cloudId = n
|
|
19100
|
+
function contributedWireId(n, destinationKey) {
|
|
19101
|
+
const cloudId = instanceReceipt(n, destinationKey)["cloudNodeId"];
|
|
19048
19102
|
return isMembraneSaltedId(cloudId) ? cloudId : n.id;
|
|
19049
19103
|
}
|
|
19050
19104
|
var WIRE_CANONICAL_ID_MIN = 6;
|
|
@@ -19188,10 +19242,26 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19188
19242
|
fileRefsSubstituted: 0,
|
|
19189
19243
|
fileRefLexiconMisses: 0
|
|
19190
19244
|
};
|
|
19245
|
+
const sharedCauses = /* @__PURE__ */ new Map();
|
|
19246
|
+
const causalQueue = store.findNodesByLabel("Problem").filter(
|
|
19247
|
+
(n) => n.attrs["source"] !== "cloud" && n.attrs["resolvedAs"] !== PROBLEM_RESOLUTION.FALSE_POSITIVE && !ignored(n.description)
|
|
19248
|
+
).map((n) => n.id);
|
|
19249
|
+
const causalSeen = new Set(causalQueue);
|
|
19250
|
+
for (let i = 0; i < causalQueue.length; i++) {
|
|
19251
|
+
const id = causalQueue[i];
|
|
19252
|
+
for (const e of [...store.outEdges(id, ["CAUSED_BY"]), ...opts.sharedStore?.outEdges(id, ["CAUSED_BY"]) ?? []]) {
|
|
19253
|
+
if (causalSeen.has(e.to)) continue;
|
|
19254
|
+
causalSeen.add(e.to);
|
|
19255
|
+
const cause = nodeOf(e.to);
|
|
19256
|
+
if (!cause || cause.label !== "RootCause" || cause.attrs["source"] === "cloud" || ignored(cause.description)) continue;
|
|
19257
|
+
sharedCauses.set(cause.id, cause);
|
|
19258
|
+
causalQueue.push(cause.id);
|
|
19259
|
+
}
|
|
19260
|
+
}
|
|
19191
19261
|
for (const label of INSTANCE_LABELS) {
|
|
19192
19262
|
const ref = [];
|
|
19193
19263
|
includedByLabel.set(label, ref);
|
|
19194
|
-
const population = label === "RootCause" && opts.sharedStore ? [...store.findNodesByLabel(label), ...
|
|
19264
|
+
const population = label === "RootCause" && opts.sharedStore ? [...store.findNodesByLabel(label), ...sharedCauses.values()] : store.findNodesByLabel(label);
|
|
19195
19265
|
for (const n of population) {
|
|
19196
19266
|
if (seen.has(n.id)) continue;
|
|
19197
19267
|
if (walked.has(n.id)) continue;
|
|
@@ -19209,18 +19279,18 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19209
19279
|
composition.ignored++;
|
|
19210
19280
|
continue;
|
|
19211
19281
|
}
|
|
19212
|
-
const contributedAtSeq = n.
|
|
19282
|
+
const contributedAtSeq = instanceReceipt(n, opts.destinationKey)["contributedAtSeq"];
|
|
19213
19283
|
if (typeof contributedAtSeq === "number" && (n.lastReinforcedAtSeq ?? 0) <= contributedAtSeq) {
|
|
19214
19284
|
composition.watermarked++;
|
|
19215
19285
|
anchorSources.add(n.id);
|
|
19216
|
-
semanticEndpoints.set(n.id, contributedWireId(n));
|
|
19286
|
+
semanticEndpoints.set(n.id, contributedWireId(n, opts.destinationKey));
|
|
19217
19287
|
continue;
|
|
19218
19288
|
}
|
|
19219
19289
|
if (label === "Solution" && n.description.startsWith(AUTO_MINT_PREFIX)) {
|
|
19220
19290
|
composition.autoMint++;
|
|
19221
19291
|
continue;
|
|
19222
19292
|
}
|
|
19223
|
-
if (isTerminallyRefused(n)) {
|
|
19293
|
+
if (isTerminallyRefused({ ...n, attrs: instanceReceipt(n, opts.destinationKey) })) {
|
|
19224
19294
|
composition.terminalRefused++;
|
|
19225
19295
|
continue;
|
|
19226
19296
|
}
|
|
@@ -19279,9 +19349,9 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19279
19349
|
}
|
|
19280
19350
|
const dg = digest(targets.map(({ e, wireId }) => `${e.type}>${wireId}`).sort());
|
|
19281
19351
|
const sourceNode = nodeOf(sourceId);
|
|
19282
|
-
if (sourceNode
|
|
19352
|
+
if ((sourceNode && instanceReceipt(sourceNode, opts.destinationKey)["anchorsContributedDigest"]) === dg) continue;
|
|
19283
19353
|
anchorDigests[sourceId] = dg;
|
|
19284
|
-
const wireFrom = seen.has(sourceId) || !sourceNode ? sourceId : contributedWireId(sourceNode);
|
|
19354
|
+
const wireFrom = seen.has(sourceId) || !sourceNode ? sourceId : contributedWireId(sourceNode, opts.destinationKey);
|
|
19285
19355
|
for (const { e, t, wireId } of targets) {
|
|
19286
19356
|
const reject = unshippableReason(wireId, t.label);
|
|
19287
19357
|
if (reject) {
|
|
@@ -19310,7 +19380,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19310
19380
|
for (const sourceId of anchorSources) {
|
|
19311
19381
|
const source = nodeOf(sourceId);
|
|
19312
19382
|
if (!source) continue;
|
|
19313
|
-
const wireFrom = seen.has(sourceId) ? sourceId : contributedWireId(source);
|
|
19383
|
+
const wireFrom = seen.has(sourceId) ? sourceId : contributedWireId(source, opts.destinationKey);
|
|
19314
19384
|
const planned = [];
|
|
19315
19385
|
for (const e of store.outEdges(sourceId, ["ANCHORED_AT"])) {
|
|
19316
19386
|
const target = nodeOf(e.to);
|
|
@@ -19345,7 +19415,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19345
19415
|
const dg = digest(
|
|
19346
19416
|
planned.map(({ symId, wireAttrs }) => `ANCHORED_AT>${symId}>${JSON.stringify(wireAttrs)}`).sort()
|
|
19347
19417
|
);
|
|
19348
|
-
if (source.
|
|
19418
|
+
if (instanceReceipt(source, opts.destinationKey)["projectAnchorsContributedDigest"] === dg) continue;
|
|
19349
19419
|
projectAnchorDigests[sourceId] = dg;
|
|
19350
19420
|
for (const { e, target, symId, wireAttrs } of planned) {
|
|
19351
19421
|
if (!contextSeen.has(symId)) {
|
|
@@ -19391,7 +19461,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19391
19461
|
if (outs.length === 0) continue;
|
|
19392
19462
|
const dg = digest(outs.map(({ e, wireTo }) => `${e.type}>${wireTo}`).sort());
|
|
19393
19463
|
const owner = nodeOf(sourceId);
|
|
19394
|
-
const digestSkip = owner
|
|
19464
|
+
const digestSkip = (owner && instanceReceipt(owner, opts.destinationKey)["semanticEdgesContributedDigest"]) === dg;
|
|
19395
19465
|
if (!digestSkip) semanticEdgeDigests[sourceId] = dg;
|
|
19396
19466
|
for (const { e, wireTo } of outs) {
|
|
19397
19467
|
if (digestSkip && !shippedById.has(e.to)) continue;
|
|
@@ -19448,7 +19518,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19448
19518
|
for (const wn of nodes) {
|
|
19449
19519
|
if (wn.label !== "RootCause" && wn.label !== "Solution") continue;
|
|
19450
19520
|
const src = nodeOf(wn.id);
|
|
19451
|
-
if (typeof src
|
|
19521
|
+
if (src && typeof instanceReceipt(src, opts.destinationKey)["contributedAtSeq"] === "number") continue;
|
|
19452
19522
|
if (bindingEndpoints.has(wn.id)) continue;
|
|
19453
19523
|
heldOrphans.add(wn.id);
|
|
19454
19524
|
}
|
|
@@ -19526,6 +19596,7 @@ function buildDrainInstances(store, sharedStore, input) {
|
|
|
19526
19596
|
...input.includePackages !== void 0 ? { includePackages: input.includePackages } : {},
|
|
19527
19597
|
workspaceRoot: input.workspaceRoot,
|
|
19528
19598
|
sharedStore,
|
|
19599
|
+
destinationKey: input.destinationKey,
|
|
19529
19600
|
onComposition: (c) => {
|
|
19530
19601
|
composition = c;
|
|
19531
19602
|
},
|