@inerrata-corporation/errata 2.0.6-dev.2674 → 2.0.6-dev.2681
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 +91 -39
- 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.2681" : "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,6 +84328,7 @@ 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)}`);
|
|
84331
|
+
if (receipt.timing?.orderWaitMs) parts2.push(`waited ${s(receipt.timing.orderWaitMs)} for the previous write`);
|
|
84330
84332
|
if (receipt.timing?.ingestMs !== void 0) parts2.push(`ingest ${s(receipt.timing.ingestMs)}`);
|
|
84331
84333
|
return ` in ${s(Date.now() - postStarted + prepMs)} (${parts2.join(", ")})`;
|
|
84332
84334
|
}
|
|
@@ -84383,8 +84385,77 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84383
84385
|
let processed = 0;
|
|
84384
84386
|
const byIndex = /* @__PURE__ */ new Map();
|
|
84385
84387
|
for (const u of units) byIndex.set(u.index, [...byIndex.get(u.index) ?? [], u]);
|
|
84386
|
-
|
|
84387
|
-
|
|
84388
|
+
const lookahead = dryRun ? 0 : Math.max(0, opts.lookahead ?? DEFAULT_LOOKAHEAD);
|
|
84389
|
+
let doorOrders = false;
|
|
84390
|
+
const settle = (p) => p.then((res) => ({ res }), (err2) => ({ err: err2 }));
|
|
84391
|
+
const prepared = /* @__PURE__ */ new Map();
|
|
84392
|
+
const launched = /* @__PURE__ */ new Map();
|
|
84393
|
+
const cap = opts.maxUnits;
|
|
84394
|
+
const predecessor = (k) => {
|
|
84395
|
+
for (let j = k - 1; j >= 0; j--) if (!units[j].skip) return units[j];
|
|
84396
|
+
return void 0;
|
|
84397
|
+
};
|
|
84398
|
+
const prepare = (k) => {
|
|
84399
|
+
const hit = prepared.get(k);
|
|
84400
|
+
if (hit) return hit;
|
|
84401
|
+
const p = (async () => {
|
|
84402
|
+
const u = units[k];
|
|
84403
|
+
const prepStarted = Date.now();
|
|
84404
|
+
const group = byIndex.get(u.index) ?? [u];
|
|
84405
|
+
const bundle = await buildUnitBundle(root, u, {
|
|
84406
|
+
ignorePatterns: ignoreLines,
|
|
84407
|
+
narrative: narrative(u, u.isMerge ? group : void 0)
|
|
84408
|
+
});
|
|
84409
|
+
const prev = dryRun ? void 0 : predecessor(k);
|
|
84410
|
+
const body2 = {
|
|
84411
|
+
unit: {
|
|
84412
|
+
sha: u.sha,
|
|
84413
|
+
index: u.index,
|
|
84414
|
+
subIndex: u.subIndex,
|
|
84415
|
+
isMerge: u.isMerge,
|
|
84416
|
+
...u.groupSha ? { groupSha: u.groupSha } : {},
|
|
84417
|
+
...u.authorDate ? { authorDate: u.authorDate } : {}
|
|
84418
|
+
},
|
|
84419
|
+
narrative: bundle.narrative,
|
|
84420
|
+
fileList: bundle.fileList,
|
|
84421
|
+
diff: bundle.diff,
|
|
84422
|
+
pathTokens: Object.keys(bundle.pathTokens),
|
|
84423
|
+
extractorVersion: HISTORY_EXTRACTOR_VERSION,
|
|
84424
|
+
...opts.frame ? { frame: opts.frame } : {},
|
|
84425
|
+
...dryRun ? { dryRun: true } : {},
|
|
84426
|
+
...prev ? { after: { sha: prev.sha, subIndex: prev.subIndex } } : {}
|
|
84427
|
+
};
|
|
84428
|
+
const spine = await spineForUnit(git3, root, u, readBlob);
|
|
84429
|
+
if (spine) body2.spine = spine;
|
|
84430
|
+
const anchors = anchorsFor(bundle.pathTokens, ignoreLines, projectId, opts.anchors);
|
|
84431
|
+
if (anchors) {
|
|
84432
|
+
body2.anchors = anchors;
|
|
84433
|
+
body2.observedAtCommit = headSha;
|
|
84434
|
+
}
|
|
84435
|
+
return { body: body2, prepMs: Date.now() - prepStarted };
|
|
84436
|
+
})();
|
|
84437
|
+
prepared.set(k, p);
|
|
84438
|
+
return p;
|
|
84439
|
+
};
|
|
84440
|
+
const launch = async (k) => {
|
|
84441
|
+
if (launched.has(k)) return;
|
|
84442
|
+
const { body: body2 } = await prepare(k);
|
|
84443
|
+
if (launched.has(k)) return;
|
|
84444
|
+
launched.set(k, { at: Date.now(), settled: settle(Promise.resolve().then(() => post(projectId, body2))) });
|
|
84445
|
+
};
|
|
84446
|
+
const launchAhead = async (k) => {
|
|
84447
|
+
if (!doorOrders || lookahead === 0) return;
|
|
84448
|
+
let ahead = 0;
|
|
84449
|
+
for (let j = k + 1; j < units.length && ahead < lookahead; j++) {
|
|
84450
|
+
if (cap !== void 0 && processed + (j - k) >= cap) break;
|
|
84451
|
+
if (units[j].skip) continue;
|
|
84452
|
+
ahead += 1;
|
|
84453
|
+
await launch(j);
|
|
84454
|
+
}
|
|
84455
|
+
};
|
|
84456
|
+
for (let k = 0; k < units.length; k++) {
|
|
84457
|
+
const u = units[k];
|
|
84458
|
+
if (cap !== void 0 && processed >= cap) break;
|
|
84388
84459
|
const label = `${u.sha.slice(0, 12)}${u.subIndex ? `/${u.subIndex}` : ""}`;
|
|
84389
84460
|
const doneSoFar = (profile.historyStage?.unitsDone ?? 0) + 1;
|
|
84390
84461
|
const group = byIndex.get(u.index) ?? [u];
|
|
@@ -84398,35 +84469,7 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84398
84469
|
log(`[errata] history ${label} skipped (${u.skip})`);
|
|
84399
84470
|
continue;
|
|
84400
84471
|
}
|
|
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
|
-
}
|
|
84472
|
+
const { body: body2, prepMs } = await prepare(k);
|
|
84430
84473
|
profile = stage(profile, { state: dryRun ? "extracting" : "contributing", unitsDone: doneSoFar - 1, lastError: void 0 }, now);
|
|
84431
84474
|
persist(profile);
|
|
84432
84475
|
response = await reportHistoryStage(client, profile, log);
|
|
@@ -84436,16 +84479,21 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84436
84479
|
await reportHistoryStage(client, profile, log);
|
|
84437
84480
|
return { profile, processed, state: "refused" };
|
|
84438
84481
|
}
|
|
84439
|
-
|
|
84440
|
-
|
|
84482
|
+
await launch(k);
|
|
84483
|
+
await launchAhead(k);
|
|
84484
|
+
const head2 = launched.get(k);
|
|
84485
|
+
launched.delete(k);
|
|
84486
|
+
prepared.delete(k);
|
|
84487
|
+
const started2 = head2.at;
|
|
84488
|
+
let first = head2.settled;
|
|
84441
84489
|
let outcome = null;
|
|
84442
84490
|
let attempt = 0;
|
|
84443
84491
|
while (outcome === null) {
|
|
84444
84492
|
attempt += 1;
|
|
84445
|
-
|
|
84446
|
-
|
|
84447
|
-
|
|
84448
|
-
|
|
84493
|
+
const settled = await (first ?? settle(Promise.resolve().then(() => post(projectId, body2))));
|
|
84494
|
+
first = null;
|
|
84495
|
+
if ("err" in settled) {
|
|
84496
|
+
const err2 = settled.err;
|
|
84449
84497
|
const status = err2 instanceof CloudError ? err2.status : 0;
|
|
84450
84498
|
const elapsed = Math.round((Date.now() - started2) / 1e3);
|
|
84451
84499
|
if (Date.now() - started2 > RECOVERY_DEADLINE_MS) {
|
|
@@ -84458,6 +84506,8 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84458
84506
|
await sleep(attempt === 1 ? 1e4 : Math.min(3e4 * attempt, 12e4));
|
|
84459
84507
|
continue;
|
|
84460
84508
|
}
|
|
84509
|
+
const res = settled.res;
|
|
84510
|
+
if (res.ordered) doorOrders = true;
|
|
84461
84511
|
if (res.status === "in_progress") {
|
|
84462
84512
|
const retryAt = new Date(Date.now() + res.retryAfterMs).toISOString();
|
|
84463
84513
|
if (Date.now() - started2 > RECOVERY_DEADLINE_MS) {
|
|
@@ -84466,12 +84516,14 @@ async function walk10(root, input, client, opts, readBlob) {
|
|
|
84466
84516
|
await reportHistoryStage(client, profile, log);
|
|
84467
84517
|
return { profile, processed, state: "paused" };
|
|
84468
84518
|
}
|
|
84469
|
-
|
|
84519
|
+
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)";
|
|
84520
|
+
log(`[errata] history ${label}: ${why}, polling in ${Math.min(LEASE_POLL_MS, res.retryAfterMs) / 1e3}s`);
|
|
84470
84521
|
await sleep(Math.min(LEASE_POLL_MS, Math.max(1e3, res.retryAfterMs)));
|
|
84471
84522
|
continue;
|
|
84472
84523
|
}
|
|
84473
84524
|
outcome = res;
|
|
84474
84525
|
}
|
|
84526
|
+
await launchAhead(k);
|
|
84475
84527
|
switch (outcome.status) {
|
|
84476
84528
|
case "completed": {
|
|
84477
84529
|
if (outcome.result.nodes.length !== outcome.counts.nodes || outcome.result.edges.length !== outcome.counts.edges) {
|