@vostride/agent-qa-knowledge-local 0.2.2 → 0.2.4

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/dist/reader.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/serving/reader.ts
2
2
  import { existsSync as existsSync7 } from "node:fs";
3
- import { basename as basename5 } from "node:path";
3
+ import { basename as basename4 } from "node:path";
4
4
  import { wrapAppObservedData } from "@vostride/agent-qa-safety";
5
5
  import {
6
6
  asRecordId as asRecordId2,
@@ -8,8 +8,7 @@ import {
8
8
  EMPTY_PROCEDURE_BINDING_AVAILABILITY,
9
9
  isVettedCandidate as isVettedCandidate3,
10
10
  normalizeAnchor as normalizeAnchor7,
11
- slugBranch as slugBranch2,
12
- strongestPromotionPath
11
+ slugBranch as slugBranch2
13
12
  } from "@vostride/agent-qa-schema";
14
13
 
15
14
  // src/bundle-read.ts
@@ -299,12 +298,12 @@ function verifyBundleIntegrity(bundleDir) {
299
298
  }
300
299
  return { ok: violations.length === 0, violations };
301
300
  }
302
- function deriveBundleTrust(loaded, priors) {
301
+ function deriveBundleTrust(loaded) {
303
302
  return foldBundleTrust(loaded.events, {
304
303
  originClass: loaded.provenance.originClass,
305
304
  evidenceIncomplete: loaded.manifest.evidenceIncomplete,
306
305
  createdAtOrdinal: loaded.manifest.createdAtOrdinal
307
- }, priors);
306
+ });
308
307
  }
309
308
 
310
309
  // src/bundle-scan.ts
@@ -391,11 +390,11 @@ function anchorMatches(bundle, queryAnchor) {
391
390
  return normalized.t === "el" && queryAnchor.t === "el" && normalized.role === queryAnchor.role && normalized.name === queryAnchor.name;
392
391
  });
393
392
  }
394
- function servableHit(dir, priors) {
393
+ function servableHit(dir) {
395
394
  const outcome = loadBundle(dir.dir);
396
395
  if (outcome.kind !== "loaded") return void 0;
397
396
  if (!verifyBundleIntegrity(dir.dir).ok) return void 0;
398
- const trustState = deriveBundleTrust(outcome.bundle, priors);
397
+ const trustState = deriveBundleTrust(outcome.bundle);
399
398
  return isServable(trustState) ? toHit(outcome.bundle, trustState, dir.product) : void 0;
400
399
  }
401
400
  function scanBundlesWithPosture(opts, servingOnly) {
@@ -407,7 +406,7 @@ function scanBundlesWithPosture(opts, servingOnly) {
407
406
  const outcome = loadBundle(entry.dir);
408
407
  if (outcome.kind !== "loaded") continue;
409
408
  if (!verifyBundleIntegrity(entry.dir).ok) continue;
410
- const trustState = deriveBundleTrust(outcome.bundle, opts.priors);
409
+ const trustState = deriveBundleTrust(outcome.bundle);
411
410
  if (servingOnly && !isServable(trustState)) continue;
412
411
  if (!textMatches(outcome.bundle, queryTokens)) continue;
413
412
  if (!anchorMatches(outcome.bundle, queryAnchor)) continue;
@@ -427,7 +426,7 @@ function scanBundlesForRetrieval(opts) {
427
426
  function scanBundleById(opts) {
428
427
  for (const entry of enumerateBundleDirs(opts.knowledgeRoot)) {
429
428
  if (basename2(entry.dir) !== opts.bundleId) continue;
430
- const hit = servableHit(entry, opts.priors);
429
+ const hit = servableHit(entry);
431
430
  if (hit !== void 0) return hit;
432
431
  }
433
432
  return void 0;
@@ -440,7 +439,6 @@ import { join as join5 } from "node:path";
440
439
  import { z as z2 } from "zod";
441
440
  import {
442
441
  canonicalJson as canonicalJson3,
443
- CROSS_CHECKS,
444
442
  sha256hex
445
443
  } from "@vostride/agent-qa-schema";
446
444
 
@@ -607,7 +605,6 @@ function publishStagedQueueEntry(stagingDir, finalDir, queueDir) {
607
605
  // src/canary-emit.ts
608
606
  var CANARY_QUEUE_SCHEMA_VERSION = 2;
609
607
  var PAYLOAD_BENEFITS = ["exercised-benefited", "rode-along", "exercised-harmed"];
610
- var PAYLOAD_STATE_VALIDITIES = ["valid", "stale", "unknown"];
611
608
  var canaryOutcomePayloadBaseShape = {
612
609
  jobKind: z2.literal("canary-outcome"),
613
610
  candidateId: z2.string().min(1),
@@ -621,28 +618,10 @@ var canaryOutcomePayloadBaseShape = {
621
618
  attribution: z2.string(),
622
619
  briefDigest: z2.string().min(1)
623
620
  };
624
- var count = z2.number().int().nonnegative();
625
- var digest = z2.string().regex(/^[0-9a-f]{64}$/);
626
621
  var canaryOutcomePayloadSchema = z2.object({
627
622
  ...canaryOutcomePayloadBaseShape,
628
623
  schemaVersion: z2.literal(CANARY_QUEUE_SCHEMA_VERSION),
629
- benefit: z2.enum(PAYLOAD_BENEFITS),
630
- stateValidity: z2.enum(PAYLOAD_STATE_VALIDITIES),
631
- corpusDigest: digest.optional(),
632
- observedStateDigest: digest.optional(),
633
- ablation: z2.object({
634
- crossCheck: z2.enum(CROSS_CHECKS),
635
- k: z2.number().int().min(3),
636
- baseSeed: z2.number().int(),
637
- seeds: z2.array(z2.number().int()),
638
- seedHonored: z2.boolean(),
639
- spend: z2.object({
640
- modelCalls: count,
641
- screens: count,
642
- promptTokens: count,
643
- completionTokens: count
644
- }).strict()
645
- }).strict().optional()
624
+ benefit: z2.enum(PAYLOAD_BENEFITS)
646
625
  }).strict();
647
626
  var diagnosticShape = { emittedAt: z2.string().optional() };
648
627
  var canaryOutcomeAddressFieldsSchema = canaryOutcomePayloadSchema.extend(diagnosticShape);
@@ -663,10 +642,6 @@ function enqueueCanaryOutcome(knowledgeRoot, outcome) {
663
642
  stepIndex: outcome.stepIndex,
664
643
  outcome: outcome.runOutcome,
665
644
  benefit: outcome.benefit,
666
- stateValidity: outcome.stateValidity,
667
- ...outcome.corpusDigest === void 0 ? {} : { corpusDigest: outcome.corpusDigest },
668
- ...outcome.observedStateDigest === void 0 ? {} : { observedStateDigest: outcome.observedStateDigest },
669
- ...outcome.ablation === void 0 ? {} : { ablation: outcome.ablation },
670
645
  exercisedAnchor: outcome.exercisedAnchor,
671
646
  attribution: outcome.attribution,
672
647
  briefDigest: outcome.briefDigest
@@ -863,7 +838,7 @@ function probeIndexHealth(db) {
863
838
 
864
839
  // src/index-reader.ts
865
840
  import { existsSync as existsSync6, statSync as statSync2 } from "node:fs";
866
- import { basename as basename4, join as join9 } from "node:path";
841
+ import { basename as basename3, join as join9 } from "node:path";
867
842
  import {
868
843
  canonicalJson as canonicalJson7,
869
844
  normalizeAnchor as normalizeAnchor3
@@ -924,11 +899,10 @@ function buildLexicalMatchExpression(text) {
924
899
 
925
900
  // src/promotion-gate-input.ts
926
901
  import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
927
- import { basename as basename3, dirname as dirname4, join as join8 } from "node:path";
902
+ import { join as join8 } from "node:path";
928
903
  import {
929
904
  canonicalJson as canonicalJson5,
930
905
  guardDistilledObservation,
931
- guardTrustPriorTable,
932
906
  isPromotionReceipt,
933
907
  survivingOutcomeEvents as survivingOutcomeEvents2,
934
908
  supersessionKey as supersessionKey2
@@ -966,12 +940,6 @@ function scanCanonicalBundles(knowledgeRoot) {
966
940
  }
967
941
 
968
942
  // src/promotion-gate-input.ts
969
- function snapshotTrustPriors(priors) {
970
- if (priors === void 0) return void 0;
971
- const snapshot = guardTrustPriorTable(priors);
972
- for (const row of Object.values(snapshot)) Object.freeze(row);
973
- return Object.freeze(snapshot);
974
- }
975
943
  function promotionObservations(bundleDir) {
976
944
  const file = join8(bundleDir, "observations.jsonl");
977
945
  if (!existsSync5(file)) return [];
@@ -991,20 +959,12 @@ function memoryOffForBundle(knowledgeRoot, bundle) {
991
959
  );
992
960
  }
993
961
  function assemblePromotionGateInput(input) {
994
- const trust = deriveBundleTrust(input.bundle, input.priors);
962
+ const trust = deriveBundleTrust(input.bundle);
995
963
  const survivingEvents = survivingOutcomeEvents2(input.bundle.events);
996
964
  const runLinkedProvenance = input.bundle.provenance.mode === "run-linked" ? input.bundle.provenance : void 0;
997
965
  const gateLines = readGateReceipts(input.bundleDir, input.bundle.manifest.id) ?? [];
998
- const provenance = candidateProvenanceOf(input.bundleDir, input.bundle);
999
- const posture = input.resolvePromotionPosture?.({
1000
- id: input.bundle.manifest.id,
1001
- product: basename3(dirname4(dirname4(input.bundleDir))),
1002
- scope: input.bundle.frontmatter.scope,
1003
- provenance
1004
- });
1005
966
  return {
1006
967
  gateReceipts: gateLines.filter((line) => !isPromotionReceipt(line)),
1007
- ...posture === void 0 ? {} : { gatePosture: posture },
1008
968
  kind: input.bundle.frontmatter.kind,
1009
969
  ...input.bundle.frontmatter.subtype === void 0 ? {} : { subtype: input.bundle.frontmatter.subtype },
1010
970
  status: trust.status,
@@ -1025,28 +985,15 @@ function assemblePromotionGateInput(input) {
1025
985
  memoryOffForAnchorGroup: memoryOffForBundle(input.knowledgeRoot, input.bundle)
1026
986
  };
1027
987
  }
1028
- function candidateProvenanceOf(bundleDir, bundle) {
1029
- const runLinked = bundle.provenance.mode === "run-linked" ? bundle.provenance : void 0;
1030
- const gateLines = readGateReceipts(bundleDir, bundle.manifest.id) ?? [];
1031
- return {
1032
- runIds: runLinked === void 0 ? [] : [runLinked.runId],
1033
- receiptDigests: gateLines.map((line) => line.receiptDigest),
1034
- capturedAtOrdinals: [...new Set([
1035
- ...runLinked?.sourceBuildOrdinal === void 0 ? [] : [runLinked.sourceBuildOrdinal],
1036
- ...survivingOutcomeEvents2(bundle.events).map((event) => event.buildOrdinal)
1037
- ].filter(Number.isInteger))].sort((left, right) => left - right)
1038
- };
1039
- }
1040
988
 
1041
989
  // src/trust-prior-context.ts
1042
990
  import { createHash as createHash2 } from "node:crypto";
1043
- import { canonicalJson as canonicalJson6, guardTrustPriorTable as guardTrustPriorTable2, ORIGIN_PRIORS } from "@vostride/agent-qa-schema";
1044
- function effectivePriorDigest(priors) {
1045
- const table = priors === void 0 ? void 0 : guardTrustPriorTable2(priors);
1046
- return createHash2("sha256").update(canonicalJson6({ ...ORIGIN_PRIORS, ...table })).digest("hex");
991
+ import { canonicalJson as canonicalJson6, ORIGIN_PRIORS } from "@vostride/agent-qa-schema";
992
+ function effectivePriorDigest() {
993
+ return createHash2("sha256").update(canonicalJson6({ ...ORIGIN_PRIORS })).digest("hex");
1047
994
  }
1048
- function indexTrustEpochMatches(db, digest2) {
1049
- return db.prepare("SELECT v FROM meta WHERE k = 'trust_prior_digest'").get()?.v === digest2 && db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest2) === void 0;
995
+ function indexTrustEpochMatches(db, digest) {
996
+ return db.prepare("SELECT v FROM meta WHERE k = 'trust_prior_digest'").get()?.v === digest && db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest) === void 0;
1050
997
  }
1051
998
  var TrustPriorEpochMismatch = class extends Error {
1052
999
  constructor() {
@@ -1119,12 +1066,12 @@ function rowToIndexedRecord(row) {
1119
1066
  };
1120
1067
  }
1121
1068
  function safeBundleDir(knowledgeRoot, hit) {
1122
- if (hit.product === "" || hit.product === "." || hit.product === ".." || hit.product !== basename4(hit.product) || hit.bundleId === "" || hit.bundleId === "." || hit.bundleId === ".." || hit.bundleId !== basename4(hit.bundleId)) {
1069
+ if (hit.product === "" || hit.product === "." || hit.product === ".." || hit.product !== basename3(hit.product) || hit.bundleId === "" || hit.bundleId === "." || hit.bundleId === ".." || hit.bundleId !== basename3(hit.bundleId)) {
1123
1070
  return void 0;
1124
1071
  }
1125
1072
  return join9(knowledgeRoot, "memory", hit.product, "bundles", hit.bundleId);
1126
1073
  }
1127
- function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
1074
+ function recheckAuthoritativeHits(knowledgeRoot, hits, audit) {
1128
1075
  const refreshed = [];
1129
1076
  for (const hit of hits) {
1130
1077
  const bundleDir = safeBundleDir(knowledgeRoot, hit);
@@ -1133,7 +1080,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
1133
1080
  if (!verifyBundleIntegrity(bundleDir).ok) continue;
1134
1081
  const outcome = loadBundle(bundleDir);
1135
1082
  if (outcome.kind !== "loaded" || outcome.bundle.manifest.id !== hit.bundleId) continue;
1136
- const trust = deriveBundleTrust(outcome.bundle, priors);
1083
+ const trust = deriveBundleTrust(outcome.bundle);
1137
1084
  if (!audit && !isServable(trust)) continue;
1138
1085
  refreshed.push({
1139
1086
  ...hit,
@@ -1153,8 +1100,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
1153
1100
  vettedCandidateInput: assemblePromotionGateInput({
1154
1101
  knowledgeRoot,
1155
1102
  bundleDir,
1156
- bundle: outcome.bundle,
1157
- priors
1103
+ bundle: outcome.bundle
1158
1104
  })
1159
1105
  });
1160
1106
  } catch {
@@ -1162,8 +1108,8 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
1162
1108
  }
1163
1109
  return refreshed;
1164
1110
  }
1165
- function recheckHits(knowledgeRoot, hits, priors) {
1166
- return recheckAuthoritativeHits(knowledgeRoot, hits, false, priors).map((hit) => {
1111
+ function recheckHits(knowledgeRoot, hits) {
1112
+ return recheckAuthoritativeHits(knowledgeRoot, hits, false).map((hit) => {
1167
1113
  const {
1168
1114
  anchors: _anchors,
1169
1115
  scope: _scope,
@@ -1232,52 +1178,50 @@ function cosineDistance(query, candidate) {
1232
1178
  }
1233
1179
  return 1 - dot;
1234
1180
  }
1235
- function scanReader(knowledgeRoot, priors) {
1181
+ function scanReader(knowledgeRoot) {
1236
1182
  const reader = {
1237
1183
  source: "scan",
1238
1184
  vec: "none",
1239
1185
  getById(bundleId) {
1240
- return scanBundleById({ knowledgeRoot, bundleId, priors });
1186
+ return scanBundleById({ knowledgeRoot, bundleId });
1241
1187
  },
1242
1188
  searchLexical(text, opts = {}) {
1243
- return scanBundles({ knowledgeRoot, text, ...opts, priors });
1189
+ return scanBundles({ knowledgeRoot, text, ...opts });
1244
1190
  },
1245
1191
  lookupAnchor(anchor, opts = {}) {
1246
- return scanBundles({ knowledgeRoot, anchor: normalizeAnchor3(anchor), ...opts, priors });
1192
+ return scanBundles({ knowledgeRoot, anchor: normalizeAnchor3(anchor), ...opts });
1247
1193
  },
1248
1194
  searchDense() {
1249
1195
  return [];
1250
1196
  },
1251
1197
  recheck(hits) {
1252
- return recheckHits(knowledgeRoot, hits, priors);
1198
+ return recheckHits(knowledgeRoot, hits);
1253
1199
  },
1254
1200
  close() {
1255
1201
  },
1256
1202
  async [RUN_RETRIEVAL](operation) {
1257
1203
  return operation({
1258
1204
  knowledgeRoot,
1259
- priors,
1260
1205
  source: "scan",
1261
1206
  vec: "none",
1262
1207
  connection: void 0,
1263
1208
  reader,
1264
1209
  scan: (text, anchor) => scanBundlesForRetrieval({
1265
1210
  knowledgeRoot,
1266
- priors,
1267
1211
  ...text === void 0 ? {} : { text },
1268
1212
  ...anchor === void 0 ? {} : { anchor }
1269
1213
  }),
1270
- recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors)
1214
+ recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
1271
1215
  });
1272
1216
  }
1273
1217
  };
1274
1218
  return reader;
1275
1219
  }
1276
- function indexReader(knowledgeRoot, connection, priors) {
1220
+ function indexReader(knowledgeRoot, connection) {
1277
1221
  let closed = false;
1278
1222
  const { db } = connection;
1279
1223
  const activeProfile = resolveActiveProfile(db);
1280
- const priorDigest = effectivePriorDigest(priors);
1224
+ const priorDigest = effectivePriorDigest();
1281
1225
  let snapshotDepth = 0;
1282
1226
  function assertTrustEpoch() {
1283
1227
  if (!indexTrustEpochMatches(db, priorDigest)) throw new TrustPriorEpochMismatch();
@@ -1295,7 +1239,7 @@ function indexReader(knowledgeRoot, connection, priors) {
1295
1239
  });
1296
1240
  }
1297
1241
  function recheckCurrent(hits) {
1298
- return recheckHits(knowledgeRoot, hits, priors);
1242
+ return recheckHits(knowledgeRoot, hits);
1299
1243
  }
1300
1244
  function denseVec02(embedding, opts) {
1301
1245
  const k = queryLimit(opts.k);
@@ -1466,13 +1410,12 @@ function indexReader(knowledgeRoot, connection, priors) {
1466
1410
  try {
1467
1411
  return await operation({
1468
1412
  knowledgeRoot,
1469
- priors,
1470
1413
  source: "index",
1471
1414
  vec: connection.vec,
1472
1415
  connection,
1473
1416
  reader: snapshotReader,
1474
1417
  scan: void 0,
1475
- recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors)
1418
+ recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
1476
1419
  });
1477
1420
  } finally {
1478
1421
  snapshotDepth -= 1;
@@ -1489,8 +1432,8 @@ function indexReader(knowledgeRoot, connection, priors) {
1489
1432
  };
1490
1433
  return snapshotReader;
1491
1434
  }
1492
- function operationDegradingReader(knowledgeRoot, connection, priors) {
1493
- let delegate = indexReader(knowledgeRoot, connection, priors);
1435
+ function operationDegradingReader(knowledgeRoot, connection) {
1436
+ let delegate = indexReader(knowledgeRoot, connection);
1494
1437
  let closed = false;
1495
1438
  function invoke(operation) {
1496
1439
  if (delegate.source === "scan") return operation(delegate);
@@ -1505,7 +1448,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
1505
1448
  `derived index operation failed: ${errorMessage2(error)}`
1506
1449
  );
1507
1450
  }
1508
- delegate = scanReader(knowledgeRoot, priors);
1451
+ delegate = scanReader(knowledgeRoot);
1509
1452
  return operation(delegate);
1510
1453
  }
1511
1454
  }
@@ -1522,7 +1465,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
1522
1465
  `derived index operation failed: ${errorMessage2(error)}`
1523
1466
  );
1524
1467
  }
1525
- delegate = scanReader(knowledgeRoot, priors);
1468
+ delegate = scanReader(knowledgeRoot);
1526
1469
  return operation(delegate);
1527
1470
  }
1528
1471
  }
@@ -1563,9 +1506,9 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
1563
1506
  };
1564
1507
  return reader;
1565
1508
  }
1566
- function degrade(knowledgeRoot, reason, detail, priors) {
1509
+ function degrade(knowledgeRoot, reason, detail) {
1567
1510
  requestRebuildBestEffort(knowledgeRoot, reason, detail);
1568
- return scanReader(knowledgeRoot, priors);
1511
+ return scanReader(knowledgeRoot);
1569
1512
  }
1570
1513
  function classifyIndexFaceWithConnection(knowledgeRoot, opts) {
1571
1514
  if (!existsSync6(indexDbPath(knowledgeRoot))) {
@@ -1608,15 +1551,14 @@ function classifyIndexFaceWithConnection(knowledgeRoot, opts) {
1608
1551
  return { face: { source: "index" }, connection };
1609
1552
  }
1610
1553
  function openKnowledgeReader(knowledgeRoot, opts = {}) {
1611
- const priors = snapshotTrustPriors(opts.priors);
1612
1554
  const result = classifyIndexFaceWithConnection(knowledgeRoot, {
1613
1555
  ...opts,
1614
1556
  inspectCheckpointedImmutably: false
1615
1557
  });
1616
1558
  if (result.connection === void 0) {
1617
- return degrade(knowledgeRoot, result.face.reason, result.face.detail, priors);
1559
+ return degrade(knowledgeRoot, result.face.reason, result.face.detail);
1618
1560
  }
1619
- return operationDegradingReader(knowledgeRoot, result.connection, priors);
1561
+ return operationDegradingReader(knowledgeRoot, result.connection);
1620
1562
  }
1621
1563
 
1622
1564
  // src/retrieval/pre-filter.ts
@@ -1699,7 +1641,6 @@ import {
1699
1641
  // src/retrieval/rerank.ts
1700
1642
  import {
1701
1643
  COLD_START_TRUST_DISCOUNT,
1702
- LOWER_TRUST_PATH_DISCOUNT,
1703
1644
  isVettedCandidate,
1704
1645
  supersessionKey as supersessionKey3
1705
1646
  } from "@vostride/agent-qa-schema";
@@ -1751,13 +1692,11 @@ function applyLifecycleTrustTreatments(entries, asOfBuild) {
1751
1692
  }
1752
1693
  const unverified = entry.vettedCandidateInput !== void 0 && isVettedCandidate(entry.vettedCandidateInput);
1753
1694
  if (unverified) trust *= COLD_START_TRUST_DISCOUNT;
1754
- if (entry.lowerTrust === true) trust *= LOWER_TRUST_PATH_DISCOUNT;
1755
1695
  return {
1756
1696
  ...base,
1757
1697
  trust,
1758
1698
  ...unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal },
1759
- ...unverified ? { unverified: true } : {},
1760
- ...entry.lowerTrust === true ? { lowerTrust: true } : {}
1699
+ ...unverified ? { unverified: true } : {}
1761
1700
  };
1762
1701
  });
1763
1702
  }
@@ -1772,9 +1711,9 @@ function applyDiversityCaps(entries, audit = false) {
1772
1711
  return entries.filter((entry) => {
1773
1712
  const key = primaryDiversityKey(entry);
1774
1713
  if (key === void 0) return true;
1775
- const count2 = counts.get(key) ?? 0;
1776
- if (count2 >= DIVERSITY_CAP_PER_ANCHOR) return false;
1777
- counts.set(key, count2 + 1);
1714
+ const count = counts.get(key) ?? 0;
1715
+ if (count >= DIVERSITY_CAP_PER_ANCHOR) return false;
1716
+ counts.set(key, count + 1);
1778
1717
  return true;
1779
1718
  });
1780
1719
  }
@@ -1813,12 +1752,12 @@ function resolveAsOfBuild(options) {
1813
1752
  if (injected !== void 0) return injected;
1814
1753
  const disk = options.runtimeRoot === void 0 ? void 0 : readLatestBuildOrdinal(options.runtimeRoot, options.product);
1815
1754
  if (disk !== void 0) return disk;
1816
- let latest2;
1755
+ let latest;
1817
1756
  for (const candidate of options.candidates) {
1818
1757
  if (!Number.isFinite(candidate.openedAtOrdinal)) continue;
1819
- latest2 = latest2 === void 0 ? candidate.openedAtOrdinal : Math.max(latest2, candidate.openedAtOrdinal);
1758
+ latest = latest === void 0 ? candidate.openedAtOrdinal : Math.max(latest, candidate.openedAtOrdinal);
1820
1759
  }
1821
- return latest2;
1760
+ return latest;
1822
1761
  }
1823
1762
  function isCurrentAt(candidate, asOfBuild) {
1824
1763
  return candidate.openedAtOrdinal <= asOfBuild && (candidate.closedAtOrdinal === null || candidate.closedAtOrdinal > asOfBuild);
@@ -2010,7 +1949,6 @@ function rankedCandidate(candidate) {
2010
1949
  lastConfirmedOrdinal,
2011
1950
  ...candidate.record.unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal: candidate.record.unconfirmedSinceOrdinal },
2012
1951
  ...candidate.record.unverified === true ? { unverified: true } : {},
2013
- ...candidate.record.lowerTrust === true ? { lowerTrust: true } : {},
2014
1952
  ...candidate.record.conflict === void 0 ? {} : { conflict: candidate.record.conflict }
2015
1953
  };
2016
1954
  }
@@ -2548,8 +2486,7 @@ function readPolicyLadder(knowledgeRoot, product) {
2548
2486
  return rung === void 0 ? [] : [rung];
2549
2487
  });
2550
2488
  return {
2551
- // D-07: Validated active policy bytes are concatenated whole. Labels frame
2552
- // sources but no active text is summarized, truncated, normalized, or reflowed.
2489
+ // Active policy bytes are concatenated whole; labels frame sources and no text is reflowed.
2553
2490
  text: renderPolicyLadder(rungs),
2554
2491
  files: rungs.map(({ file }) => file),
2555
2492
  oversized: rungs.flatMap(
@@ -2591,7 +2528,7 @@ function readIndexRows(config, scope) {
2591
2528
  ...scope === void 0 ? {} : { requestedScope: scope },
2592
2529
  ...config.scopeDefaults?.parentScopes === void 0 ? {} : { parentScopes: config.scopeDefaults.parentScopes }
2593
2530
  });
2594
- if (!indexTrustEpochMatches(reader.db, effectivePriorDigest(config.priors))) {
2531
+ if (!indexTrustEpochMatches(reader.db, effectivePriorDigest())) {
2595
2532
  const admits = reader.db.prepare(`
2596
2533
  SELECT 1 FROM (SELECT ? AS product, ? AS scope_tier, ? AS scope_key) r
2597
2534
  WHERE ${predicate.sql}
@@ -2629,7 +2566,7 @@ function readIndexRows(config, scope) {
2629
2566
  function bundleDirs(config) {
2630
2567
  return new Map(
2631
2568
  enumerateBundleDirs(config.knowledgeRoot).map(({ dir, product }) => [
2632
- basename5(dir),
2569
+ basename4(dir),
2633
2570
  { dir, product }
2634
2571
  ])
2635
2572
  );
@@ -2642,16 +2579,14 @@ function hydrateRows(config, rows, audit) {
2642
2579
  const loaded = loadBundle(found.dir);
2643
2580
  if (loaded.kind !== "loaded" || !verifyBundleIntegrity(found.dir).ok) return [];
2644
2581
  const { bundle } = loaded;
2645
- const trust = deriveBundleTrust(bundle, config.priors);
2582
+ const trust = deriveBundleTrust(bundle);
2646
2583
  const vetted = trust.status === "candidate" && isVettedCandidate3(
2647
2584
  assemblePromotionGateInput({
2648
2585
  knowledgeRoot: config.knowledgeRoot,
2649
2586
  bundleDir: found.dir,
2650
- bundle,
2651
- priors: config.priors
2587
+ bundle
2652
2588
  })
2653
2589
  );
2654
- const lowerTrust = trust.status === "active" && strongestPromotionPath(readGateReceipts(found.dir, bundle.manifest.id) ?? []) === "gate1-lower-trust";
2655
2590
  const entry = {
2656
2591
  id: asRecordId2(bundle.manifest.id),
2657
2592
  kind: bundle.frontmatter.kind,
@@ -2661,8 +2596,7 @@ function hydrateRows(config, rows, audit) {
2661
2596
  trust: trust.trust,
2662
2597
  anchors: bundle.frontmatter.anchors.map(({ normalized }) => normalized),
2663
2598
  status: trust.status,
2664
- servedAsCanary: vetted || lowerTrust,
2665
- ...lowerTrust ? { lowerTrust: true } : {},
2599
+ servedAsCanary: vetted,
2666
2600
  ...vetted ? { unverified: true } : {},
2667
2601
  ...audit ? {
2668
2602
  audit: {
@@ -2736,7 +2670,7 @@ function searchEntries(config, query, options) {
2736
2670
  if (!auditMode && (entry.status === "deprecated" || entry.status === "superseded")) {
2737
2671
  return false;
2738
2672
  }
2739
- const trust = deriveBundleTrust(bundle, config.priors);
2673
+ const trust = deriveBundleTrust(bundle);
2740
2674
  if (options.asOfBuild !== void 0 && !validAtBuild(
2741
2675
  trust.validity.openedAtOrdinal,
2742
2676
  trust.validity.closedAtOrdinal,
@@ -2766,7 +2700,7 @@ function findReadableBundle(config, id, options) {
2766
2700
  if (currentServingEntries([hydrated]).length === 0 && !admitsProcedure({ entry: hydrated.entry, bundle: hydrated.bundle })) {
2767
2701
  return void 0;
2768
2702
  }
2769
- const trust = deriveBundleTrust(hydrated.bundle, config.priors);
2703
+ const trust = deriveBundleTrust(hydrated.bundle);
2770
2704
  const asOfBuild = options?.asOfBuild ?? config.scopeDefaults?.asOfBuild;
2771
2705
  if (asOfBuild !== void 0 && !validAtBuild(
2772
2706
  trust.validity.openedAtOrdinal,
@@ -2879,7 +2813,7 @@ function servingReader(config) {
2879
2813
  };
2880
2814
  }
2881
2815
  function openKnowledgeReader2(configOrKnowledgeRoot, opts) {
2882
- return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader({ ...configOrKnowledgeRoot, priors: snapshotTrustPriors(configOrKnowledgeRoot.priors) });
2816
+ return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader(configOrKnowledgeRoot);
2883
2817
  }
2884
2818
 
2885
2819
  // src/serving/authoring-reader.ts
@@ -3033,7 +2967,7 @@ import {
3033
2967
  } from "@vostride/agent-qa-schema";
3034
2968
 
3035
2969
  // src/embedder-acquire.ts
3036
- import { dirname as dirname7 } from "node:path";
2970
+ import { dirname as dirname6 } from "node:path";
3037
2971
  import {
3038
2972
  DEFAULT_EMBEDDING_PROFILE as DEFAULT_EMBEDDING_PROFILE2,
3039
2973
  STATIC_FLOOR_EMBEDDING_PROFILE as STATIC_FLOOR_EMBEDDING_PROFILE2
@@ -3147,7 +3081,7 @@ function wrapEmbedderWithCache({
3147
3081
  // src/embedder-floor.ts
3148
3082
  import { createHash as createHash4 } from "node:crypto";
3149
3083
  import { existsSync as existsSync8, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
3150
- import { dirname as dirname5, join as join13 } from "node:path";
3084
+ import { dirname as dirname4, join as join13 } from "node:path";
3151
3085
  import { fileURLToPath } from "node:url";
3152
3086
  var PACKAGE_NAME = "@vostride/agent-qa-knowledge-local";
3153
3087
  var ASSET_DIRECTORY = "potion-retrieval-32m";
@@ -3191,7 +3125,7 @@ function errorMessage3(error) {
3191
3125
  return error instanceof Error ? error.message : String(error);
3192
3126
  }
3193
3127
  function packageRootFromImportMeta() {
3194
- let current = dirname5(fileURLToPath(import.meta.url));
3128
+ let current = dirname4(fileURLToPath(import.meta.url));
3195
3129
  while (true) {
3196
3130
  const packageJsonPath = join13(current, "package.json");
3197
3131
  if (existsSync8(packageJsonPath)) {
@@ -3201,7 +3135,7 @@ function packageRootFromImportMeta() {
3201
3135
  } catch {
3202
3136
  }
3203
3137
  }
3204
- const parent = dirname5(current);
3138
+ const parent = dirname4(current);
3205
3139
  if (parent === current) break;
3206
3140
  current = parent;
3207
3141
  }
@@ -3677,7 +3611,7 @@ import {
3677
3611
  import { request } from "node:http";
3678
3612
  import { connect } from "node:net";
3679
3613
  import { tmpdir } from "node:os";
3680
- import { basename as basename6, dirname as dirname6, join as join15 } from "node:path";
3614
+ import { basename as basename5, dirname as dirname5, join as join15 } from "node:path";
3681
3615
  import { z as z4 } from "zod";
3682
3616
  var EMBEDDER_WORKER_REGISTRATION_FILE = "embedder-worker.json";
3683
3617
  var EMBEDDER_WORKER_REGISTRATION_SCHEMA_VERSION = 2;
@@ -3761,7 +3695,7 @@ function embedderWorkerSocketPath(agentQaRoot, projectRoot, instanceId) {
3761
3695
  if (process.platform === "win32") {
3762
3696
  return `\\\\.\\pipe\\agent-qa-embedder-${hash}-${instance}`;
3763
3697
  }
3764
- const canonicalAgentQaRoot = join15(realpathSync2(dirname6(agentQaRoot)), basename6(agentQaRoot));
3698
+ const canonicalAgentQaRoot = join15(realpathSync2(dirname5(agentQaRoot)), basename5(agentQaRoot));
3765
3699
  const socketFile = `embedder-worker-${instance}.sock`;
3766
3700
  const projectLocal = join15(canonicalAgentQaRoot, socketFile);
3767
3701
  if (Buffer.byteLength(projectLocal) <= EMBEDDER_WORKER_SOCKET_PATH_BUDGET_BYTES) {
@@ -3823,7 +3757,7 @@ function sameRegistration(left, right) {
3823
3757
  }
3824
3758
  function removeEmbedderWorkerRegistration(agentQaRoot, expected, options = {}) {
3825
3759
  const file = embedderWorkerRegistrationPath(agentQaRoot);
3826
- const parent = dirname6(file);
3760
+ const parent = dirname5(file);
3827
3761
  const quarantine = `${file}.remove-${expected.instanceId}-${randomUUID3()}`;
3828
3762
  const fsyncDirectory = options.fsyncDirectory ?? bestEffortFsyncDirectory2;
3829
3763
  try {
@@ -4016,7 +3950,7 @@ function isWorkerBackedDiscovery(result) {
4016
3950
  return candidate.profile !== void 0 && candidate.embedder !== void 0;
4017
3951
  }
4018
3952
  async function discoverEmbedderWorker(agentQaRoot, options = {}) {
4019
- const projectRoot = dirname7(agentQaRoot);
3953
+ const projectRoot = dirname6(agentQaRoot);
4020
3954
  const outcome = readEmbedderWorkerRegistration(agentQaRoot);
4021
3955
  if (outcome.kind !== "parsed") return { kind: "no-worker" };
4022
3956
  const { registration } = outcome;
@@ -4588,7 +4522,7 @@ function verifiedExemplarCandidate(row, targetKeys, tokens) {
4588
4522
  return [{
4589
4523
  identity: identityTupleKey([row.filePath, row.testName]),
4590
4524
  anchorKeys: new Set(matchedKeys),
4591
- // D-15 fold: trust (neutral 1 for projection-verified rows) x recent-pass-rate x relevance.
4525
+ // Trust is a neutral 1 for projection-verified rows, so the score is pass rate times relevance.
4592
4526
  score: recentPassRate * relevance,
4593
4527
  leg: dominantAuthoringLeg(contributions),
4594
4528
  exemplar: {
@@ -4960,7 +4894,6 @@ async function readDenseScores(config, deps, intent, scope) {
4960
4894
  }
4961
4895
  }
4962
4896
  function createAuthoringReader(config, deps = {}) {
4963
- config = { ...config, priors: snapshotTrustPriors(config.priors) };
4964
4897
  return {
4965
4898
  async getAuthoringBrief(intent, scope) {
4966
4899
  const entries = hydrateRows(config, readIndexRows(config, scope), false);
@@ -4977,8 +4910,7 @@ function createAuthoringReader(config, deps = {}) {
4977
4910
  const { brief } = assembleAuthoringBrief({
4978
4911
  entries,
4979
4912
  projectionRows,
4980
- // D-16: the consumer owns the filesystem and supplies identity refs only. Projection
4981
- // identities remain a deterministic floor, while never-run tests widen the universe.
4913
+ // The consumer owns the filesystem and supplies refs; never-run tests widen the projection.
4982
4914
  knownTests,
4983
4915
  intent,
4984
4916
  scope,
@@ -5156,7 +5088,7 @@ function toInspectRecordView(entry, bundle, trust) {
5156
5088
  survivingEvents.map((event) => String(event.evidenceToken))
5157
5089
  )].sort(compareText4);
5158
5090
  const lastEventOrdinal = survivingEvents.reduce(
5159
- (latest2, event) => Math.max(latest2, event.buildOrdinal),
5091
+ (latest, event) => Math.max(latest, event.buildOrdinal),
5160
5092
  bundle.manifest.createdAtOrdinal
5161
5093
  );
5162
5094
  const trustNarrative = readTrustNarrative(entry.dir, bundle);
@@ -5209,7 +5141,7 @@ import {
5209
5141
  RecordChangeSchema,
5210
5142
  survivingOutcomeEvents as survivingOutcomeEvents5,
5211
5143
  isPromotionReceipt as isPromotionReceipt2,
5212
- strongestPromotionPath as strongestPromotionPath2
5144
+ strongestPromotionPath
5213
5145
  } from "@vostride/agent-qa-schema";
5214
5146
 
5215
5147
  // src/purge-receipt.ts
@@ -5401,9 +5333,7 @@ function diffSince(options) {
5401
5333
  recordId: bundle.manifest.id,
5402
5334
  change: "added",
5403
5335
  atOrdinal: earliestOrdinal,
5404
- // 407-04 (D-10): the appearance of a record IS the run's doing whenever the bundle
5405
- // records one — no `curationJobId` match is needed, because no event produced this
5406
- // change. A standalone bundle names no run and gets no key.
5336
+ // A run-linked bundle's appearance is the run's doing; a standalone bundle gets no run key.
5407
5337
  ...bundle.provenance.mode === "run-linked" ? { sourceRunId: bundle.provenance.runId } : {}
5408
5338
  }));
5409
5339
  eventLowerBound = earliestOrdinal;
@@ -5415,7 +5345,7 @@ function diffSince(options) {
5415
5345
  if (event.buildOrdinal <= eventLowerBound && promotion === void 0) continue;
5416
5346
  const change = directChange(bundle.manifest.id, event, bundle.provenance);
5417
5347
  if (change !== void 0) {
5418
- const promotionPath = promotion === void 0 ? void 0 : strongestPromotionPath2(receipts);
5348
+ const promotionPath = promotion === void 0 ? void 0 : strongestPromotionPath(receipts);
5419
5349
  changes.push(promotionPath === void 0 ? change : RecordChangeSchema.parse({
5420
5350
  ...change,
5421
5351
  promotionPath,
@@ -5430,13 +5360,13 @@ function diffSince(options) {
5430
5360
 
5431
5361
  // src/list-bundles.ts
5432
5362
  import { relative as relative2 } from "node:path";
5433
- function listBundles(knowledgeRoot, priors) {
5363
+ function listBundles(knowledgeRoot) {
5434
5364
  const rows = [];
5435
5365
  for (const entry of enumerateBundleDirs(knowledgeRoot)) {
5436
5366
  const outcome = loadBundle(entry.dir);
5437
5367
  if (outcome.kind !== "loaded") continue;
5438
5368
  const { bundle } = outcome;
5439
- const trust = deriveBundleTrust(bundle, priors);
5369
+ const trust = deriveBundleTrust(bundle);
5440
5370
  rows.push({
5441
5371
  bundleId: bundle.manifest.id,
5442
5372
  product: entry.product,
@@ -5605,7 +5535,7 @@ import {
5605
5535
  isPromotionReceipt as isPromotionReceipt3,
5606
5536
  KnowledgeGatesListResultSchema,
5607
5537
  standingReceiptsByGate,
5608
- strongestPromotionPath as strongestPromotionPath3
5538
+ strongestPromotionPath as strongestPromotionPath2
5609
5539
  } from "@vostride/agent-qa-schema";
5610
5540
  function gateReceiptsFor(options) {
5611
5541
  const id = asRecordId6(options.candidateId);
@@ -5616,12 +5546,11 @@ function gateReceiptsFor(options) {
5616
5546
  const standing = standingReceiptsByGate(
5617
5547
  lines.filter((line) => !isPromotionReceipt3(line))
5618
5548
  );
5619
- const path = strongestPromotionPath3(lines);
5549
+ const path = strongestPromotionPath2(lines);
5620
5550
  const gateInput = assemblePromotionGateInput({
5621
5551
  knowledgeRoot: options.knowledgeRoot,
5622
5552
  bundleDir: entry.dir,
5623
- bundle,
5624
- resolvePromotionPosture: options.resolvePromotionPosture
5553
+ bundle
5625
5554
  });
5626
5555
  return KnowledgeGatesListResultSchema.parse({
5627
5556
  kind: "found",
@@ -5632,150 +5561,20 @@ function gateReceiptsFor(options) {
5632
5561
  ...path === void 0 ? {} : { strongestPromotionPath: path },
5633
5562
  lines,
5634
5563
  standing,
5635
- // 416-DOOR: read live-verdict
5636
- live: evaluatePromotionGate(gateInput),
5637
- // 'resolved' and 'unavailable' describe the actual posture the gate judged.
5638
- posture: gateInput.gatePosture?.kind ?? "absent"
5564
+ live: evaluatePromotionGate(gateInput)
5639
5565
  });
5640
5566
  }
5641
5567
  return { kind: "not-found", recordId: options.candidateId };
5642
5568
  }
5643
5569
 
5644
- // src/gates/candidate-injection.ts
5645
- import {
5646
- asRecordId as asRecordId7,
5647
- KnowledgeCandidateInjectionResultSchema,
5648
- survivingOutcomeEvents as survivingOutcomeEvents7
5649
- } from "@vostride/agent-qa-schema";
5650
- import { renderObservationLine } from "@vostride/agent-qa-runner";
5651
- function candidateInjectionFor(options) {
5652
- const id = asRecordId7(options.candidateId);
5653
- for (const entry of enumerateMaintenanceBundleDirs(options.knowledgeRoot)) {
5654
- const bundle = loadMaintenanceBundle(entry);
5655
- if (bundle.manifest.id !== id) continue;
5656
- const frontmatter = bundle.frontmatter;
5657
- const trust = deriveBundleTrust(bundle, options.priors);
5658
- const stampedEntry = {
5659
- id,
5660
- kind: frontmatter.kind,
5661
- title: bundle.summary,
5662
- summary: bundle.summary,
5663
- trust: trust.trust,
5664
- status: trust.status,
5665
- anchors: frontmatter.anchors.map(({ normalized }) => normalized),
5666
- scope: frontmatter.scope,
5667
- validity: trust.validity.closedAtOrdinal === void 0 ? "current" : `${trust.validity.openedAtOrdinal}:${trust.validity.closedAtOrdinal}`,
5668
- servedAsCanary: false,
5669
- originClass: frontmatter.originClass
5670
- };
5671
- const line = renderBriefLine(stampedEntry).briefLine;
5672
- const target = bundle.provenance.mode === "run-linked" ? {
5673
- runId: bundle.provenance.runId,
5674
- stepIndex: bundle.provenance.stepIndex,
5675
- testId: bundle.provenance.testId,
5676
- ...bundle.provenance.sourceBuildOrdinal === void 0 ? {} : {
5677
- sourceBuildOrdinal: bundle.provenance.sourceBuildOrdinal
5678
- }
5679
- } : void 0;
5680
- return KnowledgeCandidateInjectionResultSchema.parse({
5681
- kind: "found",
5682
- injection: {
5683
- candidateId: id,
5684
- kind: frontmatter.kind,
5685
- product: entry.product,
5686
- scope: frontmatter.scope,
5687
- anchors: frontmatter.anchors,
5688
- status: trust.status,
5689
- line,
5690
- renderedLine: renderObservationLine(line),
5691
- provenance: candidateProvenanceOf(entry.dir, bundle),
5692
- ...target === void 0 ? {} : { target },
5693
- latestOrdinal: Math.max(
5694
- frontmatter.createdAtOrdinal,
5695
- ...survivingOutcomeEvents7(bundle.events).map((event) => event.buildOrdinal)
5696
- )
5697
- }
5698
- });
5699
- }
5700
- return KnowledgeCandidateInjectionResultSchema.parse({
5701
- kind: "not-found",
5702
- recordId: options.candidateId
5703
- });
5704
- }
5705
-
5706
- // src/gates/canary-posture-facts.ts
5707
- import {
5708
- asRecordId as asRecordId8,
5709
- isPromotionReceipt as isPromotionReceipt4,
5710
- standingReceiptsByGate as standingReceiptsByGate2,
5711
- strongestPromotionPath as strongestPromotionPath4,
5712
- survivingOutcomeEvents as survivingOutcomeEvents8
5713
- } from "@vostride/agent-qa-schema";
5714
- function readBundles(knowledgeRoot, resolveTrustPriors) {
5715
- return enumerateMaintenanceBundleDirs(knowledgeRoot).map((entry) => {
5716
- const bundle = loadMaintenanceBundle(entry);
5717
- const lines = readGateReceipts(entry.dir, bundle.manifest.id) ?? [];
5718
- return { ...entry, bundle, lines, active: deriveBundleTrust(bundle, resolveTrustPriors?.()).status === "active" };
5719
- });
5720
- }
5721
- function latest(ordinals) {
5722
- return ordinals.length === 0 ? void 0 : Math.max(...ordinals);
5723
- }
5724
- function canaryPostureFactsFor(input) {
5725
- const id = asRecordId8(input.candidateId);
5726
- const rows = readBundles(input.knowledgeRoot, input.resolveTrustPriors);
5727
- const candidate = rows.find((row) => row.bundle.manifest.id === id);
5728
- if (candidate === void 0) return { kind: "not-found" };
5729
- const scope = candidate.bundle.frontmatter.scope;
5730
- if (scope.tier !== "product" || input.scope.tier !== "product" || scope.key !== input.scope.key) return { kind: "not-found" };
5731
- const receipts = candidate.lines.filter((line) => !isPromotionReceipt4(line));
5732
- const pass = standingReceiptsByGate2(receipts).find((row) => row.gate === 1 && row.verdict === "pass");
5733
- const lowerTrustActiveGate1Digest = candidate.active && strongestPromotionPath4(candidate.lines) === "gate1-lower-trust" && survivingOutcomeEvents8(candidate.bundle.events).some((event) => event.type === "promoted") && pass !== void 0 && candidate.lines.some((line) => isPromotionReceipt4(line) && line.promotionPath === "gate1-lower-trust" && line.citedReceiptDigests.includes(pass.receiptDigest)) ? pass.receiptDigest : void 0;
5734
- const latestAttributionOrdinal = latest(survivingOutcomeEvents8(candidate.bundle.events).filter((event) => ["confirmed", "contradicted", "helpful", "harmful"].includes(event.type)).map((event) => event.buildOrdinal));
5735
- const latestGate2Ordinal = latest(receipts.filter((row) => row.gate === 2).map((row) => row.producedAtOrdinal));
5736
- const active = rows.filter((row) => row.active && row.product === candidate.product && row.bundle.frontmatter.scope.tier === "product" && row.bundle.frontmatter.scope.key === scope.key);
5737
- return {
5738
- kind: "found",
5739
- ...pass === void 0 ? {} : { gate1PassOrdinal: pass.producedAtOrdinal, gate1PassDigest: pass.receiptDigest },
5740
- ...lowerTrustActiveGate1Digest === void 0 ? {} : { lowerTrustActiveGate1Digest },
5741
- ...latestAttributionOrdinal === void 0 ? {} : { latestAttributionOrdinal },
5742
- ...latestGate2Ordinal === void 0 ? {} : { latestGate2Ordinal },
5743
- activeInScope: active.length,
5744
- lowerTrustActiveInScope: active.filter((row) => strongestPromotionPath4(row.lines) === "gate1-lower-trust").length
5745
- };
5746
- }
5747
- function standingReceiptDigestsFor(input) {
5748
- return readBundles(input.knowledgeRoot).flatMap((row) => standingReceiptsByGate2(
5749
- row.lines.filter((line) => !isPromotionReceipt4(line))
5750
- ).map((receipt) => ({
5751
- candidateId: receipt.candidateId,
5752
- gate: receipt.gate,
5753
- verdict: receipt.verdict,
5754
- ..."corpusVersion" in receipt ? { corpusDigest: receipt.corpusVersion.corpusDigest } : {},
5755
- producedAtOrdinal: receipt.producedAtOrdinal
5756
- })));
5757
- }
5758
- function lowerTrustSharesFor(input) {
5759
- const products = /* @__PURE__ */ new Map();
5760
- for (const row of readBundles(input.knowledgeRoot, input.resolveTrustPriors)) {
5761
- const share = products.get(row.product) ?? { product: row.product, active: 0, lowerTrust: 0 };
5762
- products.set(row.product, share);
5763
- if (!row.active) continue;
5764
- share.active += 1;
5765
- if (strongestPromotionPath4(row.lines) === "gate1-lower-trust") share.lowerTrust += 1;
5766
- }
5767
- return [...products.values()];
5768
- }
5769
-
5770
5570
  // src/feedback/mark-evidence-plan.ts
5771
- import { basename as basename7 } from "node:path";
5571
+ import { basename as basename6 } from "node:path";
5772
5572
  import {
5773
5573
  asEvidenceToken,
5774
- asRecordId as asRecordId9,
5574
+ asRecordId as asRecordId7,
5775
5575
  deriveEvidenceToken,
5776
5576
  eventDedupKey,
5777
- exercisedAnchors,
5778
- isPromotionReceipt as isPromotionReceipt5
5577
+ exercisedAnchors
5779
5578
  } from "@vostride/agent-qa-schema";
5780
5579
  var MARK_EVIDENCE_TOKEN_PREFIX = "mark:";
5781
5580
  function markEvidenceEvent(effect, markId, buildOrdinal) {
@@ -5804,7 +5603,7 @@ function planMarkEvidence(input) {
5804
5603
  ...input.mark.kind === "false-pass" && input.handoff === void 0 ? { correlationIncomplete: true } : {}
5805
5604
  };
5806
5605
  const served = new Set(input.servedRecordIds);
5807
- const targets = /* @__PURE__ */ new Set([...served, ...input.mark.kind === "false-pass" ? enumerateBundleDirs(input.knowledgeRoot).map((entry) => basename7(entry.dir)) : []]);
5606
+ const targets = /* @__PURE__ */ new Set([...served, ...input.mark.kind === "false-pass" ? enumerateBundleDirs(input.knowledgeRoot).map((entry) => basename6(entry.dir)) : []]);
5808
5607
  for (const recordId of targets) {
5809
5608
  let entry;
5810
5609
  try {
@@ -5826,7 +5625,7 @@ function planMarkEvidence(input) {
5826
5625
  for (const member of input.handoff?.tests ?? []) {
5827
5626
  for (const step of member.steps) {
5828
5627
  const canaryId = canaryOutcomeObservationId({
5829
- candidateId: asRecordId9(recordId),
5628
+ candidateId: asRecordId7(recordId),
5830
5629
  runId: input.mark.runId,
5831
5630
  testId: member.testId,
5832
5631
  testIndex: member.testIndex,
@@ -5843,18 +5642,6 @@ function planMarkEvidence(input) {
5843
5642
  }
5844
5643
  }
5845
5644
  }
5846
- for (const receipt of readGateReceipts(entry.dir, asRecordId9(recordId)) ?? []) {
5847
- if (!isPromotionReceipt5(receipt) && receipt.gate === 2 && receipt.runId === input.mark.runId) {
5848
- observations.add(receipt.attributedObservationId);
5849
- for (const anchor of bundleAnchors) {
5850
- evidenceTokens.add(deriveEvidenceToken({
5851
- attributingObservationId: receipt.attributedObservationId,
5852
- anchor,
5853
- buildOrdinal: receipt.producedAtOrdinal
5854
- }));
5855
- }
5856
- }
5857
- }
5858
5645
  const jobs = new Set(input.curationJobIds ?? []);
5859
5646
  const provenance = bundle.provenance;
5860
5647
  if (provenance.mode === "run-linked" && provenance.runId === input.mark.runId && provenance.curationJobId !== void 0) jobs.add(provenance.curationJobId);
@@ -5927,8 +5714,6 @@ export {
5927
5714
  QUARANTINE_LEDGER_FILENAME,
5928
5715
  canaryAttributionsFor,
5929
5716
  canaryOutcomeObservationId,
5930
- canaryPostureFactsFor,
5931
- candidateInjectionFor,
5932
5717
  createAuthoringReader,
5933
5718
  diffSince,
5934
5719
  foldQuarantineLedgerState,
@@ -5936,7 +5721,6 @@ export {
5936
5721
  hydrateRows,
5937
5722
  inspectRecords,
5938
5723
  listBundles,
5939
- lowerTrustSharesFor,
5940
5724
  markEvidenceEvent,
5941
5725
  openKnowledgeReader2 as openKnowledgeReader,
5942
5726
  planMarkEvidence,
@@ -5945,7 +5729,6 @@ export {
5945
5729
  readIndexRows,
5946
5730
  readQuarantineLedger,
5947
5731
  showRecord,
5948
- showRecords,
5949
- standingReceiptDigestsFor
5732
+ showRecords
5950
5733
  };
5951
5734
  //# sourceMappingURL=reader.js.map