@vostride/agent-qa-knowledge-local 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -0
- package/dist/embedder-worker/worker-entry.cjs.map +1 -1
- package/dist/embedder-worker/worker-entry.d.cts +1 -1
- package/dist/embedder-worker/worker-entry.d.ts +1 -1
- package/dist/embedder-worker/worker-entry.js.map +1 -1
- package/dist/index.cjs +571 -913
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1190
- package/dist/index.d.ts +18 -1190
- package/dist/index.js +232 -584
- package/dist/index.js.map +1 -1
- package/dist/mark-evidence-plan-CmOkzw6u.d.cts +556 -0
- package/dist/mark-evidence-plan-CmOkzw6u.d.ts +556 -0
- package/dist/reader.cjs +68 -274
- package/dist/reader.cjs.map +1 -1
- package/dist/reader.d.cts +4 -38
- package/dist/reader.d.ts +4 -38
- package/dist/reader.js +83 -300
- package/dist/reader.js.map +1 -1
- package/dist/{worker-registration-C-9spEsf.d.cts → worker-registration-DAYLDaFV.d.cts} +0 -3
- package/dist/{worker-registration-C-9spEsf.d.ts → worker-registration-DAYLDaFV.d.ts} +0 -3
- package/package.json +10 -9
- package/dist/mark-evidence-plan-BCkYN07i.d.cts +0 -1014
- package/dist/mark-evidence-plan-BCkYN07i.d.ts +0 -1014
package/dist/reader.cjs
CHANGED
|
@@ -40,8 +40,6 @@ __export(reader_exports, {
|
|
|
40
40
|
QUARANTINE_LEDGER_FILENAME: () => QUARANTINE_LEDGER_FILENAME,
|
|
41
41
|
canaryAttributionsFor: () => canaryAttributionsFor,
|
|
42
42
|
canaryOutcomeObservationId: () => canaryOutcomeObservationId,
|
|
43
|
-
canaryPostureFactsFor: () => canaryPostureFactsFor,
|
|
44
|
-
candidateInjectionFor: () => candidateInjectionFor,
|
|
45
43
|
createAuthoringReader: () => createAuthoringReader,
|
|
46
44
|
diffSince: () => diffSince,
|
|
47
45
|
foldQuarantineLedgerState: () => foldQuarantineLedgerState,
|
|
@@ -49,7 +47,6 @@ __export(reader_exports, {
|
|
|
49
47
|
hydrateRows: () => hydrateRows,
|
|
50
48
|
inspectRecords: () => inspectRecords,
|
|
51
49
|
listBundles: () => listBundles,
|
|
52
|
-
lowerTrustSharesFor: () => lowerTrustSharesFor,
|
|
53
50
|
markEvidenceEvent: () => markEvidenceEvent,
|
|
54
51
|
openKnowledgeReader: () => openKnowledgeReader2,
|
|
55
52
|
planMarkEvidence: () => planMarkEvidence,
|
|
@@ -58,8 +55,7 @@ __export(reader_exports, {
|
|
|
58
55
|
readIndexRows: () => readIndexRows,
|
|
59
56
|
readQuarantineLedger: () => readQuarantineLedger,
|
|
60
57
|
showRecord: () => showRecord,
|
|
61
|
-
showRecords: () => showRecords
|
|
62
|
-
standingReceiptDigestsFor: () => standingReceiptDigestsFor
|
|
58
|
+
showRecords: () => showRecords
|
|
63
59
|
});
|
|
64
60
|
module.exports = __toCommonJS(reader_exports);
|
|
65
61
|
|
|
@@ -339,12 +335,12 @@ function verifyBundleIntegrity(bundleDir) {
|
|
|
339
335
|
}
|
|
340
336
|
return { ok: violations.length === 0, violations };
|
|
341
337
|
}
|
|
342
|
-
function deriveBundleTrust(loaded
|
|
338
|
+
function deriveBundleTrust(loaded) {
|
|
343
339
|
return (0, import_agent_qa_schema.foldBundleTrust)(loaded.events, {
|
|
344
340
|
originClass: loaded.provenance.originClass,
|
|
345
341
|
evidenceIncomplete: loaded.manifest.evidenceIncomplete,
|
|
346
342
|
createdAtOrdinal: loaded.manifest.createdAtOrdinal
|
|
347
|
-
}
|
|
343
|
+
});
|
|
348
344
|
}
|
|
349
345
|
|
|
350
346
|
// src/bundle-scan.ts
|
|
@@ -431,11 +427,11 @@ function anchorMatches(bundle, queryAnchor) {
|
|
|
431
427
|
return normalized.t === "el" && queryAnchor.t === "el" && normalized.role === queryAnchor.role && normalized.name === queryAnchor.name;
|
|
432
428
|
});
|
|
433
429
|
}
|
|
434
|
-
function servableHit(dir
|
|
430
|
+
function servableHit(dir) {
|
|
435
431
|
const outcome = loadBundle(dir.dir);
|
|
436
432
|
if (outcome.kind !== "loaded") return void 0;
|
|
437
433
|
if (!verifyBundleIntegrity(dir.dir).ok) return void 0;
|
|
438
|
-
const trustState = deriveBundleTrust(outcome.bundle
|
|
434
|
+
const trustState = deriveBundleTrust(outcome.bundle);
|
|
439
435
|
return isServable(trustState) ? toHit(outcome.bundle, trustState, dir.product) : void 0;
|
|
440
436
|
}
|
|
441
437
|
function scanBundlesWithPosture(opts, servingOnly) {
|
|
@@ -447,7 +443,7 @@ function scanBundlesWithPosture(opts, servingOnly) {
|
|
|
447
443
|
const outcome = loadBundle(entry.dir);
|
|
448
444
|
if (outcome.kind !== "loaded") continue;
|
|
449
445
|
if (!verifyBundleIntegrity(entry.dir).ok) continue;
|
|
450
|
-
const trustState = deriveBundleTrust(outcome.bundle
|
|
446
|
+
const trustState = deriveBundleTrust(outcome.bundle);
|
|
451
447
|
if (servingOnly && !isServable(trustState)) continue;
|
|
452
448
|
if (!textMatches(outcome.bundle, queryTokens)) continue;
|
|
453
449
|
if (!anchorMatches(outcome.bundle, queryAnchor)) continue;
|
|
@@ -467,7 +463,7 @@ function scanBundlesForRetrieval(opts) {
|
|
|
467
463
|
function scanBundleById(opts) {
|
|
468
464
|
for (const entry of enumerateBundleDirs(opts.knowledgeRoot)) {
|
|
469
465
|
if ((0, import_node_path2.basename)(entry.dir) !== opts.bundleId) continue;
|
|
470
|
-
const hit = servableHit(entry
|
|
466
|
+
const hit = servableHit(entry);
|
|
471
467
|
if (hit !== void 0) return hit;
|
|
472
468
|
}
|
|
473
469
|
return void 0;
|
|
@@ -634,7 +630,6 @@ function publishStagedQueueEntry(stagingDir, finalDir, queueDir) {
|
|
|
634
630
|
// src/canary-emit.ts
|
|
635
631
|
var CANARY_QUEUE_SCHEMA_VERSION = 2;
|
|
636
632
|
var PAYLOAD_BENEFITS = ["exercised-benefited", "rode-along", "exercised-harmed"];
|
|
637
|
-
var PAYLOAD_STATE_VALIDITIES = ["valid", "stale", "unknown"];
|
|
638
633
|
var canaryOutcomePayloadBaseShape = {
|
|
639
634
|
jobKind: import_zod2.z.literal("canary-outcome"),
|
|
640
635
|
candidateId: import_zod2.z.string().min(1),
|
|
@@ -648,28 +643,10 @@ var canaryOutcomePayloadBaseShape = {
|
|
|
648
643
|
attribution: import_zod2.z.string(),
|
|
649
644
|
briefDigest: import_zod2.z.string().min(1)
|
|
650
645
|
};
|
|
651
|
-
var count = import_zod2.z.number().int().nonnegative();
|
|
652
|
-
var digest = import_zod2.z.string().regex(/^[0-9a-f]{64}$/);
|
|
653
646
|
var canaryOutcomePayloadSchema = import_zod2.z.object({
|
|
654
647
|
...canaryOutcomePayloadBaseShape,
|
|
655
648
|
schemaVersion: import_zod2.z.literal(CANARY_QUEUE_SCHEMA_VERSION),
|
|
656
|
-
benefit: import_zod2.z.enum(PAYLOAD_BENEFITS)
|
|
657
|
-
stateValidity: import_zod2.z.enum(PAYLOAD_STATE_VALIDITIES),
|
|
658
|
-
corpusDigest: digest.optional(),
|
|
659
|
-
observedStateDigest: digest.optional(),
|
|
660
|
-
ablation: import_zod2.z.object({
|
|
661
|
-
crossCheck: import_zod2.z.enum(import_agent_qa_schema3.CROSS_CHECKS),
|
|
662
|
-
k: import_zod2.z.number().int().min(3),
|
|
663
|
-
baseSeed: import_zod2.z.number().int(),
|
|
664
|
-
seeds: import_zod2.z.array(import_zod2.z.number().int()),
|
|
665
|
-
seedHonored: import_zod2.z.boolean(),
|
|
666
|
-
spend: import_zod2.z.object({
|
|
667
|
-
modelCalls: count,
|
|
668
|
-
screens: count,
|
|
669
|
-
promptTokens: count,
|
|
670
|
-
completionTokens: count
|
|
671
|
-
}).strict()
|
|
672
|
-
}).strict().optional()
|
|
649
|
+
benefit: import_zod2.z.enum(PAYLOAD_BENEFITS)
|
|
673
650
|
}).strict();
|
|
674
651
|
var diagnosticShape = { emittedAt: import_zod2.z.string().optional() };
|
|
675
652
|
var canaryOutcomeAddressFieldsSchema = canaryOutcomePayloadSchema.extend(diagnosticShape);
|
|
@@ -690,10 +667,6 @@ function enqueueCanaryOutcome(knowledgeRoot, outcome) {
|
|
|
690
667
|
stepIndex: outcome.stepIndex,
|
|
691
668
|
outcome: outcome.runOutcome,
|
|
692
669
|
benefit: outcome.benefit,
|
|
693
|
-
stateValidity: outcome.stateValidity,
|
|
694
|
-
...outcome.corpusDigest === void 0 ? {} : { corpusDigest: outcome.corpusDigest },
|
|
695
|
-
...outcome.observedStateDigest === void 0 ? {} : { observedStateDigest: outcome.observedStateDigest },
|
|
696
|
-
...outcome.ablation === void 0 ? {} : { ablation: outcome.ablation },
|
|
697
670
|
exercisedAnchor: outcome.exercisedAnchor,
|
|
698
671
|
attribution: outcome.attribution,
|
|
699
672
|
briefDigest: outcome.briefDigest
|
|
@@ -967,12 +940,6 @@ function scanCanonicalBundles(knowledgeRoot) {
|
|
|
967
940
|
}
|
|
968
941
|
|
|
969
942
|
// src/promotion-gate-input.ts
|
|
970
|
-
function snapshotTrustPriors(priors) {
|
|
971
|
-
if (priors === void 0) return void 0;
|
|
972
|
-
const snapshot = (0, import_agent_qa_schema6.guardTrustPriorTable)(priors);
|
|
973
|
-
for (const row of Object.values(snapshot)) Object.freeze(row);
|
|
974
|
-
return Object.freeze(snapshot);
|
|
975
|
-
}
|
|
976
943
|
function promotionObservations(bundleDir) {
|
|
977
944
|
const file = (0, import_node_path8.join)(bundleDir, "observations.jsonl");
|
|
978
945
|
if (!(0, import_node_fs8.existsSync)(file)) return [];
|
|
@@ -992,20 +959,12 @@ function memoryOffForBundle(knowledgeRoot, bundle) {
|
|
|
992
959
|
);
|
|
993
960
|
}
|
|
994
961
|
function assemblePromotionGateInput(input) {
|
|
995
|
-
const trust = deriveBundleTrust(input.bundle
|
|
962
|
+
const trust = deriveBundleTrust(input.bundle);
|
|
996
963
|
const survivingEvents = (0, import_agent_qa_schema6.survivingOutcomeEvents)(input.bundle.events);
|
|
997
964
|
const runLinkedProvenance = input.bundle.provenance.mode === "run-linked" ? input.bundle.provenance : void 0;
|
|
998
965
|
const gateLines = readGateReceipts(input.bundleDir, input.bundle.manifest.id) ?? [];
|
|
999
|
-
const provenance = candidateProvenanceOf(input.bundleDir, input.bundle);
|
|
1000
|
-
const posture = input.resolvePromotionPosture?.({
|
|
1001
|
-
id: input.bundle.manifest.id,
|
|
1002
|
-
product: (0, import_node_path8.basename)((0, import_node_path8.dirname)((0, import_node_path8.dirname)(input.bundleDir))),
|
|
1003
|
-
scope: input.bundle.frontmatter.scope,
|
|
1004
|
-
provenance
|
|
1005
|
-
});
|
|
1006
966
|
return {
|
|
1007
967
|
gateReceipts: gateLines.filter((line) => !(0, import_agent_qa_schema6.isPromotionReceipt)(line)),
|
|
1008
|
-
...posture === void 0 ? {} : { gatePosture: posture },
|
|
1009
968
|
kind: input.bundle.frontmatter.kind,
|
|
1010
969
|
...input.bundle.frontmatter.subtype === void 0 ? {} : { subtype: input.bundle.frontmatter.subtype },
|
|
1011
970
|
status: trust.status,
|
|
@@ -1026,28 +985,15 @@ function assemblePromotionGateInput(input) {
|
|
|
1026
985
|
memoryOffForAnchorGroup: memoryOffForBundle(input.knowledgeRoot, input.bundle)
|
|
1027
986
|
};
|
|
1028
987
|
}
|
|
1029
|
-
function candidateProvenanceOf(bundleDir, bundle) {
|
|
1030
|
-
const runLinked = bundle.provenance.mode === "run-linked" ? bundle.provenance : void 0;
|
|
1031
|
-
const gateLines = readGateReceipts(bundleDir, bundle.manifest.id) ?? [];
|
|
1032
|
-
return {
|
|
1033
|
-
runIds: runLinked === void 0 ? [] : [runLinked.runId],
|
|
1034
|
-
receiptDigests: gateLines.map((line) => line.receiptDigest),
|
|
1035
|
-
capturedAtOrdinals: [...new Set([
|
|
1036
|
-
...runLinked?.sourceBuildOrdinal === void 0 ? [] : [runLinked.sourceBuildOrdinal],
|
|
1037
|
-
...(0, import_agent_qa_schema6.survivingOutcomeEvents)(bundle.events).map((event) => event.buildOrdinal)
|
|
1038
|
-
].filter(Number.isInteger))].sort((left, right) => left - right)
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
988
|
|
|
1042
989
|
// src/trust-prior-context.ts
|
|
1043
990
|
var import_node_crypto4 = require("node:crypto");
|
|
1044
991
|
var import_agent_qa_schema7 = require("@vostride/agent-qa-schema");
|
|
1045
|
-
function effectivePriorDigest(
|
|
1046
|
-
|
|
1047
|
-
return (0, import_node_crypto4.createHash)("sha256").update((0, import_agent_qa_schema7.canonicalJson)({ ...import_agent_qa_schema7.ORIGIN_PRIORS, ...table })).digest("hex");
|
|
992
|
+
function effectivePriorDigest() {
|
|
993
|
+
return (0, import_node_crypto4.createHash)("sha256").update((0, import_agent_qa_schema7.canonicalJson)({ ...import_agent_qa_schema7.ORIGIN_PRIORS })).digest("hex");
|
|
1048
994
|
}
|
|
1049
|
-
function indexTrustEpochMatches(db,
|
|
1050
|
-
return db.prepare("SELECT v FROM meta WHERE k = 'trust_prior_digest'").get()?.v ===
|
|
995
|
+
function indexTrustEpochMatches(db, digest) {
|
|
996
|
+
return db.prepare("SELECT v FROM meta WHERE k = 'trust_prior_digest'").get()?.v === digest && db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest) === void 0;
|
|
1051
997
|
}
|
|
1052
998
|
var TrustPriorEpochMismatch = class extends Error {
|
|
1053
999
|
constructor() {
|
|
@@ -1125,7 +1071,7 @@ function safeBundleDir(knowledgeRoot, hit) {
|
|
|
1125
1071
|
}
|
|
1126
1072
|
return (0, import_node_path9.join)(knowledgeRoot, "memory", hit.product, "bundles", hit.bundleId);
|
|
1127
1073
|
}
|
|
1128
|
-
function recheckAuthoritativeHits(knowledgeRoot, hits, audit
|
|
1074
|
+
function recheckAuthoritativeHits(knowledgeRoot, hits, audit) {
|
|
1129
1075
|
const refreshed = [];
|
|
1130
1076
|
for (const hit of hits) {
|
|
1131
1077
|
const bundleDir = safeBundleDir(knowledgeRoot, hit);
|
|
@@ -1134,7 +1080,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
|
|
|
1134
1080
|
if (!verifyBundleIntegrity(bundleDir).ok) continue;
|
|
1135
1081
|
const outcome = loadBundle(bundleDir);
|
|
1136
1082
|
if (outcome.kind !== "loaded" || outcome.bundle.manifest.id !== hit.bundleId) continue;
|
|
1137
|
-
const trust = deriveBundleTrust(outcome.bundle
|
|
1083
|
+
const trust = deriveBundleTrust(outcome.bundle);
|
|
1138
1084
|
if (!audit && !isServable(trust)) continue;
|
|
1139
1085
|
refreshed.push({
|
|
1140
1086
|
...hit,
|
|
@@ -1154,8 +1100,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
|
|
|
1154
1100
|
vettedCandidateInput: assemblePromotionGateInput({
|
|
1155
1101
|
knowledgeRoot,
|
|
1156
1102
|
bundleDir,
|
|
1157
|
-
bundle: outcome.bundle
|
|
1158
|
-
priors
|
|
1103
|
+
bundle: outcome.bundle
|
|
1159
1104
|
})
|
|
1160
1105
|
});
|
|
1161
1106
|
} catch {
|
|
@@ -1163,8 +1108,8 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
|
|
|
1163
1108
|
}
|
|
1164
1109
|
return refreshed;
|
|
1165
1110
|
}
|
|
1166
|
-
function recheckHits(knowledgeRoot, hits
|
|
1167
|
-
return recheckAuthoritativeHits(knowledgeRoot, hits, false
|
|
1111
|
+
function recheckHits(knowledgeRoot, hits) {
|
|
1112
|
+
return recheckAuthoritativeHits(knowledgeRoot, hits, false).map((hit) => {
|
|
1168
1113
|
const {
|
|
1169
1114
|
anchors: _anchors,
|
|
1170
1115
|
scope: _scope,
|
|
@@ -1233,52 +1178,50 @@ function cosineDistance(query, candidate) {
|
|
|
1233
1178
|
}
|
|
1234
1179
|
return 1 - dot;
|
|
1235
1180
|
}
|
|
1236
|
-
function scanReader(knowledgeRoot
|
|
1181
|
+
function scanReader(knowledgeRoot) {
|
|
1237
1182
|
const reader = {
|
|
1238
1183
|
source: "scan",
|
|
1239
1184
|
vec: "none",
|
|
1240
1185
|
getById(bundleId) {
|
|
1241
|
-
return scanBundleById({ knowledgeRoot, bundleId
|
|
1186
|
+
return scanBundleById({ knowledgeRoot, bundleId });
|
|
1242
1187
|
},
|
|
1243
1188
|
searchLexical(text, opts = {}) {
|
|
1244
|
-
return scanBundles({ knowledgeRoot, text, ...opts
|
|
1189
|
+
return scanBundles({ knowledgeRoot, text, ...opts });
|
|
1245
1190
|
},
|
|
1246
1191
|
lookupAnchor(anchor, opts = {}) {
|
|
1247
|
-
return scanBundles({ knowledgeRoot, anchor: (0, import_agent_qa_schema8.normalizeAnchor)(anchor), ...opts
|
|
1192
|
+
return scanBundles({ knowledgeRoot, anchor: (0, import_agent_qa_schema8.normalizeAnchor)(anchor), ...opts });
|
|
1248
1193
|
},
|
|
1249
1194
|
searchDense() {
|
|
1250
1195
|
return [];
|
|
1251
1196
|
},
|
|
1252
1197
|
recheck(hits) {
|
|
1253
|
-
return recheckHits(knowledgeRoot, hits
|
|
1198
|
+
return recheckHits(knowledgeRoot, hits);
|
|
1254
1199
|
},
|
|
1255
1200
|
close() {
|
|
1256
1201
|
},
|
|
1257
1202
|
async [RUN_RETRIEVAL](operation) {
|
|
1258
1203
|
return operation({
|
|
1259
1204
|
knowledgeRoot,
|
|
1260
|
-
priors,
|
|
1261
1205
|
source: "scan",
|
|
1262
1206
|
vec: "none",
|
|
1263
1207
|
connection: void 0,
|
|
1264
1208
|
reader,
|
|
1265
1209
|
scan: (text, anchor) => scanBundlesForRetrieval({
|
|
1266
1210
|
knowledgeRoot,
|
|
1267
|
-
priors,
|
|
1268
1211
|
...text === void 0 ? {} : { text },
|
|
1269
1212
|
...anchor === void 0 ? {} : { anchor }
|
|
1270
1213
|
}),
|
|
1271
|
-
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit
|
|
1214
|
+
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
|
|
1272
1215
|
});
|
|
1273
1216
|
}
|
|
1274
1217
|
};
|
|
1275
1218
|
return reader;
|
|
1276
1219
|
}
|
|
1277
|
-
function indexReader(knowledgeRoot, connection
|
|
1220
|
+
function indexReader(knowledgeRoot, connection) {
|
|
1278
1221
|
let closed = false;
|
|
1279
1222
|
const { db } = connection;
|
|
1280
1223
|
const activeProfile = resolveActiveProfile(db);
|
|
1281
|
-
const priorDigest = effectivePriorDigest(
|
|
1224
|
+
const priorDigest = effectivePriorDigest();
|
|
1282
1225
|
let snapshotDepth = 0;
|
|
1283
1226
|
function assertTrustEpoch() {
|
|
1284
1227
|
if (!indexTrustEpochMatches(db, priorDigest)) throw new TrustPriorEpochMismatch();
|
|
@@ -1296,7 +1239,7 @@ function indexReader(knowledgeRoot, connection, priors) {
|
|
|
1296
1239
|
});
|
|
1297
1240
|
}
|
|
1298
1241
|
function recheckCurrent(hits) {
|
|
1299
|
-
return recheckHits(knowledgeRoot, hits
|
|
1242
|
+
return recheckHits(knowledgeRoot, hits);
|
|
1300
1243
|
}
|
|
1301
1244
|
function denseVec02(embedding, opts) {
|
|
1302
1245
|
const k = queryLimit(opts.k);
|
|
@@ -1467,13 +1410,12 @@ function indexReader(knowledgeRoot, connection, priors) {
|
|
|
1467
1410
|
try {
|
|
1468
1411
|
return await operation({
|
|
1469
1412
|
knowledgeRoot,
|
|
1470
|
-
priors,
|
|
1471
1413
|
source: "index",
|
|
1472
1414
|
vec: connection.vec,
|
|
1473
1415
|
connection,
|
|
1474
1416
|
reader: snapshotReader,
|
|
1475
1417
|
scan: void 0,
|
|
1476
|
-
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit
|
|
1418
|
+
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
|
|
1477
1419
|
});
|
|
1478
1420
|
} finally {
|
|
1479
1421
|
snapshotDepth -= 1;
|
|
@@ -1490,8 +1432,8 @@ function indexReader(knowledgeRoot, connection, priors) {
|
|
|
1490
1432
|
};
|
|
1491
1433
|
return snapshotReader;
|
|
1492
1434
|
}
|
|
1493
|
-
function operationDegradingReader(knowledgeRoot, connection
|
|
1494
|
-
let delegate = indexReader(knowledgeRoot, connection
|
|
1435
|
+
function operationDegradingReader(knowledgeRoot, connection) {
|
|
1436
|
+
let delegate = indexReader(knowledgeRoot, connection);
|
|
1495
1437
|
let closed = false;
|
|
1496
1438
|
function invoke(operation) {
|
|
1497
1439
|
if (delegate.source === "scan") return operation(delegate);
|
|
@@ -1506,7 +1448,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
|
|
|
1506
1448
|
`derived index operation failed: ${errorMessage2(error)}`
|
|
1507
1449
|
);
|
|
1508
1450
|
}
|
|
1509
|
-
delegate = scanReader(knowledgeRoot
|
|
1451
|
+
delegate = scanReader(knowledgeRoot);
|
|
1510
1452
|
return operation(delegate);
|
|
1511
1453
|
}
|
|
1512
1454
|
}
|
|
@@ -1523,7 +1465,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
|
|
|
1523
1465
|
`derived index operation failed: ${errorMessage2(error)}`
|
|
1524
1466
|
);
|
|
1525
1467
|
}
|
|
1526
|
-
delegate = scanReader(knowledgeRoot
|
|
1468
|
+
delegate = scanReader(knowledgeRoot);
|
|
1527
1469
|
return operation(delegate);
|
|
1528
1470
|
}
|
|
1529
1471
|
}
|
|
@@ -1564,9 +1506,9 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
|
|
|
1564
1506
|
};
|
|
1565
1507
|
return reader;
|
|
1566
1508
|
}
|
|
1567
|
-
function degrade(knowledgeRoot, reason, detail
|
|
1509
|
+
function degrade(knowledgeRoot, reason, detail) {
|
|
1568
1510
|
requestRebuildBestEffort(knowledgeRoot, reason, detail);
|
|
1569
|
-
return scanReader(knowledgeRoot
|
|
1511
|
+
return scanReader(knowledgeRoot);
|
|
1570
1512
|
}
|
|
1571
1513
|
function classifyIndexFaceWithConnection(knowledgeRoot, opts) {
|
|
1572
1514
|
if (!(0, import_node_fs9.existsSync)(indexDbPath(knowledgeRoot))) {
|
|
@@ -1609,15 +1551,14 @@ function classifyIndexFaceWithConnection(knowledgeRoot, opts) {
|
|
|
1609
1551
|
return { face: { source: "index" }, connection };
|
|
1610
1552
|
}
|
|
1611
1553
|
function openKnowledgeReader(knowledgeRoot, opts = {}) {
|
|
1612
|
-
const priors = snapshotTrustPriors(opts.priors);
|
|
1613
1554
|
const result = classifyIndexFaceWithConnection(knowledgeRoot, {
|
|
1614
1555
|
...opts,
|
|
1615
1556
|
inspectCheckpointedImmutably: false
|
|
1616
1557
|
});
|
|
1617
1558
|
if (result.connection === void 0) {
|
|
1618
|
-
return degrade(knowledgeRoot, result.face.reason, result.face.detail
|
|
1559
|
+
return degrade(knowledgeRoot, result.face.reason, result.face.detail);
|
|
1619
1560
|
}
|
|
1620
|
-
return operationDegradingReader(knowledgeRoot, result.connection
|
|
1561
|
+
return operationDegradingReader(knowledgeRoot, result.connection);
|
|
1621
1562
|
}
|
|
1622
1563
|
|
|
1623
1564
|
// src/retrieval/pre-filter.ts
|
|
@@ -1734,13 +1675,11 @@ function applyLifecycleTrustTreatments(entries, asOfBuild) {
|
|
|
1734
1675
|
}
|
|
1735
1676
|
const unverified = entry.vettedCandidateInput !== void 0 && (0, import_agent_qa_schema9.isVettedCandidate)(entry.vettedCandidateInput);
|
|
1736
1677
|
if (unverified) trust *= import_agent_qa_schema9.COLD_START_TRUST_DISCOUNT;
|
|
1737
|
-
if (entry.lowerTrust === true) trust *= import_agent_qa_schema9.LOWER_TRUST_PATH_DISCOUNT;
|
|
1738
1678
|
return {
|
|
1739
1679
|
...base,
|
|
1740
1680
|
trust,
|
|
1741
1681
|
...unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal },
|
|
1742
|
-
...unverified ? { unverified: true } : {}
|
|
1743
|
-
...entry.lowerTrust === true ? { lowerTrust: true } : {}
|
|
1682
|
+
...unverified ? { unverified: true } : {}
|
|
1744
1683
|
};
|
|
1745
1684
|
});
|
|
1746
1685
|
}
|
|
@@ -1755,9 +1694,9 @@ function applyDiversityCaps(entries, audit = false) {
|
|
|
1755
1694
|
return entries.filter((entry) => {
|
|
1756
1695
|
const key = primaryDiversityKey(entry);
|
|
1757
1696
|
if (key === void 0) return true;
|
|
1758
|
-
const
|
|
1759
|
-
if (
|
|
1760
|
-
counts.set(key,
|
|
1697
|
+
const count = counts.get(key) ?? 0;
|
|
1698
|
+
if (count >= DIVERSITY_CAP_PER_ANCHOR) return false;
|
|
1699
|
+
counts.set(key, count + 1);
|
|
1761
1700
|
return true;
|
|
1762
1701
|
});
|
|
1763
1702
|
}
|
|
@@ -1796,12 +1735,12 @@ function resolveAsOfBuild(options) {
|
|
|
1796
1735
|
if (injected !== void 0) return injected;
|
|
1797
1736
|
const disk = options.runtimeRoot === void 0 ? void 0 : readLatestBuildOrdinal(options.runtimeRoot, options.product);
|
|
1798
1737
|
if (disk !== void 0) return disk;
|
|
1799
|
-
let
|
|
1738
|
+
let latest;
|
|
1800
1739
|
for (const candidate of options.candidates) {
|
|
1801
1740
|
if (!Number.isFinite(candidate.openedAtOrdinal)) continue;
|
|
1802
|
-
|
|
1741
|
+
latest = latest === void 0 ? candidate.openedAtOrdinal : Math.max(latest, candidate.openedAtOrdinal);
|
|
1803
1742
|
}
|
|
1804
|
-
return
|
|
1743
|
+
return latest;
|
|
1805
1744
|
}
|
|
1806
1745
|
function isCurrentAt(candidate, asOfBuild) {
|
|
1807
1746
|
return candidate.openedAtOrdinal <= asOfBuild && (candidate.closedAtOrdinal === null || candidate.closedAtOrdinal > asOfBuild);
|
|
@@ -1987,7 +1926,6 @@ function rankedCandidate(candidate) {
|
|
|
1987
1926
|
lastConfirmedOrdinal,
|
|
1988
1927
|
...candidate.record.unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal: candidate.record.unconfirmedSinceOrdinal },
|
|
1989
1928
|
...candidate.record.unverified === true ? { unverified: true } : {},
|
|
1990
|
-
...candidate.record.lowerTrust === true ? { lowerTrust: true } : {},
|
|
1991
1929
|
...candidate.record.conflict === void 0 ? {} : { conflict: candidate.record.conflict }
|
|
1992
1930
|
};
|
|
1993
1931
|
}
|
|
@@ -2512,8 +2450,7 @@ function readPolicyLadder(knowledgeRoot, product) {
|
|
|
2512
2450
|
return rung === void 0 ? [] : [rung];
|
|
2513
2451
|
});
|
|
2514
2452
|
return {
|
|
2515
|
-
//
|
|
2516
|
-
// sources but no active text is summarized, truncated, normalized, or reflowed.
|
|
2453
|
+
// Active policy bytes are concatenated whole; labels frame sources and no text is reflowed.
|
|
2517
2454
|
text: renderPolicyLadder(rungs),
|
|
2518
2455
|
files: rungs.map(({ file }) => file),
|
|
2519
2456
|
oversized: rungs.flatMap(
|
|
@@ -2555,7 +2492,7 @@ function readIndexRows(config, scope) {
|
|
|
2555
2492
|
...scope === void 0 ? {} : { requestedScope: scope },
|
|
2556
2493
|
...config.scopeDefaults?.parentScopes === void 0 ? {} : { parentScopes: config.scopeDefaults.parentScopes }
|
|
2557
2494
|
});
|
|
2558
|
-
if (!indexTrustEpochMatches(reader.db, effectivePriorDigest(
|
|
2495
|
+
if (!indexTrustEpochMatches(reader.db, effectivePriorDigest())) {
|
|
2559
2496
|
const admits = reader.db.prepare(`
|
|
2560
2497
|
SELECT 1 FROM (SELECT ? AS product, ? AS scope_tier, ? AS scope_key) r
|
|
2561
2498
|
WHERE ${predicate.sql}
|
|
@@ -2606,16 +2543,14 @@ function hydrateRows(config, rows, audit) {
|
|
|
2606
2543
|
const loaded = loadBundle(found.dir);
|
|
2607
2544
|
if (loaded.kind !== "loaded" || !verifyBundleIntegrity(found.dir).ok) return [];
|
|
2608
2545
|
const { bundle } = loaded;
|
|
2609
|
-
const trust = deriveBundleTrust(bundle
|
|
2546
|
+
const trust = deriveBundleTrust(bundle);
|
|
2610
2547
|
const vetted = trust.status === "candidate" && (0, import_agent_qa_schema17.isVettedCandidate)(
|
|
2611
2548
|
assemblePromotionGateInput({
|
|
2612
2549
|
knowledgeRoot: config.knowledgeRoot,
|
|
2613
2550
|
bundleDir: found.dir,
|
|
2614
|
-
bundle
|
|
2615
|
-
priors: config.priors
|
|
2551
|
+
bundle
|
|
2616
2552
|
})
|
|
2617
2553
|
);
|
|
2618
|
-
const lowerTrust = trust.status === "active" && (0, import_agent_qa_schema17.strongestPromotionPath)(readGateReceipts(found.dir, bundle.manifest.id) ?? []) === "gate1-lower-trust";
|
|
2619
2554
|
const entry = {
|
|
2620
2555
|
id: (0, import_agent_qa_schema17.asRecordId)(bundle.manifest.id),
|
|
2621
2556
|
kind: bundle.frontmatter.kind,
|
|
@@ -2625,8 +2560,7 @@ function hydrateRows(config, rows, audit) {
|
|
|
2625
2560
|
trust: trust.trust,
|
|
2626
2561
|
anchors: bundle.frontmatter.anchors.map(({ normalized }) => normalized),
|
|
2627
2562
|
status: trust.status,
|
|
2628
|
-
servedAsCanary: vetted
|
|
2629
|
-
...lowerTrust ? { lowerTrust: true } : {},
|
|
2563
|
+
servedAsCanary: vetted,
|
|
2630
2564
|
...vetted ? { unverified: true } : {},
|
|
2631
2565
|
...audit ? {
|
|
2632
2566
|
audit: {
|
|
@@ -2700,7 +2634,7 @@ function searchEntries(config, query, options) {
|
|
|
2700
2634
|
if (!auditMode && (entry.status === "deprecated" || entry.status === "superseded")) {
|
|
2701
2635
|
return false;
|
|
2702
2636
|
}
|
|
2703
|
-
const trust = deriveBundleTrust(bundle
|
|
2637
|
+
const trust = deriveBundleTrust(bundle);
|
|
2704
2638
|
if (options.asOfBuild !== void 0 && !validAtBuild(
|
|
2705
2639
|
trust.validity.openedAtOrdinal,
|
|
2706
2640
|
trust.validity.closedAtOrdinal,
|
|
@@ -2730,7 +2664,7 @@ function findReadableBundle(config, id, options) {
|
|
|
2730
2664
|
if (currentServingEntries([hydrated]).length === 0 && !admitsProcedure({ entry: hydrated.entry, bundle: hydrated.bundle })) {
|
|
2731
2665
|
return void 0;
|
|
2732
2666
|
}
|
|
2733
|
-
const trust = deriveBundleTrust(hydrated.bundle
|
|
2667
|
+
const trust = deriveBundleTrust(hydrated.bundle);
|
|
2734
2668
|
const asOfBuild = options?.asOfBuild ?? config.scopeDefaults?.asOfBuild;
|
|
2735
2669
|
if (asOfBuild !== void 0 && !validAtBuild(
|
|
2736
2670
|
trust.validity.openedAtOrdinal,
|
|
@@ -2843,7 +2777,7 @@ function servingReader(config) {
|
|
|
2843
2777
|
};
|
|
2844
2778
|
}
|
|
2845
2779
|
function openKnowledgeReader2(configOrKnowledgeRoot, opts) {
|
|
2846
|
-
return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader(
|
|
2780
|
+
return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader(configOrKnowledgeRoot);
|
|
2847
2781
|
}
|
|
2848
2782
|
|
|
2849
2783
|
// src/serving/authoring-reader.ts
|
|
@@ -4508,7 +4442,7 @@ function verifiedExemplarCandidate(row, targetKeys, tokens) {
|
|
|
4508
4442
|
return [{
|
|
4509
4443
|
identity: (0, import_agent_qa_schema23.identityTupleKey)([row.filePath, row.testName]),
|
|
4510
4444
|
anchorKeys: new Set(matchedKeys),
|
|
4511
|
-
//
|
|
4445
|
+
// Trust is a neutral 1 for projection-verified rows, so the score is pass rate times relevance.
|
|
4512
4446
|
score: recentPassRate * relevance,
|
|
4513
4447
|
leg: dominantAuthoringLeg(contributions),
|
|
4514
4448
|
exemplar: {
|
|
@@ -4880,7 +4814,6 @@ async function readDenseScores(config, deps, intent, scope) {
|
|
|
4880
4814
|
}
|
|
4881
4815
|
}
|
|
4882
4816
|
function createAuthoringReader(config, deps = {}) {
|
|
4883
|
-
config = { ...config, priors: snapshotTrustPriors(config.priors) };
|
|
4884
4817
|
return {
|
|
4885
4818
|
async getAuthoringBrief(intent, scope) {
|
|
4886
4819
|
const entries = hydrateRows(config, readIndexRows(config, scope), false);
|
|
@@ -4897,8 +4830,7 @@ function createAuthoringReader(config, deps = {}) {
|
|
|
4897
4830
|
const { brief } = assembleAuthoringBrief({
|
|
4898
4831
|
entries,
|
|
4899
4832
|
projectionRows,
|
|
4900
|
-
//
|
|
4901
|
-
// identities remain a deterministic floor, while never-run tests widen the universe.
|
|
4833
|
+
// The consumer owns the filesystem and supplies refs; never-run tests widen the projection.
|
|
4902
4834
|
knownTests,
|
|
4903
4835
|
intent,
|
|
4904
4836
|
scope,
|
|
@@ -5069,7 +5001,7 @@ function toInspectRecordView(entry, bundle, trust) {
|
|
|
5069
5001
|
survivingEvents.map((event) => String(event.evidenceToken))
|
|
5070
5002
|
)].sort(compareText4);
|
|
5071
5003
|
const lastEventOrdinal = survivingEvents.reduce(
|
|
5072
|
-
(
|
|
5004
|
+
(latest, event) => Math.max(latest, event.buildOrdinal),
|
|
5073
5005
|
bundle.manifest.createdAtOrdinal
|
|
5074
5006
|
);
|
|
5075
5007
|
const trustNarrative = readTrustNarrative(entry.dir, bundle);
|
|
@@ -5308,9 +5240,7 @@ function diffSince(options) {
|
|
|
5308
5240
|
recordId: bundle.manifest.id,
|
|
5309
5241
|
change: "added",
|
|
5310
5242
|
atOrdinal: earliestOrdinal,
|
|
5311
|
-
//
|
|
5312
|
-
// records one — no `curationJobId` match is needed, because no event produced this
|
|
5313
|
-
// change. A standalone bundle names no run and gets no key.
|
|
5243
|
+
// A run-linked bundle's appearance is the run's doing; a standalone bundle gets no run key.
|
|
5314
5244
|
...bundle.provenance.mode === "run-linked" ? { sourceRunId: bundle.provenance.runId } : {}
|
|
5315
5245
|
}));
|
|
5316
5246
|
eventLowerBound = earliestOrdinal;
|
|
@@ -5337,13 +5267,13 @@ function diffSince(options) {
|
|
|
5337
5267
|
|
|
5338
5268
|
// src/list-bundles.ts
|
|
5339
5269
|
var import_node_path22 = require("node:path");
|
|
5340
|
-
function listBundles(knowledgeRoot
|
|
5270
|
+
function listBundles(knowledgeRoot) {
|
|
5341
5271
|
const rows = [];
|
|
5342
5272
|
for (const entry of enumerateBundleDirs(knowledgeRoot)) {
|
|
5343
5273
|
const outcome = loadBundle(entry.dir);
|
|
5344
5274
|
if (outcome.kind !== "loaded") continue;
|
|
5345
5275
|
const { bundle } = outcome;
|
|
5346
|
-
const trust = deriveBundleTrust(bundle
|
|
5276
|
+
const trust = deriveBundleTrust(bundle);
|
|
5347
5277
|
rows.push({
|
|
5348
5278
|
bundleId: bundle.manifest.id,
|
|
5349
5279
|
product: entry.product,
|
|
@@ -5514,8 +5444,7 @@ function gateReceiptsFor(options) {
|
|
|
5514
5444
|
const gateInput = assemblePromotionGateInput({
|
|
5515
5445
|
knowledgeRoot: options.knowledgeRoot,
|
|
5516
5446
|
bundleDir: entry.dir,
|
|
5517
|
-
bundle
|
|
5518
|
-
resolvePromotionPosture: options.resolvePromotionPosture
|
|
5447
|
+
bundle
|
|
5519
5448
|
});
|
|
5520
5449
|
return import_agent_qa_schema32.KnowledgeGatesListResultSchema.parse({
|
|
5521
5450
|
kind: "found",
|
|
@@ -5526,144 +5455,25 @@ function gateReceiptsFor(options) {
|
|
|
5526
5455
|
...path === void 0 ? {} : { strongestPromotionPath: path },
|
|
5527
5456
|
lines,
|
|
5528
5457
|
standing,
|
|
5529
|
-
|
|
5530
|
-
live: (0, import_agent_qa_schema32.evaluatePromotionGate)(gateInput),
|
|
5531
|
-
// 'resolved' and 'unavailable' describe the actual posture the gate judged.
|
|
5532
|
-
posture: gateInput.gatePosture?.kind ?? "absent"
|
|
5458
|
+
live: (0, import_agent_qa_schema32.evaluatePromotionGate)(gateInput)
|
|
5533
5459
|
});
|
|
5534
5460
|
}
|
|
5535
5461
|
return { kind: "not-found", recordId: options.candidateId };
|
|
5536
5462
|
}
|
|
5537
5463
|
|
|
5538
|
-
// src/gates/candidate-injection.ts
|
|
5539
|
-
var import_agent_qa_schema33 = require("@vostride/agent-qa-schema");
|
|
5540
|
-
var import_agent_qa_runner3 = require("@vostride/agent-qa-runner");
|
|
5541
|
-
function candidateInjectionFor(options) {
|
|
5542
|
-
const id = (0, import_agent_qa_schema33.asRecordId)(options.candidateId);
|
|
5543
|
-
for (const entry of enumerateMaintenanceBundleDirs(options.knowledgeRoot)) {
|
|
5544
|
-
const bundle = loadMaintenanceBundle(entry);
|
|
5545
|
-
if (bundle.manifest.id !== id) continue;
|
|
5546
|
-
const frontmatter = bundle.frontmatter;
|
|
5547
|
-
const trust = deriveBundleTrust(bundle, options.priors);
|
|
5548
|
-
const stampedEntry = {
|
|
5549
|
-
id,
|
|
5550
|
-
kind: frontmatter.kind,
|
|
5551
|
-
title: bundle.summary,
|
|
5552
|
-
summary: bundle.summary,
|
|
5553
|
-
trust: trust.trust,
|
|
5554
|
-
status: trust.status,
|
|
5555
|
-
anchors: frontmatter.anchors.map(({ normalized }) => normalized),
|
|
5556
|
-
scope: frontmatter.scope,
|
|
5557
|
-
validity: trust.validity.closedAtOrdinal === void 0 ? "current" : `${trust.validity.openedAtOrdinal}:${trust.validity.closedAtOrdinal}`,
|
|
5558
|
-
servedAsCanary: false,
|
|
5559
|
-
originClass: frontmatter.originClass
|
|
5560
|
-
};
|
|
5561
|
-
const line = (0, import_agent_qa_runner.renderBriefLine)(stampedEntry).briefLine;
|
|
5562
|
-
const target = bundle.provenance.mode === "run-linked" ? {
|
|
5563
|
-
runId: bundle.provenance.runId,
|
|
5564
|
-
stepIndex: bundle.provenance.stepIndex,
|
|
5565
|
-
testId: bundle.provenance.testId,
|
|
5566
|
-
...bundle.provenance.sourceBuildOrdinal === void 0 ? {} : {
|
|
5567
|
-
sourceBuildOrdinal: bundle.provenance.sourceBuildOrdinal
|
|
5568
|
-
}
|
|
5569
|
-
} : void 0;
|
|
5570
|
-
return import_agent_qa_schema33.KnowledgeCandidateInjectionResultSchema.parse({
|
|
5571
|
-
kind: "found",
|
|
5572
|
-
injection: {
|
|
5573
|
-
candidateId: id,
|
|
5574
|
-
kind: frontmatter.kind,
|
|
5575
|
-
product: entry.product,
|
|
5576
|
-
scope: frontmatter.scope,
|
|
5577
|
-
anchors: frontmatter.anchors,
|
|
5578
|
-
status: trust.status,
|
|
5579
|
-
line,
|
|
5580
|
-
renderedLine: (0, import_agent_qa_runner3.renderObservationLine)(line),
|
|
5581
|
-
provenance: candidateProvenanceOf(entry.dir, bundle),
|
|
5582
|
-
...target === void 0 ? {} : { target },
|
|
5583
|
-
latestOrdinal: Math.max(
|
|
5584
|
-
frontmatter.createdAtOrdinal,
|
|
5585
|
-
...(0, import_agent_qa_schema33.survivingOutcomeEvents)(bundle.events).map((event) => event.buildOrdinal)
|
|
5586
|
-
)
|
|
5587
|
-
}
|
|
5588
|
-
});
|
|
5589
|
-
}
|
|
5590
|
-
return import_agent_qa_schema33.KnowledgeCandidateInjectionResultSchema.parse({
|
|
5591
|
-
kind: "not-found",
|
|
5592
|
-
recordId: options.candidateId
|
|
5593
|
-
});
|
|
5594
|
-
}
|
|
5595
|
-
|
|
5596
|
-
// src/gates/canary-posture-facts.ts
|
|
5597
|
-
var import_agent_qa_schema34 = require("@vostride/agent-qa-schema");
|
|
5598
|
-
function readBundles(knowledgeRoot, resolveTrustPriors) {
|
|
5599
|
-
return enumerateMaintenanceBundleDirs(knowledgeRoot).map((entry) => {
|
|
5600
|
-
const bundle = loadMaintenanceBundle(entry);
|
|
5601
|
-
const lines = readGateReceipts(entry.dir, bundle.manifest.id) ?? [];
|
|
5602
|
-
return { ...entry, bundle, lines, active: deriveBundleTrust(bundle, resolveTrustPriors?.()).status === "active" };
|
|
5603
|
-
});
|
|
5604
|
-
}
|
|
5605
|
-
function latest(ordinals) {
|
|
5606
|
-
return ordinals.length === 0 ? void 0 : Math.max(...ordinals);
|
|
5607
|
-
}
|
|
5608
|
-
function canaryPostureFactsFor(input) {
|
|
5609
|
-
const id = (0, import_agent_qa_schema34.asRecordId)(input.candidateId);
|
|
5610
|
-
const rows = readBundles(input.knowledgeRoot, input.resolveTrustPriors);
|
|
5611
|
-
const candidate = rows.find((row) => row.bundle.manifest.id === id);
|
|
5612
|
-
if (candidate === void 0) return { kind: "not-found" };
|
|
5613
|
-
const scope = candidate.bundle.frontmatter.scope;
|
|
5614
|
-
if (scope.tier !== "product" || input.scope.tier !== "product" || scope.key !== input.scope.key) return { kind: "not-found" };
|
|
5615
|
-
const receipts = candidate.lines.filter((line) => !(0, import_agent_qa_schema34.isPromotionReceipt)(line));
|
|
5616
|
-
const pass = (0, import_agent_qa_schema34.standingReceiptsByGate)(receipts).find((row) => row.gate === 1 && row.verdict === "pass");
|
|
5617
|
-
const lowerTrustActiveGate1Digest = candidate.active && (0, import_agent_qa_schema34.strongestPromotionPath)(candidate.lines) === "gate1-lower-trust" && (0, import_agent_qa_schema34.survivingOutcomeEvents)(candidate.bundle.events).some((event) => event.type === "promoted") && pass !== void 0 && candidate.lines.some((line) => (0, import_agent_qa_schema34.isPromotionReceipt)(line) && line.promotionPath === "gate1-lower-trust" && line.citedReceiptDigests.includes(pass.receiptDigest)) ? pass.receiptDigest : void 0;
|
|
5618
|
-
const latestAttributionOrdinal = latest((0, import_agent_qa_schema34.survivingOutcomeEvents)(candidate.bundle.events).filter((event) => ["confirmed", "contradicted", "helpful", "harmful"].includes(event.type)).map((event) => event.buildOrdinal));
|
|
5619
|
-
const latestGate2Ordinal = latest(receipts.filter((row) => row.gate === 2).map((row) => row.producedAtOrdinal));
|
|
5620
|
-
const active = rows.filter((row) => row.active && row.product === candidate.product && row.bundle.frontmatter.scope.tier === "product" && row.bundle.frontmatter.scope.key === scope.key);
|
|
5621
|
-
return {
|
|
5622
|
-
kind: "found",
|
|
5623
|
-
...pass === void 0 ? {} : { gate1PassOrdinal: pass.producedAtOrdinal, gate1PassDigest: pass.receiptDigest },
|
|
5624
|
-
...lowerTrustActiveGate1Digest === void 0 ? {} : { lowerTrustActiveGate1Digest },
|
|
5625
|
-
...latestAttributionOrdinal === void 0 ? {} : { latestAttributionOrdinal },
|
|
5626
|
-
...latestGate2Ordinal === void 0 ? {} : { latestGate2Ordinal },
|
|
5627
|
-
activeInScope: active.length,
|
|
5628
|
-
lowerTrustActiveInScope: active.filter((row) => (0, import_agent_qa_schema34.strongestPromotionPath)(row.lines) === "gate1-lower-trust").length
|
|
5629
|
-
};
|
|
5630
|
-
}
|
|
5631
|
-
function standingReceiptDigestsFor(input) {
|
|
5632
|
-
return readBundles(input.knowledgeRoot).flatMap((row) => (0, import_agent_qa_schema34.standingReceiptsByGate)(
|
|
5633
|
-
row.lines.filter((line) => !(0, import_agent_qa_schema34.isPromotionReceipt)(line))
|
|
5634
|
-
).map((receipt) => ({
|
|
5635
|
-
candidateId: receipt.candidateId,
|
|
5636
|
-
gate: receipt.gate,
|
|
5637
|
-
verdict: receipt.verdict,
|
|
5638
|
-
..."corpusVersion" in receipt ? { corpusDigest: receipt.corpusVersion.corpusDigest } : {},
|
|
5639
|
-
producedAtOrdinal: receipt.producedAtOrdinal
|
|
5640
|
-
})));
|
|
5641
|
-
}
|
|
5642
|
-
function lowerTrustSharesFor(input) {
|
|
5643
|
-
const products = /* @__PURE__ */ new Map();
|
|
5644
|
-
for (const row of readBundles(input.knowledgeRoot, input.resolveTrustPriors)) {
|
|
5645
|
-
const share = products.get(row.product) ?? { product: row.product, active: 0, lowerTrust: 0 };
|
|
5646
|
-
products.set(row.product, share);
|
|
5647
|
-
if (!row.active) continue;
|
|
5648
|
-
share.active += 1;
|
|
5649
|
-
if ((0, import_agent_qa_schema34.strongestPromotionPath)(row.lines) === "gate1-lower-trust") share.lowerTrust += 1;
|
|
5650
|
-
}
|
|
5651
|
-
return [...products.values()];
|
|
5652
|
-
}
|
|
5653
|
-
|
|
5654
5464
|
// src/feedback/mark-evidence-plan.ts
|
|
5655
5465
|
var import_node_path23 = require("node:path");
|
|
5656
|
-
var
|
|
5466
|
+
var import_agent_qa_schema33 = require("@vostride/agent-qa-schema");
|
|
5657
5467
|
var MARK_EVIDENCE_TOKEN_PREFIX = "mark:";
|
|
5658
5468
|
function markEvidenceEvent(effect, markId, buildOrdinal) {
|
|
5659
5469
|
const token = `${MARK_EVIDENCE_TOKEN_PREFIX}${markId}`;
|
|
5660
5470
|
if (effect.direction === "confirm") {
|
|
5661
|
-
return { type: "confirmed", evidenceToken: (0,
|
|
5471
|
+
return { type: "confirmed", evidenceToken: (0, import_agent_qa_schema33.asEvidenceToken)(token), curationJobId: token, buildOrdinal, origin: "user" };
|
|
5662
5472
|
}
|
|
5663
5473
|
return {
|
|
5664
5474
|
type: "overturned",
|
|
5665
5475
|
markId,
|
|
5666
|
-
evidenceToken: (0,
|
|
5476
|
+
evidenceToken: (0, import_agent_qa_schema33.asEvidenceToken)(
|
|
5667
5477
|
`${token}:${effect.overturnsEvidenceToken}:${effect.overturnsCurationJobId}`
|
|
5668
5478
|
),
|
|
5669
5479
|
curationJobId: token,
|
|
@@ -5703,7 +5513,7 @@ function planMarkEvidence(input) {
|
|
|
5703
5513
|
for (const member of input.handoff?.tests ?? []) {
|
|
5704
5514
|
for (const step of member.steps) {
|
|
5705
5515
|
const canaryId = canaryOutcomeObservationId({
|
|
5706
|
-
candidateId: (0,
|
|
5516
|
+
candidateId: (0, import_agent_qa_schema33.asRecordId)(recordId),
|
|
5707
5517
|
runId: input.mark.runId,
|
|
5708
5518
|
testId: member.testId,
|
|
5709
5519
|
testIndex: member.testIndex,
|
|
@@ -5711,8 +5521,8 @@ function planMarkEvidence(input) {
|
|
|
5711
5521
|
});
|
|
5712
5522
|
observations.add(canaryId);
|
|
5713
5523
|
observations.add(`${input.mark.runId}:test-${member.testIndex}:step-${step.stepIndex}`);
|
|
5714
|
-
for (const anchor of [...bundleAnchors, ...(0,
|
|
5715
|
-
evidenceTokens.add((0,
|
|
5524
|
+
for (const anchor of [...bundleAnchors, ...(0, import_agent_qa_schema33.exercisedAnchors)(step)]) {
|
|
5525
|
+
evidenceTokens.add((0, import_agent_qa_schema33.deriveEvidenceToken)({
|
|
5716
5526
|
attributingObservationId: canaryId,
|
|
5717
5527
|
anchor,
|
|
5718
5528
|
buildOrdinal: input.handoff.buildOrdinal
|
|
@@ -5720,18 +5530,6 @@ function planMarkEvidence(input) {
|
|
|
5720
5530
|
}
|
|
5721
5531
|
}
|
|
5722
5532
|
}
|
|
5723
|
-
for (const receipt of readGateReceipts(entry.dir, (0, import_agent_qa_schema35.asRecordId)(recordId)) ?? []) {
|
|
5724
|
-
if (!(0, import_agent_qa_schema35.isPromotionReceipt)(receipt) && receipt.gate === 2 && receipt.runId === input.mark.runId) {
|
|
5725
|
-
observations.add(receipt.attributedObservationId);
|
|
5726
|
-
for (const anchor of bundleAnchors) {
|
|
5727
|
-
evidenceTokens.add((0, import_agent_qa_schema35.deriveEvidenceToken)({
|
|
5728
|
-
attributingObservationId: receipt.attributedObservationId,
|
|
5729
|
-
anchor,
|
|
5730
|
-
buildOrdinal: receipt.producedAtOrdinal
|
|
5731
|
-
}));
|
|
5732
|
-
}
|
|
5733
|
-
}
|
|
5734
|
-
}
|
|
5735
5533
|
const jobs = new Set(input.curationJobIds ?? []);
|
|
5736
5534
|
const provenance = bundle.provenance;
|
|
5737
5535
|
if (provenance.mode === "run-linked" && provenance.runId === input.mark.runId && provenance.curationJobId !== void 0) jobs.add(provenance.curationJobId);
|
|
@@ -5741,10 +5539,10 @@ function planMarkEvidence(input) {
|
|
|
5741
5539
|
bundle.manifest.createdAtOrdinal,
|
|
5742
5540
|
...bundle.events.map((event) => event.buildOrdinal)
|
|
5743
5541
|
) + 1;
|
|
5744
|
-
const seen = new Set(input.mark.markId === void 0 ? [] : bundle.events.map(
|
|
5542
|
+
const seen = new Set(input.mark.markId === void 0 ? [] : bundle.events.map(import_agent_qa_schema33.eventDedupKey));
|
|
5745
5543
|
const effects = [];
|
|
5746
5544
|
const add = (effect) => {
|
|
5747
|
-
const key = (0,
|
|
5545
|
+
const key = (0, import_agent_qa_schema33.eventDedupKey)(markEvidenceEvent(effect, input.mark.markId ?? "", buildOrdinal));
|
|
5748
5546
|
effects.push({ ...effect, alreadyAppended: seen.has(key) });
|
|
5749
5547
|
seen.add(key);
|
|
5750
5548
|
};
|
|
@@ -5805,8 +5603,6 @@ function projectMarkEvidenceOutcome(plan, options) {
|
|
|
5805
5603
|
QUARANTINE_LEDGER_FILENAME,
|
|
5806
5604
|
canaryAttributionsFor,
|
|
5807
5605
|
canaryOutcomeObservationId,
|
|
5808
|
-
canaryPostureFactsFor,
|
|
5809
|
-
candidateInjectionFor,
|
|
5810
5606
|
createAuthoringReader,
|
|
5811
5607
|
diffSince,
|
|
5812
5608
|
foldQuarantineLedgerState,
|
|
@@ -5814,7 +5610,6 @@ function projectMarkEvidenceOutcome(plan, options) {
|
|
|
5814
5610
|
hydrateRows,
|
|
5815
5611
|
inspectRecords,
|
|
5816
5612
|
listBundles,
|
|
5817
|
-
lowerTrustSharesFor,
|
|
5818
5613
|
markEvidenceEvent,
|
|
5819
5614
|
openKnowledgeReader,
|
|
5820
5615
|
planMarkEvidence,
|
|
@@ -5823,7 +5618,6 @@ function projectMarkEvidenceOutcome(plan, options) {
|
|
|
5823
5618
|
readIndexRows,
|
|
5824
5619
|
readQuarantineLedger,
|
|
5825
5620
|
showRecord,
|
|
5826
|
-
showRecords
|
|
5827
|
-
standingReceiptDigestsFor
|
|
5621
|
+
showRecords
|
|
5828
5622
|
});
|
|
5829
5623
|
//# sourceMappingURL=reader.cjs.map
|