@inerrata-corporation/errata 2.0.8-dev.2956 → 2.0.8-dev.2973

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.
@@ -15351,7 +15351,7 @@ function anchorLabelAttrs(attrs) {
15351
15351
  ...typeof line === "number" && Number.isInteger(line) && line >= 1 && line <= 1e7 ? { labelLine: line } : {}
15352
15352
  };
15353
15353
  }
15354
- var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, FILE_ANCHOR_QNAME, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
15354
+ var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, FILE_ANCHOR_QNAME, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, TRIAGE_DISCRIMINATOR_MAX_LENGTH, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
15355
15355
  var init_wire = __esm({
15356
15356
  "../../packages/shared/src/wire.ts"() {
15357
15357
  "use strict";
@@ -15470,6 +15470,7 @@ var init_wire = __esm({
15470
15470
  FILE_ANCHOR_QNAME = "";
15471
15471
  ANCHOR_LABEL_PATH_RE = /^(?![/])(?![A-Za-z]:)(?!(?:.*\/)?\.\.(?:\/|$))[^\x00-\x1f\x7f\\`]{1,512}$/;
15472
15472
  ANCHOR_LABEL_QNAME_RE = /^[^\x00-\x1f\x7f`]{1,256}$/;
15473
+ TRIAGE_DISCRIMINATOR_MAX_LENGTH = 2e3;
15473
15474
  CastaliaIngestEdgeSchema = external_exports.object({
15474
15475
  fromCanonicalId: external_exports.string().min(6).max(160),
15475
15476
  toCanonicalId: external_exports.string().min(6).max(160),
@@ -15480,6 +15481,8 @@ var init_wire = __esm({
15480
15481
  /** Triage route per-context counts (T3 induction). Carried as structured data
15481
15482
  * here; stored JSON-encoded on the Neo4j rel (`perContextJson`). */
15482
15483
  perContext: external_exports.record(external_exports.string(), RouteContextCountWireSchema).optional(),
15484
+ /** Scrubbed diagnostic check for a triage route, re-scanned at the cloud door. */
15485
+ discriminator: external_exports.string().trim().min(1).max(TRIAGE_DISCRIMINATOR_MAX_LENGTH).optional(),
15483
15486
  /** PJ-anchor-version: WHICH version of a symbol an `ANCHORED_AT` was
15484
15487
  * witnessed against. Both opaque — the observing checkout's HEAD sha and
15485
15488
  * the indexer's 16-hex sha256 of the symbol body. Neither is reversible
package/errata.mjs CHANGED
@@ -15732,6 +15732,13 @@ function isSeedProvenance(source) {
15732
15732
  function isAnchorLabelKind(kind) {
15733
15733
  return typeof kind === "string" && ANCHOR_LABEL_KINDS.includes(kind);
15734
15734
  }
15735
+ function triageDiscriminatorAttrs(type, attrs) {
15736
+ if (!["CONFIRMS", "INDICATES", "ROUTES_TO"].includes(type)) return {};
15737
+ const value = attrs?.["discriminator"];
15738
+ if (typeof value !== "string") return {};
15739
+ const test = value.trim();
15740
+ return test && test.length <= TRIAGE_DISCRIMINATOR_MAX_LENGTH && !(test.startsWith("<") && test.endsWith(">")) ? { discriminator: test } : {};
15741
+ }
15735
15742
  function anchorVersionAttrs(attrs) {
15736
15743
  if (!attrs) return {};
15737
15744
  const commit = attrs["observedAtCommit"];
@@ -15792,7 +15799,7 @@ function summarizeIngestResult(r) {
15792
15799
  ...r.patternReconciliation ? { patternReconciliation: r.patternReconciliation } : {}
15793
15800
  };
15794
15801
  }
15795
- var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, QUARANTINE_EXTRACTION_SOURCE_PREFIX, MAX_NODES_PER_PAYLOAD, MAX_EDGES_PER_PAYLOAD, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, FILE_ANCHOR_QNAME, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, ANCHOR_LABEL_KEYS, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
15802
+ var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, QUARANTINE_EXTRACTION_SOURCE_PREFIX, MAX_NODES_PER_PAYLOAD, MAX_EDGES_PER_PAYLOAD, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, FILE_ANCHOR_QNAME, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, ANCHOR_LABEL_KEYS, TRIAGE_DISCRIMINATOR_MAX_LENGTH, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
15796
15803
  var init_wire = __esm({
15797
15804
  "../../packages/shared/src/wire.ts"() {
15798
15805
  "use strict";
@@ -15915,6 +15922,7 @@ var init_wire = __esm({
15915
15922
  ANCHOR_LABEL_PATH_RE = /^(?![/])(?![A-Za-z]:)(?!(?:.*\/)?\.\.(?:\/|$))[^\x00-\x1f\x7f\\`]{1,512}$/;
15916
15923
  ANCHOR_LABEL_QNAME_RE = /^[^\x00-\x1f\x7f`]{1,256}$/;
15917
15924
  ANCHOR_LABEL_KEYS = ["labelRelPath", "labelQname", "labelKind", "labelLine"];
15925
+ TRIAGE_DISCRIMINATOR_MAX_LENGTH = 2e3;
15918
15926
  CastaliaIngestEdgeSchema = external_exports.object({
15919
15927
  fromCanonicalId: external_exports.string().min(6).max(160),
15920
15928
  toCanonicalId: external_exports.string().min(6).max(160),
@@ -15925,6 +15933,8 @@ var init_wire = __esm({
15925
15933
  /** Triage route per-context counts (T3 induction). Carried as structured data
15926
15934
  * here; stored JSON-encoded on the Neo4j rel (`perContextJson`). */
15927
15935
  perContext: external_exports.record(external_exports.string(), RouteContextCountWireSchema).optional(),
15936
+ /** Scrubbed diagnostic check for a triage route, re-scanned at the cloud door. */
15937
+ discriminator: external_exports.string().trim().min(1).max(TRIAGE_DISCRIMINATOR_MAX_LENGTH).optional(),
15928
15938
  /** PJ-anchor-version: WHICH version of a symbol an `ANCHORED_AT` was
15929
15939
  * witnessed against. Both opaque — the observing checkout's HEAD sha and
15930
15940
  * the indexer's 16-hex sha256 of the symbol body. Neither is reversible
@@ -16827,6 +16837,7 @@ __export(src_exports, {
16827
16837
  TAXONOMY_EDGES: () => TAXONOMY_EDGES,
16828
16838
  TOOL_KINDS: () => TOOL_KINDS,
16829
16839
  TRANSFER_EDGES: () => TRANSFER_EDGES,
16840
+ TRIAGE_DISCRIMINATOR_MAX_LENGTH: () => TRIAGE_DISCRIMINATOR_MAX_LENGTH,
16830
16841
  TRIAGE_EDGES: () => TRIAGE_EDGES,
16831
16842
  TRUTH_KIND: () => TRUTH_KIND,
16832
16843
  UnregisteredGraphEventError: () => UnregisteredGraphEventError,
@@ -16910,6 +16921,7 @@ __export(src_exports, {
16910
16921
  summaryRejectionReason: () => summaryRejectionReason,
16911
16922
  toCloudAttrs: () => toCloudAttrs,
16912
16923
  toolCanonicalId: () => toolCanonicalId,
16924
+ triageDiscriminatorAttrs: () => triageDiscriminatorAttrs,
16913
16925
  unregisteredGraphEventKeys: () => unregisteredGraphEventKeys,
16914
16926
  validateCastaliaPayload: () => validateCastaliaPayload,
16915
16927
  versionlessPurl: () => versionlessPurl,
@@ -22620,7 +22632,8 @@ function pendingDiscriminators(l2, opts = {}) {
22620
22632
  const perContext = e.attrs["perContext"] ?? {};
22621
22633
  const global2 = perContext[TRIAGE_GLOBAL_BUCKET] ?? {};
22622
22634
  const observations = Number(global2.confirmed ?? 0);
22623
- const sources = new Set(global2.contributors ?? []).size;
22635
+ const inferred = new Set(global2.inferredContributors ?? []);
22636
+ const sources = new Set((global2.contributors ?? []).filter((id) => !inferred.has(id))).size;
22624
22637
  if (sources < minSources || observations < minObservations) continue;
22625
22638
  out2.push({ route: e.id, presenting: triage.description, cause: "", sources, observations, causeId: e.to });
22626
22639
  }
@@ -22638,7 +22651,7 @@ function markDiscriminatorAsked(l2, routeIds, ts) {
22638
22651
  }
22639
22652
  }
22640
22653
  function promoteRouteWithDiscriminator(l2, routeId, discriminator, ts, source) {
22641
- const test = discriminator.trim();
22654
+ const test = triageDiscriminatorAttrs("CONFIRMS", { discriminator }).discriminator;
22642
22655
  if (!test) return false;
22643
22656
  if (isUnfilledPlaceholder(test)) return false;
22644
22657
  const existing = l2.getEdge(routeId);
@@ -22740,9 +22753,12 @@ function parseTriageFences(text) {
22740
22753
  return out2;
22741
22754
  }
22742
22755
  function harvestTriageFences(l2, text, opts) {
22756
+ const seen = [...text.matchAll(/```errata-triage[^\n]*\n([\s\S]*?)```/g)].length;
22743
22757
  let recorded = 0;
22744
22758
  let promoted = 0;
22745
22759
  for (const f of parseTriageFences(text)) {
22760
+ if ([f.presenting, f.cause, f.test, f.fix, f.route].some((value) => value && isUnfilledPlaceholder(value))) continue;
22761
+ if (f.test && !triageDiscriminatorAttrs("CONFIRMS", { discriminator: f.test }).discriminator) continue;
22746
22762
  if (f.route && f.test) {
22747
22763
  if (promoteRouteWithDiscriminator(l2, f.route.trim(), f.test, opts.ts, opts.contributor)) promoted++;
22748
22764
  continue;
@@ -22778,7 +22794,7 @@ function harvestTriageFences(l2, text, opts) {
22778
22794
  }
22779
22795
  recorded++;
22780
22796
  }
22781
- return { recorded, promoted };
22797
+ return { seen, recorded, promoted, rejected: seen - recorded - promoted };
22782
22798
  }
22783
22799
  var COOCCUR_BONUS, routeEdgeId, ROUTE_EDGE_TYPES, routeTypeFor, isRouterRoute, INDUCTED_MARK, DRIFT_VALUES;
22784
22800
  var init_triage2 = __esm({
@@ -24396,7 +24412,7 @@ function renderSnapshot(s) {
24396
24412
  lines.push("");
24397
24413
  lines.push("### \u270D\uFE0F CAPTURE PROTOCOL \u2014 tags are the record");
24398
24414
  lines.push(
24399
- "errata records ONLY inline tags: `[!one line]` for every problem you state, `(fix:[id])` when your edit fixed a shown problem, and to JUDGE a prior shown below \u2014 `(confirm:[id])` if it held, `(refute:[id] why)` if it's wrong or didn't hold. Untagged prose is silently lost \u2014 tag as you write (no fences), we filter downstream."
24415
+ "For problems and fixes, errata records inline tags: `[!one line]` for every problem you state, `(fix:[id])` when your edit fixed a shown problem, and to JUDGE a prior shown below \u2014 `(confirm:[id])` if it held, `(refute:[id] why)` if it's wrong or didn't hold. Untagged prose is silently lost \u2014 tag as you write. Requested errata-* answer blocks keep their fences; put them in your turn-final reply."
24400
24416
  );
24401
24417
  lines.push("");
24402
24418
  lines.push(SEARCH_IMPERATIVE_HEADER);
@@ -24682,7 +24698,7 @@ function renderSnapshot(s) {
24682
24698
  for (const item of reviewItems) {
24683
24699
  if (item.kind === "discriminator") {
24684
24700
  lines.push(
24685
- `- **A recurring diagnosis is one cheap check from promoting** \u2014 "${item.presenting}" usually turns out to be: ${item.cause}. If (and only if) you KNOW a cheap ante-hoc check that confirms it, answer in your reply:`
24701
+ `- **A recurring diagnosis is one cheap check from promoting** \u2014 "${item.presenting}" usually turns out to be: ${item.cause}. If (and only if) you KNOW a cheap ante-hoc check that confirms it, fill this fenced block in your turn-final reply:`
24686
24702
  );
24687
24703
  lines.push(" ```errata-triage");
24688
24704
  lines.push(` route: ${item.route}`);
@@ -24690,7 +24706,7 @@ function renderSnapshot(s) {
24690
24706
  lines.push(" ```");
24691
24707
  } else {
24692
24708
  lines.push(
24693
- `- **Name the principle this cluster of your beliefs generalizes** \u2014 it ships to the collective only once named, and the prose must cover ALL members in one sentence:`
24709
+ `- **Name the principle this cluster of your beliefs generalizes** \u2014 it ships to the collective only once named. Cover ALL members in one sentence; fill this fenced block in your turn-final reply:`
24694
24710
  );
24695
24711
  for (const m of item.members) lines.push(` - ${m.description}`);
24696
24712
  lines.push(" ```errata-abstraction");
@@ -25196,6 +25212,7 @@ function toWirePayload(batch, runId) {
25196
25212
  attrs: {
25197
25213
  ...typeof e.confidence === "number" ? { confidence: clamp012(e.confidence) } : {},
25198
25214
  ...perContext ? { perContext } : {},
25215
+ ...triageDiscriminatorAttrs(e.type, e.attrs),
25199
25216
  // PJ-anchor-version: the two opaque version stamps ride on anchors only.
25200
25217
  ...e.type === "ANCHORED_AT" ? anchorVersionAttrs(e.attrs) : {},
25201
25218
  // PJ-anchor-labels: readable labels ride only when the producer set the
@@ -25802,6 +25819,7 @@ var init_client = __esm({
25802
25819
  if (q.seed?.length) qs.set("seed", q.seed.join(","));
25803
25820
  if (q.q) qs.set("q", q.q);
25804
25821
  if (q.channel) qs.set("channel", q.channel);
25822
+ if (q.includeTriage) qs.set("includeTriage", "true");
25805
25823
  const publicCtx = process.env["ERRATA_PRIMING_PUBLIC_CONTEXT"];
25806
25824
  const usePublicCtx = Boolean(publicCtx && publicCtx !== "0" && q.channel === "priming");
25807
25825
  const UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -29016,7 +29034,7 @@ function buildAgentInstruction(opts = {}) {
29016
29034
  const signals = opts.signals ?? ["prior", "problem", "domain", "fix", "constraint", "triage", "attempt", "link"];
29017
29035
  const ref = opts.referent ?? "its-handle";
29018
29036
  const token = (s) => s === "problem" ? TAG_EXAMPLE.problem() : s === "constraint" ? TAG_EXAMPLE.constraint() : s === "attempt" ? TAG_EXAMPLE.tried() : s === "domain" ? TAG_EXAMPLE.domain() : s === "link" ? TAG_EXAMPLE.pattern() : s === "verdict" ? TAG_EXAMPLE.confirm(ref) : TAG_EXAMPLE[s](ref);
29019
- const head2 = `We tag the priors we show you with a short handle like [${opts.handleExample ?? "chokidar-glob"}]. Tags are the ONLY signal recorded \u2014 anything you state but don't tag is silently lost. Weave each tag inline in your prose as you state it (no fences or backticks, no extra calls); tag everything, we filter downstream:`;
29037
+ const head2 = `We tag the priors we show you with a short handle like [${opts.handleExample ?? "chokidar-glob"}]. Untagged prose is silently lost. Put each tag inline in prose (no fences or backticks). Requested errata-* answer blocks are the exception: keep their fences in your turn-final reply. Tag everything, we filter downstream:`;
29020
29038
  const tail = "Mid-turn text (between tool calls) can be dropped by the harness \u2014 RESTATE every tag in your turn-final message; the final message is what reliably survives \u2014 EXCEPT one already shown above with an id: that is captured, so cite `[its-handle]` rather than retyping it (drift mints a duplicate).";
29021
29039
  return [
29022
29040
  head2,
@@ -41900,7 +41918,7 @@ function takeDiscriminatorNudge(path2) {
41900
41918
  return [
41901
41919
  `\u26A1 errata \u2014 a known wrong-door is one field from ranking: "${top.presenting.slice(0, 90)}"`,
41902
41920
  ` usually turns out to be: ${top.cause.slice(0, 90)} (seen ${top.observations}x)`,
41903
- " Know a CHEAP check that confirms it? Answer in-flow \u2014 it promotes the route so the",
41921
+ " Know a CHEAP check that confirms it? Fill this fenced block in your turn-final reply so the",
41904
41922
  " next agent gets it first. Only if you actually know one: a guessed test ranks first",
41905
41923
  " and misroutes everyone after you.",
41906
41924
  " ```errata-triage",
@@ -43417,7 +43435,7 @@ var init_mcp = __esm({
43417
43435
  pending,
43418
43436
  ...pending.length > 0 ? {
43419
43437
  howToAnswer: [
43420
- "For each route you know a cheap test for, emit an errata-triage fence",
43438
+ "For each route you know a cheap test for, emit an errata-triage fence in your turn-final reply",
43421
43439
  "carrying its `route` id and the `test` \u2014 no presenting/cause needed, the",
43422
43440
  "route id identifies both endpoints. Attaching a test does NOT count as",
43423
43441
  "another sighting, so it cannot inflate the route's evidence.",
@@ -74572,6 +74590,7 @@ function readCodexRolloutCwd(path2) {
74572
74590
  }
74573
74591
  }
74574
74592
  }
74593
+ var codexRolloutActivity = /* @__PURE__ */ new Map();
74575
74594
  function codexRolloutsForCwd(cwd, opts = {}) {
74576
74595
  const sinceMs = opts.sinceMs ?? 0;
74577
74596
  const limit = opts.limit ?? 25;
@@ -74579,7 +74598,14 @@ function codexRolloutsForCwd(cwd, opts = {}) {
74579
74598
  const owner = checkoutRootOf(cwd);
74580
74599
  const owners = /* @__PURE__ */ new Map();
74581
74600
  for (const root of codexSessionRoots(opts.env, opts.home)) {
74582
- if (!existsSync16(root)) continue;
74601
+ if (!existsSync16(root)) {
74602
+ codexRolloutActivity.delete(root);
74603
+ continue;
74604
+ }
74605
+ const activity = codexRolloutActivity.get(root) ?? /* @__PURE__ */ new Map();
74606
+ codexRolloutActivity.set(root, activity);
74607
+ const observed = /* @__PURE__ */ new Set();
74608
+ const scannedAt = Date.now();
74583
74609
  const stack = [{ dir: root, depth: 0 }];
74584
74610
  while (stack.length > 0) {
74585
74611
  const { dir, depth } = stack.pop();
@@ -74603,7 +74629,15 @@ function codexRolloutsForCwd(cwd, opts = {}) {
74603
74629
  }
74604
74630
  if (depth < 3) continue;
74605
74631
  if (!name2.startsWith("rollout-") || !name2.endsWith(".jsonl")) continue;
74606
- if (st.mtimeMs < sinceMs) continue;
74632
+ observed.add(full);
74633
+ const previous = activity.get(full);
74634
+ const activityAtMs = Math.max(
74635
+ st.mtimeMs,
74636
+ previous?.activeAt ?? 0,
74637
+ previous && previous.size !== st.size ? scannedAt : 0
74638
+ );
74639
+ activity.set(full, { size: st.size, activeAt: activityAtMs });
74640
+ if (activityAtMs < sinceMs) continue;
74607
74641
  const sessionCwd = readCodexRolloutCwd(full);
74608
74642
  if (sessionCwd === null) continue;
74609
74643
  let sessionOwner = owners.get(sessionCwd);
@@ -74612,11 +74646,12 @@ function codexRolloutsForCwd(cwd, opts = {}) {
74612
74646
  owners.set(sessionCwd, sessionOwner);
74613
74647
  }
74614
74648
  if (sessionOwner !== owner) continue;
74615
- out2.push({ path: full, sessionId: `codex:${basename5(name2, ".jsonl")}`, mtimeMs: st.mtimeMs });
74649
+ out2.push({ path: full, sessionId: `codex:${basename5(name2, ".jsonl")}`, mtimeMs: st.mtimeMs, activityAtMs });
74616
74650
  }
74617
74651
  }
74652
+ for (const path2 of activity.keys()) if (!observed.has(path2)) activity.delete(path2);
74618
74653
  }
74619
- out2.sort((a, b) => b.mtimeMs - a.mtimeMs);
74654
+ out2.sort((a, b) => (b.activityAtMs ?? b.mtimeMs) - (a.activityAtMs ?? a.mtimeMs));
74620
74655
  return out2.slice(0, limit);
74621
74656
  }
74622
74657
  function geminiSessionRoots(env2 = process.env, home = homedir4()) {
@@ -76967,21 +77002,31 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
76967
77002
  stack: profile.stack,
76968
77003
  domains: profile.domains,
76969
77004
  kinds: ["Problem"],
77005
+ includeTriage: true,
76970
77006
  limit
76971
77007
  });
76972
77008
  const byId = new Map(res.nodes.map((n) => [n.id, n]));
76973
77009
  const now = Date.now();
76974
77010
  let merged = 0;
77011
+ const landedTriages = /* @__PURE__ */ new Set();
76975
77012
  const landNode = (id) => {
76976
- if (shared.getNode(id)) return true;
77013
+ const existing = shared.getNode(id);
76977
77014
  const n = byId.get(id);
77015
+ if (existing) {
77016
+ if (n && existing.attrs["source"] === "cloud") {
77017
+ shared.updateNode(id, { attrs: { ...existing.attrs, ...n.attrs, source: "cloud" }, lastUpdatedAt: now });
77018
+ }
77019
+ return true;
77020
+ }
76978
77021
  if (!n) return false;
76979
77022
  shared.mergeNode({ ...n, extractionSource: "bko-inferred", embedding: [], attrs: { ...n.attrs, source: "cloud" } });
76980
77023
  return true;
76981
77024
  };
76982
77025
  for (const edge2 of res.edges) {
76983
77026
  if (edge2.type !== "CONFIRMS" && edge2.type !== "ROUTES_TO") continue;
77027
+ if (!triageDiscriminatorAttrs(edge2.type, edge2.attrs).discriminator) continue;
76984
77028
  if (!landNode(edge2.from) || !landNode(edge2.to)) continue;
77029
+ landedTriages.add(edge2.from);
76985
77030
  const cloudAttrs = { ...edge2.attrs, source: "cloud", provisional: false };
76986
77031
  const existing = shared.getEdge(edge2.id);
76987
77032
  if (existing && existing.type === "CONFIRMS") {
@@ -76992,6 +77037,11 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
76992
77037
  }
76993
77038
  merged++;
76994
77039
  }
77040
+ for (const edge2 of res.edges) {
77041
+ if (edge2.type !== "TRIAGED_BY" || !landedTriages.has(edge2.to)) continue;
77042
+ if (!landNode(edge2.from)) continue;
77043
+ shared.mergeEdge({ ...edge2, attrs: { ...edge2.attrs, source: "cloud" } });
77044
+ }
76995
77045
  return merged;
76996
77046
  }
76997
77047
 
@@ -80288,7 +80338,7 @@ function createWatchBreaker(deps) {
80288
80338
  }
80289
80339
 
80290
80340
  // src/engine.ts
80291
- var DAEMON_VERSION = true ? "2.0.8-dev.2956" : "2.0.0-alpha.0";
80341
+ var DAEMON_VERSION = true ? "2.0.8-dev.2973" : "2.0.0-alpha.0";
80292
80342
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
80293
80343
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
80294
80344
  var GIT_OP_MUTE_MS = 4e3;
@@ -81174,6 +81224,9 @@ function createWorkspaceEngine(opts) {
81174
81224
  let resolved = 0;
81175
81225
  let abstracted = 0;
81176
81226
  let triaged = 0;
81227
+ let triageFencesSeen = 0;
81228
+ let triagePromoted = 0;
81229
+ let triageFencesRejected = 0;
81177
81230
  let priorEdges = 0;
81178
81231
  let exposureShown = 0;
81179
81232
  let exposureEvicted = 0;
@@ -81237,11 +81290,16 @@ function createWorkspaceEngine(opts) {
81237
81290
  console.warn("[errata] abstraction harvest failed:", err2);
81238
81291
  }
81239
81292
  try {
81240
- triaged += harvestTriageFences(opts.sharedStore, turn.text, {
81293
+ const triage = harvestTriageFences(opts.sharedStore, turn.text, {
81241
81294
  context: { stack: profile.stack, domain: profile.domains[0] },
81242
81295
  contributor: sessionId,
81243
81296
  ts: t
81244
- }).recorded;
81297
+ });
81298
+ triaged += triage.recorded;
81299
+ triageFencesSeen += triage.seen;
81300
+ triagePromoted += triage.promoted;
81301
+ triageFencesRejected += triage.rejected;
81302
+ if (triage.recorded > 0 || triage.promoted > 0) contextDirty = true;
81245
81303
  } catch (err2) {
81246
81304
  console.warn("[errata] triage harvest failed:", err2);
81247
81305
  }
@@ -81917,8 +81975,8 @@ function createWorkspaceEngine(opts) {
81917
81975
  if (abstracted > 0) {
81918
81976
  console.log(`[errata] abstraction: ${abstracted} principle(s) distilled from the conversation`);
81919
81977
  }
81920
- if (triaged > 0) {
81921
- console.log(`[errata] triage: ${triaged} wrong-door(s) captured from the conversation`);
81978
+ if (triaged > 0 || triagePromoted > 0 || triageFencesRejected > 0) {
81979
+ console.log(`[errata] triage: ${triaged} diagnosis(es), ${triagePromoted} route promotion(s), ${triageFencesRejected} rejected fence(s)`);
81922
81980
  }
81923
81981
  if (processedTurns > 0) {
81924
81982
  appendPassLedger(paths.configDir, "capture", Date.now() - t, {
@@ -81933,6 +81991,9 @@ function createWorkspaceEngine(opts) {
81933
81991
  tagsRestated,
81934
81992
  resolved,
81935
81993
  triaged,
81994
+ triageFencesSeen,
81995
+ triagePromoted,
81996
+ triageFencesRejected,
81936
81997
  priorEdges,
81937
81998
  corroboratedEdges,
81938
81999
  // RG-mark: refute witnesses stamped onto local nodes (the local half of
@@ -82135,6 +82196,7 @@ function createWorkspaceEngine(opts) {
82135
82196
  for (const ref of refs) {
82136
82197
  await yieldToLoop();
82137
82198
  await harvestSession(ref.sessionId, ref.path);
82199
+ lastActivityTs = Math.max(lastActivityTs, ref.activityAtMs ?? ref.mtimeMs);
82138
82200
  }
82139
82201
  } catch {
82140
82202
  }
@@ -88494,7 +88556,7 @@ function buildCodexHooksToml(port, options) {
88494
88556
  if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid hook port");
88495
88557
  const command = quote(options.nodePath) + " " + quote(options.relayPath) + " " + port;
88496
88558
  const handlers = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "Stop"].map(
88497
- (event) => "[[hooks." + event + "]]\n" + (["UserPromptSubmit", "Stop"].includes(event) ? "" : 'matcher = ".*"\n') + "\n[[hooks." + event + '.hooks]]\ntype = "command"\ncommand = ' + JSON.stringify(command) + "\ntimeout = 10\nadditionalContextLimit = 5000\n"
88559
+ (event) => "[[hooks." + event + "]]\n" + (["UserPromptSubmit", "Stop"].includes(event) ? "" : 'matcher = ".*"\n') + "\n[[hooks." + event + '.hooks]]\ntype = "command"\ncommand = ' + JSON.stringify(command) + "\ntimeout = 10\n" + (event === "Stop" ? "" : "additionalContextLimit = 5000\n")
88498
88560
  );
88499
88561
  return CODEX_HOOKS_BEGIN + "\n" + handlers.join("\n") + CODEX_HOOKS_END + "\n";
88500
88562
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.8-dev.2956",
3
+ "version": "2.0.8-dev.2973",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/pass-worker.mjs CHANGED
@@ -15140,7 +15140,7 @@ var init_symbol_intent = __esm({
15140
15140
  });
15141
15141
 
15142
15142
  // ../../packages/shared/src/wire.ts
15143
- var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
15143
+ var CLOUD_NODE_LABELS, CLOUD_WRITABLE_NODE_LABELS, PROJECT_ONLY_NODE_LABELS, PROJECT_ONLY_NODE_LABEL_SET, PROJECT_ONLY_EDGE_TYPES, PROJECT_ONLY_EDGE_TYPE_SET, CLOUD_WRITABLE_NODE_LABEL_SET, CLOUD_EDGE_TYPES, INGEST_SOURCES, INGEST_EXTRACTION_SOURCES, CastaliaIngestNodeSchema, RouteContextCountWireSchema, ANCHOR_COMMIT_SHA_RE, ANCHOR_BODY_HASH_RE, ANCHOR_SYMBOL_KINDS, ANCHOR_LABEL_KINDS, ANCHOR_LABEL_PATH_RE, ANCHOR_LABEL_QNAME_RE, TRIAGE_DISCRIMINATOR_MAX_LENGTH, CastaliaIngestEdgeSchema, SymbolSummarySidecarSchema, CastaliaIngestPayloadSchema;
15144
15144
  var init_wire = __esm({
15145
15145
  "../../packages/shared/src/wire.ts"() {
15146
15146
  "use strict";
@@ -15258,6 +15258,7 @@ var init_wire = __esm({
15258
15258
  ANCHOR_LABEL_KINDS = [...ANCHOR_SYMBOL_KINDS, "File"];
15259
15259
  ANCHOR_LABEL_PATH_RE = /^(?![/])(?![A-Za-z]:)(?!(?:.*\/)?\.\.(?:\/|$))[^\x00-\x1f\x7f\\`]{1,512}$/;
15260
15260
  ANCHOR_LABEL_QNAME_RE = /^[^\x00-\x1f\x7f`]{1,256}$/;
15261
+ TRIAGE_DISCRIMINATOR_MAX_LENGTH = 2e3;
15261
15262
  CastaliaIngestEdgeSchema = external_exports.object({
15262
15263
  fromCanonicalId: external_exports.string().min(6).max(160),
15263
15264
  toCanonicalId: external_exports.string().min(6).max(160),
@@ -15268,6 +15269,8 @@ var init_wire = __esm({
15268
15269
  /** Triage route per-context counts (T3 induction). Carried as structured data
15269
15270
  * here; stored JSON-encoded on the Neo4j rel (`perContextJson`). */
15270
15271
  perContext: external_exports.record(external_exports.string(), RouteContextCountWireSchema).optional(),
15272
+ /** Scrubbed diagnostic check for a triage route, re-scanned at the cloud door. */
15273
+ discriminator: external_exports.string().trim().min(1).max(TRIAGE_DISCRIMINATOR_MAX_LENGTH).optional(),
15271
15274
  /** PJ-anchor-version: WHICH version of a symbol an `ANCHORED_AT` was
15272
15275
  * witnessed against. Both opaque — the observing checkout's HEAD sha and
15273
15276
  * the indexer's 16-hex sha256 of the symbol body. Neither is reversible