@inerrata-corporation/errata 2.0.2-dev.503 → 2.0.2-dev.509
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 +13 -0
- package/errata.mjs +57 -13
- package/package.json +1 -1
- package/pass-worker.mjs +33 -7
package/consolidate-worker.mjs
CHANGED
|
@@ -16562,6 +16562,19 @@ var SqliteGraphStore = class {
|
|
|
16562
16562
|
const rows = this.db.prepare("SELECT from_id, to_id, type FROM edges WHERE valid_to IS NULL").all();
|
|
16563
16563
|
return rows.map((r) => ({ from: r.from_id, to: r.to_id, type: r.type }));
|
|
16564
16564
|
}
|
|
16565
|
+
liveNodeIds(ids) {
|
|
16566
|
+
const live = /* @__PURE__ */ new Set();
|
|
16567
|
+
const CHUNK = 900;
|
|
16568
|
+
for (let i = 0; i < ids.length; i += CHUNK) {
|
|
16569
|
+
const slice = ids.slice(i, i + CHUNK);
|
|
16570
|
+
if (slice.length === 0) continue;
|
|
16571
|
+
const rows = this.db.prepare(
|
|
16572
|
+
`SELECT id FROM nodes WHERE valid_to IS NULL AND id IN (${slice.map(() => "?").join(",")})`
|
|
16573
|
+
).all(...slice);
|
|
16574
|
+
for (const r of rows) live.add(r.id);
|
|
16575
|
+
}
|
|
16576
|
+
return live;
|
|
16577
|
+
}
|
|
16565
16578
|
/**
|
|
16566
16579
|
* Live edges WITH their endpoint labels and ids, resolved in ONE join.
|
|
16567
16580
|
*
|
package/errata.mjs
CHANGED
|
@@ -17237,6 +17237,19 @@ CREATE INDEX IF NOT EXISTS nodes_relpath ON nodes(json_extract(attrs_json, '$.re
|
|
|
17237
17237
|
const rows = this.db.prepare("SELECT from_id, to_id, type FROM edges WHERE valid_to IS NULL").all();
|
|
17238
17238
|
return rows.map((r) => ({ from: r.from_id, to: r.to_id, type: r.type }));
|
|
17239
17239
|
}
|
|
17240
|
+
liveNodeIds(ids) {
|
|
17241
|
+
const live = /* @__PURE__ */ new Set();
|
|
17242
|
+
const CHUNK = 900;
|
|
17243
|
+
for (let i2 = 0; i2 < ids.length; i2 += CHUNK) {
|
|
17244
|
+
const slice = ids.slice(i2, i2 + CHUNK);
|
|
17245
|
+
if (slice.length === 0) continue;
|
|
17246
|
+
const rows = this.db.prepare(
|
|
17247
|
+
`SELECT id FROM nodes WHERE valid_to IS NULL AND id IN (${slice.map(() => "?").join(",")})`
|
|
17248
|
+
).all(...slice);
|
|
17249
|
+
for (const r of rows) live.add(r.id);
|
|
17250
|
+
}
|
|
17251
|
+
return live;
|
|
17252
|
+
}
|
|
17240
17253
|
/**
|
|
17241
17254
|
* Live edges WITH their endpoint labels and ids, resolved in ONE join.
|
|
17242
17255
|
*
|
|
@@ -19462,10 +19475,12 @@ function parseIntentFences(text) {
|
|
|
19462
19475
|
}
|
|
19463
19476
|
function searchByIntent(store, intent, opts) {
|
|
19464
19477
|
const limit = opts?.limit ?? 5;
|
|
19465
|
-
const minCoverage = opts?.minCoverage ??
|
|
19478
|
+
const minCoverage = opts?.minCoverage ?? DEFAULT_MIN_COVERAGE;
|
|
19466
19479
|
const want = new Set(retrievalTokens(intent));
|
|
19467
19480
|
if (want.size < MIN_INTENT_TOKENS) return [];
|
|
19468
|
-
const
|
|
19481
|
+
const candidates = [];
|
|
19482
|
+
const df = /* @__PURE__ */ new Map();
|
|
19483
|
+
let corpus = 0;
|
|
19469
19484
|
for (const label of RECALLABLE) {
|
|
19470
19485
|
for (const node2 of store.findNodesByLabel(label)) {
|
|
19471
19486
|
if (node2.attrs["mergedInto"] !== void 0) continue;
|
|
@@ -19474,19 +19489,30 @@ function searchByIntent(store, intent, opts) {
|
|
|
19474
19489
|
}
|
|
19475
19490
|
const bag = retrievalTokens(node2.description ?? "");
|
|
19476
19491
|
if (bag.length === 0) continue;
|
|
19492
|
+
corpus++;
|
|
19477
19493
|
const matched = bag.filter((t) => want.has(t));
|
|
19478
|
-
|
|
19479
|
-
|
|
19480
|
-
if (coverage < minCoverage) continue;
|
|
19481
|
-
hits.push({ node: node2, coverage, matched });
|
|
19494
|
+
for (const t of matched) df.set(t, (df.get(t) ?? 0) + 1);
|
|
19495
|
+
if (matched.length > 0) candidates.push({ node: node2, matched });
|
|
19482
19496
|
}
|
|
19483
19497
|
}
|
|
19498
|
+
const idf = (t) => Math.log(1 + corpus / (1 + (df.get(t) ?? 0)));
|
|
19499
|
+
let denom = 0;
|
|
19500
|
+
for (const t of want) if ((df.get(t) ?? 0) > 0) denom += idf(t);
|
|
19501
|
+
if (denom === 0) return [];
|
|
19502
|
+
const hits = [];
|
|
19503
|
+
for (const { node: node2, matched } of candidates) {
|
|
19504
|
+
let num2 = 0;
|
|
19505
|
+
for (const t of matched) num2 += idf(t);
|
|
19506
|
+
const coverage = num2 / denom;
|
|
19507
|
+
if (coverage < minCoverage) continue;
|
|
19508
|
+
hits.push({ node: node2, coverage, matched });
|
|
19509
|
+
}
|
|
19484
19510
|
hits.sort(
|
|
19485
19511
|
(a, b) => b.coverage - a.coverage || (a.node.description?.length ?? 0) - (b.node.description?.length ?? 0)
|
|
19486
19512
|
);
|
|
19487
19513
|
return hits.slice(0, limit);
|
|
19488
19514
|
}
|
|
19489
|
-
var RECALLABLE, MIN_INTENT_TOKENS;
|
|
19515
|
+
var RECALLABLE, MIN_INTENT_TOKENS, DEFAULT_MIN_COVERAGE;
|
|
19490
19516
|
var init_intent = __esm({
|
|
19491
19517
|
"../../packages/local-graph/src/intent.ts"() {
|
|
19492
19518
|
"use strict";
|
|
@@ -19494,6 +19520,7 @@ var init_intent = __esm({
|
|
|
19494
19520
|
init_design_problem();
|
|
19495
19521
|
RECALLABLE = ["Problem", "Solution", "RootCause", "Pattern"];
|
|
19496
19522
|
MIN_INTENT_TOKENS = 2;
|
|
19523
|
+
DEFAULT_MIN_COVERAGE = 0.2;
|
|
19497
19524
|
}
|
|
19498
19525
|
});
|
|
19499
19526
|
|
|
@@ -21762,6 +21789,7 @@ __export(src_exports2, {
|
|
|
21762
21789
|
CITABLE_PRIOR_LABELS: () => CITABLE_PRIOR_LABELS,
|
|
21763
21790
|
CODE_REACH_EDGES: () => CODE_REACH_EDGES,
|
|
21764
21791
|
CREDIT_FAMILY: () => CREDIT_FAMILY,
|
|
21792
|
+
DEFAULT_MIN_COVERAGE: () => DEFAULT_MIN_COVERAGE,
|
|
21765
21793
|
FIX_CANDIDATE_ASK_LIMIT: () => FIX_CANDIDATE_ASK_LIMIT,
|
|
21766
21794
|
JOINT_COMMUNITY_EDGES: () => JOINT_COMMUNITY_EDGES,
|
|
21767
21795
|
JOINT_COMMUNITY_LABELS: () => JOINT_COMMUNITY_LABELS,
|
|
@@ -37781,9 +37809,13 @@ function* walkSource(dir) {
|
|
|
37781
37809
|
function listSourceFiles(root) {
|
|
37782
37810
|
return gitSourceFiles(root) ?? walkSource(root);
|
|
37783
37811
|
}
|
|
37784
|
-
function findStaleFiles(store, rootPath, workspaceId2) {
|
|
37812
|
+
async function findStaleFiles(store, rootPath, workspaceId2) {
|
|
37785
37813
|
const stale = [];
|
|
37814
|
+
const pending = [];
|
|
37815
|
+
const allTargets = [];
|
|
37816
|
+
let scanned = 0;
|
|
37786
37817
|
for (const abs of listSourceFiles(rootPath)) {
|
|
37818
|
+
if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
|
|
37787
37819
|
let mtimeMs;
|
|
37788
37820
|
try {
|
|
37789
37821
|
mtimeMs = statSync2(abs).mtimeMs;
|
|
@@ -37800,11 +37832,21 @@ function findStaleFiles(store, rootPath, workspaceId2) {
|
|
|
37800
37832
|
const edges = store.outEdges(fnode.id, ["DEFINES", "CONTAINS"]);
|
|
37801
37833
|
if (edges.length === 0) {
|
|
37802
37834
|
stale.push(abs);
|
|
37803
|
-
} else
|
|
37804
|
-
|
|
37835
|
+
} else {
|
|
37836
|
+
const targets = edges.map((e) => e.to);
|
|
37837
|
+
pending.push({ abs, targets });
|
|
37838
|
+
allTargets.push(...targets);
|
|
37805
37839
|
}
|
|
37806
37840
|
}
|
|
37807
37841
|
}
|
|
37842
|
+
const live = /* @__PURE__ */ new Set();
|
|
37843
|
+
for (let i2 = 0; i2 < allTargets.length; i2 += LIVENESS_CHUNK) {
|
|
37844
|
+
for (const id of store.liveNodeIds(allTargets.slice(i2, i2 + LIVENESS_CHUNK))) live.add(id);
|
|
37845
|
+
if (i2 + LIVENESS_CHUNK < allTargets.length) await new Promise((r) => setImmediate(r));
|
|
37846
|
+
}
|
|
37847
|
+
for (const { abs, targets } of pending) {
|
|
37848
|
+
if (targets.some((id) => !live.has(id))) stale.push(abs);
|
|
37849
|
+
}
|
|
37808
37850
|
return stale;
|
|
37809
37851
|
}
|
|
37810
37852
|
function isLive(n) {
|
|
@@ -37820,7 +37862,7 @@ function findStrandedSymbols(store) {
|
|
|
37820
37862
|
return stranded;
|
|
37821
37863
|
}
|
|
37822
37864
|
async function reconcileStaleFiles(store, rootPath, workspaceId2) {
|
|
37823
|
-
const stale = findStaleFiles(store, rootPath, workspaceId2);
|
|
37865
|
+
const stale = await findStaleFiles(store, rootPath, workspaceId2);
|
|
37824
37866
|
if (stale.length === 0) return 0;
|
|
37825
37867
|
let total = 0;
|
|
37826
37868
|
const BATCH = 20;
|
|
@@ -37831,13 +37873,15 @@ async function reconcileStaleFiles(store, rootPath, workspaceId2) {
|
|
|
37831
37873
|
}
|
|
37832
37874
|
return total;
|
|
37833
37875
|
}
|
|
37834
|
-
var IGNORED, SOURCE_RE;
|
|
37876
|
+
var IGNORED, SOURCE_RE, SCAN_YIELD_EVERY, LIVENESS_CHUNK;
|
|
37835
37877
|
var init_reconcile = __esm({
|
|
37836
37878
|
"src/reconcile.ts"() {
|
|
37837
37879
|
"use strict";
|
|
37838
37880
|
init_src11();
|
|
37839
37881
|
IGNORED = /[\\/](?:\.git|node_modules|\.errata|dist|__pycache__)(?:[\\/]|$)/;
|
|
37840
37882
|
SOURCE_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i;
|
|
37883
|
+
SCAN_YIELD_EVERY = 100;
|
|
37884
|
+
LIVENESS_CHUNK = 4e3;
|
|
37841
37885
|
}
|
|
37842
37886
|
});
|
|
37843
37887
|
|
|
@@ -53797,7 +53841,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
53797
53841
|
}
|
|
53798
53842
|
|
|
53799
53843
|
// src/engine.ts
|
|
53800
|
-
var DAEMON_VERSION = true ? "2.0.2-dev.
|
|
53844
|
+
var DAEMON_VERSION = true ? "2.0.2-dev.509" : "2.0.0-alpha.0";
|
|
53801
53845
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
53802
53846
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
53803
53847
|
var GIT_OP_MUTE_MS = 4e3;
|
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -24889,6 +24889,19 @@ var SqliteGraphStore = class {
|
|
|
24889
24889
|
const rows = this.db.prepare("SELECT from_id, to_id, type FROM edges WHERE valid_to IS NULL").all();
|
|
24890
24890
|
return rows.map((r) => ({ from: r.from_id, to: r.to_id, type: r.type }));
|
|
24891
24891
|
}
|
|
24892
|
+
liveNodeIds(ids) {
|
|
24893
|
+
const live = /* @__PURE__ */ new Set();
|
|
24894
|
+
const CHUNK = 900;
|
|
24895
|
+
for (let i2 = 0; i2 < ids.length; i2 += CHUNK) {
|
|
24896
|
+
const slice = ids.slice(i2, i2 + CHUNK);
|
|
24897
|
+
if (slice.length === 0) continue;
|
|
24898
|
+
const rows = this.db.prepare(
|
|
24899
|
+
`SELECT id FROM nodes WHERE valid_to IS NULL AND id IN (${slice.map(() => "?").join(",")})`
|
|
24900
|
+
).all(...slice);
|
|
24901
|
+
for (const r of rows) live.add(r.id);
|
|
24902
|
+
}
|
|
24903
|
+
return live;
|
|
24904
|
+
}
|
|
24892
24905
|
/**
|
|
24893
24906
|
* Live edges WITH their endpoint labels and ids, resolved in ONE join.
|
|
24894
24907
|
*
|
|
@@ -26708,9 +26721,15 @@ function* walkSource(dir) {
|
|
|
26708
26721
|
function listSourceFiles(root) {
|
|
26709
26722
|
return gitSourceFiles(root) ?? walkSource(root);
|
|
26710
26723
|
}
|
|
26711
|
-
|
|
26724
|
+
var SCAN_YIELD_EVERY = 100;
|
|
26725
|
+
var LIVENESS_CHUNK = 4e3;
|
|
26726
|
+
async function findStaleFiles(store2, rootPath, workspaceId) {
|
|
26712
26727
|
const stale = [];
|
|
26728
|
+
const pending = [];
|
|
26729
|
+
const allTargets = [];
|
|
26730
|
+
let scanned = 0;
|
|
26713
26731
|
for (const abs of listSourceFiles(rootPath)) {
|
|
26732
|
+
if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
|
|
26714
26733
|
let mtimeMs;
|
|
26715
26734
|
try {
|
|
26716
26735
|
mtimeMs = statSync2(abs).mtimeMs;
|
|
@@ -26727,18 +26746,25 @@ function findStaleFiles(store2, rootPath, workspaceId) {
|
|
|
26727
26746
|
const edges = store2.outEdges(fnode.id, ["DEFINES", "CONTAINS"]);
|
|
26728
26747
|
if (edges.length === 0) {
|
|
26729
26748
|
stale.push(abs);
|
|
26730
|
-
} else
|
|
26731
|
-
|
|
26749
|
+
} else {
|
|
26750
|
+
const targets = edges.map((e) => e.to);
|
|
26751
|
+
pending.push({ abs, targets });
|
|
26752
|
+
allTargets.push(...targets);
|
|
26732
26753
|
}
|
|
26733
26754
|
}
|
|
26734
26755
|
}
|
|
26756
|
+
const live = /* @__PURE__ */ new Set();
|
|
26757
|
+
for (let i2 = 0; i2 < allTargets.length; i2 += LIVENESS_CHUNK) {
|
|
26758
|
+
for (const id of store2.liveNodeIds(allTargets.slice(i2, i2 + LIVENESS_CHUNK))) live.add(id);
|
|
26759
|
+
if (i2 + LIVENESS_CHUNK < allTargets.length) await new Promise((r) => setImmediate(r));
|
|
26760
|
+
}
|
|
26761
|
+
for (const { abs, targets } of pending) {
|
|
26762
|
+
if (targets.some((id) => !live.has(id))) stale.push(abs);
|
|
26763
|
+
}
|
|
26735
26764
|
return stale;
|
|
26736
26765
|
}
|
|
26737
|
-
function isLive(n) {
|
|
26738
|
-
return n != null && (n.validTo ?? null) === null;
|
|
26739
|
-
}
|
|
26740
26766
|
async function reconcileStaleFiles(store2, rootPath, workspaceId) {
|
|
26741
|
-
const stale = findStaleFiles(store2, rootPath, workspaceId);
|
|
26767
|
+
const stale = await findStaleFiles(store2, rootPath, workspaceId);
|
|
26742
26768
|
if (stale.length === 0) return 0;
|
|
26743
26769
|
let total = 0;
|
|
26744
26770
|
const BATCH = 20;
|