@inerrata-corporation/errata 2.0.8-dev.2932 → 2.0.8
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 +12 -80
- package/errata.mjs +100 -302
- package/package.json +1 -1
- package/pass-worker.mjs +0 -42
package/consolidate-worker.mjs
CHANGED
|
@@ -16137,12 +16137,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS edges_triple ON edges(from_id, type, to_id);
|
|
|
16137
16137
|
`;
|
|
16138
16138
|
var TEMPORAL_INDEX_SQL = `
|
|
16139
16139
|
CREATE INDEX IF NOT EXISTS nodes_live ON nodes(label, valid_to);
|
|
16140
|
-
-- Covering + partial index for labelFingerprint over the instance labels: the
|
|
16141
|
-
-- live-push probe runs it per workspace on a timer, and each hit used to read
|
|
16142
|
-
-- its table row. Partial, so it maintains a few thousand rows instead of adding
|
|
16143
|
-
-- a write to every node write. Its label list is FINGERPRINT_INDEXED_LABELS.
|
|
16144
|
-
DROP INDEX IF EXISTS nodes_live_fingerprint;
|
|
16145
|
-
CREATE INDEX IF NOT EXISTS nodes_instance_fingerprint ON nodes(label, last_updated_at, last_reinforced_at_seq, created_at_seq) WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause');
|
|
16146
16140
|
CREATE INDEX IF NOT EXISTS nodes_logical ON nodes(logical_id, version);
|
|
16147
16141
|
CREATE INDEX IF NOT EXISTS edges_live ON edges(valid_to);
|
|
16148
16142
|
-- Expression index on the per-node relPath (stored in attrs_json) so the
|
|
@@ -16213,7 +16207,6 @@ function rowToEdge(r) {
|
|
|
16213
16207
|
attrs: JSON.parse(r.attrs_json)
|
|
16214
16208
|
};
|
|
16215
16209
|
}
|
|
16216
|
-
var FINGERPRINT_INDEXED_LABELS = ["Problem", "Solution", "RootCause"];
|
|
16217
16210
|
var SqliteGraphStore = class {
|
|
16218
16211
|
db;
|
|
16219
16212
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -16690,32 +16683,6 @@ var SqliteGraphStore = class {
|
|
|
16690
16683
|
attrs: JSON.parse(r.attrs_json)
|
|
16691
16684
|
}));
|
|
16692
16685
|
}
|
|
16693
|
-
*iterateNodeIdentitiesByLabel(label, pageSize = 2e3) {
|
|
16694
|
-
const page = this.db.prepare(
|
|
16695
|
-
"SELECT rowid AS rid, id, json_extract(attrs_json, '$.relPath') AS relPath, json_extract(attrs_json, '$.qname') AS qname FROM nodes WHERE rowid > ? AND label = ? AND valid_to IS NULL ORDER BY rowid LIMIT ?"
|
|
16696
|
-
);
|
|
16697
|
-
let after = 0;
|
|
16698
|
-
for (; ; ) {
|
|
16699
|
-
const rows = page.all(after, label, pageSize);
|
|
16700
|
-
for (const r of rows) {
|
|
16701
|
-
yield {
|
|
16702
|
-
id: r.id,
|
|
16703
|
-
relPath: typeof r.relPath === "string" ? r.relPath : null,
|
|
16704
|
-
qname: typeof r.qname === "string" ? r.qname : null
|
|
16705
|
-
};
|
|
16706
|
-
}
|
|
16707
|
-
if (rows.length < pageSize) return;
|
|
16708
|
-
after = rows[rows.length - 1].rid;
|
|
16709
|
-
}
|
|
16710
|
-
}
|
|
16711
|
-
recentNodeIds(label, limit) {
|
|
16712
|
-
const rows = this.db.prepare("SELECT id FROM nodes WHERE label = ? AND valid_to IS NULL ORDER BY last_updated_at DESC LIMIT ?").all(label, Math.max(0, limit));
|
|
16713
|
-
return rows.map((r) => r.id);
|
|
16714
|
-
}
|
|
16715
|
-
hasLiveNodes() {
|
|
16716
|
-
const r = this.db.prepare("SELECT EXISTS(SELECT 1 FROM nodes WHERE valid_to IS NULL) AS e").get();
|
|
16717
|
-
return r.e === 1;
|
|
16718
|
-
}
|
|
16719
16686
|
findNodeIdentitiesByLabel(label) {
|
|
16720
16687
|
const rows = this.stmts.identitiesByLabel.all(label);
|
|
16721
16688
|
return rows.map((r) => ({
|
|
@@ -16863,15 +16830,6 @@ var SqliteGraphStore = class {
|
|
|
16863
16830
|
}
|
|
16864
16831
|
labelFingerprint(labels) {
|
|
16865
16832
|
if (labels.length === 0) return "0";
|
|
16866
|
-
if (labels.length === FINGERPRINT_INDEXED_LABELS.length && FINGERPRINT_INDEXED_LABELS.every((l) => labels.includes(l))) {
|
|
16867
|
-
const r2 = this.db.prepare(
|
|
16868
|
-
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
16869
|
-
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
16870
|
-
FROM nodes INDEXED BY nodes_instance_fingerprint
|
|
16871
|
-
WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause')`
|
|
16872
|
-
).get();
|
|
16873
|
-
return `${r2.n}:${r2.t ?? 0}:${r2.s ?? 0}`;
|
|
16874
|
-
}
|
|
16875
16833
|
const r = this.db.prepare(
|
|
16876
16834
|
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
16877
16835
|
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
@@ -18216,15 +18174,6 @@ function generalize(text, opts = {}) {
|
|
|
18216
18174
|
// src/instance-ingest.ts
|
|
18217
18175
|
init_src();
|
|
18218
18176
|
|
|
18219
|
-
// src/instance-receipts.ts
|
|
18220
|
-
function receiptMap(attrs) {
|
|
18221
|
-
const value = attrs["instanceReceipts"];
|
|
18222
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
18223
|
-
}
|
|
18224
|
-
function instanceReceipt(n, destination) {
|
|
18225
|
-
return destination ? receiptMap(n.attrs)[destination] ?? {} : n.attrs;
|
|
18226
|
-
}
|
|
18227
|
-
|
|
18228
18177
|
// src/contribution-ready.ts
|
|
18229
18178
|
function cosine2(a, b) {
|
|
18230
18179
|
if (a.length === 0 || a.length !== b.length) return 0;
|
|
@@ -19094,8 +19043,8 @@ function stripCodebaseScope(scope) {
|
|
|
19094
19043
|
delete s["codebase"];
|
|
19095
19044
|
return s;
|
|
19096
19045
|
}
|
|
19097
|
-
function contributedWireId(n
|
|
19098
|
-
const cloudId =
|
|
19046
|
+
function contributedWireId(n) {
|
|
19047
|
+
const cloudId = n.attrs["cloudNodeId"];
|
|
19099
19048
|
return isMembraneSaltedId(cloudId) ? cloudId : n.id;
|
|
19100
19049
|
}
|
|
19101
19050
|
var WIRE_CANONICAL_ID_MIN = 6;
|
|
@@ -19239,26 +19188,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19239
19188
|
fileRefsSubstituted: 0,
|
|
19240
19189
|
fileRefLexiconMisses: 0
|
|
19241
19190
|
};
|
|
19242
|
-
const sharedCauses = /* @__PURE__ */ new Map();
|
|
19243
|
-
const causalQueue = store.findNodesByLabel("Problem").filter(
|
|
19244
|
-
(n) => n.attrs["source"] !== "cloud" && n.attrs["resolvedAs"] !== PROBLEM_RESOLUTION.FALSE_POSITIVE && !ignored(n.description)
|
|
19245
|
-
).map((n) => n.id);
|
|
19246
|
-
const causalSeen = new Set(causalQueue);
|
|
19247
|
-
for (let i = 0; i < causalQueue.length; i++) {
|
|
19248
|
-
const id = causalQueue[i];
|
|
19249
|
-
for (const e of [...store.outEdges(id, ["CAUSED_BY"]), ...opts.sharedStore?.outEdges(id, ["CAUSED_BY"]) ?? []]) {
|
|
19250
|
-
if (causalSeen.has(e.to)) continue;
|
|
19251
|
-
causalSeen.add(e.to);
|
|
19252
|
-
const cause = nodeOf(e.to);
|
|
19253
|
-
if (!cause || cause.label !== "RootCause" || cause.attrs["source"] === "cloud" || ignored(cause.description)) continue;
|
|
19254
|
-
sharedCauses.set(cause.id, cause);
|
|
19255
|
-
causalQueue.push(cause.id);
|
|
19256
|
-
}
|
|
19257
|
-
}
|
|
19258
19191
|
for (const label of INSTANCE_LABELS) {
|
|
19259
19192
|
const ref = [];
|
|
19260
19193
|
includedByLabel.set(label, ref);
|
|
19261
|
-
const population = label === "RootCause" && opts.sharedStore ? [...store.findNodesByLabel(label), ...
|
|
19194
|
+
const population = label === "RootCause" && opts.sharedStore ? [...store.findNodesByLabel(label), ...opts.sharedStore.findNodesByLabel(label)] : store.findNodesByLabel(label);
|
|
19262
19195
|
for (const n of population) {
|
|
19263
19196
|
if (seen.has(n.id)) continue;
|
|
19264
19197
|
if (walked.has(n.id)) continue;
|
|
@@ -19276,18 +19209,18 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19276
19209
|
composition.ignored++;
|
|
19277
19210
|
continue;
|
|
19278
19211
|
}
|
|
19279
|
-
const contributedAtSeq =
|
|
19212
|
+
const contributedAtSeq = n.attrs["contributedAtSeq"];
|
|
19280
19213
|
if (typeof contributedAtSeq === "number" && (n.lastReinforcedAtSeq ?? 0) <= contributedAtSeq) {
|
|
19281
19214
|
composition.watermarked++;
|
|
19282
19215
|
anchorSources.add(n.id);
|
|
19283
|
-
semanticEndpoints.set(n.id, contributedWireId(n
|
|
19216
|
+
semanticEndpoints.set(n.id, contributedWireId(n));
|
|
19284
19217
|
continue;
|
|
19285
19218
|
}
|
|
19286
19219
|
if (label === "Solution" && n.description.startsWith(AUTO_MINT_PREFIX)) {
|
|
19287
19220
|
composition.autoMint++;
|
|
19288
19221
|
continue;
|
|
19289
19222
|
}
|
|
19290
|
-
if (isTerminallyRefused(
|
|
19223
|
+
if (isTerminallyRefused(n)) {
|
|
19291
19224
|
composition.terminalRefused++;
|
|
19292
19225
|
continue;
|
|
19293
19226
|
}
|
|
@@ -19346,9 +19279,9 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19346
19279
|
}
|
|
19347
19280
|
const dg = digest(targets.map(({ e, wireId }) => `${e.type}>${wireId}`).sort());
|
|
19348
19281
|
const sourceNode = nodeOf(sourceId);
|
|
19349
|
-
if (
|
|
19282
|
+
if (sourceNode?.attrs["anchorsContributedDigest"] === dg) continue;
|
|
19350
19283
|
anchorDigests[sourceId] = dg;
|
|
19351
|
-
const wireFrom = seen.has(sourceId) || !sourceNode ? sourceId : contributedWireId(sourceNode
|
|
19284
|
+
const wireFrom = seen.has(sourceId) || !sourceNode ? sourceId : contributedWireId(sourceNode);
|
|
19352
19285
|
for (const { e, t, wireId } of targets) {
|
|
19353
19286
|
const reject = unshippableReason(wireId, t.label);
|
|
19354
19287
|
if (reject) {
|
|
@@ -19377,7 +19310,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19377
19310
|
for (const sourceId of anchorSources) {
|
|
19378
19311
|
const source = nodeOf(sourceId);
|
|
19379
19312
|
if (!source) continue;
|
|
19380
|
-
const wireFrom = seen.has(sourceId) ? sourceId : contributedWireId(source
|
|
19313
|
+
const wireFrom = seen.has(sourceId) ? sourceId : contributedWireId(source);
|
|
19381
19314
|
const planned = [];
|
|
19382
19315
|
for (const e of store.outEdges(sourceId, ["ANCHORED_AT"])) {
|
|
19383
19316
|
const target = nodeOf(e.to);
|
|
@@ -19412,7 +19345,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19412
19345
|
const dg = digest(
|
|
19413
19346
|
planned.map(({ symId, wireAttrs }) => `ANCHORED_AT>${symId}>${JSON.stringify(wireAttrs)}`).sort()
|
|
19414
19347
|
);
|
|
19415
|
-
if (
|
|
19348
|
+
if (source.attrs["projectAnchorsContributedDigest"] === dg) continue;
|
|
19416
19349
|
projectAnchorDigests[sourceId] = dg;
|
|
19417
19350
|
for (const { e, target, symId, wireAttrs } of planned) {
|
|
19418
19351
|
if (!contextSeen.has(symId)) {
|
|
@@ -19458,7 +19391,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19458
19391
|
if (outs.length === 0) continue;
|
|
19459
19392
|
const dg = digest(outs.map(({ e, wireTo }) => `${e.type}>${wireTo}`).sort());
|
|
19460
19393
|
const owner = nodeOf(sourceId);
|
|
19461
|
-
const digestSkip =
|
|
19394
|
+
const digestSkip = owner?.attrs["semanticEdgesContributedDigest"] === dg;
|
|
19462
19395
|
if (!digestSkip) semanticEdgeDigests[sourceId] = dg;
|
|
19463
19396
|
for (const { e, wireTo } of outs) {
|
|
19464
19397
|
if (digestSkip && !shippedById.has(e.to)) continue;
|
|
@@ -19515,7 +19448,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
19515
19448
|
for (const wn of nodes) {
|
|
19516
19449
|
if (wn.label !== "RootCause" && wn.label !== "Solution") continue;
|
|
19517
19450
|
const src = nodeOf(wn.id);
|
|
19518
|
-
if (
|
|
19451
|
+
if (typeof src?.attrs["contributedAtSeq"] === "number") continue;
|
|
19519
19452
|
if (bindingEndpoints.has(wn.id)) continue;
|
|
19520
19453
|
heldOrphans.add(wn.id);
|
|
19521
19454
|
}
|
|
@@ -19593,7 +19526,6 @@ function buildDrainInstances(store, sharedStore, input) {
|
|
|
19593
19526
|
...input.includePackages !== void 0 ? { includePackages: input.includePackages } : {},
|
|
19594
19527
|
workspaceRoot: input.workspaceRoot,
|
|
19595
19528
|
sharedStore,
|
|
19596
|
-
destinationKey: input.destinationKey,
|
|
19597
19529
|
onComposition: (c) => {
|
|
19598
19530
|
composition = c;
|
|
19599
19531
|
},
|
package/errata.mjs
CHANGED
|
@@ -17438,7 +17438,7 @@ function rowToEdge(r) {
|
|
|
17438
17438
|
function openGraphStore(opts) {
|
|
17439
17439
|
return new SqliteGraphStore(opts);
|
|
17440
17440
|
}
|
|
17441
|
-
var LOCAL_RULE_OVERRIDES, SCHEMA_VERSION, SCHEMA_SQL, TEMPORAL_INDEX_SQL,
|
|
17441
|
+
var LOCAL_RULE_OVERRIDES, SCHEMA_VERSION, SCHEMA_SQL, TEMPORAL_INDEX_SQL, SqliteGraphStore;
|
|
17442
17442
|
var init_store = __esm({
|
|
17443
17443
|
"../../packages/local-graph/src/store.ts"() {
|
|
17444
17444
|
"use strict";
|
|
@@ -17559,12 +17559,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS edges_triple ON edges(from_id, type, to_id);
|
|
|
17559
17559
|
`;
|
|
17560
17560
|
TEMPORAL_INDEX_SQL = `
|
|
17561
17561
|
CREATE INDEX IF NOT EXISTS nodes_live ON nodes(label, valid_to);
|
|
17562
|
-
-- Covering + partial index for labelFingerprint over the instance labels: the
|
|
17563
|
-
-- live-push probe runs it per workspace on a timer, and each hit used to read
|
|
17564
|
-
-- its table row. Partial, so it maintains a few thousand rows instead of adding
|
|
17565
|
-
-- a write to every node write. Its label list is FINGERPRINT_INDEXED_LABELS.
|
|
17566
|
-
DROP INDEX IF EXISTS nodes_live_fingerprint;
|
|
17567
|
-
CREATE INDEX IF NOT EXISTS nodes_instance_fingerprint ON nodes(label, last_updated_at, last_reinforced_at_seq, created_at_seq) WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause');
|
|
17568
17562
|
CREATE INDEX IF NOT EXISTS nodes_logical ON nodes(logical_id, version);
|
|
17569
17563
|
CREATE INDEX IF NOT EXISTS edges_live ON edges(valid_to);
|
|
17570
17564
|
-- Expression index on the per-node relPath (stored in attrs_json) so the
|
|
@@ -17578,7 +17572,6 @@ CREATE INDEX IF NOT EXISTS nodes_live_description ON nodes(description, label) W
|
|
|
17578
17572
|
-- every edited file of every turn, and a scan parses every Problem's attrs.
|
|
17579
17573
|
CREATE INDEX IF NOT EXISTS nodes_anchor_hint_path ON nodes(json_extract(attrs_json, '$.anchorHint.path')) WHERE valid_to IS NULL;
|
|
17580
17574
|
`;
|
|
17581
|
-
FINGERPRINT_INDEXED_LABELS = ["Problem", "Solution", "RootCause"];
|
|
17582
17575
|
SqliteGraphStore = class {
|
|
17583
17576
|
db;
|
|
17584
17577
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -18055,32 +18048,6 @@ CREATE INDEX IF NOT EXISTS nodes_anchor_hint_path ON nodes(json_extract(attrs_js
|
|
|
18055
18048
|
attrs: JSON.parse(r.attrs_json)
|
|
18056
18049
|
}));
|
|
18057
18050
|
}
|
|
18058
|
-
*iterateNodeIdentitiesByLabel(label, pageSize = 2e3) {
|
|
18059
|
-
const page = this.db.prepare(
|
|
18060
|
-
"SELECT rowid AS rid, id, json_extract(attrs_json, '$.relPath') AS relPath, json_extract(attrs_json, '$.qname') AS qname FROM nodes WHERE rowid > ? AND label = ? AND valid_to IS NULL ORDER BY rowid LIMIT ?"
|
|
18061
|
-
);
|
|
18062
|
-
let after = 0;
|
|
18063
|
-
for (; ; ) {
|
|
18064
|
-
const rows = page.all(after, label, pageSize);
|
|
18065
|
-
for (const r of rows) {
|
|
18066
|
-
yield {
|
|
18067
|
-
id: r.id,
|
|
18068
|
-
relPath: typeof r.relPath === "string" ? r.relPath : null,
|
|
18069
|
-
qname: typeof r.qname === "string" ? r.qname : null
|
|
18070
|
-
};
|
|
18071
|
-
}
|
|
18072
|
-
if (rows.length < pageSize) return;
|
|
18073
|
-
after = rows[rows.length - 1].rid;
|
|
18074
|
-
}
|
|
18075
|
-
}
|
|
18076
|
-
recentNodeIds(label, limit) {
|
|
18077
|
-
const rows = this.db.prepare("SELECT id FROM nodes WHERE label = ? AND valid_to IS NULL ORDER BY last_updated_at DESC LIMIT ?").all(label, Math.max(0, limit));
|
|
18078
|
-
return rows.map((r) => r.id);
|
|
18079
|
-
}
|
|
18080
|
-
hasLiveNodes() {
|
|
18081
|
-
const r = this.db.prepare("SELECT EXISTS(SELECT 1 FROM nodes WHERE valid_to IS NULL) AS e").get();
|
|
18082
|
-
return r.e === 1;
|
|
18083
|
-
}
|
|
18084
18051
|
findNodeIdentitiesByLabel(label) {
|
|
18085
18052
|
const rows = this.stmts.identitiesByLabel.all(label);
|
|
18086
18053
|
return rows.map((r) => ({
|
|
@@ -18228,15 +18195,6 @@ CREATE INDEX IF NOT EXISTS nodes_anchor_hint_path ON nodes(json_extract(attrs_js
|
|
|
18228
18195
|
}
|
|
18229
18196
|
labelFingerprint(labels) {
|
|
18230
18197
|
if (labels.length === 0) return "0";
|
|
18231
|
-
if (labels.length === FINGERPRINT_INDEXED_LABELS.length && FINGERPRINT_INDEXED_LABELS.every((l) => labels.includes(l))) {
|
|
18232
|
-
const r2 = this.db.prepare(
|
|
18233
|
-
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
18234
|
-
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
18235
|
-
FROM nodes INDEXED BY nodes_instance_fingerprint
|
|
18236
|
-
WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause')`
|
|
18237
|
-
).get();
|
|
18238
|
-
return `${r2.n}:${r2.t ?? 0}:${r2.s ?? 0}`;
|
|
18239
|
-
}
|
|
18240
18198
|
const r = this.db.prepare(
|
|
18241
18199
|
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
18242
18200
|
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
@@ -24020,7 +23978,6 @@ __export(src_exports2, {
|
|
|
24020
23978
|
CODE_REACH_EDGES: () => CODE_REACH_EDGES,
|
|
24021
23979
|
CREDIT_FAMILY: () => CREDIT_FAMILY,
|
|
24022
23980
|
DEFAULT_MIN_COVERAGE: () => DEFAULT_MIN_COVERAGE,
|
|
24023
|
-
FINGERPRINT_INDEXED_LABELS: () => FINGERPRINT_INDEXED_LABELS,
|
|
24024
23981
|
FIX_CANDIDATE_ASK_LIMIT: () => FIX_CANDIDATE_ASK_LIMIT,
|
|
24025
23982
|
FOLD_EMBED_AUTO_COSINE: () => FOLD_EMBED_AUTO_COSINE,
|
|
24026
23983
|
FOLD_JUDGE_MIN_COSINE: () => FOLD_JUDGE_MIN_COSINE,
|
|
@@ -26368,8 +26325,8 @@ var init_config = __esm({
|
|
|
26368
26325
|
"use strict";
|
|
26369
26326
|
init_paths();
|
|
26370
26327
|
LEGACY_CLOUD_URL = "https://inerrata-gateway.onrender.com";
|
|
26371
|
-
DEFAULT_CLOUD_URL = true ? "https://
|
|
26372
|
-
DEFAULT_UPDATE_CHANNEL =
|
|
26328
|
+
DEFAULT_CLOUD_URL = true ? "https://inerrata.dev" : DEV_CLOUD_URL;
|
|
26329
|
+
DEFAULT_UPDATE_CHANNEL = true ? "latest" : "dev";
|
|
26373
26330
|
}
|
|
26374
26331
|
});
|
|
26375
26332
|
|
|
@@ -29174,12 +29131,6 @@ function statuslineText(sessionId, now = Date.now()) {
|
|
|
29174
29131
|
if (!hit || now - hit.at > STATUS_CARD_TTL_MS) return IDLE_STATUS;
|
|
29175
29132
|
return renderStatusCard(hit.card);
|
|
29176
29133
|
}
|
|
29177
|
-
function statuslineDir(body2) {
|
|
29178
|
-
const ws = body2["workspace"];
|
|
29179
|
-
const current = ws && typeof ws === "object" ? ws["current_dir"] : void 0;
|
|
29180
|
-
if (typeof current === "string" && current) return current;
|
|
29181
|
-
return typeof body2["cwd"] === "string" && body2["cwd"] ? body2["cwd"] : null;
|
|
29182
|
-
}
|
|
29183
29134
|
function recallCardEnabled(env2 = process.env) {
|
|
29184
29135
|
const v = (env2["ERRATA_RECALL_CARD"] ?? "").trim().toLowerCase();
|
|
29185
29136
|
return !(v === "0" || v === "off" || v === "false" || v === "no");
|
|
@@ -29506,18 +29457,6 @@ function resolveWorkspaceIdentity(cfg, entry, env2 = process.env) {
|
|
|
29506
29457
|
function identityKey(id) {
|
|
29507
29458
|
return id.profileName ?? "@default";
|
|
29508
29459
|
}
|
|
29509
|
-
function publicWorkspaceIdentity(identity) {
|
|
29510
|
-
return {
|
|
29511
|
-
profileName: identity.profileName,
|
|
29512
|
-
rule: identity.rule,
|
|
29513
|
-
invalid: identity.invalid,
|
|
29514
|
-
reason: identity.reason,
|
|
29515
|
-
profile: identity.profile ? {
|
|
29516
|
-
installationId: identity.profile.installationId,
|
|
29517
|
-
cloudUrl: identity.profile.cloudUrl
|
|
29518
|
-
} : null
|
|
29519
|
-
};
|
|
29520
|
-
}
|
|
29521
29460
|
function blockedCloudClient(reason) {
|
|
29522
29461
|
return new Proxy(
|
|
29523
29462
|
{},
|
|
@@ -71454,7 +71393,7 @@ var init_report_render = __esm({
|
|
|
71454
71393
|
|
|
71455
71394
|
// src/cli.ts
|
|
71456
71395
|
init_src6();
|
|
71457
|
-
import { closeSync as closeSync2, existsSync as
|
|
71396
|
+
import { closeSync as closeSync2, existsSync as existsSync34, openSync as openSync2, readFileSync as readFileSync35, renameSync as renameSync4, statSync as statSync10 } from "node:fs";
|
|
71458
71397
|
import { join as join43, resolve as pathResolve2 } from "node:path";
|
|
71459
71398
|
import { spawn as spawn5 } from "node:child_process";
|
|
71460
71399
|
|
|
@@ -72776,9 +72715,9 @@ var NodeFsHandler = class {
|
|
|
72776
72715
|
if (this.fsw.closed) {
|
|
72777
72716
|
return;
|
|
72778
72717
|
}
|
|
72779
|
-
const
|
|
72718
|
+
const dirname13 = sysPath.dirname(file2);
|
|
72780
72719
|
const basename8 = sysPath.basename(file2);
|
|
72781
|
-
const parent = this.fsw._getWatchedDir(
|
|
72720
|
+
const parent = this.fsw._getWatchedDir(dirname13);
|
|
72782
72721
|
let prevStats = stats;
|
|
72783
72722
|
if (parent.has(basename8))
|
|
72784
72723
|
return;
|
|
@@ -72805,7 +72744,7 @@ var NodeFsHandler = class {
|
|
|
72805
72744
|
prevStats = newStats2;
|
|
72806
72745
|
}
|
|
72807
72746
|
} catch (error48) {
|
|
72808
|
-
this.fsw._remove(
|
|
72747
|
+
this.fsw._remove(dirname13, basename8);
|
|
72809
72748
|
}
|
|
72810
72749
|
} else if (parent.has(basename8)) {
|
|
72811
72750
|
const at = newStats.atimeMs;
|
|
@@ -80279,7 +80218,7 @@ function createWatchBreaker(deps) {
|
|
|
80279
80218
|
}
|
|
80280
80219
|
|
|
80281
80220
|
// src/engine.ts
|
|
80282
|
-
var DAEMON_VERSION = true ? "2.0.8
|
|
80221
|
+
var DAEMON_VERSION = true ? "2.0.8" : "2.0.0-alpha.0";
|
|
80283
80222
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
80284
80223
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
80285
80224
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -80846,7 +80785,7 @@ function createWorkspaceEngine(opts) {
|
|
|
80846
80785
|
lastRemoteAt = now;
|
|
80847
80786
|
try {
|
|
80848
80787
|
const norm = normStackTokens;
|
|
80849
|
-
const seed = store.
|
|
80788
|
+
const seed = store.findNodesByLabel("Problem").sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt).slice(0, 6).map((p) => p.id);
|
|
80850
80789
|
const q = {
|
|
80851
80790
|
stack: outboundStack(),
|
|
80852
80791
|
domains: norm(profile.domains),
|
|
@@ -82725,40 +82664,6 @@ async function listenServer(fetchFn, port) {
|
|
|
82725
82664
|
init_registry();
|
|
82726
82665
|
init_identity2();
|
|
82727
82666
|
|
|
82728
|
-
// src/instance-receipts.ts
|
|
82729
|
-
import { createHash as createHash16 } from "node:crypto";
|
|
82730
|
-
var FIELDS = ["contributedAtSeq", "cloudNodeId", "anchorsContributedDigest", "projectAnchorsContributedDigest", "semanticEdgesContributedDigest", "shipRefusedSinceSeq", "shipRefusedCount", "shipRefusedReason", "shipRefusedFingerprint"];
|
|
82731
|
-
function instanceDestinationKey(input) {
|
|
82732
|
-
return createHash16("sha256").update(JSON.stringify([
|
|
82733
|
-
input.workspace,
|
|
82734
|
-
input.cloudUrl.replace(/\/+$/, ""),
|
|
82735
|
-
input.installationId ?? input.profileName ?? "default",
|
|
82736
|
-
input.projectId ?? null,
|
|
82737
|
-
input.writeTarget?.visibility ?? null,
|
|
82738
|
-
input.writeTarget?.org_id ?? null,
|
|
82739
|
-
input.writeTarget?.team_id ?? null
|
|
82740
|
-
])).digest("hex");
|
|
82741
|
-
}
|
|
82742
|
-
function receiptMap(attrs) {
|
|
82743
|
-
const value = attrs["instanceReceipts"];
|
|
82744
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
82745
|
-
}
|
|
82746
|
-
function instanceReceipt(n, destination) {
|
|
82747
|
-
return destination ? receiptMap(n.attrs)[destination] ?? {} : n.attrs;
|
|
82748
|
-
}
|
|
82749
|
-
function updateInstanceReceipt(n, destination, patch, mirrorLegacy) {
|
|
82750
|
-
const receipt = { ...instanceReceipt(n, destination), ...patch };
|
|
82751
|
-
const attrs = { ...n.attrs, instanceReceipts: { ...receiptMap(n.attrs), [destination]: receipt } };
|
|
82752
|
-
if (mirrorLegacy) for (const field of FIELDS) {
|
|
82753
|
-
if (field in receipt) attrs[field] = receipt[field];
|
|
82754
|
-
else delete attrs[field];
|
|
82755
|
-
}
|
|
82756
|
-
return attrs;
|
|
82757
|
-
}
|
|
82758
|
-
function instanceReceiptSequence(n) {
|
|
82759
|
-
return Math.max(n.lastReinforcedAtSeq ?? 0, n.createdAtSeq ?? 0);
|
|
82760
|
-
}
|
|
82761
|
-
|
|
82762
82667
|
// src/multi.ts
|
|
82763
82668
|
init_dist();
|
|
82764
82669
|
init_src5();
|
|
@@ -83163,8 +83068,8 @@ function compositionCounters(c) {
|
|
|
83163
83068
|
...Object.fromEntries(buckets.map((b) => [`sidecarDrop_${b}`, sidecarDropReasons[b] ?? 0]))
|
|
83164
83069
|
};
|
|
83165
83070
|
}
|
|
83166
|
-
function contributedWireId(n
|
|
83167
|
-
const cloudId =
|
|
83071
|
+
function contributedWireId(n) {
|
|
83072
|
+
const cloudId = n.attrs["cloudNodeId"];
|
|
83168
83073
|
return isMembraneSaltedId(cloudId) ? cloudId : n.id;
|
|
83169
83074
|
}
|
|
83170
83075
|
var WIRE_CANONICAL_ID_MIN = 6;
|
|
@@ -83308,26 +83213,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83308
83213
|
fileRefsSubstituted: 0,
|
|
83309
83214
|
fileRefLexiconMisses: 0
|
|
83310
83215
|
};
|
|
83311
|
-
const sharedCauses = /* @__PURE__ */ new Map();
|
|
83312
|
-
const causalQueue = store.findNodesByLabel("Problem").filter(
|
|
83313
|
-
(n) => n.attrs["source"] !== "cloud" && n.attrs["resolvedAs"] !== PROBLEM_RESOLUTION.FALSE_POSITIVE && !ignored(n.description)
|
|
83314
|
-
).map((n) => n.id);
|
|
83315
|
-
const causalSeen = new Set(causalQueue);
|
|
83316
|
-
for (let i2 = 0; i2 < causalQueue.length; i2++) {
|
|
83317
|
-
const id = causalQueue[i2];
|
|
83318
|
-
for (const e of [...store.outEdges(id, ["CAUSED_BY"]), ...opts.sharedStore?.outEdges(id, ["CAUSED_BY"]) ?? []]) {
|
|
83319
|
-
if (causalSeen.has(e.to)) continue;
|
|
83320
|
-
causalSeen.add(e.to);
|
|
83321
|
-
const cause = nodeOf(e.to);
|
|
83322
|
-
if (!cause || cause.label !== "RootCause" || cause.attrs["source"] === "cloud" || ignored(cause.description)) continue;
|
|
83323
|
-
sharedCauses.set(cause.id, cause);
|
|
83324
|
-
causalQueue.push(cause.id);
|
|
83325
|
-
}
|
|
83326
|
-
}
|
|
83327
83216
|
for (const label of INSTANCE_LABELS) {
|
|
83328
83217
|
const ref = [];
|
|
83329
83218
|
includedByLabel.set(label, ref);
|
|
83330
|
-
const population = label === "RootCause" && opts.sharedStore ? [...store.findNodesByLabel(label), ...
|
|
83219
|
+
const population = label === "RootCause" && opts.sharedStore ? [...store.findNodesByLabel(label), ...opts.sharedStore.findNodesByLabel(label)] : store.findNodesByLabel(label);
|
|
83331
83220
|
for (const n of population) {
|
|
83332
83221
|
if (seen.has(n.id)) continue;
|
|
83333
83222
|
if (walked.has(n.id)) continue;
|
|
@@ -83345,18 +83234,18 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83345
83234
|
composition.ignored++;
|
|
83346
83235
|
continue;
|
|
83347
83236
|
}
|
|
83348
|
-
const contributedAtSeq =
|
|
83237
|
+
const contributedAtSeq = n.attrs["contributedAtSeq"];
|
|
83349
83238
|
if (typeof contributedAtSeq === "number" && (n.lastReinforcedAtSeq ?? 0) <= contributedAtSeq) {
|
|
83350
83239
|
composition.watermarked++;
|
|
83351
83240
|
anchorSources.add(n.id);
|
|
83352
|
-
semanticEndpoints.set(n.id, contributedWireId(n
|
|
83241
|
+
semanticEndpoints.set(n.id, contributedWireId(n));
|
|
83353
83242
|
continue;
|
|
83354
83243
|
}
|
|
83355
83244
|
if (label === "Solution" && n.description.startsWith(AUTO_MINT_PREFIX)) {
|
|
83356
83245
|
composition.autoMint++;
|
|
83357
83246
|
continue;
|
|
83358
83247
|
}
|
|
83359
|
-
if (isTerminallyRefused(
|
|
83248
|
+
if (isTerminallyRefused(n)) {
|
|
83360
83249
|
composition.terminalRefused++;
|
|
83361
83250
|
continue;
|
|
83362
83251
|
}
|
|
@@ -83415,9 +83304,9 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83415
83304
|
}
|
|
83416
83305
|
const dg = digest(targets.map(({ e, wireId }) => `${e.type}>${wireId}`).sort());
|
|
83417
83306
|
const sourceNode = nodeOf(sourceId);
|
|
83418
|
-
if (
|
|
83307
|
+
if (sourceNode?.attrs["anchorsContributedDigest"] === dg) continue;
|
|
83419
83308
|
anchorDigests[sourceId] = dg;
|
|
83420
|
-
const wireFrom = seen.has(sourceId) || !sourceNode ? sourceId : contributedWireId(sourceNode
|
|
83309
|
+
const wireFrom = seen.has(sourceId) || !sourceNode ? sourceId : contributedWireId(sourceNode);
|
|
83421
83310
|
for (const { e, t, wireId } of targets) {
|
|
83422
83311
|
const reject = unshippableReason(wireId, t.label);
|
|
83423
83312
|
if (reject) {
|
|
@@ -83446,7 +83335,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83446
83335
|
for (const sourceId of anchorSources) {
|
|
83447
83336
|
const source = nodeOf(sourceId);
|
|
83448
83337
|
if (!source) continue;
|
|
83449
|
-
const wireFrom = seen.has(sourceId) ? sourceId : contributedWireId(source
|
|
83338
|
+
const wireFrom = seen.has(sourceId) ? sourceId : contributedWireId(source);
|
|
83450
83339
|
const planned = [];
|
|
83451
83340
|
for (const e of store.outEdges(sourceId, ["ANCHORED_AT"])) {
|
|
83452
83341
|
const target = nodeOf(e.to);
|
|
@@ -83481,7 +83370,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83481
83370
|
const dg = digest(
|
|
83482
83371
|
planned.map(({ symId, wireAttrs }) => `ANCHORED_AT>${symId}>${JSON.stringify(wireAttrs)}`).sort()
|
|
83483
83372
|
);
|
|
83484
|
-
if (
|
|
83373
|
+
if (source.attrs["projectAnchorsContributedDigest"] === dg) continue;
|
|
83485
83374
|
projectAnchorDigests[sourceId] = dg;
|
|
83486
83375
|
for (const { e, target, symId, wireAttrs } of planned) {
|
|
83487
83376
|
if (!contextSeen.has(symId)) {
|
|
@@ -83527,7 +83416,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83527
83416
|
if (outs.length === 0) continue;
|
|
83528
83417
|
const dg = digest(outs.map(({ e, wireTo }) => `${e.type}>${wireTo}`).sort());
|
|
83529
83418
|
const owner = nodeOf(sourceId);
|
|
83530
|
-
const digestSkip =
|
|
83419
|
+
const digestSkip = owner?.attrs["semanticEdgesContributedDigest"] === dg;
|
|
83531
83420
|
if (!digestSkip) semanticEdgeDigests[sourceId] = dg;
|
|
83532
83421
|
for (const { e, wireTo } of outs) {
|
|
83533
83422
|
if (digestSkip && !shippedById.has(e.to)) continue;
|
|
@@ -83584,7 +83473,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
83584
83473
|
for (const wn of nodes) {
|
|
83585
83474
|
if (wn.label !== "RootCause" && wn.label !== "Solution") continue;
|
|
83586
83475
|
const src = nodeOf(wn.id);
|
|
83587
|
-
if (
|
|
83476
|
+
if (typeof src?.attrs["contributedAtSeq"] === "number") continue;
|
|
83588
83477
|
if (bindingEndpoints.has(wn.id)) continue;
|
|
83589
83478
|
heldOrphans.add(wn.id);
|
|
83590
83479
|
}
|
|
@@ -83738,7 +83627,6 @@ function buildDrainInstances(store, sharedStore, input) {
|
|
|
83738
83627
|
...input.includePackages !== void 0 ? { includePackages: input.includePackages } : {},
|
|
83739
83628
|
workspaceRoot: input.workspaceRoot,
|
|
83740
83629
|
sharedStore,
|
|
83741
|
-
destinationKey: input.destinationKey,
|
|
83742
83630
|
onComposition: (c) => {
|
|
83743
83631
|
composition = c;
|
|
83744
83632
|
},
|
|
@@ -84236,7 +84124,7 @@ function buildReverseSymbolMap(opts) {
|
|
|
84236
84124
|
function* reverseSymbolEntries(opts) {
|
|
84237
84125
|
const { store, salt, projectId } = opts;
|
|
84238
84126
|
for (const kind of ANCHOR_SYMBOL_KINDS2) {
|
|
84239
|
-
for (const n of store.
|
|
84127
|
+
for (const n of store.findNodeIdentitiesByLabel(kind)) {
|
|
84240
84128
|
const { relPath, qname } = n;
|
|
84241
84129
|
if (relPath === null || qname === null) continue;
|
|
84242
84130
|
const sym = projectSymbolId(salt, projectId, relPath, qname, kind);
|
|
@@ -84244,7 +84132,7 @@ function* reverseSymbolEntries(opts) {
|
|
|
84244
84132
|
yield [projectSaltedNodeId(sym, salt), n.id];
|
|
84245
84133
|
}
|
|
84246
84134
|
}
|
|
84247
|
-
for (const n of store.
|
|
84135
|
+
for (const n of store.findNodeIdentitiesByLabel("File")) {
|
|
84248
84136
|
if (n.relPath === null) continue;
|
|
84249
84137
|
const sym = projectSymbolId(salt, projectId, n.relPath, FILE_ANCHOR_QNAME, "File");
|
|
84250
84138
|
yield [sym, n.id];
|
|
@@ -84284,7 +84172,7 @@ function buildOwnKnowledgeMap(opts) {
|
|
|
84284
84172
|
function* ownKnowledgeEntries(opts) {
|
|
84285
84173
|
const { store, salt } = opts;
|
|
84286
84174
|
for (const kind of ANCHOR_SOURCE_KINDS) {
|
|
84287
|
-
for (const n of store.
|
|
84175
|
+
for (const n of store.findNodeIdentitiesByLabel(kind)) {
|
|
84288
84176
|
if (n.id.startsWith("projn_")) continue;
|
|
84289
84177
|
yield [projectSaltedNodeId(n.id, salt), n.id];
|
|
84290
84178
|
}
|
|
@@ -85406,7 +85294,7 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
85406
85294
|
|
|
85407
85295
|
// src/link-flow.ts
|
|
85408
85296
|
init_cloud_auth();
|
|
85409
|
-
import { createHash as
|
|
85297
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
85410
85298
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
85411
85299
|
import { existsSync as existsSync30, writeFileSync as writeFileSync23 } from "node:fs";
|
|
85412
85300
|
import { join as join38 } from "node:path";
|
|
@@ -85700,7 +85588,7 @@ async function loginOAuthLoopback(opts) {
|
|
|
85700
85588
|
|
|
85701
85589
|
// src/link-flow.ts
|
|
85702
85590
|
function remoteFingerprint(locator) {
|
|
85703
|
-
return
|
|
85591
|
+
return createHash16("sha256").update(locator).digest("hex");
|
|
85704
85592
|
}
|
|
85705
85593
|
function isDecision(value) {
|
|
85706
85594
|
if (!value || typeof value !== "object") return false;
|
|
@@ -86595,7 +86483,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
86595
86483
|
registerWorkspace(rec.engine.profile, rec.root);
|
|
86596
86484
|
} catch {
|
|
86597
86485
|
}
|
|
86598
|
-
if (wakeIndexPlan(rec.engine.store.
|
|
86486
|
+
if (wakeIndexPlan(rec.engine.store.nodeCount(), opts.reindexOnStart !== false) === "full-index") {
|
|
86599
86487
|
void enqueueWakeIndex(async () => {
|
|
86600
86488
|
const done = markPass(`wake-index:${rec.entry.name}`);
|
|
86601
86489
|
try {
|
|
@@ -86818,15 +86706,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
86818
86706
|
app.post("/api/context-inject", (c) => forward(c, cwdOf, { affinity: "follow" }));
|
|
86819
86707
|
app.post("/api/statusline", async (c) => {
|
|
86820
86708
|
const body2 = await c.req.json().catch(() => ({}));
|
|
86821
|
-
const dir = statuslineDir(body2);
|
|
86822
|
-
if (dir !== null) {
|
|
86823
|
-
const d = normPath(dir);
|
|
86824
|
-
const known = listWorkspaceEntries().some((e) => {
|
|
86825
|
-
const root = normPath(e.path);
|
|
86826
|
-
return d === root || d.startsWith(`${root}/`);
|
|
86827
|
-
});
|
|
86828
|
-
if (!known) return c.text("");
|
|
86829
|
-
}
|
|
86830
86709
|
return c.text(statuslineText(String(body2["session_id"] ?? "")));
|
|
86831
86710
|
});
|
|
86832
86711
|
for (const r of records) {
|
|
@@ -87007,17 +86886,11 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87007
86886
|
const ANCHOR_PULL_INTERVAL_MS = 10 * 60 * 1e3;
|
|
87008
86887
|
const anchorPullAll = async () => {
|
|
87009
86888
|
const c = loadConfig();
|
|
87010
|
-
if (
|
|
86889
|
+
if (!hasCloudCredential(c)) return;
|
|
86890
|
+
const client = cloudNow();
|
|
87011
86891
|
for (const r of records) {
|
|
87012
86892
|
const projectId = r.engine.profile.projectId;
|
|
87013
86893
|
if (!projectId || !effectiveConsent(c, r.engine.profile).sync) continue;
|
|
87014
|
-
const identity = identityFor(liveWorkspaceEntry(r.entry));
|
|
87015
|
-
if (identity.invalid) {
|
|
87016
|
-
noteIdentityBlock(r.id, r.entry.name, identity);
|
|
87017
|
-
continue;
|
|
87018
|
-
}
|
|
87019
|
-
if (identity.rule !== "workspace-binding" && !hasCloudCredential(c)) continue;
|
|
87020
|
-
const client = cloudForIdentity(identity);
|
|
87021
86894
|
try {
|
|
87022
86895
|
const { salt } = await resolveProjectSymbolSalt(client, projectId);
|
|
87023
86896
|
await pullProjectAnchors(r, client, salt);
|
|
@@ -87031,17 +86904,11 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87031
86904
|
}, ANCHOR_PULL_INTERVAL_MS);
|
|
87032
86905
|
const ambientLinkAll = async () => {
|
|
87033
86906
|
const c = loadConfig();
|
|
87034
|
-
if (
|
|
86907
|
+
if (!hasCloudCredential(c)) return;
|
|
86908
|
+
const client = cloudNow();
|
|
87035
86909
|
for (const r of records) {
|
|
87036
86910
|
const working = loadProfile(r.root) ?? r.engine.profile;
|
|
87037
86911
|
if (!effectiveConsent(c, working).sync) continue;
|
|
87038
|
-
const identity = identityFor(liveWorkspaceEntry(r.entry));
|
|
87039
|
-
if (identity.invalid) {
|
|
87040
|
-
noteIdentityBlock(r.id, r.entry.name, identity);
|
|
87041
|
-
continue;
|
|
87042
|
-
}
|
|
87043
|
-
if (identity.rule !== "workspace-binding" && !hasCloudCredential(c)) continue;
|
|
87044
|
-
const client = cloudForIdentity(identity);
|
|
87045
86912
|
const out2 = await ensureProjectLink(r.root, working, client);
|
|
87046
86913
|
if (working !== r.engine.profile) adoptLinkFields(r.engine.profile, working);
|
|
87047
86914
|
if (out2.linked) {
|
|
@@ -87429,7 +87296,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87429
87296
|
}
|
|
87430
87297
|
const ignore2 = loadClaimIgnorePatterns(globalDir());
|
|
87431
87298
|
const clientPool = /* @__PURE__ */ new Map();
|
|
87432
|
-
const receiptContexts = /* @__PURE__ */ new Map();
|
|
87433
87299
|
const poolFor = (identity) => {
|
|
87434
87300
|
const k = identityKey(identity);
|
|
87435
87301
|
let c = clientPool.get(k);
|
|
@@ -87572,26 +87438,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87572
87438
|
return res.accepted;
|
|
87573
87439
|
});
|
|
87574
87440
|
}
|
|
87575
|
-
const receiptProfile = recordIdentity.profile ?? (cfg2.activeInstallationProfile ? cfg2.installationProfiles[cfg2.activeInstallationProfile] : void 0);
|
|
87576
|
-
let receiptContext = receiptContexts.get(identityKey(recordIdentity));
|
|
87577
|
-
if (!receiptContext) {
|
|
87578
|
-
try {
|
|
87579
|
-
receiptContext = await client.context();
|
|
87580
|
-
receiptContexts.set(identityKey(recordIdentity), receiptContext);
|
|
87581
|
-
} catch (err2) {
|
|
87582
|
-
errors.push(`[${projectName}] instance destination unresolved: ${err2 instanceof Error ? err2.message : String(err2)}`);
|
|
87583
|
-
continue;
|
|
87584
|
-
}
|
|
87585
|
-
}
|
|
87586
|
-
const destinationKey = instanceDestinationKey({
|
|
87587
|
-
workspace: r.id,
|
|
87588
|
-
cloudUrl: opts.cloudUrl ?? receiptProfile?.cloudUrl ?? cfg2.cloudUrl,
|
|
87589
|
-
installationId: receiptContext.context.installation_id ?? receiptContext.identity.credential_id,
|
|
87590
|
-
projectId: project?.projectId,
|
|
87591
|
-
writeTarget: project ? null : receiptContext.context.default_write_target
|
|
87592
|
-
});
|
|
87593
87441
|
const built = await buildInstanceBatch(r, {
|
|
87594
|
-
destinationKey,
|
|
87595
87442
|
profile: r.engine.profile,
|
|
87596
87443
|
daemonVersion: DAEMON_VERSION,
|
|
87597
87444
|
ignorePatterns: [...ignore2],
|
|
@@ -87636,6 +87483,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87636
87483
|
);
|
|
87637
87484
|
}
|
|
87638
87485
|
uploaded += res.accepted;
|
|
87486
|
+
const seq = store.currentIngestSeq();
|
|
87639
87487
|
const cloudIdByLocal = new Map(
|
|
87640
87488
|
res.result.nodes.filter((rn) => rn.nodeId).map((rn) => [rn.canonicalId, rn.nodeId])
|
|
87641
87489
|
);
|
|
@@ -87644,7 +87492,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87644
87492
|
if (rn.decision === "rejected") rejected.set(rn.canonicalId, rn.reason ?? "no reason given");
|
|
87645
87493
|
}
|
|
87646
87494
|
const rejectedEdges = res.result.edges.filter((re) => re.decision === "rejected");
|
|
87647
|
-
const edgeReceiptsComplete = rejectedEdges.length === 0 && res.result.edges.length === instances.edges.length;
|
|
87648
87495
|
if (rejectedEdges.length > 0) {
|
|
87649
87496
|
const byReason = /* @__PURE__ */ new Map();
|
|
87650
87497
|
for (const re of rejectedEdges) {
|
|
@@ -87675,17 +87522,17 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87675
87522
|
const owner = owningStore(id);
|
|
87676
87523
|
if (!owner) return;
|
|
87677
87524
|
const fp = refusalFingerprint(reason, owner.n.description);
|
|
87678
|
-
const same =
|
|
87679
|
-
const count = same ? Number(
|
|
87680
|
-
if (
|
|
87525
|
+
const same = owner.n.attrs["shipRefusedFingerprint"] === fp;
|
|
87526
|
+
const count = same ? Number(owner.n.attrs["shipRefusedCount"] ?? 0) + 1 : 1;
|
|
87527
|
+
if (owner.n.attrs["shipRefusedSinceSeq"] !== void 0) repeat();
|
|
87681
87528
|
owner.s.updateNode(id, {
|
|
87682
|
-
attrs:
|
|
87683
|
-
...
|
|
87684
|
-
...same &&
|
|
87529
|
+
attrs: {
|
|
87530
|
+
...owner.n.attrs,
|
|
87531
|
+
...same && owner.n.attrs["shipRefusedSinceSeq"] !== void 0 ? {} : { shipRefusedSinceSeq: seq },
|
|
87685
87532
|
shipRefusedCount: count,
|
|
87686
87533
|
shipRefusedReason: reason,
|
|
87687
87534
|
shipRefusedFingerprint: fp
|
|
87688
|
-
}
|
|
87535
|
+
}
|
|
87689
87536
|
});
|
|
87690
87537
|
if (same && count === SHIP_TERMINAL_REFUSALS && !isRetryableRefusal(reason)) {
|
|
87691
87538
|
nowHeld.push({ id, reason });
|
|
@@ -87702,7 +87549,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87702
87549
|
const owner = owningStore(n.id);
|
|
87703
87550
|
if (!owner || !["Problem", "Solution", "RootCause"].includes(owner.n.label)) return;
|
|
87704
87551
|
if (blocked.has(n.id)) return;
|
|
87705
|
-
if (!cloudIdByLocal.has(n.id)) return;
|
|
87706
87552
|
if (rejected.has(n.id)) return;
|
|
87707
87553
|
const cloudNodeId = cloudIdByLocal.get(n.id);
|
|
87708
87554
|
const {
|
|
@@ -87711,41 +87557,37 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87711
87557
|
shipRefusedReason: _clearedReason,
|
|
87712
87558
|
shipRefusedFingerprint: _clearedFp,
|
|
87713
87559
|
...carried
|
|
87714
|
-
} =
|
|
87560
|
+
} = owner.n.attrs;
|
|
87715
87561
|
owner.s.updateNode(n.id, {
|
|
87716
|
-
attrs:
|
|
87562
|
+
attrs: {
|
|
87717
87563
|
...carried,
|
|
87718
|
-
|
|
87719
|
-
|
|
87720
|
-
|
|
87721
|
-
shipRefusedFingerprint: void 0,
|
|
87722
|
-
contributedAtSeq: instanceReceiptSequence(n),
|
|
87723
|
-
cloudNodeId
|
|
87724
|
-
}, owner.s === store)
|
|
87564
|
+
contributedAtSeq: seq,
|
|
87565
|
+
...cloudNodeId && cloudNodeId !== n.id ? { cloudNodeId } : {}
|
|
87566
|
+
}
|
|
87725
87567
|
});
|
|
87726
87568
|
});
|
|
87727
87569
|
await stampBatched(Object.entries(instances.anchorDigests), ([localId, dg]) => {
|
|
87728
87570
|
const owner = owningStore(localId);
|
|
87729
87571
|
if (!owner) return;
|
|
87730
|
-
if (
|
|
87572
|
+
if (rejected.has(localId) || blocked.has(localId)) return;
|
|
87731
87573
|
owner.s.updateNode(localId, {
|
|
87732
|
-
attrs:
|
|
87574
|
+
attrs: { ...owner.n.attrs, anchorsContributedDigest: dg }
|
|
87733
87575
|
});
|
|
87734
87576
|
});
|
|
87735
87577
|
await stampBatched(Object.entries(instances.projectAnchorDigests), ([localId, dg]) => {
|
|
87736
87578
|
const owner = owningStore(localId);
|
|
87737
87579
|
if (!owner) return;
|
|
87738
|
-
if (
|
|
87580
|
+
if (rejected.has(localId) || blocked.has(localId)) return;
|
|
87739
87581
|
owner.s.updateNode(localId, {
|
|
87740
|
-
attrs:
|
|
87582
|
+
attrs: { ...owner.n.attrs, projectAnchorsContributedDigest: dg }
|
|
87741
87583
|
});
|
|
87742
87584
|
});
|
|
87743
87585
|
await stampBatched(Object.entries(instances.semanticEdgeDigests), ([localId, dg]) => {
|
|
87744
87586
|
const owner = owningStore(localId);
|
|
87745
87587
|
if (!owner) return;
|
|
87746
|
-
if (
|
|
87588
|
+
if (rejected.has(localId) || blocked.has(localId)) return;
|
|
87747
87589
|
owner.s.updateNode(localId, {
|
|
87748
|
-
attrs:
|
|
87590
|
+
attrs: { ...owner.n.attrs, semanticEdgesContributedDigest: dg }
|
|
87749
87591
|
});
|
|
87750
87592
|
});
|
|
87751
87593
|
appendPassLedger(r.engine.paths.configDir, "ship", Date.now() - shipStartedAt, {
|
|
@@ -88724,10 +88566,9 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
88724
88566
|
}
|
|
88725
88567
|
|
|
88726
88568
|
// src/claude-statusline.ts
|
|
88727
|
-
import {
|
|
88728
|
-
import {
|
|
88729
|
-
|
|
88730
|
-
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
88569
|
+
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync26 } from "node:fs";
|
|
88570
|
+
import { join as join42 } from "node:path";
|
|
88571
|
+
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata install-hooks claude
|
|
88731
88572
|
import { readFileSync } from 'node:fs';
|
|
88732
88573
|
|
|
88733
88574
|
try {
|
|
@@ -88753,57 +88594,15 @@ function buildStatusLine(port, nodePath, relayPath) {
|
|
|
88753
88594
|
function isErrataStatusLine(value) {
|
|
88754
88595
|
return !!value && typeof value === "object" && typeof value["command"] === "string" && value["command"].includes(STATUSLINE_RELAY_FILE);
|
|
88755
88596
|
}
|
|
88756
|
-
function
|
|
88757
|
-
if (!isErrataStatusLine(settings["statusLine"])) return false;
|
|
88758
|
-
|
|
88597
|
+
function installStatusLine(settings, root, port, nodePath = process.execPath) {
|
|
88598
|
+
if (settings["statusLine"] !== void 0 && !isErrataStatusLine(settings["statusLine"])) return false;
|
|
88599
|
+
const dir = join42(root, ".claude", "hooks");
|
|
88600
|
+
const relay = join42(dir, STATUSLINE_RELAY_FILE);
|
|
88601
|
+
mkdirSync10(dir, { recursive: true });
|
|
88602
|
+
writeFileSync26(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
88603
|
+
settings["statusLine"] = buildStatusLine(port, nodePath, relay);
|
|
88759
88604
|
return true;
|
|
88760
88605
|
}
|
|
88761
|
-
function userClaudeSettingsPath() {
|
|
88762
|
-
const base = process.env["CLAUDE_CONFIG_DIR"] ?? join42(homedir8(), ".claude");
|
|
88763
|
-
return join42(base, "settings.json");
|
|
88764
|
-
}
|
|
88765
|
-
function ensureUserStatusLine(opts) {
|
|
88766
|
-
const env2 = opts.env ?? process.env;
|
|
88767
|
-
const off = (env2["ERRATA_STATUSLINE"] ?? "").trim().toLowerCase();
|
|
88768
|
-
if (off === "0" || off === "off" || off === "false" || off === "no") return "disabled";
|
|
88769
|
-
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
88770
|
-
let settings = {};
|
|
88771
|
-
if (existsSync34(settingsPath)) {
|
|
88772
|
-
try {
|
|
88773
|
-
const parsed = JSON.parse(readFileSync35(settingsPath, "utf8"));
|
|
88774
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
88775
|
-
settings = parsed;
|
|
88776
|
-
} catch {
|
|
88777
|
-
return "unreadable";
|
|
88778
|
-
}
|
|
88779
|
-
}
|
|
88780
|
-
if (settings["statusLine"] !== void 0 && !isErrataStatusLine(settings["statusLine"])) return "kept-own";
|
|
88781
|
-
const relay = join42(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
88782
|
-
mkdirSync10(opts.relayDir, { recursive: true });
|
|
88783
|
-
if (!existsSync34(relay) || readFileSync35(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
88784
|
-
writeFileSync26(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
88785
|
-
}
|
|
88786
|
-
const next = buildStatusLine(opts.port, opts.nodePath ?? process.execPath, relay);
|
|
88787
|
-
if (JSON.stringify(settings["statusLine"]) === JSON.stringify(next)) return "unchanged";
|
|
88788
|
-
settings["statusLine"] = next;
|
|
88789
|
-
mkdirSync10(dirname13(settingsPath), { recursive: true });
|
|
88790
|
-
writeFileSync26(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
88791
|
-
return "installed";
|
|
88792
|
-
}
|
|
88793
|
-
function describeStatusLineOutcome(outcome) {
|
|
88794
|
-
switch (outcome) {
|
|
88795
|
-
case "installed":
|
|
88796
|
-
return "status line: errata recall card in colour (user settings; ERRATA_STATUSLINE=off opts out)";
|
|
88797
|
-
case "unchanged":
|
|
88798
|
-
return "status line: errata recall card already set up";
|
|
88799
|
-
case "kept-own":
|
|
88800
|
-
return "status line: kept your own \u2014 errata's recall card shows inline only";
|
|
88801
|
-
case "disabled":
|
|
88802
|
-
return "status line: skipped (ERRATA_STATUSLINE=off)";
|
|
88803
|
-
case "unreadable":
|
|
88804
|
-
return "status line: skipped \u2014 ~/.claude/settings.json is not valid JSON";
|
|
88805
|
-
}
|
|
88806
|
-
}
|
|
88807
88606
|
|
|
88808
88607
|
// src/opencode-plugin.ts
|
|
88809
88608
|
var OPENCODE_PLUGIN_MARKER = "// @inerrata opencode plugin \u2014 errata-managed (errata install-hooks opencode)";
|
|
@@ -89210,14 +89009,14 @@ async function cmdInit() {
|
|
|
89210
89009
|
if (!skipHooks) {
|
|
89211
89010
|
console.log("");
|
|
89212
89011
|
console.log("installing harness hooks...");
|
|
89213
|
-
const { existsSync:
|
|
89012
|
+
const { existsSync: existsSync35 } = await import("node:fs");
|
|
89214
89013
|
const { join: join44 } = await import("node:path");
|
|
89215
89014
|
try {
|
|
89216
89015
|
await installClaudeHooks(port);
|
|
89217
89016
|
} catch (err2) {
|
|
89218
89017
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
89219
89018
|
}
|
|
89220
|
-
if (
|
|
89019
|
+
if (existsSync35(join44(ROOT, ".cursor"))) {
|
|
89221
89020
|
try {
|
|
89222
89021
|
await installCursorMcpConfig();
|
|
89223
89022
|
} catch (err2) {
|
|
@@ -89319,7 +89118,6 @@ async function cmdStart() {
|
|
|
89319
89118
|
await ensureProfile();
|
|
89320
89119
|
const profile = loadProfile(ROOT);
|
|
89321
89120
|
if (profile) registerWorkspace(profile, ROOT);
|
|
89322
|
-
if (profile) console.log(`errata: ${ensureStatusLine(resolveHookPort())}`);
|
|
89323
89121
|
const lockPath = globalDaemonLock();
|
|
89324
89122
|
const running = isDaemonAlive(lockPath) ? readDaemonLock(lockPath) : null;
|
|
89325
89123
|
const where = profile ? `${profile.name} (${profile.id})` : ROOT;
|
|
@@ -89407,9 +89205,9 @@ async function cmdStatus() {
|
|
|
89407
89205
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
89408
89206
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
89409
89207
|
}
|
|
89410
|
-
console.log(` graph db: ${
|
|
89411
|
-
console.log(` event log: ${
|
|
89412
|
-
if (
|
|
89208
|
+
console.log(` graph db: ${existsSync34(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
|
|
89209
|
+
console.log(` event log: ${existsSync34(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
|
|
89210
|
+
if (existsSync34(paths.castalia)) {
|
|
89413
89211
|
try {
|
|
89414
89212
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
89415
89213
|
const store = openGraphStore2({ path: paths.castalia });
|
|
@@ -89639,7 +89437,7 @@ async function cmdWhoami(args2) {
|
|
|
89639
89437
|
`note: daemon capture and the MCP server resolve identically; a process with ERRATA_CONFIG_PATH set resolves by rule 1 regardless of binding.`
|
|
89640
89438
|
];
|
|
89641
89439
|
if (args2.includes("--json")) {
|
|
89642
|
-
console.log(JSON.stringify({ path: path2, registered: Boolean(entry), ...
|
|
89440
|
+
console.log(JSON.stringify({ path: path2, registered: Boolean(entry), ...identity }, null, 2));
|
|
89643
89441
|
} else {
|
|
89644
89442
|
for (const l of lines) console.log(l);
|
|
89645
89443
|
}
|
|
@@ -90042,7 +89840,6 @@ async function cmdLink(args2) {
|
|
|
90042
89840
|
process.exitCode = 1;
|
|
90043
89841
|
return;
|
|
90044
89842
|
}
|
|
90045
|
-
console.log(ensureStatusLine(resolveHookPort()));
|
|
90046
89843
|
delete profile.projectLinkDisabled;
|
|
90047
89844
|
const remote = flag("--remote");
|
|
90048
89845
|
if (remote) {
|
|
@@ -90379,11 +90176,11 @@ function cmdInstallationProfile(args2) {
|
|
|
90379
90176
|
}
|
|
90380
90177
|
async function cmdReview() {
|
|
90381
90178
|
const paths = workspacePaths(ROOT);
|
|
90382
|
-
if (!
|
|
90179
|
+
if (!existsSync34(paths.reviewQueue)) {
|
|
90383
90180
|
console.log("(review queue empty)");
|
|
90384
90181
|
return;
|
|
90385
90182
|
}
|
|
90386
|
-
const queue = JSON.parse(
|
|
90183
|
+
const queue = JSON.parse(readFileSync35(paths.reviewQueue, "utf8"));
|
|
90387
90184
|
if (queue.length === 0) {
|
|
90388
90185
|
console.log("(review queue empty)");
|
|
90389
90186
|
return;
|
|
@@ -91054,7 +90851,7 @@ async function gatherRepo(store, ws) {
|
|
|
91054
90851
|
};
|
|
91055
90852
|
}
|
|
91056
90853
|
async function gatherReportData(generatedAt) {
|
|
91057
|
-
const { existsSync:
|
|
90854
|
+
const { existsSync: existsSync35 } = await import("node:fs");
|
|
91058
90855
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
91059
90856
|
const cfg = loadConfig();
|
|
91060
90857
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -91062,7 +90859,7 @@ async function gatherReportData(generatedAt) {
|
|
|
91062
90859
|
for (const ws of listWorkspaces()) {
|
|
91063
90860
|
if (ws.missing) continue;
|
|
91064
90861
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
91065
|
-
if (!
|
|
90862
|
+
if (!existsSync35(dbPath)) continue;
|
|
91066
90863
|
let store = null;
|
|
91067
90864
|
try {
|
|
91068
90865
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -91227,13 +91024,13 @@ async function cmdInstallHooks(args2) {
|
|
|
91227
91024
|
}
|
|
91228
91025
|
}
|
|
91229
91026
|
async function installOpencodePlugin(port) {
|
|
91230
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
91027
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync35, readFileSync: readFileSync36, writeFileSync: writeFileSync27 } = await import("node:fs");
|
|
91231
91028
|
const { join: join44 } = await import("node:path");
|
|
91232
91029
|
const dir = join44(ROOT, ".opencode", "plugin");
|
|
91233
|
-
if (!
|
|
91030
|
+
if (!existsSync35(dir)) mkdirSync11(dir, { recursive: true });
|
|
91234
91031
|
const file2 = join44(dir, "inerrata.js");
|
|
91235
|
-
if (
|
|
91236
|
-
const head2 =
|
|
91032
|
+
if (existsSync35(file2)) {
|
|
91033
|
+
const head2 = readFileSync36(file2, "utf8").split("\n")[0] ?? "";
|
|
91237
91034
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
91238
91035
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
91239
91036
|
process.exit(2);
|
|
@@ -91242,9 +91039,9 @@ async function installOpencodePlugin(port) {
|
|
|
91242
91039
|
writeFileSync27(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
|
|
91243
91040
|
const cfgFile = join44(ROOT, "opencode.json");
|
|
91244
91041
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
91245
|
-
if (
|
|
91042
|
+
if (existsSync35(cfgFile)) {
|
|
91246
91043
|
try {
|
|
91247
|
-
cfg = JSON.parse(
|
|
91044
|
+
cfg = JSON.parse(readFileSync36(cfgFile, "utf8"));
|
|
91248
91045
|
} catch {
|
|
91249
91046
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
91250
91047
|
process.exit(2);
|
|
@@ -91274,23 +91071,16 @@ function errataMcpInvocation() {
|
|
|
91274
91071
|
const { cmd: cmd2, args: args2 } = selfArgv("mcp");
|
|
91275
91072
|
return { command: cmd2, args: args2 };
|
|
91276
91073
|
}
|
|
91277
|
-
function ensureStatusLine(port) {
|
|
91278
|
-
try {
|
|
91279
|
-
return describeStatusLineOutcome(ensureUserStatusLine({ port, relayDir: globalDir() }));
|
|
91280
|
-
} catch (err2) {
|
|
91281
|
-
return `status line: not installed (${err2 instanceof Error ? err2.message : err2})`;
|
|
91282
|
-
}
|
|
91283
|
-
}
|
|
91284
91074
|
async function installClaudeHooks(port) {
|
|
91285
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
91075
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync35, readFileSync: readFileSync36, writeFileSync: writeFileSync27 } = await import("node:fs");
|
|
91286
91076
|
const { join: join44 } = await import("node:path");
|
|
91287
91077
|
const dir = join44(ROOT, ".claude");
|
|
91288
|
-
if (!
|
|
91078
|
+
if (!existsSync35(dir)) mkdirSync11(dir, { recursive: true });
|
|
91289
91079
|
const file2 = join44(dir, "settings.json");
|
|
91290
91080
|
let settings = {};
|
|
91291
|
-
if (
|
|
91081
|
+
if (existsSync35(file2)) {
|
|
91292
91082
|
try {
|
|
91293
|
-
settings = JSON.parse(
|
|
91083
|
+
settings = JSON.parse(readFileSync36(file2, "utf8"));
|
|
91294
91084
|
} catch {
|
|
91295
91085
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
91296
91086
|
process.exit(2);
|
|
@@ -91337,10 +91127,18 @@ async function installClaudeHooks(port) {
|
|
|
91337
91127
|
dropErrata(list);
|
|
91338
91128
|
list.push({ hooks: [{ type: "command", command: injectCmd }] });
|
|
91339
91129
|
}
|
|
91340
|
-
|
|
91130
|
+
const { homedir: homedir8 } = await import("node:os");
|
|
91131
|
+
let userStatusLine;
|
|
91132
|
+
try {
|
|
91133
|
+
userStatusLine = JSON.parse(readFileSync36(join44(homedir8(), ".claude", "settings.json"), "utf8"))["statusLine"];
|
|
91134
|
+
} catch {
|
|
91135
|
+
}
|
|
91136
|
+
const statusLineInstalled = (userStatusLine === void 0 || isErrataStatusLine(userStatusLine)) && installStatusLine(settings, ROOT, port);
|
|
91341
91137
|
writeFileSync27(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
91342
91138
|
console.log(`installed Claude Code hooks \u2192 ${file2}`);
|
|
91343
|
-
console.log(
|
|
91139
|
+
console.log(
|
|
91140
|
+
statusLineInstalled ? " status line: errata recall card in colour (daemon env ERRATA_RECALL_CARD=off hides the cards)" : " status line: kept your own \u2014 errata's recall card shows inline only"
|
|
91141
|
+
);
|
|
91344
91142
|
await installClaudeMcpConfig();
|
|
91345
91143
|
const claudeMd = join44(ROOT, "CLAUDE.md");
|
|
91346
91144
|
const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
|
|
@@ -91354,15 +91152,15 @@ async function installClaudeHooks(port) {
|
|
|
91354
91152
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
91355
91153
|
}
|
|
91356
91154
|
async function installClaudeMcpConfig() {
|
|
91357
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
91358
|
-
const { join: join44, dirname:
|
|
91155
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync35, readFileSync: readFileSync36, writeFileSync: writeFileSync27 } = await import("node:fs");
|
|
91156
|
+
const { join: join44, dirname: dirname13 } = await import("node:path");
|
|
91359
91157
|
const file2 = join44(ROOT, ".mcp.json");
|
|
91360
|
-
const dir =
|
|
91361
|
-
if (!
|
|
91158
|
+
const dir = dirname13(file2);
|
|
91159
|
+
if (!existsSync35(dir)) mkdirSync11(dir, { recursive: true });
|
|
91362
91160
|
let cfg = {};
|
|
91363
|
-
if (
|
|
91161
|
+
if (existsSync35(file2)) {
|
|
91364
91162
|
try {
|
|
91365
|
-
cfg = JSON.parse(
|
|
91163
|
+
cfg = JSON.parse(readFileSync36(file2, "utf8"));
|
|
91366
91164
|
} catch {
|
|
91367
91165
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
91368
91166
|
process.exit(2);
|
|
@@ -91376,15 +91174,15 @@ async function installClaudeMcpConfig() {
|
|
|
91376
91174
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
91377
91175
|
}
|
|
91378
91176
|
async function installCursorMcpConfig() {
|
|
91379
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
91177
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync35, readFileSync: readFileSync36, writeFileSync: writeFileSync27 } = await import("node:fs");
|
|
91380
91178
|
const { join: join44 } = await import("node:path");
|
|
91381
91179
|
const dir = join44(ROOT, ".cursor");
|
|
91382
|
-
if (!
|
|
91180
|
+
if (!existsSync35(dir)) mkdirSync11(dir, { recursive: true });
|
|
91383
91181
|
const file2 = join44(dir, "mcp.json");
|
|
91384
91182
|
let cfg = {};
|
|
91385
|
-
if (
|
|
91183
|
+
if (existsSync35(file2)) {
|
|
91386
91184
|
try {
|
|
91387
|
-
cfg = JSON.parse(
|
|
91185
|
+
cfg = JSON.parse(readFileSync36(file2, "utf8"));
|
|
91388
91186
|
} catch {
|
|
91389
91187
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
91390
91188
|
process.exit(2);
|
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -24519,12 +24519,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS edges_triple ON edges(from_id, type, to_id);
|
|
|
24519
24519
|
`;
|
|
24520
24520
|
var TEMPORAL_INDEX_SQL = `
|
|
24521
24521
|
CREATE INDEX IF NOT EXISTS nodes_live ON nodes(label, valid_to);
|
|
24522
|
-
-- Covering + partial index for labelFingerprint over the instance labels: the
|
|
24523
|
-
-- live-push probe runs it per workspace on a timer, and each hit used to read
|
|
24524
|
-
-- its table row. Partial, so it maintains a few thousand rows instead of adding
|
|
24525
|
-
-- a write to every node write. Its label list is FINGERPRINT_INDEXED_LABELS.
|
|
24526
|
-
DROP INDEX IF EXISTS nodes_live_fingerprint;
|
|
24527
|
-
CREATE INDEX IF NOT EXISTS nodes_instance_fingerprint ON nodes(label, last_updated_at, last_reinforced_at_seq, created_at_seq) WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause');
|
|
24528
24522
|
CREATE INDEX IF NOT EXISTS nodes_logical ON nodes(logical_id, version);
|
|
24529
24523
|
CREATE INDEX IF NOT EXISTS edges_live ON edges(valid_to);
|
|
24530
24524
|
-- Expression index on the per-node relPath (stored in attrs_json) so the
|
|
@@ -24595,7 +24589,6 @@ function rowToEdge(r) {
|
|
|
24595
24589
|
attrs: JSON.parse(r.attrs_json)
|
|
24596
24590
|
};
|
|
24597
24591
|
}
|
|
24598
|
-
var FINGERPRINT_INDEXED_LABELS = ["Problem", "Solution", "RootCause"];
|
|
24599
24592
|
var SqliteGraphStore = class {
|
|
24600
24593
|
db;
|
|
24601
24594
|
// Typed edge lookups build their SQL from the number of types asked for, and
|
|
@@ -25072,32 +25065,6 @@ var SqliteGraphStore = class {
|
|
|
25072
25065
|
attrs: JSON.parse(r.attrs_json)
|
|
25073
25066
|
}));
|
|
25074
25067
|
}
|
|
25075
|
-
*iterateNodeIdentitiesByLabel(label, pageSize = 2e3) {
|
|
25076
|
-
const page = this.db.prepare(
|
|
25077
|
-
"SELECT rowid AS rid, id, json_extract(attrs_json, '$.relPath') AS relPath, json_extract(attrs_json, '$.qname') AS qname FROM nodes WHERE rowid > ? AND label = ? AND valid_to IS NULL ORDER BY rowid LIMIT ?"
|
|
25078
|
-
);
|
|
25079
|
-
let after = 0;
|
|
25080
|
-
for (; ; ) {
|
|
25081
|
-
const rows = page.all(after, label, pageSize);
|
|
25082
|
-
for (const r of rows) {
|
|
25083
|
-
yield {
|
|
25084
|
-
id: r.id,
|
|
25085
|
-
relPath: typeof r.relPath === "string" ? r.relPath : null,
|
|
25086
|
-
qname: typeof r.qname === "string" ? r.qname : null
|
|
25087
|
-
};
|
|
25088
|
-
}
|
|
25089
|
-
if (rows.length < pageSize) return;
|
|
25090
|
-
after = rows[rows.length - 1].rid;
|
|
25091
|
-
}
|
|
25092
|
-
}
|
|
25093
|
-
recentNodeIds(label, limit) {
|
|
25094
|
-
const rows = this.db.prepare("SELECT id FROM nodes WHERE label = ? AND valid_to IS NULL ORDER BY last_updated_at DESC LIMIT ?").all(label, Math.max(0, limit));
|
|
25095
|
-
return rows.map((r) => r.id);
|
|
25096
|
-
}
|
|
25097
|
-
hasLiveNodes() {
|
|
25098
|
-
const r = this.db.prepare("SELECT EXISTS(SELECT 1 FROM nodes WHERE valid_to IS NULL) AS e").get();
|
|
25099
|
-
return r.e === 1;
|
|
25100
|
-
}
|
|
25101
25068
|
findNodeIdentitiesByLabel(label) {
|
|
25102
25069
|
const rows = this.stmts.identitiesByLabel.all(label);
|
|
25103
25070
|
return rows.map((r) => ({
|
|
@@ -25245,15 +25212,6 @@ var SqliteGraphStore = class {
|
|
|
25245
25212
|
}
|
|
25246
25213
|
labelFingerprint(labels) {
|
|
25247
25214
|
if (labels.length === 0) return "0";
|
|
25248
|
-
if (labels.length === FINGERPRINT_INDEXED_LABELS.length && FINGERPRINT_INDEXED_LABELS.every((l) => labels.includes(l))) {
|
|
25249
|
-
const r2 = this.db.prepare(
|
|
25250
|
-
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
25251
|
-
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|
|
25252
|
-
FROM nodes INDEXED BY nodes_instance_fingerprint
|
|
25253
|
-
WHERE valid_to IS NULL AND label IN ('Problem','Solution','RootCause')`
|
|
25254
|
-
).get();
|
|
25255
|
-
return `${r2.n}:${r2.t ?? 0}:${r2.s ?? 0}`;
|
|
25256
|
-
}
|
|
25257
25215
|
const r = this.db.prepare(
|
|
25258
25216
|
`SELECT COUNT(*) AS n, MAX(last_updated_at) AS t,
|
|
25259
25217
|
MAX(COALESCE(last_reinforced_at_seq, created_at_seq, 0)) AS s
|