@inerrata-corporation/errata 2.0.2-dev.297 → 2.0.2-dev.305
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/errata.mjs +68 -11
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -28148,6 +28148,19 @@ function summariesByBodyHash(cache) {
|
|
|
28148
28148
|
}
|
|
28149
28149
|
return m;
|
|
28150
28150
|
}
|
|
28151
|
+
function buildDocIndex(store) {
|
|
28152
|
+
const byName = /* @__PURE__ */ new Map();
|
|
28153
|
+
for (const c of store.findNodesByLabel("Comment")) {
|
|
28154
|
+
const name2 = c.attrs["attachedTo"];
|
|
28155
|
+
const kind = c.attrs["kind"];
|
|
28156
|
+
if (typeof name2 !== "string" || !name2) continue;
|
|
28157
|
+
if (typeof kind !== "string" || !DOC_COMMENT_KINDS.has(kind)) continue;
|
|
28158
|
+
const text = typeof c.attrs["text"] === "string" ? c.attrs["text"] : c.description;
|
|
28159
|
+
if (!text?.trim()) continue;
|
|
28160
|
+
if (!byName.has(name2)) byName.set(name2, text.trim().slice(0, MAX_DOC_CHARS));
|
|
28161
|
+
}
|
|
28162
|
+
return byName;
|
|
28163
|
+
}
|
|
28151
28164
|
function parseSummaryJson(text, expected) {
|
|
28152
28165
|
const start2 = text.indexOf("[");
|
|
28153
28166
|
const end = text.lastIndexOf("]");
|
|
@@ -28173,7 +28186,8 @@ function haikuIntentSummarizer(apiKey) {
|
|
|
28173
28186
|
const listing = symbols.map(
|
|
28174
28187
|
(s, i2) => `### ${i2 + 1}. kind: ${s.kind}
|
|
28175
28188
|
name: ${s.name}
|
|
28176
|
-
|
|
28189
|
+
` + (s.doc ? `doc: ${s.doc}
|
|
28190
|
+
` : "") + `${s.snippet ? `\`\`\`
|
|
28177
28191
|
${s.snippet}
|
|
28178
28192
|
\`\`\`` : "(no source available \u2014 describe from the name)"}`
|
|
28179
28193
|
).join("\n\n");
|
|
@@ -28193,10 +28207,20 @@ SYMBOLS:
|
|
|
28193
28207
|
${listing}` }]
|
|
28194
28208
|
})
|
|
28195
28209
|
});
|
|
28196
|
-
if (!resp.ok)
|
|
28210
|
+
if (!resp.ok) {
|
|
28211
|
+
const detail = await resp.text().catch(() => "");
|
|
28212
|
+
console.warn(
|
|
28213
|
+
`[errata] symbol summaries: API ${resp.status} \u2014 sweep produced nothing this round. ${detail.slice(0, 200)}`
|
|
28214
|
+
);
|
|
28215
|
+
return symbols.map(() => null);
|
|
28216
|
+
}
|
|
28197
28217
|
const json2 = await resp.json();
|
|
28198
28218
|
return parseSummaryJson(json2.content?.find((c) => c.type === "text")?.text ?? "", symbols.length);
|
|
28199
|
-
} catch {
|
|
28219
|
+
} catch (err2) {
|
|
28220
|
+
console.warn(
|
|
28221
|
+
"[errata] symbol summaries: transport failed \u2014 sweep produced nothing this round:",
|
|
28222
|
+
err2 instanceof Error ? err2.message : err2
|
|
28223
|
+
);
|
|
28200
28224
|
return symbols.map(() => null);
|
|
28201
28225
|
}
|
|
28202
28226
|
};
|
|
@@ -28227,6 +28251,7 @@ async function runSymbolSummarySweep(store, workspaceRoot, configDir, summarizer
|
|
|
28227
28251
|
const cache = loadSymbolSummaryCache(configDir);
|
|
28228
28252
|
const candidates = [];
|
|
28229
28253
|
const seen = /* @__PURE__ */ new Set();
|
|
28254
|
+
const docs = buildDocIndex(store);
|
|
28230
28255
|
for (const [label, kind] of SUMMARY_LABELS) {
|
|
28231
28256
|
for (const n of store.findNodesByLabel(label)) {
|
|
28232
28257
|
const bodyHash = n.attrs["bodyHash"];
|
|
@@ -28236,7 +28261,15 @@ async function runSymbolSummarySweep(store, workspaceRoot, configDir, summarizer
|
|
|
28236
28261
|
if (!name2 || !isDistinctiveIdentifier(name2)) continue;
|
|
28237
28262
|
seen.add(bodyHash);
|
|
28238
28263
|
const snippet = readSnippet(workspaceRoot, n.attrs);
|
|
28239
|
-
|
|
28264
|
+
const qname = typeof n.attrs["qname"] === "string" ? n.attrs["qname"] : void 0;
|
|
28265
|
+
const doc = docs.get(name2) ?? (qname ? docs.get(qname) : void 0);
|
|
28266
|
+
candidates.push({
|
|
28267
|
+
bodyHash,
|
|
28268
|
+
name: name2,
|
|
28269
|
+
kind,
|
|
28270
|
+
...snippet ? { snippet } : {},
|
|
28271
|
+
...doc ? { doc } : {}
|
|
28272
|
+
});
|
|
28240
28273
|
}
|
|
28241
28274
|
}
|
|
28242
28275
|
const todo = candidates.slice(0, maxSymbols);
|
|
@@ -28266,7 +28299,7 @@ async function runSymbolSummarySweep(store, workspaceRoot, configDir, summarizer
|
|
|
28266
28299
|
}
|
|
28267
28300
|
return { generated, rejected, remaining };
|
|
28268
28301
|
}
|
|
28269
|
-
var SUMMARY_LABELS, MAX_SNIPPET_CHARS, DEFAULT_MAX_SYMBOLS_PER_SWEEP, DEFAULT_BATCH_SIZE, SUMMARY_MODEL, SUMMARY_PROMPT;
|
|
28302
|
+
var SUMMARY_LABELS, MAX_SNIPPET_CHARS, DEFAULT_MAX_SYMBOLS_PER_SWEEP, DEFAULT_BATCH_SIZE, DOC_COMMENT_KINDS, MAX_DOC_CHARS, SUMMARY_MODEL, SUMMARY_PROMPT;
|
|
28270
28303
|
var init_symbol_summaries = __esm({
|
|
28271
28304
|
"src/symbol-summaries.ts"() {
|
|
28272
28305
|
"use strict";
|
|
@@ -28280,10 +28313,13 @@ var init_symbol_summaries = __esm({
|
|
|
28280
28313
|
MAX_SNIPPET_CHARS = 1500;
|
|
28281
28314
|
DEFAULT_MAX_SYMBOLS_PER_SWEEP = 64;
|
|
28282
28315
|
DEFAULT_BATCH_SIZE = 16;
|
|
28316
|
+
DOC_COMMENT_KINDS = /* @__PURE__ */ new Set(["docstring", "explanation"]);
|
|
28317
|
+
MAX_DOC_CHARS = 600;
|
|
28283
28318
|
SUMMARY_MODEL = "claude-haiku-4-5-20251001";
|
|
28284
28319
|
SUMMARY_PROMPT = `For each code symbol below, write ONE short English phrase stating its intent/role, shaped like "a <kind> that <does what>" (e.g. "a function that binds the server's listen port").
|
|
28320
|
+
Some symbols include a "doc:" line \u2014 the author's own description of what it is for. When present TRUST IT as the primary source of intent and translate it into the required shape; the code is secondary evidence. Carry the SPECIFIC job the symbol does, not the category it belongs to: "a function that releases a pooled connection on every exit path including cancellation" is useful; "a function that handles cleanup" is not.
|
|
28285
28321
|
HARD RULES \u2014 a violating phrase is discarded:
|
|
28286
|
-
- NEVER include any identifier, symbol name, variable, type name, file path, or module name from the code \u2014 describe meaning in plain English words only.
|
|
28322
|
+
- NEVER include any identifier, symbol name, variable, type name, file path, or module name from the code or the doc \u2014 describe meaning in plain English words only.
|
|
28287
28323
|
- NEVER include quoted strings, literals, numbers copied from the code, or code syntax.
|
|
28288
28324
|
- One phrase per symbol, under 200 characters, lowercase start, no trailing period.
|
|
28289
28325
|
Output a JSON array of strings, one per symbol in the SAME ORDER (use null for a symbol you cannot describe). Output JSON only, no prose.`;
|
|
@@ -52635,6 +52671,14 @@ function enqueueWitnesses(queue, fresh, now) {
|
|
|
52635
52671
|
function pendingFor(queue, channel) {
|
|
52636
52672
|
return queue.filter((w) => w.channel === channel);
|
|
52637
52673
|
}
|
|
52674
|
+
function partitionReplayable(queue, channel, isShipped) {
|
|
52675
|
+
const replay2 = [];
|
|
52676
|
+
const waiting = [];
|
|
52677
|
+
for (const w of pendingFor(queue, channel)) {
|
|
52678
|
+
(isShipped(w.nodeId) ? replay2 : waiting).push(w);
|
|
52679
|
+
}
|
|
52680
|
+
return { replay: replay2, waiting };
|
|
52681
|
+
}
|
|
52638
52682
|
function retireWitnesses(queue, channel, settledKeys) {
|
|
52639
52683
|
return queue.filter((w) => !(w.channel === channel && settledKeys.has(w.witnessKey)));
|
|
52640
52684
|
}
|
|
@@ -52894,7 +52938,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
52894
52938
|
}
|
|
52895
52939
|
|
|
52896
52940
|
// src/engine.ts
|
|
52897
|
-
var DAEMON_VERSION = true ? "2.0.2-dev.
|
|
52941
|
+
var DAEMON_VERSION = true ? "2.0.2-dev.305" : "2.0.0-alpha.0";
|
|
52898
52942
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
52899
52943
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
52900
52944
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -53837,8 +53881,20 @@ function createWorkspaceEngine(opts) {
|
|
|
53837
53881
|
const citingSession = sessionOriginKey(sessionId);
|
|
53838
53882
|
const mintedHere = (nodeId) => store.getNode(nodeId)?.attrs["sources"]?.[0] === sessionId;
|
|
53839
53883
|
const sendWitnesses = async (channel, fresh, send) => {
|
|
53840
|
-
const queued =
|
|
53841
|
-
|
|
53884
|
+
const { replay: queued, waiting } = partitionReplayable(
|
|
53885
|
+
witnessQueue,
|
|
53886
|
+
channel,
|
|
53887
|
+
(nodeId) => {
|
|
53888
|
+
const n = store.getNode(nodeId);
|
|
53889
|
+
return !n || n.attrs["contributedAtSeq"] != null;
|
|
53890
|
+
}
|
|
53891
|
+
);
|
|
53892
|
+
if (fresh.length === 0 && queued.length === 0) {
|
|
53893
|
+
if (waiting.length > 0) {
|
|
53894
|
+
console.log(`[errata] ${channel}: ${waiting.length} parked awaiting node drain`);
|
|
53895
|
+
}
|
|
53896
|
+
return;
|
|
53897
|
+
}
|
|
53842
53898
|
const groups = /* @__PURE__ */ new Map();
|
|
53843
53899
|
for (const q of queued) {
|
|
53844
53900
|
const g = groups.get(q.sessionKey) ?? [];
|
|
@@ -53883,7 +53939,7 @@ function createWorkspaceEngine(opts) {
|
|
|
53883
53939
|
witnessQueue = enqueueWitnesses(witnessQueue, stillUnmatched, Date.now());
|
|
53884
53940
|
saveWitnessQueue(witnessQueuePath(paths.configDir), witnessQueue);
|
|
53885
53941
|
console.log(
|
|
53886
|
-
`[errata] ${channel}: ${formatDisposition({ recorded, unmatched, duplicate, selfGated })}` + (queued.length > 0 ? ` (incl. ${queued.length} replayed)` : "")
|
|
53942
|
+
`[errata] ${channel}: ${formatDisposition({ recorded, unmatched, duplicate, selfGated })}` + (queued.length > 0 ? ` (incl. ${queued.length} replayed)` : "") + (waiting.length > 0 ? ` (${waiting.length} awaiting drain)` : "")
|
|
53887
53943
|
);
|
|
53888
53944
|
appendWitnessLedger(paths.configDir, {
|
|
53889
53945
|
ts: Date.now(),
|
|
@@ -53892,7 +53948,8 @@ function createWorkspaceEngine(opts) {
|
|
|
53892
53948
|
unmatched,
|
|
53893
53949
|
duplicate,
|
|
53894
53950
|
selfGated,
|
|
53895
|
-
parked: pendingFor(witnessQueue, channel).length
|
|
53951
|
+
parked: pendingFor(witnessQueue, channel).length,
|
|
53952
|
+
awaitingDrain: waiting.length
|
|
53896
53953
|
});
|
|
53897
53954
|
};
|
|
53898
53955
|
if (typeof cloud.reportContradictions === "function") {
|