@inerrata-corporation/errata 2.0.2-dev.73 → 2.0.2-dev.789
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 +597 -239
- package/errata.mjs +7640 -1833
- package/package.json +1 -1
- package/pass-worker.mjs +1146 -215
package/pass-worker.mjs
CHANGED
|
@@ -144,7 +144,14 @@ var init_castalia = __esm({
|
|
|
144
144
|
"SOLVED_BY",
|
|
145
145
|
"MITIGATES",
|
|
146
146
|
"REPORTED_FAILURE",
|
|
147
|
-
"CONTRADICTS"
|
|
147
|
+
"CONTRADICTS",
|
|
148
|
+
// Motif twin-faces (KN-twin-faces): failure-face motif → remedy-face motif
|
|
149
|
+
// across layers (AntiPattern/Weakness ↔ Technique/Pattern). Same
|
|
150
|
+
// problem→fix direction as FIXED_BY/SOLVED_BY. Minted by the nightly LLM
|
|
151
|
+
// twin-face pass — these are the near-identical cross-layer pairs the
|
|
152
|
+
// polarity gate (finding 5) correctly refuses to FUSE; the link carries
|
|
153
|
+
// what fusion can't.
|
|
154
|
+
"REMEDIED_BY"
|
|
148
155
|
];
|
|
149
156
|
CONCEPTUAL_EDGES = [
|
|
150
157
|
"INSTANCE_OF",
|
|
@@ -259,6 +266,10 @@ var init_castalia = __esm({
|
|
|
259
266
|
// git topology, not signal-flow
|
|
260
267
|
"AUTHORED_BY",
|
|
261
268
|
// git authorship, not signal-flow
|
|
269
|
+
"PRODUCED",
|
|
270
|
+
// edit-episode provenance (Episode→symbol), not signal-flow — the family
|
|
271
|
+
// above was excluded together but this member slipped the net (LC-produced-pagerank);
|
|
272
|
+
// at 43% of all live edges it was the largest single edge population flowing rank
|
|
262
273
|
"CONTRIBUTED",
|
|
263
274
|
// agent attribution (Agent → knowledge), not signal-flow
|
|
264
275
|
"SUPERSEDES",
|
|
@@ -274,6 +285,10 @@ var init_castalia = __esm({
|
|
|
274
285
|
CAUSED_BY: 3,
|
|
275
286
|
FIXED_BY: 3,
|
|
276
287
|
SOLVED_BY: 3,
|
|
288
|
+
// Twin-face link (failure motif → remedy motif, KN-twin-faces) — causal-grade
|
|
289
|
+
// but a notch below witnessed FIXED_BY/SOLVED_BY: the pairing is an LLM
|
|
290
|
+
// judgment over descriptions, not an agent-witnessed resolution.
|
|
291
|
+
REMEDIED_BY: 2.5,
|
|
277
292
|
MANIFESTS_AS: 2,
|
|
278
293
|
ESCALATES_TO: 1.5,
|
|
279
294
|
AFFECTS: 1.2,
|
|
@@ -447,13 +462,18 @@ function resolveCanonical(label) {
|
|
|
447
462
|
function resolveCanonicalId(label) {
|
|
448
463
|
return resolveCanonical(label)?.id;
|
|
449
464
|
}
|
|
465
|
+
function resolveUnambiguousCanonicalId(label) {
|
|
466
|
+
const key = label.trim().toLowerCase();
|
|
467
|
+
if (AMBIGUOUS_ALIASES.has(key)) return void 0;
|
|
468
|
+
return resolveCanonicalId(key);
|
|
469
|
+
}
|
|
450
470
|
function aliasesLongestFirst() {
|
|
451
471
|
const out2 = [];
|
|
452
472
|
for (const e of REGISTRY) for (const a of e.aliases) out2.push({ alias: a.toLowerCase(), entity: e });
|
|
453
473
|
out2.sort((x, y) => y.alias.length - x.alias.length);
|
|
454
474
|
return out2;
|
|
455
475
|
}
|
|
456
|
-
var REGISTRY, BY_ALIAS;
|
|
476
|
+
var REGISTRY, AMBIGUOUS_ALIASES, BY_ALIAS;
|
|
457
477
|
var init_taxonomy = __esm({
|
|
458
478
|
"../../packages/shared/src/nlp/taxonomy.ts"() {
|
|
459
479
|
"use strict";
|
|
@@ -502,6 +522,13 @@ var init_taxonomy = __esm({
|
|
|
502
522
|
{ id: "concept:retry", name: "retry", category: "concept", aliases: ["retry"] },
|
|
503
523
|
{ id: "concept:migration", name: "migration", category: "concept", aliases: ["migration"] }
|
|
504
524
|
];
|
|
525
|
+
AMBIGUOUS_ALIASES = /* @__PURE__ */ new Set([
|
|
526
|
+
"node",
|
|
527
|
+
"go",
|
|
528
|
+
"pool",
|
|
529
|
+
"spring",
|
|
530
|
+
"ws"
|
|
531
|
+
]);
|
|
505
532
|
BY_ALIAS = /* @__PURE__ */ new Map();
|
|
506
533
|
for (const e of REGISTRY) {
|
|
507
534
|
for (const a of e.aliases) {
|
|
@@ -563,7 +590,7 @@ function lemma(token) {
|
|
|
563
590
|
}
|
|
564
591
|
return token;
|
|
565
592
|
}
|
|
566
|
-
function
|
|
593
|
+
function tokenize(text, resolve) {
|
|
567
594
|
const matches = text.normalize("NFC").toLowerCase().match(TOKEN_RE) ?? [];
|
|
568
595
|
const out2 = /* @__PURE__ */ new Set();
|
|
569
596
|
for (const raw of matches) {
|
|
@@ -573,11 +600,14 @@ function conceptTokens(text) {
|
|
|
573
600
|
out2.add(token);
|
|
574
601
|
continue;
|
|
575
602
|
}
|
|
576
|
-
const canonical =
|
|
603
|
+
const canonical = resolve(token);
|
|
577
604
|
out2.add(canonical ?? lemma(token));
|
|
578
605
|
}
|
|
579
606
|
return [...out2].sort();
|
|
580
607
|
}
|
|
608
|
+
function retrievalTokens(text) {
|
|
609
|
+
return tokenize(text, resolveUnambiguousCanonicalId);
|
|
610
|
+
}
|
|
581
611
|
var STOPWORDS, NEGATION_TOKENS, TOKEN_RE;
|
|
582
612
|
var init_concept_bag = __esm({
|
|
583
613
|
"../../packages/shared/src/nlp/concept-bag.ts"() {
|
|
@@ -15049,13 +15079,21 @@ var init_edge_rules = __esm({
|
|
|
15049
15079
|
// NOT ruled here — the type pre-exists with broader extractor senses, and a
|
|
15050
15080
|
// new rule on an old type would reject legitimate live flows (reject-never-flip
|
|
15051
15081
|
// cuts both ways: only rule types you introduce or senses that are documented).
|
|
15052
|
-
|
|
15082
|
+
// `Component` joined the target set with OM-agent-anchors: an agent-named
|
|
15083
|
+
// component ("React Router") is the same knowledge→named-unit anchor shape as
|
|
15084
|
+
// a Tool — the knowledge is ABOUT it, not dependent on it.
|
|
15085
|
+
CONCERNS: { from: ["Problem", "Solution", "RootCause", "Claim", "Pattern"], to: ["Tool", "Component"] },
|
|
15053
15086
|
OPERATES_ON: { from: ["Algorithm"], to: ["DataStructure"] },
|
|
15054
15087
|
INVOLVES: { from: ["Problem", "Solution"], to: ["DataStructure"] },
|
|
15055
15088
|
// ── Taxonomy (Track 4 Stream C: MITRE CWE `ChildOf` → `Weakness —IS_A→ Weakness`) ──
|
|
15056
15089
|
IS_A: { from: ["Weakness"], to: ["Weakness"] },
|
|
15057
15090
|
// ── Conceptual (v1 taxonomy.ts: instance → motif/pattern reference) ──
|
|
15058
|
-
|
|
15091
|
+
// `AntiPattern` joined the target set 2026-08-02: it is one of the three motif
|
|
15092
|
+
// kinds (generalizer motifs.ts `layerOf`: pattern | technique | antipattern) and
|
|
15093
|
+
// the SUPPRESSED-close path mints `Problem ─INSTANCE_OF→ AntiPattern` as the
|
|
15094
|
+
// negative-knowledge binding ("silenced, not solved") — the original three-label
|
|
15095
|
+
// rule predates AntiPattern joining the motif layer and silently ate that edge.
|
|
15096
|
+
INSTANCE_OF: { to: ["Pattern", "AntiPattern", "Weakness", "Technique"] },
|
|
15059
15097
|
IMPLEMENTS: { from: ["Solution", "Language", "Component"], to: ["Pattern", "Technique"] },
|
|
15060
15098
|
MATCHES: { to: ["Pattern"] },
|
|
15061
15099
|
// ── Artifact evidence (v1 taxonomy.ts artifact rows) ──
|
|
@@ -15156,6 +15194,23 @@ var init_wire = __esm({
|
|
|
15156
15194
|
/** Canonical human-readable description (no raw paths — daemon scrubs; server rechecks). */
|
|
15157
15195
|
description: external_exports.string().min(1).max(4e3),
|
|
15158
15196
|
attrs: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
|
|
15197
|
+
/** One-way origin key of the SESSION that minted this node (`ws_…`, a
|
|
15198
|
+
* truncated digest — never the raw session id). Stamped onto the created
|
|
15199
|
+
* node as `authoringSession`, which is the independence unit for the
|
|
15200
|
+
* evidence channels: the session that authored a claim may not corroborate
|
|
15201
|
+
* or refute it, while a DIFFERENT session on the same checkout may (alyssa,
|
|
15202
|
+
* 2026-07-31 — the workspace key made every witness on a single-checkout
|
|
15203
|
+
* deployment a self-corroboration). Optional + additive: absent leaves the
|
|
15204
|
+
* gate fail-open for that node, exactly today's behaviour. */
|
|
15205
|
+
originSession: external_exports.string().min(3).max(64).optional(),
|
|
15206
|
+
/** Epoch ms of the ORIGINATING local node's creation — when the knowledge was
|
|
15207
|
+
* actually captured, as opposed to when its public twin reached the cloud.
|
|
15208
|
+
* Stored as `observedAt`; the network board's chronological view orders on
|
|
15209
|
+
* it. Without this the wire carried NO timestamp at all, so a node captured
|
|
15210
|
+
* days ago surfaced as "new" the moment it was generalized and published —
|
|
15211
|
+
* the board showed ingest order wearing a chronology's clothes. Optional +
|
|
15212
|
+
* additive: absent keeps ingest-time ordering for that node. */
|
|
15213
|
+
originCreatedAtMs: external_exports.number().int().positive().optional(),
|
|
15159
15214
|
extractionSource: external_exports.enum(INGEST_EXTRACTION_SOURCES),
|
|
15160
15215
|
validationSource: external_exports.enum(VALIDATION_SOURCES).optional(),
|
|
15161
15216
|
/** Org-membrane (M2): the daemon's anchor tag — it owns the lockfile, so it
|
|
@@ -15328,6 +15383,51 @@ var init_review = __esm({
|
|
|
15328
15383
|
}
|
|
15329
15384
|
});
|
|
15330
15385
|
|
|
15386
|
+
// ../../packages/local-shared/src/anchorable.ts
|
|
15387
|
+
function anchorableExtensionAlternation() {
|
|
15388
|
+
return BY_LENGTH.map((e) => e.slice(1).replace(/[+.]/g, (c) => `\\${c}`)).join("|");
|
|
15389
|
+
}
|
|
15390
|
+
var ANCHORABLE_EXTENSIONS, BY_LENGTH;
|
|
15391
|
+
var init_anchorable = __esm({
|
|
15392
|
+
"../../packages/local-shared/src/anchorable.ts"() {
|
|
15393
|
+
"use strict";
|
|
15394
|
+
ANCHORABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
15395
|
+
// typescript provider
|
|
15396
|
+
".ts",
|
|
15397
|
+
".tsx",
|
|
15398
|
+
".js",
|
|
15399
|
+
".jsx",
|
|
15400
|
+
".mjs",
|
|
15401
|
+
".cjs",
|
|
15402
|
+
// python / go / rust / ruby / csharp providers
|
|
15403
|
+
".py",
|
|
15404
|
+
".go",
|
|
15405
|
+
".rs",
|
|
15406
|
+
".rb",
|
|
15407
|
+
".cs",
|
|
15408
|
+
// cpp provider — every variant it parses, not just the three that were listed
|
|
15409
|
+
".c",
|
|
15410
|
+
".h",
|
|
15411
|
+
".cpp",
|
|
15412
|
+
".cc",
|
|
15413
|
+
".cxx",
|
|
15414
|
+
".c++",
|
|
15415
|
+
".hpp",
|
|
15416
|
+
".hh",
|
|
15417
|
+
".hxx",
|
|
15418
|
+
".h++",
|
|
15419
|
+
// CUDA — the cpp provider parses these too. Missed when this list was first
|
|
15420
|
+
// transcribed by hand; the parity test caught them on its very first run,
|
|
15421
|
+
// which is the argument for the test existing.
|
|
15422
|
+
".cu",
|
|
15423
|
+
".cuh",
|
|
15424
|
+
// no provider yet; the grammar ships. Inert, not wrong — see above.
|
|
15425
|
+
".java"
|
|
15426
|
+
]);
|
|
15427
|
+
BY_LENGTH = [...ANCHORABLE_EXTENSIONS].sort((a, b) => b.length - a.length);
|
|
15428
|
+
}
|
|
15429
|
+
});
|
|
15430
|
+
|
|
15331
15431
|
// ../../packages/local-shared/src/sqlite-adapter.ts
|
|
15332
15432
|
function openDatabase(path) {
|
|
15333
15433
|
const db = new DatabaseSync(path);
|
|
@@ -15340,6 +15440,7 @@ function openDatabase(path) {
|
|
|
15340
15440
|
db.exec("PRAGMA journal_mode = WAL");
|
|
15341
15441
|
db.exec("PRAGMA synchronous = NORMAL");
|
|
15342
15442
|
db.exec("PRAGMA busy_timeout = 5000");
|
|
15443
|
+
db.exec("PRAGMA journal_size_limit = 67108864");
|
|
15343
15444
|
} catch {
|
|
15344
15445
|
}
|
|
15345
15446
|
}
|
|
@@ -15375,7 +15476,7 @@ function openDatabase(path) {
|
|
|
15375
15476
|
return db.prepare(`PRAGMA ${key}`).get();
|
|
15376
15477
|
},
|
|
15377
15478
|
transaction(fn) {
|
|
15378
|
-
db.exec("BEGIN");
|
|
15479
|
+
db.exec("BEGIN IMMEDIATE");
|
|
15379
15480
|
try {
|
|
15380
15481
|
const r = fn();
|
|
15381
15482
|
db.exec("COMMIT");
|
|
@@ -15429,6 +15530,7 @@ var init_src2 = __esm({
|
|
|
15429
15530
|
init_profile();
|
|
15430
15531
|
init_daemon_wire();
|
|
15431
15532
|
init_review();
|
|
15533
|
+
init_anchorable();
|
|
15432
15534
|
init_sqlite_adapter();
|
|
15433
15535
|
}
|
|
15434
15536
|
});
|
|
@@ -15451,7 +15553,7 @@ function popcount(x) {
|
|
|
15451
15553
|
}
|
|
15452
15554
|
return c;
|
|
15453
15555
|
}
|
|
15454
|
-
function
|
|
15556
|
+
function tokenize2(text) {
|
|
15455
15557
|
return text.match(/[A-Za-z_$][A-Za-z0-9_$]*|\d+|[^\s\w]/g) ?? [];
|
|
15456
15558
|
}
|
|
15457
15559
|
function shingle(tokens, n = SHINGLE_N) {
|
|
@@ -15480,7 +15582,7 @@ function simhashFeatures(features) {
|
|
|
15480
15582
|
return out2;
|
|
15481
15583
|
}
|
|
15482
15584
|
function simhash(text) {
|
|
15483
|
-
return simhashFeatures(shingle(
|
|
15585
|
+
return simhashFeatures(shingle(tokenize2(text)));
|
|
15484
15586
|
}
|
|
15485
15587
|
function hammingDistance(a, b) {
|
|
15486
15588
|
return popcount((a ^ b) & MASK64);
|
|
@@ -15788,6 +15890,7 @@ async function incrementalReindex(store2, rootPath, workspaceId, changedAbsPaths
|
|
|
15788
15890
|
};
|
|
15789
15891
|
}
|
|
15790
15892
|
const fileHashes = /* @__PURE__ */ new Map();
|
|
15893
|
+
const contentMovedPaths = /* @__PURE__ */ new Set();
|
|
15791
15894
|
for (const rel of [...changedRelPaths]) {
|
|
15792
15895
|
let h;
|
|
15793
15896
|
try {
|
|
@@ -15800,6 +15903,8 @@ async function incrementalReindex(store2, rootPath, workspaceId, changedAbsPaths
|
|
|
15800
15903
|
if (fnode && fnode.attrs["contentHash"] === h && !fileHasStrandedSymbol(store2, fnode.id)) {
|
|
15801
15904
|
store2.updateNode(fnode.id, { lastUpdatedAt: t });
|
|
15802
15905
|
changedRelPaths.delete(rel);
|
|
15906
|
+
} else if (!fnode || fnode.attrs["contentHash"] !== h) {
|
|
15907
|
+
contentMovedPaths.add(rel);
|
|
15803
15908
|
}
|
|
15804
15909
|
}
|
|
15805
15910
|
if (changedRelPaths.size === 0) {
|
|
@@ -15934,6 +16039,7 @@ async function incrementalReindex(store2, rootPath, workspaceId, changedAbsPaths
|
|
|
15934
16039
|
changedRelPaths
|
|
15935
16040
|
});
|
|
15936
16041
|
store2.transaction(() => {
|
|
16042
|
+
store2.reviveReobserved([...changedRelPaths], workspaceId, t);
|
|
15937
16043
|
const versionedAndFile = /* @__PURE__ */ new Set([...VERSIONED_LABELS, "File"]);
|
|
15938
16044
|
const ownedLive = [];
|
|
15939
16045
|
for (const n of store2.nodesByRelPath([...changedRelPaths])) {
|
|
@@ -16042,7 +16148,14 @@ async function incrementalReindex(store2, rootPath, workspaceId, changedAbsPaths
|
|
|
16042
16148
|
const h = fileHashes.get(rel);
|
|
16043
16149
|
if (!h) continue;
|
|
16044
16150
|
const fnode = store2.getNode(fileNodeId(workspaceId, rel));
|
|
16045
|
-
if (fnode)
|
|
16151
|
+
if (!fnode) continue;
|
|
16152
|
+
store2.updateNode(fnode.id, {
|
|
16153
|
+
attrs: {
|
|
16154
|
+
...fnode.attrs,
|
|
16155
|
+
contentHash: h,
|
|
16156
|
+
...contentMovedPaths.has(rel) ? { contentChangedAt: t } : {}
|
|
16157
|
+
}
|
|
16158
|
+
});
|
|
16046
16159
|
}
|
|
16047
16160
|
return {
|
|
16048
16161
|
filesReindexed: changedRelPaths.size,
|
|
@@ -16613,7 +16726,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
16613
16726
|
}
|
|
16614
16727
|
}
|
|
16615
16728
|
}
|
|
16616
|
-
function
|
|
16729
|
+
function gitListRelPaths(root, ignores) {
|
|
16617
16730
|
let stdout;
|
|
16618
16731
|
try {
|
|
16619
16732
|
stdout = execFileSync(
|
|
@@ -16636,6 +16749,15 @@ function gitListFiles(root, ignores, providers) {
|
|
|
16636
16749
|
if (segs.some((s) => ignores.has(s) || s.startsWith(".") && s.length > 1)) {
|
|
16637
16750
|
continue;
|
|
16638
16751
|
}
|
|
16752
|
+
out2.push(rel);
|
|
16753
|
+
}
|
|
16754
|
+
return out2;
|
|
16755
|
+
}
|
|
16756
|
+
function gitListFiles(root, ignores, providers) {
|
|
16757
|
+
const rels = gitListRelPaths(root, ignores);
|
|
16758
|
+
if (rels === null) return null;
|
|
16759
|
+
const out2 = [];
|
|
16760
|
+
for (const rel of rels) {
|
|
16639
16761
|
const abs = join(root, rel);
|
|
16640
16762
|
let size;
|
|
16641
16763
|
try {
|
|
@@ -23975,6 +24097,7 @@ var init_csharp_treesitter = __esm({
|
|
|
23975
24097
|
// ../../packages/indexer/src/index.ts
|
|
23976
24098
|
var src_exports = {};
|
|
23977
24099
|
__export(src_exports, {
|
|
24100
|
+
DEFAULT_IGNORES: () => DEFAULT_IGNORES,
|
|
23978
24101
|
DRIFT_FORK_RATIO: () => DRIFT_FORK_RATIO,
|
|
23979
24102
|
TreeSitterCSharpProvider: () => TreeSitterCSharpProvider,
|
|
23980
24103
|
TreeSitterCppProvider: () => TreeSitterCppProvider,
|
|
@@ -23991,6 +24114,7 @@ __export(src_exports, {
|
|
|
23991
24114
|
findInnermostScope: () => findInnermostScope,
|
|
23992
24115
|
folderNodeId: () => folderNodeId,
|
|
23993
24116
|
fromHex: () => fromHex,
|
|
24117
|
+
gitListRelPaths: () => gitListRelPaths,
|
|
23994
24118
|
hammingDistance: () => hammingDistance,
|
|
23995
24119
|
hasForkedDrift: () => hasForkedDrift,
|
|
23996
24120
|
incrementalReindex: () => incrementalReindex,
|
|
@@ -24003,7 +24127,7 @@ __export(src_exports, {
|
|
|
24003
24127
|
simhashFeatures: () => simhashFeatures,
|
|
24004
24128
|
symbolNodeId: () => symbolNodeId,
|
|
24005
24129
|
toHex: () => toHex,
|
|
24006
|
-
tokenize: () =>
|
|
24130
|
+
tokenize: () => tokenize2
|
|
24007
24131
|
});
|
|
24008
24132
|
function defaultProviders() {
|
|
24009
24133
|
if (providersCache) return providersCache;
|
|
@@ -24056,9 +24180,32 @@ var LOCAL_RULE_OVERRIDES = {
|
|
|
24056
24180
|
to: [...CODE_NODE_LABELS, "Symbol"]
|
|
24057
24181
|
},
|
|
24058
24182
|
REVEALED_BY: null,
|
|
24059
|
-
PRODUCED: null
|
|
24183
|
+
PRODUCED: null,
|
|
24184
|
+
// FIXED_BY locally ALSO carries the fix-provenance sense: `resolveProblem`
|
|
24185
|
+
// attributes a closed Problem to the fixing `Episode` (PLAN_PLASTICITY §2.1)
|
|
24186
|
+
// alongside the cloud's Problem→Solution knowledge claim. Same shape as
|
|
24187
|
+
// PRODUCED/REVEALED_BY above — an Episode is code-layer and never drains, so
|
|
24188
|
+
// the cloud door's `to: [Solution]` rule is untouched. The `from` constraint
|
|
24189
|
+
// stays: the reversed (Solution)-FIXED_BY->(...) splash bug is the reason
|
|
24190
|
+
// this rule exists at all.
|
|
24191
|
+
FIXED_BY: { from: EDGE_RULES["FIXED_BY"]?.from, to: ["Solution", "Episode"] }
|
|
24060
24192
|
};
|
|
24061
|
-
|
|
24193
|
+
function localEdgeViolation(fromLabel, type, toLabel) {
|
|
24194
|
+
if (type in LOCAL_RULE_OVERRIDES) {
|
|
24195
|
+
const rule = LOCAL_RULE_OVERRIDES[type];
|
|
24196
|
+
if (!rule) return null;
|
|
24197
|
+
if (fromLabel && rule.from && !rule.from.includes(fromLabel)) {
|
|
24198
|
+
return `${type} cannot originate from ${fromLabel} locally (allowed: ${rule.from.join(", ")})`;
|
|
24199
|
+
}
|
|
24200
|
+
if (toLabel && rule.to && !rule.to.includes(toLabel)) {
|
|
24201
|
+
return `${type} cannot target ${toLabel} locally (allowed: ${rule.to.join(", ")})`;
|
|
24202
|
+
}
|
|
24203
|
+
return null;
|
|
24204
|
+
}
|
|
24205
|
+
const verdict = isValidEdge(fromLabel, type, toLabel);
|
|
24206
|
+
return verdict.ok ? null : verdict.reason ?? "edge rule violation";
|
|
24207
|
+
}
|
|
24208
|
+
var SCHEMA_VERSION = 6;
|
|
24062
24209
|
var SCHEMA_SQL = `
|
|
24063
24210
|
CREATE TABLE IF NOT EXISTS schema_version (
|
|
24064
24211
|
version INTEGER PRIMARY KEY
|
|
@@ -24073,6 +24220,21 @@ CREATE TABLE IF NOT EXISTS store_meta (
|
|
|
24073
24220
|
value TEXT NOT NULL
|
|
24074
24221
|
);
|
|
24075
24222
|
|
|
24223
|
+
-- Durable ledger of edges the ontology gate REFUSED, keyed by edge type.
|
|
24224
|
+
-- Durable rather than in-memory for one specific reason: the status command runs
|
|
24225
|
+
-- in a SEPARATE process and opens its own store handle, so a counter living on
|
|
24226
|
+
-- the instance reads 0 there forever. That is exactly how a producer rejecting
|
|
24227
|
+
-- 100% of its output stayed invisible for 17 days. Persisting it also survives
|
|
24228
|
+
-- the daemon restart that would otherwise erase the evidence.
|
|
24229
|
+
-- Keyed by type because a systematic producer bug shows up as ONE type
|
|
24230
|
+
-- dominating; sample keeps the latest reason so the count is actionable.
|
|
24231
|
+
CREATE TABLE IF NOT EXISTS edge_rejections (
|
|
24232
|
+
type TEXT PRIMARY KEY,
|
|
24233
|
+
count INTEGER NOT NULL DEFAULT 0,
|
|
24234
|
+
last_at INTEGER NOT NULL,
|
|
24235
|
+
sample TEXT
|
|
24236
|
+
);
|
|
24237
|
+
|
|
24076
24238
|
CREATE TABLE IF NOT EXISTS nodes (
|
|
24077
24239
|
id TEXT PRIMARY KEY,
|
|
24078
24240
|
label TEXT NOT NULL,
|
|
@@ -24335,6 +24497,13 @@ var SqliteGraphStore = class {
|
|
|
24335
24497
|
findByLabel: this.db.prepare(
|
|
24336
24498
|
"SELECT * FROM nodes WHERE label = ? AND valid_to IS NULL"
|
|
24337
24499
|
),
|
|
24500
|
+
// Scalar count twin of findByLabel — same live-row semantics, no row
|
|
24501
|
+
// hydration. Exists because status surfaces (daemon `/` + `/health`) used
|
|
24502
|
+
// findNodesByLabel(...).length, materializing every row's attrs JSON and
|
|
24503
|
+
// embedding blob per request — seconds of synchronous loop-hold per poll.
|
|
24504
|
+
countByLabel: this.db.prepare(
|
|
24505
|
+
"SELECT COUNT(*) AS n FROM nodes WHERE label = ? AND valid_to IS NULL"
|
|
24506
|
+
),
|
|
24338
24507
|
// ALL versions of a label — incl frozen/closed (valid_to set). Used by the
|
|
24339
24508
|
// clean-reindex purge so a true wipe removes history too, not just live rows.
|
|
24340
24509
|
findByLabelAll: this.db.prepare("SELECT * FROM nodes WHERE label = ?"),
|
|
@@ -24442,6 +24611,16 @@ var SqliteGraphStore = class {
|
|
|
24442
24611
|
if (!cols.has(name2)) this.db.exec(ddl);
|
|
24443
24612
|
}
|
|
24444
24613
|
}
|
|
24614
|
+
if (from < 6) {
|
|
24615
|
+
this.db.exec(`
|
|
24616
|
+
CREATE TABLE IF NOT EXISTS edge_rejections (
|
|
24617
|
+
type TEXT PRIMARY KEY,
|
|
24618
|
+
count INTEGER NOT NULL DEFAULT 0,
|
|
24619
|
+
last_at INTEGER NOT NULL,
|
|
24620
|
+
sample TEXT
|
|
24621
|
+
)
|
|
24622
|
+
`);
|
|
24623
|
+
}
|
|
24445
24624
|
this.db.prepare("UPDATE schema_version SET version = ?").run(SCHEMA_VERSION);
|
|
24446
24625
|
});
|
|
24447
24626
|
}
|
|
@@ -24523,6 +24702,7 @@ var SqliteGraphStore = class {
|
|
|
24523
24702
|
const violation = this.edgeRuleViolation(edge);
|
|
24524
24703
|
if (violation) {
|
|
24525
24704
|
this.rejectedEdgeCount++;
|
|
24705
|
+
this.recordEdgeRejection(edge.type, violation, edge.lastSeenAt || edge.createdAt || 0);
|
|
24526
24706
|
console.warn(`[local-graph] rejected edge ${edge.from}-[:${edge.type}]->${edge.to}: ${violation}`);
|
|
24527
24707
|
return;
|
|
24528
24708
|
}
|
|
@@ -24547,22 +24727,51 @@ var SqliteGraphStore = class {
|
|
|
24547
24727
|
* overlay consulted first. Returns the reason string on a documented-
|
|
24548
24728
|
* forbidden combination, else null. Point lookups on the id PK — negligible
|
|
24549
24729
|
* next to the insert itself. */
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24559
|
-
|
|
24560
|
-
|
|
24561
|
-
|
|
24562
|
-
|
|
24730
|
+
/** Upsert one refusal into the durable ledger. Best-effort: a bookkeeping
|
|
24731
|
+
* failure must never turn a refused edge into a thrown write. */
|
|
24732
|
+
recordEdgeRejection(type, reason, at) {
|
|
24733
|
+
try {
|
|
24734
|
+
this.db.prepare(
|
|
24735
|
+
`INSERT INTO edge_rejections (type, count, last_at, sample) VALUES (?, 1, ?, ?)
|
|
24736
|
+
ON CONFLICT(type) DO UPDATE SET
|
|
24737
|
+
count = count + 1, last_at = excluded.last_at, sample = excluded.sample`
|
|
24738
|
+
).run(type, at, reason.slice(0, 200));
|
|
24739
|
+
} catch {
|
|
24740
|
+
}
|
|
24741
|
+
}
|
|
24742
|
+
/** Refusals recorded by the ontology gate, per edge type, newest activity first.
|
|
24743
|
+
* Durable across restarts and readable from any process (see the table note). */
|
|
24744
|
+
edgeRejections() {
|
|
24745
|
+
try {
|
|
24746
|
+
return this.db.prepare(
|
|
24747
|
+
"SELECT type, count, last_at AS lastAt, sample FROM edge_rejections ORDER BY count DESC, last_at DESC"
|
|
24748
|
+
).all();
|
|
24749
|
+
} catch {
|
|
24750
|
+
return [];
|
|
24563
24751
|
}
|
|
24564
|
-
|
|
24565
|
-
|
|
24752
|
+
}
|
|
24753
|
+
/** Drop ledger entries whose last refusal predates `cutoff`. A still-misbehaving
|
|
24754
|
+
* producer keeps refreshing `last_at` and survives; a fixed one fades out. */
|
|
24755
|
+
pruneEdgeRejections(cutoff) {
|
|
24756
|
+
try {
|
|
24757
|
+
this.db.prepare("DELETE FROM edge_rejections WHERE last_at < ?").run(cutoff);
|
|
24758
|
+
} catch {
|
|
24759
|
+
}
|
|
24760
|
+
}
|
|
24761
|
+
/** Clear the ledger outright, whole or per type — operator escape hatch. */
|
|
24762
|
+
clearEdgeRejections(type) {
|
|
24763
|
+
try {
|
|
24764
|
+
if (type) this.db.prepare("DELETE FROM edge_rejections WHERE type = ?").run(type);
|
|
24765
|
+
else this.db.exec("DELETE FROM edge_rejections");
|
|
24766
|
+
} catch {
|
|
24767
|
+
}
|
|
24768
|
+
}
|
|
24769
|
+
edgeRuleViolation(edge) {
|
|
24770
|
+
return localEdgeViolation(
|
|
24771
|
+
this.getNode(edge.from)?.label,
|
|
24772
|
+
edge.type,
|
|
24773
|
+
this.getNode(edge.to)?.label
|
|
24774
|
+
);
|
|
24566
24775
|
}
|
|
24567
24776
|
updateEdge(id, patch) {
|
|
24568
24777
|
this.stmts.updateEdge.run({
|
|
@@ -24588,6 +24797,13 @@ var SqliteGraphStore = class {
|
|
|
24588
24797
|
const rows = this.stmts.findByLabel.all(label);
|
|
24589
24798
|
return rows.map(rowToNode);
|
|
24590
24799
|
}
|
|
24800
|
+
/** Live-row count for a label — `findNodesByLabel(label).length` without the
|
|
24801
|
+
* per-row hydration (attrs JSON + embedding blob). Status surfaces poll this
|
|
24802
|
+
* per project per request; the materializing form held the daemon's event
|
|
24803
|
+
* loop for seconds at scale. */
|
|
24804
|
+
countNodesByLabel(label) {
|
|
24805
|
+
return Number(this.stmts.countByLabel.get(label).n);
|
|
24806
|
+
}
|
|
24591
24807
|
findAllVersionsByLabel(label) {
|
|
24592
24808
|
const rows = this.stmts.findByLabelAll.all(label);
|
|
24593
24809
|
return rows.map(rowToNode);
|
|
@@ -24692,6 +24908,163 @@ var SqliteGraphStore = class {
|
|
|
24692
24908
|
const rows = this.db.prepare("SELECT from_id, to_id, type FROM edges WHERE valid_to IS NULL").all();
|
|
24693
24909
|
return rows.map((r) => ({ from: r.from_id, to: r.to_id, type: r.type }));
|
|
24694
24910
|
}
|
|
24911
|
+
getMeta(key) {
|
|
24912
|
+
const r = this.db.prepare("SELECT value FROM store_meta WHERE key = ?").get(key);
|
|
24913
|
+
return r?.value ?? null;
|
|
24914
|
+
}
|
|
24915
|
+
setMeta(key, value) {
|
|
24916
|
+
this.db.prepare(
|
|
24917
|
+
"INSERT INTO store_meta (key, value) VALUES (:key, :value) ON CONFLICT(key) DO UPDATE SET value = excluded.value"
|
|
24918
|
+
).run({ key, value });
|
|
24919
|
+
}
|
|
24920
|
+
dirtyNodeIdsSince(ts) {
|
|
24921
|
+
const rows = this.db.prepare("SELECT id FROM nodes WHERE valid_to IS NULL AND last_updated_at > ?").all(ts);
|
|
24922
|
+
return rows.map((r) => r.id);
|
|
24923
|
+
}
|
|
24924
|
+
/** Endpoints of edges TOUCHED since `ts` — created, re-seen, or CLOSED.
|
|
24925
|
+
* Closures matter as much as additions: a node that lost inflow is rank-dirty
|
|
24926
|
+
* while its own row never updated, so removal endpoints must seed the
|
|
24927
|
+
* incremental region or the stale inflow persists until the full backstop. */
|
|
24928
|
+
edgeEndpointsTouchedSince(ts) {
|
|
24929
|
+
const rows = this.db.prepare(
|
|
24930
|
+
`SELECT from_id, to_id FROM edges
|
|
24931
|
+
WHERE (valid_to IS NULL AND (created_at > :ts OR last_seen_at > :ts))
|
|
24932
|
+
OR (valid_to IS NOT NULL AND valid_to > :ts)`
|
|
24933
|
+
).all({ ts });
|
|
24934
|
+
return rows.map((r) => ({ from: r.from_id, to: r.to_id }));
|
|
24935
|
+
}
|
|
24936
|
+
/** Lightweight out-edges for a SET of sources, chunked IN-lists — the region
|
|
24937
|
+
* assembly path for incremental PageRank (per-node outEdges() at region
|
|
24938
|
+
* scale re-creates the 106k-prepared-calls problem the batch scan solved). */
|
|
24939
|
+
outEdgesForMany(ids) {
|
|
24940
|
+
return this.edgesForMany(ids, "from_id");
|
|
24941
|
+
}
|
|
24942
|
+
inEdgesForMany(ids) {
|
|
24943
|
+
return this.edgesForMany(ids, "to_id");
|
|
24944
|
+
}
|
|
24945
|
+
/** Stored pageRank for a SET of ids (live rows only — a closed id is simply
|
|
24946
|
+
* absent, which is how incremental region assembly drops dead endpoints). */
|
|
24947
|
+
ranksForMany(ids) {
|
|
24948
|
+
const out2 = /* @__PURE__ */ new Map();
|
|
24949
|
+
const CHUNK = 400;
|
|
24950
|
+
for (let i2 = 0; i2 < ids.length; i2 += CHUNK) {
|
|
24951
|
+
const chunk = ids.slice(i2, i2 + CHUNK);
|
|
24952
|
+
const placeholders = chunk.map(() => "?").join(", ");
|
|
24953
|
+
const rows = this.db.prepare(
|
|
24954
|
+
`SELECT id, page_rank FROM nodes WHERE id IN (${placeholders}) AND valid_to IS NULL`
|
|
24955
|
+
).all(...chunk);
|
|
24956
|
+
for (const r of rows) out2.set(r.id, r.page_rank);
|
|
24957
|
+
}
|
|
24958
|
+
return out2;
|
|
24959
|
+
}
|
|
24960
|
+
/** The minimal row set the landmark sweep needs — landmark CANDIDATES
|
|
24961
|
+
* (Pattern/RootCause), everything currently flagged, and every
|
|
24962
|
+
* persistent-tier node (force-landmarks). A few thousand rows, so the
|
|
24963
|
+
* incremental path can refresh the GLOBAL landmark set without the 179k-row
|
|
24964
|
+
* scanLiveNodes materialization. */
|
|
24965
|
+
landmarkSweepRows() {
|
|
24966
|
+
const rows = this.db.prepare(
|
|
24967
|
+
`SELECT id, label, page_rank, is_landmark, memory_tier, extraction_source FROM nodes
|
|
24968
|
+
WHERE valid_to IS NULL
|
|
24969
|
+
AND (memory_tier = 'persistent' OR is_landmark = 1 OR label IN ('Pattern', 'RootCause'))`
|
|
24970
|
+
).all();
|
|
24971
|
+
return rows.map((r) => ({
|
|
24972
|
+
id: r.id,
|
|
24973
|
+
label: r.label,
|
|
24974
|
+
pageRank: r.page_rank,
|
|
24975
|
+
isLandmark: r.is_landmark === 1,
|
|
24976
|
+
memoryTier: r.memory_tier,
|
|
24977
|
+
extractionSource: r.extraction_source
|
|
24978
|
+
}));
|
|
24979
|
+
}
|
|
24980
|
+
edgesForMany(ids, col) {
|
|
24981
|
+
const out2 = [];
|
|
24982
|
+
const CHUNK = 400;
|
|
24983
|
+
for (let i2 = 0; i2 < ids.length; i2 += CHUNK) {
|
|
24984
|
+
const chunk = ids.slice(i2, i2 + CHUNK);
|
|
24985
|
+
const placeholders = chunk.map(() => "?").join(", ");
|
|
24986
|
+
const rows = this.db.prepare(
|
|
24987
|
+
`SELECT from_id, to_id, type FROM edges WHERE ${col} IN (${placeholders}) AND valid_to IS NULL`
|
|
24988
|
+
).all(...chunk);
|
|
24989
|
+
for (const r of rows) out2.push({ from: r.from_id, to: r.to_id, type: r.type });
|
|
24990
|
+
}
|
|
24991
|
+
return out2;
|
|
24992
|
+
}
|
|
24993
|
+
checkpointWal() {
|
|
24994
|
+
try {
|
|
24995
|
+
const r = this.db.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get();
|
|
24996
|
+
return r ?? null;
|
|
24997
|
+
} catch {
|
|
24998
|
+
return null;
|
|
24999
|
+
}
|
|
25000
|
+
}
|
|
25001
|
+
reviveReobserved(relPaths, workspaceId, since) {
|
|
25002
|
+
let revived = 0;
|
|
25003
|
+
const CHUNK = 400;
|
|
25004
|
+
for (let i2 = 0; i2 < relPaths.length; i2 += CHUNK) {
|
|
25005
|
+
const slice = relPaths.slice(i2, i2 + CHUNK);
|
|
25006
|
+
if (slice.length === 0) continue;
|
|
25007
|
+
const r = this.db.prepare(
|
|
25008
|
+
`UPDATE nodes SET valid_to = NULL
|
|
25009
|
+
WHERE valid_to IS NOT NULL
|
|
25010
|
+
AND last_updated_at >= ?
|
|
25011
|
+
AND json_extract(attrs_json, '$.workspaceId') = ?
|
|
25012
|
+
AND json_extract(attrs_json, '$.relPath') IN (${slice.map(() => "?").join(",")})`
|
|
25013
|
+
).run(since, workspaceId, ...slice);
|
|
25014
|
+
revived += Number(r.changes);
|
|
25015
|
+
}
|
|
25016
|
+
if (revived > 0) this.mutations++;
|
|
25017
|
+
return revived;
|
|
25018
|
+
}
|
|
25019
|
+
recentEdgeAttrCoverage(marker, attr, limit) {
|
|
25020
|
+
const r = this.db.prepare(
|
|
25021
|
+
`SELECT COUNT(*) AS total,
|
|
25022
|
+
COALESCE(SUM(CASE WHEN json_extract(attrs_json, '$.' || ?) = 1 THEN 1 ELSE 0 END), 0) AS count
|
|
25023
|
+
FROM (SELECT attrs_json FROM edges
|
|
25024
|
+
WHERE valid_to IS NULL AND attrs_json LIKE ?
|
|
25025
|
+
ORDER BY created_at DESC LIMIT ?)`
|
|
25026
|
+
).get(attr, `%${marker}%`, limit);
|
|
25027
|
+
return { count: Number(r.count), total: Number(r.total) };
|
|
25028
|
+
}
|
|
25029
|
+
liveNodeIds(ids) {
|
|
25030
|
+
const live = /* @__PURE__ */ new Set();
|
|
25031
|
+
const CHUNK = 900;
|
|
25032
|
+
for (let i2 = 0; i2 < ids.length; i2 += CHUNK) {
|
|
25033
|
+
const slice = ids.slice(i2, i2 + CHUNK);
|
|
25034
|
+
if (slice.length === 0) continue;
|
|
25035
|
+
const rows = this.db.prepare(
|
|
25036
|
+
`SELECT id FROM nodes WHERE valid_to IS NULL AND id IN (${slice.map(() => "?").join(",")})`
|
|
25037
|
+
).all(...slice);
|
|
25038
|
+
for (const r of rows) live.add(r.id);
|
|
25039
|
+
}
|
|
25040
|
+
return live;
|
|
25041
|
+
}
|
|
25042
|
+
/**
|
|
25043
|
+
* Live edges WITH their endpoint labels and ids, resolved in ONE join.
|
|
25044
|
+
*
|
|
25045
|
+
* The ontology sweep needs (id, type, fromLabel, toLabel) for every live edge.
|
|
25046
|
+
* Doing that as `scanLiveEdges()` + two `getNode()` calls is 2N node reads —
|
|
25047
|
+
* 550,000 on this store — and each one deserializes the node's embedding blob.
|
|
25048
|
+
* Measured: the sweep did not finish in 10 minutes. As a single join it is one
|
|
25049
|
+
* query over an index-covered scan. Labels only; nothing here touches embeddings.
|
|
25050
|
+
*/
|
|
25051
|
+
scanLiveEdgeRows() {
|
|
25052
|
+
const rows = this.db.prepare(
|
|
25053
|
+
`SELECT e.id, e.from_id, e.to_id, e.type, a.label AS from_label, b.label AS to_label
|
|
25054
|
+
FROM edges e
|
|
25055
|
+
LEFT JOIN nodes a ON a.id = e.from_id AND a.valid_to IS NULL
|
|
25056
|
+
LEFT JOIN nodes b ON b.id = e.to_id AND b.valid_to IS NULL
|
|
25057
|
+
WHERE e.valid_to IS NULL`
|
|
25058
|
+
).all();
|
|
25059
|
+
return rows.map((r) => ({
|
|
25060
|
+
id: r.id,
|
|
25061
|
+
from: r.from_id,
|
|
25062
|
+
to: r.to_id,
|
|
25063
|
+
type: r.type,
|
|
25064
|
+
fromLabel: r.from_label ?? void 0,
|
|
25065
|
+
toLabel: r.to_label ?? void 0
|
|
25066
|
+
}));
|
|
25067
|
+
}
|
|
24695
25068
|
/** Live nodes whose attrs.relPath is one of `relPaths`. Uses the nodes_relpath
|
|
24696
25069
|
* expression index so the incremental reindex fetches only the changed files'
|
|
24697
25070
|
* symbols instead of scanning every versioned node. */
|
|
@@ -24712,6 +25085,10 @@ var SqliteGraphStore = class {
|
|
|
24712
25085
|
if (!live) return null;
|
|
24713
25086
|
const version2 = live.version ?? 1;
|
|
24714
25087
|
const frozenId = `${liveId}@v${version2}`;
|
|
25088
|
+
if (this.getNode(frozenId)) {
|
|
25089
|
+
this.stmts.advanceLive.run({ live_id: liveId, t });
|
|
25090
|
+
return frozenId;
|
|
25091
|
+
}
|
|
24715
25092
|
this.stmts.freezeCopy.run({ frozen_id: frozenId, live_id: liveId, t });
|
|
24716
25093
|
this.mergeEdge({
|
|
24717
25094
|
id: `edge_superseded_${frozenId}`,
|
|
@@ -24770,6 +25147,7 @@ var CAUSAL_FAMILY = [
|
|
|
24770
25147
|
|
|
24771
25148
|
// ../../packages/local-graph/src/justification.ts
|
|
24772
25149
|
init_src();
|
|
25150
|
+
init_src2();
|
|
24773
25151
|
function addDependency(store2, opts) {
|
|
24774
25152
|
const id = digest({ from: opts.fromId, type: "DEPENDS_ON", to: opts.toId });
|
|
24775
25153
|
const attrs = { relation: opts.relation };
|
|
@@ -24792,13 +25170,72 @@ function addDependency(store2, opts) {
|
|
|
24792
25170
|
store2.mergeEdge(edge);
|
|
24793
25171
|
return edge;
|
|
24794
25172
|
}
|
|
24795
|
-
function markRevisit(store2, node, reason, ts) {
|
|
25173
|
+
function markRevisit(store2, node, reason, ts, answeredWhen) {
|
|
24796
25174
|
const fresh = store2.getNode(node.id) ?? node;
|
|
24797
25175
|
store2.updateNode(node.id, {
|
|
24798
|
-
attrs: {
|
|
25176
|
+
attrs: {
|
|
25177
|
+
...fresh.attrs,
|
|
25178
|
+
revisit: true,
|
|
25179
|
+
revisitReason: reason,
|
|
25180
|
+
revisitSinceTs: ts,
|
|
25181
|
+
revisitAnsweredWhen: answeredWhen
|
|
25182
|
+
},
|
|
24799
25183
|
lastUpdatedAt: ts
|
|
24800
25184
|
});
|
|
24801
25185
|
}
|
|
25186
|
+
var LEGACY_AUTO_CLOSE_ASK = "auto-closed off a pre-provenance anchor";
|
|
25187
|
+
var KNOWN_CONDITIONS = {
|
|
25188
|
+
parentProblemOpen: true,
|
|
25189
|
+
dependentStale: true
|
|
25190
|
+
};
|
|
25191
|
+
function isRevisitCondition(v) {
|
|
25192
|
+
return typeof v === "string" && Object.prototype.hasOwnProperty.call(KNOWN_CONDITIONS, v);
|
|
25193
|
+
}
|
|
25194
|
+
function conditionOf(node) {
|
|
25195
|
+
const explicit = node.attrs["revisitAnsweredWhen"];
|
|
25196
|
+
if (isRevisitCondition(explicit)) return explicit;
|
|
25197
|
+
if (String(node.attrs["revisitReason"] ?? "").startsWith(LEGACY_AUTO_CLOSE_ASK)) {
|
|
25198
|
+
return "parentProblemOpen";
|
|
25199
|
+
}
|
|
25200
|
+
return void 0;
|
|
25201
|
+
}
|
|
25202
|
+
function clearAnsweredRevisits(store2, ts) {
|
|
25203
|
+
const report = { cleared: 0, standing: 0 };
|
|
25204
|
+
for (const label of SEMANTIC_NODE_LABELS) {
|
|
25205
|
+
for (const node of store2.findNodesByLabel(label)) {
|
|
25206
|
+
if (node.attrs["revisit"] !== true) continue;
|
|
25207
|
+
const condition = conditionOf(node);
|
|
25208
|
+
if (condition === void 0 || !isRevisitAnswered(store2, node, condition)) {
|
|
25209
|
+
report.standing++;
|
|
25210
|
+
continue;
|
|
25211
|
+
}
|
|
25212
|
+
clearRevisit(store2, node.id, ts);
|
|
25213
|
+
report.cleared++;
|
|
25214
|
+
}
|
|
25215
|
+
}
|
|
25216
|
+
return report;
|
|
25217
|
+
}
|
|
25218
|
+
function isRevisitAnswered(store2, node, condition) {
|
|
25219
|
+
switch (condition) {
|
|
25220
|
+
case "parentProblemOpen": {
|
|
25221
|
+
const parents = store2.inEdges(node.id, ["SOLVED_BY"]).map((e) => store2.getNode(e.from)).filter((n) => n !== null && n.validTo == null);
|
|
25222
|
+
return parents.every((p) => p.attrs["resolvedAt"] == null);
|
|
25223
|
+
}
|
|
25224
|
+
case "dependentStale": {
|
|
25225
|
+
const since = Number(node.attrs["revisitSinceTs"] ?? 0);
|
|
25226
|
+
return since > 0 && node.lastUpdatedAt > since;
|
|
25227
|
+
}
|
|
25228
|
+
}
|
|
25229
|
+
}
|
|
25230
|
+
function clearRevisit(store2, nodeId, ts) {
|
|
25231
|
+
const n = store2.getNode(nodeId);
|
|
25232
|
+
if (!n) return;
|
|
25233
|
+
const attrs = { ...n.attrs };
|
|
25234
|
+
delete attrs["revisit"];
|
|
25235
|
+
delete attrs["revisitReason"];
|
|
25236
|
+
delete attrs["revisitSinceTs"];
|
|
25237
|
+
store2.updateNode(nodeId, { attrs, lastUpdatedAt: ts });
|
|
25238
|
+
}
|
|
24802
25239
|
function listNeedsRevisit(store2, asOf) {
|
|
24803
25240
|
return store2.nodesAsOf(asOf).filter((n) => n.attrs["revisit"] === true).map((n) => ({
|
|
24804
25241
|
id: n.id,
|
|
@@ -24931,7 +25368,6 @@ function markBoth(store2, a, b, patch, ts) {
|
|
|
24931
25368
|
// ../../packages/local-graph/src/design-problem.ts
|
|
24932
25369
|
init_src();
|
|
24933
25370
|
init_src();
|
|
24934
|
-
init_src2();
|
|
24935
25371
|
|
|
24936
25372
|
// ../../packages/local-graph/src/problem-package-link.ts
|
|
24937
25373
|
init_src();
|
|
@@ -25117,42 +25553,102 @@ function backfillProblemContext(store2, ts) {
|
|
|
25117
25553
|
}
|
|
25118
25554
|
|
|
25119
25555
|
// ../../packages/local-graph/src/design-problem.ts
|
|
25120
|
-
|
|
25121
|
-
|
|
25122
|
-
|
|
25123
|
-
|
|
25124
|
-
|
|
25125
|
-
|
|
25126
|
-
|
|
25127
|
-
|
|
25128
|
-
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
|
|
25132
|
-
|
|
25133
|
-
|
|
25134
|
-
|
|
25135
|
-
pageRank: 0,
|
|
25136
|
-
isLandmark: false,
|
|
25137
|
-
community: null,
|
|
25138
|
-
stability: "unstable",
|
|
25139
|
-
attrs
|
|
25140
|
-
};
|
|
25556
|
+
init_src2();
|
|
25557
|
+
|
|
25558
|
+
// ../../packages/local-graph/src/problem-dedup.ts
|
|
25559
|
+
init_src();
|
|
25560
|
+
init_src();
|
|
25561
|
+
var REDIRECT_EDGES = [
|
|
25562
|
+
"CAUSED_BY",
|
|
25563
|
+
"SOLVED_BY",
|
|
25564
|
+
"FIXED_BY",
|
|
25565
|
+
"ANCHORED_AT",
|
|
25566
|
+
"MANIFESTED_IN",
|
|
25567
|
+
"EVIDENCED_BY"
|
|
25568
|
+
];
|
|
25569
|
+
function corroborations(n) {
|
|
25570
|
+
return Number(n.attrs["corroborations"] ?? 0);
|
|
25141
25571
|
}
|
|
25142
|
-
function
|
|
25143
|
-
|
|
25144
|
-
|
|
25145
|
-
|
|
25146
|
-
|
|
25147
|
-
|
|
25148
|
-
|
|
25149
|
-
|
|
25150
|
-
|
|
25151
|
-
|
|
25152
|
-
|
|
25153
|
-
|
|
25154
|
-
|
|
25572
|
+
function overlap(a, b) {
|
|
25573
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
25574
|
+
let inter = 0;
|
|
25575
|
+
for (const x of a) if (b.has(x)) inter++;
|
|
25576
|
+
return inter / Math.min(a.size, b.size);
|
|
25577
|
+
}
|
|
25578
|
+
function mergeDuplicateProblems(store2, opts) {
|
|
25579
|
+
const minOverlap = opts.minOverlap ?? 0.85;
|
|
25580
|
+
const minTokens = opts.minTokens ?? 4;
|
|
25581
|
+
const report = { clusters: 0, merged: 0 };
|
|
25582
|
+
const open = store2.findNodesByLabel("Problem").filter((p) => p.attrs["resolvedAt"] == null && p.attrs["mergedInto"] === void 0);
|
|
25583
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
25584
|
+
for (const p of open) tokens.set(p.id, new Set(retrievalTokens(p.description)));
|
|
25585
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
25586
|
+
store2.transaction(() => {
|
|
25587
|
+
for (let i2 = 0; i2 < open.length; i2++) {
|
|
25588
|
+
const a = open[i2];
|
|
25589
|
+
if (consumed.has(a.id)) continue;
|
|
25590
|
+
const cluster = [a];
|
|
25591
|
+
const ta = tokens.get(a.id);
|
|
25592
|
+
for (let j = i2 + 1; j < open.length; j++) {
|
|
25593
|
+
const b = open[j];
|
|
25594
|
+
if (consumed.has(b.id)) continue;
|
|
25595
|
+
const tb = tokens.get(b.id);
|
|
25596
|
+
if (Math.min(ta.size, tb.size) < minTokens) continue;
|
|
25597
|
+
if (isConstraintProblem(a) !== isConstraintProblem(b)) continue;
|
|
25598
|
+
if (overlap(ta, tb) >= minOverlap) {
|
|
25599
|
+
cluster.push(b);
|
|
25600
|
+
consumed.add(b.id);
|
|
25601
|
+
}
|
|
25602
|
+
}
|
|
25603
|
+
if (cluster.length < 2) continue;
|
|
25604
|
+
report.clusters++;
|
|
25605
|
+
cluster.sort((x, y) => corroborations(y) - corroborations(x) || x.createdAt - y.createdAt);
|
|
25606
|
+
const survivor = cluster[0];
|
|
25607
|
+
for (const dup of cluster.slice(1)) {
|
|
25608
|
+
foldDuplicateProblem(store2, dup, survivor, opts.ts);
|
|
25609
|
+
report.merged++;
|
|
25610
|
+
}
|
|
25611
|
+
}
|
|
25155
25612
|
});
|
|
25613
|
+
return report;
|
|
25614
|
+
}
|
|
25615
|
+
function foldDuplicateProblem(store2, dup, survivor, ts) {
|
|
25616
|
+
const surv = store2.getNode(survivor.id);
|
|
25617
|
+
if (!surv) return;
|
|
25618
|
+
const sources = new Set(surv.attrs["sources"] ?? []);
|
|
25619
|
+
for (const s of dup.attrs["sources"] ?? []) sources.add(s);
|
|
25620
|
+
store2.updateNode(survivor.id, {
|
|
25621
|
+
attrs: {
|
|
25622
|
+
...surv.attrs,
|
|
25623
|
+
sources: [...sources],
|
|
25624
|
+
corroborations: corroborations(surv) + corroborations(dup) + 1
|
|
25625
|
+
},
|
|
25626
|
+
cumulativeHits: (surv.cumulativeHits ?? 0) + (dup.cumulativeHits ?? 0),
|
|
25627
|
+
lastUpdatedAt: ts
|
|
25628
|
+
});
|
|
25629
|
+
for (const e of store2.outEdges(dup.id, REDIRECT_EDGES)) {
|
|
25630
|
+
if (e.to === survivor.id) continue;
|
|
25631
|
+
const id = `edge_${digest({ from: survivor.id, type: e.type, to: e.to })}`.slice(0, 24);
|
|
25632
|
+
if (store2.getEdge(id)) continue;
|
|
25633
|
+
const redirected = {
|
|
25634
|
+
...e,
|
|
25635
|
+
id,
|
|
25636
|
+
from: survivor.id,
|
|
25637
|
+
createdAt: ts,
|
|
25638
|
+
lastSeenAt: ts
|
|
25639
|
+
};
|
|
25640
|
+
store2.mergeEdge(redirected);
|
|
25641
|
+
}
|
|
25642
|
+
store2.updateNode(dup.id, {
|
|
25643
|
+
attrs: { ...dup.attrs, mergedInto: survivor.id, resolvedAs: "duplicate", resolvedAt: ts },
|
|
25644
|
+
lastUpdatedAt: ts
|
|
25645
|
+
});
|
|
25646
|
+
store2.closeNode(dup.id, ts);
|
|
25647
|
+
}
|
|
25648
|
+
|
|
25649
|
+
// ../../packages/local-graph/src/design-problem.ts
|
|
25650
|
+
function isConstraintProblem(node) {
|
|
25651
|
+
return node.attrs["kind"] === "constraint";
|
|
25156
25652
|
}
|
|
25157
25653
|
var CITABLE_PRIOR_LABELS = /* @__PURE__ */ new Set([
|
|
25158
25654
|
"Solution",
|
|
@@ -25161,6 +25657,9 @@ var CITABLE_PRIOR_LABELS = /* @__PURE__ */ new Set([
|
|
|
25161
25657
|
"Technique",
|
|
25162
25658
|
"AntiPattern"
|
|
25163
25659
|
]);
|
|
25660
|
+
function isAutoMinted(n) {
|
|
25661
|
+
return n.label === "Solution" && String(n.description ?? "").startsWith(AUTO_MINT_PREFIX);
|
|
25662
|
+
}
|
|
25164
25663
|
function priorsForFile(store2, relPath) {
|
|
25165
25664
|
const want = relPath.trim().replace(/^\.?\//, "");
|
|
25166
25665
|
let file2 = null;
|
|
@@ -25172,35 +25671,53 @@ function priorsForFile(store2, relPath) {
|
|
|
25172
25671
|
}
|
|
25173
25672
|
if (!file2) return null;
|
|
25174
25673
|
const openProblems = [];
|
|
25674
|
+
const constraints = [];
|
|
25675
|
+
const resolvedProblems = [];
|
|
25175
25676
|
const seenProblem = /* @__PURE__ */ new Set();
|
|
25176
25677
|
const related = /* @__PURE__ */ new Map();
|
|
25177
25678
|
for (const e of store2.inEdges(file2.id, ["ANCHORED_AT"])) {
|
|
25178
25679
|
const n = store2.getNode(e.from);
|
|
25179
25680
|
if (!n) continue;
|
|
25180
25681
|
if (n.label === "Problem") {
|
|
25181
|
-
if (
|
|
25182
|
-
|
|
25183
|
-
|
|
25184
|
-
|
|
25185
|
-
|
|
25682
|
+
if (seenProblem.has(n.id)) continue;
|
|
25683
|
+
seenProblem.add(n.id);
|
|
25684
|
+
if (!n.attrs["resolvedAt"]) {
|
|
25685
|
+
(isConstraintProblem(n) ? constraints : openProblems).push(n);
|
|
25686
|
+
} else if (n.attrs["resolvedAs"] == null && n.attrs["mergedInto"] === void 0 && e.attrs?.["anchorProvenance"] !== "legacy") {
|
|
25687
|
+
resolvedProblems.push(n);
|
|
25688
|
+
}
|
|
25689
|
+
} else if (CITABLE_PRIOR_LABELS.has(n.label) && !isAutoMinted(n)) {
|
|
25186
25690
|
related.set(n.id, n);
|
|
25187
25691
|
}
|
|
25188
25692
|
}
|
|
25189
25693
|
const solutionsByProblem = /* @__PURE__ */ new Map();
|
|
25190
|
-
for (const p of openProblems) {
|
|
25694
|
+
for (const p of [...openProblems, ...constraints, ...resolvedProblems]) {
|
|
25191
25695
|
for (const e of store2.outEdges(p.id, ["SOLVED_BY", "CAUSED_BY", "INSTANCE_OF"])) {
|
|
25192
25696
|
const n = store2.getNode(e.to);
|
|
25193
|
-
if (n && CITABLE_PRIOR_LABELS.has(n.label)) related.set(n.id, n);
|
|
25194
|
-
if (n && n.label === "Solution" && e.type === "SOLVED_BY") {
|
|
25697
|
+
if (n && CITABLE_PRIOR_LABELS.has(n.label) && !isAutoMinted(n)) related.set(n.id, n);
|
|
25698
|
+
if (n && n.label === "Solution" && e.type === "SOLVED_BY" && !isAutoMinted(n)) {
|
|
25195
25699
|
const list = solutionsByProblem.get(p.id) ?? [];
|
|
25196
25700
|
if (!list.some((s) => s.id === n.id)) list.push(n);
|
|
25197
25701
|
solutionsByProblem.set(p.id, list);
|
|
25198
25702
|
}
|
|
25199
25703
|
}
|
|
25200
25704
|
}
|
|
25201
|
-
if (openProblems.length === 0 && related.size === 0)
|
|
25202
|
-
|
|
25203
|
-
|
|
25705
|
+
if (openProblems.length === 0 && constraints.length === 0 && resolvedProblems.length === 0 && related.size === 0)
|
|
25706
|
+
return null;
|
|
25707
|
+
const recentFirst = (a, b) => (b.lastUpdatedAt ?? 0) - (a.lastUpdatedAt ?? 0);
|
|
25708
|
+
openProblems.sort(recentFirst);
|
|
25709
|
+
constraints.sort(recentFirst);
|
|
25710
|
+
resolvedProblems.sort(
|
|
25711
|
+
(a, b) => Number(b.attrs["resolvedAt"] ?? 0) - Number(a.attrs["resolvedAt"] ?? 0)
|
|
25712
|
+
);
|
|
25713
|
+
return {
|
|
25714
|
+
file: file2,
|
|
25715
|
+
openProblems,
|
|
25716
|
+
constraints,
|
|
25717
|
+
resolvedProblems,
|
|
25718
|
+
related: [...related.values()],
|
|
25719
|
+
solutionsByProblem
|
|
25720
|
+
};
|
|
25204
25721
|
}
|
|
25205
25722
|
function recordAnchorHint(store2, problemId, relPath, provenance, ts) {
|
|
25206
25723
|
const p = store2.getNode(problemId);
|
|
@@ -25211,18 +25728,49 @@ function recordAnchorHint(store2, problemId, relPath, provenance, ts) {
|
|
|
25211
25728
|
});
|
|
25212
25729
|
return true;
|
|
25213
25730
|
}
|
|
25214
|
-
function
|
|
25731
|
+
function reopenAutoClosedProblems(store2, t) {
|
|
25732
|
+
const report = { reopened: 0, alreadySuspect: 0, agentDescribed: 0 };
|
|
25733
|
+
for (const p of store2.findNodesByLabel("Problem")) {
|
|
25734
|
+
if (p.attrs["resolvedAt"] == null) continue;
|
|
25735
|
+
if (p.attrs["resolvedAs"] != null) continue;
|
|
25736
|
+
if (p.attrs["mergedInto"] !== void 0) continue;
|
|
25737
|
+
if (p.attrs["resolutionWitnessed"] === true) {
|
|
25738
|
+
report.agentDescribed++;
|
|
25739
|
+
continue;
|
|
25740
|
+
}
|
|
25741
|
+
const sols = store2.outEdges(p.id, ["SOLVED_BY"]).map((e) => store2.getNode(e.to)).filter((n) => n !== null);
|
|
25742
|
+
if (sols.length === 0) continue;
|
|
25743
|
+
if (!sols.every((s) => String(s.description ?? "").startsWith(AUTO_MINT_PREFIX))) {
|
|
25744
|
+
report.agentDescribed++;
|
|
25745
|
+
continue;
|
|
25746
|
+
}
|
|
25747
|
+
if (p.attrs["resolutionSuspect"] === true) report.alreadySuspect++;
|
|
25748
|
+
const attrs = { ...p.attrs };
|
|
25749
|
+
delete attrs["resolvedAt"];
|
|
25750
|
+
attrs["reopenedFrom"] = "auto-close";
|
|
25751
|
+
attrs["reopenedAt"] = t;
|
|
25752
|
+
store2.updateNode(p.id, { attrs, lastUpdatedAt: t });
|
|
25753
|
+
report.reopened++;
|
|
25754
|
+
}
|
|
25755
|
+
return report;
|
|
25756
|
+
}
|
|
25757
|
+
var AUTO_MINT_PREFIX = "addressed by an edit to ";
|
|
25758
|
+
function markFixCandidates(store2, t) {
|
|
25215
25759
|
let resolved = 0;
|
|
25216
25760
|
for (const p of store2.findNodesByLabel("Problem")) {
|
|
25217
25761
|
if (!p.id.startsWith("dprob_")) continue;
|
|
25218
25762
|
if (p.attrs["resolvedAt"]) continue;
|
|
25763
|
+
if (isConstraintProblem(p)) continue;
|
|
25219
25764
|
let symName = "";
|
|
25220
25765
|
let symRelPath;
|
|
25221
25766
|
let edited = false;
|
|
25767
|
+
const since = Math.max(p.createdAt, Number(p.attrs["fixCandidateClearedAt"] ?? 0));
|
|
25222
25768
|
for (const e of store2.outEdges(p.id, ["ANCHORED_AT"])) {
|
|
25223
25769
|
if (e.attrs?.["mention"] === true) continue;
|
|
25770
|
+
if (e.attrs?.["anchorProvenance"] === "legacy") continue;
|
|
25224
25771
|
const sym = store2.getNode(e.to);
|
|
25225
|
-
|
|
25772
|
+
const changedAt = sym?.label === "File" ? Number(sym.attrs["contentChangedAt"] ?? 0) : sym?.lastUpdatedAt ?? 0;
|
|
25773
|
+
if (sym && changedAt > since) {
|
|
25226
25774
|
edited = true;
|
|
25227
25775
|
symName = sym.description;
|
|
25228
25776
|
symRelPath = sym.attrs["relPath"] ?? void 0;
|
|
@@ -25230,36 +25778,172 @@ function resolveDesignProblems(store2, t) {
|
|
|
25230
25778
|
}
|
|
25231
25779
|
}
|
|
25232
25780
|
if (!edited) continue;
|
|
25233
|
-
if (
|
|
25234
|
-
|
|
25235
|
-
store2.
|
|
25236
|
-
|
|
25237
|
-
|
|
25238
|
-
|
|
25239
|
-
// AC-resolution-attrs: the resolving symbol/file as STRUCTURED data, not
|
|
25240
|
-
// just prose — the F2 join key downstream backfills and the viz read.
|
|
25241
|
-
resolvedSymbols: [symName],
|
|
25242
|
-
...symRelPath ? { resolvedRelPath: symRelPath } : {}
|
|
25243
|
-
})
|
|
25244
|
-
);
|
|
25245
|
-
mergeEdge(store2, p.id, solId, "SOLVED_BY", t);
|
|
25246
|
-
for (const ae of store2.outEdges(p.id, ["ANCHORED_AT"]))
|
|
25247
|
-
mergeEdge(store2, solId, ae.to, "ANCHORED_AT", t);
|
|
25248
|
-
}
|
|
25781
|
+
if (p.attrs["fixCandidateAt"] !== void 0) continue;
|
|
25782
|
+
if (store2.outEdges(p.id, ["SOLVED_BY"]).some((e) => {
|
|
25783
|
+
const s = store2.getNode(e.to);
|
|
25784
|
+
return s !== null && !String(s.description ?? "").startsWith(AUTO_MINT_PREFIX);
|
|
25785
|
+
}))
|
|
25786
|
+
continue;
|
|
25249
25787
|
store2.updateNode(p.id, {
|
|
25250
|
-
attrs: {
|
|
25788
|
+
attrs: {
|
|
25789
|
+
...p.attrs,
|
|
25790
|
+
// The cue, kept as structured data so the render can name the file it is
|
|
25791
|
+
// asking about. Deliberately NOT `resolvedAt` — this is a question.
|
|
25792
|
+
fixCandidateAt: t,
|
|
25793
|
+
fixCandidateSymbol: symName,
|
|
25794
|
+
...symRelPath ? { fixCandidateFile: symRelPath } : {},
|
|
25795
|
+
// Snapshot the render-ledger counter so "shown since THIS ask" is
|
|
25796
|
+
// measurable. `shownCount` is the node's LIFETIME count across every
|
|
25797
|
+
// band, so comparing it raw would retire a fresh ask on a
|
|
25798
|
+
// frequently-surfaced problem before anyone had seen the question once.
|
|
25799
|
+
fixCandidateShownBase: Number(p.attrs["shownCount"] ?? 0)
|
|
25800
|
+
},
|
|
25251
25801
|
lastUpdatedAt: t
|
|
25252
25802
|
});
|
|
25253
25803
|
resolved++;
|
|
25254
25804
|
}
|
|
25255
25805
|
return resolved;
|
|
25256
25806
|
}
|
|
25807
|
+
var FIX_CANDIDATE_ASK_LIMIT = 5;
|
|
25808
|
+
function clearSettledFixCandidates(store2, t) {
|
|
25809
|
+
const report = { answered: 0, ignored: 0, unsubstantiated: 0, standing: 0 };
|
|
25810
|
+
for (const p of store2.findNodesByLabel("Problem")) {
|
|
25811
|
+
if (p.attrs["fixCandidateAt"] === void 0) continue;
|
|
25812
|
+
const fileAnchors = store2.outEdges(p.id, ["ANCHORED_AT"]).filter((e) => e.attrs?.["mention"] !== true && e.attrs?.["anchorProvenance"] !== "legacy").map((e) => store2.getNode(e.to)).filter((n) => n !== null && n.label === "File");
|
|
25813
|
+
const unsubstantiated = fileAnchors.length > 0 && fileAnchors.every((f) => f.attrs["contentChangedAt"] === void 0);
|
|
25814
|
+
const answered = p.attrs["resolvedAt"] != null || store2.outEdges(p.id, ["SOLVED_BY"]).some((e) => {
|
|
25815
|
+
const s = store2.getNode(e.to);
|
|
25816
|
+
return s !== null && !String(s.description ?? "").startsWith(AUTO_MINT_PREFIX);
|
|
25817
|
+
});
|
|
25818
|
+
const base = Number(
|
|
25819
|
+
p.attrs["fixCandidateShownBase"] ?? p.attrs["shownCount"] ?? 0
|
|
25820
|
+
);
|
|
25821
|
+
const shownSinceAsk = Number(p.attrs["shownCount"] ?? 0) - base;
|
|
25822
|
+
const ignored = shownSinceAsk >= FIX_CANDIDATE_ASK_LIMIT;
|
|
25823
|
+
if (!answered && !ignored && !unsubstantiated) {
|
|
25824
|
+
report.standing++;
|
|
25825
|
+
continue;
|
|
25826
|
+
}
|
|
25827
|
+
const attrs = { ...p.attrs };
|
|
25828
|
+
delete attrs["fixCandidateAt"];
|
|
25829
|
+
delete attrs["fixCandidateSymbol"];
|
|
25830
|
+
delete attrs["fixCandidateFile"];
|
|
25831
|
+
attrs["fixCandidateClearedAt"] = t;
|
|
25832
|
+
store2.updateNode(p.id, { attrs, lastUpdatedAt: t });
|
|
25833
|
+
if (answered) report.answered++;
|
|
25834
|
+
else if (ignored) report.ignored++;
|
|
25835
|
+
else report.unsubstantiated++;
|
|
25836
|
+
}
|
|
25837
|
+
return report;
|
|
25838
|
+
}
|
|
25839
|
+
|
|
25840
|
+
// ../../packages/local-graph/src/intent.ts
|
|
25841
|
+
init_src();
|
|
25257
25842
|
|
|
25258
25843
|
// ../../packages/local-graph/src/anchor-backfill.ts
|
|
25259
|
-
|
|
25844
|
+
init_src();
|
|
25845
|
+
init_src2();
|
|
25260
25846
|
function isLegacyAnchor(attrs) {
|
|
25261
25847
|
return attrs?.["captureTime"] === true && attrs["anchorProvenance"] === void 0;
|
|
25262
25848
|
}
|
|
25849
|
+
var STATEMENT_PATH_RE = new RegExp(
|
|
25850
|
+
String.raw`(?:[\w.+-]+\/)+[\w.+-]+\.(?:${anchorableExtensionAlternation()})`,
|
|
25851
|
+
"g"
|
|
25852
|
+
);
|
|
25853
|
+
function repairLegacyAnchorsFromStatement(store2, ts) {
|
|
25854
|
+
const report = {
|
|
25855
|
+
repaired: [],
|
|
25856
|
+
retiredGuesses: 0,
|
|
25857
|
+
noPathNamed: 0,
|
|
25858
|
+
pathUnknown: 0,
|
|
25859
|
+
alreadyCorrect: 0
|
|
25860
|
+
};
|
|
25861
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
25862
|
+
for (const f of store2.findNodesByLabel("File")) {
|
|
25863
|
+
const path = String(f.attrs["relPath"] ?? f.description ?? "");
|
|
25864
|
+
if (path) byPath.set(path, { id: f.id, path });
|
|
25865
|
+
}
|
|
25866
|
+
const resolvePath = (named) => {
|
|
25867
|
+
const exact = byPath.get(named);
|
|
25868
|
+
if (exact) return exact;
|
|
25869
|
+
const hits = [...byPath.values()].filter(
|
|
25870
|
+
(f) => f.path.endsWith(`/${named}`) || named.endsWith(`/${f.path}`)
|
|
25871
|
+
);
|
|
25872
|
+
return hits.length === 1 ? hits[0] : null;
|
|
25873
|
+
};
|
|
25874
|
+
for (const p of store2.findNodesByLabel("Problem")) {
|
|
25875
|
+
try {
|
|
25876
|
+
const anchors = store2.outEdges(p.id, ["ANCHORED_AT"]);
|
|
25877
|
+
const legacy = anchors.filter((e) => e.attrs?.["anchorProvenance"] === "legacy");
|
|
25878
|
+
if (legacy.length === 0) continue;
|
|
25879
|
+
const better = anchors.filter((e) => {
|
|
25880
|
+
const prov = e.attrs?.["anchorProvenance"];
|
|
25881
|
+
return prov === "restated" || prov === "witnessed" || prov === "edited";
|
|
25882
|
+
});
|
|
25883
|
+
if (better.length > 0) {
|
|
25884
|
+
const betterTargets = new Set(better.map((e) => e.to));
|
|
25885
|
+
let retired = 0;
|
|
25886
|
+
for (const e of legacy) {
|
|
25887
|
+
if (!betterTargets.has(e.to)) {
|
|
25888
|
+
store2.closeEdge(e.id, ts);
|
|
25889
|
+
retired++;
|
|
25890
|
+
}
|
|
25891
|
+
}
|
|
25892
|
+
report.retiredGuesses += retired;
|
|
25893
|
+
continue;
|
|
25894
|
+
}
|
|
25895
|
+
const named = [...String(p.description ?? "").matchAll(STATEMENT_PATH_RE)].map((m) => m[0]);
|
|
25896
|
+
if (named.length === 0) {
|
|
25897
|
+
report.noPathNamed++;
|
|
25898
|
+
continue;
|
|
25899
|
+
}
|
|
25900
|
+
const guessedPaths = legacy.map((e) => {
|
|
25901
|
+
const f = store2.getNode(e.to);
|
|
25902
|
+
return String(f?.attrs["relPath"] ?? f?.description ?? "");
|
|
25903
|
+
});
|
|
25904
|
+
if (named.some((x) => guessedPaths.some((g) => g.endsWith(x) || x.endsWith(g)))) {
|
|
25905
|
+
report.alreadyCorrect++;
|
|
25906
|
+
continue;
|
|
25907
|
+
}
|
|
25908
|
+
const target = named.map(resolvePath).find((f) => f !== null);
|
|
25909
|
+
if (!target) {
|
|
25910
|
+
report.pathUnknown++;
|
|
25911
|
+
continue;
|
|
25912
|
+
}
|
|
25913
|
+
store2.mergeEdge({
|
|
25914
|
+
id: `edge_${digest({ from: p.id, type: "ANCHORED_AT", to: target.id })}`.slice(0, 24),
|
|
25915
|
+
from: p.id,
|
|
25916
|
+
to: target.id,
|
|
25917
|
+
type: "ANCHORED_AT",
|
|
25918
|
+
// Same confidence a capture-time anchor enters at: the source is the
|
|
25919
|
+
// agent's own statement either way, only the moment of reading differs.
|
|
25920
|
+
confidence: 0.4,
|
|
25921
|
+
extractionSource: "agent-observed",
|
|
25922
|
+
createdAt: ts,
|
|
25923
|
+
lastSeenAt: ts,
|
|
25924
|
+
navSuccesses: 0,
|
|
25925
|
+
navFailures: 0,
|
|
25926
|
+
attrs: {
|
|
25927
|
+
anchorProvenance: "restated",
|
|
25928
|
+
restatedFrom: guessedPaths[0] ?? "",
|
|
25929
|
+
restatedAt: ts
|
|
25930
|
+
}
|
|
25931
|
+
});
|
|
25932
|
+
for (const e of legacy) {
|
|
25933
|
+
if (e.to !== target.id) store2.closeEdge(e.id, ts);
|
|
25934
|
+
}
|
|
25935
|
+
report.retiredGuesses += legacy.filter((e) => e.to !== target.id).length;
|
|
25936
|
+
report.repaired.push({
|
|
25937
|
+
problemId: p.id,
|
|
25938
|
+
problem: p.description,
|
|
25939
|
+
guessed: guessedPaths[0] ?? "",
|
|
25940
|
+
restated: target.path
|
|
25941
|
+
});
|
|
25942
|
+
} catch {
|
|
25943
|
+
}
|
|
25944
|
+
}
|
|
25945
|
+
return report;
|
|
25946
|
+
}
|
|
25263
25947
|
function backfillLegacyAnchors(store2, ts) {
|
|
25264
25948
|
const report = {
|
|
25265
25949
|
demotedEdges: 0,
|
|
@@ -25299,7 +25983,11 @@ function backfillLegacyAnchors(store2, ts) {
|
|
|
25299
25983
|
store2,
|
|
25300
25984
|
sol,
|
|
25301
25985
|
`auto-closed off a pre-provenance anchor (guessed ${guessedAnchor}) \u2014 confirm the problem is really fixed, or reopen it`,
|
|
25302
|
-
ts
|
|
25986
|
+
ts,
|
|
25987
|
+
// "or reopen it" is half the ask, and the nightly reopen takes that
|
|
25988
|
+
// branch — so record what would answer this, or the flag can never be
|
|
25989
|
+
// lowered and the band fills with settled questions.
|
|
25990
|
+
"parentProblemOpen"
|
|
25303
25991
|
);
|
|
25304
25992
|
store2.updateNode(p.id, {
|
|
25305
25993
|
attrs: { ...p.attrs, resolutionSuspect: true },
|
|
@@ -25333,7 +26021,7 @@ function pagerank(input) {
|
|
|
25333
26021
|
const ids = input.nodeIds;
|
|
25334
26022
|
const n = ids.length;
|
|
25335
26023
|
if (n === 0) {
|
|
25336
|
-
return { scores: /* @__PURE__ */ new Map(), iterations: 0, converged: true };
|
|
26024
|
+
return { scores: /* @__PURE__ */ new Map(), iterations: 0, converged: true, danglingRank: 0 };
|
|
25337
26025
|
}
|
|
25338
26026
|
const index = /* @__PURE__ */ new Map();
|
|
25339
26027
|
for (let i2 = 0; i2 < n; i2++) index.set(ids[i2], i2);
|
|
@@ -25405,8 +26093,12 @@ function pagerank(input) {
|
|
|
25405
26093
|
}
|
|
25406
26094
|
}
|
|
25407
26095
|
const scores = /* @__PURE__ */ new Map();
|
|
25408
|
-
|
|
25409
|
-
|
|
26096
|
+
let danglingRank = 0;
|
|
26097
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
26098
|
+
scores.set(ids[i2], score2[i2]);
|
|
26099
|
+
if (dangling[i2]) danglingRank += score2[i2];
|
|
26100
|
+
}
|
|
26101
|
+
return { scores, iterations: iter, converged, danglingRank };
|
|
25410
26102
|
}
|
|
25411
26103
|
function markLandmarks(scores, percentile = 0.1, filter) {
|
|
25412
26104
|
const entries = [...scores.entries()];
|
|
@@ -25416,7 +26108,7 @@ function markLandmarks(scores, percentile = 0.1, filter) {
|
|
|
25416
26108
|
}
|
|
25417
26109
|
}
|
|
25418
26110
|
if (entries.length === 0) return /* @__PURE__ */ new Set();
|
|
25419
|
-
entries.sort((a, b) => b[1] - a[1]);
|
|
26111
|
+
entries.sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
25420
26112
|
const cutoff = Math.max(1, Math.floor(entries.length * percentile));
|
|
25421
26113
|
const out2 = /* @__PURE__ */ new Set();
|
|
25422
26114
|
for (let i2 = 0; i2 < cutoff; i2++) {
|
|
@@ -25654,8 +26346,86 @@ function motifDecision(input) {
|
|
|
25654
26346
|
};
|
|
25655
26347
|
}
|
|
25656
26348
|
|
|
25657
|
-
// ../../packages/
|
|
25658
|
-
|
|
26349
|
+
// ../../packages/math/src/pagerank-local.ts
|
|
26350
|
+
function pagerankLocal(input) {
|
|
26351
|
+
const damping = input.damping ?? 0.85;
|
|
26352
|
+
const tol = input.tolerance ?? 1e-6;
|
|
26353
|
+
const maxIter = input.maxIterations ?? 100;
|
|
26354
|
+
const ids = input.regionIds;
|
|
26355
|
+
const n = ids.length;
|
|
26356
|
+
if (n === 0 || input.globalN === 0) {
|
|
26357
|
+
return { scores: /* @__PURE__ */ new Map(), iterations: 0, converged: true };
|
|
26358
|
+
}
|
|
26359
|
+
const index = /* @__PURE__ */ new Map();
|
|
26360
|
+
for (let i2 = 0; i2 < n; i2++) index.set(ids[i2], i2);
|
|
26361
|
+
const base = (1 - damping) / input.globalN;
|
|
26362
|
+
const outSum = new Float64Array(n);
|
|
26363
|
+
const inflow = new Float64Array(n);
|
|
26364
|
+
let score2 = new Float64Array(n);
|
|
26365
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
26366
|
+
const id = ids[i2];
|
|
26367
|
+
outSum[i2] = input.outSum.get(id) ?? 0;
|
|
26368
|
+
inflow[i2] = input.boundaryInflow.get(id) ?? 0;
|
|
26369
|
+
score2[i2] = input.rank0.get(id) ?? base;
|
|
26370
|
+
}
|
|
26371
|
+
const rowLen = new Int32Array(n);
|
|
26372
|
+
let edgeCount = 0;
|
|
26373
|
+
for (const [from, edges] of input.out) {
|
|
26374
|
+
const fi = index.get(from);
|
|
26375
|
+
if (fi === void 0) continue;
|
|
26376
|
+
let inSet = 0;
|
|
26377
|
+
for (const e of edges) if (index.has(e.to)) inSet++;
|
|
26378
|
+
rowLen[fi] = inSet;
|
|
26379
|
+
edgeCount += inSet;
|
|
26380
|
+
}
|
|
26381
|
+
const rowStart = new Int32Array(n + 1);
|
|
26382
|
+
for (let i2 = 0; i2 < n; i2++) rowStart[i2 + 1] = rowStart[i2] + rowLen[i2];
|
|
26383
|
+
const colIdx = new Int32Array(edgeCount);
|
|
26384
|
+
const colW = new Float64Array(edgeCount);
|
|
26385
|
+
const cursor = rowStart.slice(0, n);
|
|
26386
|
+
for (const [from, edges] of input.out) {
|
|
26387
|
+
const fi = index.get(from);
|
|
26388
|
+
if (fi === void 0) continue;
|
|
26389
|
+
for (const e of edges) {
|
|
26390
|
+
const ti = index.get(e.to);
|
|
26391
|
+
if (ti === void 0) continue;
|
|
26392
|
+
const c = cursor[fi];
|
|
26393
|
+
cursor[fi] = c + 1;
|
|
26394
|
+
colIdx[c] = ti;
|
|
26395
|
+
colW[c] = e.weight;
|
|
26396
|
+
}
|
|
26397
|
+
}
|
|
26398
|
+
const externalDangling = input.externalDanglingRank ?? 0;
|
|
26399
|
+
let next = new Float64Array(n);
|
|
26400
|
+
let iter = 0;
|
|
26401
|
+
let converged = false;
|
|
26402
|
+
for (; iter < maxIter; iter++) {
|
|
26403
|
+
let internalDangling = 0;
|
|
26404
|
+
for (let i2 = 0; i2 < n; i2++) if (outSum[i2] <= 0) internalDangling += score2[i2];
|
|
26405
|
+
const danglingShare = damping * (internalDangling + externalDangling) / input.globalN;
|
|
26406
|
+
for (let i2 = 0; i2 < n; i2++) next[i2] = base + danglingShare + damping * inflow[i2];
|
|
26407
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
26408
|
+
const os2 = outSum[i2];
|
|
26409
|
+
if (os2 <= 0) continue;
|
|
26410
|
+
const f = damping * score2[i2] / os2;
|
|
26411
|
+
const end = rowStart[i2 + 1];
|
|
26412
|
+
for (let c = rowStart[i2]; c < end; c++) next[colIdx[c]] += f * colW[c];
|
|
26413
|
+
}
|
|
26414
|
+
let diff = 0;
|
|
26415
|
+
for (let i2 = 0; i2 < n; i2++) diff += Math.abs(next[i2] - score2[i2]);
|
|
26416
|
+
const tmp = score2;
|
|
26417
|
+
score2 = next;
|
|
26418
|
+
next = tmp;
|
|
26419
|
+
if (diff < tol) {
|
|
26420
|
+
iter++;
|
|
26421
|
+
converged = true;
|
|
26422
|
+
break;
|
|
26423
|
+
}
|
|
26424
|
+
}
|
|
26425
|
+
const scores = /* @__PURE__ */ new Map();
|
|
26426
|
+
for (let i2 = 0; i2 < n; i2++) scores.set(ids[i2], score2[i2]);
|
|
26427
|
+
return { scores, iterations: iter, converged };
|
|
26428
|
+
}
|
|
25659
26429
|
|
|
25660
26430
|
// ../../packages/local-graph/src/triage.ts
|
|
25661
26431
|
init_src();
|
|
@@ -25664,95 +26434,8 @@ init_src();
|
|
|
25664
26434
|
init_src2();
|
|
25665
26435
|
var DRIFT_VALUES = new Set(Object.values(DRIFT_KIND));
|
|
25666
26436
|
|
|
25667
|
-
// ../../packages/local-graph/src/
|
|
25668
|
-
|
|
25669
|
-
init_src();
|
|
25670
|
-
var REDIRECT_EDGES = [
|
|
25671
|
-
"CAUSED_BY",
|
|
25672
|
-
"SOLVED_BY",
|
|
25673
|
-
"FIXED_BY",
|
|
25674
|
-
"ANCHORED_AT",
|
|
25675
|
-
"MANIFESTED_IN",
|
|
25676
|
-
"EVIDENCED_BY"
|
|
25677
|
-
];
|
|
25678
|
-
function corroborations(n) {
|
|
25679
|
-
return Number(n.attrs["corroborations"] ?? 0);
|
|
25680
|
-
}
|
|
25681
|
-
function overlap(a, b) {
|
|
25682
|
-
if (a.size === 0 || b.size === 0) return 0;
|
|
25683
|
-
let inter = 0;
|
|
25684
|
-
for (const x of a) if (b.has(x)) inter++;
|
|
25685
|
-
return inter / Math.min(a.size, b.size);
|
|
25686
|
-
}
|
|
25687
|
-
function mergeDuplicateProblems(store2, opts) {
|
|
25688
|
-
const minOverlap = opts.minOverlap ?? 0.85;
|
|
25689
|
-
const minTokens = opts.minTokens ?? 4;
|
|
25690
|
-
const report = { clusters: 0, merged: 0 };
|
|
25691
|
-
const open = store2.findNodesByLabel("Problem").filter((p) => p.attrs["resolvedAt"] == null && p.attrs["mergedInto"] === void 0);
|
|
25692
|
-
const tokens = /* @__PURE__ */ new Map();
|
|
25693
|
-
for (const p of open) tokens.set(p.id, new Set(conceptTokens(p.description)));
|
|
25694
|
-
const consumed = /* @__PURE__ */ new Set();
|
|
25695
|
-
store2.transaction(() => {
|
|
25696
|
-
for (let i2 = 0; i2 < open.length; i2++) {
|
|
25697
|
-
const a = open[i2];
|
|
25698
|
-
if (consumed.has(a.id)) continue;
|
|
25699
|
-
const cluster = [a];
|
|
25700
|
-
const ta = tokens.get(a.id);
|
|
25701
|
-
for (let j = i2 + 1; j < open.length; j++) {
|
|
25702
|
-
const b = open[j];
|
|
25703
|
-
if (consumed.has(b.id)) continue;
|
|
25704
|
-
const tb = tokens.get(b.id);
|
|
25705
|
-
if (Math.min(ta.size, tb.size) < minTokens) continue;
|
|
25706
|
-
if (overlap(ta, tb) >= minOverlap) {
|
|
25707
|
-
cluster.push(b);
|
|
25708
|
-
consumed.add(b.id);
|
|
25709
|
-
}
|
|
25710
|
-
}
|
|
25711
|
-
if (cluster.length < 2) continue;
|
|
25712
|
-
report.clusters++;
|
|
25713
|
-
cluster.sort((x, y) => corroborations(y) - corroborations(x) || x.createdAt - y.createdAt);
|
|
25714
|
-
const survivor = cluster[0];
|
|
25715
|
-
for (const dup of cluster.slice(1)) {
|
|
25716
|
-
foldDuplicateProblem(store2, dup, survivor, opts.ts);
|
|
25717
|
-
report.merged++;
|
|
25718
|
-
}
|
|
25719
|
-
}
|
|
25720
|
-
});
|
|
25721
|
-
return report;
|
|
25722
|
-
}
|
|
25723
|
-
function foldDuplicateProblem(store2, dup, survivor, ts) {
|
|
25724
|
-
const surv = store2.getNode(survivor.id);
|
|
25725
|
-
if (!surv) return;
|
|
25726
|
-
const sources = new Set(surv.attrs["sources"] ?? []);
|
|
25727
|
-
for (const s of dup.attrs["sources"] ?? []) sources.add(s);
|
|
25728
|
-
store2.updateNode(survivor.id, {
|
|
25729
|
-
attrs: {
|
|
25730
|
-
...surv.attrs,
|
|
25731
|
-
sources: [...sources],
|
|
25732
|
-
corroborations: corroborations(surv) + corroborations(dup) + 1
|
|
25733
|
-
},
|
|
25734
|
-
cumulativeHits: (surv.cumulativeHits ?? 0) + (dup.cumulativeHits ?? 0),
|
|
25735
|
-
lastUpdatedAt: ts
|
|
25736
|
-
});
|
|
25737
|
-
for (const e of store2.outEdges(dup.id, REDIRECT_EDGES)) {
|
|
25738
|
-
if (e.to === survivor.id) continue;
|
|
25739
|
-
const id = `edge_${digest({ from: survivor.id, type: e.type, to: e.to })}`.slice(0, 24);
|
|
25740
|
-
if (store2.getEdge(id)) continue;
|
|
25741
|
-
const redirected = {
|
|
25742
|
-
...e,
|
|
25743
|
-
id,
|
|
25744
|
-
from: survivor.id,
|
|
25745
|
-
createdAt: ts,
|
|
25746
|
-
lastSeenAt: ts
|
|
25747
|
-
};
|
|
25748
|
-
store2.mergeEdge(redirected);
|
|
25749
|
-
}
|
|
25750
|
-
store2.updateNode(dup.id, {
|
|
25751
|
-
attrs: { ...dup.attrs, mergedInto: survivor.id, resolvedAs: "duplicate", resolvedAt: ts },
|
|
25752
|
-
lastUpdatedAt: ts
|
|
25753
|
-
});
|
|
25754
|
-
store2.closeNode(dup.id, ts);
|
|
25755
|
-
}
|
|
26437
|
+
// ../../packages/local-graph/src/community.ts
|
|
26438
|
+
init_src2();
|
|
25756
26439
|
|
|
25757
26440
|
// ../../packages/local-graph/src/tools.ts
|
|
25758
26441
|
init_src();
|
|
@@ -25769,6 +26452,9 @@ function rankToolsForHandles(store2, limit = 5) {
|
|
|
25769
26452
|
// ../../packages/local-graph/src/principle-sync.ts
|
|
25770
26453
|
init_src2();
|
|
25771
26454
|
|
|
26455
|
+
// ../../packages/local-graph/src/mechanism-liveness.ts
|
|
26456
|
+
var STALL_MIN_SPAN_MS = 60 * 60 * 1e3;
|
|
26457
|
+
|
|
25772
26458
|
// ../../packages/generalizer/src/generalizer.ts
|
|
25773
26459
|
init_src2();
|
|
25774
26460
|
init_src();
|
|
@@ -25888,7 +26574,164 @@ function promoteMotifs(store2, t) {
|
|
|
25888
26574
|
}
|
|
25889
26575
|
|
|
25890
26576
|
// ../../packages/generalizer/src/nightly.ts
|
|
25891
|
-
|
|
26577
|
+
var FULL_RESCORE_EVERY = 12;
|
|
26578
|
+
var INCREMENTAL_REGION_MAX_FRACTION = 0.2;
|
|
26579
|
+
var INCREMENTAL_HOPS = 3;
|
|
26580
|
+
function runGraphRescore(store2, opts = {}) {
|
|
26581
|
+
const lastRescoreAt = Number(store2.getMeta?.("lastRescoreAt") ?? 0);
|
|
26582
|
+
const sinceFull = Number(store2.getMeta?.("rescoresSinceFull") ?? 0);
|
|
26583
|
+
const incrementalCapable = !opts.forceFull && lastRescoreAt > 0 && sinceFull < FULL_RESCORE_EVERY - 1 && !!store2.getMeta && !!store2.setMeta && !!store2.dirtyNodeIdsSince && !!store2.edgeEndpointsTouchedSince && !!store2.outEdgesForMany && !!store2.inEdgesForMany && !!store2.ranksForMany && !!store2.landmarkSweepRows;
|
|
26584
|
+
if (incrementalCapable) {
|
|
26585
|
+
const started = Date.now();
|
|
26586
|
+
const inc = tryIncrementalRescore(store2, lastRescoreAt, started);
|
|
26587
|
+
if (inc) {
|
|
26588
|
+
store2.setMeta("lastRescoreAt", String(started));
|
|
26589
|
+
store2.setMeta("rescoresSinceFull", String(sinceFull + 1));
|
|
26590
|
+
return inc;
|
|
26591
|
+
}
|
|
26592
|
+
}
|
|
26593
|
+
const report = runFullRescore(store2);
|
|
26594
|
+
store2.setMeta?.("lastRescoreAt", String(report.startedAt));
|
|
26595
|
+
store2.setMeta?.("rescoresSinceFull", "0");
|
|
26596
|
+
store2.setMeta?.("danglingRankShare", String(report.danglingRank));
|
|
26597
|
+
const { startedAt: _drop, danglingRank: _drop2, ...rest } = report;
|
|
26598
|
+
return rest;
|
|
26599
|
+
}
|
|
26600
|
+
function tryIncrementalRescore(store2, lastRescoreAt, started) {
|
|
26601
|
+
const allowedTypes = new Set(pagerankEdgeTypes());
|
|
26602
|
+
const liveN = store2.nodeCount();
|
|
26603
|
+
const cap = Math.max(1e3, Math.floor(liveN * INCREMENTAL_REGION_MAX_FRACTION));
|
|
26604
|
+
const region = new Set(store2.dirtyNodeIdsSince(lastRescoreAt));
|
|
26605
|
+
for (const e of store2.edgeEndpointsTouchedSince(lastRescoreAt)) {
|
|
26606
|
+
region.add(e.from);
|
|
26607
|
+
region.add(e.to);
|
|
26608
|
+
}
|
|
26609
|
+
if (region.size > cap) return null;
|
|
26610
|
+
let frontier = [...region];
|
|
26611
|
+
for (let hop = 0; hop < INCREMENTAL_HOPS && frontier.length > 0; hop++) {
|
|
26612
|
+
const next = [];
|
|
26613
|
+
for (const e of store2.outEdgesForMany(frontier)) {
|
|
26614
|
+
if (!allowedTypes.has(e.type)) continue;
|
|
26615
|
+
if (!region.has(e.to)) {
|
|
26616
|
+
region.add(e.to);
|
|
26617
|
+
next.push(e.to);
|
|
26618
|
+
}
|
|
26619
|
+
}
|
|
26620
|
+
if (region.size > cap) return null;
|
|
26621
|
+
frontier = next;
|
|
26622
|
+
}
|
|
26623
|
+
const rank0 = store2.ranksForMany([...region]);
|
|
26624
|
+
const regionIds = [...rank0.keys()];
|
|
26625
|
+
if (regionIds.length === 0) {
|
|
26626
|
+
return {
|
|
26627
|
+
scoredNodes: 0,
|
|
26628
|
+
iterations: 0,
|
|
26629
|
+
converged: true,
|
|
26630
|
+
landmarks: 0,
|
|
26631
|
+
communities: 0,
|
|
26632
|
+
motifsPromoted: 0,
|
|
26633
|
+
techniques: 0,
|
|
26634
|
+
antipatterns: 0,
|
|
26635
|
+
pageRankWritten: 0,
|
|
26636
|
+
landmarkFlips: 0,
|
|
26637
|
+
mode: "incremental",
|
|
26638
|
+
regionSize: 0,
|
|
26639
|
+
durationMs: Date.now() - started
|
|
26640
|
+
};
|
|
26641
|
+
}
|
|
26642
|
+
const inRegion = new Set(regionIds);
|
|
26643
|
+
const out2 = /* @__PURE__ */ new Map();
|
|
26644
|
+
const outSum = /* @__PURE__ */ new Map();
|
|
26645
|
+
for (const e of store2.outEdgesForMany(regionIds)) {
|
|
26646
|
+
if (!allowedTypes.has(e.type)) continue;
|
|
26647
|
+
const w = EDGE_WEIGHT[e.type] ?? 1;
|
|
26648
|
+
if (w <= 0) continue;
|
|
26649
|
+
outSum.set(e.from, (outSum.get(e.from) ?? 0) + w);
|
|
26650
|
+
if (!inRegion.has(e.to)) continue;
|
|
26651
|
+
const l = out2.get(e.from);
|
|
26652
|
+
if (l) l.push({ to: e.to, weight: w });
|
|
26653
|
+
else out2.set(e.from, [{ to: e.to, weight: w }]);
|
|
26654
|
+
}
|
|
26655
|
+
const boundaryEdges = store2.inEdgesForMany(regionIds).filter((e) => allowedTypes.has(e.type) && !inRegion.has(e.from) && (EDGE_WEIGHT[e.type] ?? 1) > 0);
|
|
26656
|
+
const boundarySources = [...new Set(boundaryEdges.map((e) => e.from))];
|
|
26657
|
+
if (boundarySources.length > cap) return null;
|
|
26658
|
+
const boundaryRanks = store2.ranksForMany(boundarySources);
|
|
26659
|
+
const boundaryOutSum = /* @__PURE__ */ new Map();
|
|
26660
|
+
for (const e of store2.outEdgesForMany(boundarySources)) {
|
|
26661
|
+
if (!allowedTypes.has(e.type)) continue;
|
|
26662
|
+
const w = EDGE_WEIGHT[e.type] ?? 1;
|
|
26663
|
+
if (w > 0) boundaryOutSum.set(e.from, (boundaryOutSum.get(e.from) ?? 0) + w);
|
|
26664
|
+
}
|
|
26665
|
+
const boundaryInflow = /* @__PURE__ */ new Map();
|
|
26666
|
+
for (const e of boundaryEdges) {
|
|
26667
|
+
const r = boundaryRanks.get(e.from);
|
|
26668
|
+
const os2 = boundaryOutSum.get(e.from);
|
|
26669
|
+
if (r === void 0 || !os2) continue;
|
|
26670
|
+
const w = EDGE_WEIGHT[e.type] ?? 1;
|
|
26671
|
+
boundaryInflow.set(e.to, (boundaryInflow.get(e.to) ?? 0) + r * w / os2);
|
|
26672
|
+
}
|
|
26673
|
+
const globalDangling = Number(store2.getMeta("danglingRankShare") ?? 0);
|
|
26674
|
+
let regionDangling = 0;
|
|
26675
|
+
for (const id of regionIds) {
|
|
26676
|
+
if ((outSum.get(id) ?? 0) <= 0) regionDangling += rank0.get(id) ?? 0;
|
|
26677
|
+
}
|
|
26678
|
+
const result = pagerankLocal({
|
|
26679
|
+
regionIds,
|
|
26680
|
+
rank0,
|
|
26681
|
+
out: out2,
|
|
26682
|
+
outSum,
|
|
26683
|
+
boundaryInflow,
|
|
26684
|
+
globalN: liveN,
|
|
26685
|
+
externalDanglingRank: Math.max(0, globalDangling - regionDangling),
|
|
26686
|
+
damping: 0.85,
|
|
26687
|
+
tolerance: 1e-6,
|
|
26688
|
+
maxIterations: 100
|
|
26689
|
+
});
|
|
26690
|
+
let pageRankWritten = 0;
|
|
26691
|
+
store2.transaction(() => {
|
|
26692
|
+
for (const [id, score2] of result.scores) {
|
|
26693
|
+
if (Math.abs(score2 - (rank0.get(id) ?? 0)) < 1e-9) continue;
|
|
26694
|
+
store2.setPageRank(id, score2);
|
|
26695
|
+
pageRankWritten++;
|
|
26696
|
+
}
|
|
26697
|
+
});
|
|
26698
|
+
const sweep = store2.landmarkSweepRows();
|
|
26699
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
26700
|
+
for (const row of sweep) {
|
|
26701
|
+
if (row.label === "Pattern" || row.label === "RootCause") {
|
|
26702
|
+
candidates.set(row.id, result.scores.get(row.id) ?? row.pageRank);
|
|
26703
|
+
}
|
|
26704
|
+
}
|
|
26705
|
+
const want = markLandmarks(candidates, 0.1);
|
|
26706
|
+
for (const row of sweep) if (row.memoryTier === "persistent") want.add(row.id);
|
|
26707
|
+
let landmarkFlips = 0;
|
|
26708
|
+
store2.transaction(() => {
|
|
26709
|
+
for (const row of sweep) {
|
|
26710
|
+
if (row.extractionSource === "bko-inferred") continue;
|
|
26711
|
+
const should = want.has(row.id);
|
|
26712
|
+
if (row.isLandmark === should) continue;
|
|
26713
|
+
store2.setLandmark(row.id, should);
|
|
26714
|
+
landmarkFlips++;
|
|
26715
|
+
}
|
|
26716
|
+
});
|
|
26717
|
+
return {
|
|
26718
|
+
scoredNodes: regionIds.length,
|
|
26719
|
+
iterations: result.iterations,
|
|
26720
|
+
converged: result.converged,
|
|
26721
|
+
landmarks: want.size,
|
|
26722
|
+
communities: 0,
|
|
26723
|
+
// deferred to the full backstop — see mode docs
|
|
26724
|
+
motifsPromoted: 0,
|
|
26725
|
+
techniques: 0,
|
|
26726
|
+
antipatterns: 0,
|
|
26727
|
+
pageRankWritten,
|
|
26728
|
+
landmarkFlips,
|
|
26729
|
+
mode: "incremental",
|
|
26730
|
+
regionSize: regionIds.length,
|
|
26731
|
+
durationMs: Date.now() - started
|
|
26732
|
+
};
|
|
26733
|
+
}
|
|
26734
|
+
function runFullRescore(store2) {
|
|
25892
26735
|
const started = Date.now();
|
|
25893
26736
|
const allowedTypes = new Set(pagerankEdgeTypes());
|
|
25894
26737
|
const nodeIds = [];
|
|
@@ -25914,10 +26757,12 @@ function runNightlyPipeline(store2) {
|
|
|
25914
26757
|
maxIterations: 100
|
|
25915
26758
|
});
|
|
25916
26759
|
const scored = result.scores.size;
|
|
26760
|
+
let pageRankWritten = 0;
|
|
25917
26761
|
store2.transaction(() => {
|
|
25918
26762
|
for (const [id, score2] of result.scores) {
|
|
25919
26763
|
if (Math.abs(score2 - (meta3.get(id)?.pageRank ?? 0)) < 1e-9) continue;
|
|
25920
26764
|
store2.setPageRank(id, score2);
|
|
26765
|
+
pageRankWritten++;
|
|
25921
26766
|
}
|
|
25922
26767
|
});
|
|
25923
26768
|
const landmarkCandidates = /* @__PURE__ */ new Map();
|
|
@@ -25932,11 +26777,13 @@ function runNightlyPipeline(store2) {
|
|
|
25932
26777
|
for (const id of nodeIds) {
|
|
25933
26778
|
if (meta3.get(id)?.memoryTier === "persistent") allLandmarks.add(id);
|
|
25934
26779
|
}
|
|
26780
|
+
let landmarkFlips = 0;
|
|
25935
26781
|
store2.transaction(() => {
|
|
25936
26782
|
for (const id of nodeIds) {
|
|
25937
26783
|
const want = allLandmarks.has(id);
|
|
25938
26784
|
if ((meta3.get(id)?.isLandmark ?? false) === want) continue;
|
|
25939
26785
|
store2.setLandmark(id, want);
|
|
26786
|
+
landmarkFlips++;
|
|
25940
26787
|
}
|
|
25941
26788
|
});
|
|
25942
26789
|
const MOTIF_LABELS = /* @__PURE__ */ new Set(["Pattern", "Technique", "AntiPattern"]);
|
|
@@ -25971,8 +26818,6 @@ function runNightlyPipeline(store2) {
|
|
|
25971
26818
|
for (const [id, c] of comm.community) store2.updateNode(id, { community: c });
|
|
25972
26819
|
});
|
|
25973
26820
|
const motifs = promoteMotifs(store2, started);
|
|
25974
|
-
const designResolved = resolveDesignProblems(store2, started);
|
|
25975
|
-
const cry = crystallize(store2, { ts: started });
|
|
25976
26821
|
return {
|
|
25977
26822
|
scoredNodes: scored,
|
|
25978
26823
|
iterations: result.iterations,
|
|
@@ -25982,15 +26827,61 @@ function runNightlyPipeline(store2) {
|
|
|
25982
26827
|
motifsPromoted: motifs.promoted,
|
|
25983
26828
|
techniques: motifs.techniques,
|
|
25984
26829
|
antipatterns: motifs.antipatterns,
|
|
25985
|
-
|
|
25986
|
-
|
|
25987
|
-
|
|
26830
|
+
pageRankWritten,
|
|
26831
|
+
landmarkFlips,
|
|
26832
|
+
mode: "full",
|
|
26833
|
+
regionSize: 0,
|
|
26834
|
+
startedAt: started,
|
|
26835
|
+
danglingRank: result.danglingRank,
|
|
26836
|
+
durationMs: Date.now() - started
|
|
26837
|
+
};
|
|
26838
|
+
}
|
|
26839
|
+
function runSemanticMaintenance(store2) {
|
|
26840
|
+
const started = Date.now();
|
|
26841
|
+
reopenAutoClosedProblems(store2, started);
|
|
26842
|
+
const revisits = clearAnsweredRevisits(store2, started);
|
|
26843
|
+
const fixCandidates = clearSettledFixCandidates(store2, started);
|
|
26844
|
+
const designResolved = markFixCandidates(store2, started);
|
|
26845
|
+
const cry = crystallize(store2, { ts: started });
|
|
26846
|
+
return {
|
|
25988
26847
|
designResolved,
|
|
26848
|
+
revisitsCleared: revisits.cleared,
|
|
26849
|
+
revisitsStanding: revisits.standing,
|
|
26850
|
+
fixCandidatesSettled: fixCandidates.answered + fixCandidates.ignored + fixCandidates.unsubstantiated,
|
|
26851
|
+
fixCandidates,
|
|
25989
26852
|
claimsEvaluated: cry.evaluated,
|
|
25990
26853
|
claimsDerived: cry.derived.length,
|
|
25991
26854
|
durationMs: Date.now() - started
|
|
25992
26855
|
};
|
|
25993
26856
|
}
|
|
26857
|
+
function runNightlyPipeline(store2) {
|
|
26858
|
+
const started = Date.now();
|
|
26859
|
+
const rescore = runGraphRescore(store2);
|
|
26860
|
+
const semantic = runSemanticMaintenance(store2);
|
|
26861
|
+
return {
|
|
26862
|
+
scoredNodes: rescore.scoredNodes,
|
|
26863
|
+
iterations: rescore.iterations,
|
|
26864
|
+
converged: rescore.converged,
|
|
26865
|
+
landmarks: rescore.landmarks,
|
|
26866
|
+
communities: rescore.communities,
|
|
26867
|
+
motifsPromoted: rescore.motifsPromoted,
|
|
26868
|
+
techniques: rescore.techniques,
|
|
26869
|
+
antipatterns: rescore.antipatterns,
|
|
26870
|
+
skillsInduced: 0,
|
|
26871
|
+
// skills are cloud-induced now (see above)
|
|
26872
|
+
skillsRefreshed: 0,
|
|
26873
|
+
pageRankWritten: rescore.pageRankWritten,
|
|
26874
|
+
landmarkFlips: rescore.landmarkFlips,
|
|
26875
|
+
mode: rescore.mode,
|
|
26876
|
+
regionSize: rescore.regionSize,
|
|
26877
|
+
designResolved: semantic.designResolved,
|
|
26878
|
+
revisitsCleared: semantic.revisitsCleared,
|
|
26879
|
+
fixCandidatesSettled: semantic.fixCandidatesSettled,
|
|
26880
|
+
claimsEvaluated: semantic.claimsEvaluated,
|
|
26881
|
+
claimsDerived: semantic.claimsDerived,
|
|
26882
|
+
durationMs: Date.now() - started
|
|
26883
|
+
};
|
|
26884
|
+
}
|
|
25994
26885
|
function codeAnchorProjection(store2, semanticIds, opts = {}) {
|
|
25995
26886
|
const anchorToNodes = /* @__PURE__ */ new Map();
|
|
25996
26887
|
for (const id of semanticIds) {
|
|
@@ -26035,12 +26926,14 @@ var AGENTS_POINTER_BODY = [
|
|
|
26035
26926
|
init_src2();
|
|
26036
26927
|
function buildSnapshot(opts) {
|
|
26037
26928
|
const problems = opts.store.findNodesByLabel("Problem").filter((p) => p.attrs["mergedInto"] === void 0);
|
|
26038
|
-
const
|
|
26929
|
+
const stillOpen = problems.filter((p) => p.attrs["resolvedAt"] == null);
|
|
26930
|
+
const allProblems = stillOpen.filter((p) => !isConstraintProblem(p));
|
|
26039
26931
|
allProblems.sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt);
|
|
26040
26932
|
const recent = allProblems.slice(0, 8).map((p) => ({
|
|
26041
26933
|
node: p,
|
|
26042
26934
|
anchors: opts.store.outEdges(p.id, ["MANIFESTED_IN", "EVIDENCED_BY"])
|
|
26043
26935
|
}));
|
|
26936
|
+
const recentConstraints = stillOpen.filter((p) => isConstraintProblem(p)).sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt).slice(0, 3);
|
|
26044
26937
|
const recentResolved = problems.filter((p) => p.attrs["resolvedAt"] != null && p.attrs["resolvedAs"] == null).sort((a, b) => Number(b.attrs["resolvedAt"] ?? 0) - Number(a.attrs["resolvedAt"] ?? 0)).slice(0, 4).map((p) => {
|
|
26045
26938
|
const solEdge = opts.store.outEdges(p.id, ["SOLVED_BY"])[0];
|
|
26046
26939
|
const solution = solEdge ? opts.store.getNode(solEdge.to) ?? void 0 : void 0;
|
|
@@ -26068,10 +26961,13 @@ function buildSnapshot(opts) {
|
|
|
26068
26961
|
episodeId,
|
|
26069
26962
|
problems: problems2
|
|
26070
26963
|
}));
|
|
26071
|
-
const
|
|
26072
|
-
|
|
26073
|
-
|
|
26074
|
-
|
|
26964
|
+
const revisitSeen = /* @__PURE__ */ new Set();
|
|
26965
|
+
const needsRevisit = listNeedsRevisit(opts.store, (opts.now ?? /* @__PURE__ */ new Date()).getTime()).filter((r) => {
|
|
26966
|
+
const key = `${r.label}:${r.description.trim().toLowerCase()}`;
|
|
26967
|
+
if (revisitSeen.has(key)) return false;
|
|
26968
|
+
revisitSeen.add(key);
|
|
26969
|
+
return true;
|
|
26970
|
+
}).slice(0, 5);
|
|
26075
26971
|
const norm = (x) => x.toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
26076
26972
|
const pkgBase = (x) => {
|
|
26077
26973
|
const at = x.lastIndexOf("@");
|
|
@@ -26107,7 +27003,9 @@ function buildSnapshot(opts) {
|
|
|
26107
27003
|
profileContext,
|
|
26108
27004
|
recentProblems: recent,
|
|
26109
27005
|
recentResolved,
|
|
27006
|
+
recentConstraints,
|
|
26110
27007
|
...causalNudge ? { causalNudge } : {},
|
|
27008
|
+
...opts.selfCiteSkips && opts.selfCiteSkips > 0 ? { selfCiteSkips: opts.selfCiteSkips } : {},
|
|
26111
27009
|
...domainNudge ? { domainNudge } : {},
|
|
26112
27010
|
motifs,
|
|
26113
27011
|
reviewCount: opts.reviewCount,
|
|
@@ -26158,10 +27056,16 @@ function sliceForFile(store2, relPath) {
|
|
|
26158
27056
|
}
|
|
26159
27057
|
const fp = priorsForFile(store2, relPath);
|
|
26160
27058
|
const priors = fp ? {
|
|
26161
|
-
openProblems: fp.openProblems.slice(0, 3).map((p) => ({
|
|
27059
|
+
openProblems: fp.openProblems.slice(0, 3).map((p) => ({
|
|
27060
|
+
id: p.id,
|
|
27061
|
+
description: p.description,
|
|
27062
|
+
...typeof p.attrs["fixCandidateFile"] === "string" ? { fixCandidateFile: p.attrs["fixCandidateFile"] } : {}
|
|
27063
|
+
})),
|
|
27064
|
+
constraints: fp.constraints.slice(0, 2).map((c) => ({ id: c.id, description: c.description })),
|
|
27065
|
+
resolvedProblems: fp.resolvedProblems.slice(0, 3).map((p) => ({ id: p.id, description: p.description })),
|
|
26162
27066
|
related: fp.related.slice(0, 4).map((n) => ({ id: n.id, label: n.label, description: n.description })),
|
|
26163
27067
|
solutionsByProblem: Object.fromEntries(
|
|
26164
|
-
fp.openProblems.slice(0, 3).map((p) => [
|
|
27068
|
+
[...fp.openProblems.slice(0, 3), ...fp.resolvedProblems.slice(0, 3)].map((p) => [
|
|
26165
27069
|
p.id,
|
|
26166
27070
|
(fp.solutionsByProblem.get(p.id) ?? []).slice(0, 4).map((s) => ({ id: s.id, description: s.description }))
|
|
26167
27071
|
])
|
|
@@ -26269,9 +27173,15 @@ function* walkSource(dir) {
|
|
|
26269
27173
|
function listSourceFiles(root) {
|
|
26270
27174
|
return gitSourceFiles(root) ?? walkSource(root);
|
|
26271
27175
|
}
|
|
26272
|
-
|
|
27176
|
+
var SCAN_YIELD_EVERY = 100;
|
|
27177
|
+
var LIVENESS_CHUNK = 4e3;
|
|
27178
|
+
async function findStaleFiles(store2, rootPath, workspaceId) {
|
|
26273
27179
|
const stale = [];
|
|
27180
|
+
const pending = [];
|
|
27181
|
+
const allTargets = [];
|
|
27182
|
+
let scanned = 0;
|
|
26274
27183
|
for (const abs of listSourceFiles(rootPath)) {
|
|
27184
|
+
if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
|
|
26275
27185
|
let mtimeMs;
|
|
26276
27186
|
try {
|
|
26277
27187
|
mtimeMs = statSync2(abs).mtimeMs;
|
|
@@ -26282,32 +27192,52 @@ function findStaleFiles(store2, rootPath, workspaceId) {
|
|
|
26282
27192
|
const fnode = store2.getNode(fileNodeId(workspaceId, rel));
|
|
26283
27193
|
if (!fnode) {
|
|
26284
27194
|
stale.push(abs);
|
|
27195
|
+
} else if ((fnode.validTo ?? null) !== null) {
|
|
27196
|
+
stale.push(abs);
|
|
26285
27197
|
} else if (fnode.lastUpdatedAt < mtimeMs) {
|
|
26286
27198
|
stale.push(abs);
|
|
26287
27199
|
} else {
|
|
26288
27200
|
const edges = store2.outEdges(fnode.id, ["DEFINES", "CONTAINS"]);
|
|
26289
27201
|
if (edges.length === 0) {
|
|
26290
27202
|
stale.push(abs);
|
|
26291
|
-
} else
|
|
26292
|
-
|
|
27203
|
+
} else {
|
|
27204
|
+
const targets = edges.map((e) => e.to);
|
|
27205
|
+
pending.push({ abs, targets });
|
|
27206
|
+
allTargets.push(...targets);
|
|
26293
27207
|
}
|
|
26294
27208
|
}
|
|
26295
27209
|
}
|
|
27210
|
+
const live = /* @__PURE__ */ new Set();
|
|
27211
|
+
for (let i2 = 0; i2 < allTargets.length; i2 += LIVENESS_CHUNK) {
|
|
27212
|
+
for (const id of store2.liveNodeIds(allTargets.slice(i2, i2 + LIVENESS_CHUNK))) live.add(id);
|
|
27213
|
+
if (i2 + LIVENESS_CHUNK < allTargets.length) await new Promise((r) => setImmediate(r));
|
|
27214
|
+
}
|
|
27215
|
+
for (const { abs, targets } of pending) {
|
|
27216
|
+
if (targets.some((id) => !live.has(id))) stale.push(abs);
|
|
27217
|
+
}
|
|
26296
27218
|
return stale;
|
|
26297
27219
|
}
|
|
26298
|
-
function isLive(n) {
|
|
26299
|
-
return n != null && (n.validTo ?? null) === null;
|
|
26300
|
-
}
|
|
26301
27220
|
async function reconcileStaleFiles(store2, rootPath, workspaceId) {
|
|
26302
|
-
const stale = findStaleFiles(store2, rootPath, workspaceId);
|
|
27221
|
+
const stale = await findStaleFiles(store2, rootPath, workspaceId);
|
|
26303
27222
|
if (stale.length === 0) return 0;
|
|
26304
27223
|
let total = 0;
|
|
27224
|
+
let failedBatches = 0;
|
|
26305
27225
|
const BATCH = 20;
|
|
26306
27226
|
for (let i2 = 0; i2 < stale.length; i2 += BATCH) {
|
|
26307
|
-
|
|
26308
|
-
|
|
27227
|
+
try {
|
|
27228
|
+
const r = await incrementalReindex(store2, rootPath, workspaceId, stale.slice(i2, i2 + BATCH));
|
|
27229
|
+
total += r.filesReindexed;
|
|
27230
|
+
} catch (err2) {
|
|
27231
|
+
failedBatches++;
|
|
27232
|
+
console.warn(
|
|
27233
|
+
`[errata] reconcile: batch ${i2 / BATCH + 1} failed (${stale.slice(i2, i2 + BATCH).length} file(s) skipped): ${err2 instanceof Error ? err2.message : err2}`
|
|
27234
|
+
);
|
|
27235
|
+
}
|
|
26309
27236
|
if (i2 + BATCH < stale.length) await new Promise((res) => setImmediate(res));
|
|
26310
27237
|
}
|
|
27238
|
+
if (failedBatches > 0) {
|
|
27239
|
+
console.warn(`[errata] reconcile: ${failedBatches} batch(es) failed; ${total} file(s) reindexed`);
|
|
27240
|
+
}
|
|
26311
27241
|
return total;
|
|
26312
27242
|
}
|
|
26313
27243
|
|
|
@@ -26360,6 +27290,7 @@ function runNightly() {
|
|
|
26360
27290
|
const a = backfillLegacyAnchors(store, Date.now());
|
|
26361
27291
|
anchorsDemoted = a.demotedEdges;
|
|
26362
27292
|
resolutionsSuspect = a.suspects.length;
|
|
27293
|
+
repairLegacyAnchorsFromStatement(store, Date.now());
|
|
26363
27294
|
} catch {
|
|
26364
27295
|
}
|
|
26365
27296
|
const report = runNightlyPipeline(store);
|