@inerrata-corporation/errata 2.0.17-dev.3549 → 2.0.17-dev.3562
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 +14 -0
- package/errata.mjs +146 -31
- package/package.json +1 -1
- package/pass-worker.mjs +18 -0
package/consolidate-worker.mjs
CHANGED
|
@@ -16611,6 +16611,7 @@ function rowToEdge(r) {
|
|
|
16611
16611
|
};
|
|
16612
16612
|
}
|
|
16613
16613
|
var FINGERPRINT_INDEXED_LABELS = ["Problem", "Vulnerability", "Solution", "RootCause"];
|
|
16614
|
+
var NODE_LABELS_CHUNK = 256;
|
|
16614
16615
|
var SqliteGraphStore = class {
|
|
16615
16616
|
db;
|
|
16616
16617
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -17113,6 +17114,19 @@ var SqliteGraphStore = class {
|
|
|
17113
17114
|
const row = this.stmts.getNode.get(id);
|
|
17114
17115
|
return row ? rowToNode(row) : null;
|
|
17115
17116
|
}
|
|
17117
|
+
nodeLabels(ids) {
|
|
17118
|
+
const width = NODE_LABELS_CHUNK;
|
|
17119
|
+
const stmt = this.typedEdgeStmt(
|
|
17120
|
+
`SELECT id, label FROM nodes WHERE id IN (${Array.from({ length: width }, () => "?").join(",")})`
|
|
17121
|
+
);
|
|
17122
|
+
const labels = /* @__PURE__ */ new Map();
|
|
17123
|
+
for (let i = 0; i < ids.length; i += width) {
|
|
17124
|
+
const chunk = ids.slice(i, i + width);
|
|
17125
|
+
while (chunk.length < width) chunk.push(null);
|
|
17126
|
+
for (const row of stmt.all(...chunk)) labels.set(row.id, row.label);
|
|
17127
|
+
}
|
|
17128
|
+
return labels;
|
|
17129
|
+
}
|
|
17116
17130
|
getEdge(id) {
|
|
17117
17131
|
const row = this.stmts.getEdge.get(id);
|
|
17118
17132
|
return row ? rowToEdge(row) : null;
|
package/errata.mjs
CHANGED
|
@@ -18445,7 +18445,7 @@ function rowToEdge(r) {
|
|
|
18445
18445
|
function openGraphStore(opts) {
|
|
18446
18446
|
return new SqliteGraphStore(opts);
|
|
18447
18447
|
}
|
|
18448
|
-
var LOCAL_RULE_OVERRIDES, SCHEMA_VERSION, SESSION_REPAIR_KEY, SESSION_EVIDENCE_PREDICATE, SCHEMA_SQL, TEMPORAL_INDEX_SQL, FINGERPRINT_INDEXED_LABELS, SqliteGraphStore;
|
|
18448
|
+
var LOCAL_RULE_OVERRIDES, SCHEMA_VERSION, SESSION_REPAIR_KEY, SESSION_EVIDENCE_PREDICATE, SCHEMA_SQL, TEMPORAL_INDEX_SQL, FINGERPRINT_INDEXED_LABELS, NODE_LABELS_CHUNK, SqliteGraphStore;
|
|
18449
18449
|
var init_store = __esm({
|
|
18450
18450
|
"../../packages/local-graph/src/store.ts"() {
|
|
18451
18451
|
"use strict";
|
|
@@ -18596,6 +18596,7 @@ CREATE INDEX IF NOT EXISTS nodes_live_description ON nodes(description, label) W
|
|
|
18596
18596
|
CREATE INDEX IF NOT EXISTS nodes_anchor_hint_path ON nodes(json_extract(attrs_json, '$.anchorHint.path')) WHERE valid_to IS NULL;
|
|
18597
18597
|
`;
|
|
18598
18598
|
FINGERPRINT_INDEXED_LABELS = ["Problem", "Vulnerability", "Solution", "RootCause"];
|
|
18599
|
+
NODE_LABELS_CHUNK = 256;
|
|
18599
18600
|
SqliteGraphStore = class {
|
|
18600
18601
|
db;
|
|
18601
18602
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -19098,6 +19099,19 @@ CREATE INDEX IF NOT EXISTS nodes_anchor_hint_path ON nodes(json_extract(attrs_js
|
|
|
19098
19099
|
const row = this.stmts.getNode.get(id);
|
|
19099
19100
|
return row ? rowToNode(row) : null;
|
|
19100
19101
|
}
|
|
19102
|
+
nodeLabels(ids) {
|
|
19103
|
+
const width = NODE_LABELS_CHUNK;
|
|
19104
|
+
const stmt = this.typedEdgeStmt(
|
|
19105
|
+
`SELECT id, label FROM nodes WHERE id IN (${Array.from({ length: width }, () => "?").join(",")})`
|
|
19106
|
+
);
|
|
19107
|
+
const labels = /* @__PURE__ */ new Map();
|
|
19108
|
+
for (let i2 = 0; i2 < ids.length; i2 += width) {
|
|
19109
|
+
const chunk = ids.slice(i2, i2 + width);
|
|
19110
|
+
while (chunk.length < width) chunk.push(null);
|
|
19111
|
+
for (const row of stmt.all(...chunk)) labels.set(row.id, row.label);
|
|
19112
|
+
}
|
|
19113
|
+
return labels;
|
|
19114
|
+
}
|
|
19101
19115
|
getEdge(id) {
|
|
19102
19116
|
const row = this.stmts.getEdge.get(id);
|
|
19103
19117
|
return row ? rowToEdge(row) : null;
|
|
@@ -19600,7 +19614,9 @@ function staticConductance(edgeType) {
|
|
|
19600
19614
|
return Math.max(UNKNOWN_CONDUCTANCE, Math.min(1, w / MAX_EDGE_WEIGHT));
|
|
19601
19615
|
}
|
|
19602
19616
|
function edgeConductance(edge2) {
|
|
19603
|
-
|
|
19617
|
+
return learnedConductance(staticConductance(edge2.type), edge2);
|
|
19618
|
+
}
|
|
19619
|
+
function learnedConductance(staticW, edge2) {
|
|
19604
19620
|
const s = edge2.navSuccesses ?? 0;
|
|
19605
19621
|
const f = edge2.navFailures ?? 0;
|
|
19606
19622
|
const betaMean = (1 + s) / (2 + s + f);
|
|
@@ -22800,9 +22816,28 @@ var init_uncertainty = __esm({
|
|
|
22800
22816
|
});
|
|
22801
22817
|
|
|
22802
22818
|
// ../../packages/math/src/discovery.ts
|
|
22819
|
+
function typeRelevance(label) {
|
|
22820
|
+
return TYPE_RELEVANCE[label] ?? DEFAULT_TYPE_RELEVANCE;
|
|
22821
|
+
}
|
|
22822
|
+
var TYPE_RELEVANCE, DEFAULT_TYPE_RELEVANCE;
|
|
22803
22823
|
var init_discovery = __esm({
|
|
22804
22824
|
"../../packages/math/src/discovery.ts"() {
|
|
22805
22825
|
"use strict";
|
|
22826
|
+
TYPE_RELEVANCE = {
|
|
22827
|
+
Solution: 1,
|
|
22828
|
+
Vulnerability: 0.95,
|
|
22829
|
+
RootCause: 0.9,
|
|
22830
|
+
Pattern: 0.8,
|
|
22831
|
+
Problem: 0.7,
|
|
22832
|
+
Technique: 0.7,
|
|
22833
|
+
AntiPattern: 0.7,
|
|
22834
|
+
Weakness: 0.6,
|
|
22835
|
+
Domain: 0.5,
|
|
22836
|
+
Function: 0.4,
|
|
22837
|
+
Class: 0.4,
|
|
22838
|
+
File: 0.3
|
|
22839
|
+
};
|
|
22840
|
+
DEFAULT_TYPE_RELEVANCE = 0.3;
|
|
22806
22841
|
}
|
|
22807
22842
|
});
|
|
22808
22843
|
|
|
@@ -25340,6 +25375,7 @@ __export(src_exports2, {
|
|
|
25340
25375
|
isFragmentFixNote: () => isFragmentFixNote,
|
|
25341
25376
|
isPlaceholderStatement: () => isPlaceholderStatement,
|
|
25342
25377
|
isUnfilledPlaceholder: () => isUnfilledPlaceholder,
|
|
25378
|
+
learnedConductance: () => learnedConductance,
|
|
25343
25379
|
linkProblemToLanguages: () => linkProblemToLanguages,
|
|
25344
25380
|
linkProblemToPackages: () => linkProblemToPackages,
|
|
25345
25381
|
linkProblemToSymbols: () => linkProblemToSymbols,
|
|
@@ -32175,62 +32211,139 @@ async function rankForText(store, text, candidateIds) {
|
|
|
32175
32211
|
(r) => r.score > 0
|
|
32176
32212
|
);
|
|
32177
32213
|
}
|
|
32214
|
+
function walksRelatedness(type) {
|
|
32215
|
+
if (type === "DEPENDS_ON") return true;
|
|
32216
|
+
if (PAGERANK_EXCLUSIONS.has(type)) return false;
|
|
32217
|
+
return (EDGE_WEIGHT[type] ?? 1) > 0;
|
|
32218
|
+
}
|
|
32219
|
+
function burstStaticConductance(type, seedLabel) {
|
|
32220
|
+
if (type === "ANCHORED_AT") return BURST_ANCHORED_AT_CONDUCTANCE;
|
|
32221
|
+
if (type === "DEPENDS_ON") return seedLabel === "Package" ? staticConductance(type) : BURST_DEPENDS_ON_FLOOR;
|
|
32222
|
+
return staticConductance(type);
|
|
32223
|
+
}
|
|
32224
|
+
function burstConductance(edge2, seedLabel) {
|
|
32225
|
+
return learnedConductance(burstStaticConductance(edge2.type, seedLabel), edge2);
|
|
32226
|
+
}
|
|
32178
32227
|
function localBurst(store, seedId, opts = {}) {
|
|
32179
|
-
const maxHops = opts.maxHops ??
|
|
32228
|
+
const maxHops = opts.maxHops ?? 3;
|
|
32180
32229
|
const limit = opts.limit ?? 20;
|
|
32181
|
-
const nodeCap = opts.nodeCap ??
|
|
32230
|
+
const nodeCap = opts.nodeCap ?? 200;
|
|
32182
32231
|
const seed = store.getNode(seedId);
|
|
32183
32232
|
if (!seed) return [];
|
|
32233
|
+
const act = /* @__PURE__ */ new Map([[seedId, 1]]);
|
|
32184
32234
|
const hopOf = /* @__PURE__ */ new Map([[seedId, 0]]);
|
|
32185
32235
|
const viaOf = /* @__PURE__ */ new Map();
|
|
32186
|
-
|
|
32187
|
-
|
|
32188
|
-
|
|
32189
|
-
|
|
32190
|
-
|
|
32191
|
-
|
|
32192
|
-
|
|
32193
|
-
|
|
32194
|
-
|
|
32195
|
-
|
|
32196
|
-
|
|
32197
|
-
|
|
32198
|
-
|
|
32199
|
-
|
|
32200
|
-
|
|
32201
|
-
|
|
32202
|
-
|
|
32203
|
-
|
|
32204
|
-
|
|
32205
|
-
|
|
32206
|
-
|
|
32236
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
32237
|
+
const frontier = new ActivationHeap();
|
|
32238
|
+
frontier.push(seedId, 1);
|
|
32239
|
+
let strongest = 0;
|
|
32240
|
+
while (frontier.size > 0 && expanded.size < nodeCap) {
|
|
32241
|
+
const top = frontier.pop();
|
|
32242
|
+
if (expanded.has(top.id) || top.a < (act.get(top.id) ?? 0)) continue;
|
|
32243
|
+
if (top.a < ACTIVATION_EPSILON || top.a < strongest * BURST_RELATIVE_FLOOR) break;
|
|
32244
|
+
expanded.add(top.id);
|
|
32245
|
+
const hops = hopOf.get(top.id) ?? 0;
|
|
32246
|
+
if (hops >= maxHops) continue;
|
|
32247
|
+
const edges = [
|
|
32248
|
+
...store.outEdges(top.id).map((e) => ({ e, nb: e.to, forward: true })),
|
|
32249
|
+
...store.inEdges(top.id).map((e) => ({ e, nb: e.from, forward: false }))
|
|
32250
|
+
].filter(({ e }) => walksRelatedness(e.type));
|
|
32251
|
+
const damp = BURST_STEP_DAMPING / Math.sqrt(Math.max(1, edges.length));
|
|
32252
|
+
for (const { e, nb, forward } of edges) {
|
|
32253
|
+
if (nb === seedId || expanded.has(nb)) continue;
|
|
32254
|
+
const a = top.a * burstConductance(e, seed.label) * damp;
|
|
32255
|
+
if (a <= (act.get(nb) ?? 0)) continue;
|
|
32256
|
+
act.set(nb, a);
|
|
32257
|
+
if (a > strongest) strongest = a;
|
|
32258
|
+
hopOf.set(nb, hops + 1);
|
|
32259
|
+
viaOf.set(nb, { edgeType: e.type, parentId: top.id, forward });
|
|
32260
|
+
frontier.push(nb, a);
|
|
32261
|
+
}
|
|
32262
|
+
}
|
|
32263
|
+
act.delete(seedId);
|
|
32207
32264
|
const ctxSeed = seed.embedding.length > 0 ? { seedEmbedding: seed.embedding, seedEmbeddingVersion: seed.attrs["embeddingVersion"] } : {};
|
|
32208
32265
|
const gated = seed.embedding.length > 0;
|
|
32209
|
-
const
|
|
32210
|
-
const
|
|
32266
|
+
const labelOf = store.nodeLabels([...act.keys()]);
|
|
32267
|
+
const pool = (keep) => [...act.entries()].filter(([id]) => keep(labelOf.get(id) ?? "")).sort((x, y) => y[1] - x[1]).slice(0, BURST_SCORED_CANDIDATES);
|
|
32268
|
+
const isKnowledge = (label) => typeRelevance(label) >= KNOWLEDGE_TYPE_RELEVANCE;
|
|
32269
|
+
const reached = [...pool(isKnowledge), ...pool((l) => !isKnowledge(l))].map(([id, a]) => ({ node: store.getNode(id), a })).filter((x) => x.node != null);
|
|
32270
|
+
const maxPr = Math.max(1e-9, ...reached.map((x) => x.node.pageRank));
|
|
32271
|
+
const maxAct = Math.max(1e-12, ...reached.map((x) => x.a));
|
|
32211
32272
|
const weights = {
|
|
32212
32273
|
centralityScale: maxPr,
|
|
32213
32274
|
...gated ? { semanticFloor: semanticFloorFor(ctxSeed.seedEmbeddingVersion) } : {},
|
|
32214
32275
|
...opts.weights
|
|
32215
32276
|
};
|
|
32216
32277
|
const now = store.currentIngestSeq();
|
|
32217
|
-
return
|
|
32218
|
-
const r = scoreCandidate(node2, { ...ctxSeed,
|
|
32278
|
+
return reached.map(({ node: node2, a }) => {
|
|
32279
|
+
const r = scoreCandidate(node2, { ...ctxSeed, decay: nodeFreshness(node2, now) }, weights);
|
|
32280
|
+
const score2 = a / maxAct * r.score * typeRelevance(node2.label);
|
|
32219
32281
|
const via = viaOf.get(node2.id);
|
|
32220
|
-
return { id: node2.id, score:
|
|
32282
|
+
return { id: node2.id, score: score2, components: r.components, node: node2, hops: hopOf.get(node2.id) ?? 0, ...via ? { via } : {} };
|
|
32221
32283
|
}).filter((r) => !gated || r.score > 0).sort((a, b) => b.score - a.score).slice(0, limit);
|
|
32222
32284
|
}
|
|
32285
|
+
var BURST_STEP_DAMPING, ACTIVATION_EPSILON, BURST_RELATIVE_FLOOR, BURST_SCORED_CANDIDATES, KNOWLEDGE_TYPE_RELEVANCE, BURST_ANCHORED_AT_CONDUCTANCE, BURST_DEPENDS_ON_FLOOR, ActivationHeap;
|
|
32223
32286
|
var init_relevance_rank = __esm({
|
|
32224
32287
|
"../../packages/generalizer/src/relevance-rank.ts"() {
|
|
32225
32288
|
"use strict";
|
|
32226
32289
|
init_src3();
|
|
32227
32290
|
init_src4();
|
|
32291
|
+
init_src5();
|
|
32292
|
+
init_src();
|
|
32293
|
+
BURST_STEP_DAMPING = 0.85;
|
|
32294
|
+
ACTIVATION_EPSILON = 1e-6;
|
|
32295
|
+
BURST_RELATIVE_FLOOR = 0.02;
|
|
32296
|
+
BURST_SCORED_CANDIDATES = 150;
|
|
32297
|
+
KNOWLEDGE_TYPE_RELEVANCE = 0.5;
|
|
32298
|
+
BURST_ANCHORED_AT_CONDUCTANCE = 1 / 3;
|
|
32299
|
+
BURST_DEPENDS_ON_FLOOR = 0.1;
|
|
32300
|
+
ActivationHeap = class {
|
|
32301
|
+
items = [];
|
|
32302
|
+
get size() {
|
|
32303
|
+
return this.items.length;
|
|
32304
|
+
}
|
|
32305
|
+
push(id, a) {
|
|
32306
|
+
const items = this.items;
|
|
32307
|
+
items.push({ id, a });
|
|
32308
|
+
let i2 = items.length - 1;
|
|
32309
|
+
while (i2 > 0) {
|
|
32310
|
+
const p = i2 - 1 >> 1;
|
|
32311
|
+
if (items[p].a >= items[i2].a) break;
|
|
32312
|
+
[items[p], items[i2]] = [items[i2], items[p]];
|
|
32313
|
+
i2 = p;
|
|
32314
|
+
}
|
|
32315
|
+
}
|
|
32316
|
+
pop() {
|
|
32317
|
+
const items = this.items;
|
|
32318
|
+
const top = items[0];
|
|
32319
|
+
const last = items.pop();
|
|
32320
|
+
if (items.length > 0 && last) {
|
|
32321
|
+
items[0] = last;
|
|
32322
|
+
let i2 = 0;
|
|
32323
|
+
for (; ; ) {
|
|
32324
|
+
const l = 2 * i2 + 1, r = l + 1;
|
|
32325
|
+
let m = i2;
|
|
32326
|
+
if (l < items.length && items[l].a > items[m].a) m = l;
|
|
32327
|
+
if (r < items.length && items[r].a > items[m].a) m = r;
|
|
32328
|
+
if (m === i2) break;
|
|
32329
|
+
[items[m], items[i2]] = [items[i2], items[m]];
|
|
32330
|
+
i2 = m;
|
|
32331
|
+
}
|
|
32332
|
+
}
|
|
32333
|
+
return top;
|
|
32334
|
+
}
|
|
32335
|
+
};
|
|
32228
32336
|
}
|
|
32229
32337
|
});
|
|
32230
32338
|
|
|
32231
32339
|
// ../../packages/generalizer/src/index.ts
|
|
32232
32340
|
var src_exports3 = {};
|
|
32233
32341
|
__export(src_exports3, {
|
|
32342
|
+
BURST_ANCHORED_AT_CONDUCTANCE: () => BURST_ANCHORED_AT_CONDUCTANCE,
|
|
32343
|
+
BURST_DEPENDS_ON_FLOOR: () => BURST_DEPENDS_ON_FLOOR,
|
|
32344
|
+
BURST_RELATIVE_FLOOR: () => BURST_RELATIVE_FLOOR,
|
|
32345
|
+
BURST_SCORED_CANDIDATES: () => BURST_SCORED_CANDIDATES,
|
|
32346
|
+
BURST_STEP_DAMPING: () => BURST_STEP_DAMPING,
|
|
32234
32347
|
FULL_RESCORE_EVERY: () => FULL_RESCORE_EVERY,
|
|
32235
32348
|
INCREMENTAL_REGION_MAX_FRACTION: () => INCREMENTAL_REGION_MAX_FRACTION,
|
|
32236
32349
|
anchorByLine: () => anchorByLine,
|
|
@@ -32240,6 +32353,8 @@ __export(src_exports3, {
|
|
|
32240
32353
|
attributeRootCause: () => attributeRootCause,
|
|
32241
32354
|
bindCanonicalNeighbors: () => bindCanonicalNeighbors,
|
|
32242
32355
|
bindResolvedRegressions: () => bindResolvedRegressions,
|
|
32356
|
+
burstConductance: () => burstConductance,
|
|
32357
|
+
burstStaticConductance: () => burstStaticConductance,
|
|
32243
32358
|
closeProblem: () => closeProblem,
|
|
32244
32359
|
codeAnchorProjection: () => codeAnchorProjection,
|
|
32245
32360
|
commandSignature: () => commandSignature,
|
|
@@ -82519,7 +82634,7 @@ function createWatchBreaker(deps) {
|
|
|
82519
82634
|
}
|
|
82520
82635
|
|
|
82521
82636
|
// src/engine.ts
|
|
82522
|
-
var DAEMON_VERSION = true ? "2.0.17-dev.
|
|
82637
|
+
var DAEMON_VERSION = true ? "2.0.17-dev.3562" : "2.0.0-alpha.0";
|
|
82523
82638
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
82524
82639
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
82525
82640
|
var GIT_OP_MUTE_MS = 4e3;
|
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -25640,6 +25640,7 @@ function rowToEdge(r) {
|
|
|
25640
25640
|
};
|
|
25641
25641
|
}
|
|
25642
25642
|
var FINGERPRINT_INDEXED_LABELS = ["Problem", "Vulnerability", "Solution", "RootCause"];
|
|
25643
|
+
var NODE_LABELS_CHUNK = 256;
|
|
25643
25644
|
var SqliteGraphStore = class {
|
|
25644
25645
|
db;
|
|
25645
25646
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -26142,6 +26143,19 @@ var SqliteGraphStore = class {
|
|
|
26142
26143
|
const row = this.stmts.getNode.get(id);
|
|
26143
26144
|
return row ? rowToNode(row) : null;
|
|
26144
26145
|
}
|
|
26146
|
+
nodeLabels(ids) {
|
|
26147
|
+
const width = NODE_LABELS_CHUNK;
|
|
26148
|
+
const stmt = this.typedEdgeStmt(
|
|
26149
|
+
`SELECT id, label FROM nodes WHERE id IN (${Array.from({ length: width }, () => "?").join(",")})`
|
|
26150
|
+
);
|
|
26151
|
+
const labels = /* @__PURE__ */ new Map();
|
|
26152
|
+
for (let i2 = 0; i2 < ids.length; i2 += width) {
|
|
26153
|
+
const chunk = ids.slice(i2, i2 + width);
|
|
26154
|
+
while (chunk.length < width) chunk.push(null);
|
|
26155
|
+
for (const row of stmt.all(...chunk)) labels.set(row.id, row.label);
|
|
26156
|
+
}
|
|
26157
|
+
return labels;
|
|
26158
|
+
}
|
|
26145
26159
|
getEdge(id) {
|
|
26146
26160
|
const row = this.stmts.getEdge.get(id);
|
|
26147
26161
|
return row ? rowToEdge(row) : null;
|
|
@@ -28965,6 +28979,10 @@ function codeAnchorProjection(store2, semanticIds, opts = {}) {
|
|
|
28965
28979
|
// ../../packages/generalizer/src/embed-code.ts
|
|
28966
28980
|
init_src();
|
|
28967
28981
|
|
|
28982
|
+
// ../../packages/generalizer/src/relevance-rank.ts
|
|
28983
|
+
init_src();
|
|
28984
|
+
var BURST_ANCHORED_AT_CONDUCTANCE = 1 / 3;
|
|
28985
|
+
|
|
28968
28986
|
// ../../packages/context-writer/src/agents-md.ts
|
|
28969
28987
|
init_src();
|
|
28970
28988
|
|