@inerrata-corporation/errata 2.0.17-dev.3447 → 2.0.17-dev.3459

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.
@@ -18575,6 +18575,8 @@ function generalize(text, opts = {}) {
18575
18575
  init_src();
18576
18576
 
18577
18577
  // src/instance-receipts.ts
18578
+ var INSTANCE_SEMANTIC_EDGE_TYPES = ["CAUSED_BY", "SOLVED_BY"];
18579
+ var INSTANCE_ANCHOR_EDGE_TYPES = ["OCCURS_IN", "DEPENDS_ON", "PERTAIN_TO", "CONCERNS"];
18578
18580
  function receiptMap(attrs) {
18579
18581
  const value = attrs["instanceReceipts"];
18580
18582
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -19455,8 +19457,8 @@ function generalizeFileRefs(text, fileLexicon, level = 1) {
19455
19457
 
19456
19458
  // src/instance-ingest.ts
19457
19459
  var INSTANCE_LABELS = ["Problem", "Vulnerability", "Solution", "RootCause"];
19458
- var INSTANCE_EDGES = ["CAUSED_BY", "SOLVED_BY"];
19459
- var ANCHOR_EDGES = ["OCCURS_IN", "DEPENDS_ON", "PERTAIN_TO", "CONCERNS"];
19460
+ var INSTANCE_EDGES = INSTANCE_SEMANTIC_EDGE_TYPES;
19461
+ var ANCHOR_EDGES = INSTANCE_ANCHOR_EDGE_TYPES;
19460
19462
  var ANCHOR_TARGET_LABELS = ["Language", "Package", "Domain", "Component"];
19461
19463
  function stripCodebaseScope(scope) {
19462
19464
  const s = { ...scope ?? {} };
package/errata.mjs CHANGED
@@ -82169,7 +82169,7 @@ function createWatchBreaker(deps) {
82169
82169
  }
82170
82170
 
82171
82171
  // src/engine.ts
82172
- var DAEMON_VERSION = true ? "2.0.17-dev.3447" : "2.0.0-alpha.0";
82172
+ var DAEMON_VERSION = true ? "2.0.17-dev.3459" : "2.0.0-alpha.0";
82173
82173
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
82174
82174
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
82175
82175
  var GIT_OP_MUTE_MS = 4e3;
@@ -85055,6 +85055,39 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
85055
85055
 
85056
85056
  // src/instance-receipts.ts
85057
85057
  import { createHash as createHash18 } from "node:crypto";
85058
+ var INSTANCE_SEMANTIC_EDGE_TYPES = ["CAUSED_BY", "SOLVED_BY"];
85059
+ var INSTANCE_ANCHOR_EDGE_TYPES = ["OCCURS_IN", "DEPENDS_ON", "PERTAIN_TO", "CONCERNS"];
85060
+ function edgeReceiptKind(type) {
85061
+ if (INSTANCE_SEMANTIC_EDGE_TYPES.includes(type)) return "semantic";
85062
+ if (INSTANCE_ANCHOR_EDGE_TYPES.includes(type)) return "anchor";
85063
+ return type === "ANCHORED_AT" ? "projectAnchor" : null;
85064
+ }
85065
+ function instanceEdgeReceipts(sent, received, cloudIds) {
85066
+ const wireId = (id) => cloudIds.get(id) ?? id;
85067
+ const edgeKey = (e) => JSON.stringify([wireId(e.from), e.type, wireId(e.to)]);
85068
+ const groupKey = (source, kind) => JSON.stringify([wireId(source), kind]);
85069
+ const accepted = /* @__PURE__ */ new Map();
85070
+ const rejected = /* @__PURE__ */ new Set();
85071
+ for (const edge2 of received) {
85072
+ const key = edgeKey(edge2);
85073
+ if (edge2.decision === "rejected") rejected.add(key);
85074
+ else if (edge2.decision === "created" || edge2.decision === "reinforced") accepted.set(key, (accepted.get(key) ?? 0) + 1);
85075
+ }
85076
+ const groups = /* @__PURE__ */ new Map();
85077
+ for (const edge2 of sent) {
85078
+ const kind = edgeReceiptKind(edge2.type);
85079
+ if (!kind) continue;
85080
+ const group = groupKey(edge2.from, kind);
85081
+ const expected = groups.get(group) ?? /* @__PURE__ */ new Map();
85082
+ const key = edgeKey(edge2);
85083
+ expected.set(key, (expected.get(key) ?? 0) + 1);
85084
+ groups.set(group, expected);
85085
+ }
85086
+ const complete = new Set([...groups].filter(
85087
+ ([, expected]) => [...expected].every(([key, count]) => !rejected.has(key) && (accepted.get(key) ?? 0) >= count)
85088
+ ).map(([group]) => group));
85089
+ return { complete: (source, kind) => complete.has(groupKey(source, kind)) };
85090
+ }
85058
85091
  var FIELDS = ["contributedAtSeq", "cloudNodeId", "anchorsContributedDigest", "projectAnchorsContributedDigest", "semanticEdgesContributedDigest", "shipRefusedSinceSeq", "shipRefusedCount", "shipRefusedReason", "shipRefusedFingerprint"];
85059
85092
  function instanceDestinationKey(input) {
85060
85093
  return createHash18("sha256").update(JSON.stringify([
@@ -85099,6 +85132,7 @@ function acceptedInstanceReceipt(current, sent, decision, destination, mirrorLeg
85099
85132
  }
85100
85133
 
85101
85134
  // src/multi.ts
85135
+ init_src();
85102
85136
  init_dist();
85103
85137
  init_src5();
85104
85138
  import { existsSync as existsSync34, readFileSync as readFileSync36, unlinkSync as unlinkSync5, writeFileSync as writeFileSync26 } from "node:fs";
@@ -85480,8 +85514,8 @@ function internalSymbolsFor(description, lexiconHas, publicIndex) {
85480
85514
  // src/instance-ingest.ts
85481
85515
  init_generalize_graph();
85482
85516
  var INSTANCE_LABELS = ["Problem", "Vulnerability", "Solution", "RootCause"];
85483
- var INSTANCE_EDGES = ["CAUSED_BY", "SOLVED_BY"];
85484
- var ANCHOR_EDGES = ["OCCURS_IN", "DEPENDS_ON", "PERTAIN_TO", "CONCERNS"];
85517
+ var INSTANCE_EDGES = INSTANCE_SEMANTIC_EDGE_TYPES;
85518
+ var ANCHOR_EDGES = INSTANCE_ANCHOR_EDGE_TYPES;
85485
85519
  var ANCHOR_TARGET_LABELS = ["Language", "Package", "Domain", "Component"];
85486
85520
  function stripCodebaseScope(scope) {
85487
85521
  const s = { ...scope ?? {} };
@@ -87620,6 +87654,23 @@ function stageMs(value) {
87620
87654
  const ms = Number.parseInt(value, 10);
87621
87655
  return Number.isFinite(ms) ? ms : -1;
87622
87656
  }
87657
+ function unitDecisions(receipt) {
87658
+ const decisions = receipt.decisions ?? [];
87659
+ if (receipt.proposedAtoms === void 0 && decisions.length === 0) return "";
87660
+ const part = (kind, head2) => {
87661
+ const tally = /* @__PURE__ */ new Map();
87662
+ for (const d of decisions) if (d.kind === kind && d.verdict !== "accepted") {
87663
+ const key = `${d.verdict} ${d.reason}`;
87664
+ tally.set(key, (tally.get(key) ?? 0) + 1);
87665
+ }
87666
+ const why = [...tally].sort((a, b) => b[1] - a[1]).map(([key, n]) => {
87667
+ const [verdict, ...reason] = key.split(" ");
87668
+ return `${verdict} ${n} ${reason.join(" ")}`;
87669
+ });
87670
+ return `${head2}${why.length ? ` ${why.join(", ")}` : ""}`;
87671
+ };
87672
+ return ` [${part("atom", `atoms ${receipt.proposedAtoms ?? "?"}\u2192${receipt.acceptedAtoms ?? "?"}`)}; ${part("relation", `relations ${receipt.pairs}\u2192${receipt.keptPairs} pairs`)}]`;
87673
+ }
87623
87674
  function unitTiming(postStarted, prepMs, receipt, nowMs = Date.now()) {
87624
87675
  const s = (ms) => `${(ms / 1e3).toFixed(1)}s`;
87625
87676
  const parts2 = [`local ${s(prepMs)}`];
@@ -87897,7 +87948,7 @@ async function walk10(root, input, client, opts, readBlob) {
87897
87948
  }
87898
87949
  const packages = new Set(outcome.result.nodes.filter((n) => n.decision !== "rejected" && n.canonicalId.startsWith("pkg:")).map((n) => n.canonicalId)).size;
87899
87950
  counts = addCounts(counts, { commitsWalked: 1, changesExtracted: 1, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims, anchors: outcome.receipt.anchors, packages });
87900
- log(`[errata] history ${label}: ${outcome.result.nodes.length} nodes, ${outcome.result.edges.length} edges (${outcome.receipt.keptPairs} pairs, ${outcome.receipt.claims} claims)${unitTiming(started2, prepMs, outcome.receipt)}`);
87951
+ log(`[errata] history ${label}: ${outcome.result.nodes.length} nodes, ${outcome.result.edges.length} edges (${outcome.receipt.keptPairs} pairs, ${outcome.receipt.claims} claims)${unitDecisions(outcome.receipt)}${unitTiming(started2, prepMs, outcome.receipt)}`);
87901
87952
  break;
87902
87953
  }
87903
87954
  case "replayed": {
@@ -87908,7 +87959,7 @@ async function walk10(root, input, client, opts, readBlob) {
87908
87959
  case "empty":
87909
87960
  case "dry-run":
87910
87961
  counts = addCounts(counts, { commitsWalked: 1, changesExtracted: outcome.status === "dry-run" ? 1 : 0, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims });
87911
- log(`[errata] history ${label}: ${outcome.status} (${outcome.receipt.keptPairs} pairs, dropped ${outcome.receipt.droppedByEvidence} by evidence, ${outcome.receipt.droppedByAnchor} by anchor)${unitTiming(started2, prepMs, outcome.receipt)}`);
87962
+ log(`[errata] history ${label}: ${outcome.status} (${outcome.receipt.keptPairs} pairs, dropped ${outcome.receipt.droppedByEvidence} by evidence, ${outcome.receipt.droppedByAnchor} by anchor)${unitDecisions(outcome.receipt)}${unitTiming(started2, prepMs, outcome.receipt)}`);
87912
87963
  break;
87913
87964
  case "refused":
87914
87965
  profile = stage(profile, { state: "refused", lastError: `unit ${label} refused: ${outcome.reason}` }, now);
@@ -90343,7 +90394,20 @@ async function startMultiDaemon(opts = {}) {
90343
90394
  if (rn.decision === "rejected") rejected.set(rn.canonicalId, rn.reason ?? "no reason given");
90344
90395
  }
90345
90396
  const rejectedEdges = res.result.edges.filter((re) => re.decision === "rejected");
90346
- const edgeReceiptsComplete = rejectedEdges.length === 0 && res.result.edges.length === instances.edges.length;
90397
+ const cloudIds = /* @__PURE__ */ new Map();
90398
+ for (const node2 of res.result.nodes) {
90399
+ if (isMembraneSaltedId(node2.nodeId)) cloudIds.set(node2.canonicalId, node2.nodeId);
90400
+ }
90401
+ for (const localId of /* @__PURE__ */ new Set([
90402
+ ...Object.keys(instances.anchorDigests),
90403
+ ...Object.keys(instances.projectAnchorDigests),
90404
+ ...Object.keys(instances.semanticEdgeDigests)
90405
+ ])) {
90406
+ const owner = owningStore(localId);
90407
+ const cloudId = owner && instanceReceipt(owner.n, destinationKey)["cloudNodeId"];
90408
+ if (isMembraneSaltedId(cloudId)) cloudIds.set(localId, cloudId);
90409
+ }
90410
+ const edgeReceipts = instanceEdgeReceipts(instances.edges, res.result.edges, cloudIds);
90347
90411
  if (rejectedEdges.length > 0) {
90348
90412
  const byReason = /* @__PURE__ */ new Map();
90349
90413
  for (const re of rejectedEdges) {
@@ -90393,7 +90457,7 @@ async function startMultiDaemon(opts = {}) {
90393
90457
  await stampBatched(Object.entries(instances.anchorDigests), ([localId, dg]) => {
90394
90458
  const owner = owningStore(localId);
90395
90459
  if (!owner) return;
90396
- if (!edgeReceiptsComplete || !instanceReceipt(owner.n, destinationKey)["cloudNodeId"] || rejected.has(localId) || blocked.has(localId)) return;
90460
+ if (!edgeReceipts.complete(localId, "anchor") || !instanceReceipt(owner.n, destinationKey)["cloudNodeId"] || rejected.has(localId) || blocked.has(localId)) return;
90397
90461
  owner.s.updateNode(localId, {
90398
90462
  attrs: updateInstanceReceipt(owner.n, destinationKey, { anchorsContributedDigest: dg }, owner.s === store)
90399
90463
  });
@@ -90401,7 +90465,7 @@ async function startMultiDaemon(opts = {}) {
90401
90465
  await stampBatched(Object.entries(instances.projectAnchorDigests), ([localId, dg]) => {
90402
90466
  const owner = owningStore(localId);
90403
90467
  if (!owner) return;
90404
- if (!edgeReceiptsComplete || !instanceReceipt(owner.n, destinationKey)["cloudNodeId"] || rejected.has(localId) || blocked.has(localId)) return;
90468
+ if (!edgeReceipts.complete(localId, "projectAnchor") || !instanceReceipt(owner.n, destinationKey)["cloudNodeId"] || rejected.has(localId) || blocked.has(localId)) return;
90405
90469
  owner.s.updateNode(localId, {
90406
90470
  attrs: updateInstanceReceipt(owner.n, destinationKey, { projectAnchorsContributedDigest: dg }, owner.s === store)
90407
90471
  });
@@ -90409,7 +90473,7 @@ async function startMultiDaemon(opts = {}) {
90409
90473
  await stampBatched(Object.entries(instances.semanticEdgeDigests), ([localId, dg]) => {
90410
90474
  const owner = owningStore(localId);
90411
90475
  if (!owner) return;
90412
- if (!edgeReceiptsComplete || !instanceReceipt(owner.n, destinationKey)["cloudNodeId"] || rejected.has(localId) || blocked.has(localId)) return;
90476
+ if (!edgeReceipts.complete(localId, "semantic") || !instanceReceipt(owner.n, destinationKey)["cloudNodeId"] || rejected.has(localId) || blocked.has(localId)) return;
90413
90477
  owner.s.updateNode(localId, {
90414
90478
  attrs: updateInstanceReceipt(owner.n, destinationKey, { semanticEdgesContributedDigest: dg }, owner.s === store)
90415
90479
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.17-dev.3447",
3
+ "version": "2.0.17-dev.3459",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {