@vostride/agent-qa-knowledge-local 0.2.3 → 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/index.cjs CHANGED
@@ -102,7 +102,6 @@ __export(index_exports, {
102
102
  NativeEmbeddingDimensionError: () => NativeEmbeddingDimensionError,
103
103
  NativeEmbeddingModuleLoadError: () => NativeEmbeddingModuleLoadError,
104
104
  PAYLOAD_BENEFITS: () => PAYLOAD_BENEFITS,
105
- PAYLOAD_STATE_VALIDITIES: () => PAYLOAD_STATE_VALIDITIES,
106
105
  PURGE_RECEIPT_SCHEMA_VERSION: () => PURGE_RECEIPT_SCHEMA_VERSION,
107
106
  PolicyTextRefusedError: () => PolicyTextRefusedError,
108
107
  PurgeChronologyRequiredError: () => PurgeChronologyRequiredError,
@@ -164,7 +163,6 @@ __export(index_exports, {
164
163
  authoredCheckpointSchema: () => authoredCheckpointSchema,
165
164
  buildCurationCandidateAddressFields: () => buildCurationCandidateAddressFields,
166
165
  buildRetrievalQuery: () => buildRetrievalQuery,
167
- canaryPostureFactsFor: () => canaryPostureFactsFor,
168
166
  candidateContentAddress: () => candidateContentAddress,
169
167
  claimNextJob: () => claimNextJob,
170
168
  claimedCandidateDir: () => claimedCandidateDir,
@@ -233,7 +231,6 @@ __export(index_exports, {
233
231
  listTestsInFile: () => listTestsInFile,
234
232
  loadBundle: () => loadBundle,
235
233
  loadFloorAssets: () => loadFloorAssets,
236
- lowerTrustSharesFor: () => lowerTrustSharesFor,
237
234
  markEvidenceEvent: () => markEvidenceEvent,
238
235
  materializePolicy: () => materializePolicy,
239
236
  openAddressingLedger: () => openAddressingLedger,
@@ -264,7 +261,6 @@ __export(index_exports, {
264
261
  queuedCandidateDir: () => queuedCandidateDir,
265
262
  queuedRoot: () => queuedRoot,
266
263
  readCanonicalBundleAnchors: () => readCanonicalBundleAnchors,
267
- readCanonicalBundleStateDigests: () => readCanonicalBundleStateDigests,
268
264
  readCurationCandidatePayload: () => readCurationCandidatePayload,
269
265
  readCurationEffects: () => readCurationEffects,
270
266
  readEmbedderWorkerRegistration: () => readEmbedderWorkerRegistration,
@@ -315,10 +311,9 @@ __export(index_exports, {
315
311
  showRecord: () => showRecord,
316
312
  sightEntity: () => sightEntity,
317
313
  sliceAuthoredCheckpoint: () => sliceAuthoredCheckpoint,
318
- standingReceiptDigestsFor: () => standingReceiptDigestsFor,
319
314
  suiteFingerprintDeltas: () => suiteFingerprintDeltas,
320
315
  sweepEntityIndex: () => sweepEntityIndex,
321
- testFingerprintElements: () => import_agent_qa_schema46.testFingerprintElements,
316
+ testFingerprintElements: () => import_agent_qa_schema45.testFingerprintElements,
322
317
  toInspectRecordView: () => toInspectRecordView,
323
318
  triageMark: () => triageMark,
324
319
  vecTableName: () => vecTableName,
@@ -610,12 +605,12 @@ function verifyBundleIntegrity(bundleDir2) {
610
605
  }
611
606
  return { ok: violations.length === 0, violations };
612
607
  }
613
- function deriveBundleTrust(loaded, priors) {
608
+ function deriveBundleTrust(loaded) {
614
609
  return (0, import_agent_qa_schema.foldBundleTrust)(loaded.events, {
615
610
  originClass: loaded.provenance.originClass,
616
611
  evidenceIncomplete: loaded.manifest.evidenceIncomplete,
617
612
  createdAtOrdinal: loaded.manifest.createdAtOrdinal
618
- }, priors);
613
+ });
619
614
  }
620
615
 
621
616
  // src/maintenance-scan.ts
@@ -2040,11 +2035,11 @@ function anchorMatches(bundle, queryAnchor) {
2040
2035
  return normalized.t === "el" && queryAnchor.t === "el" && normalized.role === queryAnchor.role && normalized.name === queryAnchor.name;
2041
2036
  });
2042
2037
  }
2043
- function servableHit(dir, priors) {
2038
+ function servableHit(dir) {
2044
2039
  const outcome = loadBundle(dir.dir);
2045
2040
  if (outcome.kind !== "loaded") return void 0;
2046
2041
  if (!verifyBundleIntegrity(dir.dir).ok) return void 0;
2047
- const trustState = deriveBundleTrust(outcome.bundle, priors);
2042
+ const trustState = deriveBundleTrust(outcome.bundle);
2048
2043
  return isServable(trustState) ? toHit(outcome.bundle, trustState, dir.product) : void 0;
2049
2044
  }
2050
2045
  function scanBundlesWithPosture(opts, servingOnly) {
@@ -2056,7 +2051,7 @@ function scanBundlesWithPosture(opts, servingOnly) {
2056
2051
  const outcome = loadBundle(entry.dir);
2057
2052
  if (outcome.kind !== "loaded") continue;
2058
2053
  if (!verifyBundleIntegrity(entry.dir).ok) continue;
2059
- const trustState = deriveBundleTrust(outcome.bundle, opts.priors);
2054
+ const trustState = deriveBundleTrust(outcome.bundle);
2060
2055
  if (servingOnly && !isServable(trustState)) continue;
2061
2056
  if (!textMatches(outcome.bundle, queryTokens)) continue;
2062
2057
  if (!anchorMatches(outcome.bundle, queryAnchor)) continue;
@@ -2076,7 +2071,7 @@ function scanBundlesForRetrieval(opts) {
2076
2071
  function scanBundleById(opts) {
2077
2072
  for (const entry of enumerateBundleDirs(opts.knowledgeRoot)) {
2078
2073
  if ((0, import_node_path6.basename)(entry.dir) !== opts.bundleId) continue;
2079
- const hit = servableHit(entry, opts.priors);
2074
+ const hit = servableHit(entry);
2080
2075
  if (hit !== void 0) return hit;
2081
2076
  }
2082
2077
  return void 0;
@@ -2445,9 +2440,7 @@ function diffSince(options) {
2445
2440
  recordId: bundle.manifest.id,
2446
2441
  change: "added",
2447
2442
  atOrdinal: earliestOrdinal,
2448
- // 407-04 (D-10): the appearance of a record IS the run's doing whenever the bundle
2449
- // records one — no `curationJobId` match is needed, because no event produced this
2450
- // change. A standalone bundle names no run and gets no key.
2443
+ // A run-linked bundle's appearance is the run's doing; a standalone bundle gets no run key.
2451
2444
  ...bundle.provenance.mode === "run-linked" ? { sourceRunId: bundle.provenance.runId } : {}
2452
2445
  }));
2453
2446
  eventLowerBound = earliestOrdinal;
@@ -2535,12 +2528,12 @@ function foldCurationSnapshot(effects) {
2535
2528
  }
2536
2529
  const rows = [...groups].map(([recordId, changes]) => {
2537
2530
  const bucket = import_agent_qa_schema6.CURATION_BUCKET_PRECEDENCE.find((value) => changes.some((e) => e.bucket === value));
2538
- const latest2 = changes.filter((e) => e.bucket === "superseded").sort((a, b) => b.change.atOrdinal - a.change.atOrdinal)[0];
2531
+ const latest = changes.filter((e) => e.bucket === "superseded").sort((a, b) => b.change.atOrdinal - a.change.atOrdinal)[0];
2539
2532
  return {
2540
2533
  recordId,
2541
2534
  bucket,
2542
2535
  changes,
2543
- ...latest2 === void 0 ? {} : { byRecordId: latest2.change.byRecordId }
2536
+ ...latest === void 0 ? {} : { byRecordId: latest.change.byRecordId }
2544
2537
  };
2545
2538
  });
2546
2539
  for (const row of rows) {
@@ -2700,7 +2693,6 @@ function publishStagedQueueEntry(stagingDir, finalDir, queueDir) {
2700
2693
  // src/canary-emit.ts
2701
2694
  var CANARY_QUEUE_SCHEMA_VERSION = 2;
2702
2695
  var PAYLOAD_BENEFITS = ["exercised-benefited", "rode-along", "exercised-harmed"];
2703
- var PAYLOAD_STATE_VALIDITIES = ["valid", "stale", "unknown"];
2704
2696
  var canaryOutcomePayloadBaseShape = {
2705
2697
  jobKind: import_zod5.z.literal("canary-outcome"),
2706
2698
  candidateId: import_zod5.z.string().min(1),
@@ -2714,28 +2706,10 @@ var canaryOutcomePayloadBaseShape = {
2714
2706
  attribution: import_zod5.z.string(),
2715
2707
  briefDigest: import_zod5.z.string().min(1)
2716
2708
  };
2717
- var count = import_zod5.z.number().int().nonnegative();
2718
- var digest2 = import_zod5.z.string().regex(/^[0-9a-f]{64}$/);
2719
2709
  var canaryOutcomePayloadSchema = import_zod5.z.object({
2720
2710
  ...canaryOutcomePayloadBaseShape,
2721
2711
  schemaVersion: import_zod5.z.literal(CANARY_QUEUE_SCHEMA_VERSION),
2722
- benefit: import_zod5.z.enum(PAYLOAD_BENEFITS),
2723
- stateValidity: import_zod5.z.enum(PAYLOAD_STATE_VALIDITIES),
2724
- corpusDigest: digest2.optional(),
2725
- observedStateDigest: digest2.optional(),
2726
- ablation: import_zod5.z.object({
2727
- crossCheck: import_zod5.z.enum(import_agent_qa_schema7.CROSS_CHECKS),
2728
- k: import_zod5.z.number().int().min(3),
2729
- baseSeed: import_zod5.z.number().int(),
2730
- seeds: import_zod5.z.array(import_zod5.z.number().int()),
2731
- seedHonored: import_zod5.z.boolean(),
2732
- spend: import_zod5.z.object({
2733
- modelCalls: count,
2734
- screens: count,
2735
- promptTokens: count,
2736
- completionTokens: count
2737
- }).strict()
2738
- }).strict().optional()
2712
+ benefit: import_zod5.z.enum(PAYLOAD_BENEFITS)
2739
2713
  }).strict();
2740
2714
  var diagnosticShape = { emittedAt: import_zod5.z.string().optional() };
2741
2715
  var canaryOutcomeAddressFieldsSchema = canaryOutcomePayloadSchema.extend(diagnosticShape);
@@ -2763,10 +2737,6 @@ function enqueueCanaryOutcome(knowledgeRoot, outcome) {
2763
2737
  stepIndex: outcome.stepIndex,
2764
2738
  outcome: outcome.runOutcome,
2765
2739
  benefit: outcome.benefit,
2766
- stateValidity: outcome.stateValidity,
2767
- ...outcome.corpusDigest === void 0 ? {} : { corpusDigest: outcome.corpusDigest },
2768
- ...outcome.observedStateDigest === void 0 ? {} : { observedStateDigest: outcome.observedStateDigest },
2769
- ...outcome.ablation === void 0 ? {} : { ablation: outcome.ablation },
2770
2740
  exercisedAnchor: outcome.exercisedAnchor,
2771
2741
  attribution: outcome.attribution,
2772
2742
  briefDigest: outcome.briefDigest
@@ -2807,7 +2777,7 @@ var ADDRESSING_LEDGER_DB_FILE = "entity-addresses.db";
2807
2777
  var AddressingLedgerSchemaVersionError = class extends Error {
2808
2778
  constructor(path, expected, found) {
2809
2779
  super(
2810
- `The addressing ledger at ${path} is stamped schema version ${String(found)}, but this build reads version ${String(expected)}. The ledger is never migrated and never rebuilt (D-02/D-04); move the file aside if it is a development artifact.`
2780
+ `The addressing ledger at ${path} is stamped schema version ${String(found)}, but this build reads version ${String(expected)}. The ledger is never migrated and never rebuilt; move the file aside if it is a development artifact.`
2811
2781
  );
2812
2782
  this.path = path;
2813
2783
  this.expected = expected;
@@ -2835,19 +2805,14 @@ var SCHEMA_STATEMENTS = [
2835
2805
  `CREATE TRIGGER IF NOT EXISTS addresses_are_append_only
2836
2806
  BEFORE DELETE ON addresses
2837
2807
  BEGIN
2838
- SELECT RAISE(ABORT, 'the addressing ledger never deletes an address (387 D-04)');
2808
+ SELECT RAISE(ABORT, 'the addressing ledger never deletes an address');
2839
2809
  END`,
2840
2810
  `CREATE TRIGGER IF NOT EXISTS addresses_are_immutable
2841
2811
  BEFORE UPDATE ON addresses
2842
2812
  BEGIN
2843
- SELECT RAISE(ABORT, 'a minted address never changes (387 D-04)');
2813
+ SELECT RAISE(ABORT, 'a minted address never changes');
2844
2814
  END`,
2845
- // Renames live in their OWN table rather than as a nullable column on `addresses`, and the
2846
- // reason is the trigger directly above: a rename is a fact recorded LATER about a row that
2847
- // must never change, so writing it onto the address row would require exactly the statement
2848
- // this ledger forbids. Additive, and the stamped version does not move — nothing between
2849
- // this milestone's releases has written a v1 file, and `IF NOT EXISTS` heals a development
2850
- // one. D-04's never-rebuild law is about ORDINALS, which no statement here touches.
2815
+ // Renames get their own table: writing one onto an immutable address row would need an update.
2851
2816
  `CREATE TABLE IF NOT EXISTS target_renames (
2852
2817
  from_slug TEXT NOT NULL PRIMARY KEY,
2853
2818
  to_slug TEXT NOT NULL,
@@ -3257,10 +3222,7 @@ function ensureRunOutcomeTables(db) {
3257
3222
  UNIQUE (product, file_path, test_name, fingerprint, build_ordinal, run_id)
3258
3223
  );
3259
3224
 
3260
- -- 393 D-15: gate 3's comparison substrate, folded by the same pass and cleared by the same
3261
- -- rebuild as the tables above. One row per fingerprint element, ordered by seq, keyed by the
3262
- -- stable test identity; run_id and build_ordinal are the provenance the fold's
3263
- -- newest-evidence-wins replacement rule compares on (see projection/suite-fingerprints.ts).
3225
+ -- run_id and build_ordinal are what the fold's newest-evidence-wins replacement compares on.
3264
3226
  CREATE TABLE IF NOT EXISTS suite_fingerprints (
3265
3227
  product TEXT NOT NULL,
3266
3228
  file_path TEXT NOT NULL,
@@ -3272,11 +3234,7 @@ function ensureRunOutcomeTables(db) {
3272
3234
  PRIMARY KEY (product, file_path, test_name, seq)
3273
3235
  );
3274
3236
 
3275
- -- 393 CR-02: the stored fold-semantics stamp for the five tables above. Singleton by
3276
- -- construction (the CHECK admits exactly one row) because "which semantics produced this
3277
- -- family" is one fact about one derived index, and a second row could only ever be a second
3278
- -- answer to it. Absent is a legal state and means MISMATCH: a pre-stamp index and an index
3279
- -- whose file was deleted both read as absent, and both want the same rebuild.
3237
+ -- One fold-semantics stamp for the tables above; an absent row reads as a mismatch.
3280
3238
  CREATE TABLE IF NOT EXISTS run_outcome_projection_version (
3281
3239
  id INTEGER PRIMARY KEY CHECK (id = 1),
3282
3240
  version INTEGER NOT NULL
@@ -3989,12 +3947,12 @@ function compareSnapshots(left, right) {
3989
3947
  }
3990
3948
  function resolveAsOfBuildOrdinal(bundles, explicit) {
3991
3949
  if (explicit !== void 0) return explicit;
3992
- let latest2 = 0;
3950
+ let latest = 0;
3993
3951
  for (const bundle of bundles) {
3994
- latest2 = Math.max(latest2, bundle.createdAtOrdinal);
3995
- for (const event of bundle.events) latest2 = Math.max(latest2, event.buildOrdinal);
3952
+ latest = Math.max(latest, bundle.createdAtOrdinal);
3953
+ for (const event of bundle.events) latest = Math.max(latest, event.buildOrdinal);
3996
3954
  }
3997
- return latest2;
3955
+ return latest;
3998
3956
  }
3999
3957
  function windowOpenOrdinal(asOfBuildOrdinal, windowBuilds) {
4000
3958
  if (!Number.isInteger(windowBuilds) || windowBuilds < 1) {
@@ -4100,12 +4058,6 @@ function foldFirstSeenAnchorsByScope(bundles, options) {
4100
4058
  }
4101
4059
 
4102
4060
  // src/promotion-gate-input.ts
4103
- function snapshotTrustPriors(priors) {
4104
- if (priors === void 0) return void 0;
4105
- const snapshot = (0, import_agent_qa_schema13.guardTrustPriorTable)(priors);
4106
- for (const row of Object.values(snapshot)) Object.freeze(row);
4107
- return Object.freeze(snapshot);
4108
- }
4109
4061
  function promotionObservations(bundleDir2) {
4110
4062
  const file = (0, import_node_path15.join)(bundleDir2, "observations.jsonl");
4111
4063
  if (!(0, import_node_fs15.existsSync)(file)) return [];
@@ -4125,20 +4077,12 @@ function memoryOffForBundle(knowledgeRoot, bundle) {
4125
4077
  );
4126
4078
  }
4127
4079
  function assemblePromotionGateInput(input) {
4128
- const trust = deriveBundleTrust(input.bundle, input.priors);
4080
+ const trust = deriveBundleTrust(input.bundle);
4129
4081
  const survivingEvents = (0, import_agent_qa_schema13.survivingOutcomeEvents)(input.bundle.events);
4130
4082
  const runLinkedProvenance = input.bundle.provenance.mode === "run-linked" ? input.bundle.provenance : void 0;
4131
4083
  const gateLines = readGateReceipts(input.bundleDir, input.bundle.manifest.id) ?? [];
4132
- const provenance = candidateProvenanceOf(input.bundleDir, input.bundle);
4133
- const posture = input.resolvePromotionPosture?.({
4134
- id: input.bundle.manifest.id,
4135
- product: (0, import_node_path15.basename)((0, import_node_path15.dirname)((0, import_node_path15.dirname)(input.bundleDir))),
4136
- scope: input.bundle.frontmatter.scope,
4137
- provenance
4138
- });
4139
4084
  return {
4140
4085
  gateReceipts: gateLines.filter((line) => !(0, import_agent_qa_schema13.isPromotionReceipt)(line)),
4141
- ...posture === void 0 ? {} : { gatePosture: posture },
4142
4086
  kind: input.bundle.frontmatter.kind,
4143
4087
  ...input.bundle.frontmatter.subtype === void 0 ? {} : { subtype: input.bundle.frontmatter.subtype },
4144
4088
  status: trust.status,
@@ -4159,28 +4103,15 @@ function assemblePromotionGateInput(input) {
4159
4103
  memoryOffForAnchorGroup: memoryOffForBundle(input.knowledgeRoot, input.bundle)
4160
4104
  };
4161
4105
  }
4162
- function candidateProvenanceOf(bundleDir2, bundle) {
4163
- const runLinked = bundle.provenance.mode === "run-linked" ? bundle.provenance : void 0;
4164
- const gateLines = readGateReceipts(bundleDir2, bundle.manifest.id) ?? [];
4165
- return {
4166
- runIds: runLinked === void 0 ? [] : [runLinked.runId],
4167
- receiptDigests: gateLines.map((line) => line.receiptDigest),
4168
- capturedAtOrdinals: [...new Set([
4169
- ...runLinked?.sourceBuildOrdinal === void 0 ? [] : [runLinked.sourceBuildOrdinal],
4170
- ...(0, import_agent_qa_schema13.survivingOutcomeEvents)(bundle.events).map((event) => event.buildOrdinal)
4171
- ].filter(Number.isInteger))].sort((left, right) => left - right)
4172
- };
4173
- }
4174
4106
 
4175
4107
  // src/trust-prior-context.ts
4176
4108
  var import_node_crypto6 = require("node:crypto");
4177
4109
  var import_agent_qa_schema14 = require("@vostride/agent-qa-schema");
4178
- function effectivePriorDigest(priors) {
4179
- const table = priors === void 0 ? void 0 : (0, import_agent_qa_schema14.guardTrustPriorTable)(priors);
4180
- return (0, import_node_crypto6.createHash)("sha256").update((0, import_agent_qa_schema14.canonicalJson)({ ...import_agent_qa_schema14.ORIGIN_PRIORS, ...table })).digest("hex");
4110
+ function effectivePriorDigest() {
4111
+ return (0, import_node_crypto6.createHash)("sha256").update((0, import_agent_qa_schema14.canonicalJson)({ ...import_agent_qa_schema14.ORIGIN_PRIORS })).digest("hex");
4181
4112
  }
4182
- function indexTrustEpochMatches(db, digest3) {
4183
- return db.prepare("SELECT v FROM meta WHERE k = 'trust_prior_digest'").get()?.v === digest3 && db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest3) === void 0;
4113
+ function indexTrustEpochMatches(db, digest2) {
4114
+ 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;
4184
4115
  }
4185
4116
  var TrustPriorEpochMismatch = class extends Error {
4186
4117
  constructor() {
@@ -4258,7 +4189,7 @@ function safeBundleDir(knowledgeRoot, hit) {
4258
4189
  }
4259
4190
  return (0, import_node_path16.join)(knowledgeRoot, "memory", hit.product, "bundles", hit.bundleId);
4260
4191
  }
4261
- function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
4192
+ function recheckAuthoritativeHits(knowledgeRoot, hits, audit) {
4262
4193
  const refreshed = [];
4263
4194
  for (const hit of hits) {
4264
4195
  const bundleDir2 = safeBundleDir(knowledgeRoot, hit);
@@ -4267,7 +4198,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
4267
4198
  if (!verifyBundleIntegrity(bundleDir2).ok) continue;
4268
4199
  const outcome = loadBundle(bundleDir2);
4269
4200
  if (outcome.kind !== "loaded" || outcome.bundle.manifest.id !== hit.bundleId) continue;
4270
- const trust = deriveBundleTrust(outcome.bundle, priors);
4201
+ const trust = deriveBundleTrust(outcome.bundle);
4271
4202
  if (!audit && !isServable(trust)) continue;
4272
4203
  refreshed.push({
4273
4204
  ...hit,
@@ -4287,8 +4218,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
4287
4218
  vettedCandidateInput: assemblePromotionGateInput({
4288
4219
  knowledgeRoot,
4289
4220
  bundleDir: bundleDir2,
4290
- bundle: outcome.bundle,
4291
- priors
4221
+ bundle: outcome.bundle
4292
4222
  })
4293
4223
  });
4294
4224
  } catch {
@@ -4296,8 +4226,8 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
4296
4226
  }
4297
4227
  return refreshed;
4298
4228
  }
4299
- function recheckHits(knowledgeRoot, hits, priors) {
4300
- return recheckAuthoritativeHits(knowledgeRoot, hits, false, priors).map((hit) => {
4229
+ function recheckHits(knowledgeRoot, hits) {
4230
+ return recheckAuthoritativeHits(knowledgeRoot, hits, false).map((hit) => {
4301
4231
  const {
4302
4232
  anchors: _anchors,
4303
4233
  scope: _scope,
@@ -4366,52 +4296,50 @@ function cosineDistance(query, candidate2) {
4366
4296
  }
4367
4297
  return 1 - dot;
4368
4298
  }
4369
- function scanReader(knowledgeRoot, priors) {
4299
+ function scanReader(knowledgeRoot) {
4370
4300
  const reader = {
4371
4301
  source: "scan",
4372
4302
  vec: "none",
4373
4303
  getById(bundleId) {
4374
- return scanBundleById({ knowledgeRoot, bundleId, priors });
4304
+ return scanBundleById({ knowledgeRoot, bundleId });
4375
4305
  },
4376
4306
  searchLexical(text, opts = {}) {
4377
- return scanBundles({ knowledgeRoot, text, ...opts, priors });
4307
+ return scanBundles({ knowledgeRoot, text, ...opts });
4378
4308
  },
4379
4309
  lookupAnchor(anchor, opts = {}) {
4380
- return scanBundles({ knowledgeRoot, anchor: (0, import_agent_qa_schema15.normalizeAnchor)(anchor), ...opts, priors });
4310
+ return scanBundles({ knowledgeRoot, anchor: (0, import_agent_qa_schema15.normalizeAnchor)(anchor), ...opts });
4381
4311
  },
4382
4312
  searchDense() {
4383
4313
  return [];
4384
4314
  },
4385
4315
  recheck(hits) {
4386
- return recheckHits(knowledgeRoot, hits, priors);
4316
+ return recheckHits(knowledgeRoot, hits);
4387
4317
  },
4388
4318
  close() {
4389
4319
  },
4390
4320
  async [RUN_RETRIEVAL](operation) {
4391
4321
  return operation({
4392
4322
  knowledgeRoot,
4393
- priors,
4394
4323
  source: "scan",
4395
4324
  vec: "none",
4396
4325
  connection: void 0,
4397
4326
  reader,
4398
4327
  scan: (text, anchor) => scanBundlesForRetrieval({
4399
4328
  knowledgeRoot,
4400
- priors,
4401
4329
  ...text === void 0 ? {} : { text },
4402
4330
  ...anchor === void 0 ? {} : { anchor }
4403
4331
  }),
4404
- recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors)
4332
+ recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
4405
4333
  });
4406
4334
  }
4407
4335
  };
4408
4336
  return reader;
4409
4337
  }
4410
- function indexReader(knowledgeRoot, connection, priors) {
4338
+ function indexReader(knowledgeRoot, connection) {
4411
4339
  let closed = false;
4412
4340
  const { db } = connection;
4413
4341
  const activeProfile = resolveActiveProfile(db);
4414
- const priorDigest = effectivePriorDigest(priors);
4342
+ const priorDigest = effectivePriorDigest();
4415
4343
  let snapshotDepth = 0;
4416
4344
  function assertTrustEpoch() {
4417
4345
  if (!indexTrustEpochMatches(db, priorDigest)) throw new TrustPriorEpochMismatch();
@@ -4429,7 +4357,7 @@ function indexReader(knowledgeRoot, connection, priors) {
4429
4357
  });
4430
4358
  }
4431
4359
  function recheckCurrent(hits) {
4432
- return recheckHits(knowledgeRoot, hits, priors);
4360
+ return recheckHits(knowledgeRoot, hits);
4433
4361
  }
4434
4362
  function denseVec02(embedding, opts) {
4435
4363
  const k = queryLimit(opts.k);
@@ -4600,13 +4528,12 @@ function indexReader(knowledgeRoot, connection, priors) {
4600
4528
  try {
4601
4529
  return await operation({
4602
4530
  knowledgeRoot,
4603
- priors,
4604
4531
  source: "index",
4605
4532
  vec: connection.vec,
4606
4533
  connection,
4607
4534
  reader: snapshotReader,
4608
4535
  scan: void 0,
4609
- recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors)
4536
+ recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
4610
4537
  });
4611
4538
  } finally {
4612
4539
  snapshotDepth -= 1;
@@ -4623,8 +4550,8 @@ function indexReader(knowledgeRoot, connection, priors) {
4623
4550
  };
4624
4551
  return snapshotReader;
4625
4552
  }
4626
- function operationDegradingReader(knowledgeRoot, connection, priors) {
4627
- let delegate = indexReader(knowledgeRoot, connection, priors);
4553
+ function operationDegradingReader(knowledgeRoot, connection) {
4554
+ let delegate = indexReader(knowledgeRoot, connection);
4628
4555
  let closed = false;
4629
4556
  function invoke(operation) {
4630
4557
  if (delegate.source === "scan") return operation(delegate);
@@ -4639,7 +4566,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
4639
4566
  `derived index operation failed: ${errorMessage2(error)}`
4640
4567
  );
4641
4568
  }
4642
- delegate = scanReader(knowledgeRoot, priors);
4569
+ delegate = scanReader(knowledgeRoot);
4643
4570
  return operation(delegate);
4644
4571
  }
4645
4572
  }
@@ -4656,7 +4583,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
4656
4583
  `derived index operation failed: ${errorMessage2(error)}`
4657
4584
  );
4658
4585
  }
4659
- delegate = scanReader(knowledgeRoot, priors);
4586
+ delegate = scanReader(knowledgeRoot);
4660
4587
  return operation(delegate);
4661
4588
  }
4662
4589
  }
@@ -4705,9 +4632,9 @@ function withKnowledgeReadSnapshot(reader, operation) {
4705
4632
  }
4706
4633
  return reader[RUN_RETRIEVAL](operation);
4707
4634
  }
4708
- function degrade(knowledgeRoot, reason, detail, priors) {
4635
+ function degrade(knowledgeRoot, reason, detail) {
4709
4636
  requestRebuildBestEffort(knowledgeRoot, reason, detail);
4710
- return scanReader(knowledgeRoot, priors);
4637
+ return scanReader(knowledgeRoot);
4711
4638
  }
4712
4639
  function classifyIndexFaceWithConnection(knowledgeRoot, opts) {
4713
4640
  if (!(0, import_node_fs16.existsSync)(indexDbPath(knowledgeRoot))) {
@@ -4783,15 +4710,14 @@ function indexFileChangedSince(knowledgeRoot, before) {
4783
4710
  return after === void 0 || after.walPresent || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs || after.size !== before.size || after.ino !== before.ino;
4784
4711
  }
4785
4712
  function openKnowledgeReader(knowledgeRoot, opts = {}) {
4786
- const priors = snapshotTrustPriors(opts.priors);
4787
4713
  const result = classifyIndexFaceWithConnection(knowledgeRoot, {
4788
4714
  ...opts,
4789
4715
  inspectCheckpointedImmutably: false
4790
4716
  });
4791
4717
  if (result.connection === void 0) {
4792
- return degrade(knowledgeRoot, result.face.reason, result.face.detail, priors);
4718
+ return degrade(knowledgeRoot, result.face.reason, result.face.detail);
4793
4719
  }
4794
- return operationDegradingReader(knowledgeRoot, result.connection, priors);
4720
+ return operationDegradingReader(knowledgeRoot, result.connection);
4795
4721
  }
4796
4722
 
4797
4723
  // src/query-helper.ts
@@ -6939,13 +6865,11 @@ function applyLifecycleTrustTreatments(entries, asOfBuild) {
6939
6865
  }
6940
6866
  const unverified = entry.vettedCandidateInput !== void 0 && (0, import_agent_qa_schema19.isVettedCandidate)(entry.vettedCandidateInput);
6941
6867
  if (unverified) trust *= import_agent_qa_schema19.COLD_START_TRUST_DISCOUNT;
6942
- if (entry.lowerTrust === true) trust *= import_agent_qa_schema19.LOWER_TRUST_PATH_DISCOUNT;
6943
6868
  return {
6944
6869
  ...base,
6945
6870
  trust,
6946
6871
  ...unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal },
6947
- ...unverified ? { unverified: true } : {},
6948
- ...entry.lowerTrust === true ? { lowerTrust: true } : {}
6872
+ ...unverified ? { unverified: true } : {}
6949
6873
  };
6950
6874
  });
6951
6875
  }
@@ -7004,9 +6928,9 @@ function applyDiversityCaps(entries, audit = false) {
7004
6928
  return entries.filter((entry) => {
7005
6929
  const key = primaryDiversityKey(entry);
7006
6930
  if (key === void 0) return true;
7007
- const count2 = counts.get(key) ?? 0;
7008
- if (count2 >= DIVERSITY_CAP_PER_ANCHOR) return false;
7009
- counts.set(key, count2 + 1);
6931
+ const count = counts.get(key) ?? 0;
6932
+ if (count >= DIVERSITY_CAP_PER_ANCHOR) return false;
6933
+ counts.set(key, count + 1);
7010
6934
  return true;
7011
6935
  });
7012
6936
  }
@@ -7045,12 +6969,12 @@ function resolveAsOfBuild(options) {
7045
6969
  if (injected !== void 0) return injected;
7046
6970
  const disk = options.runtimeRoot === void 0 ? void 0 : readLatestBuildOrdinal(options.runtimeRoot, options.product);
7047
6971
  if (disk !== void 0) return disk;
7048
- let latest2;
6972
+ let latest;
7049
6973
  for (const candidate2 of options.candidates) {
7050
6974
  if (!Number.isFinite(candidate2.openedAtOrdinal)) continue;
7051
- latest2 = latest2 === void 0 ? candidate2.openedAtOrdinal : Math.max(latest2, candidate2.openedAtOrdinal);
6975
+ latest = latest === void 0 ? candidate2.openedAtOrdinal : Math.max(latest, candidate2.openedAtOrdinal);
7052
6976
  }
7053
- return latest2;
6977
+ return latest;
7054
6978
  }
7055
6979
  function isCurrentAt(candidate2, asOfBuild) {
7056
6980
  return candidate2.openedAtOrdinal <= asOfBuild && (candidate2.closedAtOrdinal === null || candidate2.closedAtOrdinal > asOfBuild);
@@ -7142,7 +7066,7 @@ function thrashTriggerKey(anchor) {
7142
7066
  const match = /^thrash:([0-9a-f]{64}):window:[0-9]+$/.exec(anchor.name);
7143
7067
  return match?.[1];
7144
7068
  }
7145
- function attachMemoryOffUnknowns(knowledgeRoot, candidates, options, priors) {
7069
+ function attachMemoryOffUnknowns(knowledgeRoot, candidates, options) {
7146
7070
  if (auditMode(options)) return [...candidates];
7147
7071
  const relevantGroups = new Set(
7148
7072
  candidates.flatMap((candidate2) => {
@@ -7160,7 +7084,7 @@ function attachMemoryOffUnknowns(knowledgeRoot, candidates, options, priors) {
7160
7084
  if (!verifyBundleIntegrity(entry.dir).ok) continue;
7161
7085
  const loaded = loadBundle(entry.dir);
7162
7086
  if (loaded.kind !== "loaded" || loaded.bundle.frontmatter.kind !== "unknown") continue;
7163
- const trust = deriveBundleTrust(loaded.bundle, priors);
7087
+ const trust = deriveBundleTrust(loaded.bundle);
7164
7088
  if (trust.status !== "active" && trust.status !== "candidate" || trust.validity.closedAtOrdinal !== void 0) {
7165
7089
  continue;
7166
7090
  }
@@ -7573,8 +7497,7 @@ async function retrieveFromIndex(context, input, scope, options) {
7573
7497
  const withMemoryOffUnknowns = attachMemoryOffUnknowns(
7574
7498
  context.knowledgeRoot,
7575
7499
  authoritative,
7576
- options,
7577
- context.priors
7500
+ options
7578
7501
  );
7579
7502
  const assembled = applyAssembly(
7580
7503
  withMemoryOffUnknowns,
@@ -7684,8 +7607,7 @@ async function retrieveFromScan(context, input, scope, options) {
7684
7607
  const withMemoryOffUnknowns = attachMemoryOffUnknowns(
7685
7608
  context.knowledgeRoot,
7686
7609
  candidates,
7687
- options,
7688
- context.priors
7610
+ options
7689
7611
  );
7690
7612
  const assembled = applyAssembly(withMemoryOffUnknowns, [], options);
7691
7613
  return finalRecheck(context, assembled, scope, options).slice(0, options.n);
@@ -7840,8 +7762,7 @@ async function resolveEntityRef(ref, deps) {
7840
7762
  if (deps.entityIndex === void 0) return { kind: "none", reason: "no-match" };
7841
7763
  return resolveHybrid(trimmed, {
7842
7764
  index: deps.entityIndex,
7843
- // The LEDGER describes the winner, never the projection: a disposable index may hold a
7844
- // stale row, and a stale title in front of a user is the failure D-06 keeps it out of.
7765
+ // The ledger describes the winner, never the index, which may hold a stale row.
7845
7766
  describe: (candidateShortId) => {
7846
7767
  const candidateKind = (0, import_agent_qa_schema23.parseShortId)(candidateShortId)?.kind;
7847
7768
  if (candidateKind === void 0) return void 0;
@@ -7863,13 +7784,13 @@ function getEntityDescriptor(ref, deps) {
7863
7784
 
7864
7785
  // src/list-bundles.ts
7865
7786
  var import_node_path23 = require("node:path");
7866
- function listBundles(knowledgeRoot, priors) {
7787
+ function listBundles(knowledgeRoot) {
7867
7788
  const rows = [];
7868
7789
  for (const entry of enumerateBundleDirs(knowledgeRoot)) {
7869
7790
  const outcome = loadBundle(entry.dir);
7870
7791
  if (outcome.kind !== "loaded") continue;
7871
7792
  const { bundle } = outcome;
7872
- const trust = deriveBundleTrust(bundle, priors);
7793
+ const trust = deriveBundleTrust(bundle);
7873
7794
  rows.push({
7874
7795
  bundleId: bundle.manifest.id,
7875
7796
  product: entry.product,
@@ -7931,9 +7852,7 @@ function createMemorySightingSource(resolveKnowledgeRoot) {
7931
7852
  return {
7932
7853
  kind: "MEM",
7933
7854
  sight: find,
7934
- // Sighting and hydration are the same lookup for MEM: a bundle id IS the machine id, so
7935
- // there is no second index to consult. They stay two members on the port because for
7936
- // RUN and TST (387-03) they will not be.
7855
+ // Sighting and hydration are one lookup for MEM, because a bundle id is the machine id.
7937
7856
  hydrate: find
7938
7857
  };
7939
7858
  }
@@ -8236,9 +8155,7 @@ function evaluateQuarantineDetection(input) {
8236
8155
  const expiresAt = expiryFrom(input.now);
8237
8156
  let floorAdmissions = 0;
8238
8157
  for (const failure of [...input.failures].sort(
8239
- // ONE ordering rule (390-22 / WR-06). Both legs compare CODE UNITS — the identity key through
8240
- // the shared comparator, the fingerprint tiebreak through the same primitive — because a
8241
- // comparison chain is only as deterministic as its least deterministic leg.
8158
+ // Both legs compare code units, so the chain stays host-independent.
8242
8159
  (a, b) => compareQuarantineIdentity(a, b) || compareBytes(a.fingerprint, b.fingerprint)
8243
8160
  )) {
8244
8161
  if (activeKeys.has(quarantineIdentityKey(failure))) continue;
@@ -8450,15 +8367,7 @@ function createQuarantineOperations(options) {
8450
8367
  filePath: entry.filePath,
8451
8368
  testName: entry.testName,
8452
8369
  expiresAt,
8453
- // OMITTED when the caller named nobody: an absent owner leaves the existing claim (or
8454
- // the unassigned literal) exactly as it was. Writing `unassigned` here would silently
8455
- // UN-claim a window somebody had taken.
8456
- //
8457
- // TWO AUTHORING PATHS, ONE RULE. `ownerForAutoEntry` (detection.ts) makes the same
8458
- // decision for an AUTO re-entry, stated over the prior entry's state: carry across a
8459
- // lapse, start unassigned after a deliberate release. Until 390-18 the rule was
8460
- // written down here and applied only here, and the auto path did exactly what this
8461
- // comment refuses to. If you change one, change the other.
8370
+ // An absent owner keeps the claim; `ownerForAutoEntry` follows the same rule.
8462
8371
  ...input.owner === void 0 ? {} : { owner: input.owner }
8463
8372
  }]);
8464
8373
  return {
@@ -8855,11 +8764,6 @@ function writePart(stagingDir, part2) {
8855
8764
  (0, import_node_fs22.writeFileSync)(target, part2.text, "utf8");
8856
8765
  }
8857
8766
  function stageBundle(config, input) {
8858
- if (config.commitArtifacts === "thumbnails") {
8859
- throw new Error(
8860
- "commitArtifacts 'thumbnails' is not implemented; Phase 380 visual review owns it"
8861
- );
8862
- }
8863
8767
  if (!(0, import_node_path26.isAbsolute)(config.knowledgeRoot)) {
8864
8768
  throw new TypeError("BundleStoreConfig.knowledgeRoot must be absolute");
8865
8769
  }
@@ -9571,31 +9475,17 @@ function appendRelation(config, id, relation) {
9571
9475
  return rewriteBundleFile(config, dir, id, RELATIONS_REL_PATH2, rewrittenText, manifestText);
9572
9476
  }
9573
9477
 
9574
- // src/canonical-bundle-state-digests.ts
9575
- var import_node_path29 = require("node:path");
9576
- var import_agent_qa_schema32 = require("@vostride/agent-qa-schema");
9577
- function readCanonicalBundleStateDigests(input) {
9578
- const found = enumerateBundleDirs(input.knowledgeRoot).find(({ dir }) => (0, import_node_path29.basename)(dir) === input.candidateId);
9579
- if (found === void 0) return { kind: "not-found" };
9580
- const loaded = loadBundle(found.dir);
9581
- if (loaded.kind !== "loaded" || loaded.bundle.manifest.id !== input.candidateId || !verifyBundleIntegrity(found.dir).ok) return { kind: "not-found" };
9582
- return {
9583
- kind: "found",
9584
- digests: loaded.bundle.screenStates.map((state) => (0, import_agent_qa_schema32.distilledScreenStateDigest)(state))
9585
- };
9586
- }
9587
-
9588
9478
  // src/serving/reader.ts
9589
9479
  var import_node_fs26 = require("node:fs");
9590
- var import_node_path31 = require("node:path");
9480
+ var import_node_path30 = require("node:path");
9591
9481
  var import_agent_qa_safety = require("@vostride/agent-qa-safety");
9592
- var import_agent_qa_schema39 = require("@vostride/agent-qa-schema");
9482
+ var import_agent_qa_schema38 = require("@vostride/agent-qa-schema");
9593
9483
 
9594
9484
  // src/serving/get-cautions.ts
9595
- var import_agent_qa_schema35 = require("@vostride/agent-qa-schema");
9485
+ var import_agent_qa_schema34 = require("@vostride/agent-qa-schema");
9596
9486
 
9597
9487
  // src/serving/brief-selection.ts
9598
- var import_agent_qa_schema33 = require("@vostride/agent-qa-schema");
9488
+ var import_agent_qa_schema32 = require("@vostride/agent-qa-schema");
9599
9489
 
9600
9490
  // src/serving/brief-render.ts
9601
9491
  var import_agent_qa_runner = require("@vostride/agent-qa-runner");
@@ -9621,7 +9511,7 @@ function compareServingTrustThenId(left, right) {
9621
9511
  return servingTrust(right) - servingTrust(left) || compareServingRecordIds(left, right);
9622
9512
  }
9623
9513
  function normalizedAnchorText(anchor) {
9624
- const normalized = (0, import_agent_qa_schema33.normalizeAnchor)(anchor);
9514
+ const normalized = (0, import_agent_qa_schema32.normalizeAnchor)(anchor);
9625
9515
  switch (normalized.t) {
9626
9516
  case "page":
9627
9517
  return normalized.route;
@@ -9659,7 +9549,7 @@ function candidateVetting(input, candidate2) {
9659
9549
  function isEligibleCandidate(input, candidate2) {
9660
9550
  if (candidate2.status !== "candidate") return candidate2.status === "active";
9661
9551
  const vetting = candidateVetting(input, candidate2);
9662
- if (vetting !== void 0) return (0, import_agent_qa_schema33.isVettedCandidate)(vetting);
9552
+ if (vetting !== void 0) return (0, import_agent_qa_schema32.isVettedCandidate)(vetting);
9663
9553
  return candidate2.unverified === true && (candidate2.kind === "fact" || candidate2.kind === "caution");
9664
9554
  }
9665
9555
  function preFilter(input) {
@@ -9714,7 +9604,6 @@ function rankedCandidate(candidate2) {
9714
9604
  lastConfirmedOrdinal,
9715
9605
  ...candidate2.record.unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal: candidate2.record.unconfirmedSinceOrdinal },
9716
9606
  ...candidate2.record.unverified === true ? { unverified: true } : {},
9717
- ...candidate2.record.lowerTrust === true ? { lowerTrust: true } : {},
9718
9607
  ...candidate2.record.conflict === void 0 ? {} : { conflict: candidate2.record.conflict }
9719
9608
  };
9720
9609
  }
@@ -9757,7 +9646,7 @@ function stageCandidates(input, channelBudget) {
9757
9646
  const scored = scoreCandidates(reranked, input.scope);
9758
9647
  const vetted = scored.filter(({ candidate: candidate2 }) => candidate2.unverified === true);
9759
9648
  const admittedVetted = new Set(
9760
- (0, import_agent_qa_schema33.applyColdStartSubCap)(
9649
+ (0, import_agent_qa_schema32.applyColdStartSubCap)(
9761
9650
  vetted.map(({ candidate: candidate2 }) => candidate2),
9762
9651
  channelBudget
9763
9652
  ).map(({ bundleId }) => bundleId)
@@ -9769,16 +9658,16 @@ function selectServingRecordsWithProvenance(input) {
9769
9658
  const recordCap = normalizeLimit(input.recordCap);
9770
9659
  if (channelBudget === 0 || recordCap === 0 || input.candidates.length === 0) return [];
9771
9660
  const selected = [];
9772
- const admission = (0, import_agent_qa_schema33.createServingAdmissionState)();
9661
+ const admission = (0, import_agent_qa_schema32.createServingAdmissionState)();
9773
9662
  for (const { candidate: candidate2, score } of stageCandidates(input, channelBudget)) {
9774
9663
  if (admission.selectedCount >= recordCap) break;
9775
9664
  const record = reflectedRecord(candidate2);
9776
- const metadata = (0, import_agent_qa_schema33.servingRecordMetadata)({
9665
+ const metadata = (0, import_agent_qa_schema32.servingRecordMetadata)({
9777
9666
  id: record.id,
9778
9667
  anchors: record.anchors,
9779
9668
  renderedCost: candidate2.tokenEstimate
9780
9669
  });
9781
- if (!(0, import_agent_qa_schema33.tryAdmitServingRecord)({
9670
+ if (!(0, import_agent_qa_schema32.tryAdmitServingRecord)({
9782
9671
  record: metadata,
9783
9672
  budget: channelBudget,
9784
9673
  recordCap
@@ -9789,7 +9678,7 @@ function selectServingRecordsWithProvenance(input) {
9789
9678
  }
9790
9679
 
9791
9680
  // src/serving/serve-trace.ts
9792
- var import_agent_qa_schema34 = require("@vostride/agent-qa-schema");
9681
+ var import_agent_qa_schema33 = require("@vostride/agent-qa-schema");
9793
9682
  var CHANNEL_1_SERVING_LEG = "anchor";
9794
9683
  var CHANNEL_3_CAUTION_LEG = "anchor";
9795
9684
  var AUTHORING_LEG_PRECEDENCE = ["anchor", "lexical", "dense"];
@@ -9812,16 +9701,16 @@ function traceLine(input) {
9812
9701
  };
9813
9702
  }
9814
9703
  function boundTruncationLedger(lines) {
9815
- return lines.slice(0, import_agent_qa_schema34.TRACE_TRUNCATION_TOP_K);
9704
+ return lines.slice(0, import_agent_qa_schema33.TRACE_TRUNCATION_TOP_K);
9816
9705
  }
9817
9706
  function composeServedTrace(input) {
9818
9707
  return {
9819
- schemaVersion: import_agent_qa_schema34.RETRIEVAL_TRACE_SCHEMA_VERSION,
9708
+ schemaVersion: import_agent_qa_schema33.RETRIEVAL_TRACE_SCHEMA_VERSION,
9820
9709
  servedLines: [...input.servedLines],
9821
9710
  truncated: boundTruncationLedger(input.truncated)
9822
9711
  };
9823
9712
  }
9824
- var SERVING_TRACE_LEGS = import_agent_qa_schema34.RETRIEVAL_TRACE_LEGS;
9713
+ var SERVING_TRACE_LEGS = import_agent_qa_schema33.RETRIEVAL_TRACE_LEGS;
9825
9714
 
9826
9715
  // src/serving/get-cautions.ts
9827
9716
  var MATCH_PRIORITY = {
@@ -9830,7 +9719,7 @@ var MATCH_PRIORITY = {
9830
9719
  flow: 2
9831
9720
  };
9832
9721
  function normalizedAnchorKey(anchor) {
9833
- return (0, import_agent_qa_schema35.canonicalJson)((0, import_agent_qa_schema35.normalizeAnchor)(anchor));
9722
+ return (0, import_agent_qa_schema34.canonicalJson)((0, import_agent_qa_schema34.normalizeAnchor)(anchor));
9834
9723
  }
9835
9724
  function queryPriorities(anchors) {
9836
9725
  const priorities = /* @__PURE__ */ new Map();
@@ -9873,13 +9762,13 @@ function rankedCautions(input) {
9873
9762
  function selectCautions(input) {
9874
9763
  const ranked = rankedCautions(input);
9875
9764
  const recordCap = input.recordCap ?? ranked.length;
9876
- const admission = (0, import_agent_qa_schema35.createServingAdmissionState)();
9765
+ const admission = (0, import_agent_qa_schema34.createServingAdmissionState)();
9877
9766
  const cautions = [];
9878
9767
  const admissions = [];
9879
9768
  const servedLines = [];
9880
9769
  const truncated = [];
9881
9770
  for (const [index, candidate2] of ranked.entries()) {
9882
- const metadata = (0, import_agent_qa_schema35.servingRecordMetadata)({
9771
+ const metadata = (0, import_agent_qa_schema34.servingRecordMetadata)({
9883
9772
  id: candidate2.record.id,
9884
9773
  anchors: candidate2.record.anchors,
9885
9774
  renderedCost: candidate2.cost
@@ -9890,7 +9779,7 @@ function selectCautions(input) {
9890
9779
  rank: index + 1,
9891
9780
  score: candidate2.record.trust
9892
9781
  });
9893
- if (!(0, import_agent_qa_schema35.tryAdmitServingRecord)({
9782
+ if (!(0, import_agent_qa_schema34.tryAdmitServingRecord)({
9894
9783
  record: metadata,
9895
9784
  budget: input.budget,
9896
9785
  recordCap
@@ -9912,7 +9801,7 @@ function selectCautions(input) {
9912
9801
  }
9913
9802
 
9914
9803
  // src/serving/get-procedure.ts
9915
- var import_agent_qa_schema36 = require("@vostride/agent-qa-schema");
9804
+ var import_agent_qa_schema35 = require("@vostride/agent-qa-schema");
9916
9805
  var PROCEDURE_REPLAY_CONFIRMATIONS = {
9917
9806
  full: 2,
9918
9807
  degraded: 4
@@ -9927,7 +9816,7 @@ var PROCEDURE_LEXICAL_WEIGHT = 0.5;
9927
9816
  var PROCEDURE_DENSE_WEIGHT = 0.25;
9928
9817
  var PROCEDURE_UNFILLABLE_FACTOR = 0.5;
9929
9818
  function normalizedAnchorKey2(anchor) {
9930
- return (0, import_agent_qa_schema36.canonicalJson)((0, import_agent_qa_schema36.normalizeAnchor)(anchor));
9819
+ return (0, import_agent_qa_schema35.canonicalJson)((0, import_agent_qa_schema35.normalizeAnchor)(anchor));
9931
9820
  }
9932
9821
  function compareRecordId(left, right) {
9933
9822
  const leftId = String(left.id);
@@ -9940,7 +9829,7 @@ function admitsProcedure({ entry, bundle }) {
9940
9829
  if (entry.status !== "candidate") return false;
9941
9830
  if (entry.validity !== "current") return false;
9942
9831
  if (bundle.provenance.mode === "run-linked" && bundle.provenance.withheld === true) return false;
9943
- return !(0, import_agent_qa_schema36.survivingOutcomeEvents)(bundle.events).some((event) => event.type === "deprecated");
9832
+ return !(0, import_agent_qa_schema35.survivingOutcomeEvents)(bundle.events).some((event) => event.type === "deprecated");
9944
9833
  }
9945
9834
  function anchorRelevance(entry, requestedKeys) {
9946
9835
  const flowPageAnchors = entry.anchors.filter(
@@ -9960,7 +9849,7 @@ function lexicalRelevance(bundle, intent) {
9960
9849
  }
9961
9850
  function confirmationCount(events, provenance) {
9962
9851
  const creationJobId = provenance.mode === "run-linked" ? provenance.curationJobId : void 0;
9963
- return (0, import_agent_qa_schema36.survivingOutcomeEvents)(events).flatMap((event) => event.type === "confirmed" && event.curationJobId !== creationJobId ? [event.evidenceToken] : []).filter((token) => token.length > 0).length;
9852
+ return (0, import_agent_qa_schema35.survivingOutcomeEvents)(events).flatMap((event) => event.type === "confirmed" && event.curationJobId !== creationJobId ? [event.evidenceToken] : []).filter((token) => token.length > 0).length;
9964
9853
  }
9965
9854
  function matchProcedure(input) {
9966
9855
  const requestedKeys = new Set(input.anchors.map(normalizedAnchorKey2));
@@ -9968,7 +9857,7 @@ function matchProcedure(input) {
9968
9857
  if (!admitsProcedure(candidate2)) return [];
9969
9858
  const anchorScore = anchorRelevance(candidate2.entry, requestedKeys);
9970
9859
  if (anchorScore === 0) return [];
9971
- const payload = (0, import_agent_qa_schema36.parseProcedureBody)(candidate2.bundle.body);
9860
+ const payload = (0, import_agent_qa_schema35.parseProcedureBody)(candidate2.bundle.body);
9972
9861
  if (payload === void 0) return [];
9973
9862
  const flowAnchor = candidate2.entry.anchors.find((anchor) => anchor.t === "flow") ?? candidate2.entry.anchors[0];
9974
9863
  if (flowAnchor === void 0) return [];
@@ -9977,21 +9866,21 @@ function matchProcedure(input) {
9977
9866
  1,
9978
9867
  anchorScore + PROCEDURE_LEXICAL_WEIGHT * lexicalRelevance(candidate2.bundle, input.intent) + PROCEDURE_DENSE_WEIGHT * denseScore
9979
9868
  );
9980
- const tier = (0, import_agent_qa_schema36.curatorTier)(
9869
+ const tier = (0, import_agent_qa_schema35.curatorTier)(
9981
9870
  candidate2.bundle.provenance.mode === "run-linked" ? candidate2.bundle.provenance.authorship : void 0
9982
9871
  );
9983
9872
  const confirmations = confirmationCount(
9984
9873
  candidate2.bundle.events,
9985
9874
  candidate2.bundle.provenance
9986
9875
  );
9987
- const { fillable } = (0, import_agent_qa_schema36.procedureParameterFillability)(payload, input.availability);
9876
+ const { fillable } = (0, import_agent_qa_schema35.procedureParameterFillability)(payload, input.availability);
9988
9877
  const confidence = relevance * PROCEDURE_TIER_FACTOR[tier] * ((confirmations + 1) / (confirmations + 2)) * (fillable ? 1 : PROCEDURE_UNFILLABLE_FACTOR);
9989
9878
  const replay = tier !== "floor" && confirmations >= PROCEDURE_REPLAY_CONFIRMATIONS[tier] && fillable && confidence >= PROCEDURE_REPLAY_CONFIDENCE_FLOOR;
9990
9879
  return [{
9991
9880
  entry: candidate2.entry,
9992
9881
  match: {
9993
9882
  id: candidate2.entry.id,
9994
- flowAnchor: (0, import_agent_qa_schema36.normalizeAnchor)(flowAnchor),
9883
+ flowAnchor: (0, import_agent_qa_schema35.normalizeAnchor)(flowAnchor),
9995
9884
  confidence,
9996
9885
  authoringModelTier: tier,
9997
9886
  parameterSchema: payload.parameters.map(({ name, type, required }) => ({
@@ -10009,7 +9898,7 @@ function matchProcedure(input) {
10009
9898
 
10010
9899
  // src/serving/get-run-brief.ts
10011
9900
  var import_agent_qa_runner2 = require("@vostride/agent-qa-runner");
10012
- var import_agent_qa_schema37 = require("@vostride/agent-qa-schema");
9901
+ var import_agent_qa_schema36 = require("@vostride/agent-qa-schema");
10013
9902
  function isUserFact(entry) {
10014
9903
  const stampedEntry = entry;
10015
9904
  return entry.kind === "fact" && entry.status === "active" && (stampedEntry.origin === "user" || stampedEntry.originClass === "user");
@@ -10107,12 +9996,12 @@ function assembleRunBrief(input) {
10107
9996
  policyWarnings(input.policy)
10108
9997
  ),
10109
9998
  admissions: [
10110
- ...sovereignLines.map(({ record, rendered: rendered2 }) => (0, import_agent_qa_schema37.servingRecordMetadata)({
9999
+ ...sovereignLines.map(({ record, rendered: rendered2 }) => (0, import_agent_qa_schema36.servingRecordMetadata)({
10111
10000
  id: record.id,
10112
10001
  anchors: record.anchors,
10113
10002
  renderedCost: rendered2.cost
10114
10003
  })),
10115
- ...selected.map((record, index) => (0, import_agent_qa_schema37.servingRecordMetadata)({
10004
+ ...selected.map((record, index) => (0, import_agent_qa_schema36.servingRecordMetadata)({
10116
10005
  id: record.id,
10117
10006
  anchors: record.anchors,
10118
10007
  renderedCost: rendered[index].cost
@@ -10124,8 +10013,8 @@ function assembleRunBrief(input) {
10124
10013
 
10125
10014
  // src/serving/policy-ladder.ts
10126
10015
  var import_node_fs25 = require("node:fs");
10127
- var import_node_path30 = require("node:path");
10128
- var import_agent_qa_schema38 = require("@vostride/agent-qa-schema");
10016
+ var import_node_path29 = require("node:path");
10017
+ var import_agent_qa_schema37 = require("@vostride/agent-qa-schema");
10129
10018
  var POLICY_SIZE_WARNING_CHARACTERS = 16e3;
10130
10019
  var MalformedPolicyCommentError = class extends SyntaxError {
10131
10020
  sourceFile;
@@ -10207,7 +10096,7 @@ function stripPolicyHtmlComments(text, sourceFile) {
10207
10096
  function readOptionalPolicy(knowledgeRoot, file) {
10208
10097
  try {
10209
10098
  const text = stripPolicyHtmlComments(
10210
- (0, import_node_fs25.readFileSync)((0, import_node_path30.join)(knowledgeRoot, ...file.split("/")), "utf8"),
10099
+ (0, import_node_fs25.readFileSync)((0, import_node_path29.join)(knowledgeRoot, ...file.split("/")), "utf8"),
10211
10100
  file
10212
10101
  );
10213
10102
  if (text.trim().length === 0) return void 0;
@@ -10233,15 +10122,14 @@ ${rung.text}`;
10233
10122
  function readPolicyLadder(knowledgeRoot, product) {
10234
10123
  const requestedFiles = ["policies/global.md"];
10235
10124
  if (product !== void 0 && product.length > 0) {
10236
- requestedFiles.push(`policies/${(0, import_agent_qa_schema38.slugBranch)(product)}.md`);
10125
+ requestedFiles.push(`policies/${(0, import_agent_qa_schema37.slugBranch)(product)}.md`);
10237
10126
  }
10238
10127
  const rungs = requestedFiles.flatMap((file) => {
10239
10128
  const rung = readOptionalPolicy(knowledgeRoot, file);
10240
10129
  return rung === void 0 ? [] : [rung];
10241
10130
  });
10242
10131
  return {
10243
- // D-07: Validated active policy bytes are concatenated whole. Labels frame
10244
- // sources but no active text is summarized, truncated, normalized, or reflowed.
10132
+ // Active policy bytes are concatenated whole; labels frame sources and no text is reflowed.
10245
10133
  text: renderPolicyLadder(rungs),
10246
10134
  files: rungs.map(({ file }) => file),
10247
10135
  oversized: rungs.flatMap(
@@ -10269,7 +10157,7 @@ function normalizedRecordCap2(config) {
10269
10157
  return Number.isFinite(configured) ? Math.max(0, Math.floor(configured)) : 0;
10270
10158
  }
10271
10159
  function productSlug(config) {
10272
- return config.product === void 0 ? void 0 : (0, import_agent_qa_schema39.slugBranch)(config.product);
10160
+ return config.product === void 0 ? void 0 : (0, import_agent_qa_schema38.slugBranch)(config.product);
10273
10161
  }
10274
10162
  function readIndexRows(config, scope) {
10275
10163
  if (!(0, import_node_fs26.existsSync)(indexDbPath(config.knowledgeRoot))) return [];
@@ -10283,7 +10171,7 @@ function readIndexRows(config, scope) {
10283
10171
  ...scope === void 0 ? {} : { requestedScope: scope },
10284
10172
  ...config.scopeDefaults?.parentScopes === void 0 ? {} : { parentScopes: config.scopeDefaults.parentScopes }
10285
10173
  });
10286
- if (!indexTrustEpochMatches(reader.db, effectivePriorDigest(config.priors))) {
10174
+ if (!indexTrustEpochMatches(reader.db, effectivePriorDigest())) {
10287
10175
  const admits = reader.db.prepare(`
10288
10176
  SELECT 1 FROM (SELECT ? AS product, ? AS scope_tier, ? AS scope_key) r
10289
10177
  WHERE ${predicate.sql}
@@ -10321,7 +10209,7 @@ function readIndexRows(config, scope) {
10321
10209
  function bundleDirs(config) {
10322
10210
  return new Map(
10323
10211
  enumerateBundleDirs(config.knowledgeRoot).map(({ dir, product }) => [
10324
- (0, import_node_path31.basename)(dir),
10212
+ (0, import_node_path30.basename)(dir),
10325
10213
  { dir, product }
10326
10214
  ])
10327
10215
  );
@@ -10334,18 +10222,16 @@ function hydrateRows(config, rows, audit) {
10334
10222
  const loaded = loadBundle(found.dir);
10335
10223
  if (loaded.kind !== "loaded" || !verifyBundleIntegrity(found.dir).ok) return [];
10336
10224
  const { bundle } = loaded;
10337
- const trust = deriveBundleTrust(bundle, config.priors);
10338
- const vetted = trust.status === "candidate" && (0, import_agent_qa_schema39.isVettedCandidate)(
10225
+ const trust = deriveBundleTrust(bundle);
10226
+ const vetted = trust.status === "candidate" && (0, import_agent_qa_schema38.isVettedCandidate)(
10339
10227
  assemblePromotionGateInput({
10340
10228
  knowledgeRoot: config.knowledgeRoot,
10341
10229
  bundleDir: found.dir,
10342
- bundle,
10343
- priors: config.priors
10230
+ bundle
10344
10231
  })
10345
10232
  );
10346
- const lowerTrust = trust.status === "active" && (0, import_agent_qa_schema39.strongestPromotionPath)(readGateReceipts(found.dir, bundle.manifest.id) ?? []) === "gate1-lower-trust";
10347
10233
  const entry = {
10348
- id: (0, import_agent_qa_schema39.asRecordId)(bundle.manifest.id),
10234
+ id: (0, import_agent_qa_schema38.asRecordId)(bundle.manifest.id),
10349
10235
  kind: bundle.frontmatter.kind,
10350
10236
  ...bundle.frontmatter.subtype === void 0 ? {} : { subtype: bundle.frontmatter.subtype },
10351
10237
  title: bundle.summary,
@@ -10353,8 +10239,7 @@ function hydrateRows(config, rows, audit) {
10353
10239
  trust: trust.trust,
10354
10240
  anchors: bundle.frontmatter.anchors.map(({ normalized }) => normalized),
10355
10241
  status: trust.status,
10356
- servedAsCanary: vetted || lowerTrust,
10357
- ...lowerTrust ? { lowerTrust: true } : {},
10242
+ servedAsCanary: vetted,
10358
10243
  ...vetted ? { unverified: true } : {},
10359
10244
  ...audit ? {
10360
10245
  audit: {
@@ -10378,14 +10263,14 @@ function currentServingEntries(entries) {
10378
10263
  });
10379
10264
  }
10380
10265
  function normalizedAnchorKey3(anchor) {
10381
- return (0, import_agent_qa_schema39.canonicalJson)((0, import_agent_qa_schema39.normalizeAnchor)(anchor));
10266
+ return (0, import_agent_qa_schema38.canonicalJson)((0, import_agent_qa_schema38.normalizeAnchor)(anchor));
10382
10267
  }
10383
10268
  function screenStatePageAnchors(screenState) {
10384
10269
  if (screenState.url === void 0 || screenState.url.trim() === "") return [];
10385
- const anchors = [(0, import_agent_qa_schema39.normalizeAnchor)({ t: "page", route: screenState.url })];
10270
+ const anchors = [(0, import_agent_qa_schema38.normalizeAnchor)({ t: "page", route: screenState.url })];
10386
10271
  try {
10387
10272
  const parsed = new URL(screenState.url);
10388
- anchors.push((0, import_agent_qa_schema39.normalizeAnchor)({ t: "page", route: `${parsed.pathname}${parsed.search}` }));
10273
+ anchors.push((0, import_agent_qa_schema38.normalizeAnchor)({ t: "page", route: `${parsed.pathname}${parsed.search}` }));
10389
10274
  } catch {
10390
10275
  }
10391
10276
  return anchors;
@@ -10402,7 +10287,7 @@ function lexicalMatches(bundle, query) {
10402
10287
  bundle.summary,
10403
10288
  bundle.body,
10404
10289
  bundle.manifest.embeddingInput,
10405
- ...bundle.frontmatter.anchors.map(({ normalized }) => (0, import_agent_qa_schema39.canonicalJson)(normalized))
10290
+ ...bundle.frontmatter.anchors.map(({ normalized }) => (0, import_agent_qa_schema38.canonicalJson)(normalized))
10406
10291
  ].join("\n").toLowerCase();
10407
10292
  return tokens.every((token) => text.includes(token));
10408
10293
  }
@@ -10428,7 +10313,7 @@ function searchEntries(config, query, options) {
10428
10313
  if (!auditMode2 && (entry.status === "deprecated" || entry.status === "superseded")) {
10429
10314
  return false;
10430
10315
  }
10431
- const trust = deriveBundleTrust(bundle, config.priors);
10316
+ const trust = deriveBundleTrust(bundle);
10432
10317
  if (options.asOfBuild !== void 0 && !validAtBuild(
10433
10318
  trust.validity.openedAtOrdinal,
10434
10319
  trust.validity.closedAtOrdinal,
@@ -10458,7 +10343,7 @@ function findReadableBundle(config, id, options) {
10458
10343
  if (currentServingEntries([hydrated]).length === 0 && !admitsProcedure({ entry: hydrated.entry, bundle: hydrated.bundle })) {
10459
10344
  return void 0;
10460
10345
  }
10461
- const trust = deriveBundleTrust(hydrated.bundle, config.priors);
10346
+ const trust = deriveBundleTrust(hydrated.bundle);
10462
10347
  const asOfBuild = options?.asOfBuild ?? config.scopeDefaults?.asOfBuild;
10463
10348
  if (asOfBuild !== void 0 && !validAtBuild(
10464
10349
  trust.validity.openedAtOrdinal,
@@ -10495,7 +10380,7 @@ function readRecord(config, id, options) {
10495
10380
  const { bundle } = found;
10496
10381
  const measurements = readMeasurements(found.dir);
10497
10382
  return {
10498
- id: (0, import_agent_qa_schema39.asRecordId)(bundle.manifest.id),
10383
+ id: (0, import_agent_qa_schema38.asRecordId)(bundle.manifest.id),
10499
10384
  title: bundle.summary,
10500
10385
  body: truncateBody(
10501
10386
  bundle.body,
@@ -10504,10 +10389,10 @@ function readRecord(config, id, options) {
10504
10389
  ),
10505
10390
  anchors: bundle.frontmatter.anchors.map(({ normalized }) => normalized),
10506
10391
  evidenceDigest: bundle.manifest.contentHashes["evidence/evidence.md"] ?? bundle.manifest.contentHashes["record.md"] ?? bundle.manifest.identityHash,
10507
- ...measurements === void 0 ? {} : { measurement: (0, import_agent_qa_schema39.canonicalJson)(measurements) },
10392
+ ...measurements === void 0 ? {} : { measurement: (0, import_agent_qa_schema38.canonicalJson)(measurements) },
10508
10393
  relations: bundle.relations.relations.map((relation) => ({
10509
10394
  kind: relation.type,
10510
- targetId: (0, import_agent_qa_schema39.asRecordId)(relation.targetId)
10395
+ targetId: (0, import_agent_qa_schema38.asRecordId)(relation.targetId)
10511
10396
  }))
10512
10397
  };
10513
10398
  }
@@ -10545,7 +10430,7 @@ function servingReader(config) {
10545
10430
  return { block: selected.block, trace: selected.trace };
10546
10431
  }
10547
10432
  const overflowLine = {
10548
- id: (0, import_agent_qa_schema39.asRecordId)("caution:truncated"),
10433
+ id: (0, import_agent_qa_schema38.asRecordId)("caution:truncated"),
10549
10434
  anchors: [],
10550
10435
  summary: `truncated ${selected.overflow.served} of ${selected.overflow.eligible}`
10551
10436
  };
@@ -10562,7 +10447,7 @@ function servingReader(config) {
10562
10447
  entries: hydrateRows(config, readIndexRows(config), false),
10563
10448
  intent,
10564
10449
  anchors: screenStatePageAnchors(screenState),
10565
- availability: availability ?? import_agent_qa_schema39.EMPTY_PROCEDURE_BINDING_AVAILABILITY
10450
+ availability: availability ?? import_agent_qa_schema38.EMPTY_PROCEDURE_BINDING_AVAILABILITY
10566
10451
  });
10567
10452
  },
10568
10453
  emitCanaryOutcome(payload) {
@@ -10571,15 +10456,15 @@ function servingReader(config) {
10571
10456
  };
10572
10457
  }
10573
10458
  function openKnowledgeReader2(configOrKnowledgeRoot, opts) {
10574
- return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader({ ...configOrKnowledgeRoot, priors: snapshotTrustPriors(configOrKnowledgeRoot.priors) });
10459
+ return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader(configOrKnowledgeRoot);
10575
10460
  }
10576
10461
 
10577
10462
  // src/serving/authoring-reader.ts
10578
10463
  var import_node_fs27 = require("node:fs");
10579
- var import_agent_qa_schema41 = require("@vostride/agent-qa-schema");
10464
+ var import_agent_qa_schema40 = require("@vostride/agent-qa-schema");
10580
10465
 
10581
10466
  // src/serving/get-authoring-brief.ts
10582
- var import_agent_qa_schema40 = require("@vostride/agent-qa-schema");
10467
+ var import_agent_qa_schema39 = require("@vostride/agent-qa-schema");
10583
10468
  var AUTHORING_EXEMPLAR_CAP = 4;
10584
10469
  var AUTHORING_PROCEDURE_CAP = 5;
10585
10470
  var AUTHORING_EXCERPT_CHAR_BUDGET = 240;
@@ -10588,7 +10473,7 @@ var AUTHORING_MMR_WEIGHT = 0.5;
10588
10473
  var AUTHORING_LEXICAL_WEIGHT = 0.5;
10589
10474
  var AUTHORING_DENSE_WEIGHT = 0.25;
10590
10475
  function normalizedAnchorKey4(anchor) {
10591
- return (0, import_agent_qa_schema40.canonicalJson)((0, import_agent_qa_schema40.normalizeAnchor)(anchor));
10476
+ return (0, import_agent_qa_schema39.canonicalJson)((0, import_agent_qa_schema39.normalizeAnchor)(anchor));
10592
10477
  }
10593
10478
  function compareText6(left, right) {
10594
10479
  return left < right ? -1 : left > right ? 1 : 0;
@@ -10642,7 +10527,7 @@ function topProcedures(input) {
10642
10527
  entries: remaining,
10643
10528
  intent: input.intent,
10644
10529
  anchors: input.targetAnchors,
10645
- availability: import_agent_qa_schema40.EMPTY_PROCEDURE_BINDING_AVAILABILITY,
10530
+ availability: import_agent_qa_schema39.EMPTY_PROCEDURE_BINDING_AVAILABILITY,
10646
10531
  ...input.denseScoreByRecordId === void 0 ? {} : { denseScoreByRecordId: input.denseScoreByRecordId }
10647
10532
  });
10648
10533
  if (match === void 0) break;
@@ -10658,7 +10543,7 @@ function anchorDisplayText(anchor) {
10658
10543
  case "flow":
10659
10544
  return anchor.name;
10660
10545
  default:
10661
- return (0, import_agent_qa_schema40.canonicalJson)(anchor);
10546
+ return (0, import_agent_qa_schema39.canonicalJson)(anchor);
10662
10547
  }
10663
10548
  }
10664
10549
  function boundedExcerpt(parts) {
@@ -10681,9 +10566,9 @@ function verifiedExemplarCandidate(row, targetKeys, tokens) {
10681
10566
  const matchedAnchors = matchedKeys.map((key) => JSON.parse(key));
10682
10567
  const total = row.passes + row.failures;
10683
10568
  return [{
10684
- identity: (0, import_agent_qa_schema40.identityTupleKey)([row.filePath, row.testName]),
10569
+ identity: (0, import_agent_qa_schema39.identityTupleKey)([row.filePath, row.testName]),
10685
10570
  anchorKeys: new Set(matchedKeys),
10686
- // D-15 fold: trust (neutral 1 for projection-verified rows) x recent-pass-rate x relevance.
10571
+ // Trust is a neutral 1 for projection-verified rows, so the score is pass rate times relevance.
10687
10572
  score: recentPassRate * relevance,
10688
10573
  leg: dominantAuthoringLeg(contributions),
10689
10574
  exemplar: {
@@ -10705,7 +10590,7 @@ function neverRunExemplarCandidate(ref, tokens) {
10705
10590
  const relevance = lexicalRelevance2(tokens, `${ref.testName} ${ref.filePath}`);
10706
10591
  if (relevance === 0) return [];
10707
10592
  return [{
10708
- identity: (0, import_agent_qa_schema40.identityTupleKey)([ref.filePath, ref.testName]),
10593
+ identity: (0, import_agent_qa_schema39.identityTupleKey)([ref.filePath, ref.testName]),
10709
10594
  anchorKeys: /* @__PURE__ */ new Set(),
10710
10595
  // Neutral trust, no observed pass-rate: discounted below verified rows, never dropped.
10711
10596
  score: AUTHORING_UNVERIFIED_OUTCOMES_DISCOUNT * relevance,
@@ -10753,11 +10638,11 @@ function mmrOverlapPenalty(candidate2, selected) {
10753
10638
  }
10754
10639
  function selectExemplars(input, targetKeys, tokens) {
10755
10640
  const projectionIdentities = new Set(
10756
- input.projectionRows.map((row) => (0, import_agent_qa_schema40.identityTupleKey)([row.filePath, row.testName]))
10641
+ input.projectionRows.map((row) => (0, import_agent_qa_schema39.identityTupleKey)([row.filePath, row.testName]))
10757
10642
  );
10758
10643
  const candidates = [
10759
10644
  ...input.projectionRows.flatMap((row) => verifiedExemplarCandidate(row, targetKeys, tokens)),
10760
- ...(input.knownTests ?? []).flatMap((ref) => projectionIdentities.has((0, import_agent_qa_schema40.identityTupleKey)([ref.filePath, ref.testName])) ? [] : neverRunExemplarCandidate(ref, tokens))
10645
+ ...(input.knownTests ?? []).flatMap((ref) => projectionIdentities.has((0, import_agent_qa_schema39.identityTupleKey)([ref.filePath, ref.testName])) ? [] : neverRunExemplarCandidate(ref, tokens))
10761
10646
  ].sort((left, right) => right.score - left.score || compareText6(left.identity, right.identity));
10762
10647
  const diverse = applyDiversityCaps(
10763
10648
  candidates.map((candidate2) => exemplarRerankEntry(candidate2, input.scope))
@@ -10779,7 +10664,7 @@ function selectExemplars(input, targetKeys, tokens) {
10779
10664
  return selected;
10780
10665
  }
10781
10666
  function exemplarRecordId(exemplar) {
10782
- return `exemplar:${(0, import_agent_qa_schema40.identityTupleKey)([exemplar.filePath, exemplar.testName])}`;
10667
+ return `exemplar:${(0, import_agent_qa_schema39.identityTupleKey)([exemplar.filePath, exemplar.testName])}`;
10783
10668
  }
10784
10669
  function assembleAuthoringBrief(input) {
10785
10670
  const targetKeys = new Set(input.targetAnchors.map(normalizedAnchorKey4));
@@ -10788,7 +10673,7 @@ function assembleAuthoringBrief(input) {
10788
10673
  const cautionItems = scoreEntries(input, "caution", targetKeys, tokens).map(({ entry, score, leg }) => {
10789
10674
  const rendered = (0, import_agent_qa_runner.renderCautionLine)(entry);
10790
10675
  return {
10791
- metadata: (0, import_agent_qa_schema40.servingRecordMetadata)({
10676
+ metadata: (0, import_agent_qa_schema39.servingRecordMetadata)({
10792
10677
  id: entry.id,
10793
10678
  anchors: entry.anchors,
10794
10679
  renderedCost: rendered.cost
@@ -10804,10 +10689,10 @@ function assembleAuthoringBrief(input) {
10804
10689
  });
10805
10690
  const procedures = [];
10806
10691
  const procedureItems = topProcedures(input).map((match) => ({
10807
- metadata: (0, import_agent_qa_schema40.servingRecordMetadata)({
10692
+ metadata: (0, import_agent_qa_schema39.servingRecordMetadata)({
10808
10693
  id: match.id,
10809
10694
  anchors: [match.flowAnchor],
10810
- renderedCost: (0, import_agent_qa_runner.estimateRenderedServingCost)((0, import_agent_qa_schema40.canonicalJson)(match))
10695
+ renderedCost: (0, import_agent_qa_runner.estimateRenderedServingCost)((0, import_agent_qa_schema39.canonicalJson)(match))
10811
10696
  }),
10812
10697
  // matchProcedure drops any candidate whose anchor relevance is zero before scoring it, so a
10813
10698
  // procedure is here because an anchor matched. Its confidence IS the fold's own score.
@@ -10817,10 +10702,10 @@ function assembleAuthoringBrief(input) {
10817
10702
  }));
10818
10703
  const exemplars = [];
10819
10704
  const exemplarItems = selectExemplars(input, targetKeys, tokens).map(({ exemplar, score, leg }) => ({
10820
- metadata: (0, import_agent_qa_schema40.servingRecordMetadata)({
10821
- id: (0, import_agent_qa_schema40.asRecordId)(exemplarRecordId(exemplar)),
10705
+ metadata: (0, import_agent_qa_schema39.servingRecordMetadata)({
10706
+ id: (0, import_agent_qa_schema39.asRecordId)(exemplarRecordId(exemplar)),
10822
10707
  anchors: exemplar.matchedAnchors,
10823
- renderedCost: (0, import_agent_qa_runner.estimateRenderedServingCost)((0, import_agent_qa_schema40.canonicalJson)(exemplar))
10708
+ renderedCost: (0, import_agent_qa_runner.estimateRenderedServingCost)((0, import_agent_qa_schema39.canonicalJson)(exemplar))
10824
10709
  }),
10825
10710
  leg,
10826
10711
  score,
@@ -10830,7 +10715,7 @@ function assembleAuthoringBrief(input) {
10830
10715
  const factItems = scoreEntries(input, "fact", targetKeys, tokens).map(({ entry, score, leg }) => {
10831
10716
  const rendered = (0, import_agent_qa_runner.renderBriefLine)(entry);
10832
10717
  return {
10833
- metadata: (0, import_agent_qa_schema40.servingRecordMetadata)({
10718
+ metadata: (0, import_agent_qa_schema39.servingRecordMetadata)({
10834
10719
  id: entry.id,
10835
10720
  anchors: entry.anchors,
10836
10721
  renderedCost: rendered.cost
@@ -10840,7 +10725,7 @@ function assembleAuthoringBrief(input) {
10840
10725
  serve: () => facts.push(rendered.briefLine)
10841
10726
  };
10842
10727
  });
10843
- const admission = (0, import_agent_qa_schema40.createServingAdmissionState)();
10728
+ const admission = (0, import_agent_qa_schema39.createServingAdmissionState)();
10844
10729
  const admissions = [];
10845
10730
  const servedLines = [];
10846
10731
  const truncated = [];
@@ -10867,7 +10752,7 @@ function assembleAuthoringBrief(input) {
10867
10752
  for (const item of bucket) {
10868
10753
  rank += 1;
10869
10754
  const line = cutLine(item, rank);
10870
- if (!(0, import_agent_qa_schema40.tryAdmitServingRecord)({
10755
+ if (!(0, import_agent_qa_schema39.tryAdmitServingRecord)({
10871
10756
  record: item.metadata,
10872
10757
  budget: input.budget,
10873
10758
  recordCap: Number.POSITIVE_INFINITY
@@ -10903,7 +10788,7 @@ var AUTHORING_DENSE_K = 32;
10903
10788
  function quarantinedIdentityKeys(knowledgeRoot, now) {
10904
10789
  const { events } = readQuarantineLedger(knowledgeRoot);
10905
10790
  return new Set(
10906
- foldQuarantineLedgerState(events, now).filter((entry) => entry.state === "quarantined").map((entry) => (0, import_agent_qa_schema41.identityTupleKey)([entry.product, entry.filePath, entry.testName]))
10791
+ foldQuarantineLedgerState(events, now).filter((entry) => entry.state === "quarantined").map((entry) => (0, import_agent_qa_schema40.identityTupleKey)([entry.product, entry.filePath, entry.testName]))
10907
10792
  );
10908
10793
  }
10909
10794
  function parseLastOutcomes(json) {
@@ -10937,7 +10822,7 @@ function readProjectionRows(config, scope, now) {
10937
10822
  });
10938
10823
  if (!partitionColumnsPresent) return [];
10939
10824
  const predicate = scopeLadderPredicate({
10940
- ...config.product === void 0 ? {} : { productRow: (0, import_agent_qa_schema41.slugBranch)(config.product), productScope: config.product },
10825
+ ...config.product === void 0 ? {} : { productRow: (0, import_agent_qa_schema40.slugBranch)(config.product), productScope: config.product },
10941
10826
  requestedScope: scope,
10942
10827
  ...config.scopeDefaults?.parentScopes === void 0 ? {} : { parentScopes: config.scopeDefaults.parentScopes }
10943
10828
  });
@@ -10949,7 +10834,7 @@ function readProjectionRows(config, scope, now) {
10949
10834
  ORDER BY r.product, r.file_path, r.test_name, r.anchor_normalized_json
10950
10835
  `).all(...predicate.binds);
10951
10836
  for (const row of anchorRows) {
10952
- const key = (0, import_agent_qa_schema41.identityTupleKey)([
10837
+ const key = (0, import_agent_qa_schema40.identityTupleKey)([
10953
10838
  String(row.product),
10954
10839
  String(row.file_path),
10955
10840
  String(row.test_name)
@@ -10973,13 +10858,13 @@ function readProjectionRows(config, scope, now) {
10973
10858
  failures: Number(row.failures),
10974
10859
  heals: Number(row.heals),
10975
10860
  flakeCount: Number(row.flake_count),
10976
- quarantined: quarantinedKeys.has((0, import_agent_qa_schema41.identityTupleKey)([
10861
+ quarantined: quarantinedKeys.has((0, import_agent_qa_schema40.identityTupleKey)([
10977
10862
  String(row.product),
10978
10863
  String(row.file_path),
10979
10864
  String(row.test_name)
10980
10865
  ])),
10981
10866
  lastOutcomes: parseLastOutcomes(String(row.last_outcomes_json)),
10982
- anchorKeys: anchorsByTest.get((0, import_agent_qa_schema41.identityTupleKey)([
10867
+ anchorKeys: anchorsByTest.get((0, import_agent_qa_schema40.identityTupleKey)([
10983
10868
  String(row.product),
10984
10869
  String(row.file_path),
10985
10870
  String(row.test_name)
@@ -10998,7 +10883,7 @@ function deriveTargetAnchors(intent) {
10998
10883
  }
10999
10884
  if (intent.trim() !== "") anchors.push({ t: "flow", name: intent });
11000
10885
  const seen = /* @__PURE__ */ new Set();
11001
- return anchors.map(import_agent_qa_schema41.normalizeAnchor).filter((anchor) => {
10886
+ return anchors.map(import_agent_qa_schema40.normalizeAnchor).filter((anchor) => {
11002
10887
  const key = JSON.stringify(anchor);
11003
10888
  if (seen.has(key)) return false;
11004
10889
  seen.add(key);
@@ -11009,7 +10894,7 @@ function authoringRetrievalScope(config, scope) {
11009
10894
  const containingScopes = [scope, ...config.scopeDefaults?.parentScopes ?? []];
11010
10895
  const productKey = config.product ?? containingScopes.find((candidate2) => candidate2.tier === "product")?.key ?? scope.key;
11011
10896
  return {
11012
- product: (0, import_agent_qa_schema41.slugBranch)(productKey),
10897
+ product: (0, import_agent_qa_schema40.slugBranch)(productKey),
11013
10898
  testKey: containingScopes.find((candidate2) => candidate2.tier === "test")?.key ?? `__missing_test_scope__:${productKey}`,
11014
10899
  suiteKey: containingScopes.find((candidate2) => candidate2.tier === "suite")?.key ?? `__missing_suite_scope__:${productKey}`,
11015
10900
  productKey,
@@ -11023,10 +10908,10 @@ function clamp01(value) {
11023
10908
  function knownTestUniverse(projectionRows, discovered) {
11024
10909
  const byIdentity = /* @__PURE__ */ new Map();
11025
10910
  for (const { filePath, testName } of discovered) {
11026
- byIdentity.set((0, import_agent_qa_schema41.identityTupleKey)([filePath, testName]), { filePath, testName });
10911
+ byIdentity.set((0, import_agent_qa_schema40.identityTupleKey)([filePath, testName]), { filePath, testName });
11027
10912
  }
11028
10913
  for (const { filePath, testName } of projectionRows) {
11029
- byIdentity.set((0, import_agent_qa_schema41.identityTupleKey)([filePath, testName]), { filePath, testName });
10914
+ byIdentity.set((0, import_agent_qa_schema40.identityTupleKey)([filePath, testName]), { filePath, testName });
11030
10915
  }
11031
10916
  return [...byIdentity.values()].sort((left, right) => (left.filePath < right.filePath ? -1 : left.filePath > right.filePath ? 1 : 0) || (left.testName < right.testName ? -1 : left.testName > right.testName ? 1 : 0));
11032
10917
  }
@@ -11055,7 +10940,6 @@ async function readDenseScores(config, deps, intent, scope) {
11055
10940
  }
11056
10941
  }
11057
10942
  function createAuthoringReader(config, deps = {}) {
11058
- config = { ...config, priors: snapshotTrustPriors(config.priors) };
11059
10943
  return {
11060
10944
  async getAuthoringBrief(intent, scope) {
11061
10945
  const entries = hydrateRows(config, readIndexRows(config, scope), false);
@@ -11072,8 +10956,7 @@ function createAuthoringReader(config, deps = {}) {
11072
10956
  const { brief } = assembleAuthoringBrief({
11073
10957
  entries,
11074
10958
  projectionRows,
11075
- // D-16: the consumer owns the filesystem and supplies identity refs only. Projection
11076
- // identities remain a deterministic floor, while never-run tests widen the universe.
10959
+ // The consumer owns the filesystem and supplies refs; never-run tests widen the projection.
11077
10960
  knownTests,
11078
10961
  intent,
11079
10962
  scope,
@@ -11087,7 +10970,7 @@ function createAuthoringReader(config, deps = {}) {
11087
10970
  }
11088
10971
 
11089
10972
  // src/retrieval-rung.ts
11090
- var import_agent_qa_schema42 = require("@vostride/agent-qa-schema");
10973
+ var import_agent_qa_schema41 = require("@vostride/agent-qa-schema");
11091
10974
  var INDEX_REASONS = {
11092
10975
  absent: "index-not-built",
11093
10976
  locked: "index-locked",
@@ -11099,7 +10982,7 @@ var DEFERRED_REASONS = {
11099
10982
  "load-failure": "embedder-load-failed",
11100
10983
  "worker-unavailable": "profile-unresolved"
11101
10984
  };
11102
- function foldRetrievalRung(index, embedder, preferredProfile = import_agent_qa_schema42.DEFAULT_EMBEDDING_PROFILE) {
10985
+ function foldRetrievalRung(index, embedder, preferredProfile = import_agent_qa_schema41.DEFAULT_EMBEDDING_PROFILE) {
11103
10986
  if (index.source === "scan") {
11104
10987
  return { schemaVersion: 2, rung: "bundle-scan", reason: INDEX_REASONS[index.reason] };
11105
10988
  }
@@ -11119,7 +11002,7 @@ function foldRetrievalRung(index, embedder, preferredProfile = import_agent_qa_s
11119
11002
  return { schemaVersion: 2, rung: "lexical-only", reason: "floor-disabled" };
11120
11003
  }
11121
11004
  async function resolveRetrievalRung(options) {
11122
- const preferredProfile = options.preferredProfile ?? import_agent_qa_schema42.DEFAULT_EMBEDDING_PROFILE;
11005
+ const preferredProfile = options.preferredProfile ?? import_agent_qa_schema41.DEFAULT_EMBEDDING_PROFILE;
11123
11006
  const index = classifyIndexFace(options.knowledgeRoot);
11124
11007
  if (index.source === "scan") {
11125
11008
  return foldRetrievalRung(index, { kind: "lexical-only" }, preferredProfile);
@@ -11140,11 +11023,11 @@ async function resolveRetrievalRung(options) {
11140
11023
 
11141
11024
  // src/index-rebuild.ts
11142
11025
  var import_node_fs28 = require("node:fs");
11143
- var import_node_path32 = require("node:path");
11144
- var import_agent_qa_schema45 = require("@vostride/agent-qa-schema");
11026
+ var import_node_path31 = require("node:path");
11027
+ var import_agent_qa_schema44 = require("@vostride/agent-qa-schema");
11145
11028
 
11146
11029
  // src/contextual-rendering.ts
11147
- var import_agent_qa_schema43 = require("@vostride/agent-qa-schema");
11030
+ var import_agent_qa_schema42 = require("@vostride/agent-qa-schema");
11148
11031
  function recordKind(value) {
11149
11032
  if (value === "fact" || value === "procedure" || value === "caution" || value === "unknown" || value === "policy") {
11150
11033
  return value;
@@ -11285,7 +11168,7 @@ function buildSituatingLine(db, recordRowid) {
11285
11168
  }
11286
11169
  const record = db.prepare("SELECT bundle_id, kind FROM records WHERE record_rowid = ?").get(recordRowid);
11287
11170
  if (record === void 0) return "";
11288
- const recordNodeId = (0, import_agent_qa_schema43.recordGraphNode)(
11171
+ const recordNodeId = (0, import_agent_qa_schema42.recordGraphNode)(
11289
11172
  recordKind(record.kind),
11290
11173
  String(record.bundle_id)
11291
11174
  ).nodeId;
@@ -11314,7 +11197,7 @@ function computeRenderingDrift(expected, stored) {
11314
11197
  }
11315
11198
 
11316
11199
  // src/graph-derive.ts
11317
- var import_agent_qa_schema44 = require("@vostride/agent-qa-schema");
11200
+ var import_agent_qa_schema43 = require("@vostride/agent-qa-schema");
11318
11201
  function compareText7(left, right) {
11319
11202
  return left < right ? -1 : left > right ? 1 : 0;
11320
11203
  }
@@ -11334,7 +11217,7 @@ function edgeIdentity(edge) {
11334
11217
  ].join("\0");
11335
11218
  }
11336
11219
  function node(type, naturalKey, product) {
11337
- return { nodeId: (0, import_agent_qa_schema44.graphNodeId)(type, naturalKey), type, naturalKey, product };
11220
+ return { nodeId: (0, import_agent_qa_schema43.graphNodeId)(type, naturalKey), type, naturalKey, product };
11338
11221
  }
11339
11222
  var DerivationBuilder = class {
11340
11223
  #nodes = /* @__PURE__ */ new Map();
@@ -11455,7 +11338,7 @@ function deriveLocatesViaEdges(anchors, platform, context) {
11455
11338
  const elements = [];
11456
11339
  const locators = [];
11457
11340
  for (const anchor of anchors) {
11458
- const projected = (0, import_agent_qa_schema44.anchorGraphNode)(anchor, platform);
11341
+ const projected = (0, import_agent_qa_schema43.anchorGraphNode)(anchor, platform);
11459
11342
  if (projected === null) continue;
11460
11343
  const derived = { ...projected, product: context.product };
11461
11344
  if (derived.type === "element" || derived.type === "web-element" || derived.type === "mobile-element") {
@@ -11607,7 +11490,7 @@ function recordVecMetadata(db, recordRowid) {
11607
11490
  }
11608
11491
  function identityText(bundle) {
11609
11492
  return bundle.frontmatter.anchors.flatMap(({ raw }) => {
11610
- const serialized = (0, import_agent_qa_schema45.canonicalJson)(raw);
11493
+ const serialized = (0, import_agent_qa_schema44.canonicalJson)(raw);
11611
11494
  if (raw.t === "selector") return [serialized, raw.literal];
11612
11495
  if (raw.t === "error") return [serialized, raw.message];
11613
11496
  return [serialized];
@@ -11624,7 +11507,7 @@ function insertGraphNode(db, node2, product) {
11624
11507
  INSERT OR IGNORE INTO graph_nodes (
11625
11508
  node_id, node_type, natural_key_json, product
11626
11509
  ) VALUES (?, ?, ?, ?)
11627
- `).run(node2.nodeId, node2.type, (0, import_agent_qa_schema45.canonicalJson)(node2.naturalKey), product);
11510
+ `).run(node2.nodeId, node2.type, (0, import_agent_qa_schema44.canonicalJson)(node2.naturalKey), product);
11628
11511
  }
11629
11512
  function insertGraphEdge(db, edge) {
11630
11513
  db.prepare(`
@@ -11644,10 +11527,10 @@ function insertGraphDerivation(db, projection) {
11644
11527
  for (const node2 of projection.nodes) insertGraphNode(db, node2, node2.product);
11645
11528
  for (const edge of projection.edges) insertGraphEdge(db, edge);
11646
11529
  }
11647
- function upsertRecord(db, bundle, product, priors) {
11648
- const trust = deriveBundleTrust(bundle, priors);
11649
- const digest3 = effectivePriorDigest(priors);
11650
- db.prepare("DELETE FROM meta WHERE k = 'trust_prior_digest' AND v != ?").run(digest3);
11530
+ function upsertRecord(db, bundle, product) {
11531
+ const trust = deriveBundleTrust(bundle);
11532
+ const digest2 = effectivePriorDigest();
11533
+ db.prepare("DELETE FROM meta WHERE k = 'trust_prior_digest' AND v != ?").run(digest2);
11651
11534
  db.prepare(`
11652
11535
  INSERT INTO records (
11653
11536
  bundle_id, product, mutable_state_hash, kind, subtype, scope_tier, scope_key,
@@ -11699,7 +11582,7 @@ function upsertRecord(db, bundle, product, priors) {
11699
11582
  bundle.manifest.embeddingInput,
11700
11583
  "",
11701
11584
  bundle.manifest.embeddingInput,
11702
- digest3
11585
+ digest2
11703
11586
  );
11704
11587
  const row = db.prepare("SELECT record_rowid FROM records WHERE bundle_id = ?").get(bundle.manifest.id);
11705
11588
  if (row === void 0) throw new Error(`record upsert lost bundle ${bundle.manifest.id}`);
@@ -11731,19 +11614,19 @@ function replaceFtsAndAnchors(db, bundle, product, recordRowid) {
11731
11614
  recordRowid,
11732
11615
  product,
11733
11616
  anchor.normalized.t,
11734
- (0, import_agent_qa_schema45.canonicalJson)(anchor.raw),
11735
- (0, import_agent_qa_schema45.canonicalJson)(anchor.normalized)
11617
+ (0, import_agent_qa_schema44.canonicalJson)(anchor.raw),
11618
+ (0, import_agent_qa_schema44.canonicalJson)(anchor.normalized)
11736
11619
  );
11737
11620
  }
11738
11621
  }
11739
11622
  function replaceAnchorGraph(db, bundle, product, recordRowid) {
11740
11623
  db.prepare("DELETE FROM graph_edges WHERE record_rowid = ?").run(recordRowid);
11741
- const recordNode = (0, import_agent_qa_schema45.recordGraphNode)(bundle.frontmatter.kind, bundle.manifest.id);
11624
+ const recordNode = (0, import_agent_qa_schema44.recordGraphNode)(bundle.frontmatter.kind, bundle.manifest.id);
11742
11625
  insertGraphNode(db, recordNode, product);
11743
11626
  const platform = bundlePlatform(bundle);
11744
11627
  const nodes = /* @__PURE__ */ new Map();
11745
11628
  for (const { normalized } of bundle.frontmatter.anchors) {
11746
- const node2 = (0, import_agent_qa_schema45.anchorGraphNode)(normalized, platform);
11629
+ const node2 = (0, import_agent_qa_schema44.anchorGraphNode)(normalized, platform);
11747
11630
  if (node2 !== null) nodes.set(node2.nodeId, node2);
11748
11631
  }
11749
11632
  const elementNodes = [];
@@ -11852,7 +11735,7 @@ function scrubDeadRecallRows(db, bundle, recordRowid) {
11852
11735
  embed_status = CASE WHEN embed_status = ? THEN ? ELSE ? END
11853
11736
  WHERE record_rowid = ?
11854
11737
  `).run(EMBED_STATUS_SUPPRESSED, EMBED_STATUS_SUPPRESSED, EMBED_STATUS_SCRUBBED, recordRowid);
11855
- const recordNode = (0, import_agent_qa_schema45.recordGraphNode)(bundle.frontmatter.kind, bundle.manifest.id);
11738
+ const recordNode = (0, import_agent_qa_schema44.recordGraphNode)(bundle.frontmatter.kind, bundle.manifest.id);
11856
11739
  db.prepare(`
11857
11740
  DELETE FROM graph_edges
11858
11741
  WHERE record_rowid = ?
@@ -11861,13 +11744,12 @@ function scrubDeadRecallRows(db, bundle, recordRowid) {
11861
11744
  `).run(recordRowid, recordNode.nodeId, recordNode.nodeId);
11862
11745
  deleteOrphanGraphNodes(db);
11863
11746
  }
11864
- function projectBundle(db, vec, projected, activeProfile, authority, beforeCommit, hooks, priors) {
11747
+ function projectBundle(db, vec, projected, activeProfile, authority, beforeCommit, hooks) {
11865
11748
  transaction(db, () => {
11866
11749
  const { recordRowid, status } = upsertRecord(
11867
11750
  db,
11868
11751
  projected.bundle,
11869
- projected.product,
11870
- priors
11752
+ projected.product
11871
11753
  );
11872
11754
  replaceFtsAndAnchors(db, projected.bundle, projected.product, recordRowid);
11873
11755
  if (isDeadStatus(status)) {
@@ -11890,7 +11772,6 @@ function projectBundleIndexRowWithinCurrentAuthority(opts) {
11890
11772
  projectBundleIndexRowWithAuthority(opts, { withinHeldAuthority: true });
11891
11773
  }
11892
11774
  function projectBundleIndexRowWithAuthority(opts, authority) {
11893
- const priors = opts.priors === void 0 ? void 0 : (0, import_agent_qa_schema45.guardTrustPriorTable)(opts.priors);
11894
11775
  const target = resolveProductQualifiedBundleDir({
11895
11776
  knowledgeRoot: opts.knowledgeRoot,
11896
11777
  recordId: opts.bundleId,
@@ -11914,7 +11795,7 @@ function projectBundleIndexRowWithAuthority(opts, authority) {
11914
11795
  const writer = openIndexWriter(opts.knowledgeRoot);
11915
11796
  const activeProfile = resolveActiveProfile(writer.db);
11916
11797
  try {
11917
- projectBundle(writer.db, writer.vec, projected, activeProfile, authority, void 0, void 0, priors);
11798
+ projectBundle(writer.db, writer.vec, projected, activeProfile, authority);
11918
11799
  emitRelationEdges(writer.db, [projected], authority);
11919
11800
  const scanIssues = [];
11920
11801
  emitObservationEdges(
@@ -11941,14 +11822,14 @@ function emitRelationEdges(db, relationSources, authority) {
11941
11822
  const sourceRow = db.prepare("SELECT record_rowid, status FROM records WHERE bundle_id = ?").get(bundle.manifest.id);
11942
11823
  if (sourceRow === void 0 || isDeadStatus(sourceRow.status)) continue;
11943
11824
  const recordRowid = Number(sourceRow.record_rowid);
11944
- const sourceNode = (0, import_agent_qa_schema45.recordGraphNode)(bundle.frontmatter.kind, bundle.manifest.id);
11825
+ const sourceNode = (0, import_agent_qa_schema44.recordGraphNode)(bundle.frontmatter.kind, bundle.manifest.id);
11945
11826
  for (const relation of bundle.relations.relations) {
11946
11827
  const targetRow = db.prepare("SELECT kind, status FROM records WHERE bundle_id = ?").get(relation.targetId);
11947
11828
  if (targetRow === void 0 || isDeadStatus(targetRow.status) && relation.type !== "renamed-from") {
11948
11829
  continue;
11949
11830
  }
11950
11831
  const targetKind = targetRow.kind;
11951
- const targetNode = (0, import_agent_qa_schema45.recordGraphNode)(targetKind, relation.targetId);
11832
+ const targetNode = (0, import_agent_qa_schema44.recordGraphNode)(targetKind, relation.targetId);
11952
11833
  insertGraphNode(db, targetNode, product);
11953
11834
  insertGraphEdge(db, {
11954
11835
  srcNodeId: sourceNode.nodeId,
@@ -11963,11 +11844,11 @@ function emitRelationEdges(db, relationSources, authority) {
11963
11844
  }, authority);
11964
11845
  }
11965
11846
  function safeObservationPath(knowledgeRoot, source) {
11966
- const bundleDir2 = (0, import_node_path32.basename)(source.dir);
11967
- if (source.product === "" || source.product === "." || source.product === ".." || source.product !== (0, import_node_path32.basename)(source.product) || bundleDir2 === "" || bundleDir2 === "." || bundleDir2 === ".." || source.dir !== (0, import_node_path32.join)(knowledgeRoot, "memory", source.product, "bundles", bundleDir2)) {
11847
+ const bundleDir2 = (0, import_node_path31.basename)(source.dir);
11848
+ if (source.product === "" || source.product === "." || source.product === ".." || source.product !== (0, import_node_path31.basename)(source.product) || bundleDir2 === "" || bundleDir2 === "." || bundleDir2 === ".." || source.dir !== (0, import_node_path31.join)(knowledgeRoot, "memory", source.product, "bundles", bundleDir2)) {
11968
11849
  return void 0;
11969
11850
  }
11970
- return (0, import_node_path32.join)(source.dir, "observations.jsonl");
11851
+ return (0, import_node_path31.join)(source.dir, "observations.jsonl");
11971
11852
  }
11972
11853
  function loadObservations(knowledgeRoot, source, scanIssues) {
11973
11854
  const observationPath = safeObservationPath(knowledgeRoot, source);
@@ -11988,7 +11869,7 @@ function loadObservations(knowledgeRoot, source, scanIssues) {
11988
11869
  if (lines.at(-1) === "") lines.pop();
11989
11870
  for (const [index, line] of lines.entries()) {
11990
11871
  try {
11991
- observations.push((0, import_agent_qa_schema45.guardDistilledObservation)(JSON.parse(line)));
11872
+ observations.push((0, import_agent_qa_schema44.guardDistilledObservation)(JSON.parse(line)));
11992
11873
  } catch (error) {
11993
11874
  scanIssues.push(`${observationPath}:${index + 1}: ${errorMessage4(error)}`);
11994
11875
  }
@@ -12179,7 +12060,7 @@ function refreshContextualRenderings(db, force = false, authority) {
12179
12060
  return refreshed;
12180
12061
  }
12181
12062
  function deleteRecordProjectionRows(db, recordRowid, bundleId, kind) {
12182
- const recordNode = (0, import_agent_qa_schema45.recordGraphNode)(kind, bundleId);
12063
+ const recordNode = (0, import_agent_qa_schema44.recordGraphNode)(kind, bundleId);
12183
12064
  deleteRecordFromAllSchemaVecTables(db, recordRowid);
12184
12065
  db.prepare("DELETE FROM fts_records WHERE rowid = ?").run(recordRowid);
12185
12066
  db.prepare("DELETE FROM anchors WHERE record_rowid = ?").run(recordRowid);
@@ -12326,8 +12207,7 @@ function reconcileVecRows(db, vec, activeProfile, authority) {
12326
12207
  }, authority);
12327
12208
  }
12328
12209
  async function rebuildIndex(opts) {
12329
- const priors = snapshotTrustPriors(opts.priors);
12330
- const digest3 = effectivePriorDigest(priors);
12210
+ const digest2 = effectivePriorDigest();
12331
12211
  const writerAuthority = opts.writerAuthority;
12332
12212
  if (writerAuthority !== void 0 && writerAuthority.knowledgeRoot !== opts.knowledgeRoot) {
12333
12213
  throw new TypeError("rebuild writerAuthority must belong to knowledgeRoot");
@@ -12362,12 +12242,12 @@ async function rebuildIndex(opts) {
12362
12242
  for (const entry of enumerateBundleDirs(opts.knowledgeRoot)) {
12363
12243
  const outcome = loadBundle(entry.dir);
12364
12244
  if (outcome.kind === "incomplete") {
12365
- seenBundleIds.add((0, import_node_path32.basename)(entry.dir));
12245
+ seenBundleIds.add((0, import_node_path31.basename)(entry.dir));
12366
12246
  report.skippedIncomplete += 1;
12367
12247
  continue;
12368
12248
  }
12369
12249
  if (outcome.kind !== "loaded") {
12370
- seenBundleIds.add((0, import_node_path32.basename)(entry.dir));
12250
+ seenBundleIds.add((0, import_node_path31.basename)(entry.dir));
12371
12251
  const reason = "reason" in outcome ? `: ${outcome.reason}` : "";
12372
12252
  report.scanIssues.push(`${entry.dir}: ${outcome.kind}${reason}`);
12373
12253
  continue;
@@ -12387,9 +12267,9 @@ async function rebuildIndex(opts) {
12387
12267
  `).get(outcome.bundle.manifest.id);
12388
12268
  processedBundles += 1;
12389
12269
  if (current?.mutable_state_hash === outcome.bundle.manifest.mutableStateHash) {
12390
- if (current.trust_prior_digest !== digest3) {
12270
+ if (current.trust_prior_digest !== digest2) {
12391
12271
  transaction(writer.db, () => {
12392
- writer.db.prepare("UPDATE records SET trust = ?, trust_prior_digest = ? WHERE bundle_id = ?").run(deriveBundleTrust(outcome.bundle, priors).trust, digest3, outcome.bundle.manifest.id);
12272
+ writer.db.prepare("UPDATE records SET trust = ?, trust_prior_digest = ? WHERE bundle_id = ?").run(deriveBundleTrust(outcome.bundle).trust, digest2, outcome.bundle.manifest.id);
12393
12273
  }, authority, opts.hooks?.beforeTransactionCommit, { family: "project-bundle", hooks: opts.hooks });
12394
12274
  report.projected += 1;
12395
12275
  }
@@ -12410,8 +12290,7 @@ async function rebuildIndex(opts) {
12410
12290
  activeProfile,
12411
12291
  authority,
12412
12292
  opts.hooks?.beforeTransactionCommit,
12413
- opts.hooks,
12414
- priors
12293
+ opts.hooks
12415
12294
  );
12416
12295
  projected.push(item);
12417
12296
  report.projected += 1;
@@ -12458,9 +12337,9 @@ async function rebuildIndex(opts) {
12458
12337
  );
12459
12338
  if (writerAuthority !== void 0 && report.skippedIncomplete === 0 && report.scanIssues.length === 0) {
12460
12339
  transaction(writer.db, () => {
12461
- const mixed = writer.db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest3);
12340
+ const mixed = writer.db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest2);
12462
12341
  if (mixed !== void 0) return;
12463
- writer.db.prepare("INSERT INTO meta (k, v) VALUES ('trust_prior_digest', ?) ON CONFLICT(k) DO UPDATE SET v = excluded.v").run(digest3);
12342
+ writer.db.prepare("INSERT INTO meta (k, v) VALUES ('trust_prior_digest', ?) ON CONFLICT(k) DO UPDATE SET v = excluded.v").run(digest2);
12464
12343
  }, authority, void 0, { family: "complete-trust-epoch", hooks: opts.hooks });
12465
12344
  }
12466
12345
  report.pendingEmbeddings = selectPendingEmbeddingRows(writer.db).length;
@@ -12481,9 +12360,9 @@ async function rebuildIndex(opts) {
12481
12360
 
12482
12361
  // src/projection/run-outcomes.ts
12483
12362
  var import_node_fs30 = require("node:fs");
12484
- var import_node_path33 = require("node:path");
12363
+ var import_node_path32 = require("node:path");
12364
+ var import_agent_qa_schema46 = require("@vostride/agent-qa-schema");
12485
12365
  var import_agent_qa_schema47 = require("@vostride/agent-qa-schema");
12486
- var import_agent_qa_schema48 = require("@vostride/agent-qa-schema");
12487
12366
 
12488
12367
  // src/projection/path-present.ts
12489
12368
  var import_node_fs29 = require("node:fs");
@@ -12564,12 +12443,12 @@ function failureRecurrence(history, currentBuildOrdinal) {
12564
12443
  }
12565
12444
 
12566
12445
  // src/projection/suite-fingerprints.ts
12567
- var import_agent_qa_schema46 = require("@vostride/agent-qa-schema");
12446
+ var import_agent_qa_schema45 = require("@vostride/agent-qa-schema");
12568
12447
  var SUITE_FINGERPRINTS_TABLE = "suite_fingerprints";
12569
12448
  function suiteFingerprintDeltas(members) {
12570
12449
  const byIdentity = /* @__PURE__ */ new Map();
12571
12450
  for (const member of members) {
12572
- const elements = (0, import_agent_qa_schema46.testFingerprintElements)(member);
12451
+ const elements = (0, import_agent_qa_schema45.testFingerprintElements)(member);
12573
12452
  if (elements.length === 0) continue;
12574
12453
  byIdentity.set(`${member.filePath}\0${member.testName}`, {
12575
12454
  filePath: member.filePath,
@@ -12665,7 +12544,7 @@ var RUN_OUTCOMES_PROJECTION_VERSION = 2;
12665
12544
  var RUN_HANDOFF_FILE = "handoff.json";
12666
12545
  function projectionPartition(scope) {
12667
12546
  return {
12668
- product: (0, import_agent_qa_schema47.slugBranch)(scope.key),
12547
+ product: (0, import_agent_qa_schema46.slugBranch)(scope.key),
12669
12548
  scopeTier: scope.tier,
12670
12549
  scopeKey: scope.key
12671
12550
  };
@@ -12688,7 +12567,7 @@ function resolveProjectionClasses(handoff, artifact) {
12688
12567
  for (const member of members) {
12689
12568
  if (member.rootCause !== void 0) verdicts.set(member.testIndex, member.rootCause);
12690
12569
  }
12691
- for (const verdict of (0, import_agent_qa_schema47.resolveRunVerdicts)(artifact, { ...handoff, tests: members })) {
12570
+ for (const verdict of (0, import_agent_qa_schema46.resolveRunVerdicts)(artifact, { ...handoff, tests: members })) {
12692
12571
  verdicts.set(verdict.perTest, verdict);
12693
12572
  }
12694
12573
  return verdicts;
@@ -12700,7 +12579,7 @@ function testDelta(test, extractAnchors, resolvedVerdicts) {
12700
12579
  const anchorKeys = /* @__PURE__ */ new Set();
12701
12580
  for (const step of steps) {
12702
12581
  for (const anchor of extractAnchors(step)) {
12703
- anchorKeys.add((0, import_agent_qa_schema47.canonicalJson)((0, import_agent_qa_schema47.normalizeAnchor)(anchor)));
12582
+ anchorKeys.add((0, import_agent_qa_schema46.canonicalJson)((0, import_agent_qa_schema46.normalizeAnchor)(anchor)));
12704
12583
  }
12705
12584
  }
12706
12585
  const resolved = resolvedVerdicts.get(test.testIndex);
@@ -12715,12 +12594,12 @@ function testDelta(test, extractAnchors, resolvedVerdicts) {
12715
12594
  };
12716
12595
  }
12717
12596
  function failureKey(test, resolved) {
12718
- const step = (0, import_agent_qa_schema47.failingStepOf)(test);
12719
- const anchors = step === void 0 ? [] : (0, import_agent_qa_schema47.exercisedAnchors)(step);
12597
+ const step = (0, import_agent_qa_schema46.failingStepOf)(test);
12598
+ const anchors = step === void 0 ? [] : (0, import_agent_qa_schema46.exercisedAnchors)(step);
12720
12599
  const verdictClass = resolved?.class ?? "unknown";
12721
12600
  return {
12722
- fingerprint: (0, import_agent_qa_schema47.failureFingerprint)(
12723
- { anchors, errorText: (0, import_agent_qa_schema47.errorTextOf)(step, test) },
12601
+ fingerprint: (0, import_agent_qa_schema46.failureFingerprint)(
12602
+ { anchors, errorText: (0, import_agent_qa_schema46.errorTextOf)(step, test) },
12724
12603
  verdictClass
12725
12604
  ),
12726
12605
  verdictClass,
@@ -12759,7 +12638,7 @@ function mergeOutcomeEntries(existingJson, entry) {
12759
12638
  entries.sort(
12760
12639
  (a, b) => a.buildOrdinal - b.buildOrdinal || Number(a.passed) - Number(b.passed)
12761
12640
  );
12762
- return (0, import_agent_qa_schema47.canonicalJson)(entries.slice(-LAST_OUTCOMES_LIMIT));
12641
+ return (0, import_agent_qa_schema46.canonicalJson)(entries.slice(-LAST_OUTCOMES_LIMIT));
12763
12642
  }
12764
12643
  function runAlreadyApplied(db, product, runId) {
12765
12644
  return db.prepare(`
@@ -12876,13 +12755,13 @@ function isErrnoHostFault(error) {
12876
12755
  function loadRunArtifact(runDir, runId) {
12877
12756
  let bytes;
12878
12757
  try {
12879
- bytes = (0, import_node_fs30.readFileSync)((0, import_node_path33.join)(runDir, import_agent_qa_schema47.ANALYSIS_FILE), "utf8");
12758
+ bytes = (0, import_node_fs30.readFileSync)((0, import_node_path32.join)(runDir, import_agent_qa_schema46.ANALYSIS_FILE), "utf8");
12880
12759
  } catch (error) {
12881
12760
  if (isAbsenceErrno(error)) return void 0;
12882
12761
  throw error;
12883
12762
  }
12884
- const admission = (0, import_agent_qa_schema47.admitAnalysisArtifactForRun)(
12885
- (0, import_agent_qa_schema47.guardRunAnalysisArtifact)(JSON.parse(bytes)),
12763
+ const admission = (0, import_agent_qa_schema46.admitAnalysisArtifactForRun)(
12764
+ (0, import_agent_qa_schema46.guardRunAnalysisArtifact)(JSON.parse(bytes)),
12886
12765
  runId
12887
12766
  );
12888
12767
  return admission.kind === "admitted" ? admission.artifact : void 0;
@@ -12896,7 +12775,7 @@ function loadRebuildHandoff(file) {
12896
12775
  throw error;
12897
12776
  }
12898
12777
  try {
12899
- const guarded = (0, import_agent_qa_schema47.guardCompletedRunHandoff)(JSON.parse(bytes));
12778
+ const guarded = (0, import_agent_qa_schema46.guardCompletedRunHandoff)(JSON.parse(bytes));
12900
12779
  const tests = guarded.tests;
12901
12780
  if (tests !== void 0 && !Array.isArray(tests)) return void 0;
12902
12781
  const structurallyCurrent = (tests ?? []).every((test) => {
@@ -12919,9 +12798,9 @@ function rebuildRunOutcomes(db, runsRoot, opts) {
12919
12798
  const loaded = [];
12920
12799
  const report = { folded: 0, skippedHandoffs: 0, skippedArtifacts: 0 };
12921
12800
  if (pathPresent(runsRoot, "directory") === "present") {
12922
- const runDirs = (0, import_node_fs30.readdirSync)(runsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => (0, import_node_path33.join)(runsRoot, entry.name)).filter((dir) => pathPresent((0, import_node_path33.join)(dir, RUN_HANDOFF_FILE), "file") === "present").sort();
12801
+ const runDirs = (0, import_node_fs30.readdirSync)(runsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => (0, import_node_path32.join)(runsRoot, entry.name)).filter((dir) => pathPresent((0, import_node_path32.join)(dir, RUN_HANDOFF_FILE), "file") === "present").sort();
12923
12802
  for (const runDir of runDirs) {
12924
- const handoff = loadRebuildHandoff((0, import_node_path33.join)(runDir, RUN_HANDOFF_FILE));
12803
+ const handoff = loadRebuildHandoff((0, import_node_path32.join)(runDir, RUN_HANDOFF_FILE));
12925
12804
  if (handoff === void 0) {
12926
12805
  report.skippedHandoffs += 1;
12927
12806
  continue;
@@ -12981,7 +12860,7 @@ function evaluateQuarantineForFold(db, projection, knowledgeRoot, opts) {
12981
12860
  try {
12982
12861
  read = readQuarantineLedger(knowledgeRoot);
12983
12862
  } catch (error) {
12984
- if (error instanceof import_agent_qa_schema48.QuarantineLedgerVersionError) {
12863
+ if (error instanceof import_agent_qa_schema47.QuarantineLedgerVersionError) {
12985
12864
  return { kind: "ledger-unreadable", reason: error.message };
12986
12865
  }
12987
12866
  throw error;
@@ -12994,21 +12873,7 @@ function evaluateQuarantineForFold(db, projection, knowledgeRoot, opts) {
12994
12873
  fingerprint: test.failure.fingerprint,
12995
12874
  verdictClass: test.failure.verdictClass,
12996
12875
  producer: test.failure.producer,
12997
- // THE PER-CROSSING FLAKE SIGNATURE, read from this test's OWN outcome window (390-21).
12998
- // `hasSameBuildPassAndFail` is called rather than re-derived: the exit path's
12999
- // `distinctOrdinalOutcomes` and this entry-side read share one `groupByBuildOrdinal`, so
13000
- // "what a build ordinal is" has exactly one spelling and the two directions cannot drift.
13001
- // A test with no history row answers false through the `?? []` — typed absence, never a
13002
- // throw and never a fabricated window. (Defensive in-tree: the reads below run after
13003
- // `applyRunOutcomes` returned `applied`, so a crossing test always has a row by now.)
13004
- //
13005
- // AND IT IS SCOPED TO THIS CROSSING'S OWN RECURRENCE WINDOW (390-24, WR-05). The per-test
13006
- // outcome window keeps LAST_OUTCOMES_LIMIT entries, which is DEEPER than the detection
13007
- // window, so an unscoped read let a since-fixed flake episode license a new hard regression
13008
- // several ordinals later — the gate silencing exactly what the disposition table exists to
13009
- // keep failing the build. The floor here is `fingerprintRecurrence`'s floor, from the same
13010
- // export: the evidence and the count are bounded by ONE window, so evidence expires with the
13011
- // window that licensed nothing (D-07 windows-forgive; D-05 anti-silencing).
12876
+ // Scoped to this crossing's recurrence window, so old flake evidence licenses nothing.
13012
12877
  sameBuildPassAndFail: hasSameBuildPassAndFail(
13013
12878
  (readTestOutcomeHistory(db, {
13014
12879
  product: projection.product,
@@ -13086,14 +12951,14 @@ function foldRunOutcomes(opts) {
13086
12951
 
13087
12952
  // src/gc.ts
13088
12953
  var import_node_fs31 = require("node:fs");
13089
- var import_node_path34 = require("node:path");
13090
- var import_agent_qa_schema49 = require("@vostride/agent-qa-schema");
12954
+ var import_node_path33 = require("node:path");
12955
+ var import_agent_qa_schema48 = require("@vostride/agent-qa-schema");
13091
12956
  var GC_SUPERSEDED_RETAIN_K = 3;
13092
12957
  function compareText8(left, right) {
13093
12958
  return left < right ? -1 : left > right ? 1 : 0;
13094
12959
  }
13095
12960
  function validateInput(input) {
13096
- if (!(0, import_node_path34.isAbsolute)(input.knowledgeRoot)) {
12961
+ if (!(0, import_node_path33.isAbsolute)(input.knowledgeRoot)) {
13097
12962
  throw new TypeError("runKnowledgeGc knowledgeRoot must be absolute");
13098
12963
  }
13099
12964
  const retainK = input.retainK ?? GC_SUPERSEDED_RETAIN_K;
@@ -13112,7 +12977,7 @@ function loadGcBundles(knowledgeRoot) {
13112
12977
  for (const entry of enumerateBundleDirs(knowledgeRoot)) {
13113
12978
  const loaded = loadBundle(entry.dir);
13114
12979
  if (loaded.kind !== "loaded") continue;
13115
- const recordId = (0, import_agent_qa_schema49.asRecordId)(loaded.bundle.manifest.id);
12980
+ const recordId = (0, import_agent_qa_schema48.asRecordId)(loaded.bundle.manifest.id);
13116
12981
  bundles.set(recordId, {
13117
12982
  recordId,
13118
12983
  dir: entry.dir,
@@ -13123,19 +12988,19 @@ function loadGcBundles(knowledgeRoot) {
13123
12988
  return bundles;
13124
12989
  }
13125
12990
  function latestBuildOrdinal(bundles) {
13126
- let latest2 = 1;
12991
+ let latest = 1;
13127
12992
  for (const bundle of bundles) {
13128
- latest2 = Math.max(latest2, bundle.createdAtOrdinal);
13129
- for (const event of bundle.events) latest2 = Math.max(latest2, event.buildOrdinal);
12993
+ latest = Math.max(latest, bundle.createdAtOrdinal);
12994
+ for (const event of bundle.events) latest = Math.max(latest, event.buildOrdinal);
13130
12995
  }
13131
- return latest2;
12996
+ return latest;
13132
12997
  }
13133
12998
  function latestSupersessionOrdinal(bundle) {
13134
- let latest2 = bundle.createdAtOrdinal;
13135
- for (const event of (0, import_agent_qa_schema49.survivingOutcomeEvents)(bundle.events)) {
13136
- if (event.type === "superseded") latest2 = Math.max(latest2, event.buildOrdinal);
12999
+ let latest = bundle.createdAtOrdinal;
13000
+ for (const event of (0, import_agent_qa_schema48.survivingOutcomeEvents)(bundle.events)) {
13001
+ if (event.type === "superseded") latest = Math.max(latest, event.buildOrdinal);
13137
13002
  }
13138
- return latest2;
13003
+ return latest;
13139
13004
  }
13140
13005
  function unknownConflictRecordIds(bundle) {
13141
13006
  let parsed;
@@ -13573,7 +13438,7 @@ function verifyEmbedderWorkerIncarnation(registration) {
13573
13438
 
13574
13439
  // src/queue/queue-payload.ts
13575
13440
  var import_zod9 = require("zod");
13576
- var import_agent_qa_schema50 = require("@vostride/agent-qa-schema");
13441
+ var import_agent_qa_schema49 = require("@vostride/agent-qa-schema");
13577
13442
  var CURATION_QUEUE_SCHEMA_VERSION = 2;
13578
13443
  var SHA256_HEX = /^[0-9a-f]{64}$/;
13579
13444
  var scopeSchema = import_zod9.z.object({
@@ -13644,15 +13509,12 @@ var candidateSeedShape = {
13644
13509
  executionContext: executionContextSchema,
13645
13510
  kind: bundleKindSchema,
13646
13511
  subtype: factSubtypeSchema.optional(),
13647
- /**
13648
- * 379 D-16 additive-optional typed caution evidence. Existing queue-v2
13649
- * bytes remain valid; when present this real evidence joins the address.
13650
- */
13651
- rootCauseClass: import_agent_qa_schema50.cautionRootCauseClassSchema.optional(),
13512
+ // Optional, so existing queue-v2 bytes stay valid; when present it joins the address.
13513
+ rootCauseClass: import_agent_qa_schema49.cautionRootCauseClassSchema.optional(),
13652
13514
  anchors: import_zod9.z.array(anchorSchema).min(1),
13653
13515
  summarySeed: import_zod9.z.string(),
13654
13516
  bodySeed: import_zod9.z.string(),
13655
- distilledObservations: import_zod9.z.array(import_agent_qa_schema50.distilledObservationSchema),
13517
+ distilledObservations: import_zod9.z.array(import_agent_qa_schema49.distilledObservationSchema),
13656
13518
  evidenceToken: import_zod9.z.string().min(1),
13657
13519
  attributingObservationId: import_zod9.z.string().min(1)
13658
13520
  };
@@ -13741,21 +13603,21 @@ function buildCurationCandidateAddressFields(input) {
13741
13603
  function candidateContentAddress(fields) {
13742
13604
  const parsed = curationCandidateAddressFieldsSchema.parse(fields);
13743
13605
  const { emittedAt: _diagnostic, ...deterministic } = parsed;
13744
- return (0, import_agent_qa_schema50.sha256hex)((0, import_agent_qa_schema50.canonicalJson)(deterministic));
13606
+ return (0, import_agent_qa_schema49.sha256hex)((0, import_agent_qa_schema49.canonicalJson)(deterministic));
13745
13607
  }
13746
13608
 
13747
13609
  // src/queue/curation-queue.ts
13748
13610
  var import_node_crypto16 = require("node:crypto");
13749
13611
  var import_node_fs33 = require("node:fs");
13750
- var import_node_path36 = require("node:path");
13751
- var import_agent_qa_schema52 = require("@vostride/agent-qa-schema");
13612
+ var import_node_path35 = require("node:path");
13613
+ var import_agent_qa_schema51 = require("@vostride/agent-qa-schema");
13752
13614
  var import_zod11 = require("zod");
13753
13615
 
13754
13616
  // src/queue/job-state.ts
13755
13617
  var import_node_crypto15 = require("node:crypto");
13756
13618
  var import_node_fs32 = require("node:fs");
13757
- var import_node_path35 = require("node:path");
13758
- var import_agent_qa_schema51 = require("@vostride/agent-qa-schema");
13619
+ var import_node_path34 = require("node:path");
13620
+ var import_agent_qa_schema50 = require("@vostride/agent-qa-schema");
13759
13621
  var import_zod10 = require("zod");
13760
13622
  var CURATION_JOB_STATE_SCHEMA_VERSION = 2;
13761
13623
  var jobLifecycleSchema = import_zod10.z.enum([
@@ -13770,9 +13632,7 @@ var curationJobStateSchema = import_zod10.z.object({
13770
13632
  candidateId: import_zod10.z.string().regex(/^[0-9a-f]{64}$/),
13771
13633
  lifecycle: jobLifecycleSchema,
13772
13634
  embedCrashCount: import_zod10.z.number().int().nonnegative().default(0),
13773
- /**
13774
- * Opaque transport slot. Plan 378-06's authoredCheckpointSchema owns semantic validation.
13775
- */
13635
+ // Opaque transport slot; the authored checkpoint schema validates its contents.
13776
13636
  authored: import_zod10.z.unknown().optional(),
13777
13637
  /** Diagnostic wall-clock metadata only; never identity, ordering, or disposition input. */
13778
13638
  updatedAt: import_zod10.z.string()
@@ -13800,18 +13660,18 @@ function removeEmptyDir2(dir) {
13800
13660
  }
13801
13661
  }
13802
13662
  function atomicRewrite3(file, state) {
13803
- (0, import_node_fs32.mkdirSync)((0, import_node_path35.dirname)(file), { recursive: true });
13663
+ (0, import_node_fs32.mkdirSync)((0, import_node_path34.dirname)(file), { recursive: true });
13804
13664
  const temporary = `${file}.tmp-${(0, import_node_crypto15.randomUUID)()}`;
13805
13665
  let fd;
13806
13666
  try {
13807
13667
  fd = (0, import_node_fs32.openSync)(temporary, "wx");
13808
- (0, import_node_fs32.writeFileSync)(fd, `${(0, import_agent_qa_schema51.canonicalJson)(state)}
13668
+ (0, import_node_fs32.writeFileSync)(fd, `${(0, import_agent_qa_schema50.canonicalJson)(state)}
13809
13669
  `);
13810
13670
  (0, import_node_fs32.fsyncSync)(fd);
13811
13671
  (0, import_node_fs32.closeSync)(fd);
13812
13672
  fd = void 0;
13813
13673
  (0, import_node_fs32.renameSync)(temporary, file);
13814
- bestEffortFsyncDirectory4((0, import_node_path35.dirname)(file));
13674
+ bestEffortFsyncDirectory4((0, import_node_path34.dirname)(file));
13815
13675
  } finally {
13816
13676
  if (fd !== void 0) (0, import_node_fs32.closeSync)(fd);
13817
13677
  (0, import_node_fs32.rmSync)(temporary, { force: true });
@@ -13931,7 +13791,7 @@ function inspectDrainableCurationWork(options) {
13931
13791
  };
13932
13792
  }
13933
13793
  function readCurationCandidatePayload(candidateDir) {
13934
- const file = (0, import_node_path36.join)(candidateDir, "payload.json");
13794
+ const file = (0, import_node_path35.join)(candidateDir, "payload.json");
13935
13795
  let raw;
13936
13796
  try {
13937
13797
  raw = (0, import_node_fs33.readFileSync)(file, "utf8");
@@ -13940,7 +13800,7 @@ function readCurationCandidatePayload(candidateDir) {
13940
13800
  }
13941
13801
  try {
13942
13802
  const parsed = curationCandidatePayloadSchema.safeParse(JSON.parse(raw));
13943
- return parsed.success && parsed.data.candidateId === (0, import_node_path36.basename)(candidateDir) ? { kind: "parsed", present: true, payload: parsed.data } : { kind: "malformed", present: true };
13803
+ return parsed.success && parsed.data.candidateId === (0, import_node_path35.basename)(candidateDir) ? { kind: "parsed", present: true, payload: parsed.data } : { kind: "malformed", present: true };
13944
13804
  } catch {
13945
13805
  return { kind: "malformed", present: true };
13946
13806
  }
@@ -13998,8 +13858,8 @@ function claimNextJob(opts) {
13998
13858
  bestEffortFsyncDirectory2(leaseDir);
13999
13859
  bestEffortFsyncDirectory2(queuedRoot(opts.knowledgeRoot));
14000
13860
  initializeClaimedState(opts.knowledgeRoot, candidateId, opts.authority);
14001
- const payloadPath = (0, import_node_path36.join)(candidateDir, "payload.json");
14002
- const artifactsDir = (0, import_node_path36.join)(candidateDir, "artifacts");
13861
+ const payloadPath = (0, import_node_path35.join)(candidateDir, "payload.json");
13862
+ const artifactsDir = (0, import_node_path35.join)(candidateDir, "artifacts");
14003
13863
  const payload = readCurationCandidatePayload(candidateDir);
14004
13864
  if (payload.kind !== "parsed") {
14005
13865
  return {
@@ -14103,11 +13963,11 @@ function quarantineClaimed(opts) {
14103
13963
  if ((0, import_node_fs33.existsSync)(targetDir)) return targetDir;
14104
13964
  throw new Error(`claimed candidate ${opts.candidateId} is absent`);
14105
13965
  }
14106
- const reasonPath = (0, import_node_path36.join)(sourceDir, CURATION_QUARANTINE_FILE);
13966
+ const reasonPath = (0, import_node_path35.join)(sourceDir, CURATION_QUARANTINE_FILE);
14107
13967
  if (!(0, import_node_fs33.existsSync)(reasonPath)) {
14108
13968
  durableWrite(
14109
13969
  reasonPath,
14110
- `${(0, import_agent_qa_schema52.canonicalJson)({
13970
+ `${(0, import_agent_qa_schema51.canonicalJson)({
14111
13971
  schemaVersion: CURATION_QUARANTINE_SCHEMA_VERSION,
14112
13972
  candidateId: opts.candidateId,
14113
13973
  leaseId: opts.leaseId,
@@ -14119,10 +13979,10 @@ function quarantineClaimed(opts) {
14119
13979
  }
14120
13980
  const statePath = jobStatePath(opts.knowledgeRoot, opts.candidateId);
14121
13981
  if ((0, import_node_fs33.existsSync)(statePath)) {
14122
- const firstArchive = (0, import_node_path36.join)(sourceDir, "job-state.json");
13982
+ const firstArchive = (0, import_node_path35.join)(sourceDir, "job-state.json");
14123
13983
  (0, import_node_fs33.renameSync)(
14124
13984
  statePath,
14125
- (0, import_node_fs33.existsSync)(firstArchive) ? (0, import_node_path36.join)(sourceDir, `job-state-${(0, import_node_crypto16.randomUUID)()}.json`) : firstArchive
13985
+ (0, import_node_fs33.existsSync)(firstArchive) ? (0, import_node_path35.join)(sourceDir, `job-state-${(0, import_node_crypto16.randomUUID)()}.json`) : firstArchive
14126
13986
  );
14127
13987
  bestEffortFsyncDirectory2(jobsRoot(opts.knowledgeRoot));
14128
13988
  }
@@ -14151,9 +14011,9 @@ function quarantineClaimed(opts) {
14151
14011
  function queueCapExceeded(knowledgeRoot, payload) {
14152
14012
  let scopeCount = 0;
14153
14013
  let sourceRunCount = 0;
14154
- const scopeKey = (0, import_agent_qa_schema52.canonicalJson)(payload.scope);
14014
+ const scopeKey = (0, import_agent_qa_schema51.canonicalJson)(payload.scope);
14155
14015
  for (const queued of queuedPayloads(knowledgeRoot)) {
14156
- if ((0, import_agent_qa_schema52.canonicalJson)(queued.scope) === scopeKey) scopeCount += 1;
14016
+ if ((0, import_agent_qa_schema51.canonicalJson)(queued.scope) === scopeKey) scopeCount += 1;
14157
14017
  if (queued.sourceRunId === payload.sourceRunId) sourceRunCount += 1;
14158
14018
  }
14159
14019
  return scopeCount >= QUEUE_MAX_JOBS_PER_SCOPE || sourceRunCount >= QUEUE_MAX_EMITS_PER_RUN;
@@ -14173,7 +14033,7 @@ function skippedArtifactReason(reason) {
14173
14033
  function projectionArtifactInputs(projection, artifactSources) {
14174
14034
  const sourceByArtifactId = /* @__PURE__ */ new Map();
14175
14035
  for (const source of artifactSources) {
14176
- if (source.artifactId === "" || !(0, import_node_path36.isAbsolute)(source.sourcePath) || sourceByArtifactId.has(source.artifactId)) {
14036
+ if (source.artifactId === "" || !(0, import_node_path35.isAbsolute)(source.sourcePath) || sourceByArtifactId.has(source.artifactId)) {
14177
14037
  return { kind: "refused", reason: "artifact-inventory-mismatch" };
14178
14038
  }
14179
14039
  sourceByArtifactId.set(source.artifactId, source.sourcePath);
@@ -14220,7 +14080,7 @@ function artifactInventoryFromSafeCopies(copied, descriptors) {
14220
14080
  }
14221
14081
  function fsyncCopiedArtifacts(stagingDir, copied) {
14222
14082
  for (const artifact of copied) {
14223
- const fd = (0, import_node_fs33.openSync)((0, import_node_path36.join)(stagingDir, artifact.relPath), "r");
14083
+ const fd = (0, import_node_fs33.openSync)((0, import_node_path35.join)(stagingDir, artifact.relPath), "r");
14224
14084
  try {
14225
14085
  (0, import_node_fs33.fsyncSync)(fd);
14226
14086
  } finally {
@@ -14231,7 +14091,7 @@ function fsyncCopiedArtifacts(stagingDir, copied) {
14231
14091
  function finalizeProjection(stagingDir, projection, sourceInputs, mask) {
14232
14092
  const copied = copyArtifacts(
14233
14093
  sourceInputs,
14234
- (0, import_node_path36.join)(stagingDir, "artifacts"),
14094
+ (0, import_node_path35.join)(stagingDir, "artifacts"),
14235
14095
  mask === void 0 ? {} : { mask }
14236
14096
  );
14237
14097
  const [failedCopy] = copied.skipped;
@@ -14284,7 +14144,7 @@ function enqueueCurationCandidateProjection(opts) {
14284
14144
  const stagingRoot = queueStagingRoot(opts.knowledgeRoot);
14285
14145
  assertWithinKnowledgeRoot(opts.knowledgeRoot, stagingRoot);
14286
14146
  assertWithinKnowledgeRoot(opts.knowledgeRoot, queuedRoot(opts.knowledgeRoot));
14287
- const stagingDir = (0, import_node_path36.join)(stagingRoot, (0, import_node_crypto16.randomUUID)());
14147
+ const stagingDir = (0, import_node_path35.join)(stagingRoot, (0, import_node_crypto16.randomUUID)());
14288
14148
  (0, import_node_fs33.mkdirSync)(stagingDir, { recursive: true });
14289
14149
  try {
14290
14150
  const finalized = finalizeProjection(stagingDir, projection, sourceInputs.inputs, opts.mask);
@@ -14296,9 +14156,9 @@ function enqueueCurationCandidateProjection(opts) {
14296
14156
  if (queueCapExceeded(opts.knowledgeRoot, payload)) {
14297
14157
  return { kind: "cap-exceeded", candidateId };
14298
14158
  }
14299
- durableWrite((0, import_node_path36.join)(stagingDir, "payload.json"), `${(0, import_agent_qa_schema52.canonicalJson)(payload)}
14159
+ durableWrite((0, import_node_path35.join)(stagingDir, "payload.json"), `${(0, import_agent_qa_schema51.canonicalJson)(payload)}
14300
14160
  `);
14301
- bestEffortFsyncDirectory2((0, import_node_path36.join)(stagingDir, "artifacts"));
14161
+ bestEffortFsyncDirectory2((0, import_node_path35.join)(stagingDir, "artifacts"));
14302
14162
  bestEffortFsyncDirectory2(stagingDir);
14303
14163
  const published = publishStagedQueueEntry(
14304
14164
  stagingDir,
@@ -14317,8 +14177,8 @@ var enqueueCurationCandidate = enqueueCurationCandidateProjection;
14317
14177
  // src/journal/intent-journal.ts
14318
14178
  var import_node_crypto17 = require("node:crypto");
14319
14179
  var import_node_fs34 = require("node:fs");
14320
- var import_node_path37 = require("node:path");
14321
- var import_agent_qa_schema53 = require("@vostride/agent-qa-schema");
14180
+ var import_node_path36 = require("node:path");
14181
+ var import_agent_qa_schema52 = require("@vostride/agent-qa-schema");
14322
14182
  var import_zod12 = require("zod");
14323
14183
  var JOURNAL_SUBDIR = "memory/queue/journal";
14324
14184
  var COMMIT_INTENT_SCHEMA_VERSION = 2;
@@ -14335,14 +14195,14 @@ var commitIntentSchema = import_zod12.z.object({
14335
14195
  observation: curationObservationSchema.optional()
14336
14196
  }).strict();
14337
14197
  function journalRoot(knowledgeRoot) {
14338
- if (!(0, import_node_path37.isAbsolute)(knowledgeRoot)) {
14198
+ if (!(0, import_node_path36.isAbsolute)(knowledgeRoot)) {
14339
14199
  throw new TypeError("knowledgeRoot must be absolute");
14340
14200
  }
14341
- return (0, import_node_path37.join)(knowledgeRoot, JOURNAL_SUBDIR);
14201
+ return (0, import_node_path36.join)(knowledgeRoot, JOURNAL_SUBDIR);
14342
14202
  }
14343
14203
  function intentPath(knowledgeRoot, candidateId) {
14344
14204
  const parsedCandidateId = import_zod12.z.string().regex(CANDIDATE_ID2).parse(candidateId);
14345
- return (0, import_node_path37.join)(journalRoot(knowledgeRoot), `${parsedCandidateId}.intent.json`);
14205
+ return (0, import_node_path36.join)(journalRoot(knowledgeRoot), `${parsedCandidateId}.intent.json`);
14346
14206
  }
14347
14207
  function bestEffortFsyncDirectory5(dir) {
14348
14208
  let fd;
@@ -14359,7 +14219,7 @@ function bestEffortFsyncDirectory5(dir) {
14359
14219
  }
14360
14220
  }
14361
14221
  function atomicRewrite4(file, text) {
14362
- (0, import_node_fs34.mkdirSync)((0, import_node_path37.dirname)(file), { recursive: true });
14222
+ (0, import_node_fs34.mkdirSync)((0, import_node_path36.dirname)(file), { recursive: true });
14363
14223
  const temporary = `${file}.tmp-${(0, import_node_crypto17.randomUUID)()}`;
14364
14224
  let fd;
14365
14225
  try {
@@ -14369,7 +14229,7 @@ function atomicRewrite4(file, text) {
14369
14229
  (0, import_node_fs34.closeSync)(fd);
14370
14230
  fd = void 0;
14371
14231
  (0, import_node_fs34.renameSync)(temporary, file);
14372
- bestEffortFsyncDirectory5((0, import_node_path37.dirname)(file));
14232
+ bestEffortFsyncDirectory5((0, import_node_path36.dirname)(file));
14373
14233
  } finally {
14374
14234
  if (fd !== void 0) (0, import_node_fs34.closeSync)(fd);
14375
14235
  (0, import_node_fs34.rmSync)(temporary, { force: true });
@@ -14380,14 +14240,14 @@ function writeCommitIntent(knowledgeRoot, intent) {
14380
14240
  assertWithinKnowledgeRoot(knowledgeRoot, journalRoot(knowledgeRoot));
14381
14241
  atomicRewrite4(
14382
14242
  intentPath(knowledgeRoot, parsed.candidateId),
14383
- `${(0, import_agent_qa_schema53.canonicalJson)(parsed)}
14243
+ `${(0, import_agent_qa_schema52.canonicalJson)(parsed)}
14384
14244
  `
14385
14245
  );
14386
14246
  }
14387
14247
  function readReconciledEpoch(knowledgeRoot) {
14388
14248
  let raw;
14389
14249
  try {
14390
- raw = (0, import_node_fs34.readFileSync)((0, import_node_path37.join)(knowledgeRoot, RECONCILED_EPOCH_FILE), "utf8");
14250
+ raw = (0, import_node_fs34.readFileSync)((0, import_node_path36.join)(knowledgeRoot, RECONCILED_EPOCH_FILE), "utf8");
14391
14251
  } catch {
14392
14252
  return 0;
14393
14253
  }
@@ -14397,27 +14257,27 @@ function readReconciledEpoch(knowledgeRoot) {
14397
14257
  function writeReconciledEpochWithinCurrentAuthority(knowledgeRoot, epoch) {
14398
14258
  const validated = import_zod12.z.number().int().positive().parse(epoch);
14399
14259
  assertWithinKnowledgeRoot(knowledgeRoot, journalRoot(knowledgeRoot));
14400
- atomicRewrite4((0, import_node_path37.join)(knowledgeRoot, RECONCILED_EPOCH_FILE), `${validated}
14260
+ atomicRewrite4((0, import_node_path36.join)(knowledgeRoot, RECONCILED_EPOCH_FILE), `${validated}
14401
14261
  `);
14402
14262
  }
14403
14263
  function quarantineStaleCommitIntent(knowledgeRoot, candidateId, epoch) {
14404
14264
  const file = intentPath(knowledgeRoot, candidateId);
14405
- assertWithinKnowledgeRoot(knowledgeRoot, (0, import_node_path37.dirname)(file));
14265
+ assertWithinKnowledgeRoot(knowledgeRoot, (0, import_node_path36.dirname)(file));
14406
14266
  const quarantined = `.stale-${epoch}-${candidateId}-${(0, import_node_crypto17.randomUUID)()}.intent.json`;
14407
14267
  try {
14408
- (0, import_node_fs34.renameSync)(file, (0, import_node_path37.join)((0, import_node_path37.dirname)(file), quarantined));
14268
+ (0, import_node_fs34.renameSync)(file, (0, import_node_path36.join)((0, import_node_path36.dirname)(file), quarantined));
14409
14269
  } catch (error) {
14410
14270
  if (error.code !== "ENOENT") throw error;
14411
14271
  return { kind: "already-gone" };
14412
14272
  }
14413
- bestEffortFsyncDirectory5((0, import_node_path37.dirname)(file));
14273
+ bestEffortFsyncDirectory5((0, import_node_path36.dirname)(file));
14414
14274
  return { kind: "quarantined", name: quarantined };
14415
14275
  }
14416
14276
  function clearCommitIntent(knowledgeRoot, candidateId) {
14417
14277
  const file = intentPath(knowledgeRoot, candidateId);
14418
- assertWithinKnowledgeRoot(knowledgeRoot, (0, import_node_path37.dirname)(file));
14278
+ assertWithinKnowledgeRoot(knowledgeRoot, (0, import_node_path36.dirname)(file));
14419
14279
  (0, import_node_fs34.rmSync)(file, { force: true });
14420
- bestEffortFsyncDirectory5((0, import_node_path37.dirname)(file));
14280
+ bestEffortFsyncDirectory5((0, import_node_path36.dirname)(file));
14421
14281
  }
14422
14282
  function listCommitIntents(knowledgeRoot) {
14423
14283
  let names;
@@ -14431,7 +14291,7 @@ function listCommitIntents(knowledgeRoot) {
14431
14291
  const candidateId = INTENT_FILE.exec(name)[1];
14432
14292
  try {
14433
14293
  const parsed = commitIntentSchema.safeParse(
14434
- JSON.parse((0, import_node_fs34.readFileSync)((0, import_node_path37.join)(journalRoot(knowledgeRoot), name), "utf8"))
14294
+ JSON.parse((0, import_node_fs34.readFileSync)((0, import_node_path36.join)(journalRoot(knowledgeRoot), name), "utf8"))
14435
14295
  );
14436
14296
  return parsed.success && parsed.data.candidateId === candidateId ? { parsed: parsed.data } : { malformed: true, candidateId };
14437
14297
  } catch {
@@ -14441,7 +14301,7 @@ function listCommitIntents(knowledgeRoot) {
14441
14301
  }
14442
14302
 
14443
14303
  // src/curator/author-contract.ts
14444
- var import_agent_qa_schema54 = require("@vostride/agent-qa-schema");
14304
+ var import_agent_qa_schema53 = require("@vostride/agent-qa-schema");
14445
14305
  var import_zod13 = require("zod");
14446
14306
  var AUTHORED_CHECKPOINT_SCHEMA_VERSION = 2;
14447
14307
  function resolveDispositionProfile(executionContext) {
@@ -14458,8 +14318,8 @@ function resolveDispositionProfile(executionContext) {
14458
14318
  }
14459
14319
  }
14460
14320
  }
14461
- var recordIdSchema = import_zod13.z.string().min(1).transform(import_agent_qa_schema54.asRecordId);
14462
- var evidenceTokenSchema = import_zod13.z.string().min(1).transform(import_agent_qa_schema54.asEvidenceToken);
14321
+ var recordIdSchema = import_zod13.z.string().min(1).transform(import_agent_qa_schema53.asRecordId);
14322
+ var evidenceTokenSchema = import_zod13.z.string().min(1).transform(import_agent_qa_schema53.asEvidenceToken);
14463
14323
  var scopeSchema2 = import_zod13.z.object({
14464
14324
  tier: import_zod13.z.enum(["global", "product", "suite", "test"]),
14465
14325
  key: import_zod13.z.string().min(1)
@@ -14508,7 +14368,7 @@ var bundleDraftSchema = import_zod13.z.object({
14508
14368
  body: import_zod13.z.string(),
14509
14369
  distilledEvidenceRef: artifactRefSchema2,
14510
14370
  originStage: import_zod13.z.literal("run-curation"),
14511
- /** Transient CUR-02 signal consumed when commit renders run-linked provenance. */
14371
+ // Transient signal consumed when commit renders run-linked provenance.
14512
14372
  needsEnrichment: import_zod13.z.literal(true).optional()
14513
14373
  }).strict().superRefine((bundle, ctx) => {
14514
14374
  if (bundle.kind === "fact" && bundle.subtype === void 0) {
@@ -14539,14 +14399,12 @@ var curationAuthorshipSchema = import_zod13.z.object({
14539
14399
  fingerprint: import_zod13.z.string().optional()
14540
14400
  }).strict().optional(),
14541
14401
  executionContext: import_zod13.z.enum(["local-interactive", "local-headless", "ci", "cloud"]),
14542
- // 381-47 additive-optional: an absent member still parses (pre-stamp checkpoints).
14402
+ // Optional, so a checkpoint written before the stamp still parses.
14543
14403
  fallbackReason: import_zod13.z.enum(["malformed", "no-model", "token-budget", "model-error"]).optional()
14544
14404
  }).strict();
14545
14405
  var envelopeShape = {
14546
- // Projected from the schema package's registry rather than re-listed here. A hand-written
14547
- // member list is the class of defect this phase keeps closing: it is a second vocabulary that
14548
- // has to be kept in step with the first, and nothing makes it.
14549
- origin: import_zod13.z.enum(import_agent_qa_schema54.DELTA_ORIGINS),
14406
+ // Projected from the schema registry, so no second vocabulary has to be kept in step.
14407
+ origin: import_zod13.z.enum(import_agent_qa_schema53.DELTA_ORIGINS),
14550
14408
  scope: scopeSchema2,
14551
14409
  citedIds: import_zod13.z.array(recordIdSchema),
14552
14410
  precondition: import_zod13.z.array(compareAndSetSchema).optional(),
@@ -14638,16 +14496,16 @@ function widenAuthoredDeltaCheckpoint(slice) {
14638
14496
  // src/curator/commit.ts
14639
14497
  var import_node_crypto18 = require("node:crypto");
14640
14498
  var import_node_fs35 = require("node:fs");
14641
- var import_node_path38 = require("node:path");
14642
- var import_agent_qa_schema57 = require("@vostride/agent-qa-schema");
14499
+ var import_node_path37 = require("node:path");
14500
+ var import_agent_qa_schema56 = require("@vostride/agent-qa-schema");
14643
14501
 
14644
14502
  // src/curator/disposition.ts
14645
- var import_agent_qa_schema56 = require("@vostride/agent-qa-schema");
14503
+ var import_agent_qa_schema55 = require("@vostride/agent-qa-schema");
14646
14504
 
14647
14505
  // src/serving/canary-observation-id.ts
14648
- var import_agent_qa_schema55 = require("@vostride/agent-qa-schema");
14506
+ var import_agent_qa_schema54 = require("@vostride/agent-qa-schema");
14649
14507
  function canaryOutcomeObservationId(outcome) {
14650
- return `canary-outcome:${(0, import_agent_qa_schema55.sha256hex)((0, import_agent_qa_schema55.canonicalJson)({
14508
+ return `canary-outcome:${(0, import_agent_qa_schema54.sha256hex)((0, import_agent_qa_schema54.canonicalJson)({
14651
14509
  candidateId: outcome.candidateId,
14652
14510
  runId: outcome.runId,
14653
14511
  testId: outcome.testId,
@@ -14666,7 +14524,7 @@ function sameScope(left, right) {
14666
14524
  return left.tier === right.tier && left.key === right.key;
14667
14525
  }
14668
14526
  function sameAnchor(left, right) {
14669
- return (0, import_agent_qa_schema56.canonicalJson)((0, import_agent_qa_schema56.normalizeAnchor)(left)) === (0, import_agent_qa_schema56.canonicalJson)((0, import_agent_qa_schema56.normalizeAnchor)(right));
14527
+ return (0, import_agent_qa_schema55.canonicalJson)((0, import_agent_qa_schema55.normalizeAnchor)(left)) === (0, import_agent_qa_schema55.canonicalJson)((0, import_agent_qa_schema55.normalizeAnchor)(right));
14670
14528
  }
14671
14529
  function primaryAnchor(anchors) {
14672
14530
  return anchors[0];
@@ -14690,14 +14548,14 @@ function deltaTargetIds(delta) {
14690
14548
  }
14691
14549
  return [...ids];
14692
14550
  }
14693
- function truthLookup(knowledgeRoot, priors) {
14551
+ function truthLookup(knowledgeRoot) {
14694
14552
  const cache = /* @__PURE__ */ new Map();
14695
14553
  return (id) => {
14696
14554
  if (cache.has(id)) return cache.get(id);
14697
14555
  for (const entry of enumerateBundleDirs(knowledgeRoot)) {
14698
14556
  const loaded = loadBundle(entry.dir);
14699
14557
  if (loaded.kind !== "loaded" || loaded.bundle.manifest.id !== id) continue;
14700
- const trust = deriveBundleTrust(loaded.bundle, priors);
14558
+ const trust = deriveBundleTrust(loaded.bundle);
14701
14559
  const truth = {
14702
14560
  dir: entry.dir,
14703
14561
  bundle: loaded.bundle,
@@ -14754,7 +14612,7 @@ function armThrashTripAndClosure(input, lookup, state) {
14754
14612
  const victimAnchors = victim.bundle.frontmatter.anchors.map(
14755
14613
  ({ normalized }) => normalized
14756
14614
  );
14757
- const triggerKey2 = (0, import_agent_qa_schema56.supersessionKey)(victimAnchors);
14615
+ const triggerKey2 = (0, import_agent_qa_schema55.supersessionKey)(victimAnchors);
14758
14616
  const folded2 = foldSupersessionLineage(bundles, {
14759
14617
  windowBuilds: THRASH_WINDOW_BUILDS,
14760
14618
  asOfBuildOrdinal: buildOrdinal
@@ -14788,13 +14646,13 @@ function armThrashTripAndClosure(input, lookup, state) {
14788
14646
  const targetAnchors = target.bundle.frontmatter.anchors.map(
14789
14647
  ({ normalized }) => normalized
14790
14648
  );
14791
- const triggerKey = (0, import_agent_qa_schema56.supersessionKey)(targetAnchors);
14649
+ const triggerKey = (0, import_agent_qa_schema55.supersessionKey)(targetAnchors);
14792
14650
  const folded = foldSupersessionLineage(bundles, {
14793
14651
  windowBuilds: Number.MAX_SAFE_INTEGER,
14794
14652
  asOfBuildOrdinal: buildOrdinal
14795
14653
  }).get(triggerKey);
14796
- const latest2 = folded?.latestSupersessionOrdinal;
14797
- if (latest2 === void 0 || buildOrdinal - latest2 < STABLE_WINDOW_BUILDS) return;
14654
+ const latest = folded?.latestSupersessionOrdinal;
14655
+ if (latest === void 0 || buildOrdinal - latest < STABLE_WINDOW_BUILDS) return;
14798
14656
  for (const unknown of unresolvedUnknownsWithPrefix(input, `thrash:${triggerKey}:window:`)) {
14799
14657
  pushUnknownResolution(state, {
14800
14658
  targetId: unknown.recordId,
@@ -14813,10 +14671,10 @@ function armScopeBurst(input, state) {
14813
14671
  if (anchors === void 0 || buildOrdinal === void 0) return;
14814
14672
  const scopeKey = anchorScopeKey(anchors);
14815
14673
  if (scopeKey === void 0) return;
14816
- const candidateKey = (0, import_agent_qa_schema56.supersessionKey)(anchors);
14674
+ const candidateKey = (0, import_agent_qa_schema55.supersessionKey)(anchors);
14817
14675
  const bundles = canonicalBundles(input);
14818
14676
  const matchingCanonical = bundles.filter(
14819
- (bundle) => bundle.kind !== "unknown" && (0, import_agent_qa_schema56.supersessionKey)(bundle.anchors) === candidateKey
14677
+ (bundle) => bundle.kind !== "unknown" && (0, import_agent_qa_schema55.supersessionKey)(bundle.anchors) === candidateKey
14820
14678
  );
14821
14679
  const replayedCandidate = matchingCanonical.find(
14822
14680
  (bundle) => input.candidate?.curationJobId !== void 0 && bundle.curationJobId === input.candidate.curationJobId
@@ -14902,13 +14760,13 @@ function disposeMeasurementDrift(input, lookup) {
14902
14760
  const consumed = measurements.observations.find(
14903
14761
  (candidate2) => candidate2.evidenceToken === observation.evidenceToken && candidate2.curationJobId === observation.curationJobId
14904
14762
  );
14905
- if (consumed !== void 0 && (0, import_agent_qa_schema56.canonicalJson)(consumed) !== (0, import_agent_qa_schema56.canonicalJson)(observation)) {
14763
+ if (consumed !== void 0 && (0, import_agent_qa_schema55.canonicalJson)(consumed) !== (0, import_agent_qa_schema55.canonicalJson)(observation)) {
14906
14764
  throw new TypeError("measurement observation identity resolved to different canonical bytes");
14907
14765
  }
14908
14766
  const observations = consumed === void 0 ? [...measurements.observations, observation] : measurements.observations;
14909
- const decision = (0, import_agent_qa_schema56.decideMeasurementDrift)({
14767
+ const decision = (0, import_agent_qa_schema55.decideMeasurementDrift)({
14910
14768
  baseline: measurements.baseline,
14911
- state: (0, import_agent_qa_schema56.foldMeasurements)(measurements.baseline, observations),
14769
+ state: (0, import_agent_qa_schema55.foldMeasurements)(measurements.baseline, observations),
14912
14770
  windowBuilds: { observations }
14913
14771
  });
14914
14772
  if (delta.kind === "Confirm") {
@@ -14987,8 +14845,8 @@ function renameBridge(newAnchors, victimAnchors, victimId) {
14987
14845
  const next = primaryAnchor(newAnchors);
14988
14846
  const previous = primaryAnchor(victimAnchors);
14989
14847
  if (next?.t !== "el" || previous?.t !== "el") return void 0;
14990
- const normalizedNext = (0, import_agent_qa_schema56.normalizeAnchor)(next);
14991
- const normalizedPrevious = (0, import_agent_qa_schema56.normalizeAnchor)(previous);
14848
+ const normalizedNext = (0, import_agent_qa_schema55.normalizeAnchor)(next);
14849
+ const normalizedPrevious = (0, import_agent_qa_schema55.normalizeAnchor)(previous);
14992
14850
  if (normalizedNext.t !== "el" || normalizedPrevious.t !== "el") return void 0;
14993
14851
  if (normalizedNext.role !== normalizedPrevious.role || normalizedNext.name === normalizedPrevious.name) {
14994
14852
  return void 0;
@@ -15046,7 +14904,7 @@ function checkSupersessionKey(input, lookup, state) {
15046
14904
  return { kind: "downgrade", reason: "supersession-key" };
15047
14905
  }
15048
14906
  const victimAnchors = victim.bundle.frontmatter.anchors.map(({ normalized }) => normalized);
15049
- if (state.renameBridge === void 0 && (0, import_agent_qa_schema56.supersessionKey)(input.delta.newBundle.anchors) !== (0, import_agent_qa_schema56.supersessionKey)(victimAnchors)) {
14907
+ if (state.renameBridge === void 0 && (0, import_agent_qa_schema55.supersessionKey)(input.delta.newBundle.anchors) !== (0, import_agent_qa_schema55.supersessionKey)(victimAnchors)) {
15050
14908
  return { kind: "downgrade", reason: "supersession-key" };
15051
14909
  }
15052
14910
  if (input.candidate.buildOrdinal <= victim.openedAtOrdinal) {
@@ -15081,7 +14939,7 @@ function checkBlastRadius(input, state) {
15081
14939
  return { kind: "downgrade", reason: "blast-radius-scope" };
15082
14940
  }
15083
14941
  if (input.profile.mode === "propose-only") return PASS;
15084
- const anchorKey = (0, import_agent_qa_schema56.supersessionKey)(
14942
+ const anchorKey = (0, import_agent_qa_schema55.supersessionKey)(
15085
14943
  input.candidate?.anchors ?? input.delta.newBundle.anchors
15086
14944
  );
15087
14945
  const seen = input.drainState.supersedesSeenByAnchorKey.get(anchorKey) ?? 0;
@@ -15196,7 +15054,7 @@ function disposeProcedureExtraction(input) {
15196
15054
  if (draft2 === void 0) return void 0;
15197
15055
  const evidence = input.candidate?.procedureEvidence;
15198
15056
  if (evidence === void 0) return "procedure-evidence-missing";
15199
- const payload = (0, import_agent_qa_schema56.parseProcedureBody)(draft2.body);
15057
+ const payload = (0, import_agent_qa_schema55.parseProcedureBody)(draft2.body);
15200
15058
  if (payload === void 0) return "procedure-body-unparseable";
15201
15059
  const covered = coveredProcedureSteps(payload, evidence.distilledObservations);
15202
15060
  if (covered === void 0) {
@@ -15231,7 +15089,7 @@ function disposeProcedureExtraction(input) {
15231
15089
  ...Object.keys(step.action.targets),
15232
15090
  ...Object.keys(step.action.values)
15233
15091
  ];
15234
- if (!(0, import_agent_qa_schema56.isReplayableActionShape)(step.action.type, shapeKeys)) {
15092
+ if (!(0, import_agent_qa_schema55.isReplayableActionShape)(step.action.type, shapeKeys)) {
15235
15093
  return "procedure-non-replayable-action";
15236
15094
  }
15237
15095
  }
@@ -15269,12 +15127,11 @@ function procedureBindingIntegrityReject(payload) {
15269
15127
  return void 0;
15270
15128
  }
15271
15129
  function disposeDelta(input) {
15272
- const priors = snapshotTrustPriors(input.priors);
15273
15130
  const procedureReject = disposeProcedureExtraction(input);
15274
15131
  if (procedureReject !== void 0) {
15275
15132
  return { kind: "noop", reason: procedureReject };
15276
15133
  }
15277
- const lookup = truthLookup(input.knowledgeRoot, priors);
15134
+ const lookup = truthLookup(input.knowledgeRoot);
15278
15135
  const measurement = disposeMeasurementDrift(input, lookup);
15279
15136
  const dispositionInput = measurement.input;
15280
15137
  const state = {};
@@ -15358,8 +15215,8 @@ function deriveIndexRowFromBundle(input) {
15358
15215
  projectBundleIndexRow(input);
15359
15216
  }
15360
15217
  function derivePromotedEvidenceToken(sourceToken) {
15361
- return (0, import_agent_qa_schema57.asEvidenceToken)(
15362
- (0, import_agent_qa_schema57.sha256hex)((0, import_agent_qa_schema57.canonicalJson)({ token: sourceToken, event: "promoted" }))
15218
+ return (0, import_agent_qa_schema56.asEvidenceToken)(
15219
+ (0, import_agent_qa_schema56.sha256hex)((0, import_agent_qa_schema56.canonicalJson)({ token: sourceToken, event: "promoted" }))
15363
15220
  );
15364
15221
  }
15365
15222
  function staleEpoch(deps) {
@@ -15386,7 +15243,7 @@ function elementRef(anchors) {
15386
15243
  );
15387
15244
  if (element !== void 0) return { role: element.role, name: element.name };
15388
15245
  const primary = anchors[0];
15389
- return { role: primary.t, name: (0, import_agent_qa_schema57.canonicalJson)(primary) };
15246
+ return { role: primary.t, name: (0, import_agent_qa_schema56.canonicalJson)(primary) };
15390
15247
  }
15391
15248
  function discriminant(draft2, delta, structuralProcedureStepKeys) {
15392
15249
  switch (draft2.kind) {
@@ -15398,7 +15255,7 @@ function discriminant(draft2, delta, structuralProcedureStepKeys) {
15398
15255
  subtype: "measurement",
15399
15256
  // A superseding validity window keeps the same anchor-level supersession key while its
15400
15257
  // code-derived evidence token gives the replacement a distinct, replay-stable identity.
15401
- metricKey: (0, import_agent_qa_schema57.canonicalJson)({
15258
+ metricKey: (0, import_agent_qa_schema56.canonicalJson)({
15402
15259
  anchors: draft2.anchors,
15403
15260
  ...delta.kind === "Supersede" ? { validityWindowEvidenceToken: delta.evidenceToken } : {}
15404
15261
  })
@@ -15420,17 +15277,16 @@ function discriminant(draft2, delta, structuralProcedureStepKeys) {
15420
15277
  );
15421
15278
  return {
15422
15279
  kind: "procedure",
15423
- flowName: flow?.name ?? (0, import_agent_qa_schema57.canonicalJson)(draft2.anchors[0]),
15424
- // D-01: procedureStepKeys is the schema-owned identity authority. Observation
15425
- // naturalKeys are evidence prose and must never enter the content address.
15426
- stepSignature: (0, import_agent_qa_schema57.computeStepSequenceSignature)(structuralProcedureStepKeys)
15280
+ flowName: flow?.name ?? (0, import_agent_qa_schema56.canonicalJson)(draft2.anchors[0]),
15281
+ // Step keys are the identity; observation natural keys are prose and stay out of it.
15282
+ stepSignature: (0, import_agent_qa_schema56.computeStepSequenceSignature)(structuralProcedureStepKeys)
15427
15283
  };
15428
15284
  }
15429
15285
  case "caution": {
15430
15286
  const error = draft2.anchors.find(
15431
15287
  (anchor) => anchor.t === "error"
15432
15288
  );
15433
- return { kind: "caution", errorKey: error?.message ?? (0, import_agent_qa_schema57.canonicalJson)(draft2.anchors[0]) };
15289
+ return { kind: "caution", errorKey: error?.message ?? (0, import_agent_qa_schema56.canonicalJson)(draft2.anchors[0]) };
15434
15290
  }
15435
15291
  case "unknown":
15436
15292
  return {
@@ -15440,7 +15296,7 @@ function discriminant(draft2, delta, structuralProcedureStepKeys) {
15440
15296
  case "policy":
15441
15297
  return {
15442
15298
  kind: "policy",
15443
- ruleKey: (0, import_agent_qa_schema57.canonicalJson)(draft2.anchors[0]),
15299
+ ruleKey: (0, import_agent_qa_schema56.canonicalJson)(draft2.anchors[0]),
15444
15300
  ...delta.kind === "Supersede" ? { validityWindowEvidenceToken: delta.evidenceToken } : {}
15445
15301
  };
15446
15302
  }
@@ -15468,7 +15324,7 @@ function draftForDelta(delta, job) {
15468
15324
  }
15469
15325
  function evidenceMarkdown(job) {
15470
15326
  const lines = job.payload.distilledObservations.map(
15471
- (observation) => `- ${(0, import_agent_qa_schema57.canonicalJson)(observation)}`
15327
+ (observation) => `- ${(0, import_agent_qa_schema56.canonicalJson)(observation)}`
15472
15328
  );
15473
15329
  return `${lines.length === 0 ? job.payload.bodySeed : lines.join("\n")}
15474
15330
  `;
@@ -15494,7 +15350,7 @@ function numericMeasurementSeed(job) {
15494
15350
  function confirmedEvent(job, delta, evidenceToken = job.payload.evidenceToken) {
15495
15351
  return {
15496
15352
  type: "confirmed",
15497
- evidenceToken: (0, import_agent_qa_schema57.asEvidenceToken)(evidenceToken),
15353
+ evidenceToken: (0, import_agent_qa_schema56.asEvidenceToken)(evidenceToken),
15498
15354
  curationJobId: job.candidateId,
15499
15355
  buildOrdinal: job.payload.buildOrdinal,
15500
15356
  observationId: job.payload.attributingObservationId,
@@ -15525,7 +15381,7 @@ function artifactInputs(job) {
15525
15381
  id: `${job.candidateId}:${artifact.stepIndex}:${artifact.sha256}`,
15526
15382
  sha: artifact.sha256
15527
15383
  },
15528
- sourcePath: (0, import_node_path38.join)(job.candidateDir, artifact.relativePath),
15384
+ sourcePath: (0, import_node_path37.join)(job.candidateDir, artifact.relativePath),
15529
15385
  stepIndex: artifact.stepIndex,
15530
15386
  role: artifact.role,
15531
15387
  originalName: artifact.originalName
@@ -15536,12 +15392,12 @@ function preCopyArtifacts(job, preflightDir) {
15536
15392
  if (inputs.length === 0) {
15537
15393
  return { copied: [], skipped: [], evidenceIncomplete: false };
15538
15394
  }
15539
- return copyArtifacts(inputs, (0, import_node_path38.join)(preflightDir, "artifacts"));
15395
+ return copyArtifacts(inputs, (0, import_node_path37.join)(preflightDir, "artifacts"));
15540
15396
  }
15541
15397
  function publisherArtifacts(preCopy, preflightDir) {
15542
15398
  return preCopy.copied.map((artifact) => ({
15543
15399
  ref: artifact.ref,
15544
- sourcePath: (0, import_node_path38.join)(preflightDir, artifact.relPath),
15400
+ sourcePath: (0, import_node_path37.join)(preflightDir, artifact.relPath),
15545
15401
  stepIndex: artifact.stepIndex,
15546
15402
  ...artifact.role === void 0 ? {} : { role: artifact.role },
15547
15403
  ...artifact.originalName === void 0 ? {} : { originalName: artifact.originalName }
@@ -15555,7 +15411,6 @@ function storeConfig(deps, productKey, writerLeaseId) {
15555
15411
  return {
15556
15412
  knowledgeRoot: deps.knowledgeRoot,
15557
15413
  productKey,
15558
- commitArtifacts: "none",
15559
15414
  writerLeaseId,
15560
15415
  writerEpoch: deps.epoch,
15561
15416
  ...Object.keys(hooks).length === 0 ? {} : { hooks }
@@ -15626,7 +15481,7 @@ function unknownDraft(intent, evidenceRecordIds, job) {
15626
15481
  anchors: [{ t: "flow", name: intent.marker }],
15627
15482
  scope: intent.scope,
15628
15483
  summary: intent.kind === "thrash" ? `Memory disabled for churning anchor ${intent.triggerKey}` : `High-cardinality restructuring detected for ${intent.triggerKey}`,
15629
- body: (0, import_agent_qa_schema57.canonicalJson)(payload),
15484
+ body: (0, import_agent_qa_schema56.canonicalJson)(payload),
15630
15485
  distilledEvidenceRef: {
15631
15486
  id: `${intent.kind}:${job.candidateId}`,
15632
15487
  sha: job.candidateId
@@ -15693,7 +15548,6 @@ function commitUnknownMintIntentWithinCurrentAuthority(deps, job, prepared) {
15693
15548
  };
15694
15549
  }
15695
15550
  applyIndexDeltaForBundleWithinCurrentAuthority({
15696
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
15697
15551
  knowledgeRoot: deps.knowledgeRoot,
15698
15552
  bundleId: published.id,
15699
15553
  product: prepared.intent.scope.key
@@ -15702,8 +15556,8 @@ function commitUnknownMintIntentWithinCurrentAuthority(deps, job, prepared) {
15702
15556
  }
15703
15557
  function commitUnknownResolutionIntent(deps, job, intent, target) {
15704
15558
  const config = storeConfig(deps, target.product, job.leaseId);
15705
- const evidenceToken = (0, import_agent_qa_schema57.asEvidenceToken)(
15706
- (0, import_agent_qa_schema57.sha256hex)((0, import_agent_qa_schema57.canonicalJson)({
15559
+ const evidenceToken = (0, import_agent_qa_schema56.asEvidenceToken)(
15560
+ (0, import_agent_qa_schema56.sha256hex)((0, import_agent_qa_schema56.canonicalJson)({
15707
15561
  token: job.payload.evidenceToken,
15708
15562
  event: intent.reason,
15709
15563
  targetId: intent.targetId
@@ -15719,7 +15573,6 @@ function commitUnknownResolutionIntent(deps, job, intent, target) {
15719
15573
  const failure = appendFailure(appended);
15720
15574
  if (failure !== void 0) return failure;
15721
15575
  applyIndexDeltaForBundleWithinCurrentAuthority({
15722
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
15723
15576
  knowledgeRoot: deps.knowledgeRoot,
15724
15577
  bundleId: intent.targetId,
15725
15578
  product: target.product
@@ -15763,8 +15616,7 @@ function finishCommitWithinCurrentAuthority(deps, job, observation, projectSucce
15763
15616
  if (projectSuccessfulPrefix) applyIndexDeltaForBundleWithinCurrentAuthority({
15764
15617
  knowledgeRoot: deps.knowledgeRoot,
15765
15618
  bundleId: effect.recordId,
15766
- product: effect.product,
15767
- ...deps.priors === void 0 ? {} : { priors: deps.priors }
15619
+ product: effect.product
15768
15620
  });
15769
15621
  writeCurationEffectReceiptWithinCurrentAuthority({
15770
15622
  knowledgeRoot: deps.knowledgeRoot,
@@ -15787,7 +15639,7 @@ function appendMeasurementObservationOnce(config, victim, observation) {
15787
15639
  (candidate2) => candidate2.evidenceToken === observation.evidenceToken && candidate2.curationJobId === observation.curationJobId
15788
15640
  );
15789
15641
  if (consumed !== void 0) {
15790
- if ((0, import_agent_qa_schema57.canonicalJson)(consumed) !== (0, import_agent_qa_schema57.canonicalJson)(observation)) {
15642
+ if ((0, import_agent_qa_schema56.canonicalJson)(consumed) !== (0, import_agent_qa_schema56.canonicalJson)(observation)) {
15791
15643
  throw new TypeError("measurement observation identity resolved to different canonical bytes");
15792
15644
  }
15793
15645
  return { kind: "duplicate" };
@@ -15800,11 +15652,9 @@ function mutationTarget(delta) {
15800
15652
  return void 0;
15801
15653
  }
15802
15654
  function commitCurationDelta(deps, job, checkpoint) {
15803
- deps = { ...deps, ...deps.priors === void 0 ? {} : { priors: snapshotTrustPriors(deps.priors) } };
15804
15655
  const beforeWork = staleEpoch(deps);
15805
15656
  if (beforeWork !== void 0) return beforeWork;
15806
15657
  const disposed = disposeDelta({
15807
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
15808
15658
  delta: checkpoint.delta,
15809
15659
  checkpoint,
15810
15660
  profile: deps.profile,
@@ -15815,8 +15665,7 @@ function commitCurationDelta(deps, job, checkpoint) {
15815
15665
  buildOrdinal: job.payload.buildOrdinal,
15816
15666
  curationJobId: job.candidateId,
15817
15667
  ...measurementSeedValue(job) === void 0 ? {} : { measurementValue: measurementSeedValue(job) },
15818
- // 381-03: procedure deltas are validated against durable queue evidence, so the
15819
- // extraction wall receives the payload's code-derived facts (never LLM text).
15668
+ // Procedure deltas are checked against durable queue evidence, never model text.
15820
15669
  ...job.payload.kind === "procedure" ? {
15821
15670
  procedureEvidence: {
15822
15671
  distilledObservations: job.payload.distilledObservations
@@ -15838,8 +15687,8 @@ function commitCurationDelta(deps, job, checkpoint) {
15838
15687
  const draft2 = draftForDelta(delta, job);
15839
15688
  const structuralProcedureStepKeys = (() => {
15840
15689
  if (draft2?.kind !== "procedure") return [];
15841
- const payload = (0, import_agent_qa_schema57.parseProcedureBody)(draft2.body);
15842
- return payload === void 0 ? void 0 : (0, import_agent_qa_schema57.procedureStepKeys)(payload);
15690
+ const payload = (0, import_agent_qa_schema56.parseProcedureBody)(draft2.body);
15691
+ return payload === void 0 ? void 0 : (0, import_agent_qa_schema56.procedureStepKeys)(payload);
15843
15692
  })();
15844
15693
  if (structuralProcedureStepKeys === void 0) {
15845
15694
  markDone(deps, job);
@@ -15872,7 +15721,7 @@ function commitCurationDelta(deps, job, checkpoint) {
15872
15721
  let publishInput;
15873
15722
  let preparedPublication;
15874
15723
  let preparedUnknownMintIntents = [];
15875
- const preflightDir = (0, import_node_path38.join)(job.candidateDir, `.commit-artifacts-${(0, import_node_crypto18.randomUUID)()}`);
15724
+ const preflightDir = (0, import_node_path37.join)(job.candidateDir, `.commit-artifacts-${(0, import_node_crypto18.randomUUID)()}`);
15876
15725
  writeJobState({
15877
15726
  knowledgeRoot: deps.knowledgeRoot,
15878
15727
  candidateId: job.candidateId,
@@ -16021,7 +15870,7 @@ function commitCurationDelta(deps, job, checkpoint) {
16021
15870
  resolution.targetId,
16022
15871
  existingTargets.get(resolution.targetId).product,
16023
15872
  "deprecated",
16024
- (0, import_agent_qa_schema57.asEvidenceToken)((0, import_agent_qa_schema57.sha256hex)((0, import_agent_qa_schema57.canonicalJson)({
15873
+ (0, import_agent_qa_schema56.asEvidenceToken)((0, import_agent_qa_schema56.sha256hex)((0, import_agent_qa_schema56.canonicalJson)({
16025
15874
  token: job.payload.evidenceToken,
16026
15875
  event: resolution.reason,
16027
15876
  targetId: resolution.targetId
@@ -16124,16 +15973,13 @@ function commitCurationDelta(deps, job, checkpoint) {
16124
15973
  finishCommitWithinCurrentAuthority(deps, job, curationObservation, true, false);
16125
15974
  return { kind: "failed", reason: "append-failed" };
16126
15975
  }
16127
- const gate = (0, import_agent_qa_schema57.evaluatePromotionGate)(assemblePromotionGateInput({
15976
+ const gate = (0, import_agent_qa_schema56.evaluatePromotionGate)(assemblePromotionGateInput({
16128
15977
  knowledgeRoot: deps.knowledgeRoot,
16129
15978
  bundleDir: promotionBundleDir,
16130
- bundle: loaded.bundle,
16131
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
16132
- ...deps.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: deps.resolvePromotionPosture }
15979
+ bundle: loaded.bundle
16133
15980
  }));
16134
15981
  if (gate.verdict === "promote") {
16135
15982
  const promoted = appendOutcomeEvent(config, published.id, {
16136
- // 416-DOOR: door-3 promoted
16137
15983
  type: "promoted",
16138
15984
  evidenceToken: derivePromotedEvidenceToken(job.payload.evidenceToken),
16139
15985
  curationJobId: job.candidateId,
@@ -16146,7 +15992,7 @@ function commitCurationDelta(deps, job, checkpoint) {
16146
15992
  }
16147
15993
  tailMutationAppended ||= promoted.kind === "appended";
16148
15994
  const receipt = appendPromotionReceipt(config, published.id, {
16149
- schemaVersion: import_agent_qa_schema57.GATE_RECEIPT_SCHEMA_VERSION,
15995
+ schemaVersion: import_agent_qa_schema56.GATE_RECEIPT_SCHEMA_VERSION,
16150
15996
  kind: "promotion",
16151
15997
  candidateId: published.id,
16152
15998
  promotionPath: gate.promotionPath,
@@ -16185,7 +16031,6 @@ function commitCurationDelta(deps, job, checkpoint) {
16185
16031
  throw new TypeError("born-active disposition requires a Supersede delta");
16186
16032
  }
16187
16033
  const promoted = appendOutcomeEvent(config, published.id, {
16188
- // 416-DOOR: born-active promoted
16189
16034
  type: "promoted",
16190
16035
  evidenceToken: derivePromotedEvidenceToken(delta.evidenceToken),
16191
16036
  curationJobId: job.candidateId,
@@ -16201,7 +16046,6 @@ function commitCurationDelta(deps, job, checkpoint) {
16201
16046
  if (freshlyPublished) deps.hooks?.afterBundlePublished?.(published.id);
16202
16047
  if (disposed.kind === "apply" && disposed.bornActive === true) {
16203
16048
  applyIndexDeltaForBundleWithinCurrentAuthority({
16204
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
16205
16049
  knowledgeRoot: deps.knowledgeRoot,
16206
16050
  bundleId: published.id,
16207
16051
  product: bundleProduct
@@ -16246,7 +16090,7 @@ function commitCurationDelta(deps, job, checkpoint) {
16246
16090
  );
16247
16091
  const appended = appendOutcomeEvent(targetConfig, delta.targetId, {
16248
16092
  type: "deprecated",
16249
- evidenceToken: (0, import_agent_qa_schema57.asEvidenceToken)(job.payload.evidenceToken),
16093
+ evidenceToken: (0, import_agent_qa_schema56.asEvidenceToken)(job.payload.evidenceToken),
16250
16094
  curationJobId: job.candidateId,
16251
16095
  buildOrdinal: job.payload.buildOrdinal,
16252
16096
  reason: delta.reason
@@ -16318,8 +16162,8 @@ function commitCurationDelta(deps, job, checkpoint) {
16318
16162
  return supersededFailure;
16319
16163
  }
16320
16164
  tailMutationAppended ||= superseded.kind === "appended";
16321
- const closeToken = (0, import_agent_qa_schema57.asEvidenceToken)(
16322
- (0, import_agent_qa_schema57.sha256hex)((0, import_agent_qa_schema57.canonicalJson)({ token: delta.evidenceToken, event: "window-close" }))
16165
+ const closeToken = (0, import_agent_qa_schema56.asEvidenceToken)(
16166
+ (0, import_agent_qa_schema56.sha256hex)((0, import_agent_qa_schema56.canonicalJson)({ token: delta.evidenceToken, event: "window-close" }))
16323
16167
  );
16324
16168
  const closed = appendOutcomeEvent(victimConfig, delta.victimId, {
16325
16169
  type: "window-close",
@@ -16335,7 +16179,6 @@ function commitCurationDelta(deps, job, checkpoint) {
16335
16179
  }
16336
16180
  tailMutationAppended ||= closed.kind === "appended";
16337
16181
  applyIndexDeltaForBundleWithinCurrentAuthority({
16338
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
16339
16182
  knowledgeRoot: deps.knowledgeRoot,
16340
16183
  bundleId: delta.victimId,
16341
16184
  product: victim.product
@@ -16347,7 +16190,6 @@ function commitCurationDelta(deps, job, checkpoint) {
16347
16190
  return { kind: "noop", reason: "evidence-token-consumed" };
16348
16191
  }
16349
16192
  applyIndexDeltaForBundleWithinCurrentAuthority({
16350
- ...deps.priors === void 0 ? {} : { priors: deps.priors },
16351
16193
  knowledgeRoot: deps.knowledgeRoot,
16352
16194
  bundleId,
16353
16195
  product: bundleProduct
@@ -16402,11 +16244,11 @@ function commitCurationDelta(deps, job, checkpoint) {
16402
16244
 
16403
16245
  // src/curator/drain.ts
16404
16246
  var import_node_fs37 = require("node:fs");
16405
- var import_agent_qa_schema60 = require("@vostride/agent-qa-schema");
16247
+ var import_agent_qa_schema59 = require("@vostride/agent-qa-schema");
16406
16248
 
16407
16249
  // src/journal/reconcile.ts
16408
16250
  var import_node_fs36 = require("node:fs");
16409
- var import_node_path39 = require("node:path");
16251
+ var import_node_path38 = require("node:path");
16410
16252
  function childDirectories2(dir) {
16411
16253
  try {
16412
16254
  return (0, import_node_fs36.readdirSync)(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
@@ -16419,7 +16261,7 @@ function stagingRoots(root) {
16419
16261
  const roots = [];
16420
16262
  const visit = (dir) => {
16421
16263
  for (const name of childDirectories2(dir)) {
16422
- const child = (0, import_node_path39.join)(dir, name);
16264
+ const child = (0, import_node_path38.join)(dir, name);
16423
16265
  if (name === ".staging") {
16424
16266
  roots.push(child);
16425
16267
  } else {
@@ -16450,7 +16292,7 @@ function removeExpiredLeaseStaging(knowledgeRoot, expiredLeaseIds) {
16450
16292
  if ([...expiredLeaseIds].some(
16451
16293
  (leaseId) => stagingEntryBelongsToLease(entryName, leaseId)
16452
16294
  )) {
16453
- (0, import_node_fs36.rmSync)((0, import_node_path39.join)(stagingRoot, entryName), { recursive: true, force: true });
16295
+ (0, import_node_fs36.rmSync)((0, import_node_path38.join)(stagingRoot, entryName), { recursive: true, force: true });
16454
16296
  removed += 1;
16455
16297
  }
16456
16298
  }
@@ -16599,7 +16441,7 @@ function reconcileOnDrainStartWithinCurrentAuthority(deps) {
16599
16441
  for (const [bundleId, dir] of bundles) {
16600
16442
  if (bundleIdsWithIntent.has(bundleId) || deps.hasIndexRow(bundleId)) continue;
16601
16443
  const outcome = loadBundle(dir);
16602
- if (outcome.kind !== "loaded" || (0, import_node_path39.basename)(dir) !== outcome.bundle.manifest.id) continue;
16444
+ if (outcome.kind !== "loaded" || (0, import_node_path38.basename)(dir) !== outcome.bundle.manifest.id) continue;
16603
16445
  deps.deriveIndexRowFromBundle(bundleId);
16604
16446
  }
16605
16447
  writeReconciledEpochWithinCurrentAuthority(
@@ -16618,7 +16460,7 @@ function reconcileOnDrainStart(deps) {
16618
16460
  }
16619
16461
 
16620
16462
  // src/curator/fallback.ts
16621
- var import_agent_qa_schema58 = require("@vostride/agent-qa-schema");
16463
+ var import_agent_qa_schema57 = require("@vostride/agent-qa-schema");
16622
16464
  function cloneAnchor(anchor) {
16623
16465
  switch (anchor.t) {
16624
16466
  case "page":
@@ -16691,7 +16533,7 @@ function fallbackDraft(job) {
16691
16533
  };
16692
16534
  }
16693
16535
  function normalizedAnchorKey5(anchor) {
16694
- return (0, import_agent_qa_schema58.canonicalJson)((0, import_agent_qa_schema58.normalizeAnchor)(anchor));
16536
+ return (0, import_agent_qa_schema57.canonicalJson)((0, import_agent_qa_schema57.normalizeAnchor)(anchor));
16695
16537
  }
16696
16538
  function exactPrimaryAnchorNeighbor(primaryAnchor2, neighbors) {
16697
16539
  const primaryKey = normalizedAnchorKey5(primaryAnchor2);
@@ -16726,12 +16568,12 @@ function constructFallbackDeltas(job, neighbors, fallbackReason) {
16726
16568
  }
16727
16569
  const primaryAnchor2 = job.anchors[0];
16728
16570
  const exactNeighbor = exactPrimaryAnchorNeighbor(primaryAnchor2, neighbors);
16729
- const evidenceToken = (0, import_agent_qa_schema58.deriveEvidenceToken)({
16571
+ const evidenceToken = (0, import_agent_qa_schema57.deriveEvidenceToken)({
16730
16572
  attributingObservationId: job.attributingObservationId,
16731
16573
  anchor: primaryAnchor2,
16732
16574
  buildOrdinal: job.buildOrdinal
16733
16575
  });
16734
- if (job.kind === "fact" && job.subtype === "measurement" && exactNeighbor?.kind === "fact" && exactNeighbor.subtype === "measurement" && (0, import_agent_qa_schema58.supersessionKey)(job.anchors) === (0, import_agent_qa_schema58.supersessionKey)(exactNeighbor.anchors)) {
16576
+ if (job.kind === "fact" && job.subtype === "measurement" && exactNeighbor?.kind === "fact" && exactNeighbor.subtype === "measurement" && (0, import_agent_qa_schema57.supersessionKey)(job.anchors) === (0, import_agent_qa_schema57.supersessionKey)(exactNeighbor.anchors)) {
16735
16577
  return [
16736
16578
  {
16737
16579
  ...citedEnvelope(job, fallbackReason, exactNeighbor),
@@ -16762,11 +16604,11 @@ function constructFallbackDeltas(job, neighbors, fallbackReason) {
16762
16604
  }
16763
16605
 
16764
16606
  // src/curator/knowledge-store.ts
16765
- var import_node_path40 = require("node:path");
16766
- var import_agent_qa_schema59 = require("@vostride/agent-qa-schema");
16607
+ var import_node_path39 = require("node:path");
16608
+ var import_agent_qa_schema58 = require("@vostride/agent-qa-schema");
16767
16609
  var KnowledgeStoreNotImplementedError = class extends Error {
16768
16610
  operation;
16769
- constructor(operation, _retiredOwnerPhase) {
16611
+ constructor(operation) {
16770
16612
  super(`${operation} compatibility error is retired because the operation is implemented`);
16771
16613
  this.name = "KnowledgeStoreNotImplementedError";
16772
16614
  this.operation = operation;
@@ -16802,7 +16644,7 @@ var KnowledgeUnsupportedDeltaError = class extends Error {
16802
16644
  this.reason = "procedure-evidence-unsupported";
16803
16645
  }
16804
16646
  };
16805
- function resolveTruth(knowledgeRoot, id, priors) {
16647
+ function resolveTruth(knowledgeRoot, id) {
16806
16648
  let target;
16807
16649
  try {
16808
16650
  target = resolveProductQualifiedBundleDir({ knowledgeRoot, recordId: id });
@@ -16812,7 +16654,7 @@ function resolveTruth(knowledgeRoot, id, priors) {
16812
16654
  }
16813
16655
  const loaded = loadBundle(target.dir);
16814
16656
  if (loaded.kind !== "loaded" || loaded.bundle.manifest.id !== id) return void 0;
16815
- const trust = deriveBundleTrust(loaded.bundle, priors);
16657
+ const trust = deriveBundleTrust(loaded.bundle);
16816
16658
  return {
16817
16659
  id,
16818
16660
  bundle: loaded.bundle,
@@ -16843,7 +16685,7 @@ function draft(delta) {
16843
16685
  }
16844
16686
  function syntheticEvidenceToken(delta) {
16845
16687
  if (delta.kind === "Confirm" || delta.kind === "Supersede") return delta.evidenceToken;
16846
- return (0, import_agent_qa_schema59.sha256hex)((0, import_agent_qa_schema59.canonicalJson)({ delta, source: "knowledge-port" }));
16688
+ return (0, import_agent_qa_schema58.sha256hex)((0, import_agent_qa_schema58.canonicalJson)({ delta, source: "knowledge-port" }));
16847
16689
  }
16848
16690
  function addressFields(config, delta, target, buildOrdinal) {
16849
16691
  const authored = draft(delta);
@@ -16860,10 +16702,10 @@ function addressFields(config, delta, target, buildOrdinal) {
16860
16702
  ...kind === "fact" ? { subtype: subtype ?? "content" } : {},
16861
16703
  anchors,
16862
16704
  summarySeed: authored?.summary ?? target?.bundle.summary ?? `KnowledgePort ${delta.kind}`,
16863
- bodySeed: authored?.body ?? target?.bundle.body ?? (0, import_agent_qa_schema59.canonicalJson)(delta),
16705
+ bodySeed: authored?.body ?? target?.bundle.body ?? (0, import_agent_qa_schema58.canonicalJson)(delta),
16864
16706
  distilledObservations: [],
16865
16707
  evidenceToken: syntheticEvidenceToken(delta),
16866
- attributingObservationId: `knowledge-port:${(0, import_agent_qa_schema59.sha256hex)((0, import_agent_qa_schema59.canonicalJson)(delta))}`,
16708
+ attributingObservationId: `knowledge-port:${(0, import_agent_qa_schema58.sha256hex)((0, import_agent_qa_schema58.canonicalJson)(delta))}`,
16867
16709
  artifactInventory: [],
16868
16710
  emittedAt: "1970-01-01T00:00:00.000Z"
16869
16711
  });
@@ -16881,17 +16723,17 @@ function currentAuthority(config) {
16881
16723
  epoch: config.epoch ?? readCurrentEpoch(config.knowledgeRoot)
16882
16724
  };
16883
16725
  }
16884
- function bridgeDelta(config, delta, priors) {
16885
- const neighbors = delta.citedIds.map((id) => resolveTruth(config.knowledgeRoot, id, priors)).filter((truth) => truth !== void 0);
16726
+ function bridgeDelta(config, delta) {
16727
+ const neighbors = delta.citedIds.map((id) => resolveTruth(config.knowledgeRoot, id)).filter((truth) => truth !== void 0);
16886
16728
  const target = targetId(delta);
16887
- const targetTruth = target === void 0 ? void 0 : neighbors.find(({ id }) => id === target) ?? resolveTruth(config.knowledgeRoot, target, priors);
16729
+ const targetTruth = target === void 0 ? void 0 : neighbors.find(({ id }) => id === target) ?? resolveTruth(config.knowledgeRoot, target);
16888
16730
  const observedOrdinals = [...neighbors, ...targetTruth === void 0 ? [] : [targetTruth]].map(({ observedOrdinal }) => observedOrdinal);
16889
16731
  const buildOrdinal = config.sourceBuildOrdinal ?? (observedOrdinals.length === 0 ? 0 : Math.max(...observedOrdinals) + 1);
16890
16732
  const fields = addressFields(config, delta, targetTruth, buildOrdinal);
16891
16733
  const candidateId = candidateContentAddress(fields);
16892
16734
  const leaseId = config.writerLeaseId;
16893
16735
  const candidateDir = claimedCandidateDir(config.knowledgeRoot, leaseId, candidateId);
16894
- const artifactsDir = (0, import_node_path40.join)(candidateDir, "artifacts");
16736
+ const artifactsDir = (0, import_node_path39.join)(candidateDir, "artifacts");
16895
16737
  const payload = { candidateId, ...fields };
16896
16738
  const authorship = syntheticAuthorship(config, delta);
16897
16739
  return {
@@ -16901,7 +16743,7 @@ function bridgeDelta(config, delta, priors) {
16901
16743
  leaseId,
16902
16744
  payload,
16903
16745
  candidateDir,
16904
- payloadPath: (0, import_node_path40.join)(candidateDir, "payload.json"),
16746
+ payloadPath: (0, import_node_path39.join)(candidateDir, "payload.json"),
16905
16747
  artifactsDir,
16906
16748
  targetProducts: Object.fromEntries(
16907
16749
  [...neighbors, ...targetTruth === void 0 ? [] : [targetTruth]].map((truth) => [truth.id, truth.product])
@@ -16934,7 +16776,7 @@ function expectedPromotionHold(error) {
16934
16776
  return error instanceof KnowledgePromotionError && error.reason !== "not-found";
16935
16777
  }
16936
16778
  function unreachableCanaryOutcome(outcome) {
16937
- throw new TypeError(`unsupported canary outcome: ${(0, import_agent_qa_schema59.canonicalJson)(outcome)}`);
16779
+ throw new TypeError(`unsupported canary outcome: ${(0, import_agent_qa_schema58.canonicalJson)(outcome)}`);
16938
16780
  }
16939
16781
  var EXPLICIT_PROFILE = Object.freeze({ mode: "drain-to-active" });
16940
16782
  function dispositionProfileFor(config, authority) {
@@ -16948,13 +16790,11 @@ function createExplicitReviewStore(config) {
16948
16790
  return { commit, promote, recordGateReceipt };
16949
16791
  }
16950
16792
  function buildLocalKnowledgeStore(config, authority) {
16951
- const priors = snapshotTrustPriors(config.resolveTrustPriors?.());
16952
16793
  const operation = config.operations?.commitCurationDelta ?? commitCurationDelta;
16953
16794
  function bundleStoreConfig(productKey) {
16954
16795
  return {
16955
16796
  knowledgeRoot: config.knowledgeRoot,
16956
16797
  productKey,
16957
- commitArtifacts: "none",
16958
16798
  writerLeaseId: config.writerLeaseId
16959
16799
  };
16960
16800
  }
@@ -16971,7 +16811,7 @@ function buildLocalKnowledgeStore(config, authority) {
16971
16811
  if (profile.mode === "propose-only") {
16972
16812
  throw new KnowledgePromotionError(candidateId, "propose-only");
16973
16813
  }
16974
- const resolved = resolveTruth(config.knowledgeRoot, candidateId, priors);
16814
+ const resolved = resolveTruth(config.knowledgeRoot, candidateId);
16975
16815
  if (resolved === void 0) {
16976
16816
  throw new KnowledgePromotionError(candidateId, "not-found");
16977
16817
  }
@@ -16980,25 +16820,22 @@ function buildLocalKnowledgeStore(config, authority) {
16980
16820
  const gateInput = assemblePromotionGateInput({
16981
16821
  knowledgeRoot: config.knowledgeRoot,
16982
16822
  bundleDir: resolved.bundleDir,
16983
- bundle: resolved.bundle,
16984
- resolvePromotionPosture: config.resolvePromotionPosture,
16985
- ...priors === void 0 ? {} : { priors }
16823
+ bundle: resolved.bundle
16986
16824
  });
16987
- const setAside = (0, import_agent_qa_schema59.foldBundleTrust)(
16988
- (0, import_agent_qa_schema59.survivingOutcomeEvents)(resolved.bundle.events).filter(({ type }) => type !== "promoted"),
16825
+ const setAside = (0, import_agent_qa_schema58.foldBundleTrust)(
16826
+ (0, import_agent_qa_schema58.survivingOutcomeEvents)(resolved.bundle.events).filter(({ type }) => type !== "promoted"),
16989
16827
  {
16990
16828
  originClass: resolved.bundle.frontmatter.originClass,
16991
16829
  evidenceIncomplete: resolved.bundle.manifest.evidenceIncomplete,
16992
16830
  createdAtOrdinal: resolved.bundle.frontmatter.createdAtOrdinal
16993
- },
16994
- priors
16831
+ }
16995
16832
  );
16996
- const revalidated = (0, import_agent_qa_schema59.evaluatePromotionGate)({ ...gateInput, status: setAside.status });
16833
+ const revalidated = (0, import_agent_qa_schema58.evaluatePromotionGate)({ ...gateInput, status: setAside.status });
16997
16834
  if (revalidated.verdict === "promote") {
16998
- const onDisk = (0, import_agent_qa_schema59.strongestPromotionPath)(readGateReceipts(resolved.bundleDir, candidateId) ?? []);
16999
- if (onDisk === void 0 || revalidated.promotionPath !== onDisk && (0, import_agent_qa_schema59.strongerPromotionPath)(revalidated.promotionPath, onDisk) === revalidated.promotionPath) {
16835
+ const onDisk = (0, import_agent_qa_schema58.strongestPromotionPath)(readGateReceipts(resolved.bundleDir, candidateId) ?? []);
16836
+ if (onDisk === void 0 || revalidated.promotionPath !== onDisk && (0, import_agent_qa_schema58.strongerPromotionPath)(revalidated.promotionPath, onDisk) === revalidated.promotionPath) {
17000
16837
  checkedAppend(candidateId, appendPromotionReceipt(appendConfig, candidateId, {
17001
- schemaVersion: import_agent_qa_schema59.GATE_RECEIPT_SCHEMA_VERSION,
16838
+ schemaVersion: import_agent_qa_schema58.GATE_RECEIPT_SCHEMA_VERSION,
17002
16839
  kind: "promotion",
17003
16840
  candidateId,
17004
16841
  promotionPath: revalidated.promotionPath,
@@ -17008,22 +16845,21 @@ function buildLocalKnowledgeStore(config, authority) {
17008
16845
  }));
17009
16846
  }
17010
16847
  applyIndexDeltaForBundleWithinCurrentAuthority({
17011
- ...priors === void 0 ? {} : { priors },
17012
16848
  knowledgeRoot: config.knowledgeRoot,
17013
16849
  bundleId: candidateId,
17014
16850
  product: resolved.product
17015
16851
  });
17016
- const promotionPath = (0, import_agent_qa_schema59.strongestPromotionPath)(readGateReceipts(resolved.bundleDir, candidateId) ?? []);
16852
+ const promotionPath = (0, import_agent_qa_schema58.strongestPromotionPath)(readGateReceipts(resolved.bundleDir, candidateId) ?? []);
17017
16853
  config.onPromotionOutcome?.({ candidateId, ...promotionPath === void 0 ? {} : { promotionPath } });
17018
16854
  return { kind: "already-active", ...promotionPath === void 0 ? {} : { promotionPath } };
17019
16855
  }
17020
- const survivingPromoted = (0, import_agent_qa_schema59.survivingOutcomeEvents)(resolved.bundle.events).filter(({ type }) => type === "promoted");
16856
+ const survivingPromoted = (0, import_agent_qa_schema58.survivingOutcomeEvents)(resolved.bundle.events).filter(({ type }) => type === "promoted");
17021
16857
  const healReceiptId = `promote-heal:${candidateId}`;
17022
16858
  for (const promoted of survivingPromoted) {
17023
16859
  const appended2 = appendOutcomeEvent(appendConfig, candidateId, {
17024
16860
  type: "retracted",
17025
- evidenceToken: (0, import_agent_qa_schema59.asEvidenceToken)((0, import_agent_qa_schema59.sha256hex)((0, import_agent_qa_schema59.canonicalJson)({
17026
- healedPromotedEventKey: (0, import_agent_qa_schema59.eventDedupKey)(promoted),
16861
+ evidenceToken: (0, import_agent_qa_schema58.asEvidenceToken)((0, import_agent_qa_schema58.sha256hex)((0, import_agent_qa_schema58.canonicalJson)({
16862
+ healedPromotedEventKey: (0, import_agent_qa_schema58.eventDedupKey)(promoted),
17027
16863
  candidateId
17028
16864
  }))),
17029
16865
  curationJobId: healReceiptId,
@@ -17037,34 +16873,30 @@ function buildLocalKnowledgeStore(config, authority) {
17037
16873
  }
17038
16874
  }
17039
16875
  applyIndexDeltaForBundleWithinCurrentAuthority({
17040
- ...priors === void 0 ? {} : { priors },
17041
16876
  knowledgeRoot: config.knowledgeRoot,
17042
16877
  bundleId: candidateId,
17043
16878
  product: resolved.product
17044
16879
  });
17045
16880
  throw new KnowledgePromotionError(candidateId, revalidated.reason);
17046
16881
  }
17047
- const gate = (0, import_agent_qa_schema59.evaluatePromotionGate)(assemblePromotionGateInput({
16882
+ const gate = (0, import_agent_qa_schema58.evaluatePromotionGate)(assemblePromotionGateInput({
17048
16883
  knowledgeRoot: config.knowledgeRoot,
17049
16884
  bundleDir: resolved.bundleDir,
17050
- bundle: resolved.bundle,
17051
- resolvePromotionPosture: config.resolvePromotionPosture,
17052
- ...priors === void 0 ? {} : { priors }
16885
+ bundle: resolved.bundle
17053
16886
  }));
17054
16887
  if (gate.verdict === "hold") {
17055
16888
  throw new KnowledgePromotionError(candidateId, gate.reason);
17056
16889
  }
17057
- const promotedKeys = new Set(resolved.bundle.events.filter((event) => event.type === "promoted").map(import_agent_qa_schema59.eventDedupKey));
16890
+ const promotedKeys = new Set(resolved.bundle.events.filter((event) => event.type === "promoted").map(import_agent_qa_schema58.eventDedupKey));
17058
16891
  const recoveryBoundary = [...new Set(resolved.bundle.events.flatMap(
17059
- (event) => event.type === "retracted" && promotedKeys.has((0, import_agent_qa_schema59.eventDedupKey)({
16892
+ (event) => event.type === "retracted" && promotedKeys.has((0, import_agent_qa_schema58.eventDedupKey)({
17060
16893
  ...event,
17061
16894
  evidenceToken: event.retractsEvidenceToken,
17062
16895
  curationJobId: event.retractsCurationJobId
17063
- })) ? [(0, import_agent_qa_schema59.eventDedupKey)(event)] : []
16896
+ })) ? [(0, import_agent_qa_schema58.eventDedupKey)(event)] : []
17064
16897
  ))].sort();
17065
- const promotionSource = recoveryBoundary.length === 0 ? candidateId : (0, import_agent_qa_schema59.canonicalJson)({ candidateId, retractedPromotionEvents: recoveryBoundary });
16898
+ const promotionSource = recoveryBoundary.length === 0 ? candidateId : (0, import_agent_qa_schema58.canonicalJson)({ candidateId, retractedPromotionEvents: recoveryBoundary });
17066
16899
  const appended = appendOutcomeEvent(appendConfig, candidateId, {
17067
- // 416-DOOR: door-1-2 promoted
17068
16900
  type: "promoted",
17069
16901
  evidenceToken: derivePromotedEvidenceToken(promotionSource),
17070
16902
  curationJobId: `promote:${candidateId}`,
@@ -17074,7 +16906,7 @@ function buildLocalKnowledgeStore(config, authority) {
17074
16906
  throw new KnowledgePromotionError(candidateId, appended.kind);
17075
16907
  }
17076
16908
  const receipt = appendPromotionReceipt(appendConfig, candidateId, {
17077
- schemaVersion: import_agent_qa_schema59.GATE_RECEIPT_SCHEMA_VERSION,
16909
+ schemaVersion: import_agent_qa_schema58.GATE_RECEIPT_SCHEMA_VERSION,
17078
16910
  kind: "promotion",
17079
16911
  candidateId,
17080
16912
  promotionPath: gate.promotionPath,
@@ -17084,7 +16916,6 @@ function buildLocalKnowledgeStore(config, authority) {
17084
16916
  });
17085
16917
  if (receipt.kind === "not-found") throw new KnowledgePromotionError(candidateId, receipt.kind);
17086
16918
  applyIndexDeltaForBundleWithinCurrentAuthority({
17087
- ...priors === void 0 ? {} : { priors },
17088
16919
  knowledgeRoot: config.knowledgeRoot,
17089
16920
  bundleId: candidateId,
17090
16921
  product: resolved.product
@@ -17100,15 +16931,13 @@ function buildLocalKnowledgeStore(config, authority) {
17100
16931
  if (draft(delta)?.kind === "procedure") {
17101
16932
  throw new KnowledgeUnsupportedDeltaError(delta.kind);
17102
16933
  }
17103
- const { job, checkpoint } = bridgeDelta(config, delta, priors);
16934
+ const { job, checkpoint } = bridgeDelta(config, delta);
17104
16935
  const outcome = operation(
17105
16936
  {
17106
16937
  knowledgeRoot: config.knowledgeRoot,
17107
16938
  epoch: currentAuthority(config).epoch,
17108
16939
  profile,
17109
- drainState,
17110
- ...priors === void 0 ? {} : { priors },
17111
- ...config.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: config.resolvePromotionPosture }
16940
+ drainState
17112
16941
  },
17113
16942
  job,
17114
16943
  checkpoint
@@ -17116,39 +16945,6 @@ function buildLocalKnowledgeStore(config, authority) {
17116
16945
  if (!completed(outcome)) throw new KnowledgeCommitError(outcome);
17117
16946
  }
17118
16947
  }
17119
- function gate2ReceiptFor(outcome, verdict) {
17120
- if (outcome.corpusDigest === void 0) throw new TypeError("Gate-2 receipt requires a corpus digest");
17121
- return (0, import_agent_qa_schema59.stampReceiptDigest)({
17122
- schemaVersion: import_agent_qa_schema59.GATE_RECEIPT_SCHEMA_VERSION,
17123
- gate: 2,
17124
- candidateId: outcome.candidateId,
17125
- verdict,
17126
- producedAtOrdinal: outcome.buildOrdinal,
17127
- producedBy: {
17128
- ...config.sourceJobId === void 0 ? {} : { jobId: config.sourceJobId },
17129
- opId: "canary.record"
17130
- },
17131
- attributedObservationId: canaryOutcomeObservationId(outcome),
17132
- corpusVersion: { corpusDigest: outcome.corpusDigest },
17133
- benefit: outcome.runOutcome === "negative" ? "exercised-harmed" : outcome.benefit,
17134
- stateValidity: outcome.stateValidity,
17135
- runId: outcome.runId,
17136
- testIndex: outcome.testIndex,
17137
- stepIndex: outcome.stepIndex,
17138
- attribution: outcome.attribution,
17139
- ...outcome.observedStateDigest === void 0 ? {} : { observedStateDigest: outcome.observedStateDigest },
17140
- ...outcome.ablation === void 0 ? {} : {
17141
- crossCheck: outcome.ablation.crossCheck,
17142
- samples: {
17143
- k: outcome.ablation.k,
17144
- seeds: outcome.ablation.seeds,
17145
- seedHonored: outcome.ablation.seedHonored,
17146
- modelCalls: outcome.ablation.spend.modelCalls
17147
- },
17148
- spend: outcome.ablation.spend
17149
- }
17150
- });
17151
- }
17152
16948
  const store = {
17153
16949
  proposeDeltas(deltas) {
17154
16950
  return commitWithProfile(deltas, { mode: "propose-only" });
@@ -17157,12 +16953,12 @@ function buildLocalKnowledgeStore(config, authority) {
17157
16953
  return commitWithProfile(deltas, dispositionProfileFor(config, authority));
17158
16954
  },
17159
16955
  async recordCanaryOutcome(outcome) {
17160
- const resolved = resolveTruth(config.knowledgeRoot, outcome.candidateId, priors);
16956
+ const resolved = resolveTruth(config.knowledgeRoot, outcome.candidateId);
17161
16957
  if (resolved === void 0) {
17162
16958
  throw new KnowledgePromotionError(outcome.candidateId, "not-found");
17163
16959
  }
17164
16960
  const observationId = canaryOutcomeObservationId(outcome);
17165
- const evidenceToken = (0, import_agent_qa_schema59.deriveEvidenceToken)({
16961
+ const evidenceToken = (0, import_agent_qa_schema58.deriveEvidenceToken)({
17166
16962
  attributingObservationId: observationId,
17167
16963
  anchor: outcome.exercisedAnchor,
17168
16964
  buildOrdinal: outcome.buildOrdinal
@@ -17184,11 +16980,6 @@ function buildLocalKnowledgeStore(config, authority) {
17184
16980
  await store.commit([confirm]);
17185
16981
  config.canaryAuthorityHooks?.beforePromotionAppend?.();
17186
16982
  withCurrentWriterAuthority(config.knowledgeRoot, currentAuthority(config), () => {
17187
- if (outcome.benefit === "exercised-benefited" && outcome.corpusDigest !== void 0) {
17188
- const receipt = gate2ReceiptFor(outcome, "pass");
17189
- const appendConfig = bundleStoreConfig(resolved.product);
17190
- checkedAppend(outcome.candidateId, appendGateReceipt(appendConfig, outcome.candidateId, receipt));
17191
- }
17192
16983
  try {
17193
16984
  promoteWithinCurrentAuthority(outcome.candidateId);
17194
16985
  } catch (error) {
@@ -17203,19 +16994,6 @@ function buildLocalKnowledgeStore(config, authority) {
17203
16994
  const appendConfig = bundleStoreConfig(resolved.product);
17204
16995
  config.canaryAuthorityHooks?.beforeNegativeAppend?.();
17205
16996
  withCurrentWriterAuthority(config.knowledgeRoot, currentAuthority(config), () => {
17206
- if (outcome.corpusDigest !== void 0 && outcome.stateValidity === "stale") {
17207
- const current = resolveTruth(config.knowledgeRoot, outcome.candidateId, priors);
17208
- if (current === void 0) throw new KnowledgePromotionError(outcome.candidateId, "not-found");
17209
- const validity = deriveBundleTrust(current.bundle, priors).validity;
17210
- const insideWindow = (ordinal) => ordinal >= validity.openedAtOrdinal && (validity.closedAtOrdinal === void 0 || ordinal <= validity.closedAtOrdinal);
17211
- const priorRuns = new Set((readGateReceipts(current.bundleDir, outcome.candidateId) ?? []).flatMap((receipt) => !(0, import_agent_qa_schema59.isPromotionReceipt)(receipt) && receipt.gate === 2 && receipt.verdict === "abstain" && receipt.stateValidity === "stale" && receipt.benefit === "exercised-harmed" && receipt.runId !== void 0 && receipt.runId !== outcome.runId && insideWindow(receipt.producedAtOrdinal) ? [receipt.runId] : []));
17212
- if (!insideWindow(outcome.buildOrdinal) || priorRuns.size + 1 < import_agent_qa_schema59.GATE2_DEFAULT_STALE_CONFIRMATIONS) {
17213
- const receipt = gate2ReceiptFor(outcome, "abstain");
17214
- checkedAppend(outcome.candidateId, appendGateReceipt(appendConfig, outcome.candidateId, receipt));
17215
- config.onCanaryTailWithinCurrentAuthority?.();
17216
- return;
17217
- }
17218
- }
17219
16997
  const appended = appendOutcomeEvent(appendConfig, outcome.candidateId, {
17220
16998
  type: "contradicted",
17221
16999
  evidenceToken,
@@ -17228,19 +17006,8 @@ function buildLocalKnowledgeStore(config, authority) {
17228
17006
  if (appended.kind === "not-found") {
17229
17007
  throw new KnowledgePromotionError(outcome.candidateId, appended.kind);
17230
17008
  }
17231
- if (outcome.corpusDigest !== void 0) {
17232
- const receipt = gate2ReceiptFor(outcome, "fail");
17233
- checkedAppend(outcome.candidateId, appendGateReceipt(appendConfig, outcome.candidateId, receipt));
17234
- try {
17235
- promoteWithinCurrentAuthority(outcome.candidateId);
17236
- } catch (error) {
17237
- if (!expectedPromotionHold(error)) throw error;
17238
- reportHold(error);
17239
- }
17240
- }
17241
17009
  config.canaryAuthorityHooks?.beforeIndexProjection?.();
17242
17010
  applyIndexDeltaForBundleWithinCurrentAuthority({
17243
- ...priors === void 0 ? {} : { priors },
17244
17011
  knowledgeRoot: config.knowledgeRoot,
17245
17012
  bundleId: outcome.candidateId,
17246
17013
  product: resolved.product
@@ -17259,12 +17026,12 @@ function buildLocalKnowledgeStore(config, authority) {
17259
17026
  if (profile.mode === "propose-only") {
17260
17027
  throw new KnowledgePromotionError(candidateId, "propose-only");
17261
17028
  }
17262
- const resolved = resolveTruth(config.knowledgeRoot, candidateId, priors);
17029
+ const resolved = resolveTruth(config.knowledgeRoot, candidateId);
17263
17030
  if (resolved === void 0) throw new KnowledgePromotionError(candidateId, "not-found");
17264
17031
  const validated = (receipts ?? []).map((receipt) => {
17265
- const parsed = import_agent_qa_schema59.GateReceiptSchema.parse(receipt);
17032
+ const parsed = import_agent_qa_schema58.GateReceiptSchema.parse(receipt);
17266
17033
  if (parsed.candidateId !== candidateId) throw new TypeError("foreign candidateId");
17267
- if ((0, import_agent_qa_schema59.receiptDigestOf)(parsed) !== parsed.receiptDigest) throw new TypeError("receiptDigest mismatch");
17034
+ if ((0, import_agent_qa_schema58.receiptDigestOf)(parsed) !== parsed.receiptDigest) throw new TypeError("receiptDigest mismatch");
17268
17035
  return parsed;
17269
17036
  });
17270
17037
  const appendConfig = bundleStoreConfig(resolved.product);
@@ -17279,8 +17046,8 @@ function buildLocalKnowledgeStore(config, authority) {
17279
17046
  },
17280
17047
  async recordGateReceipt(receipt) {
17281
17048
  return withCurrentWriterAuthority(config.knowledgeRoot, currentAuthority(config), () => {
17282
- const candidateId = (0, import_agent_qa_schema59.asRecordId)(receipt.candidateId);
17283
- const resolved = resolveTruth(config.knowledgeRoot, candidateId, priors);
17049
+ const candidateId = (0, import_agent_qa_schema58.asRecordId)(receipt.candidateId);
17050
+ const resolved = resolveTruth(config.knowledgeRoot, candidateId);
17284
17051
  if (resolved === void 0) throw new KnowledgePromotionError(candidateId, "not-found");
17285
17052
  return checkedAppend(candidateId, appendGateReceipt(bundleStoreConfig(resolved.product), candidateId, receipt));
17286
17053
  });
@@ -17317,10 +17084,8 @@ async function runWriterPass(options, operations) {
17317
17084
  const injectedRebuild = options.operations?.rebuildIndex !== void 0;
17318
17085
  const rebuild = await operations.rebuildIndex({
17319
17086
  knowledgeRoot: options.knowledgeRoot,
17320
- ...options.priors === void 0 ? {} : { priors: options.priors },
17321
17087
  ...capability.kind === "ready" ? { embedder: capability.embedder } : {},
17322
- // Production rebuilds retain Phase 385's fresh authority fence at every mutation boundary.
17323
- // Fault-injection rebuilds keep their historical call shape and own their injected behavior.
17088
+ // Production rebuilds re-check the authority fence at every mutation boundary.
17324
17089
  ...injectedRebuild ? {} : {
17325
17090
  writerAuthority: {
17326
17091
  knowledgeRoot: options.knowledgeRoot,
@@ -17339,8 +17104,6 @@ function shouldSurfaceAuthorityLoss(options, error) {
17339
17104
  return options.surfaceAuthorityLoss !== false && error instanceof WriterAuthorityLostError;
17340
17105
  }
17341
17106
  async function runMaintenanceTail(options) {
17342
- const priors = snapshotTrustPriors(options.priors);
17343
- options = { ...options, ...priors === void 0 ? {} : { priors } };
17344
17107
  const operations = {
17345
17108
  ...DEFAULT_OPERATIONS,
17346
17109
  ...options.operations
@@ -17472,13 +17235,9 @@ function readClaimedCanaryOutcome(claimed) {
17472
17235
  return void 0;
17473
17236
  }
17474
17237
  return {
17475
- candidateId: (0, import_agent_qa_schema60.asRecordId)(read.payload.candidateId),
17238
+ candidateId: (0, import_agent_qa_schema59.asRecordId)(read.payload.candidateId),
17476
17239
  runOutcome: read.payload.outcome,
17477
17240
  benefit: read.payload.benefit,
17478
- stateValidity: read.payload.stateValidity,
17479
- ...read.payload.corpusDigest === void 0 ? {} : { corpusDigest: read.payload.corpusDigest },
17480
- ...read.payload.observedStateDigest === void 0 ? {} : { observedStateDigest: read.payload.observedStateDigest },
17481
- ...read.payload.ablation === void 0 ? {} : { ablation: read.payload.ablation },
17482
17241
  runId: read.payload.runId,
17483
17242
  testId: read.payload.testId,
17484
17243
  testIndex: read.payload.testIndex,
@@ -17555,7 +17314,7 @@ function jobView(payload, fallbackExecutionContext) {
17555
17314
  }
17556
17315
  function addTargetedQuery(queries, seen, query) {
17557
17316
  if (queries.length >= SEARCH_BEFORE_CREATE_MAX_QUERIES) return;
17558
- const key = (0, import_agent_qa_schema60.canonicalJson)({ intent: query.intent, anchors: query.anchors });
17317
+ const key = (0, import_agent_qa_schema59.canonicalJson)({ intent: query.intent, anchors: query.anchors });
17559
17318
  if (seen.has(key)) return;
17560
17319
  seen.add(key);
17561
17320
  queries.push(query);
@@ -17658,7 +17417,7 @@ async function searchBeforeCreate(operations, payload, knowledgeRoot, embeddingC
17658
17417
  function checkpointFromAuthored(deltas, authorship, neighbors) {
17659
17418
  const seen = /* @__PURE__ */ new Set();
17660
17419
  const preconditions = deltas.flatMap((delta) => delta.precondition ?? []).filter((cas) => {
17661
- const key = (0, import_agent_qa_schema60.canonicalJson)(cas);
17420
+ const key = (0, import_agent_qa_schema59.canonicalJson)(cas);
17662
17421
  if (seen.has(key)) return false;
17663
17422
  seen.add(key);
17664
17423
  return true;
@@ -17852,24 +17611,16 @@ function isSuccessfulTerminalCommitOutcome(outcome) {
17852
17611
  return false;
17853
17612
  }
17854
17613
  }
17855
- function reconcileDependencies(operations, knowledgeRoot, writerAuthority, priors) {
17614
+ function reconcileDependencies(operations, knowledgeRoot, writerAuthority) {
17856
17615
  return {
17857
17616
  knowledgeRoot,
17858
17617
  writerAuthority,
17859
17618
  hasIndexRow: (bundleId) => operations.hasIndexRow(knowledgeRoot, bundleId),
17860
17619
  applyIndexDelta: (intent) => {
17861
- operations.applyIndexDeltaForBundle({
17862
- knowledgeRoot,
17863
- bundleId: intent.bundleId,
17864
- ...priors === void 0 ? {} : { priors }
17865
- });
17620
+ operations.applyIndexDeltaForBundle({ knowledgeRoot, bundleId: intent.bundleId });
17866
17621
  },
17867
17622
  deriveIndexRowFromBundle: (bundleId) => {
17868
- operations.deriveIndexRowFromBundle({
17869
- knowledgeRoot,
17870
- bundleId,
17871
- ...priors === void 0 ? {} : { priors }
17872
- });
17623
+ operations.deriveIndexRowFromBundle({ knowledgeRoot, bundleId });
17873
17624
  }
17874
17625
  };
17875
17626
  }
@@ -17882,7 +17633,6 @@ function budgetMs(options) {
17882
17633
  return value;
17883
17634
  }
17884
17635
  async function drainQueue(options) {
17885
- const priors = snapshotTrustPriors(options.priors);
17886
17636
  const operations = { ...DEFAULT_OPERATIONS2, ...options.operations };
17887
17637
  const now = options.now ?? Date.now;
17888
17638
  const startedAt = now();
@@ -17917,7 +17667,7 @@ async function drainQueue(options) {
17917
17667
  try {
17918
17668
  try {
17919
17669
  result.reconcile = operations.reconcileOnDrainStart(
17920
- reconcileDependencies(operations, options.knowledgeRoot, lease, priors)
17670
+ reconcileDependencies(operations, options.knowledgeRoot, lease)
17921
17671
  );
17922
17672
  } catch (error) {
17923
17673
  recordFailure(result, "reconcile", error);
@@ -17991,15 +17741,8 @@ async function drainQueue(options) {
17991
17741
  sourceRunId: canaryOutcome.runId,
17992
17742
  sourceJobId: claimed.candidateId,
17993
17743
  writerLeaseId: lease.leaseId,
17994
- ...priors === void 0 ? {} : { resolveTrustPriors: () => priors },
17995
- ...options.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: options.resolvePromotionPosture },
17996
17744
  onPromotionOutcome: (outcome) => result.promotions.push(outcome),
17997
- /**
17998
- * CR-02: the terminal transition joins the canary tail's own held section through
17999
- * the within-held form. Calling the fenced writeJobState here would re-enter
18000
- * withCurrentWriterAuthority against a BEGIN IMMEDIATE the tail already holds and
18001
- * deadlock (the Plan 25/28 within-held idiom).
18002
- */
17745
+ // Within-held form: the fenced write would re-enter the held transaction and deadlock.
18003
17746
  onCanaryTailWithinCurrentAuthority: () => {
18004
17747
  writeJobStateWithinCurrentAuthority({
18005
17748
  knowledgeRoot: options.knowledgeRoot,
@@ -18117,8 +17860,6 @@ async function drainQueue(options) {
18117
17860
  epoch: lease.epoch,
18118
17861
  profile: resolveDispositionProfile(executionContext),
18119
17862
  drainState,
18120
- ...priors === void 0 ? {} : { priors },
18121
- ...options.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: options.resolvePromotionPosture },
18122
17863
  ...!finalDelta || anySliceFailed ? { deferCompletion: true } : {}
18123
17864
  },
18124
17865
  claimed,
@@ -18193,7 +17934,6 @@ async function drainQueue(options) {
18193
17934
  } else {
18194
17935
  const maintenance = await runMaintenanceTail({
18195
17936
  knowledgeRoot: options.knowledgeRoot,
18196
- ...priors === void 0 ? {} : { priors },
18197
17937
  lease,
18198
17938
  ...options.embeddingCapability === void 0 ? {} : { embeddingCapability: options.embeddingCapability },
18199
17939
  operations,
@@ -18247,8 +17987,8 @@ async function drainQueue(options) {
18247
17987
  // src/purge.ts
18248
17988
  var import_node_crypto19 = require("node:crypto");
18249
17989
  var import_node_fs38 = require("node:fs");
18250
- var import_node_path41 = require("node:path");
18251
- var import_agent_qa_schema61 = require("@vostride/agent-qa-schema");
17990
+ var import_node_path40 = require("node:path");
17991
+ var import_agent_qa_schema60 = require("@vostride/agent-qa-schema");
18252
17992
  var import_zod14 = require("zod");
18253
17993
  var QUEUE_CANDIDATE_ID = /^[0-9a-f]{64}$/;
18254
17994
  var PURGE_SAFE_PATH_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -18285,7 +18025,7 @@ var PurgeIntentSchema = import_zod14.z.object({
18285
18025
  queuePayloadDirs: import_zod14.z.array(purgeReceiptRelativePathSchema),
18286
18026
  affectedSet: PurgeAffectedSetSchema
18287
18027
  }).strict();
18288
- var guardPurgeIntentVersion = (0, import_agent_qa_schema61.createVersionGuard)({
18028
+ var guardPurgeIntentVersion = (0, import_agent_qa_schema60.createVersionGuard)({
18289
18029
  name: "PurgeIntent",
18290
18030
  current: PURGE_INTENT_SCHEMA_VERSION,
18291
18031
  migrations: {}
@@ -18336,7 +18076,7 @@ var PurgeChronologyRequiredError = class extends Error {
18336
18076
  }
18337
18077
  };
18338
18078
  function assertInput(input) {
18339
- if (!(0, import_node_path41.isAbsolute)(input.knowledgeRoot)) {
18079
+ if (!(0, import_node_path40.isAbsolute)(input.knowledgeRoot)) {
18340
18080
  throw new TypeError("knowledgeRoot must be absolute");
18341
18081
  }
18342
18082
  if (input.initiator.trim() === "") {
@@ -18364,7 +18104,7 @@ function fenceWriterAuthority(input) {
18364
18104
  }
18365
18105
  function resolveBundles(knowledgeRoot, recordId) {
18366
18106
  const matches = [];
18367
- const memoryRoot = (0, import_node_path41.join)(knowledgeRoot, "memory");
18107
+ const memoryRoot = (0, import_node_path40.join)(knowledgeRoot, "memory");
18368
18108
  let entries;
18369
18109
  try {
18370
18110
  entries = (0, import_node_fs38.readdirSync)(memoryRoot, { withFileTypes: true });
@@ -18375,7 +18115,7 @@ function resolveBundles(knowledgeRoot, recordId) {
18375
18115
  for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
18376
18116
  if (entry.name.startsWith(".") || entry.name === "index" || entry.name === "queue" || entry.name === "receipts") continue;
18377
18117
  const targetRelativePath = `memory/${entry.name}/bundles/${recordId}`;
18378
- const targetDir = (0, import_node_path41.join)(knowledgeRoot, targetRelativePath);
18118
+ const targetDir = (0, import_node_path40.join)(knowledgeRoot, targetRelativePath);
18379
18119
  let targetStat;
18380
18120
  try {
18381
18121
  targetStat = (0, import_node_fs38.lstatSync)(targetDir);
@@ -18423,7 +18163,7 @@ function purgeIndexSurfaces(knowledgeRoot, recordId, kind) {
18423
18163
  try {
18424
18164
  const row = writer.db.prepare("SELECT record_rowid, kind FROM records WHERE bundle_id = ?").get(recordId);
18425
18165
  const resolvedKind = kind ?? (row === void 0 ? void 0 : String(row.kind));
18426
- const recordNode = resolvedKind === void 0 ? void 0 : (0, import_agent_qa_schema61.recordGraphNode)(resolvedKind, recordId);
18166
+ const recordNode = resolvedKind === void 0 ? void 0 : (0, import_agent_qa_schema60.recordGraphNode)(resolvedKind, recordId);
18427
18167
  transaction3(() => {
18428
18168
  if (row !== void 0 && recordNode !== void 0) {
18429
18169
  const recordRowid = Number(row.record_rowid);
@@ -18477,28 +18217,28 @@ function payloadDirectories(root) {
18477
18217
  return;
18478
18218
  }
18479
18219
  for (const entry of entries) {
18480
- if (entry.isDirectory()) visit((0, import_node_path41.join)(dir, entry.name));
18220
+ if (entry.isDirectory()) visit((0, import_node_path40.join)(dir, entry.name));
18481
18221
  }
18482
18222
  }
18483
18223
  visit(root);
18484
18224
  return found.sort();
18485
18225
  }
18486
18226
  function removeEmptyQueueParents(candidateDir, root, beforeMutation) {
18487
- let current = (0, import_node_path41.dirname)(candidateDir);
18488
- while (current !== root && current.startsWith(`${root}${import_node_path41.sep}`)) {
18227
+ let current = (0, import_node_path40.dirname)(candidateDir);
18228
+ while (current !== root && current.startsWith(`${root}${import_node_path40.sep}`)) {
18489
18229
  try {
18490
18230
  beforeMutation?.();
18491
18231
  (0, import_node_fs38.rmdirSync)(current);
18492
18232
  } catch (error) {
18493
18233
  const code = error.code;
18494
18234
  if (code === "ENOENT") {
18495
- current = (0, import_node_path41.dirname)(current);
18235
+ current = (0, import_node_path40.dirname)(current);
18496
18236
  continue;
18497
18237
  }
18498
18238
  if (code === "ENOTEMPTY" || code === "EEXIST") return;
18499
18239
  throw error;
18500
18240
  }
18501
- current = (0, import_node_path41.dirname)(current);
18241
+ current = (0, import_node_path40.dirname)(current);
18502
18242
  }
18503
18243
  }
18504
18244
  function lineageCandidateIds(matches) {
@@ -18526,8 +18266,8 @@ function contentSeeds(matches) {
18526
18266
  function artifactDigests(matches) {
18527
18267
  const digests = /* @__PURE__ */ new Set();
18528
18268
  for (const { bundle } of matches) {
18529
- for (const digest3 of Object.values(bundle.manifest.contentHashes)) {
18530
- digests.add(digest3);
18269
+ for (const digest2 of Object.values(bundle.manifest.contentHashes)) {
18270
+ digests.add(digest2);
18531
18271
  }
18532
18272
  }
18533
18273
  return digests;
@@ -18541,8 +18281,8 @@ function looselyCarriesPurgedContent(payload, seeds, digests) {
18541
18281
  const inventory = Array.isArray(loose["artifactInventory"]) ? loose["artifactInventory"] : [];
18542
18282
  return seedMatch || inventory.some((artifact) => {
18543
18283
  if (typeof artifact !== "object" || artifact === null) return false;
18544
- const digest3 = artifact["sha256"];
18545
- return typeof digest3 === "string" && digests.has(digest3);
18284
+ const digest2 = artifact["sha256"];
18285
+ return typeof digest2 === "string" && digests.has(digest2);
18546
18286
  });
18547
18287
  }
18548
18288
  function resolveQueueSweepTargets(knowledgeRoot, matches) {
@@ -18551,7 +18291,7 @@ function resolveQueueSweepTargets(knowledgeRoot, matches) {
18551
18291
  const digests = artifactDigests(matches);
18552
18292
  const targets = [];
18553
18293
  for (const candidateDir of payloadDirectories(queueRoot(knowledgeRoot))) {
18554
- const candidateId = (0, import_node_path41.basename)(candidateDir);
18294
+ const candidateId = (0, import_node_path40.basename)(candidateDir);
18555
18295
  if (!QUEUE_CANDIDATE_ID.test(candidateId)) {
18556
18296
  throw new PurgeQueueIdentityError(candidateDir, "non-canonical candidate directory");
18557
18297
  }
@@ -18561,7 +18301,7 @@ function resolveQueueSweepTargets(knowledgeRoot, matches) {
18561
18301
  }
18562
18302
  let payload;
18563
18303
  try {
18564
- payload = JSON.parse((0, import_node_fs38.readFileSync)((0, import_node_path41.join)(candidateDir, "payload.json"), "utf8"));
18304
+ payload = JSON.parse((0, import_node_fs38.readFileSync)((0, import_node_path40.join)(candidateDir, "payload.json"), "utf8"));
18565
18305
  } catch (error) {
18566
18306
  throw new PurgeQueueIdentityError(
18567
18307
  candidateDir,
@@ -18604,7 +18344,7 @@ function sweepQueuePayloads(input, targets) {
18604
18344
  assertWithinKnowledgeRoot(input.knowledgeRoot, target.candidateDir);
18605
18345
  assertWithinKnowledgeRoot(
18606
18346
  input.knowledgeRoot,
18607
- (0, import_node_path41.dirname)(jobStatePath(input.knowledgeRoot, target.candidateId))
18347
+ (0, import_node_path40.dirname)(jobStatePath(input.knowledgeRoot, target.candidateId))
18608
18348
  );
18609
18349
  fenceWriterAuthority(input);
18610
18350
  (0, import_node_fs38.rmSync)(target.candidateDir, { recursive: true, force: true });
@@ -18619,7 +18359,7 @@ function sweepQueuePayloads(input, targets) {
18619
18359
  }
18620
18360
  function assertPurgePathAbsent(knowledgeRoot, relativePath) {
18621
18361
  try {
18622
- (0, import_node_fs38.lstatSync)((0, import_node_path41.join)(knowledgeRoot, relativePath));
18362
+ (0, import_node_fs38.lstatSync)((0, import_node_path40.join)(knowledgeRoot, relativePath));
18623
18363
  } catch (error) {
18624
18364
  if (error.code === "ENOENT") return;
18625
18365
  throw error;
@@ -18633,7 +18373,7 @@ function verifyPurgedIndexSurfaces(knowledgeRoot, recordId) {
18633
18373
  if (writer.db.prepare("SELECT 1 FROM records WHERE bundle_id = ?").get(recordId)) {
18634
18374
  throw new PurgeCompletionVerificationError(`index records/${recordId}`);
18635
18375
  }
18636
- const nodeIds = ["fact", "procedure", "caution", "unknown", "policy"].map((kind) => (0, import_agent_qa_schema61.recordGraphNode)(
18376
+ const nodeIds = ["fact", "procedure", "caution", "unknown", "policy"].map((kind) => (0, import_agent_qa_schema60.recordGraphNode)(
18637
18377
  kind,
18638
18378
  recordId
18639
18379
  ).nodeId);
@@ -18668,7 +18408,7 @@ function verifyPurgeCompletion(input, intent) {
18668
18408
  }
18669
18409
  const candidateIds = new Set(intent.queueCandidateIds);
18670
18410
  for (const dir of payloadDirectories(queueRoot(input.knowledgeRoot))) {
18671
- if (candidateIds.has((0, import_node_path41.basename)(dir))) {
18411
+ if (candidateIds.has((0, import_node_path40.basename)(dir))) {
18672
18412
  throw new PurgeCompletionVerificationError(toReceiptPath(input.knowledgeRoot, dir));
18673
18413
  }
18674
18414
  }
@@ -18679,17 +18419,17 @@ function receiptCycleRelativePath(recordId, cycle) {
18679
18419
  }
18680
18420
  function receiptCyclePath(knowledgeRoot, recordId, cycle) {
18681
18421
  const fileName = receiptCycleRelativePath(recordId, cycle).split("/").at(-1);
18682
- return (0, import_node_path41.join)(knowledgeRoot, "memory", "receipts", fileName);
18422
+ return (0, import_node_path40.join)(knowledgeRoot, "memory", "receipts", fileName);
18683
18423
  }
18684
18424
  function intentPath2(knowledgeRoot, recordId) {
18685
- return (0, import_node_path41.join)(knowledgeRoot, "memory", "receipts", `purge-${recordId}.intent.json`);
18425
+ return (0, import_node_path40.join)(knowledgeRoot, "memory", "receipts", `purge-${recordId}.intent.json`);
18686
18426
  }
18687
18427
  function readReceiptAtCycle(knowledgeRoot, recordId, cycle) {
18688
18428
  const file = receiptCyclePath(knowledgeRoot, recordId, cycle);
18689
18429
  if (!(0, import_node_fs38.existsSync)(file)) return void 0;
18690
18430
  return guardPurgeReceiptForFile(
18691
18431
  JSON.parse((0, import_node_fs38.readFileSync)(file, "utf8")),
18692
- (0, import_node_path41.basename)(file),
18432
+ (0, import_node_path40.basename)(file),
18693
18433
  { recordId, cycle }
18694
18434
  );
18695
18435
  }
@@ -18703,7 +18443,7 @@ function resolveReceiptSeries(knowledgeRoot, recordId) {
18703
18443
  };
18704
18444
  }
18705
18445
  function assertCanonicalPurgeReceiptHistory(knowledgeRoot) {
18706
- const receiptsDir = (0, import_node_path41.join)(knowledgeRoot, "memory", "receipts");
18446
+ const receiptsDir = (0, import_node_path40.join)(knowledgeRoot, "memory", "receipts");
18707
18447
  let files;
18708
18448
  try {
18709
18449
  files = (0, import_node_fs38.readdirSync)(receiptsDir, { withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => entry.name).sort();
@@ -18715,7 +18455,7 @@ function assertCanonicalPurgeReceiptHistory(knowledgeRoot) {
18715
18455
  const canonicalName = parseCanonicalPurgeReceiptFileName(file);
18716
18456
  if (canonicalName === void 0) continue;
18717
18457
  guardPurgeReceiptForFile(
18718
- JSON.parse((0, import_node_fs38.readFileSync)((0, import_node_path41.join)(receiptsDir, file), "utf8")),
18458
+ JSON.parse((0, import_node_fs38.readFileSync)((0, import_node_path40.join)(receiptsDir, file), "utf8")),
18719
18459
  file,
18720
18460
  canonicalName
18721
18461
  );
@@ -18724,7 +18464,7 @@ function assertCanonicalPurgeReceiptHistory(knowledgeRoot) {
18724
18464
  function assertNoSymlinkComponents(knowledgeRoot, relativePath) {
18725
18465
  let current = knowledgeRoot;
18726
18466
  for (const segment of relativePath.split("/")) {
18727
- current = (0, import_node_path41.join)(current, segment);
18467
+ current = (0, import_node_path40.join)(current, segment);
18728
18468
  try {
18729
18469
  if ((0, import_node_fs38.lstatSync)(current).isSymbolicLink()) {
18730
18470
  throw new TypeError(`purge authority path crosses a symbolic link: ${relativePath}`);
@@ -18746,7 +18486,7 @@ function sorted(values) {
18746
18486
  function assertSameIdentities(actual, expected, label) {
18747
18487
  assertUnique(actual, label);
18748
18488
  assertUnique(expected, label);
18749
- if ((0, import_agent_qa_schema61.canonicalJson)(sorted(actual)) !== (0, import_agent_qa_schema61.canonicalJson)(sorted(expected))) {
18489
+ if ((0, import_agent_qa_schema60.canonicalJson)(sorted(actual)) !== (0, import_agent_qa_schema60.canonicalJson)(sorted(expected))) {
18750
18490
  throw new TypeError(`${label} does not match the executable purge identities`);
18751
18491
  }
18752
18492
  }
@@ -18841,14 +18581,14 @@ function guardPurgeIntentForRequest(knowledgeRoot, requestedRecordId, value) {
18841
18581
  "purge affected-set receipt paths"
18842
18582
  );
18843
18583
  const expectedQueueTargets = queueTargets.map(
18844
- ({ candidateId, candidateDir }) => (0, import_agent_qa_schema61.canonicalJson)({
18584
+ ({ candidateId, candidateDir }) => (0, import_agent_qa_schema60.canonicalJson)({
18845
18585
  candidateId,
18846
18586
  candidateDir,
18847
18587
  jobStatePath: `memory/queue/jobs/${candidateId}.state.json`
18848
18588
  })
18849
18589
  );
18850
18590
  assertSameIdentities(
18851
- affected.queueTargets.map((target) => (0, import_agent_qa_schema61.canonicalJson)(target)),
18591
+ affected.queueTargets.map((target) => (0, import_agent_qa_schema60.canonicalJson)(target)),
18852
18592
  expectedQueueTargets,
18853
18593
  "purge affected-set queue targets"
18854
18594
  );
@@ -18873,7 +18613,7 @@ function readExistingIntent(knowledgeRoot, recordId) {
18873
18613
  );
18874
18614
  }
18875
18615
  function toReceiptPath(knowledgeRoot, absolutePath) {
18876
- return (0, import_node_path41.relative)(knowledgeRoot, absolutePath).split(import_node_path41.sep).join("/");
18616
+ return (0, import_node_path40.relative)(knowledgeRoot, absolutePath).split(import_node_path40.sep).join("/");
18877
18617
  }
18878
18618
  function affectedPaths(knowledgeRoot, matches) {
18879
18619
  const paths = /* @__PURE__ */ new Set();
@@ -18954,7 +18694,7 @@ function resolvePurgeTargets(knowledgeRoot, recordId) {
18954
18694
  };
18955
18695
  }
18956
18696
  function resolvePurgeAffectedSet(input) {
18957
- if (!(0, import_node_path41.isAbsolute)(input.knowledgeRoot)) {
18697
+ if (!(0, import_node_path40.isAbsolute)(input.knowledgeRoot)) {
18958
18698
  throw new TypeError("knowledgeRoot must be absolute");
18959
18699
  }
18960
18700
  if (!PURGE_SAFE_RECORD_ID.test(input.recordId)) {
@@ -18964,7 +18704,7 @@ function resolvePurgeAffectedSet(input) {
18964
18704
  return resolved.affectedSet;
18965
18705
  }
18966
18706
  function purgeAffectedSetFingerprint(affectedSet) {
18967
- return (0, import_node_crypto19.createHash)("sha256").update((0, import_agent_qa_schema61.canonicalJson)(affectedSet)).digest("hex");
18707
+ return (0, import_node_crypto19.createHash)("sha256").update((0, import_agent_qa_schema60.canonicalJson)(affectedSet)).digest("hex");
18968
18708
  }
18969
18709
  function assertExpectedAffectedSet(expectedFingerprint, affectedSet) {
18970
18710
  if (expectedFingerprint === void 0) return;
@@ -18993,7 +18733,7 @@ function buildReceipt(input, matches, occurrenceOrdinal) {
18993
18733
  });
18994
18734
  }
18995
18735
  function writeDurableExclusive(finalPath, text, beforeMutation) {
18996
- const directory = (0, import_node_path41.dirname)(finalPath);
18736
+ const directory = (0, import_node_path40.dirname)(finalPath);
18997
18737
  beforeMutation?.();
18998
18738
  (0, import_node_fs38.mkdirSync)(directory, { recursive: true });
18999
18739
  const temporary = `${finalPath}.tmp-${(0, import_node_crypto19.randomUUID)()}`;
@@ -19036,13 +18776,13 @@ function retireIntent(input) {
19036
18776
  if (!(0, import_node_fs38.existsSync)(file)) return;
19037
18777
  fenceWriterAuthority(input);
19038
18778
  (0, import_node_fs38.rmSync)(file, { force: true });
19039
- fsyncDirectory((0, import_node_path41.dirname)(file));
18779
+ fsyncDirectory((0, import_node_path40.dirname)(file));
19040
18780
  }
19041
18781
  function publishReceiptAndRetire(input, receiptText, receipt, receiptCycle) {
19042
18782
  input.hooks?.beforeReceiptPublish?.();
19043
18783
  assertWithinKnowledgeRoot(
19044
18784
  input.knowledgeRoot,
19045
- (0, import_node_path41.dirname)(receiptCyclePath(input.knowledgeRoot, input.recordId, receiptCycle))
18785
+ (0, import_node_path40.dirname)(receiptCyclePath(input.knowledgeRoot, input.recordId, receiptCycle))
19046
18786
  );
19047
18787
  const writeOutcome = writeDurableExclusive(
19048
18788
  receiptCyclePath(input.knowledgeRoot, input.recordId, receiptCycle),
@@ -19062,7 +18802,7 @@ function publishReceiptAndRetire(input, receiptText, receipt, receiptCycle) {
19062
18802
  }
19063
18803
  function survivingBundleKind(knowledgeRoot, intent) {
19064
18804
  for (const dir of intent.bundleDirs) {
19065
- const loaded = loadBundle((0, import_node_path41.join)(knowledgeRoot, dir));
18805
+ const loaded = loadBundle((0, import_node_path40.join)(knowledgeRoot, dir));
19066
18806
  if (loaded.kind === "loaded") return loaded.bundle.frontmatter.kind;
19067
18807
  }
19068
18808
  return void 0;
@@ -19076,14 +18816,14 @@ function resumeFromIntent(input, intent) {
19076
18816
  );
19077
18817
  input.hooks?.afterProjectionPurge?.();
19078
18818
  for (const dir of intent.bundleDirs) {
19079
- assertWithinKnowledgeRoot(input.knowledgeRoot, (0, import_node_path41.join)(input.knowledgeRoot, dir));
18819
+ assertWithinKnowledgeRoot(input.knowledgeRoot, (0, import_node_path40.join)(input.knowledgeRoot, dir));
19080
18820
  fenceWriterAuthority(input);
19081
- (0, import_node_fs38.rmSync)((0, import_node_path41.join)(input.knowledgeRoot, dir), { recursive: true, force: true });
18821
+ (0, import_node_fs38.rmSync)((0, import_node_path40.join)(input.knowledgeRoot, dir), { recursive: true, force: true });
19082
18822
  input.hooks?.afterBundleRemoval?.();
19083
18823
  }
19084
18824
  const root = queueRoot(input.knowledgeRoot);
19085
18825
  for (const dir of intent.queuePayloadDirs) {
19086
- const candidateDir = (0, import_node_path41.join)(input.knowledgeRoot, dir);
18826
+ const candidateDir = (0, import_node_path40.join)(input.knowledgeRoot, dir);
19087
18827
  assertWithinKnowledgeRoot(input.knowledgeRoot, candidateDir);
19088
18828
  fenceWriterAuthority(input);
19089
18829
  (0, import_node_fs38.rmSync)(candidateDir, { recursive: true, force: true });
@@ -19097,7 +18837,7 @@ function resumeFromIntent(input, intent) {
19097
18837
  verifyPurgeCompletion(input, intent);
19098
18838
  return publishReceiptAndRetire(
19099
18839
  input,
19100
- (0, import_agent_qa_schema61.committedFileText)(intent.receipt),
18840
+ (0, import_agent_qa_schema60.committedFileText)(intent.receipt),
19101
18841
  intent.receipt,
19102
18842
  intent.receiptCycle
19103
18843
  );
@@ -19115,7 +18855,7 @@ function purgeRecord(input) {
19115
18855
  const receiptCycle = series.nextCycle;
19116
18856
  const occurrenceOrdinal = freshPurgeOrdinal(input);
19117
18857
  const receipt = buildReceipt(input, matches, occurrenceOrdinal);
19118
- const receiptText = (0, import_agent_qa_schema61.committedFileText)(receipt);
18858
+ const receiptText = (0, import_agent_qa_schema60.committedFileText)(receipt);
19119
18859
  const kind = matches[0].bundle.frontmatter.kind;
19120
18860
  const queueSweepTargets = resolved.queueSweepTargets;
19121
18861
  const intent = buildIntent(
@@ -19126,10 +18866,10 @@ function purgeRecord(input) {
19126
18866
  queueSweepTargets,
19127
18867
  resolved.affectedSet
19128
18868
  );
19129
- assertWithinKnowledgeRoot(input.knowledgeRoot, (0, import_node_path41.dirname)(intentPath2(input.knowledgeRoot, input.recordId)));
18869
+ assertWithinKnowledgeRoot(input.knowledgeRoot, (0, import_node_path40.dirname)(intentPath2(input.knowledgeRoot, input.recordId)));
19130
18870
  const intentOutcome = writeDurableExclusive(
19131
18871
  intentPath2(input.knowledgeRoot, input.recordId),
19132
- (0, import_agent_qa_schema61.committedFileText)(intent),
18872
+ (0, import_agent_qa_schema60.committedFileText)(intent),
19133
18873
  () => fenceWriterAuthority(input)
19134
18874
  );
19135
18875
  if (intentOutcome === "already-exists") {
@@ -19161,8 +18901,8 @@ function purgeRecord(input) {
19161
18901
 
19162
18902
  // src/inspect.ts
19163
18903
  var import_node_fs39 = require("node:fs");
19164
- var import_node_path42 = require("node:path");
19165
- var import_agent_qa_schema62 = require("@vostride/agent-qa-schema");
18904
+ var import_node_path41 = require("node:path");
18905
+ var import_agent_qa_schema61 = require("@vostride/agent-qa-schema");
19166
18906
  var TRUST_NARRATIVE_REL_PATH = "evidence/evidence.md";
19167
18907
  function compareText10(left, right) {
19168
18908
  return left < right ? -1 : left > right ? 1 : 0;
@@ -19204,11 +18944,11 @@ function parsedAnchor(value) {
19204
18944
  function scalarAnchorMatches(anchor, filter) {
19205
18945
  switch (anchor.t) {
19206
18946
  case "page":
19207
- return (0, import_agent_qa_schema62.canonicalJson)((0, import_agent_qa_schema62.normalizeAnchor)({ t: "page", route: filter })) === (0, import_agent_qa_schema62.canonicalJson)(anchor);
18947
+ return (0, import_agent_qa_schema61.canonicalJson)((0, import_agent_qa_schema61.normalizeAnchor)({ t: "page", route: filter })) === (0, import_agent_qa_schema61.canonicalJson)(anchor);
19208
18948
  case "flow":
19209
- return (0, import_agent_qa_schema62.canonicalJson)((0, import_agent_qa_schema62.normalizeAnchor)({ t: "flow", name: filter })) === (0, import_agent_qa_schema62.canonicalJson)(anchor);
18949
+ return (0, import_agent_qa_schema61.canonicalJson)((0, import_agent_qa_schema61.normalizeAnchor)({ t: "flow", name: filter })) === (0, import_agent_qa_schema61.canonicalJson)(anchor);
19210
18950
  case "el": {
19211
- const normalizedName = (0, import_agent_qa_schema62.normalizeAnchor)({
18951
+ const normalizedName = (0, import_agent_qa_schema61.normalizeAnchor)({
19212
18952
  t: "el",
19213
18953
  role: anchor.role,
19214
18954
  name: filter
@@ -19218,38 +18958,38 @@ function scalarAnchorMatches(anchor, filter) {
19218
18958
  case "platform":
19219
18959
  return filter.trim().toLowerCase() === anchor.platform;
19220
18960
  case "selector":
19221
- return (0, import_agent_qa_schema62.canonicalJson)((0, import_agent_qa_schema62.normalizeAnchor)({ t: "selector", literal: filter })) === (0, import_agent_qa_schema62.canonicalJson)(anchor);
18961
+ return (0, import_agent_qa_schema61.canonicalJson)((0, import_agent_qa_schema61.normalizeAnchor)({ t: "selector", literal: filter })) === (0, import_agent_qa_schema61.canonicalJson)(anchor);
19222
18962
  case "error":
19223
- return (0, import_agent_qa_schema62.canonicalJson)((0, import_agent_qa_schema62.normalizeAnchor)({ t: "error", message: filter })) === (0, import_agent_qa_schema62.canonicalJson)(anchor);
18963
+ return (0, import_agent_qa_schema61.canonicalJson)((0, import_agent_qa_schema61.normalizeAnchor)({ t: "error", message: filter })) === (0, import_agent_qa_schema61.canonicalJson)(anchor);
19224
18964
  }
19225
18965
  }
19226
18966
  function anchorMatches3(bundle, filter) {
19227
18967
  if (filter === void 0) return true;
19228
- const normalizedAnchors = bundle.frontmatter.anchors.map(({ raw }) => (0, import_agent_qa_schema62.normalizeAnchor)(raw));
18968
+ const normalizedAnchors = bundle.frontmatter.anchors.map(({ raw }) => (0, import_agent_qa_schema61.normalizeAnchor)(raw));
19229
18969
  const structured = parsedAnchor(filter);
19230
18970
  if (structured !== void 0) {
19231
- const canonicalFilter = (0, import_agent_qa_schema62.canonicalJson)((0, import_agent_qa_schema62.normalizeAnchor)(structured));
19232
- return normalizedAnchors.some((anchor) => (0, import_agent_qa_schema62.canonicalJson)(anchor) === canonicalFilter);
18971
+ const canonicalFilter = (0, import_agent_qa_schema61.canonicalJson)((0, import_agent_qa_schema61.normalizeAnchor)(structured));
18972
+ return normalizedAnchors.some((anchor) => (0, import_agent_qa_schema61.canonicalJson)(anchor) === canonicalFilter);
19233
18973
  }
19234
18974
  return normalizedAnchors.some((anchor) => scalarAnchorMatches(anchor, filter));
19235
18975
  }
19236
18976
  function readTrustNarrative(dir, bundle) {
19237
18977
  if (!(TRUST_NARRATIVE_REL_PATH in bundle.manifest.contentHashes)) return void 0;
19238
- const file = (0, import_node_path42.join)(dir, TRUST_NARRATIVE_REL_PATH);
18978
+ const file = (0, import_node_path41.join)(dir, TRUST_NARRATIVE_REL_PATH);
19239
18979
  return (0, import_node_fs39.existsSync)(file) ? (0, import_node_fs39.readFileSync)(file, "utf8") : void 0;
19240
18980
  }
19241
18981
  function toInspectRecordView(entry, bundle, trust) {
19242
- const survivingEvents = (0, import_agent_qa_schema62.survivingOutcomeEvents)(bundle.events);
18982
+ const survivingEvents = (0, import_agent_qa_schema61.survivingOutcomeEvents)(bundle.events);
19243
18983
  const evidenceTokens = [...new Set(
19244
18984
  survivingEvents.map((event) => String(event.evidenceToken))
19245
18985
  )].sort(compareText10);
19246
18986
  const lastEventOrdinal = survivingEvents.reduce(
19247
- (latest2, event) => Math.max(latest2, event.buildOrdinal),
18987
+ (latest, event) => Math.max(latest, event.buildOrdinal),
19248
18988
  bundle.manifest.createdAtOrdinal
19249
18989
  );
19250
18990
  const trustNarrative = readTrustNarrative(entry.dir, bundle);
19251
- return import_agent_qa_schema62.InspectRecordViewSchema.parse({
19252
- schemaVersion: import_agent_qa_schema62.INSPECT_RECORD_VIEW_SCHEMA_VERSION,
18991
+ return import_agent_qa_schema61.InspectRecordViewSchema.parse({
18992
+ schemaVersion: import_agent_qa_schema61.INSPECT_RECORD_VIEW_SCHEMA_VERSION,
19253
18993
  recordId: bundle.manifest.id,
19254
18994
  product: entry.product,
19255
18995
  scope: bundle.frontmatter.scope.key,
@@ -19261,12 +19001,12 @@ function toInspectRecordView(entry, bundle, trust) {
19261
19001
  lastEventOrdinal,
19262
19002
  openedAtOrdinal: trust.validity.openedAtOrdinal,
19263
19003
  ...trust.validity.closedAtOrdinal === void 0 ? {} : { closedAtOrdinal: trust.validity.closedAtOrdinal },
19264
- anchors: bundle.frontmatter.anchors.map(({ raw }) => (0, import_agent_qa_schema62.canonicalJson)((0, import_agent_qa_schema62.normalizeAnchor)(raw))).sort(compareText10),
19004
+ anchors: bundle.frontmatter.anchors.map(({ raw }) => (0, import_agent_qa_schema61.canonicalJson)((0, import_agent_qa_schema61.normalizeAnchor)(raw))).sort(compareText10),
19265
19005
  ...trustNarrative === void 0 ? {} : { trustNarrative }
19266
19006
  });
19267
19007
  }
19268
19008
  function inspectRecords(options) {
19269
- const filter = import_agent_qa_schema62.InspectFilterSchema.parse(options.filter);
19009
+ const filter = import_agent_qa_schema61.InspectFilterSchema.parse(options.filter);
19270
19010
  const records = [];
19271
19011
  const auditVisibility = filter.asOfBuild !== void 0 || filter.status === "superseded" || filter.status === "deprecated";
19272
19012
  for (const entry of enumerateMaintenanceBundleDirs(options.knowledgeRoot)) {
@@ -19290,7 +19030,7 @@ function inspectRecords(options) {
19290
19030
  }
19291
19031
 
19292
19032
  // src/show-records.ts
19293
- var import_agent_qa_schema63 = require("@vostride/agent-qa-schema");
19033
+ var import_agent_qa_schema62 = require("@vostride/agent-qa-schema");
19294
19034
  function showRecords(options) {
19295
19035
  const recordIds = [...new Set(options.recordIds)];
19296
19036
  if (recordIds.length === 0) return [];
@@ -19299,7 +19039,7 @@ function showRecords(options) {
19299
19039
  for (const entry of enumerateMaintenanceBundleDirs(options.knowledgeRoot)) {
19300
19040
  const bundle = loadMaintenanceBundle(entry);
19301
19041
  if (!pending.has(bundle.manifest.id)) continue;
19302
- found.set(bundle.manifest.id, import_agent_qa_schema63.KnowledgeRecordShowResultSchema.parse({
19042
+ found.set(bundle.manifest.id, import_agent_qa_schema62.KnowledgeRecordShowResultSchema.parse({
19303
19043
  kind: "found",
19304
19044
  schemaVersion: 2,
19305
19045
  record: toInspectRecordView(entry, bundle, deriveBundleTrust(bundle)),
@@ -19310,7 +19050,7 @@ function showRecords(options) {
19310
19050
  pending.delete(bundle.manifest.id);
19311
19051
  if (pending.size === 0) break;
19312
19052
  }
19313
- return recordIds.map((recordId) => found.get(recordId) ?? import_agent_qa_schema63.KnowledgeRecordShowResultSchema.parse({
19053
+ return recordIds.map((recordId) => found.get(recordId) ?? import_agent_qa_schema62.KnowledgeRecordShowResultSchema.parse({
19314
19054
  kind: "not-found",
19315
19055
  schemaVersion: 2,
19316
19056
  recordId
@@ -19323,7 +19063,7 @@ function showRecord(options) {
19323
19063
  }
19324
19064
 
19325
19065
  // src/review/propose-review.ts
19326
- var import_agent_qa_schema64 = require("@vostride/agent-qa-schema");
19066
+ var import_agent_qa_schema63 = require("@vostride/agent-qa-schema");
19327
19067
  var FORGET_SCRUBBED_PROJECTIONS = ["fts", "vec", "graph"];
19328
19068
  var MarkPlanIntegrityError = class extends Error {
19329
19069
  constructor(recordId) {
@@ -19354,14 +19094,14 @@ function reviewDeltasFor(request2, resolved, changeId) {
19354
19094
  const envelope2 = {
19355
19095
  origin: "user",
19356
19096
  scope: resolved.scope,
19357
- citedIds: [(0, import_agent_qa_schema64.asRecordId)(resolved.recordId)]
19097
+ citedIds: [(0, import_agent_qa_schema63.asRecordId)(resolved.recordId)]
19358
19098
  };
19359
19099
  switch (request2.verb) {
19360
19100
  case "mark": {
19361
- const parsed = import_agent_qa_schema64.KnowledgeMarkInputSchema.safeParse(request2.input);
19101
+ const parsed = import_agent_qa_schema63.KnowledgeMarkInputSchema.safeParse(request2.input);
19362
19102
  if (!parsed.success) throw new MarkPlanIntegrityError(resolved.recordId);
19363
19103
  const { plan, mark } = parsed.data;
19364
- if (plan.markId !== mark.markId || plan.fix !== mark.fix || plan.feedbackSource.runId !== mark.runId || plan.runTraceRef.runId !== mark.runId || plan.feedbackSource.testIndex !== mark.testIndex || plan.feedbackSource.stepIndex !== mark.stepIndex || plan.feedbackSource.kind !== mark.kind || (0, import_agent_qa_schema64.canonicalJson)(plan.target) !== (0, import_agent_qa_schema64.canonicalJson)(parsed.data.target) || plan.deltas.some((delta) => delta.origin !== "user" || (0, import_agent_qa_schema64.canonicalJson)(delta.scope) !== (0, import_agent_qa_schema64.canonicalJson)(resolved.scope) || !delta.citedIds.includes((0, import_agent_qa_schema64.asRecordId)(resolved.recordId)))) {
19104
+ if (plan.markId !== mark.markId || plan.fix !== mark.fix || plan.feedbackSource.runId !== mark.runId || plan.runTraceRef.runId !== mark.runId || plan.feedbackSource.testIndex !== mark.testIndex || plan.feedbackSource.stepIndex !== mark.stepIndex || plan.feedbackSource.kind !== mark.kind || (0, import_agent_qa_schema63.canonicalJson)(plan.target) !== (0, import_agent_qa_schema63.canonicalJson)(parsed.data.target) || plan.deltas.some((delta) => delta.origin !== "user" || (0, import_agent_qa_schema63.canonicalJson)(delta.scope) !== (0, import_agent_qa_schema63.canonicalJson)(resolved.scope) || !delta.citedIds.includes((0, import_agent_qa_schema63.asRecordId)(resolved.recordId)))) {
19365
19105
  throw new MarkPlanIntegrityError(resolved.recordId);
19366
19106
  }
19367
19107
  return plan.deltas;
@@ -19370,7 +19110,7 @@ function reviewDeltasFor(request2, resolved, changeId) {
19370
19110
  return [{
19371
19111
  ...envelope2,
19372
19112
  kind: "Confirm",
19373
- targetId: (0, import_agent_qa_schema64.asRecordId)(resolved.recordId),
19113
+ targetId: (0, import_agent_qa_schema63.asRecordId)(resolved.recordId),
19374
19114
  // The evidence for a human accept IS the change identity: deriving the token from it
19375
19115
  // makes the confirmation replay-safe (a second apply of the same change is the same
19376
19116
  // token, which the append dedups).
@@ -19380,14 +19120,14 @@ function reviewDeltasFor(request2, resolved, changeId) {
19380
19120
  return [{
19381
19121
  ...envelope2,
19382
19122
  kind: "Deprecate",
19383
- targetId: (0, import_agent_qa_schema64.asRecordId)(resolved.recordId),
19123
+ targetId: (0, import_agent_qa_schema63.asRecordId)(resolved.recordId),
19384
19124
  reason: request2.input.reason
19385
19125
  }];
19386
19126
  case "forget":
19387
19127
  return [{
19388
19128
  ...envelope2,
19389
19129
  kind: "Deprecate",
19390
- targetId: (0, import_agent_qa_schema64.asRecordId)(resolved.recordId),
19130
+ targetId: (0, import_agent_qa_schema63.asRecordId)(resolved.recordId),
19391
19131
  reason: `forget:${changeId}`
19392
19132
  }];
19393
19133
  }
@@ -19395,13 +19135,13 @@ function reviewDeltasFor(request2, resolved, changeId) {
19395
19135
 
19396
19136
  // src/review/apply-review.ts
19397
19137
  var import_node_fs42 = require("node:fs");
19398
- var import_node_path45 = require("node:path");
19399
- var import_agent_qa_schema67 = require("@vostride/agent-qa-schema");
19138
+ var import_node_path44 = require("node:path");
19139
+ var import_agent_qa_schema66 = require("@vostride/agent-qa-schema");
19400
19140
 
19401
19141
  // src/policy/materialize.ts
19402
19142
  var import_node_fs40 = require("node:fs");
19403
- var import_node_path43 = require("node:path");
19404
- var import_agent_qa_schema65 = require("@vostride/agent-qa-schema");
19143
+ var import_node_path42 = require("node:path");
19144
+ var import_agent_qa_schema64 = require("@vostride/agent-qa-schema");
19405
19145
  var PolicyTextRefusedError = class extends Error {
19406
19146
  constructor() {
19407
19147
  super("Policy text must not contain HTML comment delimiters or invalid marker identity");
@@ -19413,7 +19153,7 @@ function policySectionMarkers(recordId) {
19413
19153
  return { open: `<!-- agent-qa:policy ${recordId} -->`, close: `<!-- /agent-qa:policy ${recordId} -->` };
19414
19154
  }
19415
19155
  function policyShelfPath(knowledgeRoot, scope) {
19416
- return (0, import_node_path43.join)(knowledgeRoot, "policies", `${(0, import_agent_qa_schema65.slugBranch)(scope)}.md`);
19156
+ return (0, import_node_path42.join)(knowledgeRoot, "policies", `${(0, import_agent_qa_schema64.slugBranch)(scope)}.md`);
19417
19157
  }
19418
19158
  function materializePolicy(input) {
19419
19159
  return withCurrentWriterAuthority(input.knowledgeRoot, input.writerAuthority, () => materializeUnderAuthority(input));
@@ -19424,8 +19164,8 @@ function materializeUnderAuthority(input) {
19424
19164
  }
19425
19165
  const { open, close } = policySectionMarkers(input.recordId);
19426
19166
  const path = policyShelfPath(input.knowledgeRoot, input.scope);
19427
- assertWithinKnowledgeRoot(input.knowledgeRoot, (0, import_node_path43.dirname)(path));
19428
- const relPath = (0, import_node_path43.relative)(input.knowledgeRoot, path);
19167
+ assertWithinKnowledgeRoot(input.knowledgeRoot, (0, import_node_path42.dirname)(path));
19168
+ const relPath = (0, import_node_path42.relative)(input.knowledgeRoot, path);
19429
19169
  const section = `
19430
19170
  ${open}
19431
19171
  ${input.title ? `### ${input.title}
@@ -19462,7 +19202,7 @@ ${close}
19462
19202
  if (input.existingOnly) throw new PolicyTextRefusedError();
19463
19203
  const text = `${exists ? "" : `# Policies \u2014 ${input.scope}
19464
19204
  `}${section}`;
19465
- (0, import_node_fs40.mkdirSync)((0, import_node_path43.dirname)(path), { recursive: true });
19205
+ (0, import_node_fs40.mkdirSync)((0, import_node_path42.dirname)(path), { recursive: true });
19466
19206
  const staged = `${path}.pending`;
19467
19207
  let fd;
19468
19208
  try {
@@ -19482,13 +19222,13 @@ ${close}
19482
19222
  // src/review/forget-receipt-journal.ts
19483
19223
  var import_node_crypto20 = require("node:crypto");
19484
19224
  var import_node_fs41 = require("node:fs");
19485
- var import_node_path44 = require("node:path");
19486
- var import_agent_qa_schema66 = require("@vostride/agent-qa-schema");
19225
+ var import_node_path43 = require("node:path");
19226
+ var import_agent_qa_schema65 = require("@vostride/agent-qa-schema");
19487
19227
  var FORGET_RECEIPTS_SUBDIR = `${JOURNAL_SUBDIR}/forget-receipts`;
19488
19228
  function receiptFile(knowledgeRoot, changeId) {
19489
- if (!(0, import_node_path44.isAbsolute)(knowledgeRoot)) throw new TypeError("knowledgeRoot must be absolute");
19490
- const name = `${import_agent_qa_schema66.KnowledgeChangeIdSchema.parse(changeId)}.json`;
19491
- return (0, import_node_path44.join)(knowledgeRoot, FORGET_RECEIPTS_SUBDIR, name);
19229
+ if (!(0, import_node_path43.isAbsolute)(knowledgeRoot)) throw new TypeError("knowledgeRoot must be absolute");
19230
+ const name = `${import_agent_qa_schema65.KnowledgeChangeIdSchema.parse(changeId)}.json`;
19231
+ return (0, import_node_path43.join)(knowledgeRoot, FORGET_RECEIPTS_SUBDIR, name);
19492
19232
  }
19493
19233
  function readRecordedForgetReceipt(knowledgeRoot, changeId) {
19494
19234
  let text;
@@ -19504,18 +19244,18 @@ function readRecordedForgetReceipt(knowledgeRoot, changeId) {
19504
19244
  } catch {
19505
19245
  return void 0;
19506
19246
  }
19507
- const parsed = import_agent_qa_schema66.ForgetReceiptV1Schema.safeParse(value);
19247
+ const parsed = import_agent_qa_schema65.ForgetReceiptV1Schema.safeParse(value);
19508
19248
  if (!parsed.success || parsed.data.proposalId !== changeId) return void 0;
19509
19249
  return value;
19510
19250
  }
19511
19251
  function recordForgetReceipt(knowledgeRoot, authority, receipt) {
19512
- const file = receiptFile(knowledgeRoot, import_agent_qa_schema66.ForgetReceiptV1Schema.parse(receipt).proposalId);
19513
- assertWithinKnowledgeRoot(knowledgeRoot, (0, import_node_path44.dirname)(file));
19252
+ const file = receiptFile(knowledgeRoot, import_agent_qa_schema65.ForgetReceiptV1Schema.parse(receipt).proposalId);
19253
+ assertWithinKnowledgeRoot(knowledgeRoot, (0, import_node_path43.dirname)(file));
19514
19254
  const text = `${JSON.stringify(receipt)}
19515
19255
  `;
19516
19256
  withCurrentWriterAuthority(knowledgeRoot, authority, () => {
19517
- (0, import_node_fs41.mkdirSync)((0, import_node_path44.dirname)(file), { recursive: true });
19518
- fsyncDirectory((0, import_node_path44.dirname)((0, import_node_path44.dirname)(file)));
19257
+ (0, import_node_fs41.mkdirSync)((0, import_node_path43.dirname)(file), { recursive: true });
19258
+ fsyncDirectory((0, import_node_path43.dirname)((0, import_node_path43.dirname)(file)));
19519
19259
  const temporary = `${file}.tmp-${(0, import_node_crypto20.randomUUID)()}`;
19520
19260
  let fd;
19521
19261
  try {
@@ -19525,7 +19265,7 @@ function recordForgetReceipt(knowledgeRoot, authority, receipt) {
19525
19265
  (0, import_node_fs41.closeSync)(fd);
19526
19266
  fd = void 0;
19527
19267
  (0, import_node_fs41.renameSync)(temporary, file);
19528
- fsyncDirectory((0, import_node_path44.dirname)(file));
19268
+ fsyncDirectory((0, import_node_path43.dirname)(file));
19529
19269
  } finally {
19530
19270
  if (fd !== void 0) (0, import_node_fs41.closeSync)(fd);
19531
19271
  (0, import_node_fs41.rmSync)(temporary, { force: true });
@@ -19548,7 +19288,7 @@ var ApplyDelegateTimeoutError = class extends Error {
19548
19288
  var ApplyDelegateUnavailableError = class extends Error {
19549
19289
  constructor(changeId, holder) {
19550
19290
  super(
19551
- `The writer lease for this knowledge root is held by pid ${holder.pid} (lease ${holder.leaseId}, epoch ${holder.epoch}) and this host has no delegate transport, so ${changeId} cannot be applied here. Lease-stealing is structurally refused (386 D-14).`
19291
+ `The writer lease for this knowledge root is held by pid ${holder.pid} (lease ${holder.leaseId}, epoch ${holder.epoch}) and this host has no delegate transport, so ${changeId} cannot be applied here. Lease-stealing is structurally refused.`
19552
19292
  );
19553
19293
  this.changeId = changeId;
19554
19294
  this.holder = holder;
@@ -19633,7 +19373,7 @@ function assembleForgetReceipt(knowledgeRoot, change, forgottenAt, projectionsSc
19633
19373
  resultingBundleStatus = memoryStatusForBundle(located.status);
19634
19374
  }
19635
19375
  return {
19636
- schemaVersion: import_agent_qa_schema67.FORGET_RECEIPT_SCHEMA_VERSION,
19376
+ schemaVersion: import_agent_qa_schema66.FORGET_RECEIPT_SCHEMA_VERSION,
19637
19377
  proposalId: change.id,
19638
19378
  tombstonedRecords,
19639
19379
  projectionsScrubbed: [...projectionsScrubbed],
@@ -19648,9 +19388,7 @@ function reviewStore(writer, change, lease, sourceBuildOrdinal) {
19648
19388
  epoch: lease.epoch,
19649
19389
  writerLeaseId: lease.leaseId,
19650
19390
  ...change.mark === void 0 ? {} : { sourceRunId: change.mark.runId },
19651
- ...sourceBuildOrdinal === void 0 ? {} : { sourceBuildOrdinal },
19652
- ...writer.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: writer.resolvePromotionPosture },
19653
- ...writer.resolveTrustPriors === void 0 ? {} : { resolveTrustPriors: writer.resolveTrustPriors }
19391
+ ...sourceBuildOrdinal === void 0 ? {} : { sourceBuildOrdinal }
19654
19392
  });
19655
19393
  }
19656
19394
  async function commitInProcess(writer, change, lease, sourceBuildOrdinal) {
@@ -19676,7 +19414,7 @@ function readBackCommittedIds(knowledgeRoot, preOrdinal, change) {
19676
19414
  const ids = new Set(change.deltas.flatMap((delta) => delta.kind === "Confirm" ? [delta.targetId] : []));
19677
19415
  for (const row of diffSince({ knowledgeRoot, sinceOrdinal: preOrdinal })) {
19678
19416
  if (row.change === "added" || row.change === "confirmed" || row.change === "superseded") {
19679
- ids.add((0, import_agent_qa_schema67.asRecordId)(row.recordId));
19417
+ ids.add((0, import_agent_qa_schema66.asRecordId)(row.recordId));
19680
19418
  }
19681
19419
  }
19682
19420
  return [...ids].filter((id) => {
@@ -19686,8 +19424,8 @@ function readBackCommittedIds(knowledgeRoot, preOrdinal, change) {
19686
19424
  }
19687
19425
  function mintGate3Receipt(candidateId, writer, change, producedAtOrdinal) {
19688
19426
  if (change.mark === void 0) throw new TypeError("mark change has no mark stamp");
19689
- return (0, import_agent_qa_schema67.stampReceiptDigest)({
19690
- schemaVersion: import_agent_qa_schema67.GATE_RECEIPT_SCHEMA_VERSION,
19427
+ return (0, import_agent_qa_schema66.stampReceiptDigest)({
19428
+ schemaVersion: import_agent_qa_schema66.GATE_RECEIPT_SCHEMA_VERSION,
19691
19429
  gate: 3,
19692
19430
  candidateId,
19693
19431
  verdict: "pass",
@@ -19695,7 +19433,7 @@ function mintGate3Receipt(candidateId, writer, change, producedAtOrdinal) {
19695
19433
  producedBy: { opId: writer.opId },
19696
19434
  runId: change.mark.runId,
19697
19435
  ...change.mark.stepIndex === void 0 ? {} : {
19698
- stepId: (0, import_agent_qa_schema67.deriveMarkStepId)(change.mark.testIndex, change.mark.stepIndex)
19436
+ stepId: (0, import_agent_qa_schema66.deriveMarkStepId)(change.mark.testIndex, change.mark.stepIndex)
19699
19437
  },
19700
19438
  mark: change.mark.kind
19701
19439
  });
@@ -19707,7 +19445,7 @@ async function applyMarkArm(writer, change, authority) {
19707
19445
  const recordIds = recovered?.recordIds ?? readBackCommittedIds(writer.knowledgeRoot, preOrdinal, change);
19708
19446
  const committedAtOrdinal = recovered?.ordinal ?? currentOrdinal(writer.knowledgeRoot);
19709
19447
  const commitReceipt = {
19710
- schemaVersion: import_agent_qa_schema67.COMMIT_RECEIPT_SCHEMA_VERSION,
19448
+ schemaVersion: import_agent_qa_schema66.COMMIT_RECEIPT_SCHEMA_VERSION,
19711
19449
  proposalId: change.id,
19712
19450
  markId: change.mark.markId,
19713
19451
  committedAtOrdinal,
@@ -19719,7 +19457,7 @@ async function applyMarkArm(writer, change, authority) {
19719
19457
  for (const candidateId of recordIds) {
19720
19458
  const receipt = mintGate3Receipt(candidateId, writer, change, committedAtOrdinal);
19721
19459
  try {
19722
- const outcome = await store.promote((0, import_agent_qa_schema67.asRecordId)(candidateId), [receipt]);
19460
+ const outcome = await store.promote((0, import_agent_qa_schema66.asRecordId)(candidateId), [receipt]);
19723
19461
  if (outcome.promotionPath !== void 0) {
19724
19462
  commitReceipt.promoted.push({ candidateId, promotionPath: outcome.promotionPath });
19725
19463
  }
@@ -19747,7 +19485,7 @@ function completedMarkSupersession(writer, change, authority) {
19747
19485
  throw new ReviewTargetVanishedError(change.id);
19748
19486
  }
19749
19487
  const replacement = locateRecord(writer.knowledgeRoot, event.byRecordId);
19750
- if (replacement === void 0 || memoryStatusForBundle(replacement.status) === "tombstoned" || replacement.bundle.frontmatter.kind !== delta.newBundle.kind || replacement.bundle.frontmatter.subtype !== delta.newBundle.subtype || replacement.bundle.body !== delta.newBundle.body || (0, import_agent_qa_schema67.canonicalJson)(replacement.bundle.frontmatter.scope) !== (0, import_agent_qa_schema67.canonicalJson)(delta.newBundle.scope) || (0, import_agent_qa_schema67.canonicalJson)(replacement.bundle.frontmatter.anchors.map((anchor) => anchor.raw)) !== (0, import_agent_qa_schema67.canonicalJson)(delta.newBundle.anchors) || !replacement.bundle.events.some((row) => row.type === "confirmed" && row.evidenceToken === delta.evidenceToken && row.buildOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !replacement.bundle.relations.relations.some((row) => row.type === "supersedes" && row.targetId === delta.victimId && row.addedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !victim.bundle.events.some((row) => row.type === "window-close" && row.closedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId)) throw new ReviewTargetVanishedError(change.id);
19488
+ if (replacement === void 0 || memoryStatusForBundle(replacement.status) === "tombstoned" || replacement.bundle.frontmatter.kind !== delta.newBundle.kind || replacement.bundle.frontmatter.subtype !== delta.newBundle.subtype || replacement.bundle.body !== delta.newBundle.body || (0, import_agent_qa_schema66.canonicalJson)(replacement.bundle.frontmatter.scope) !== (0, import_agent_qa_schema66.canonicalJson)(delta.newBundle.scope) || (0, import_agent_qa_schema66.canonicalJson)(replacement.bundle.frontmatter.anchors.map((anchor) => anchor.raw)) !== (0, import_agent_qa_schema66.canonicalJson)(delta.newBundle.anchors) || !replacement.bundle.events.some((row) => row.type === "confirmed" && row.evidenceToken === delta.evidenceToken && row.buildOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !replacement.bundle.relations.relations.some((row) => row.type === "supersedes" && row.targetId === delta.victimId && row.addedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !victim.bundle.events.some((row) => row.type === "window-close" && row.closedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId)) throw new ReviewTargetVanishedError(change.id);
19751
19489
  found.push({ id: event.byRecordId, ordinal: event.buildOrdinal });
19752
19490
  }
19753
19491
  if (found.length === 0) return void 0;
@@ -19781,9 +19519,9 @@ async function applyPolicyArm(writer, change, authority, recordId, record) {
19781
19519
  kind: "Supersede",
19782
19520
  origin: "user",
19783
19521
  scope,
19784
- citedIds: [(0, import_agent_qa_schema67.asRecordId)(recordId)],
19785
- victimId: (0, import_agent_qa_schema67.asRecordId)(recordId),
19786
- evidenceToken: (0, import_agent_qa_schema67.asEvidenceToken)(`policy-materialize:${change.id}`),
19522
+ citedIds: [(0, import_agent_qa_schema66.asRecordId)(recordId)],
19523
+ victimId: (0, import_agent_qa_schema66.asRecordId)(recordId),
19524
+ evidenceToken: (0, import_agent_qa_schema66.asEvidenceToken)(`policy-materialize:${change.id}`),
19787
19525
  newBundle: {
19788
19526
  kind: "policy",
19789
19527
  summary: bundle.body.split("\n")[0] ?? bundle.summary,
@@ -19807,8 +19545,8 @@ async function applyPolicyArm(writer, change, authority, recordId, record) {
19807
19545
  throw new ReviewTargetVanishedError(change.id);
19808
19546
  }
19809
19547
  const committedAtOrdinal = currentOrdinal(writer.knowledgeRoot);
19810
- const receipt = (0, import_agent_qa_schema67.stampReceiptDigest)({
19811
- schemaVersion: import_agent_qa_schema67.GATE_RECEIPT_SCHEMA_VERSION,
19548
+ const receipt = (0, import_agent_qa_schema66.stampReceiptDigest)({
19549
+ schemaVersion: import_agent_qa_schema66.GATE_RECEIPT_SCHEMA_VERSION,
19812
19550
  gate: 3,
19813
19551
  candidateId: recordId,
19814
19552
  verdict: "pass",
@@ -19818,7 +19556,7 @@ async function applyPolicyArm(writer, change, authority, recordId, record) {
19818
19556
  });
19819
19557
  await store.recordGateReceipt(receipt);
19820
19558
  const commitReceipt = {
19821
- schemaVersion: import_agent_qa_schema67.COMMIT_RECEIPT_SCHEMA_VERSION,
19559
+ schemaVersion: import_agent_qa_schema66.COMMIT_RECEIPT_SCHEMA_VERSION,
19822
19560
  proposalId: change.id,
19823
19561
  committedAtOrdinal,
19824
19562
  recordIds: [recordId],
@@ -19844,10 +19582,10 @@ async function recoverPolicyArm(writer, change, authority, recordId) {
19844
19582
  const replacement = locateRecord(writer.knowledgeRoot, event.byRecordId);
19845
19583
  const scope = victim.bundle.frontmatter.scope;
19846
19584
  const shelfScope = scope.tier === "global" ? "global" : scope.key;
19847
- const relPath = (0, import_node_path45.relative)(writer.knowledgeRoot, policyShelfPath(writer.knowledgeRoot, shelfScope));
19848
- if (replacement?.bundle.frontmatter.kind !== "policy" || memoryStatusForBundle(replacement.status) === "tombstoned" || replacement.bundle.body !== `${relPath}#agent-qa:policy ${recordId}` || (0, import_agent_qa_schema67.canonicalJson)(replacement.bundle.frontmatter.scope) !== (0, import_agent_qa_schema67.canonicalJson)(scope) || replacement.bundle.manifest.createdAtOrdinal !== event.buildOrdinal || !replacement.bundle.events.some((row) => row.type === "confirmed" && row.evidenceToken === token && row.buildOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !replacement.bundle.relations.relations.some((row) => row.type === "supersedes" && row.targetId === recordId && row.addedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !victim.bundle.events.some((row) => row.type === "window-close" && row.closedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !change.deltas.every((delta) => delta.kind === "Confirm" && delta.targetId === recordId && victim.bundle.events.some((row) => row.type === "confirmed" && row.evidenceToken === delta.evidenceToken && row.buildOrdinal === event.buildOrdinal))) throw new ReviewTargetVanishedError(change.id);
19849
- const receipt = (0, import_agent_qa_schema67.stampReceiptDigest)({
19850
- schemaVersion: import_agent_qa_schema67.GATE_RECEIPT_SCHEMA_VERSION,
19585
+ const relPath = (0, import_node_path44.relative)(writer.knowledgeRoot, policyShelfPath(writer.knowledgeRoot, shelfScope));
19586
+ if (replacement?.bundle.frontmatter.kind !== "policy" || memoryStatusForBundle(replacement.status) === "tombstoned" || replacement.bundle.body !== `${relPath}#agent-qa:policy ${recordId}` || (0, import_agent_qa_schema66.canonicalJson)(replacement.bundle.frontmatter.scope) !== (0, import_agent_qa_schema66.canonicalJson)(scope) || replacement.bundle.manifest.createdAtOrdinal !== event.buildOrdinal || !replacement.bundle.events.some((row) => row.type === "confirmed" && row.evidenceToken === token && row.buildOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !replacement.bundle.relations.relations.some((row) => row.type === "supersedes" && row.targetId === recordId && row.addedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !victim.bundle.events.some((row) => row.type === "window-close" && row.closedAtOrdinal === event.buildOrdinal && row.curationJobId === event.curationJobId) || !change.deltas.every((delta) => delta.kind === "Confirm" && delta.targetId === recordId && victim.bundle.events.some((row) => row.type === "confirmed" && row.evidenceToken === delta.evidenceToken && row.buildOrdinal === event.buildOrdinal))) throw new ReviewTargetVanishedError(change.id);
19587
+ const receipt = (0, import_agent_qa_schema66.stampReceiptDigest)({
19588
+ schemaVersion: import_agent_qa_schema66.GATE_RECEIPT_SCHEMA_VERSION,
19851
19589
  gate: 3,
19852
19590
  candidateId: recordId,
19853
19591
  verdict: "pass",
@@ -19856,11 +19594,11 @@ async function recoverPolicyArm(writer, change, authority, recordId) {
19856
19594
  policyApproval: { proposalId: change.id, recordId }
19857
19595
  });
19858
19596
  const gates = readGateReceipts(victim.dir, recordId);
19859
- if (gates === void 0 && (0, import_node_fs42.existsSync)((0, import_node_path45.join)(victim.dir, "evidence/gates.jsonl"))) {
19597
+ if (gates === void 0 && (0, import_node_fs42.existsSync)((0, import_node_path44.join)(victim.dir, "evidence/gates.jsonl"))) {
19860
19598
  throw new Error("Policy approval evidence is unreadable");
19861
19599
  }
19862
19600
  const prior = (gates ?? []).filter((row) => "gate" in row && row.gate === 3 && row.policyApproval?.proposalId === change.id);
19863
- if (prior.length > 1 || prior.length === 1 && (0, import_agent_qa_schema67.canonicalJson)(prior[0]) !== (0, import_agent_qa_schema67.canonicalJson)(receipt)) {
19601
+ if (prior.length > 1 || prior.length === 1 && (0, import_agent_qa_schema66.canonicalJson)(prior[0]) !== (0, import_agent_qa_schema66.canonicalJson)(receipt)) {
19864
19602
  throw new Error("Policy approval evidence does not match the committed supersession");
19865
19603
  }
19866
19604
  return { victim, shelfScope, relPath, receipt, hasReceipt: prior.length === 1 };
@@ -19877,7 +19615,7 @@ async function recoverPolicyArm(writer, change, authority, recordId) {
19877
19615
  if (materialized.kind !== "unchanged") throw new Error("Committed policy section is unavailable");
19878
19616
  if (!committed.hasReceipt) await reviewStore(writer, change, authority).recordGateReceipt(committed.receipt);
19879
19617
  const commitReceipt = {
19880
- schemaVersion: import_agent_qa_schema67.COMMIT_RECEIPT_SCHEMA_VERSION,
19618
+ schemaVersion: import_agent_qa_schema66.COMMIT_RECEIPT_SCHEMA_VERSION,
19881
19619
  proposalId: change.id,
19882
19620
  committedAtOrdinal: committed.receipt.producedAtOrdinal,
19883
19621
  recordIds: [recordId],
@@ -19903,7 +19641,7 @@ async function writeReviewChange(writer, change, authority) {
19903
19641
  if (change.verb !== "forget") return { kind: "applied", recordIds: recordIds2 };
19904
19642
  const recorded = readRecordedForgetReceipt(writer.knowledgeRoot, change.id);
19905
19643
  const recordedIds = recorded?.tombstonedRecords.map((row) => row.recordId);
19906
- if (recorded !== void 0 && (0, import_agent_qa_schema67.canonicalJson)(recordedIds) === (0, import_agent_qa_schema67.canonicalJson)(recordIds2)) {
19644
+ if (recorded !== void 0 && (0, import_agent_qa_schema66.canonicalJson)(recordedIds) === (0, import_agent_qa_schema66.canonicalJson)(recordIds2)) {
19907
19645
  return { kind: "applied", recordIds: recordIds2, forgetReceipt: recorded };
19908
19646
  }
19909
19647
  const scrubbed = tombstonedByThisForget(writer.knowledgeRoot, change) ? FORGET_SCRUBBED_PROJECTIONS : [];
@@ -19957,19 +19695,19 @@ async function withBoundedWait(changeId, delegateTimeoutMs, call) {
19957
19695
  function validatedRequest(request2) {
19958
19696
  switch (request2.verb) {
19959
19697
  case "accept":
19960
- return { verb: "accept", input: import_agent_qa_schema67.KnowledgeAcceptInputSchema.parse(request2.input) };
19698
+ return { verb: "accept", input: import_agent_qa_schema66.KnowledgeAcceptInputSchema.parse(request2.input) };
19961
19699
  case "reject":
19962
- return { verb: "reject", input: import_agent_qa_schema67.KnowledgeRejectInputSchema.parse(request2.input) };
19700
+ return { verb: "reject", input: import_agent_qa_schema66.KnowledgeRejectInputSchema.parse(request2.input) };
19963
19701
  case "forget":
19964
- return { verb: "forget", input: import_agent_qa_schema67.KnowledgeForgetInputSchema.parse(request2.input) };
19702
+ return { verb: "forget", input: import_agent_qa_schema66.KnowledgeForgetInputSchema.parse(request2.input) };
19965
19703
  case "mark":
19966
- return { verb: "mark", input: import_agent_qa_schema67.KnowledgeMarkInputSchema.parse(request2.input) };
19704
+ return { verb: "mark", input: import_agent_qa_schema66.KnowledgeMarkInputSchema.parse(request2.input) };
19967
19705
  default:
19968
19706
  throw new TypeError("an explicit knowledge change names accept, reject, forget or mark");
19969
19707
  }
19970
19708
  }
19971
19709
  function explicitChangeId(operationId) {
19972
- const parsed = typeof operationId === "string" ? import_agent_qa_schema67.KnowledgeChangeIdSchema.safeParse(`prop_${operationId.toLowerCase()}`) : void 0;
19710
+ const parsed = typeof operationId === "string" ? import_agent_qa_schema66.KnowledgeChangeIdSchema.safeParse(`prop_${operationId.toLowerCase()}`) : void 0;
19973
19711
  if (parsed?.success !== true) {
19974
19712
  throw new TypeError(
19975
19713
  "operationId must be a stable identity of letters, digits and single hyphens, such as a UUID"
@@ -20007,13 +19745,10 @@ async function applyExplicitReview(input) {
20007
19745
  if (typeof input.opId !== "string" || input.opId.length === 0) {
20008
19746
  throw new TypeError("applyExplicitReview needs the op id that makes the change");
20009
19747
  }
20010
- const priors = snapshotTrustPriors(input.resolveTrustPriors?.());
20011
19748
  const writer = {
20012
19749
  knowledgeRoot: input.knowledgeRoot,
20013
19750
  executionContext: input.executionContext,
20014
19751
  opId: input.opId,
20015
- ...input.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: input.resolvePromotionPosture },
20016
- ...input.resolveTrustPriors === void 0 ? {} : { resolveTrustPriors: () => priors },
20017
19752
  ...input.now === void 0 ? {} : { now: input.now }
20018
19753
  };
20019
19754
  if (input.writerAuthority !== void 0) {
@@ -20045,8 +19780,8 @@ async function applyExplicitReview(input) {
20045
19780
 
20046
19781
  // src/authoring/draft-receipts-store.ts
20047
19782
  var import_node_fs43 = require("node:fs");
20048
- var import_node_path46 = require("node:path");
20049
- var import_agent_qa_schema68 = require("@vostride/agent-qa-schema");
19783
+ var import_node_path45 = require("node:path");
19784
+ var import_agent_qa_schema67 = require("@vostride/agent-qa-schema");
20050
19785
  var DRAFT_RECEIPTS_DIR_NAME = "draft-receipts";
20051
19786
  var RECEIPT_SUFFIX = ".json";
20052
19787
  var TEMP_SUFFIX = ".tmp";
@@ -20063,7 +19798,7 @@ var DraftReceiptDigestError = class extends Error {
20063
19798
  var DraftReceiptSchemaVersionError = class extends Error {
20064
19799
  constructor(path, foundVersion) {
20065
19800
  super(
20066
- `Draft receipt at ${path} declares schemaVersion ${String(foundVersion)}, but this build reads version ${import_agent_qa_schema68.CURRENT_DRAFT_RECEIPT_SCHEMA_VERSION}`
19801
+ `Draft receipt at ${path} declares schemaVersion ${String(foundVersion)}, but this build reads version ${import_agent_qa_schema67.CURRENT_DRAFT_RECEIPT_SCHEMA_VERSION}`
20067
19802
  );
20068
19803
  this.path = path;
20069
19804
  this.foundVersion = foundVersion;
@@ -20071,11 +19806,11 @@ var DraftReceiptSchemaVersionError = class extends Error {
20071
19806
  }
20072
19807
  };
20073
19808
  function draftReceiptsDir(agentQaRoot) {
20074
- return (0, import_node_path46.join)(agentQaRoot, DRAFT_RECEIPTS_DIR_NAME);
19809
+ return (0, import_node_path45.join)(agentQaRoot, DRAFT_RECEIPTS_DIR_NAME);
20075
19810
  }
20076
19811
  function receiptPath(agentQaRoot, contentDigest) {
20077
19812
  if (!SAFE_DIGEST.test(contentDigest)) throw new DraftReceiptDigestError(contentDigest);
20078
- return (0, import_node_path46.join)(draftReceiptsDir(agentQaRoot), `${contentDigest}${RECEIPT_SUFFIX}`);
19813
+ return (0, import_node_path45.join)(draftReceiptsDir(agentQaRoot), `${contentDigest}${RECEIPT_SUFFIX}`);
20079
19814
  }
20080
19815
  function writeFileAtomically(path, contents) {
20081
19816
  const temp = `${path}.${process.pid}${TEMP_SUFFIX}`;
@@ -20085,10 +19820,10 @@ function writeFileAtomically(path, contents) {
20085
19820
  }
20086
19821
  function parseReceipt2(path, raw) {
20087
19822
  const version = raw?.schemaVersion;
20088
- if (version !== import_agent_qa_schema68.CURRENT_DRAFT_RECEIPT_SCHEMA_VERSION) {
19823
+ if (version !== import_agent_qa_schema67.CURRENT_DRAFT_RECEIPT_SCHEMA_VERSION) {
20089
19824
  throw new DraftReceiptSchemaVersionError(path, version);
20090
19825
  }
20091
- return import_agent_qa_schema68.DraftReceiptSchema.parse(raw);
19826
+ return import_agent_qa_schema67.DraftReceiptSchema.parse(raw);
20092
19827
  }
20093
19828
  function readReceiptIfPresent(path) {
20094
19829
  let bytes;
@@ -20107,7 +19842,7 @@ function createDraftReceiptsStore(options) {
20107
19842
  return {
20108
19843
  async put(receipt) {
20109
19844
  const agentQaRoot = await root();
20110
- const validated = import_agent_qa_schema68.DraftReceiptSchema.parse(receipt);
19845
+ const validated = import_agent_qa_schema67.DraftReceiptSchema.parse(receipt);
20111
19846
  const path = receiptPath(agentQaRoot, validated.draftRef.contentDigest);
20112
19847
  const directory = draftReceiptsDir(agentQaRoot);
20113
19848
  (0, import_node_fs43.mkdirSync)(directory, { recursive: true });
@@ -20130,7 +19865,7 @@ function createDraftReceiptsStore(options) {
20130
19865
  const receipts = [];
20131
19866
  for (const name of [...names].sort()) {
20132
19867
  if (name.endsWith(TEMP_SUFFIX) || !name.endsWith(RECEIPT_SUFFIX)) continue;
20133
- const receipt = readReceiptIfPresent((0, import_node_path46.join)(directory, name));
19868
+ const receipt = readReceiptIfPresent((0, import_node_path45.join)(directory, name));
20134
19869
  if (receipt !== void 0) receipts.push(receipt);
20135
19870
  }
20136
19871
  return receipts;
@@ -20139,8 +19874,8 @@ function createDraftReceiptsStore(options) {
20139
19874
  }
20140
19875
 
20141
19876
  // src/rollback.ts
20142
- var import_node_path47 = require("node:path");
20143
- var import_agent_qa_schema69 = require("@vostride/agent-qa-schema");
19877
+ var import_node_path46 = require("node:path");
19878
+ var import_agent_qa_schema68 = require("@vostride/agent-qa-schema");
20144
19879
  var RollbackCausalityError = class extends Error {
20145
19880
  offendingRecordIds;
20146
19881
  minimumRequiredOrdinal;
@@ -20179,7 +19914,7 @@ function assertOrdinal(value, label) {
20179
19914
  }
20180
19915
  }
20181
19916
  function assertBaseInput(input) {
20182
- if (!(0, import_node_path47.isAbsolute)(input.knowledgeRoot)) {
19917
+ if (!(0, import_node_path46.isAbsolute)(input.knowledgeRoot)) {
20183
19918
  throw new TypeError("rollback knowledgeRoot must be absolute");
20184
19919
  }
20185
19920
  if (input.writerAuthority !== void 0 && input.writerAuthority.knowledgeRoot !== input.knowledgeRoot) {
@@ -20221,7 +19956,7 @@ function campaignKeys(input) {
20221
19956
  };
20222
19957
  }
20223
19958
  function rollbackReceiptId(kind, keys, effectKeys = []) {
20224
- return `rollback:${(0, import_agent_qa_schema69.sha256hex)((0, import_agent_qa_schema69.canonicalJson)({
19959
+ return `rollback:${(0, import_agent_qa_schema68.sha256hex)((0, import_agent_qa_schema68.canonicalJson)({
20225
19960
  kind,
20226
19961
  keys,
20227
19962
  effectKeys: [...effectKeys].sort(compareText11)
@@ -20233,7 +19968,7 @@ function canonicalBundles2(knowledgeRoot) {
20233
19968
  const loaded = loadBundle(entry.dir);
20234
19969
  if (loaded.kind !== "loaded") continue;
20235
19970
  bundles.push({
20236
- recordId: (0, import_agent_qa_schema69.asRecordId)(loaded.bundle.manifest.id),
19971
+ recordId: (0, import_agent_qa_schema68.asRecordId)(loaded.bundle.manifest.id),
20237
19972
  product: entry.product,
20238
19973
  dir: entry.dir,
20239
19974
  bundle: loaded.bundle
@@ -20248,7 +19983,7 @@ function publicAffectedSet(resolution) {
20248
19983
  return resolution.affected;
20249
19984
  }
20250
19985
  function rollbackAffectedSetFingerprint(affected) {
20251
- return (0, import_agent_qa_schema69.canonicalJson)(affected);
19986
+ return (0, import_agent_qa_schema68.canonicalJson)(affected);
20252
19987
  }
20253
19988
  function resolveRollbackAffectedSet(input) {
20254
19989
  return publicAffectedSet(
@@ -20280,25 +20015,25 @@ function bundleTargetKey(product, recordId) {
20280
20015
  return `${product}\0${recordId}`;
20281
20016
  }
20282
20017
  function eventEffectKey(kind, product, recordId, event) {
20283
- return (0, import_agent_qa_schema69.canonicalJson)({
20018
+ return (0, import_agent_qa_schema68.canonicalJson)({
20284
20019
  kind,
20285
20020
  product,
20286
20021
  recordId,
20287
- ...event === void 0 ? {} : { eventKey: (0, import_agent_qa_schema69.eventDedupKey)(event) }
20022
+ ...event === void 0 ? {} : { eventKey: (0, import_agent_qa_schema68.eventDedupKey)(event) }
20288
20023
  });
20289
20024
  }
20290
20025
  function eventSurvivalKeys(bundle) {
20291
- return new Set((0, import_agent_qa_schema69.survivingOutcomeEvents)(bundle.events).map(import_agent_qa_schema69.eventDedupKey));
20026
+ return new Set((0, import_agent_qa_schema68.survivingOutcomeEvents)(bundle.events).map(import_agent_qa_schema68.eventDedupKey));
20292
20027
  }
20293
20028
  function hasExactRetraction(bundle, receiptId, targetRecordId, target) {
20294
- const targetKey = (0, import_agent_qa_schema69.eventDedupKey)(target);
20029
+ const targetKey = (0, import_agent_qa_schema68.eventDedupKey)(target);
20295
20030
  const token = inverseEvidenceToken(receiptId, targetRecordId, targetKey);
20296
20031
  return bundle.events.some(
20297
20032
  (event) => event.type === "retracted" && event.evidenceToken === token && event.curationJobId === receiptId && event.retractsEvidenceToken === target.evidenceToken && event.retractsCurationJobId === target.curationJobId
20298
20033
  );
20299
20034
  }
20300
20035
  function windowCloseFor(bundle, superseded) {
20301
- const closeToken = (0, import_agent_qa_schema69.asEvidenceToken)((0, import_agent_qa_schema69.sha256hex)((0, import_agent_qa_schema69.canonicalJson)({
20036
+ const closeToken = (0, import_agent_qa_schema68.asEvidenceToken)((0, import_agent_qa_schema68.sha256hex)((0, import_agent_qa_schema68.canonicalJson)({
20302
20037
  token: superseded.evidenceToken,
20303
20038
  event: "window-close"
20304
20039
  })));
@@ -20315,13 +20050,13 @@ function windowCloseFor(bundle, superseded) {
20315
20050
  function promotionCascadeUniverse(bundles, counters) {
20316
20051
  const selectedConfirmations = /* @__PURE__ */ new Map();
20317
20052
  const directlySelectedEvents = new Set(counters.map(
20318
- ({ product, recordId, event }) => `${bundleTargetKey(product, recordId)}\0${(0, import_agent_qa_schema69.eventDedupKey)(event)}`
20053
+ ({ product, recordId, event }) => `${bundleTargetKey(product, recordId)}\0${(0, import_agent_qa_schema68.eventDedupKey)(event)}`
20319
20054
  ));
20320
20055
  for (const counter of counters) {
20321
20056
  if (counter.type !== "confirmed") continue;
20322
20057
  const key = bundleTargetKey(counter.product, counter.recordId);
20323
20058
  const selected = selectedConfirmations.get(key) ?? /* @__PURE__ */ new Set();
20324
- selected.add((0, import_agent_qa_schema69.eventDedupKey)(counter.event));
20059
+ selected.add((0, import_agent_qa_schema68.eventDedupKey)(counter.event));
20325
20060
  selectedConfirmations.set(key, selected);
20326
20061
  }
20327
20062
  const cascades = [];
@@ -20330,14 +20065,14 @@ function promotionCascadeUniverse(bundles, counters) {
20330
20065
  bundleTargetKey(bundle.product, bundle.recordId)
20331
20066
  );
20332
20067
  if (selected === void 0) continue;
20333
- const surviving = (0, import_agent_qa_schema69.survivingOutcomeEvents)(bundle.bundle.events);
20068
+ const surviving = (0, import_agent_qa_schema68.survivingOutcomeEvents)(bundle.bundle.events);
20334
20069
  if (surviving.some(
20335
- (event) => event.type === "confirmed" && !selected.has((0, import_agent_qa_schema69.eventDedupKey)(event))
20070
+ (event) => event.type === "confirmed" && !selected.has((0, import_agent_qa_schema68.eventDedupKey)(event))
20336
20071
  )) continue;
20337
20072
  for (const event of bundle.bundle.events) {
20338
20073
  const selectedEventKey = [
20339
20074
  bundleTargetKey(bundle.product, bundle.recordId),
20340
- (0, import_agent_qa_schema69.eventDedupKey)(event)
20075
+ (0, import_agent_qa_schema68.eventDedupKey)(event)
20341
20076
  ].join("\0");
20342
20077
  if (event.type !== "promoted" || directlySelectedEvents.has(selectedEventKey)) continue;
20343
20078
  cascades.push({
@@ -20349,7 +20084,7 @@ function promotionCascadeUniverse(bundles, counters) {
20349
20084
  }
20350
20085
  }
20351
20086
  return cascades.sort(
20352
- (left, right) => compareText11(left.product, right.product) || compareText11(left.recordId, right.recordId) || compareText11((0, import_agent_qa_schema69.eventDedupKey)(left.event), (0, import_agent_qa_schema69.eventDedupKey)(right.event))
20087
+ (left, right) => compareText11(left.product, right.product) || compareText11(left.recordId, right.recordId) || compareText11((0, import_agent_qa_schema68.eventDedupKey)(left.event), (0, import_agent_qa_schema68.eventDedupKey)(right.event))
20353
20088
  );
20354
20089
  }
20355
20090
  function buildResolution(input) {
@@ -20400,7 +20135,7 @@ function buildResolution(input) {
20400
20135
  const pending = (effect) => {
20401
20136
  const bundle = byTarget.get(bundleTargetKey(effect.product, effect.recordId));
20402
20137
  const surviving = survivingByTarget.get(bundleTargetKey(effect.product, effect.recordId));
20403
- return bundle !== void 0 && surviving?.has((0, import_agent_qa_schema69.eventDedupKey)(effect.event)) === true && !hasExactRetraction(bundle.bundle, receiptId, effect.recordId, effect.event);
20138
+ return bundle !== void 0 && surviving?.has((0, import_agent_qa_schema68.eventDedupKey)(effect.event)) === true && !hasExactRetraction(bundle.bundle, receiptId, effect.recordId, effect.event);
20404
20139
  };
20405
20140
  const counterEvents = input.counterUniverse.filter(pending);
20406
20141
  const windowCloseEvents = windowCloseUniverse.filter(pending);
@@ -20415,7 +20150,7 @@ function buildResolution(input) {
20415
20150
  kind: "retract-counter",
20416
20151
  product: effect.product,
20417
20152
  recordId: effect.recordId,
20418
- eventKey: (0, import_agent_qa_schema69.eventDedupKey)(effect.event),
20153
+ eventKey: (0, import_agent_qa_schema68.eventDedupKey)(effect.event),
20419
20154
  evidenceToken: effect.evidenceToken,
20420
20155
  curationJobId: effect.curationJobId
20421
20156
  })),
@@ -20423,7 +20158,7 @@ function buildResolution(input) {
20423
20158
  kind: effect.effectKind,
20424
20159
  product: effect.product,
20425
20160
  recordId: effect.recordId,
20426
- eventKey: (0, import_agent_qa_schema69.eventDedupKey)(effect.event),
20161
+ eventKey: (0, import_agent_qa_schema68.eventDedupKey)(effect.event),
20427
20162
  evidenceToken: effect.event.evidenceToken,
20428
20163
  curationJobId: effect.event.curationJobId
20429
20164
  })),
@@ -20431,11 +20166,11 @@ function buildResolution(input) {
20431
20166
  kind: effect.effectKind,
20432
20167
  product: effect.product,
20433
20168
  recordId: effect.recordId,
20434
- eventKey: (0, import_agent_qa_schema69.eventDedupKey)(effect.event),
20169
+ eventKey: (0, import_agent_qa_schema68.eventDedupKey)(effect.event),
20435
20170
  evidenceToken: effect.event.evidenceToken,
20436
20171
  curationJobId: effect.event.curationJobId
20437
20172
  }))
20438
- ].sort((left, right) => compareText11((0, import_agent_qa_schema69.canonicalJson)(left), (0, import_agent_qa_schema69.canonicalJson)(right)));
20173
+ ].sort((left, right) => compareText11((0, import_agent_qa_schema68.canonicalJson)(left), (0, import_agent_qa_schema68.canonicalJson)(right)));
20439
20174
  const projectionTargetMap = /* @__PURE__ */ new Map();
20440
20175
  const includeProjection = (product, recordId) => {
20441
20176
  projectionTargetMap.set(bundleTargetKey(product, recordId), { product, recordId });
@@ -20512,7 +20247,7 @@ function ordinalMatches(ordinal, input) {
20512
20247
  return (input.fromOrdinal === void 0 || ordinal >= input.fromOrdinal) && (input.toOrdinal === void 0 || ordinal <= input.toOrdinal);
20513
20248
  }
20514
20249
  function bundleAxesMatch(bundle, input) {
20515
- return (input.anchorClusterKey === void 0 || (0, import_agent_qa_schema69.supersessionKey)(bundle.bundle.frontmatter.anchors.map(({ normalized }) => normalized)) === input.anchorClusterKey) && (input.originClass === void 0 || bundle.bundle.frontmatter.originClass === input.originClass);
20250
+ return (input.anchorClusterKey === void 0 || (0, import_agent_qa_schema68.supersessionKey)(bundle.bundle.frontmatter.anchors.map(({ normalized }) => normalized)) === input.anchorClusterKey) && (input.originClass === void 0 || bundle.bundle.frontmatter.originClass === input.originClass);
20516
20251
  }
20517
20252
  function resolveCampaign(input) {
20518
20253
  assertBaseInput(input);
@@ -20540,12 +20275,11 @@ function bundleConfig(input, productKey) {
20540
20275
  return {
20541
20276
  knowledgeRoot: input.knowledgeRoot,
20542
20277
  productKey,
20543
- commitArtifacts: "none",
20544
20278
  ...input.writerAuthority === void 0 ? {} : { writerLeaseId: input.writerAuthority.leaseId }
20545
20279
  };
20546
20280
  }
20547
20281
  function inverseEvidenceToken(receiptId, targetRecordId, retractedKey) {
20548
- return (0, import_agent_qa_schema69.asEvidenceToken)((0, import_agent_qa_schema69.sha256hex)((0, import_agent_qa_schema69.canonicalJson)({
20282
+ return (0, import_agent_qa_schema68.asEvidenceToken)((0, import_agent_qa_schema68.sha256hex)((0, import_agent_qa_schema68.canonicalJson)({
20549
20283
  rollbackReceiptId: receiptId,
20550
20284
  targetRecordId,
20551
20285
  retractedKey
@@ -20627,7 +20361,7 @@ function appendInverseDeprecate(input, resolution, target) {
20627
20361
  );
20628
20362
  }
20629
20363
  function appendRetraction(input, resolution, target) {
20630
- const retractedKey = (0, import_agent_qa_schema69.eventDedupKey)(target.event);
20364
+ const retractedKey = (0, import_agent_qa_schema68.eventDedupKey)(target.event);
20631
20365
  return appendRollbackEvent(
20632
20366
  input,
20633
20367
  target.product,
@@ -20648,13 +20382,13 @@ function appendRetraction(input, resolution, target) {
20648
20382
  );
20649
20383
  }
20650
20384
  function latestSurvivingLifecycleOrdinal(bundle) {
20651
- let latest2 = bundle.manifest.createdAtOrdinal;
20652
- for (const event of (0, import_agent_qa_schema69.survivingOutcomeEvents)(bundle.events)) {
20653
- if ((event.type === "promoted" || event.type === "superseded" || event.type === "deprecated") && event.buildOrdinal > latest2) {
20654
- latest2 = event.buildOrdinal;
20385
+ let latest = bundle.manifest.createdAtOrdinal;
20386
+ for (const event of (0, import_agent_qa_schema68.survivingOutcomeEvents)(bundle.events)) {
20387
+ if ((event.type === "promoted" || event.type === "superseded" || event.type === "deprecated") && event.buildOrdinal > latest) {
20388
+ latest = event.buildOrdinal;
20655
20389
  }
20656
20390
  }
20657
- return latest2;
20391
+ return latest;
20658
20392
  }
20659
20393
  function assertCausalResolution(input, resolution) {
20660
20394
  const offenders = [];
@@ -20757,66 +20491,8 @@ function rollbackCampaign(input) {
20757
20491
  return emitRollback(input, resolveCampaign(input), () => resolveCampaign(input));
20758
20492
  }
20759
20493
 
20760
- // src/gates/canary-posture-facts.ts
20761
- var import_agent_qa_schema70 = require("@vostride/agent-qa-schema");
20762
- function readBundles(knowledgeRoot, resolveTrustPriors) {
20763
- return enumerateMaintenanceBundleDirs(knowledgeRoot).map((entry) => {
20764
- const bundle = loadMaintenanceBundle(entry);
20765
- const lines = readGateReceipts(entry.dir, bundle.manifest.id) ?? [];
20766
- return { ...entry, bundle, lines, active: deriveBundleTrust(bundle, resolveTrustPriors?.()).status === "active" };
20767
- });
20768
- }
20769
- function latest(ordinals) {
20770
- return ordinals.length === 0 ? void 0 : Math.max(...ordinals);
20771
- }
20772
- function canaryPostureFactsFor(input) {
20773
- const id = (0, import_agent_qa_schema70.asRecordId)(input.candidateId);
20774
- const rows = readBundles(input.knowledgeRoot, input.resolveTrustPriors);
20775
- const candidate2 = rows.find((row) => row.bundle.manifest.id === id);
20776
- if (candidate2 === void 0) return { kind: "not-found" };
20777
- const scope = candidate2.bundle.frontmatter.scope;
20778
- if (scope.tier !== "product" || input.scope.tier !== "product" || scope.key !== input.scope.key) return { kind: "not-found" };
20779
- const receipts = candidate2.lines.filter((line) => !(0, import_agent_qa_schema70.isPromotionReceipt)(line));
20780
- const pass = (0, import_agent_qa_schema70.standingReceiptsByGate)(receipts).find((row) => row.gate === 1 && row.verdict === "pass");
20781
- const lowerTrustActiveGate1Digest = candidate2.active && (0, import_agent_qa_schema70.strongestPromotionPath)(candidate2.lines) === "gate1-lower-trust" && (0, import_agent_qa_schema70.survivingOutcomeEvents)(candidate2.bundle.events).some((event) => event.type === "promoted") && pass !== void 0 && candidate2.lines.some((line) => (0, import_agent_qa_schema70.isPromotionReceipt)(line) && line.promotionPath === "gate1-lower-trust" && line.citedReceiptDigests.includes(pass.receiptDigest)) ? pass.receiptDigest : void 0;
20782
- const latestAttributionOrdinal = latest((0, import_agent_qa_schema70.survivingOutcomeEvents)(candidate2.bundle.events).filter((event) => ["confirmed", "contradicted", "helpful", "harmful"].includes(event.type)).map((event) => event.buildOrdinal));
20783
- const latestGate2Ordinal = latest(receipts.filter((row) => row.gate === 2).map((row) => row.producedAtOrdinal));
20784
- const active = rows.filter((row) => row.active && row.product === candidate2.product && row.bundle.frontmatter.scope.tier === "product" && row.bundle.frontmatter.scope.key === scope.key);
20785
- return {
20786
- kind: "found",
20787
- ...pass === void 0 ? {} : { gate1PassOrdinal: pass.producedAtOrdinal, gate1PassDigest: pass.receiptDigest },
20788
- ...lowerTrustActiveGate1Digest === void 0 ? {} : { lowerTrustActiveGate1Digest },
20789
- ...latestAttributionOrdinal === void 0 ? {} : { latestAttributionOrdinal },
20790
- ...latestGate2Ordinal === void 0 ? {} : { latestGate2Ordinal },
20791
- activeInScope: active.length,
20792
- lowerTrustActiveInScope: active.filter((row) => (0, import_agent_qa_schema70.strongestPromotionPath)(row.lines) === "gate1-lower-trust").length
20793
- };
20794
- }
20795
- function standingReceiptDigestsFor(input) {
20796
- return readBundles(input.knowledgeRoot).flatMap((row) => (0, import_agent_qa_schema70.standingReceiptsByGate)(
20797
- row.lines.filter((line) => !(0, import_agent_qa_schema70.isPromotionReceipt)(line))
20798
- ).map((receipt) => ({
20799
- candidateId: receipt.candidateId,
20800
- gate: receipt.gate,
20801
- verdict: receipt.verdict,
20802
- ..."corpusVersion" in receipt ? { corpusDigest: receipt.corpusVersion.corpusDigest } : {},
20803
- producedAtOrdinal: receipt.producedAtOrdinal
20804
- })));
20805
- }
20806
- function lowerTrustSharesFor(input) {
20807
- const products = /* @__PURE__ */ new Map();
20808
- for (const row of readBundles(input.knowledgeRoot, input.resolveTrustPriors)) {
20809
- const share = products.get(row.product) ?? { product: row.product, active: 0, lowerTrust: 0 };
20810
- products.set(row.product, share);
20811
- if (!row.active) continue;
20812
- share.active += 1;
20813
- if ((0, import_agent_qa_schema70.strongestPromotionPath)(row.lines) === "gate1-lower-trust") share.lowerTrust += 1;
20814
- }
20815
- return [...products.values()];
20816
- }
20817
-
20818
20494
  // src/feedback/apply-feedback.ts
20819
- var import_agent_qa_schema71 = require("@vostride/agent-qa-schema");
20495
+ var import_agent_qa_schema69 = require("@vostride/agent-qa-schema");
20820
20496
 
20821
20497
  // src/feedback/floor-prose.ts
20822
20498
  function bounded(text, limit) {
@@ -20853,7 +20529,7 @@ ${note}`
20853
20529
  // src/feedback/apply-feedback.ts
20854
20530
  function triageMark(member) {
20855
20531
  const root = member.rootCause;
20856
- const quarantine = import_agent_qa_schema71.MARK_QUARANTINE_CLASSES.find((value) => value === root?.class);
20532
+ const quarantine = import_agent_qa_schema69.MARK_QUARANTINE_CLASSES.find((value) => value === root?.class);
20857
20533
  if (quarantine !== void 0 && root !== void 0) {
20858
20534
  return { kind: "quarantined", class: quarantine, producer: root.producer };
20859
20535
  }
@@ -20868,7 +20544,7 @@ function procedureReadOn(member, stepIndex) {
20868
20544
  return member.steps.filter((step) => step.stepIndex <= stepIndex).flatMap((step) => step.servedBrief.channel2)[0]?.id;
20869
20545
  }
20870
20546
  function assertionDrift(member, step) {
20871
- return member.rootCause?.class === "test_bug" || step.verifierVerdict.pass === false && step.subActions.every((action) => (0, import_agent_qa_schema71.actionDidNotFail)(action.result));
20547
+ return member.rootCause?.class === "test_bug" || step.verifierVerdict.pass === false && step.subActions.every((action) => (0, import_agent_qa_schema69.actionDidNotFail)(action.result));
20872
20548
  }
20873
20549
  function selectFixKind(input) {
20874
20550
  if (input.kind === "confirmed-bug") throw new TypeError("confirmed-bug has no drafted fix");
@@ -20912,7 +20588,7 @@ function applyFeedback(input) {
20912
20588
  stepIndex: input.resolvedStepIndex
20913
20589
  });
20914
20590
  const base = {
20915
- schemaVersion: import_agent_qa_schema71.IMPROVEMENT_PLAN_SCHEMA_VERSION,
20591
+ schemaVersion: import_agent_qa_schema69.IMPROVEMENT_PLAN_SCHEMA_VERSION,
20916
20592
  markId: mark.markId,
20917
20593
  feedbackSource: {
20918
20594
  runId: mark.runId,
@@ -20924,19 +20600,19 @@ function applyFeedback(input) {
20924
20600
  runTraceRef: { runId: mark.runId, runSlug: mark.runSlug }
20925
20601
  };
20926
20602
  if (selection.fix === "none") {
20927
- return import_agent_qa_schema71.ImprovementPlanSchema.parse({ ...base, kind: "no-draftable-fix", checked: selection.checked });
20603
+ return import_agent_qa_schema69.ImprovementPlanSchema.parse({ ...base, kind: "no-draftable-fix", checked: selection.checked });
20928
20604
  }
20929
20605
  if (selection.fix === "test-edit") {
20930
20606
  const testRef = input.testRef || (member.filePath && member.testName ? `${member.filePath}::${member.testName}` : void 0);
20931
20607
  if (testRef === void 0) {
20932
- return import_agent_qa_schema71.ImprovementPlanSchema.parse({ ...base, kind: "no-draftable-fix", checked: {
20608
+ return import_agent_qa_schema69.ImprovementPlanSchema.parse({ ...base, kind: "no-draftable-fix", checked: {
20933
20609
  servedRecords: 0,
20934
20610
  procedureReads: 0,
20935
20611
  assertionDrift: true,
20936
20612
  ...member.rootCause === void 0 ? {} : { rootCause: member.rootCause.class }
20937
20613
  } });
20938
20614
  }
20939
- return import_agent_qa_schema71.ImprovementPlanSchema.parse({
20615
+ return import_agent_qa_schema69.ImprovementPlanSchema.parse({
20940
20616
  ...base,
20941
20617
  kind: "test-edit",
20942
20618
  fix: "test-edit",
@@ -20970,15 +20646,15 @@ function applyFeedback(input) {
20970
20646
  // OriginStage is closed to run-curation; user authorship lives on the delta envelope.
20971
20647
  originStage: target.originStage
20972
20648
  };
20973
- const envelope2 = { origin: "user", scope: target.scope, citedIds: [(0, import_agent_qa_schema71.asRecordId)(target.recordId)] };
20649
+ const envelope2 = { origin: "user", scope: target.scope, citedIds: [(0, import_agent_qa_schema69.asRecordId)(target.recordId)] };
20974
20650
  const delta = selection.fix === "fact" ? {
20975
20651
  ...envelope2,
20976
20652
  kind: "Supersede",
20977
- victimId: (0, import_agent_qa_schema71.asRecordId)(target.recordId),
20653
+ victimId: (0, import_agent_qa_schema69.asRecordId)(target.recordId),
20978
20654
  newBundle: bundle,
20979
- evidenceToken: (0, import_agent_qa_schema71.asEvidenceToken)(`mark:${mark.markId}`)
20655
+ evidenceToken: (0, import_agent_qa_schema69.asEvidenceToken)(`mark:${mark.markId}`)
20980
20656
  } : { ...envelope2, kind: "Add", bundle };
20981
- return import_agent_qa_schema71.ImprovementPlanSchema.parse({
20657
+ return import_agent_qa_schema69.ImprovementPlanSchema.parse({
20982
20658
  ...base,
20983
20659
  kind: "knowledge",
20984
20660
  fix: selection.fix,
@@ -20989,21 +20665,21 @@ function applyFeedback(input) {
20989
20665
  }
20990
20666
 
20991
20667
  // src/feedback/mark-evidence.ts
20992
- var import_agent_qa_schema73 = require("@vostride/agent-qa-schema");
20668
+ var import_agent_qa_schema71 = require("@vostride/agent-qa-schema");
20993
20669
 
20994
20670
  // src/feedback/mark-evidence-plan.ts
20995
- var import_node_path48 = require("node:path");
20996
- var import_agent_qa_schema72 = require("@vostride/agent-qa-schema");
20671
+ var import_node_path47 = require("node:path");
20672
+ var import_agent_qa_schema70 = require("@vostride/agent-qa-schema");
20997
20673
  var MARK_EVIDENCE_TOKEN_PREFIX = "mark:";
20998
20674
  function markEvidenceEvent(effect, markId, buildOrdinal) {
20999
20675
  const token = `${MARK_EVIDENCE_TOKEN_PREFIX}${markId}`;
21000
20676
  if (effect.direction === "confirm") {
21001
- return { type: "confirmed", evidenceToken: (0, import_agent_qa_schema72.asEvidenceToken)(token), curationJobId: token, buildOrdinal, origin: "user" };
20677
+ return { type: "confirmed", evidenceToken: (0, import_agent_qa_schema70.asEvidenceToken)(token), curationJobId: token, buildOrdinal, origin: "user" };
21002
20678
  }
21003
20679
  return {
21004
20680
  type: "overturned",
21005
20681
  markId,
21006
- evidenceToken: (0, import_agent_qa_schema72.asEvidenceToken)(
20682
+ evidenceToken: (0, import_agent_qa_schema70.asEvidenceToken)(
21007
20683
  `${token}:${effect.overturnsEvidenceToken}:${effect.overturnsCurationJobId}`
21008
20684
  ),
21009
20685
  curationJobId: token,
@@ -21021,7 +20697,7 @@ function planMarkEvidence(input) {
21021
20697
  ...input.mark.kind === "false-pass" && input.handoff === void 0 ? { correlationIncomplete: true } : {}
21022
20698
  };
21023
20699
  const served = new Set(input.servedRecordIds);
21024
- const targets = /* @__PURE__ */ new Set([...served, ...input.mark.kind === "false-pass" ? enumerateBundleDirs(input.knowledgeRoot).map((entry) => (0, import_node_path48.basename)(entry.dir)) : []]);
20700
+ const targets = /* @__PURE__ */ new Set([...served, ...input.mark.kind === "false-pass" ? enumerateBundleDirs(input.knowledgeRoot).map((entry) => (0, import_node_path47.basename)(entry.dir)) : []]);
21025
20701
  for (const recordId of targets) {
21026
20702
  let entry;
21027
20703
  try {
@@ -21043,7 +20719,7 @@ function planMarkEvidence(input) {
21043
20719
  for (const member of input.handoff?.tests ?? []) {
21044
20720
  for (const step of member.steps) {
21045
20721
  const canaryId = canaryOutcomeObservationId({
21046
- candidateId: (0, import_agent_qa_schema72.asRecordId)(recordId),
20722
+ candidateId: (0, import_agent_qa_schema70.asRecordId)(recordId),
21047
20723
  runId: input.mark.runId,
21048
20724
  testId: member.testId,
21049
20725
  testIndex: member.testIndex,
@@ -21051,8 +20727,8 @@ function planMarkEvidence(input) {
21051
20727
  });
21052
20728
  observations.add(canaryId);
21053
20729
  observations.add(`${input.mark.runId}:test-${member.testIndex}:step-${step.stepIndex}`);
21054
- for (const anchor of [...bundleAnchors, ...(0, import_agent_qa_schema72.exercisedAnchors)(step)]) {
21055
- evidenceTokens.add((0, import_agent_qa_schema72.deriveEvidenceToken)({
20730
+ for (const anchor of [...bundleAnchors, ...(0, import_agent_qa_schema70.exercisedAnchors)(step)]) {
20731
+ evidenceTokens.add((0, import_agent_qa_schema70.deriveEvidenceToken)({
21056
20732
  attributingObservationId: canaryId,
21057
20733
  anchor,
21058
20734
  buildOrdinal: input.handoff.buildOrdinal
@@ -21060,18 +20736,6 @@ function planMarkEvidence(input) {
21060
20736
  }
21061
20737
  }
21062
20738
  }
21063
- for (const receipt of readGateReceipts(entry.dir, (0, import_agent_qa_schema72.asRecordId)(recordId)) ?? []) {
21064
- if (!(0, import_agent_qa_schema72.isPromotionReceipt)(receipt) && receipt.gate === 2 && receipt.runId === input.mark.runId) {
21065
- observations.add(receipt.attributedObservationId);
21066
- for (const anchor of bundleAnchors) {
21067
- evidenceTokens.add((0, import_agent_qa_schema72.deriveEvidenceToken)({
21068
- attributingObservationId: receipt.attributedObservationId,
21069
- anchor,
21070
- buildOrdinal: receipt.producedAtOrdinal
21071
- }));
21072
- }
21073
- }
21074
- }
21075
20739
  const jobs = new Set(input.curationJobIds ?? []);
21076
20740
  const provenance = bundle.provenance;
21077
20741
  if (provenance.mode === "run-linked" && provenance.runId === input.mark.runId && provenance.curationJobId !== void 0) jobs.add(provenance.curationJobId);
@@ -21081,10 +20745,10 @@ function planMarkEvidence(input) {
21081
20745
  bundle.manifest.createdAtOrdinal,
21082
20746
  ...bundle.events.map((event) => event.buildOrdinal)
21083
20747
  ) + 1;
21084
- const seen = new Set(input.mark.markId === void 0 ? [] : bundle.events.map(import_agent_qa_schema72.eventDedupKey));
20748
+ const seen = new Set(input.mark.markId === void 0 ? [] : bundle.events.map(import_agent_qa_schema70.eventDedupKey));
21085
20749
  const effects = [];
21086
20750
  const add = (effect) => {
21087
- const key = (0, import_agent_qa_schema72.eventDedupKey)(markEvidenceEvent(effect, input.mark.markId ?? "", buildOrdinal));
20751
+ const key = (0, import_agent_qa_schema70.eventDedupKey)(markEvidenceEvent(effect, input.mark.markId ?? "", buildOrdinal));
21088
20752
  effects.push({ ...effect, alreadyAppended: seen.has(key) });
21089
20753
  seen.add(key);
21090
20754
  };
@@ -21161,7 +20825,6 @@ async function appendMarkEvidence(input) {
21161
20825
  const config = {
21162
20826
  knowledgeRoot: input.knowledgeRoot,
21163
20827
  productKey: target.productKey,
21164
- commitArtifacts: "none",
21165
20828
  writerLeaseId: input.lease.leaseId,
21166
20829
  writerEpoch: input.lease.epoch
21167
20830
  };
@@ -21169,7 +20832,7 @@ async function appendMarkEvidence(input) {
21169
20832
  for (const effect of target.effects) {
21170
20833
  const outcome = appendOutcomeEvent(
21171
20834
  config,
21172
- (0, import_agent_qa_schema73.asRecordId)(target.recordId),
20835
+ (0, import_agent_qa_schema71.asRecordId)(target.recordId),
21173
20836
  markEvidenceEvent(effect, input.mark.markId, target.buildOrdinal)
21174
20837
  );
21175
20838
  if (outcome.kind !== "appended" && outcome.kind !== "duplicate") {
@@ -21259,7 +20922,6 @@ async function appendMarkEvidence(input) {
21259
20922
  NativeEmbeddingDimensionError,
21260
20923
  NativeEmbeddingModuleLoadError,
21261
20924
  PAYLOAD_BENEFITS,
21262
- PAYLOAD_STATE_VALIDITIES,
21263
20925
  PURGE_RECEIPT_SCHEMA_VERSION,
21264
20926
  PolicyTextRefusedError,
21265
20927
  PurgeChronologyRequiredError,
@@ -21321,7 +20983,6 @@ async function appendMarkEvidence(input) {
21321
20983
  authoredCheckpointSchema,
21322
20984
  buildCurationCandidateAddressFields,
21323
20985
  buildRetrievalQuery,
21324
- canaryPostureFactsFor,
21325
20986
  candidateContentAddress,
21326
20987
  claimNextJob,
21327
20988
  claimedCandidateDir,
@@ -21390,7 +21051,6 @@ async function appendMarkEvidence(input) {
21390
21051
  listTestsInFile,
21391
21052
  loadBundle,
21392
21053
  loadFloorAssets,
21393
- lowerTrustSharesFor,
21394
21054
  markEvidenceEvent,
21395
21055
  materializePolicy,
21396
21056
  openAddressingLedger,
@@ -21421,7 +21081,6 @@ async function appendMarkEvidence(input) {
21421
21081
  queuedCandidateDir,
21422
21082
  queuedRoot,
21423
21083
  readCanonicalBundleAnchors,
21424
- readCanonicalBundleStateDigests,
21425
21084
  readCurationCandidatePayload,
21426
21085
  readCurationEffects,
21427
21086
  readEmbedderWorkerRegistration,
@@ -21472,7 +21131,6 @@ async function appendMarkEvidence(input) {
21472
21131
  showRecord,
21473
21132
  sightEntity,
21474
21133
  sliceAuthoredCheckpoint,
21475
- standingReceiptDigestsFor,
21476
21134
  suiteFingerprintDeltas,
21477
21135
  sweepEntityIndex,
21478
21136
  testFingerprintElements,