@inerrata-corporation/errata 2.0.6-dev.2674 → 2.0.6-dev.2687
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 +95 -40
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -78536,7 +78536,7 @@ function createWatchBreaker(deps) {
|
|
|
78536
78536
|
}
|
|
78537
78537
|
|
|
78538
78538
|
// src/engine.ts
|
|
78539
|
-
var DAEMON_VERSION = true ? "2.0.6-dev.
|
|
78539
|
+
var DAEMON_VERSION = true ? "2.0.6-dev.2687" : "2.0.0-alpha.0";
|
|
78540
78540
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
78541
78541
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
78542
78542
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -84228,6 +84228,7 @@ var HISTORY_EXTRACTOR_VERSION = "history-2";
|
|
|
84228
84228
|
var LEASE_POLL_MS = 2e4;
|
|
84229
84229
|
var RECOVERY_DEADLINE_MS = 15 * 6e4;
|
|
84230
84230
|
var MAX_ANCHORS_PER_TOKEN = 20;
|
|
84231
|
+
var DEFAULT_LOOKAHEAD = 2;
|
|
84231
84232
|
async function defaultGit(root, args2) {
|
|
84232
84233
|
const { stdout } = await execFileAsync("git", ["-C", root, ...args2], { maxBuffer: 64 * 1024 * 1024, windowsHide: true });
|
|
84233
84234
|
return stdout;
|
|
@@ -84327,7 +84328,11 @@ function unitTiming(postStarted, prepMs, receipt) {
|
|
|
84327
84328
|
const g = receipt.gate;
|
|
84328
84329
|
if (g) parts2.push(g.pRoutine === null ? `jev ${g.error ?? "n/a"}` : `jev ${s(g.ms)} p=${g.pRoutine}${g.skipped ? " skipped" : ""}`);
|
|
84329
84330
|
if (receipt.timing?.modelMs !== void 0) parts2.push(`model ${s(receipt.timing.modelMs)}`);
|
|
84330
|
-
if (receipt.timing?.
|
|
84331
|
+
if (receipt.timing?.orderWaitMs) parts2.push(`waited ${s(receipt.timing.orderWaitMs)} for the previous write`);
|
|
84332
|
+
if (receipt.timing?.ingestMs !== void 0) {
|
|
84333
|
+
const top = Object.entries(receipt.timing.ingestStages ?? {}).slice(0, 4).map(([k, v]) => `${k} ${v}`);
|
|
84334
|
+
parts2.push(`ingest ${s(receipt.timing.ingestMs)}${top.length ? ` [${top.join(", ")}]` : ""}`);
|
|
84335
|
+
}
|
|
84331
84336
|
return ` in ${s(Date.now() - postStarted + prepMs)} (${parts2.join(", ")})`;
|
|
84332
84337
|
}
|
|
84333
84338
|
function addCounts(a, b) {
|
|
@@ -84383,8 +84388,77 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84383
84388
|
let processed = 0;
|
|
84384
84389
|
const byIndex = /* @__PURE__ */ new Map();
|
|
84385
84390
|
for (const u of units) byIndex.set(u.index, [...byIndex.get(u.index) ?? [], u]);
|
|
84386
|
-
|
|
84387
|
-
|
|
84391
|
+
const lookahead = dryRun ? 0 : Math.max(0, opts.lookahead ?? DEFAULT_LOOKAHEAD);
|
|
84392
|
+
let doorOrders = false;
|
|
84393
|
+
const settle = (p) => p.then((res) => ({ res }), (err2) => ({ err: err2 }));
|
|
84394
|
+
const prepared = /* @__PURE__ */ new Map();
|
|
84395
|
+
const launched = /* @__PURE__ */ new Map();
|
|
84396
|
+
const cap = opts.maxUnits;
|
|
84397
|
+
const predecessor = (k) => {
|
|
84398
|
+
for (let j = k - 1; j >= 0; j--) if (!units[j].skip) return units[j];
|
|
84399
|
+
return void 0;
|
|
84400
|
+
};
|
|
84401
|
+
const prepare = (k) => {
|
|
84402
|
+
const hit = prepared.get(k);
|
|
84403
|
+
if (hit) return hit;
|
|
84404
|
+
const p = (async () => {
|
|
84405
|
+
const u = units[k];
|
|
84406
|
+
const prepStarted = Date.now();
|
|
84407
|
+
const group = byIndex.get(u.index) ?? [u];
|
|
84408
|
+
const bundle = await buildUnitBundle(root, u, {
|
|
84409
|
+
ignorePatterns: ignoreLines,
|
|
84410
|
+
narrative: narrative(u, u.isMerge ? group : void 0)
|
|
84411
|
+
});
|
|
84412
|
+
const prev = dryRun ? void 0 : predecessor(k);
|
|
84413
|
+
const body2 = {
|
|
84414
|
+
unit: {
|
|
84415
|
+
sha: u.sha,
|
|
84416
|
+
index: u.index,
|
|
84417
|
+
subIndex: u.subIndex,
|
|
84418
|
+
isMerge: u.isMerge,
|
|
84419
|
+
...u.groupSha ? { groupSha: u.groupSha } : {},
|
|
84420
|
+
...u.authorDate ? { authorDate: u.authorDate } : {}
|
|
84421
|
+
},
|
|
84422
|
+
narrative: bundle.narrative,
|
|
84423
|
+
fileList: bundle.fileList,
|
|
84424
|
+
diff: bundle.diff,
|
|
84425
|
+
pathTokens: Object.keys(bundle.pathTokens),
|
|
84426
|
+
extractorVersion: HISTORY_EXTRACTOR_VERSION,
|
|
84427
|
+
...opts.frame ? { frame: opts.frame } : {},
|
|
84428
|
+
...dryRun ? { dryRun: true } : {},
|
|
84429
|
+
...prev ? { after: { sha: prev.sha, subIndex: prev.subIndex } } : {}
|
|
84430
|
+
};
|
|
84431
|
+
const spine = await spineForUnit(git3, root, u, readBlob);
|
|
84432
|
+
if (spine) body2.spine = spine;
|
|
84433
|
+
const anchors = anchorsFor(bundle.pathTokens, ignoreLines, projectId, opts.anchors);
|
|
84434
|
+
if (anchors) {
|
|
84435
|
+
body2.anchors = anchors;
|
|
84436
|
+
body2.observedAtCommit = headSha;
|
|
84437
|
+
}
|
|
84438
|
+
return { body: body2, prepMs: Date.now() - prepStarted };
|
|
84439
|
+
})();
|
|
84440
|
+
prepared.set(k, p);
|
|
84441
|
+
return p;
|
|
84442
|
+
};
|
|
84443
|
+
const launch = async (k) => {
|
|
84444
|
+
if (launched.has(k)) return;
|
|
84445
|
+
const { body: body2 } = await prepare(k);
|
|
84446
|
+
if (launched.has(k)) return;
|
|
84447
|
+
launched.set(k, { at: Date.now(), settled: settle(Promise.resolve().then(() => post(projectId, body2))) });
|
|
84448
|
+
};
|
|
84449
|
+
const launchAhead = async (k) => {
|
|
84450
|
+
if (!doorOrders || lookahead === 0) return;
|
|
84451
|
+
let ahead = 0;
|
|
84452
|
+
for (let j = k + 1; j < units.length && ahead < lookahead; j++) {
|
|
84453
|
+
if (cap !== void 0 && processed + (j - k) >= cap) break;
|
|
84454
|
+
if (units[j].skip) continue;
|
|
84455
|
+
ahead += 1;
|
|
84456
|
+
await launch(j);
|
|
84457
|
+
}
|
|
84458
|
+
};
|
|
84459
|
+
for (let k = 0; k < units.length; k++) {
|
|
84460
|
+
const u = units[k];
|
|
84461
|
+
if (cap !== void 0 && processed >= cap) break;
|
|
84388
84462
|
const label = `${u.sha.slice(0, 12)}${u.subIndex ? `/${u.subIndex}` : ""}`;
|
|
84389
84463
|
const doneSoFar = (profile.historyStage?.unitsDone ?? 0) + 1;
|
|
84390
84464
|
const group = byIndex.get(u.index) ?? [u];
|
|
@@ -84398,35 +84472,7 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84398
84472
|
log(`[errata] history ${label} skipped (${u.skip})`);
|
|
84399
84473
|
continue;
|
|
84400
84474
|
}
|
|
84401
|
-
const
|
|
84402
|
-
const bundle = await buildUnitBundle(root, u, {
|
|
84403
|
-
ignorePatterns: ignoreLines,
|
|
84404
|
-
narrative: narrative(u, u.isMerge ? group : void 0)
|
|
84405
|
-
});
|
|
84406
|
-
const body2 = {
|
|
84407
|
-
unit: {
|
|
84408
|
-
sha: u.sha,
|
|
84409
|
-
index: u.index,
|
|
84410
|
-
subIndex: u.subIndex,
|
|
84411
|
-
isMerge: u.isMerge,
|
|
84412
|
-
...u.groupSha ? { groupSha: u.groupSha } : {},
|
|
84413
|
-
...u.authorDate ? { authorDate: u.authorDate } : {}
|
|
84414
|
-
},
|
|
84415
|
-
narrative: bundle.narrative,
|
|
84416
|
-
fileList: bundle.fileList,
|
|
84417
|
-
diff: bundle.diff,
|
|
84418
|
-
pathTokens: Object.keys(bundle.pathTokens),
|
|
84419
|
-
extractorVersion: HISTORY_EXTRACTOR_VERSION,
|
|
84420
|
-
...opts.frame ? { frame: opts.frame } : {},
|
|
84421
|
-
...dryRun ? { dryRun: true } : {}
|
|
84422
|
-
};
|
|
84423
|
-
const spine = await spineForUnit(git3, root, u, readBlob);
|
|
84424
|
-
if (spine) body2.spine = spine;
|
|
84425
|
-
const anchors = anchorsFor(bundle.pathTokens, ignoreLines, projectId, opts.anchors);
|
|
84426
|
-
if (anchors) {
|
|
84427
|
-
body2.anchors = anchors;
|
|
84428
|
-
body2.observedAtCommit = headSha;
|
|
84429
|
-
}
|
|
84475
|
+
const { body: body2, prepMs } = await prepare(k);
|
|
84430
84476
|
profile = stage(profile, { state: dryRun ? "extracting" : "contributing", unitsDone: doneSoFar - 1, lastError: void 0 }, now);
|
|
84431
84477
|
persist(profile);
|
|
84432
84478
|
response = await reportHistoryStage(client, profile, log);
|
|
@@ -84436,16 +84482,21 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84436
84482
|
await reportHistoryStage(client, profile, log);
|
|
84437
84483
|
return { profile, processed, state: "refused" };
|
|
84438
84484
|
}
|
|
84439
|
-
|
|
84440
|
-
|
|
84485
|
+
await launch(k);
|
|
84486
|
+
await launchAhead(k);
|
|
84487
|
+
const head2 = launched.get(k);
|
|
84488
|
+
launched.delete(k);
|
|
84489
|
+
prepared.delete(k);
|
|
84490
|
+
const started2 = head2.at;
|
|
84491
|
+
let first = head2.settled;
|
|
84441
84492
|
let outcome = null;
|
|
84442
84493
|
let attempt = 0;
|
|
84443
84494
|
while (outcome === null) {
|
|
84444
84495
|
attempt += 1;
|
|
84445
|
-
|
|
84446
|
-
|
|
84447
|
-
|
|
84448
|
-
|
|
84496
|
+
const settled = await (first ?? settle(Promise.resolve().then(() => post(projectId, body2))));
|
|
84497
|
+
first = null;
|
|
84498
|
+
if ("err" in settled) {
|
|
84499
|
+
const err2 = settled.err;
|
|
84449
84500
|
const status = err2 instanceof CloudError ? err2.status : 0;
|
|
84450
84501
|
const elapsed = Math.round((Date.now() - started2) / 1e3);
|
|
84451
84502
|
if (Date.now() - started2 > RECOVERY_DEADLINE_MS) {
|
|
@@ -84458,6 +84509,8 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84458
84509
|
await sleep(attempt === 1 ? 1e4 : Math.min(3e4 * attempt, 12e4));
|
|
84459
84510
|
continue;
|
|
84460
84511
|
}
|
|
84512
|
+
const res = settled.res;
|
|
84513
|
+
if (res.ordered) doorOrders = true;
|
|
84461
84514
|
if (res.status === "in_progress") {
|
|
84462
84515
|
const retryAt = new Date(Date.now() + res.retryAfterMs).toISOString();
|
|
84463
84516
|
if (Date.now() - started2 > RECOVERY_DEADLINE_MS) {
|
|
@@ -84466,12 +84519,14 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84466
84519
|
await reportHistoryStage(client, profile, log);
|
|
84467
84520
|
return { profile, processed, state: "paused" };
|
|
84468
84521
|
}
|
|
84469
|
-
|
|
84522
|
+
const why = res.waitingOn === "predecessor" ? `sent ahead, its predecessor ${res.predecessor === "failed" ? "failed" : "had not landed"} \u2014 re-POSTing in turn` : "run held by the door (lease)";
|
|
84523
|
+
log(`[errata] history ${label}: ${why}, polling in ${Math.min(LEASE_POLL_MS, res.retryAfterMs) / 1e3}s`);
|
|
84470
84524
|
await sleep(Math.min(LEASE_POLL_MS, Math.max(1e3, res.retryAfterMs)));
|
|
84471
84525
|
continue;
|
|
84472
84526
|
}
|
|
84473
84527
|
outcome = res;
|
|
84474
84528
|
}
|
|
84529
|
+
await launchAhead(k);
|
|
84475
84530
|
switch (outcome.status) {
|
|
84476
84531
|
case "completed": {
|
|
84477
84532
|
if (outcome.result.nodes.length !== outcome.counts.nodes || outcome.result.edges.length !== outcome.counts.edges) {
|