@inerrata-corporation/errata 2.0.13-dev.2998 → 2.0.13-dev.3054

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.13-dev.2998",
3
+ "version": "2.0.13-dev.3054",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
package/pass-worker.mjs CHANGED
@@ -15017,6 +15017,79 @@ var init_zod = __esm({
15017
15017
  }
15018
15018
  });
15019
15019
 
15020
+ // ../../packages/shared/src/history-text.ts
15021
+ var init_history_text = __esm({
15022
+ "../../packages/shared/src/history-text.ts"() {
15023
+ "use strict";
15024
+ }
15025
+ });
15026
+
15027
+ // ../../packages/shared/src/history-evidence.ts
15028
+ var HistoryAnchorSourceSchema, HistorySymbolAnchorSchema, HistoryEvidenceSelectionSchema, HistoryCandidateSchema, HistoryRelationCandidateSchema, HistoryCandidateBatchSchema, HistoryEvidenceRefSchema;
15029
+ var init_history_evidence = __esm({
15030
+ "../../packages/shared/src/history-evidence.ts"() {
15031
+ "use strict";
15032
+ init_zod();
15033
+ init_history_text();
15034
+ HistoryAnchorSourceSchema = external_exports.strictObject({
15035
+ sourceCommitSha: external_exports.string().regex(/^[a-f0-9]{40,64}$/),
15036
+ commitSha: external_exports.string().regex(/^[a-f0-9]{40,64}$/),
15037
+ side: external_exports.enum(["before", "after"]),
15038
+ blockDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
15039
+ startByte: external_exports.number().int().nonnegative(),
15040
+ endByte: external_exports.number().int().positive(),
15041
+ bodyHash: external_exports.string().regex(/^[a-f0-9]{8,64}$/).optional()
15042
+ }).refine((v) => v.endByte > v.startByte);
15043
+ HistorySymbolAnchorSchema = external_exports.object({
15044
+ symbolId: external_exports.string().regex(/^sym_[a-f0-9]{8,64}$/),
15045
+ kind: external_exports.string().max(40),
15046
+ /** Legacy association, never a source-revision or live validation. */
15047
+ contentHash: external_exports.string().regex(/^[a-f0-9]{8,64}$/).optional(),
15048
+ historical: HistoryAnchorSourceSchema.optional()
15049
+ });
15050
+ HistoryEvidenceSelectionSchema = external_exports.strictObject({
15051
+ blockId: external_exports.string().min(1).max(80),
15052
+ quote: external_exports.string().min(3).max(1600),
15053
+ supports: external_exports.enum(["statement", "condition", "rationale", "relation"]),
15054
+ conditionIndex: external_exports.number().int().min(0).max(7).nullable(),
15055
+ /** Optional exact location disambiguates repeated source lines. */
15056
+ startByte: external_exports.number().int().nonnegative().optional()
15057
+ });
15058
+ HistoryCandidateSchema = external_exports.strictObject({
15059
+ tempId: external_exports.string().regex(/^a[0-9]{1,3}$/),
15060
+ label: external_exports.enum(["Problem", "Solution", "RootCause", "Claim"]),
15061
+ statement: external_exports.string().min(10).max(2e3),
15062
+ claimKind: external_exports.enum(["snapshot", "decision", "constraint"]).nullable(),
15063
+ qualifier: external_exports.enum(["instance", "project"]),
15064
+ conditions: external_exports.array(external_exports.string().min(1).max(300)).max(8),
15065
+ rationale: external_exports.string().min(1).max(1e3).nullable(),
15066
+ evidence: external_exports.array(HistoryEvidenceSelectionSchema).min(1).max(12),
15067
+ anchorTokens: external_exports.array(external_exports.string().regex(/^p[0-9]+$/)).max(8)
15068
+ });
15069
+ HistoryRelationCandidateSchema = external_exports.strictObject({
15070
+ tempId: external_exports.string().regex(/^r[0-9]{1,3}$/),
15071
+ fromTempId: external_exports.string().regex(/^a[0-9]{1,3}$/),
15072
+ toTempId: external_exports.string().regex(/^a[0-9]{1,3}$/),
15073
+ meaning: external_exports.enum(["resolves", "mitigates", "caused-by"]),
15074
+ evidence: external_exports.array(HistoryEvidenceSelectionSchema).min(1).max(8)
15075
+ });
15076
+ HistoryCandidateBatchSchema = external_exports.strictObject({
15077
+ atoms: external_exports.array(HistoryCandidateSchema).max(32),
15078
+ relations: external_exports.array(HistoryRelationCandidateSchema).max(32)
15079
+ });
15080
+ HistoryEvidenceRefSchema = HistoryEvidenceSelectionSchema.extend({
15081
+ blockDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
15082
+ startByte: external_exports.number().int().nonnegative(),
15083
+ endByte: external_exports.number().int().nonnegative(),
15084
+ sourceKind: external_exports.enum(["narrative", "diff"]),
15085
+ commitSha: external_exports.string().regex(/^[a-f0-9]{40,64}$/).nullable(),
15086
+ pathToken: external_exports.string().regex(/^p[0-9]+$/).nullable(),
15087
+ scrubberVersion: external_exports.string().max(80),
15088
+ side: external_exports.enum(["before", "after", "context", "mixed", "narrative"])
15089
+ });
15090
+ }
15091
+ });
15092
+
15020
15093
  // ../../packages/shared/src/edge-rules.ts
15021
15094
  function isValidEdge(from, type, to) {
15022
15095
  const rule = EDGE_RULES[type];
@@ -15055,7 +15128,9 @@ var init_edge_rules = __esm({
15055
15128
  // ── Security spine (v1 taxonomy.ts SECURITY_FORWARD_ONLY commentary) ──
15056
15129
  TARGETS: { from: ["Exploit"], to: ["Vulnerability"] },
15057
15130
  ENABLES: { from: ["AntiPattern"], to: ["Vulnerability"] },
15058
- MITIGATES: { from: ["Solution"], to: ["Vulnerability"] },
15131
+ // Partial remedies also apply to project Problems/RootCauses. Direction stays
15132
+ // remedy -> ailment; a mitigation must never claim complete SOLVED_BY status.
15133
+ MITIGATES: { from: ["Solution"], to: ["Vulnerability", "Problem", "RootCause"] },
15059
15134
  PRESENTS: { from: ["Solution"], to: ["Problem", "Vulnerability"] },
15060
15135
  // SOLVED_BY sources: Vulnerability (v1 comment) + Problem/RootCause
15061
15136
  // (upstream design-problem.ts + triage.ts mint both).
@@ -15145,6 +15220,7 @@ var init_wire = __esm({
15145
15220
  "../../packages/shared/src/wire.ts"() {
15146
15221
  "use strict";
15147
15222
  init_zod();
15223
+ init_history_evidence();
15148
15224
  init_castalia();
15149
15225
  init_edge_rules();
15150
15226
  init_symbol_intent();
@@ -15266,6 +15342,12 @@ var init_wire = __esm({
15266
15342
  attrs: external_exports.object({
15267
15343
  confidence: external_exports.number().min(0).max(1).optional(),
15268
15344
  extractedBy: external_exports.enum(INGEST_EXTRACTION_SOURCES).optional(),
15345
+ sourceSupport: external_exports.literal("supported").optional(),
15346
+ historicalAnchors: external_exports.array(HistoryAnchorSourceSchema).max(160).optional(),
15347
+ evidence: external_exports.array(HistoryEvidenceRefSchema).max(12).optional(),
15348
+ verificationEvidence: external_exports.array(HistoryEvidenceRefSchema).max(12).optional(),
15349
+ verifierBuild: external_exports.string().max(80).optional(),
15350
+ unitDigest: external_exports.string().regex(/^[a-f0-9]{64}$/).optional(),
15269
15351
  /** Triage route per-context counts (T3 induction). Carried as structured data
15270
15352
  * here; stored JSON-encoded on the Neo4j rel (`perContextJson`). */
15271
15353
  perContext: external_exports.record(external_exports.string(), RouteContextCountWireSchema).optional(),
@@ -15362,6 +15444,84 @@ var init_manifests = __esm({
15362
15444
  }
15363
15445
  });
15364
15446
 
15447
+ // ../../packages/shared/src/history-quality.ts
15448
+ var init_history_quality = __esm({
15449
+ "../../packages/shared/src/history-quality.ts"() {
15450
+ "use strict";
15451
+ }
15452
+ });
15453
+
15454
+ // ../../packages/shared/src/history-read.ts
15455
+ function unpackHistoryAttrs(attrs = {}) {
15456
+ let nested = {};
15457
+ if (typeof attrs["attrsJson"] === "string") {
15458
+ try {
15459
+ const parsed = JSON.parse(attrs["attrsJson"]);
15460
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) nested = parsed;
15461
+ } catch {
15462
+ }
15463
+ }
15464
+ return { ...nested, ...attrs };
15465
+ }
15466
+ function historyReadPolicy(node, options = {}) {
15467
+ const attrs = unpackHistoryAttrs(node.attrs);
15468
+ if (attrs["source"] === "cloud" && typeof attrs["extractionSource"] !== "string" && attrs["historyQuality"] == null) {
15469
+ return { allow: options.mode !== "passive", history: false, notice: "Cloud provenance is missing; refresh this cached result before using it as a standing prior." };
15470
+ }
15471
+ const isHistory = node.extractionSource === "history-mined" || attrs["extractionSource"] === "history-mined" || attrs["historyQuality"] != null;
15472
+ if (!isHistory) return { allow: true, history: false, notice: null };
15473
+ const raw = attrs["historyQuality"];
15474
+ const q = raw && typeof raw === "object" ? raw : {};
15475
+ const source = q["sourceSupport"] ?? "unreviewed";
15476
+ const applicability = q["applicability"] ?? "unknown";
15477
+ const current = options.atCommit !== void 0 && q["evaluatedAtCommit"] === options.atCommit;
15478
+ const invalid = source === "contradicted" || source === "quarantined";
15479
+ const passive = options.mode === "passive";
15480
+ const validation = node.validationSource ?? attrs["validationSource"];
15481
+ const independentlyValidated = validation === "human-explicit" || validation === "human-implicit" || validation === "agent-observed";
15482
+ const allow = !invalid && (!passive || source === "supported" && current && applicability === "applicable" && independentlyValidated);
15483
+ const at = typeof attrs["commitSha"] === "string" ? ` at ${attrs["commitSha"].slice(0, 12)}` : "";
15484
+ return {
15485
+ allow,
15486
+ history: true,
15487
+ notice: `History-derived${at}; source ${String(source)}; applicability ${current ? String(applicability) : "unknown at this checkout"}; ${independentlyValidated ? "separate validation recorded" : "not independently validated"}.`
15488
+ };
15489
+ }
15490
+ var init_history_read = __esm({
15491
+ "../../packages/shared/src/history-read.ts"() {
15492
+ "use strict";
15493
+ }
15494
+ });
15495
+
15496
+ // ../../packages/shared/src/history-temporal.ts
15497
+ var init_history_temporal = __esm({
15498
+ "../../packages/shared/src/history-temporal.ts"() {
15499
+ "use strict";
15500
+ }
15501
+ });
15502
+
15503
+ // ../../packages/shared/src/history-revision.ts
15504
+ var Sha, HistoryRevisionRequestSchema;
15505
+ var init_history_revision = __esm({
15506
+ "../../packages/shared/src/history-revision.ts"() {
15507
+ "use strict";
15508
+ init_zod();
15509
+ init_hash();
15510
+ init_history_evidence();
15511
+ Sha = external_exports.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/);
15512
+ HistoryRevisionRequestSchema = external_exports.strictObject({
15513
+ atCommit: Sha,
15514
+ parents: external_exports.array(external_exports.strictObject({ commit: Sha, parents: external_exports.array(Sha).max(32) })).max(8192),
15515
+ observations: external_exports.array(external_exports.strictObject({
15516
+ occurrenceId: external_exports.string().min(1).max(100),
15517
+ symbols: external_exports.array(external_exports.strictObject({ symbolId: external_exports.string().regex(/^sym_[a-f0-9]{8,64}$/), bodyHash: external_exports.string().regex(/^[a-f0-9]{8,64}$/) })).max(32),
15518
+ /** Scrubbed, tokenized net change from this occurrence's source to atCommit. */
15519
+ diff: external_exports.string().max(16e3).optional()
15520
+ })).max(50)
15521
+ });
15522
+ }
15523
+ });
15524
+
15365
15525
  // ../../packages/shared/src/nlp/canonicalize.ts
15366
15526
  var init_canonicalize = __esm({
15367
15527
  "../../packages/shared/src/nlp/canonicalize.ts"() {
@@ -15391,6 +15551,11 @@ var init_src = __esm({
15391
15551
  init_project_symbol();
15392
15552
  init_lockfile();
15393
15553
  init_manifests();
15554
+ init_history_quality();
15555
+ init_history_read();
15556
+ init_history_temporal();
15557
+ init_history_revision();
15558
+ init_history_evidence();
15394
15559
  init_hash();
15395
15560
  init_error_signature();
15396
15561
  init_canonicalize();
@@ -15400,6 +15565,7 @@ var init_src = __esm({
15400
15565
  init_predicate();
15401
15566
  init_taxonomy();
15402
15567
  init_triage_canon();
15568
+ init_history_text();
15403
15569
  }
15404
15570
  });
15405
15571
 
@@ -27299,6 +27465,9 @@ function codeAnchorProjection(store2, semanticIds, opts = {}) {
27299
27465
  return out2;
27300
27466
  }
27301
27467
 
27468
+ // ../../packages/generalizer/src/embed-code.ts
27469
+ init_src();
27470
+
27302
27471
  // ../../packages/context-writer/src/agents-md.ts
27303
27472
  init_src();
27304
27473
 
@@ -27323,8 +27492,9 @@ var AGENTS_POINTER_BODY = [
27323
27492
 
27324
27493
  // ../../packages/context-writer/src/render.ts
27325
27494
  init_src2();
27495
+ init_src();
27326
27496
  function buildSnapshot(opts) {
27327
- const problems = opts.store.findNodesByLabel("Problem").filter((p) => p.attrs["mergedInto"] === void 0);
27497
+ const problems = opts.store.findNodesByLabel("Problem").filter((p) => p.attrs["mergedInto"] === void 0 && historyReadPolicy(p, { mode: "passive" }).allow);
27328
27498
  const stillOpen = problems.filter((p) => p.attrs["resolvedAt"] == null);
27329
27499
  const allProblems = stillOpen.filter((p) => !isConstraintProblem(p));
27330
27500
  allProblems.sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt);
@@ -27354,10 +27524,11 @@ function buildSnapshot(opts) {
27354
27524
  ...opts.store.findNodesByLabel("Pattern"),
27355
27525
  ...opts.store.findNodesByLabel("Technique"),
27356
27526
  ...opts.store.findNodesByLabel("AntiPattern")
27357
- ].sort((a, b) => b.pageRank - a.pageRank).slice(0, 10);
27527
+ ].filter((n) => historyReadPolicy(n, { mode: "passive" }).allow).sort((a, b) => b.pageRank - a.pageRank).slice(0, 10);
27358
27528
  const workingFile = opts.workingFile ? sliceForFile(opts.store, opts.workingFile) : void 0;
27359
27529
  const byEpisode = /* @__PURE__ */ new Map();
27360
27530
  for (const sol of opts.store.findNodesByLabel("Solution")) {
27531
+ if (!historyReadPolicy(sol, { mode: "passive" }).allow) continue;
27361
27532
  if (sol.attrs["enrichmentPending"] !== true) continue;
27362
27533
  const ep = sol.attrs["episodeId"] ?? sol.id;
27363
27534
  const list = byEpisode.get(ep) ?? [];
@@ -27467,6 +27638,14 @@ function sliceForFile(store2, relPath) {
27467
27638
  if (externalRefs.length >= 20) break;
27468
27639
  }
27469
27640
  const fp = priorsForFile(store2, relPath);
27641
+ if (fp) {
27642
+ const allowed = (n) => historyReadPolicy(n, { mode: "passive" }).allow;
27643
+ fp.openProblems = fp.openProblems.filter(allowed);
27644
+ fp.constraints = fp.constraints.filter(allowed);
27645
+ fp.resolvedProblems = fp.resolvedProblems.filter(allowed);
27646
+ fp.related = fp.related.filter(allowed);
27647
+ for (const [id, solutions] of fp.solutionsByProblem) fp.solutionsByProblem.set(id, solutions.filter(allowed));
27648
+ }
27470
27649
  const priors = fp ? {
27471
27650
  openProblems: fp.openProblems.slice(0, 3).map((p) => ({
27472
27651
  id: p.id,
@@ -27507,6 +27686,7 @@ ${RECALL_FIRST_BODY}`;
27507
27686
 
27508
27687
  // ../../packages/context-writer/src/select-durable-memory.ts
27509
27688
  init_src2();
27689
+ init_src();
27510
27690
 
27511
27691
  // src/pass-worker.ts
27512
27692
  init_src3();