@inerrata-corporation/errata 2.0.17-dev.3435 → 2.0.17-dev.3447
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 +56 -57
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -26399,7 +26399,7 @@ function parseRestErrorEnvelope(text) {
|
|
|
26399
26399
|
return null;
|
|
26400
26400
|
}
|
|
26401
26401
|
}
|
|
26402
|
-
var asWireCount, INGEST_NODE_CHUNK, E6B_PUBLIC_CONTEXT_SENTINEL, CloudClient, CloudError;
|
|
26402
|
+
var asWireCount, INGEST_NODE_CHUNK, INGEST_EDGE_CHUNK, E6B_PUBLIC_CONTEXT_SENTINEL, CloudClient, CloudError;
|
|
26403
26403
|
var init_client = __esm({
|
|
26404
26404
|
"../../packages/cloud-client/src/client.ts"() {
|
|
26405
26405
|
"use strict";
|
|
@@ -26407,6 +26407,7 @@ var init_client = __esm({
|
|
|
26407
26407
|
init_src();
|
|
26408
26408
|
asWireCount = (n) => typeof n === "number" && Number.isFinite(n) && n >= 0 ? Math.floor(n) : null;
|
|
26409
26409
|
INGEST_NODE_CHUNK = 8;
|
|
26410
|
+
INGEST_EDGE_CHUNK = 32;
|
|
26410
26411
|
E6B_PUBLIC_CONTEXT_SENTINEL = "00000000-0000-4e6b-8000-000000000e6b";
|
|
26411
26412
|
CloudClient = class {
|
|
26412
26413
|
baseUrl;
|
|
@@ -26598,42 +26599,45 @@ var init_client = __esm({
|
|
|
26598
26599
|
async ingest(batch, opts = {}) {
|
|
26599
26600
|
const runId = randomUUID();
|
|
26600
26601
|
const startedAt = Date.now();
|
|
26601
|
-
const
|
|
26602
|
+
const single = batch.nodes.length <= INGEST_NODE_CHUNK && batch.edges.length <= INGEST_EDGE_CHUNK;
|
|
26603
|
+
let pendingEdges = [...batch.edges];
|
|
26604
|
+
const nodePlan = single ? [] : chunkArray(batch.nodes, INGEST_NODE_CHUNK).map((nodes) => {
|
|
26605
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
26606
|
+
const edges = pendingEdges.filter((e) => ids.has(e.from) && ids.has(e.to)).slice(0, INGEST_EDGE_CHUNK);
|
|
26607
|
+
const shipped = new Set(edges);
|
|
26608
|
+
pendingEdges = pendingEdges.filter((e) => !shipped.has(e));
|
|
26609
|
+
return { nodes, edges };
|
|
26610
|
+
});
|
|
26611
|
+
const totalChunks = single ? 1 : nodePlan.length + Math.ceil(pendingEdges.length / INGEST_EDGE_CHUNK);
|
|
26602
26612
|
let chunkIndex = 0;
|
|
26603
26613
|
const blocked = [];
|
|
26604
|
-
const emit = (nodeIds,
|
|
26614
|
+
const emit = async (nodeIds, result) => {
|
|
26605
26615
|
chunkIndex++;
|
|
26606
26616
|
const refused = blocked.splice(0, blocked.length);
|
|
26607
26617
|
const refusedSet = new Set(refused);
|
|
26608
|
-
opts.onChunk?.({
|
|
26618
|
+
await opts.onChunk?.({
|
|
26609
26619
|
chunkIndex,
|
|
26610
26620
|
totalChunks,
|
|
26611
26621
|
// Watermark only what actually landed — a blocked node never reached the
|
|
26612
26622
|
// door, and marking it contributed would lose it permanently and silently.
|
|
26613
26623
|
nodeIds: refusedSet.size ? nodeIds.filter((id) => !refusedSet.has(id)) : nodeIds,
|
|
26614
|
-
accepted,
|
|
26624
|
+
accepted: summarizeIngestResult(result).accepted,
|
|
26625
|
+
result,
|
|
26615
26626
|
elapsedMs: Date.now() - startedAt,
|
|
26616
26627
|
...refused.length ? { blockedNodeIds: refused } : {}
|
|
26617
26628
|
});
|
|
26618
26629
|
};
|
|
26619
|
-
if (
|
|
26630
|
+
if (single) {
|
|
26620
26631
|
const result = await this.ingestWithSplit(batch, batch.nodes, batch.edges, blocked);
|
|
26621
26632
|
const summary = summarizeIngestResult(result);
|
|
26622
|
-
emit(batch.nodes.map((n) => n.id),
|
|
26633
|
+
await emit(batch.nodes.map((n) => n.id), result);
|
|
26623
26634
|
return { ...summary, result };
|
|
26624
26635
|
}
|
|
26625
26636
|
const merged = { runId, nodes: [], edges: [] };
|
|
26626
|
-
let pendingEdges = [...batch.edges];
|
|
26627
26637
|
const echoedCloudId = /* @__PURE__ */ new Map();
|
|
26628
|
-
for (const nodeChunk of
|
|
26629
|
-
const ids = new Set(nodeChunk.map((n) => n.id));
|
|
26630
|
-
const inChunk = pendingEdges.filter((e) => ids.has(e.from) && ids.has(e.to)).slice(0, MAX_EDGES_PER_PAYLOAD);
|
|
26631
|
-
if (inChunk.length > 0) {
|
|
26632
|
-
const shipped = new Set(inChunk);
|
|
26633
|
-
pendingEdges = pendingEdges.filter((e) => !shipped.has(e));
|
|
26634
|
-
}
|
|
26638
|
+
for (const { nodes: nodeChunk, edges: inChunk } of nodePlan) {
|
|
26635
26639
|
const r = await this.ingestWithSplit(batch, nodeChunk, inChunk, blocked);
|
|
26636
|
-
emit(nodeChunk.map((n) => n.id),
|
|
26640
|
+
await emit(nodeChunk.map((n) => n.id), r);
|
|
26637
26641
|
merged.nodes.push(...r.nodes);
|
|
26638
26642
|
merged.edges.push(...r.edges);
|
|
26639
26643
|
for (const rn of r.nodes) {
|
|
@@ -26645,7 +26649,7 @@ var init_client = __esm({
|
|
|
26645
26649
|
merged.patternReconciliation = { ...merged.patternReconciliation, ...r.patternReconciliation };
|
|
26646
26650
|
}
|
|
26647
26651
|
}
|
|
26648
|
-
for (const edgeChunk of chunkArray(pendingEdges,
|
|
26652
|
+
for (const edgeChunk of chunkArray(pendingEdges, INGEST_EDGE_CHUNK)) {
|
|
26649
26653
|
const projected = edgeChunk.map((e) => ({
|
|
26650
26654
|
...e,
|
|
26651
26655
|
from: echoedCloudId.get(e.from) ?? e.from,
|
|
@@ -26664,11 +26668,11 @@ var init_client = __esm({
|
|
|
26664
26668
|
return false;
|
|
26665
26669
|
});
|
|
26666
26670
|
if (rewritten.length === 0) {
|
|
26667
|
-
emit([],
|
|
26671
|
+
await emit([], { runId, nodes: [], edges: [] });
|
|
26668
26672
|
continue;
|
|
26669
26673
|
}
|
|
26670
|
-
const r = await this.
|
|
26671
|
-
emit([],
|
|
26674
|
+
const r = await this.ingestWithSplit(batch, [], rewritten, blocked);
|
|
26675
|
+
await emit([], r);
|
|
26672
26676
|
merged.edges.push(...r.edges);
|
|
26673
26677
|
}
|
|
26674
26678
|
return { ...summarizeIngestResult(merged), result: merged };
|
|
@@ -26697,6 +26701,12 @@ var init_client = __esm({
|
|
|
26697
26701
|
} catch (err2) {
|
|
26698
26702
|
const status = err2 instanceof CloudError ? err2.status : 0;
|
|
26699
26703
|
const timedOut = status === 502 || status === 504 || status === 408 || status === 0;
|
|
26704
|
+
if (timedOut && nodes.length === 0 && edges.length > 1) {
|
|
26705
|
+
const mid2 = Math.ceil(edges.length / 2);
|
|
26706
|
+
const a2 = await this.ingestWithSplit(batch, [], edges.slice(0, mid2), blocked);
|
|
26707
|
+
const b2 = await this.ingestWithSplit(batch, [], edges.slice(mid2), blocked);
|
|
26708
|
+
return { runId: a2.runId, nodes: [], edges: [...a2.edges, ...b2.edges] };
|
|
26709
|
+
}
|
|
26700
26710
|
const refusedAtEdge = blocked !== void 0 && isIntermediaryRejection(err2);
|
|
26701
26711
|
if (refusedAtEdge && nodes.length === 1 && nodes[0]) {
|
|
26702
26712
|
blocked.push(nodes[0].id);
|
|
@@ -82159,7 +82169,7 @@ function createWatchBreaker(deps) {
|
|
|
82159
82169
|
}
|
|
82160
82170
|
|
|
82161
82171
|
// src/engine.ts
|
|
82162
|
-
var DAEMON_VERSION = true ? "2.0.17-dev.
|
|
82172
|
+
var DAEMON_VERSION = true ? "2.0.17-dev.3447" : "2.0.0-alpha.0";
|
|
82163
82173
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
82164
82174
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
82165
82175
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -85076,6 +85086,17 @@ function updateInstanceReceipt(n, destination, patch, mirrorLegacy) {
|
|
|
85076
85086
|
function instanceReceiptSequence(n) {
|
|
85077
85087
|
return Math.max(n.lastReinforcedAtSeq ?? 0, n.createdAtSeq ?? 0);
|
|
85078
85088
|
}
|
|
85089
|
+
function acceptedInstanceReceipt(current, sent, decision, destination, mirrorLegacy) {
|
|
85090
|
+
if (!["Problem", "Vulnerability", "Solution", "RootCause"].includes(current.label) || !["created", "reinforced"].includes(decision.decision) || !decision.nodeId) return null;
|
|
85091
|
+
return updateInstanceReceipt(current, destination, {
|
|
85092
|
+
contributedAtSeq: instanceReceiptSequence(sent),
|
|
85093
|
+
cloudNodeId: decision.nodeId,
|
|
85094
|
+
shipRefusedSinceSeq: void 0,
|
|
85095
|
+
shipRefusedCount: void 0,
|
|
85096
|
+
shipRefusedReason: void 0,
|
|
85097
|
+
shipRefusedFingerprint: void 0
|
|
85098
|
+
}, mirrorLegacy);
|
|
85099
|
+
}
|
|
85079
85100
|
|
|
85080
85101
|
// src/multi.ts
|
|
85081
85102
|
init_dist();
|
|
@@ -90290,10 +90311,24 @@ async function startMultiDaemon(opts = {}) {
|
|
|
90290
90311
|
if (project) instances.projectId = project.projectId;
|
|
90291
90312
|
const shipStartedAt = Date.now();
|
|
90292
90313
|
await lane("instances", projectName, async () => {
|
|
90314
|
+
const owningStore = (id) => {
|
|
90315
|
+
const w = store.getNode(id);
|
|
90316
|
+
if (w) return { s: store, n: w };
|
|
90317
|
+
const sh = sharedStore.getNode(id);
|
|
90318
|
+
return sh ? { s: sharedStore, n: sh } : null;
|
|
90319
|
+
};
|
|
90320
|
+
const sentById = new Map(instances.nodes.map((n) => [n.id, n]));
|
|
90293
90321
|
const blocked = /* @__PURE__ */ new Set();
|
|
90294
90322
|
const res = await client.ingest(instances, {
|
|
90295
90323
|
onChunk: (p) => {
|
|
90296
90324
|
for (const id of p.blockedNodeIds ?? []) blocked.add(id);
|
|
90325
|
+
for (const decision of p.result.nodes) {
|
|
90326
|
+
const sent = sentById.get(decision.canonicalId);
|
|
90327
|
+
const owner = owningStore(decision.canonicalId);
|
|
90328
|
+
if (!sent || !owner || blocked.has(sent.id)) continue;
|
|
90329
|
+
const attrs = acceptedInstanceReceipt(owner.n, sent, decision, destinationKey, owner.s === store);
|
|
90330
|
+
if (attrs) owner.s.updateNode(sent.id, { attrs });
|
|
90331
|
+
}
|
|
90297
90332
|
noteFlushProgress(p.accepted, p.nodeIds.length, `instances ${p.chunkIndex}/${p.totalChunks}`);
|
|
90298
90333
|
}
|
|
90299
90334
|
});
|
|
@@ -90303,9 +90338,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
90303
90338
|
);
|
|
90304
90339
|
}
|
|
90305
90340
|
uploaded += res.accepted;
|
|
90306
|
-
const cloudIdByLocal = new Map(
|
|
90307
|
-
res.result.nodes.filter((rn) => rn.nodeId).map((rn) => [rn.canonicalId, rn.nodeId])
|
|
90308
|
-
);
|
|
90309
90341
|
const rejected = /* @__PURE__ */ new Map();
|
|
90310
90342
|
for (const rn of res.result.nodes) {
|
|
90311
90343
|
if (rn.decision === "rejected") rejected.set(rn.canonicalId, rn.reason ?? "no reason given");
|
|
@@ -90328,13 +90360,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
90328
90360
|
`[sync\u2192cloud] [${projectName}] instances: ${rejected.size} node(s) REJECTED by the door \u2014 left pending for the next flush: ` + sample.join(" | ")
|
|
90329
90361
|
);
|
|
90330
90362
|
}
|
|
90331
|
-
const owningStore = (id) => {
|
|
90332
|
-
const w = store.getNode(id);
|
|
90333
|
-
if (w) return { s: store, n: w };
|
|
90334
|
-
const sh = sharedStore.getNode(id);
|
|
90335
|
-
if (sh) return { s: sharedStore, n: sh };
|
|
90336
|
-
return null;
|
|
90337
|
-
};
|
|
90338
90363
|
let blockedRepeat = 0;
|
|
90339
90364
|
let rejectedRepeat = 0;
|
|
90340
90365
|
const nowHeld = [];
|
|
@@ -90365,32 +90390,6 @@ async function startMultiDaemon(opts = {}) {
|
|
|
90365
90390
|
`[sync\u2192cloud] [${projectName}] instances: HOLDING ${nowHeld.length} node(s) \u2014 refused identically ${SHIP_TERMINAL_REFUSALS}\xD7 on unchanged text; not re-sent until the text changes: ` + nowHeld.map(({ id, reason }) => `${id} "${owningStore(id)?.n.description.slice(0, 60) ?? ""}": ${reason}`).join(" | ")
|
|
90366
90391
|
);
|
|
90367
90392
|
}
|
|
90368
|
-
await stampBatched(instances.nodes, (n) => {
|
|
90369
|
-
const owner = owningStore(n.id);
|
|
90370
|
-
if (!owner || !["Problem", "Solution", "RootCause"].includes(owner.n.label)) return;
|
|
90371
|
-
if (blocked.has(n.id)) return;
|
|
90372
|
-
if (!cloudIdByLocal.has(n.id)) return;
|
|
90373
|
-
if (rejected.has(n.id)) return;
|
|
90374
|
-
const cloudNodeId = cloudIdByLocal.get(n.id);
|
|
90375
|
-
const {
|
|
90376
|
-
shipRefusedSinceSeq: _clearedSeq,
|
|
90377
|
-
shipRefusedCount: _clearedCount,
|
|
90378
|
-
shipRefusedReason: _clearedReason,
|
|
90379
|
-
shipRefusedFingerprint: _clearedFp,
|
|
90380
|
-
...carried
|
|
90381
|
-
} = instanceReceipt(owner.n, destinationKey);
|
|
90382
|
-
owner.s.updateNode(n.id, {
|
|
90383
|
-
attrs: updateInstanceReceipt(owner.n, destinationKey, {
|
|
90384
|
-
...carried,
|
|
90385
|
-
shipRefusedSinceSeq: void 0,
|
|
90386
|
-
shipRefusedCount: void 0,
|
|
90387
|
-
shipRefusedReason: void 0,
|
|
90388
|
-
shipRefusedFingerprint: void 0,
|
|
90389
|
-
contributedAtSeq: instanceReceiptSequence(n),
|
|
90390
|
-
cloudNodeId
|
|
90391
|
-
}, owner.s === store)
|
|
90392
|
-
});
|
|
90393
|
-
});
|
|
90394
90393
|
await stampBatched(Object.entries(instances.anchorDigests), ([localId, dg]) => {
|
|
90395
90394
|
const owner = owningStore(localId);
|
|
90396
90395
|
if (!owner) return;
|