@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/index.js
CHANGED
|
@@ -300,12 +300,12 @@ function verifyBundleIntegrity(bundleDir2) {
|
|
|
300
300
|
}
|
|
301
301
|
return { ok: violations.length === 0, violations };
|
|
302
302
|
}
|
|
303
|
-
function deriveBundleTrust(loaded
|
|
303
|
+
function deriveBundleTrust(loaded) {
|
|
304
304
|
return foldBundleTrust(loaded.events, {
|
|
305
305
|
originClass: loaded.provenance.originClass,
|
|
306
306
|
evidenceIncomplete: loaded.manifest.evidenceIncomplete,
|
|
307
307
|
createdAtOrdinal: loaded.manifest.createdAtOrdinal
|
|
308
|
-
}
|
|
308
|
+
});
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
// src/maintenance-scan.ts
|
|
@@ -1762,11 +1762,11 @@ function anchorMatches(bundle, queryAnchor) {
|
|
|
1762
1762
|
return normalized.t === "el" && queryAnchor.t === "el" && normalized.role === queryAnchor.role && normalized.name === queryAnchor.name;
|
|
1763
1763
|
});
|
|
1764
1764
|
}
|
|
1765
|
-
function servableHit(dir
|
|
1765
|
+
function servableHit(dir) {
|
|
1766
1766
|
const outcome = loadBundle(dir.dir);
|
|
1767
1767
|
if (outcome.kind !== "loaded") return void 0;
|
|
1768
1768
|
if (!verifyBundleIntegrity(dir.dir).ok) return void 0;
|
|
1769
|
-
const trustState = deriveBundleTrust(outcome.bundle
|
|
1769
|
+
const trustState = deriveBundleTrust(outcome.bundle);
|
|
1770
1770
|
return isServable(trustState) ? toHit(outcome.bundle, trustState, dir.product) : void 0;
|
|
1771
1771
|
}
|
|
1772
1772
|
function scanBundlesWithPosture(opts, servingOnly) {
|
|
@@ -1778,7 +1778,7 @@ function scanBundlesWithPosture(opts, servingOnly) {
|
|
|
1778
1778
|
const outcome = loadBundle(entry.dir);
|
|
1779
1779
|
if (outcome.kind !== "loaded") continue;
|
|
1780
1780
|
if (!verifyBundleIntegrity(entry.dir).ok) continue;
|
|
1781
|
-
const trustState = deriveBundleTrust(outcome.bundle
|
|
1781
|
+
const trustState = deriveBundleTrust(outcome.bundle);
|
|
1782
1782
|
if (servingOnly && !isServable(trustState)) continue;
|
|
1783
1783
|
if (!textMatches(outcome.bundle, queryTokens)) continue;
|
|
1784
1784
|
if (!anchorMatches(outcome.bundle, queryAnchor)) continue;
|
|
@@ -1798,7 +1798,7 @@ function scanBundlesForRetrieval(opts) {
|
|
|
1798
1798
|
function scanBundleById(opts) {
|
|
1799
1799
|
for (const entry of enumerateBundleDirs(opts.knowledgeRoot)) {
|
|
1800
1800
|
if (basename3(entry.dir) !== opts.bundleId) continue;
|
|
1801
|
-
const hit = servableHit(entry
|
|
1801
|
+
const hit = servableHit(entry);
|
|
1802
1802
|
if (hit !== void 0) return hit;
|
|
1803
1803
|
}
|
|
1804
1804
|
return void 0;
|
|
@@ -2173,9 +2173,7 @@ function diffSince(options) {
|
|
|
2173
2173
|
recordId: bundle.manifest.id,
|
|
2174
2174
|
change: "added",
|
|
2175
2175
|
atOrdinal: earliestOrdinal,
|
|
2176
|
-
//
|
|
2177
|
-
// records one — no `curationJobId` match is needed, because no event produced this
|
|
2178
|
-
// change. A standalone bundle names no run and gets no key.
|
|
2176
|
+
// A run-linked bundle's appearance is the run's doing; a standalone bundle gets no run key.
|
|
2179
2177
|
...bundle.provenance.mode === "run-linked" ? { sourceRunId: bundle.provenance.runId } : {}
|
|
2180
2178
|
}));
|
|
2181
2179
|
eventLowerBound = earliestOrdinal;
|
|
@@ -2263,12 +2261,12 @@ function foldCurationSnapshot(effects) {
|
|
|
2263
2261
|
}
|
|
2264
2262
|
const rows = [...groups].map(([recordId, changes]) => {
|
|
2265
2263
|
const bucket = CURATION_BUCKET_PRECEDENCE.find((value) => changes.some((e) => e.bucket === value));
|
|
2266
|
-
const
|
|
2264
|
+
const latest = changes.filter((e) => e.bucket === "superseded").sort((a, b) => b.change.atOrdinal - a.change.atOrdinal)[0];
|
|
2267
2265
|
return {
|
|
2268
2266
|
recordId,
|
|
2269
2267
|
bucket,
|
|
2270
2268
|
changes,
|
|
2271
|
-
...
|
|
2269
|
+
...latest === void 0 ? {} : { byRecordId: latest.change.byRecordId }
|
|
2272
2270
|
};
|
|
2273
2271
|
});
|
|
2274
2272
|
for (const row of rows) {
|
|
@@ -2299,7 +2297,6 @@ import { join as join10 } from "node:path";
|
|
|
2299
2297
|
import { z as z5 } from "zod";
|
|
2300
2298
|
import {
|
|
2301
2299
|
canonicalJson as canonicalJson5,
|
|
2302
|
-
CROSS_CHECKS,
|
|
2303
2300
|
sha256hex as sha256hex2
|
|
2304
2301
|
} from "@vostride/agent-qa-schema";
|
|
2305
2302
|
|
|
@@ -2441,7 +2438,6 @@ function publishStagedQueueEntry(stagingDir, finalDir, queueDir) {
|
|
|
2441
2438
|
// src/canary-emit.ts
|
|
2442
2439
|
var CANARY_QUEUE_SCHEMA_VERSION = 2;
|
|
2443
2440
|
var PAYLOAD_BENEFITS = ["exercised-benefited", "rode-along", "exercised-harmed"];
|
|
2444
|
-
var PAYLOAD_STATE_VALIDITIES = ["valid", "stale", "unknown"];
|
|
2445
2441
|
var canaryOutcomePayloadBaseShape = {
|
|
2446
2442
|
jobKind: z5.literal("canary-outcome"),
|
|
2447
2443
|
candidateId: z5.string().min(1),
|
|
@@ -2455,28 +2451,10 @@ var canaryOutcomePayloadBaseShape = {
|
|
|
2455
2451
|
attribution: z5.string(),
|
|
2456
2452
|
briefDigest: z5.string().min(1)
|
|
2457
2453
|
};
|
|
2458
|
-
var count = z5.number().int().nonnegative();
|
|
2459
|
-
var digest2 = z5.string().regex(/^[0-9a-f]{64}$/);
|
|
2460
2454
|
var canaryOutcomePayloadSchema = z5.object({
|
|
2461
2455
|
...canaryOutcomePayloadBaseShape,
|
|
2462
2456
|
schemaVersion: z5.literal(CANARY_QUEUE_SCHEMA_VERSION),
|
|
2463
|
-
benefit: z5.enum(PAYLOAD_BENEFITS)
|
|
2464
|
-
stateValidity: z5.enum(PAYLOAD_STATE_VALIDITIES),
|
|
2465
|
-
corpusDigest: digest2.optional(),
|
|
2466
|
-
observedStateDigest: digest2.optional(),
|
|
2467
|
-
ablation: z5.object({
|
|
2468
|
-
crossCheck: z5.enum(CROSS_CHECKS),
|
|
2469
|
-
k: z5.number().int().min(3),
|
|
2470
|
-
baseSeed: z5.number().int(),
|
|
2471
|
-
seeds: z5.array(z5.number().int()),
|
|
2472
|
-
seedHonored: z5.boolean(),
|
|
2473
|
-
spend: z5.object({
|
|
2474
|
-
modelCalls: count,
|
|
2475
|
-
screens: count,
|
|
2476
|
-
promptTokens: count,
|
|
2477
|
-
completionTokens: count
|
|
2478
|
-
}).strict()
|
|
2479
|
-
}).strict().optional()
|
|
2457
|
+
benefit: z5.enum(PAYLOAD_BENEFITS)
|
|
2480
2458
|
}).strict();
|
|
2481
2459
|
var diagnosticShape = { emittedAt: z5.string().optional() };
|
|
2482
2460
|
var canaryOutcomeAddressFieldsSchema = canaryOutcomePayloadSchema.extend(diagnosticShape);
|
|
@@ -2504,10 +2482,6 @@ function enqueueCanaryOutcome(knowledgeRoot, outcome) {
|
|
|
2504
2482
|
stepIndex: outcome.stepIndex,
|
|
2505
2483
|
outcome: outcome.runOutcome,
|
|
2506
2484
|
benefit: outcome.benefit,
|
|
2507
|
-
stateValidity: outcome.stateValidity,
|
|
2508
|
-
...outcome.corpusDigest === void 0 ? {} : { corpusDigest: outcome.corpusDigest },
|
|
2509
|
-
...outcome.observedStateDigest === void 0 ? {} : { observedStateDigest: outcome.observedStateDigest },
|
|
2510
|
-
...outcome.ablation === void 0 ? {} : { ablation: outcome.ablation },
|
|
2511
2485
|
exercisedAnchor: outcome.exercisedAnchor,
|
|
2512
2486
|
attribution: outcome.attribution,
|
|
2513
2487
|
briefDigest: outcome.briefDigest
|
|
@@ -2552,7 +2526,7 @@ var ADDRESSING_LEDGER_DB_FILE = "entity-addresses.db";
|
|
|
2552
2526
|
var AddressingLedgerSchemaVersionError = class extends Error {
|
|
2553
2527
|
constructor(path, expected, found) {
|
|
2554
2528
|
super(
|
|
2555
|
-
`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
|
|
2529
|
+
`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.`
|
|
2556
2530
|
);
|
|
2557
2531
|
this.path = path;
|
|
2558
2532
|
this.expected = expected;
|
|
@@ -2580,19 +2554,14 @@ var SCHEMA_STATEMENTS = [
|
|
|
2580
2554
|
`CREATE TRIGGER IF NOT EXISTS addresses_are_append_only
|
|
2581
2555
|
BEFORE DELETE ON addresses
|
|
2582
2556
|
BEGIN
|
|
2583
|
-
SELECT RAISE(ABORT, 'the addressing ledger never deletes an address
|
|
2557
|
+
SELECT RAISE(ABORT, 'the addressing ledger never deletes an address');
|
|
2584
2558
|
END`,
|
|
2585
2559
|
`CREATE TRIGGER IF NOT EXISTS addresses_are_immutable
|
|
2586
2560
|
BEFORE UPDATE ON addresses
|
|
2587
2561
|
BEGIN
|
|
2588
|
-
SELECT RAISE(ABORT, 'a minted address never changes
|
|
2562
|
+
SELECT RAISE(ABORT, 'a minted address never changes');
|
|
2589
2563
|
END`,
|
|
2590
|
-
// Renames
|
|
2591
|
-
// reason is the trigger directly above: a rename is a fact recorded LATER about a row that
|
|
2592
|
-
// must never change, so writing it onto the address row would require exactly the statement
|
|
2593
|
-
// this ledger forbids. Additive, and the stamped version does not move — nothing between
|
|
2594
|
-
// this milestone's releases has written a v1 file, and `IF NOT EXISTS` heals a development
|
|
2595
|
-
// one. D-04's never-rebuild law is about ORDINALS, which no statement here touches.
|
|
2564
|
+
// Renames get their own table: writing one onto an immutable address row would need an update.
|
|
2596
2565
|
`CREATE TABLE IF NOT EXISTS target_renames (
|
|
2597
2566
|
from_slug TEXT NOT NULL PRIMARY KEY,
|
|
2598
2567
|
to_slug TEXT NOT NULL,
|
|
@@ -3014,10 +2983,7 @@ function ensureRunOutcomeTables(db) {
|
|
|
3014
2983
|
UNIQUE (product, file_path, test_name, fingerprint, build_ordinal, run_id)
|
|
3015
2984
|
);
|
|
3016
2985
|
|
|
3017
|
-
--
|
|
3018
|
-
-- rebuild as the tables above. One row per fingerprint element, ordered by seq, keyed by the
|
|
3019
|
-
-- stable test identity; run_id and build_ordinal are the provenance the fold's
|
|
3020
|
-
-- newest-evidence-wins replacement rule compares on (see projection/suite-fingerprints.ts).
|
|
2986
|
+
-- run_id and build_ordinal are what the fold's newest-evidence-wins replacement compares on.
|
|
3021
2987
|
CREATE TABLE IF NOT EXISTS suite_fingerprints (
|
|
3022
2988
|
product TEXT NOT NULL,
|
|
3023
2989
|
file_path TEXT NOT NULL,
|
|
@@ -3029,11 +2995,7 @@ function ensureRunOutcomeTables(db) {
|
|
|
3029
2995
|
PRIMARY KEY (product, file_path, test_name, seq)
|
|
3030
2996
|
);
|
|
3031
2997
|
|
|
3032
|
-
--
|
|
3033
|
-
-- construction (the CHECK admits exactly one row) because "which semantics produced this
|
|
3034
|
-
-- family" is one fact about one derived index, and a second row could only ever be a second
|
|
3035
|
-
-- answer to it. Absent is a legal state and means MISMATCH: a pre-stamp index and an index
|
|
3036
|
-
-- whose file was deleted both read as absent, and both want the same rebuild.
|
|
2998
|
+
-- One fold-semantics stamp for the tables above; an absent row reads as a mismatch.
|
|
3037
2999
|
CREATE TABLE IF NOT EXISTS run_outcome_projection_version (
|
|
3038
3000
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
3039
3001
|
version INTEGER NOT NULL
|
|
@@ -3662,7 +3624,7 @@ import {
|
|
|
3662
3624
|
|
|
3663
3625
|
// src/index-reader.ts
|
|
3664
3626
|
import { existsSync as existsSync8, statSync as statSync2 } from "node:fs";
|
|
3665
|
-
import { basename as
|
|
3627
|
+
import { basename as basename4, join as join15 } from "node:path";
|
|
3666
3628
|
import {
|
|
3667
3629
|
canonicalJson as canonicalJson9,
|
|
3668
3630
|
normalizeAnchor as normalizeAnchor3
|
|
@@ -3742,11 +3704,10 @@ function buildLexicalMatchExpression(text) {
|
|
|
3742
3704
|
|
|
3743
3705
|
// src/promotion-gate-input.ts
|
|
3744
3706
|
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
|
|
3745
|
-
import {
|
|
3707
|
+
import { join as join14 } from "node:path";
|
|
3746
3708
|
import {
|
|
3747
3709
|
canonicalJson as canonicalJson7,
|
|
3748
3710
|
guardDistilledObservation,
|
|
3749
|
-
guardTrustPriorTable,
|
|
3750
3711
|
isPromotionReceipt as isPromotionReceipt2,
|
|
3751
3712
|
survivingOutcomeEvents as survivingOutcomeEvents4,
|
|
3752
3713
|
supersessionKey as supersessionKey2
|
|
@@ -3772,12 +3733,12 @@ function compareSnapshots(left, right) {
|
|
|
3772
3733
|
}
|
|
3773
3734
|
function resolveAsOfBuildOrdinal(bundles, explicit) {
|
|
3774
3735
|
if (explicit !== void 0) return explicit;
|
|
3775
|
-
let
|
|
3736
|
+
let latest = 0;
|
|
3776
3737
|
for (const bundle of bundles) {
|
|
3777
|
-
|
|
3778
|
-
for (const event of bundle.events)
|
|
3738
|
+
latest = Math.max(latest, bundle.createdAtOrdinal);
|
|
3739
|
+
for (const event of bundle.events) latest = Math.max(latest, event.buildOrdinal);
|
|
3779
3740
|
}
|
|
3780
|
-
return
|
|
3741
|
+
return latest;
|
|
3781
3742
|
}
|
|
3782
3743
|
function windowOpenOrdinal(asOfBuildOrdinal, windowBuilds) {
|
|
3783
3744
|
if (!Number.isInteger(windowBuilds) || windowBuilds < 1) {
|
|
@@ -3883,12 +3844,6 @@ function foldFirstSeenAnchorsByScope(bundles, options) {
|
|
|
3883
3844
|
}
|
|
3884
3845
|
|
|
3885
3846
|
// src/promotion-gate-input.ts
|
|
3886
|
-
function snapshotTrustPriors(priors) {
|
|
3887
|
-
if (priors === void 0) return void 0;
|
|
3888
|
-
const snapshot = guardTrustPriorTable(priors);
|
|
3889
|
-
for (const row of Object.values(snapshot)) Object.freeze(row);
|
|
3890
|
-
return Object.freeze(snapshot);
|
|
3891
|
-
}
|
|
3892
3847
|
function promotionObservations(bundleDir2) {
|
|
3893
3848
|
const file = join14(bundleDir2, "observations.jsonl");
|
|
3894
3849
|
if (!existsSync7(file)) return [];
|
|
@@ -3908,20 +3863,12 @@ function memoryOffForBundle(knowledgeRoot, bundle) {
|
|
|
3908
3863
|
);
|
|
3909
3864
|
}
|
|
3910
3865
|
function assemblePromotionGateInput(input) {
|
|
3911
|
-
const trust = deriveBundleTrust(input.bundle
|
|
3866
|
+
const trust = deriveBundleTrust(input.bundle);
|
|
3912
3867
|
const survivingEvents = survivingOutcomeEvents4(input.bundle.events);
|
|
3913
3868
|
const runLinkedProvenance = input.bundle.provenance.mode === "run-linked" ? input.bundle.provenance : void 0;
|
|
3914
3869
|
const gateLines = readGateReceipts(input.bundleDir, input.bundle.manifest.id) ?? [];
|
|
3915
|
-
const provenance = candidateProvenanceOf(input.bundleDir, input.bundle);
|
|
3916
|
-
const posture = input.resolvePromotionPosture?.({
|
|
3917
|
-
id: input.bundle.manifest.id,
|
|
3918
|
-
product: basename4(dirname9(dirname9(input.bundleDir))),
|
|
3919
|
-
scope: input.bundle.frontmatter.scope,
|
|
3920
|
-
provenance
|
|
3921
|
-
});
|
|
3922
3870
|
return {
|
|
3923
3871
|
gateReceipts: gateLines.filter((line) => !isPromotionReceipt2(line)),
|
|
3924
|
-
...posture === void 0 ? {} : { gatePosture: posture },
|
|
3925
3872
|
kind: input.bundle.frontmatter.kind,
|
|
3926
3873
|
...input.bundle.frontmatter.subtype === void 0 ? {} : { subtype: input.bundle.frontmatter.subtype },
|
|
3927
3874
|
status: trust.status,
|
|
@@ -3942,28 +3889,15 @@ function assemblePromotionGateInput(input) {
|
|
|
3942
3889
|
memoryOffForAnchorGroup: memoryOffForBundle(input.knowledgeRoot, input.bundle)
|
|
3943
3890
|
};
|
|
3944
3891
|
}
|
|
3945
|
-
function candidateProvenanceOf(bundleDir2, bundle) {
|
|
3946
|
-
const runLinked = bundle.provenance.mode === "run-linked" ? bundle.provenance : void 0;
|
|
3947
|
-
const gateLines = readGateReceipts(bundleDir2, bundle.manifest.id) ?? [];
|
|
3948
|
-
return {
|
|
3949
|
-
runIds: runLinked === void 0 ? [] : [runLinked.runId],
|
|
3950
|
-
receiptDigests: gateLines.map((line) => line.receiptDigest),
|
|
3951
|
-
capturedAtOrdinals: [...new Set([
|
|
3952
|
-
...runLinked?.sourceBuildOrdinal === void 0 ? [] : [runLinked.sourceBuildOrdinal],
|
|
3953
|
-
...survivingOutcomeEvents4(bundle.events).map((event) => event.buildOrdinal)
|
|
3954
|
-
].filter(Number.isInteger))].sort((left, right) => left - right)
|
|
3955
|
-
};
|
|
3956
|
-
}
|
|
3957
3892
|
|
|
3958
3893
|
// src/trust-prior-context.ts
|
|
3959
3894
|
import { createHash as createHash2 } from "node:crypto";
|
|
3960
|
-
import { canonicalJson as canonicalJson8,
|
|
3961
|
-
function effectivePriorDigest(
|
|
3962
|
-
|
|
3963
|
-
return createHash2("sha256").update(canonicalJson8({ ...ORIGIN_PRIORS, ...table })).digest("hex");
|
|
3895
|
+
import { canonicalJson as canonicalJson8, ORIGIN_PRIORS } from "@vostride/agent-qa-schema";
|
|
3896
|
+
function effectivePriorDigest() {
|
|
3897
|
+
return createHash2("sha256").update(canonicalJson8({ ...ORIGIN_PRIORS })).digest("hex");
|
|
3964
3898
|
}
|
|
3965
|
-
function indexTrustEpochMatches(db,
|
|
3966
|
-
return db.prepare("SELECT v FROM meta WHERE k = 'trust_prior_digest'").get()?.v ===
|
|
3899
|
+
function indexTrustEpochMatches(db, digest2) {
|
|
3900
|
+
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;
|
|
3967
3901
|
}
|
|
3968
3902
|
var TrustPriorEpochMismatch = class extends Error {
|
|
3969
3903
|
constructor() {
|
|
@@ -4036,12 +3970,12 @@ function rowToIndexedRecord(row) {
|
|
|
4036
3970
|
};
|
|
4037
3971
|
}
|
|
4038
3972
|
function safeBundleDir(knowledgeRoot, hit) {
|
|
4039
|
-
if (hit.product === "" || hit.product === "." || hit.product === ".." || hit.product !==
|
|
3973
|
+
if (hit.product === "" || hit.product === "." || hit.product === ".." || hit.product !== basename4(hit.product) || hit.bundleId === "" || hit.bundleId === "." || hit.bundleId === ".." || hit.bundleId !== basename4(hit.bundleId)) {
|
|
4040
3974
|
return void 0;
|
|
4041
3975
|
}
|
|
4042
3976
|
return join15(knowledgeRoot, "memory", hit.product, "bundles", hit.bundleId);
|
|
4043
3977
|
}
|
|
4044
|
-
function recheckAuthoritativeHits(knowledgeRoot, hits, audit
|
|
3978
|
+
function recheckAuthoritativeHits(knowledgeRoot, hits, audit) {
|
|
4045
3979
|
const refreshed = [];
|
|
4046
3980
|
for (const hit of hits) {
|
|
4047
3981
|
const bundleDir2 = safeBundleDir(knowledgeRoot, hit);
|
|
@@ -4050,7 +3984,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
|
|
|
4050
3984
|
if (!verifyBundleIntegrity(bundleDir2).ok) continue;
|
|
4051
3985
|
const outcome = loadBundle(bundleDir2);
|
|
4052
3986
|
if (outcome.kind !== "loaded" || outcome.bundle.manifest.id !== hit.bundleId) continue;
|
|
4053
|
-
const trust = deriveBundleTrust(outcome.bundle
|
|
3987
|
+
const trust = deriveBundleTrust(outcome.bundle);
|
|
4054
3988
|
if (!audit && !isServable(trust)) continue;
|
|
4055
3989
|
refreshed.push({
|
|
4056
3990
|
...hit,
|
|
@@ -4070,8 +4004,7 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
|
|
|
4070
4004
|
vettedCandidateInput: assemblePromotionGateInput({
|
|
4071
4005
|
knowledgeRoot,
|
|
4072
4006
|
bundleDir: bundleDir2,
|
|
4073
|
-
bundle: outcome.bundle
|
|
4074
|
-
priors
|
|
4007
|
+
bundle: outcome.bundle
|
|
4075
4008
|
})
|
|
4076
4009
|
});
|
|
4077
4010
|
} catch {
|
|
@@ -4079,8 +4012,8 @@ function recheckAuthoritativeHits(knowledgeRoot, hits, audit, priors) {
|
|
|
4079
4012
|
}
|
|
4080
4013
|
return refreshed;
|
|
4081
4014
|
}
|
|
4082
|
-
function recheckHits(knowledgeRoot, hits
|
|
4083
|
-
return recheckAuthoritativeHits(knowledgeRoot, hits, false
|
|
4015
|
+
function recheckHits(knowledgeRoot, hits) {
|
|
4016
|
+
return recheckAuthoritativeHits(knowledgeRoot, hits, false).map((hit) => {
|
|
4084
4017
|
const {
|
|
4085
4018
|
anchors: _anchors,
|
|
4086
4019
|
scope: _scope,
|
|
@@ -4149,52 +4082,50 @@ function cosineDistance(query, candidate2) {
|
|
|
4149
4082
|
}
|
|
4150
4083
|
return 1 - dot;
|
|
4151
4084
|
}
|
|
4152
|
-
function scanReader(knowledgeRoot
|
|
4085
|
+
function scanReader(knowledgeRoot) {
|
|
4153
4086
|
const reader = {
|
|
4154
4087
|
source: "scan",
|
|
4155
4088
|
vec: "none",
|
|
4156
4089
|
getById(bundleId) {
|
|
4157
|
-
return scanBundleById({ knowledgeRoot, bundleId
|
|
4090
|
+
return scanBundleById({ knowledgeRoot, bundleId });
|
|
4158
4091
|
},
|
|
4159
4092
|
searchLexical(text, opts = {}) {
|
|
4160
|
-
return scanBundles({ knowledgeRoot, text, ...opts
|
|
4093
|
+
return scanBundles({ knowledgeRoot, text, ...opts });
|
|
4161
4094
|
},
|
|
4162
4095
|
lookupAnchor(anchor, opts = {}) {
|
|
4163
|
-
return scanBundles({ knowledgeRoot, anchor: normalizeAnchor3(anchor), ...opts
|
|
4096
|
+
return scanBundles({ knowledgeRoot, anchor: normalizeAnchor3(anchor), ...opts });
|
|
4164
4097
|
},
|
|
4165
4098
|
searchDense() {
|
|
4166
4099
|
return [];
|
|
4167
4100
|
},
|
|
4168
4101
|
recheck(hits) {
|
|
4169
|
-
return recheckHits(knowledgeRoot, hits
|
|
4102
|
+
return recheckHits(knowledgeRoot, hits);
|
|
4170
4103
|
},
|
|
4171
4104
|
close() {
|
|
4172
4105
|
},
|
|
4173
4106
|
async [RUN_RETRIEVAL](operation) {
|
|
4174
4107
|
return operation({
|
|
4175
4108
|
knowledgeRoot,
|
|
4176
|
-
priors,
|
|
4177
4109
|
source: "scan",
|
|
4178
4110
|
vec: "none",
|
|
4179
4111
|
connection: void 0,
|
|
4180
4112
|
reader,
|
|
4181
4113
|
scan: (text, anchor) => scanBundlesForRetrieval({
|
|
4182
4114
|
knowledgeRoot,
|
|
4183
|
-
priors,
|
|
4184
4115
|
...text === void 0 ? {} : { text },
|
|
4185
4116
|
...anchor === void 0 ? {} : { anchor }
|
|
4186
4117
|
}),
|
|
4187
|
-
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit
|
|
4118
|
+
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
|
|
4188
4119
|
});
|
|
4189
4120
|
}
|
|
4190
4121
|
};
|
|
4191
4122
|
return reader;
|
|
4192
4123
|
}
|
|
4193
|
-
function indexReader(knowledgeRoot, connection
|
|
4124
|
+
function indexReader(knowledgeRoot, connection) {
|
|
4194
4125
|
let closed = false;
|
|
4195
4126
|
const { db } = connection;
|
|
4196
4127
|
const activeProfile = resolveActiveProfile(db);
|
|
4197
|
-
const priorDigest = effectivePriorDigest(
|
|
4128
|
+
const priorDigest = effectivePriorDigest();
|
|
4198
4129
|
let snapshotDepth = 0;
|
|
4199
4130
|
function assertTrustEpoch() {
|
|
4200
4131
|
if (!indexTrustEpochMatches(db, priorDigest)) throw new TrustPriorEpochMismatch();
|
|
@@ -4212,7 +4143,7 @@ function indexReader(knowledgeRoot, connection, priors) {
|
|
|
4212
4143
|
});
|
|
4213
4144
|
}
|
|
4214
4145
|
function recheckCurrent(hits) {
|
|
4215
|
-
return recheckHits(knowledgeRoot, hits
|
|
4146
|
+
return recheckHits(knowledgeRoot, hits);
|
|
4216
4147
|
}
|
|
4217
4148
|
function denseVec02(embedding, opts) {
|
|
4218
4149
|
const k = queryLimit(opts.k);
|
|
@@ -4383,13 +4314,12 @@ function indexReader(knowledgeRoot, connection, priors) {
|
|
|
4383
4314
|
try {
|
|
4384
4315
|
return await operation({
|
|
4385
4316
|
knowledgeRoot,
|
|
4386
|
-
priors,
|
|
4387
4317
|
source: "index",
|
|
4388
4318
|
vec: connection.vec,
|
|
4389
4319
|
connection,
|
|
4390
4320
|
reader: snapshotReader,
|
|
4391
4321
|
scan: void 0,
|
|
4392
|
-
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit
|
|
4322
|
+
recheck: (hits, audit) => recheckAuthoritativeHits(knowledgeRoot, hits, audit)
|
|
4393
4323
|
});
|
|
4394
4324
|
} finally {
|
|
4395
4325
|
snapshotDepth -= 1;
|
|
@@ -4406,8 +4336,8 @@ function indexReader(knowledgeRoot, connection, priors) {
|
|
|
4406
4336
|
};
|
|
4407
4337
|
return snapshotReader;
|
|
4408
4338
|
}
|
|
4409
|
-
function operationDegradingReader(knowledgeRoot, connection
|
|
4410
|
-
let delegate = indexReader(knowledgeRoot, connection
|
|
4339
|
+
function operationDegradingReader(knowledgeRoot, connection) {
|
|
4340
|
+
let delegate = indexReader(knowledgeRoot, connection);
|
|
4411
4341
|
let closed = false;
|
|
4412
4342
|
function invoke(operation) {
|
|
4413
4343
|
if (delegate.source === "scan") return operation(delegate);
|
|
@@ -4422,7 +4352,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
|
|
|
4422
4352
|
`derived index operation failed: ${errorMessage2(error)}`
|
|
4423
4353
|
);
|
|
4424
4354
|
}
|
|
4425
|
-
delegate = scanReader(knowledgeRoot
|
|
4355
|
+
delegate = scanReader(knowledgeRoot);
|
|
4426
4356
|
return operation(delegate);
|
|
4427
4357
|
}
|
|
4428
4358
|
}
|
|
@@ -4439,7 +4369,7 @@ function operationDegradingReader(knowledgeRoot, connection, priors) {
|
|
|
4439
4369
|
`derived index operation failed: ${errorMessage2(error)}`
|
|
4440
4370
|
);
|
|
4441
4371
|
}
|
|
4442
|
-
delegate = scanReader(knowledgeRoot
|
|
4372
|
+
delegate = scanReader(knowledgeRoot);
|
|
4443
4373
|
return operation(delegate);
|
|
4444
4374
|
}
|
|
4445
4375
|
}
|
|
@@ -4488,9 +4418,9 @@ function withKnowledgeReadSnapshot(reader, operation) {
|
|
|
4488
4418
|
}
|
|
4489
4419
|
return reader[RUN_RETRIEVAL](operation);
|
|
4490
4420
|
}
|
|
4491
|
-
function degrade(knowledgeRoot, reason, detail
|
|
4421
|
+
function degrade(knowledgeRoot, reason, detail) {
|
|
4492
4422
|
requestRebuildBestEffort(knowledgeRoot, reason, detail);
|
|
4493
|
-
return scanReader(knowledgeRoot
|
|
4423
|
+
return scanReader(knowledgeRoot);
|
|
4494
4424
|
}
|
|
4495
4425
|
function classifyIndexFaceWithConnection(knowledgeRoot, opts) {
|
|
4496
4426
|
if (!existsSync8(indexDbPath(knowledgeRoot))) {
|
|
@@ -4566,15 +4496,14 @@ function indexFileChangedSince(knowledgeRoot, before) {
|
|
|
4566
4496
|
return after === void 0 || after.walPresent || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs || after.size !== before.size || after.ino !== before.ino;
|
|
4567
4497
|
}
|
|
4568
4498
|
function openKnowledgeReader(knowledgeRoot, opts = {}) {
|
|
4569
|
-
const priors = snapshotTrustPriors(opts.priors);
|
|
4570
4499
|
const result = classifyIndexFaceWithConnection(knowledgeRoot, {
|
|
4571
4500
|
...opts,
|
|
4572
4501
|
inspectCheckpointedImmutably: false
|
|
4573
4502
|
});
|
|
4574
4503
|
if (result.connection === void 0) {
|
|
4575
|
-
return degrade(knowledgeRoot, result.face.reason, result.face.detail
|
|
4504
|
+
return degrade(knowledgeRoot, result.face.reason, result.face.detail);
|
|
4576
4505
|
}
|
|
4577
|
-
return operationDegradingReader(knowledgeRoot, result.connection
|
|
4506
|
+
return operationDegradingReader(knowledgeRoot, result.connection);
|
|
4578
4507
|
}
|
|
4579
4508
|
|
|
4580
4509
|
// src/query-helper.ts
|
|
@@ -5148,7 +5077,7 @@ import {
|
|
|
5148
5077
|
} from "@vostride/agent-qa-schema";
|
|
5149
5078
|
|
|
5150
5079
|
// src/embedder-acquire.ts
|
|
5151
|
-
import { dirname as
|
|
5080
|
+
import { dirname as dirname11 } from "node:path";
|
|
5152
5081
|
import {
|
|
5153
5082
|
DEFAULT_EMBEDDING_PROFILE as DEFAULT_EMBEDDING_PROFILE3,
|
|
5154
5083
|
STATIC_FLOOR_EMBEDDING_PROFILE as STATIC_FLOOR_EMBEDDING_PROFILE2
|
|
@@ -5279,7 +5208,7 @@ function wrapEmbedderWithCache({
|
|
|
5279
5208
|
// src/embedder-floor.ts
|
|
5280
5209
|
import { createHash as createHash4 } from "node:crypto";
|
|
5281
5210
|
import { existsSync as existsSync9, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
|
|
5282
|
-
import { dirname as
|
|
5211
|
+
import { dirname as dirname9, join as join16 } from "node:path";
|
|
5283
5212
|
import { fileURLToPath } from "node:url";
|
|
5284
5213
|
var PACKAGE_NAME = "@vostride/agent-qa-knowledge-local";
|
|
5285
5214
|
var ASSET_DIRECTORY = "potion-retrieval-32m";
|
|
@@ -5323,7 +5252,7 @@ function errorMessage3(error) {
|
|
|
5323
5252
|
return error instanceof Error ? error.message : String(error);
|
|
5324
5253
|
}
|
|
5325
5254
|
function packageRootFromImportMeta() {
|
|
5326
|
-
let current =
|
|
5255
|
+
let current = dirname9(fileURLToPath(import.meta.url));
|
|
5327
5256
|
while (true) {
|
|
5328
5257
|
const packageJsonPath = join16(current, "package.json");
|
|
5329
5258
|
if (existsSync9(packageJsonPath)) {
|
|
@@ -5333,7 +5262,7 @@ function packageRootFromImportMeta() {
|
|
|
5333
5262
|
} catch {
|
|
5334
5263
|
}
|
|
5335
5264
|
}
|
|
5336
|
-
const parent =
|
|
5265
|
+
const parent = dirname9(current);
|
|
5337
5266
|
if (parent === current) break;
|
|
5338
5267
|
current = parent;
|
|
5339
5268
|
}
|
|
@@ -5809,7 +5738,7 @@ import {
|
|
|
5809
5738
|
import { request } from "node:http";
|
|
5810
5739
|
import { connect } from "node:net";
|
|
5811
5740
|
import { tmpdir } from "node:os";
|
|
5812
|
-
import { basename as
|
|
5741
|
+
import { basename as basename5, dirname as dirname10, join as join18 } from "node:path";
|
|
5813
5742
|
import { z as z7 } from "zod";
|
|
5814
5743
|
var EMBEDDER_WORKER_REGISTRATION_FILE = "embedder-worker.json";
|
|
5815
5744
|
var EMBEDDER_WORKER_REGISTRATION_SCHEMA_VERSION = 2;
|
|
@@ -5896,7 +5825,7 @@ function embedderWorkerSocketPath(agentQaRoot, projectRoot, instanceId) {
|
|
|
5896
5825
|
if (process.platform === "win32") {
|
|
5897
5826
|
return `\\\\.\\pipe\\agent-qa-embedder-${hash}-${instance}`;
|
|
5898
5827
|
}
|
|
5899
|
-
const canonicalAgentQaRoot = join18(realpathSync2(
|
|
5828
|
+
const canonicalAgentQaRoot = join18(realpathSync2(dirname10(agentQaRoot)), basename5(agentQaRoot));
|
|
5900
5829
|
const socketFile = `embedder-worker-${instance}.sock`;
|
|
5901
5830
|
const projectLocal = join18(canonicalAgentQaRoot, socketFile);
|
|
5902
5831
|
if (Buffer.byteLength(projectLocal) <= EMBEDDER_WORKER_SOCKET_PATH_BUDGET_BYTES) {
|
|
@@ -5925,7 +5854,7 @@ function bestEffortFsyncDirectory3(dir) {
|
|
|
5925
5854
|
}
|
|
5926
5855
|
}
|
|
5927
5856
|
function atomicRewrite2(file, text) {
|
|
5928
|
-
const parent =
|
|
5857
|
+
const parent = dirname10(file);
|
|
5929
5858
|
mkdirSync9(parent, { recursive: true, mode: 448 });
|
|
5930
5859
|
chmodSync(parent, 448);
|
|
5931
5860
|
const temporary = `${file}.tmp-${randomUUID5()}`;
|
|
@@ -5985,7 +5914,7 @@ function sameRegistration(left, right) {
|
|
|
5985
5914
|
}
|
|
5986
5915
|
function removeEmbedderWorkerRegistration(agentQaRoot, expected, options = {}) {
|
|
5987
5916
|
const file = embedderWorkerRegistrationPath(agentQaRoot);
|
|
5988
|
-
const parent =
|
|
5917
|
+
const parent = dirname10(file);
|
|
5989
5918
|
const quarantine = `${file}.remove-${expected.instanceId}-${randomUUID5()}`;
|
|
5990
5919
|
const fsyncDirectory2 = options.fsyncDirectory ?? bestEffortFsyncDirectory3;
|
|
5991
5920
|
try {
|
|
@@ -6178,7 +6107,7 @@ function isWorkerBackedDiscovery(result) {
|
|
|
6178
6107
|
return candidate2.profile !== void 0 && candidate2.embedder !== void 0;
|
|
6179
6108
|
}
|
|
6180
6109
|
async function discoverEmbedderWorker(agentQaRoot, options = {}) {
|
|
6181
|
-
const projectRoot =
|
|
6110
|
+
const projectRoot = dirname11(agentQaRoot);
|
|
6182
6111
|
const outcome = readEmbedderWorkerRegistration(agentQaRoot);
|
|
6183
6112
|
if (outcome.kind !== "parsed") return { kind: "no-worker" };
|
|
6184
6113
|
const { registration } = outcome;
|
|
@@ -6702,7 +6631,6 @@ function anchorSeedLeg(db, normalizedAnchors, scope) {
|
|
|
6702
6631
|
// src/retrieval/rerank.ts
|
|
6703
6632
|
import {
|
|
6704
6633
|
COLD_START_TRUST_DISCOUNT,
|
|
6705
|
-
LOWER_TRUST_PATH_DISCOUNT,
|
|
6706
6634
|
isVettedCandidate,
|
|
6707
6635
|
supersessionKey as supersessionKey3
|
|
6708
6636
|
} from "@vostride/agent-qa-schema";
|
|
@@ -6749,13 +6677,11 @@ function applyLifecycleTrustTreatments(entries, asOfBuild) {
|
|
|
6749
6677
|
}
|
|
6750
6678
|
const unverified = entry.vettedCandidateInput !== void 0 && isVettedCandidate(entry.vettedCandidateInput);
|
|
6751
6679
|
if (unverified) trust *= COLD_START_TRUST_DISCOUNT;
|
|
6752
|
-
if (entry.lowerTrust === true) trust *= LOWER_TRUST_PATH_DISCOUNT;
|
|
6753
6680
|
return {
|
|
6754
6681
|
...base,
|
|
6755
6682
|
trust,
|
|
6756
6683
|
...unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal },
|
|
6757
|
-
...unverified ? { unverified: true } : {}
|
|
6758
|
-
...entry.lowerTrust === true ? { lowerTrust: true } : {}
|
|
6684
|
+
...unverified ? { unverified: true } : {}
|
|
6759
6685
|
};
|
|
6760
6686
|
});
|
|
6761
6687
|
}
|
|
@@ -6814,9 +6740,9 @@ function applyDiversityCaps(entries, audit = false) {
|
|
|
6814
6740
|
return entries.filter((entry) => {
|
|
6815
6741
|
const key = primaryDiversityKey(entry);
|
|
6816
6742
|
if (key === void 0) return true;
|
|
6817
|
-
const
|
|
6818
|
-
if (
|
|
6819
|
-
counts.set(key,
|
|
6743
|
+
const count = counts.get(key) ?? 0;
|
|
6744
|
+
if (count >= DIVERSITY_CAP_PER_ANCHOR) return false;
|
|
6745
|
+
counts.set(key, count + 1);
|
|
6820
6746
|
return true;
|
|
6821
6747
|
});
|
|
6822
6748
|
}
|
|
@@ -6855,12 +6781,12 @@ function resolveAsOfBuild(options) {
|
|
|
6855
6781
|
if (injected !== void 0) return injected;
|
|
6856
6782
|
const disk = options.runtimeRoot === void 0 ? void 0 : readLatestBuildOrdinal(options.runtimeRoot, options.product);
|
|
6857
6783
|
if (disk !== void 0) return disk;
|
|
6858
|
-
let
|
|
6784
|
+
let latest;
|
|
6859
6785
|
for (const candidate2 of options.candidates) {
|
|
6860
6786
|
if (!Number.isFinite(candidate2.openedAtOrdinal)) continue;
|
|
6861
|
-
|
|
6787
|
+
latest = latest === void 0 ? candidate2.openedAtOrdinal : Math.max(latest, candidate2.openedAtOrdinal);
|
|
6862
6788
|
}
|
|
6863
|
-
return
|
|
6789
|
+
return latest;
|
|
6864
6790
|
}
|
|
6865
6791
|
function isCurrentAt(candidate2, asOfBuild) {
|
|
6866
6792
|
return candidate2.openedAtOrdinal <= asOfBuild && (candidate2.closedAtOrdinal === null || candidate2.closedAtOrdinal > asOfBuild);
|
|
@@ -6952,7 +6878,7 @@ function thrashTriggerKey(anchor) {
|
|
|
6952
6878
|
const match = /^thrash:([0-9a-f]{64}):window:[0-9]+$/.exec(anchor.name);
|
|
6953
6879
|
return match?.[1];
|
|
6954
6880
|
}
|
|
6955
|
-
function attachMemoryOffUnknowns(knowledgeRoot, candidates, options
|
|
6881
|
+
function attachMemoryOffUnknowns(knowledgeRoot, candidates, options) {
|
|
6956
6882
|
if (auditMode(options)) return [...candidates];
|
|
6957
6883
|
const relevantGroups = new Set(
|
|
6958
6884
|
candidates.flatMap((candidate2) => {
|
|
@@ -6970,7 +6896,7 @@ function attachMemoryOffUnknowns(knowledgeRoot, candidates, options, priors) {
|
|
|
6970
6896
|
if (!verifyBundleIntegrity(entry.dir).ok) continue;
|
|
6971
6897
|
const loaded = loadBundle(entry.dir);
|
|
6972
6898
|
if (loaded.kind !== "loaded" || loaded.bundle.frontmatter.kind !== "unknown") continue;
|
|
6973
|
-
const trust = deriveBundleTrust(loaded.bundle
|
|
6899
|
+
const trust = deriveBundleTrust(loaded.bundle);
|
|
6974
6900
|
if (trust.status !== "active" && trust.status !== "candidate" || trust.validity.closedAtOrdinal !== void 0) {
|
|
6975
6901
|
continue;
|
|
6976
6902
|
}
|
|
@@ -7383,8 +7309,7 @@ async function retrieveFromIndex(context, input, scope, options) {
|
|
|
7383
7309
|
const withMemoryOffUnknowns = attachMemoryOffUnknowns(
|
|
7384
7310
|
context.knowledgeRoot,
|
|
7385
7311
|
authoritative,
|
|
7386
|
-
options
|
|
7387
|
-
context.priors
|
|
7312
|
+
options
|
|
7388
7313
|
);
|
|
7389
7314
|
const assembled = applyAssembly(
|
|
7390
7315
|
withMemoryOffUnknowns,
|
|
@@ -7494,8 +7419,7 @@ async function retrieveFromScan(context, input, scope, options) {
|
|
|
7494
7419
|
const withMemoryOffUnknowns = attachMemoryOffUnknowns(
|
|
7495
7420
|
context.knowledgeRoot,
|
|
7496
7421
|
candidates,
|
|
7497
|
-
options
|
|
7498
|
-
context.priors
|
|
7422
|
+
options
|
|
7499
7423
|
);
|
|
7500
7424
|
const assembled = applyAssembly(withMemoryOffUnknowns, [], options);
|
|
7501
7425
|
return finalRecheck(context, assembled, scope, options).slice(0, options.n);
|
|
@@ -7650,8 +7574,7 @@ async function resolveEntityRef(ref, deps) {
|
|
|
7650
7574
|
if (deps.entityIndex === void 0) return { kind: "none", reason: "no-match" };
|
|
7651
7575
|
return resolveHybrid(trimmed, {
|
|
7652
7576
|
index: deps.entityIndex,
|
|
7653
|
-
// The
|
|
7654
|
-
// stale row, and a stale title in front of a user is the failure D-06 keeps it out of.
|
|
7577
|
+
// The ledger describes the winner, never the index, which may hold a stale row.
|
|
7655
7578
|
describe: (candidateShortId) => {
|
|
7656
7579
|
const candidateKind = parseShortId(candidateShortId)?.kind;
|
|
7657
7580
|
if (candidateKind === void 0) return void 0;
|
|
@@ -7673,13 +7596,13 @@ function getEntityDescriptor(ref, deps) {
|
|
|
7673
7596
|
|
|
7674
7597
|
// src/list-bundles.ts
|
|
7675
7598
|
import { relative as relative2 } from "node:path";
|
|
7676
|
-
function listBundles(knowledgeRoot
|
|
7599
|
+
function listBundles(knowledgeRoot) {
|
|
7677
7600
|
const rows = [];
|
|
7678
7601
|
for (const entry of enumerateBundleDirs(knowledgeRoot)) {
|
|
7679
7602
|
const outcome = loadBundle(entry.dir);
|
|
7680
7603
|
if (outcome.kind !== "loaded") continue;
|
|
7681
7604
|
const { bundle } = outcome;
|
|
7682
|
-
const trust = deriveBundleTrust(bundle
|
|
7605
|
+
const trust = deriveBundleTrust(bundle);
|
|
7683
7606
|
rows.push({
|
|
7684
7607
|
bundleId: bundle.manifest.id,
|
|
7685
7608
|
product: entry.product,
|
|
@@ -7741,9 +7664,7 @@ function createMemorySightingSource(resolveKnowledgeRoot) {
|
|
|
7741
7664
|
return {
|
|
7742
7665
|
kind: "MEM",
|
|
7743
7666
|
sight: find,
|
|
7744
|
-
// Sighting and hydration are
|
|
7745
|
-
// there is no second index to consult. They stay two members on the port because for
|
|
7746
|
-
// RUN and TST (387-03) they will not be.
|
|
7667
|
+
// Sighting and hydration are one lookup for MEM, because a bundle id is the machine id.
|
|
7747
7668
|
hydrate: find
|
|
7748
7669
|
};
|
|
7749
7670
|
}
|
|
@@ -8055,9 +7976,7 @@ function evaluateQuarantineDetection(input) {
|
|
|
8055
7976
|
const expiresAt = expiryFrom(input.now);
|
|
8056
7977
|
let floorAdmissions = 0;
|
|
8057
7978
|
for (const failure of [...input.failures].sort(
|
|
8058
|
-
//
|
|
8059
|
-
// the shared comparator, the fingerprint tiebreak through the same primitive — because a
|
|
8060
|
-
// comparison chain is only as deterministic as its least deterministic leg.
|
|
7979
|
+
// Both legs compare code units, so the chain stays host-independent.
|
|
8061
7980
|
(a, b) => compareQuarantineIdentity(a, b) || compareBytes(a.fingerprint, b.fingerprint)
|
|
8062
7981
|
)) {
|
|
8063
7982
|
if (activeKeys.has(quarantineIdentityKey(failure))) continue;
|
|
@@ -8273,15 +8192,7 @@ function createQuarantineOperations(options) {
|
|
|
8273
8192
|
filePath: entry.filePath,
|
|
8274
8193
|
testName: entry.testName,
|
|
8275
8194
|
expiresAt,
|
|
8276
|
-
//
|
|
8277
|
-
// the unassigned literal) exactly as it was. Writing `unassigned` here would silently
|
|
8278
|
-
// UN-claim a window somebody had taken.
|
|
8279
|
-
//
|
|
8280
|
-
// TWO AUTHORING PATHS, ONE RULE. `ownerForAutoEntry` (detection.ts) makes the same
|
|
8281
|
-
// decision for an AUTO re-entry, stated over the prior entry's state: carry across a
|
|
8282
|
-
// lapse, start unassigned after a deliberate release. Until 390-18 the rule was
|
|
8283
|
-
// written down here and applied only here, and the auto path did exactly what this
|
|
8284
|
-
// comment refuses to. If you change one, change the other.
|
|
8195
|
+
// An absent owner keeps the claim; `ownerForAutoEntry` follows the same rule.
|
|
8285
8196
|
...input.owner === void 0 ? {} : { owner: input.owner }
|
|
8286
8197
|
}]);
|
|
8287
8198
|
return {
|
|
@@ -8621,7 +8532,7 @@ import {
|
|
|
8621
8532
|
rmSync as rmSync6,
|
|
8622
8533
|
writeFileSync as writeFileSync7
|
|
8623
8534
|
} from "node:fs";
|
|
8624
|
-
import { dirname as
|
|
8535
|
+
import { dirname as dirname12, isAbsolute as isAbsolute5, join as join22 } from "node:path";
|
|
8625
8536
|
import {
|
|
8626
8537
|
canonicalJson as canonicalJson15,
|
|
8627
8538
|
guardBundleManifest as guardBundleManifest2,
|
|
@@ -8698,15 +8609,10 @@ function removeStaging(stagingDir, stagingRoot, bundlesDir) {
|
|
|
8698
8609
|
}
|
|
8699
8610
|
function writePart(stagingDir, part2) {
|
|
8700
8611
|
const target = join22(stagingDir, part2.relPath);
|
|
8701
|
-
mkdirSync12(
|
|
8612
|
+
mkdirSync12(dirname12(target), { recursive: true });
|
|
8702
8613
|
writeFileSync7(target, part2.text, "utf8");
|
|
8703
8614
|
}
|
|
8704
8615
|
function stageBundle(config, input) {
|
|
8705
|
-
if (config.commitArtifacts === "thumbnails") {
|
|
8706
|
-
throw new Error(
|
|
8707
|
-
"commitArtifacts 'thumbnails' is not implemented; Phase 380 visual review owns it"
|
|
8708
|
-
);
|
|
8709
|
-
}
|
|
8710
8616
|
if (!isAbsolute5(config.knowledgeRoot)) {
|
|
8711
8617
|
throw new TypeError("BundleStoreConfig.knowledgeRoot must be absolute");
|
|
8712
8618
|
}
|
|
@@ -8780,7 +8686,7 @@ function discardStagedBundle(staged, removeEmptyBundlesDir = false) {
|
|
|
8780
8686
|
if (!removeEmptyBundlesDir) return;
|
|
8781
8687
|
try {
|
|
8782
8688
|
rmdirSync3(staged.bundlesDir);
|
|
8783
|
-
fsyncDirectory(
|
|
8689
|
+
fsyncDirectory(dirname12(staged.bundlesDir));
|
|
8784
8690
|
} catch (error) {
|
|
8785
8691
|
const code = error.code;
|
|
8786
8692
|
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST") throw error;
|
|
@@ -8858,7 +8764,7 @@ import {
|
|
|
8858
8764
|
rmSync as rmSync7,
|
|
8859
8765
|
writeFileSync as writeFileSync8
|
|
8860
8766
|
} from "node:fs";
|
|
8861
|
-
import { basename as
|
|
8767
|
+
import { basename as basename6, dirname as dirname13, isAbsolute as isAbsolute6, join as join23, relative as relative3, resolve as resolve3, sep as sep3 } from "node:path";
|
|
8862
8768
|
import { canonicalJson as canonicalJson16, slugBranch as slugBranch3 } from "@vostride/agent-qa-schema";
|
|
8863
8769
|
import { z as z8 } from "zod";
|
|
8864
8770
|
var BUNDLE_MUTATION_JOURNAL_VERSION = 2;
|
|
@@ -8904,7 +8810,7 @@ function assertBundleLocation(knowledgeRoot, bundleDir2, bundleId) {
|
|
|
8904
8810
|
if (slugBranch3(bundleId) !== bundleId) {
|
|
8905
8811
|
throw new TypeError("bundleId must already be a canonical path segment");
|
|
8906
8812
|
}
|
|
8907
|
-
if (
|
|
8813
|
+
if (basename6(bundleDir2) !== slugBranch3(bundleId)) {
|
|
8908
8814
|
throw new TypeError("bundleDir must end with the canonical bundle id");
|
|
8909
8815
|
}
|
|
8910
8816
|
const rel = relative3(resolve3(knowledgeRoot), resolve3(bundleDir2)).split(sep3);
|
|
@@ -8912,11 +8818,11 @@ function assertBundleLocation(knowledgeRoot, bundleDir2, bundleId) {
|
|
|
8912
8818
|
throw new TypeError("bundleDir must use the canonical memory/<product>/bundles/<id> layout");
|
|
8913
8819
|
}
|
|
8914
8820
|
assertWithinKnowledgeRoot(knowledgeRoot, bundleDir2);
|
|
8915
|
-
assertWithinKnowledgeRoot(knowledgeRoot, join23(
|
|
8821
|
+
assertWithinKnowledgeRoot(knowledgeRoot, join23(dirname13(bundleDir2), ".staging"));
|
|
8916
8822
|
}
|
|
8917
8823
|
function assertTargetsContained(knowledgeRoot, bundleDir2, targetRelPaths) {
|
|
8918
8824
|
for (const targetRelPath of targetRelPaths) {
|
|
8919
|
-
assertWithinKnowledgeRoot(knowledgeRoot,
|
|
8825
|
+
assertWithinKnowledgeRoot(knowledgeRoot, dirname13(join23(bundleDir2, targetRelPath)));
|
|
8920
8826
|
}
|
|
8921
8827
|
}
|
|
8922
8828
|
function assertMutableTarget(targetRelPath) {
|
|
@@ -8966,7 +8872,7 @@ function parseCanonicalJournal(transactionDir) {
|
|
|
8966
8872
|
}
|
|
8967
8873
|
function assertTransactionName(transactionDir, journal) {
|
|
8968
8874
|
const prefix = `${journal.leaseId}-mutation-${journal.bundleId}-`;
|
|
8969
|
-
const name =
|
|
8875
|
+
const name = basename6(transactionDir);
|
|
8970
8876
|
if (!name.startsWith(prefix) || !UUID.test(name.slice(prefix.length))) {
|
|
8971
8877
|
throw new TypeError("mutation directory name does not bind its lease and bundle");
|
|
8972
8878
|
}
|
|
@@ -8978,7 +8884,7 @@ function readRecoveryPayloads(transactionDir, journal) {
|
|
|
8978
8884
|
}
|
|
8979
8885
|
const recoveryRoot = join23(transactionDir, RECOVERY_DIR);
|
|
8980
8886
|
const expectedNames = journal.replacements.map(
|
|
8981
|
-
(_replacement, index) =>
|
|
8887
|
+
(_replacement, index) => basename6(recoveryRelPath(index))
|
|
8982
8888
|
);
|
|
8983
8889
|
const actualEntries = readdirSync7(recoveryRoot, { withFileTypes: true }).sort(
|
|
8984
8890
|
(left, right) => left.name.localeCompare(right.name)
|
|
@@ -9006,8 +8912,8 @@ function applyJournal(bundleDir2, transactionDir, journal, afterMutableReplaceme
|
|
|
9006
8912
|
throw new TypeError("mutation target escapes its bundle");
|
|
9007
8913
|
}
|
|
9008
8914
|
const temporary = join23(
|
|
9009
|
-
|
|
9010
|
-
`.${
|
|
8915
|
+
dirname13(target),
|
|
8916
|
+
`.${basename6(target)}.mutation-${randomUUID7()}.tmp`
|
|
9011
8917
|
);
|
|
9012
8918
|
try {
|
|
9013
8919
|
writeFileSync8(temporary, recoveryPayloads[index], { flag: "wx" });
|
|
@@ -9016,7 +8922,7 @@ function applyJournal(bundleDir2, transactionDir, journal, afterMutableReplaceme
|
|
|
9016
8922
|
} finally {
|
|
9017
8923
|
if (existsSync13(temporary)) {
|
|
9018
8924
|
rmSync7(temporary, { force: true });
|
|
9019
|
-
fsyncDirectory(
|
|
8925
|
+
fsyncDirectory(dirname13(temporary));
|
|
9020
8926
|
}
|
|
9021
8927
|
}
|
|
9022
8928
|
afterMutableReplacement?.(replacement.targetRelPath);
|
|
@@ -9036,10 +8942,10 @@ function removeEmptyStagingRoot2(stagingRoot) {
|
|
|
9036
8942
|
const code = error.code;
|
|
9037
8943
|
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST") throw error;
|
|
9038
8944
|
}
|
|
9039
|
-
if (removed) fsyncDirectory(
|
|
8945
|
+
if (removed) fsyncDirectory(dirname13(stagingRoot));
|
|
9040
8946
|
}
|
|
9041
8947
|
function removeCompletedTransaction(transactionDir) {
|
|
9042
|
-
const stagingRoot =
|
|
8948
|
+
const stagingRoot = dirname13(transactionDir);
|
|
9043
8949
|
rmSync7(transactionDir, { recursive: true, force: true });
|
|
9044
8950
|
fsyncDirectory(stagingRoot);
|
|
9045
8951
|
removeEmptyStagingRoot2(stagingRoot);
|
|
@@ -9076,7 +8982,7 @@ function commitBundleMutation(input) {
|
|
|
9076
8982
|
input.bundleDir,
|
|
9077
8983
|
replacements.map((replacement) => replacement.targetRelPath)
|
|
9078
8984
|
);
|
|
9079
|
-
const bundlesDir =
|
|
8985
|
+
const bundlesDir = dirname13(input.bundleDir);
|
|
9080
8986
|
const stagingRoot = join23(bundlesDir, ".staging");
|
|
9081
8987
|
const transactionDir = join23(
|
|
9082
8988
|
stagingRoot,
|
|
@@ -9162,7 +9068,7 @@ function recoverExpiredBundleMutations(knowledgeRoot, expiredLeaseIds) {
|
|
|
9162
9068
|
if (journal.leaseId !== expectedLeaseId) {
|
|
9163
9069
|
throw new TypeError("mutation journal lease does not match its expired owner");
|
|
9164
9070
|
}
|
|
9165
|
-
const bundleDir2 = join23(
|
|
9071
|
+
const bundleDir2 = join23(dirname13(stagingRoot), journal.bundleId);
|
|
9166
9072
|
assertBundleLocation(knowledgeRoot, bundleDir2, journal.bundleId);
|
|
9167
9073
|
assertTargetsContained(
|
|
9168
9074
|
knowledgeRoot,
|
|
@@ -9447,23 +9353,9 @@ function appendRelation(config, id, relation) {
|
|
|
9447
9353
|
return rewriteBundleFile(config, dir, id, RELATIONS_REL_PATH2, rewrittenText, manifestText);
|
|
9448
9354
|
}
|
|
9449
9355
|
|
|
9450
|
-
// src/canonical-bundle-state-digests.ts
|
|
9451
|
-
import { basename as basename8 } from "node:path";
|
|
9452
|
-
import { distilledScreenStateDigest } from "@vostride/agent-qa-schema";
|
|
9453
|
-
function readCanonicalBundleStateDigests(input) {
|
|
9454
|
-
const found = enumerateBundleDirs(input.knowledgeRoot).find(({ dir }) => basename8(dir) === input.candidateId);
|
|
9455
|
-
if (found === void 0) return { kind: "not-found" };
|
|
9456
|
-
const loaded = loadBundle(found.dir);
|
|
9457
|
-
if (loaded.kind !== "loaded" || loaded.bundle.manifest.id !== input.candidateId || !verifyBundleIntegrity(found.dir).ok) return { kind: "not-found" };
|
|
9458
|
-
return {
|
|
9459
|
-
kind: "found",
|
|
9460
|
-
digests: loaded.bundle.screenStates.map((state) => distilledScreenStateDigest(state))
|
|
9461
|
-
};
|
|
9462
|
-
}
|
|
9463
|
-
|
|
9464
9356
|
// src/serving/reader.ts
|
|
9465
9357
|
import { existsSync as existsSync15 } from "node:fs";
|
|
9466
|
-
import { basename as
|
|
9358
|
+
import { basename as basename7 } from "node:path";
|
|
9467
9359
|
import { wrapAppObservedData } from "@vostride/agent-qa-safety";
|
|
9468
9360
|
import {
|
|
9469
9361
|
asRecordId as asRecordId3,
|
|
@@ -9471,8 +9363,7 @@ import {
|
|
|
9471
9363
|
EMPTY_PROCEDURE_BINDING_AVAILABILITY,
|
|
9472
9364
|
isVettedCandidate as isVettedCandidate3,
|
|
9473
9365
|
normalizeAnchor as normalizeAnchor10,
|
|
9474
|
-
slugBranch as slugBranch6
|
|
9475
|
-
strongestPromotionPath as strongestPromotionPath2
|
|
9366
|
+
slugBranch as slugBranch6
|
|
9476
9367
|
} from "@vostride/agent-qa-schema";
|
|
9477
9368
|
|
|
9478
9369
|
// src/serving/get-cautions.ts
|
|
@@ -9617,7 +9508,6 @@ function rankedCandidate(candidate2) {
|
|
|
9617
9508
|
lastConfirmedOrdinal,
|
|
9618
9509
|
...candidate2.record.unconfirmedSinceOrdinal === void 0 ? {} : { unconfirmedSinceOrdinal: candidate2.record.unconfirmedSinceOrdinal },
|
|
9619
9510
|
...candidate2.record.unverified === true ? { unverified: true } : {},
|
|
9620
|
-
...candidate2.record.lowerTrust === true ? { lowerTrust: true } : {},
|
|
9621
9511
|
...candidate2.record.conflict === void 0 ? {} : { conflict: candidate2.record.conflict }
|
|
9622
9512
|
};
|
|
9623
9513
|
}
|
|
@@ -10156,8 +10046,7 @@ function readPolicyLadder(knowledgeRoot, product) {
|
|
|
10156
10046
|
return rung === void 0 ? [] : [rung];
|
|
10157
10047
|
});
|
|
10158
10048
|
return {
|
|
10159
|
-
//
|
|
10160
|
-
// sources but no active text is summarized, truncated, normalized, or reflowed.
|
|
10049
|
+
// Active policy bytes are concatenated whole; labels frame sources and no text is reflowed.
|
|
10161
10050
|
text: renderPolicyLadder(rungs),
|
|
10162
10051
|
files: rungs.map(({ file }) => file),
|
|
10163
10052
|
oversized: rungs.flatMap(
|
|
@@ -10199,7 +10088,7 @@ function readIndexRows(config, scope) {
|
|
|
10199
10088
|
...scope === void 0 ? {} : { requestedScope: scope },
|
|
10200
10089
|
...config.scopeDefaults?.parentScopes === void 0 ? {} : { parentScopes: config.scopeDefaults.parentScopes }
|
|
10201
10090
|
});
|
|
10202
|
-
if (!indexTrustEpochMatches(reader.db, effectivePriorDigest(
|
|
10091
|
+
if (!indexTrustEpochMatches(reader.db, effectivePriorDigest())) {
|
|
10203
10092
|
const admits = reader.db.prepare(`
|
|
10204
10093
|
SELECT 1 FROM (SELECT ? AS product, ? AS scope_tier, ? AS scope_key) r
|
|
10205
10094
|
WHERE ${predicate.sql}
|
|
@@ -10237,7 +10126,7 @@ function readIndexRows(config, scope) {
|
|
|
10237
10126
|
function bundleDirs(config) {
|
|
10238
10127
|
return new Map(
|
|
10239
10128
|
enumerateBundleDirs(config.knowledgeRoot).map(({ dir, product }) => [
|
|
10240
|
-
|
|
10129
|
+
basename7(dir),
|
|
10241
10130
|
{ dir, product }
|
|
10242
10131
|
])
|
|
10243
10132
|
);
|
|
@@ -10250,16 +10139,14 @@ function hydrateRows(config, rows, audit) {
|
|
|
10250
10139
|
const loaded = loadBundle(found.dir);
|
|
10251
10140
|
if (loaded.kind !== "loaded" || !verifyBundleIntegrity(found.dir).ok) return [];
|
|
10252
10141
|
const { bundle } = loaded;
|
|
10253
|
-
const trust = deriveBundleTrust(bundle
|
|
10142
|
+
const trust = deriveBundleTrust(bundle);
|
|
10254
10143
|
const vetted = trust.status === "candidate" && isVettedCandidate3(
|
|
10255
10144
|
assemblePromotionGateInput({
|
|
10256
10145
|
knowledgeRoot: config.knowledgeRoot,
|
|
10257
10146
|
bundleDir: found.dir,
|
|
10258
|
-
bundle
|
|
10259
|
-
priors: config.priors
|
|
10147
|
+
bundle
|
|
10260
10148
|
})
|
|
10261
10149
|
);
|
|
10262
|
-
const lowerTrust = trust.status === "active" && strongestPromotionPath2(readGateReceipts(found.dir, bundle.manifest.id) ?? []) === "gate1-lower-trust";
|
|
10263
10150
|
const entry = {
|
|
10264
10151
|
id: asRecordId3(bundle.manifest.id),
|
|
10265
10152
|
kind: bundle.frontmatter.kind,
|
|
@@ -10269,8 +10156,7 @@ function hydrateRows(config, rows, audit) {
|
|
|
10269
10156
|
trust: trust.trust,
|
|
10270
10157
|
anchors: bundle.frontmatter.anchors.map(({ normalized }) => normalized),
|
|
10271
10158
|
status: trust.status,
|
|
10272
|
-
servedAsCanary: vetted
|
|
10273
|
-
...lowerTrust ? { lowerTrust: true } : {},
|
|
10159
|
+
servedAsCanary: vetted,
|
|
10274
10160
|
...vetted ? { unverified: true } : {},
|
|
10275
10161
|
...audit ? {
|
|
10276
10162
|
audit: {
|
|
@@ -10344,7 +10230,7 @@ function searchEntries(config, query, options) {
|
|
|
10344
10230
|
if (!auditMode2 && (entry.status === "deprecated" || entry.status === "superseded")) {
|
|
10345
10231
|
return false;
|
|
10346
10232
|
}
|
|
10347
|
-
const trust = deriveBundleTrust(bundle
|
|
10233
|
+
const trust = deriveBundleTrust(bundle);
|
|
10348
10234
|
if (options.asOfBuild !== void 0 && !validAtBuild(
|
|
10349
10235
|
trust.validity.openedAtOrdinal,
|
|
10350
10236
|
trust.validity.closedAtOrdinal,
|
|
@@ -10374,7 +10260,7 @@ function findReadableBundle(config, id, options) {
|
|
|
10374
10260
|
if (currentServingEntries([hydrated]).length === 0 && !admitsProcedure({ entry: hydrated.entry, bundle: hydrated.bundle })) {
|
|
10375
10261
|
return void 0;
|
|
10376
10262
|
}
|
|
10377
|
-
const trust = deriveBundleTrust(hydrated.bundle
|
|
10263
|
+
const trust = deriveBundleTrust(hydrated.bundle);
|
|
10378
10264
|
const asOfBuild = options?.asOfBuild ?? config.scopeDefaults?.asOfBuild;
|
|
10379
10265
|
if (asOfBuild !== void 0 && !validAtBuild(
|
|
10380
10266
|
trust.validity.openedAtOrdinal,
|
|
@@ -10487,7 +10373,7 @@ function servingReader(config) {
|
|
|
10487
10373
|
};
|
|
10488
10374
|
}
|
|
10489
10375
|
function openKnowledgeReader2(configOrKnowledgeRoot, opts) {
|
|
10490
|
-
return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader(
|
|
10376
|
+
return typeof configOrKnowledgeRoot === "string" ? openKnowledgeReader(configOrKnowledgeRoot, opts) : servingReader(configOrKnowledgeRoot);
|
|
10491
10377
|
}
|
|
10492
10378
|
|
|
10493
10379
|
// src/serving/authoring-reader.ts
|
|
@@ -10612,7 +10498,7 @@ function verifiedExemplarCandidate(row, targetKeys, tokens) {
|
|
|
10612
10498
|
return [{
|
|
10613
10499
|
identity: identityTupleKey([row.filePath, row.testName]),
|
|
10614
10500
|
anchorKeys: new Set(matchedKeys),
|
|
10615
|
-
//
|
|
10501
|
+
// Trust is a neutral 1 for projection-verified rows, so the score is pass rate times relevance.
|
|
10616
10502
|
score: recentPassRate * relevance,
|
|
10617
10503
|
leg: dominantAuthoringLeg(contributions),
|
|
10618
10504
|
exemplar: {
|
|
@@ -10984,7 +10870,6 @@ async function readDenseScores(config, deps, intent, scope) {
|
|
|
10984
10870
|
}
|
|
10985
10871
|
}
|
|
10986
10872
|
function createAuthoringReader(config, deps = {}) {
|
|
10987
|
-
config = { ...config, priors: snapshotTrustPriors(config.priors) };
|
|
10988
10873
|
return {
|
|
10989
10874
|
async getAuthoringBrief(intent, scope) {
|
|
10990
10875
|
const entries = hydrateRows(config, readIndexRows(config, scope), false);
|
|
@@ -11001,8 +10886,7 @@ function createAuthoringReader(config, deps = {}) {
|
|
|
11001
10886
|
const { brief } = assembleAuthoringBrief({
|
|
11002
10887
|
entries,
|
|
11003
10888
|
projectionRows,
|
|
11004
|
-
//
|
|
11005
|
-
// identities remain a deterministic floor, while never-run tests widen the universe.
|
|
10889
|
+
// The consumer owns the filesystem and supplies refs; never-run tests widen the projection.
|
|
11006
10890
|
knownTests,
|
|
11007
10891
|
intent,
|
|
11008
10892
|
scope,
|
|
@@ -11071,12 +10955,11 @@ async function resolveRetrievalRung(options) {
|
|
|
11071
10955
|
|
|
11072
10956
|
// src/index-rebuild.ts
|
|
11073
10957
|
import { existsSync as existsSync17, readFileSync as readFileSync16 } from "node:fs";
|
|
11074
|
-
import { basename as
|
|
10958
|
+
import { basename as basename8, join as join26 } from "node:path";
|
|
11075
10959
|
import {
|
|
11076
10960
|
anchorGraphNode as anchorGraphNode2,
|
|
11077
10961
|
canonicalJson as canonicalJson22,
|
|
11078
10962
|
guardDistilledObservation as guardDistilledObservation2,
|
|
11079
|
-
guardTrustPriorTable as guardTrustPriorTable3,
|
|
11080
10963
|
recordGraphNode as recordGraphNode2
|
|
11081
10964
|
} from "@vostride/agent-qa-schema";
|
|
11082
10965
|
|
|
@@ -11584,10 +11467,10 @@ function insertGraphDerivation(db, projection) {
|
|
|
11584
11467
|
for (const node2 of projection.nodes) insertGraphNode(db, node2, node2.product);
|
|
11585
11468
|
for (const edge of projection.edges) insertGraphEdge(db, edge);
|
|
11586
11469
|
}
|
|
11587
|
-
function upsertRecord(db, bundle, product
|
|
11588
|
-
const trust = deriveBundleTrust(bundle
|
|
11589
|
-
const
|
|
11590
|
-
db.prepare("DELETE FROM meta WHERE k = 'trust_prior_digest' AND v != ?").run(
|
|
11470
|
+
function upsertRecord(db, bundle, product) {
|
|
11471
|
+
const trust = deriveBundleTrust(bundle);
|
|
11472
|
+
const digest2 = effectivePriorDigest();
|
|
11473
|
+
db.prepare("DELETE FROM meta WHERE k = 'trust_prior_digest' AND v != ?").run(digest2);
|
|
11591
11474
|
db.prepare(`
|
|
11592
11475
|
INSERT INTO records (
|
|
11593
11476
|
bundle_id, product, mutable_state_hash, kind, subtype, scope_tier, scope_key,
|
|
@@ -11639,7 +11522,7 @@ function upsertRecord(db, bundle, product, priors) {
|
|
|
11639
11522
|
bundle.manifest.embeddingInput,
|
|
11640
11523
|
"",
|
|
11641
11524
|
bundle.manifest.embeddingInput,
|
|
11642
|
-
|
|
11525
|
+
digest2
|
|
11643
11526
|
);
|
|
11644
11527
|
const row = db.prepare("SELECT record_rowid FROM records WHERE bundle_id = ?").get(bundle.manifest.id);
|
|
11645
11528
|
if (row === void 0) throw new Error(`record upsert lost bundle ${bundle.manifest.id}`);
|
|
@@ -11801,13 +11684,12 @@ function scrubDeadRecallRows(db, bundle, recordRowid) {
|
|
|
11801
11684
|
`).run(recordRowid, recordNode.nodeId, recordNode.nodeId);
|
|
11802
11685
|
deleteOrphanGraphNodes(db);
|
|
11803
11686
|
}
|
|
11804
|
-
function projectBundle(db, vec, projected, activeProfile, authority, beforeCommit, hooks
|
|
11687
|
+
function projectBundle(db, vec, projected, activeProfile, authority, beforeCommit, hooks) {
|
|
11805
11688
|
transaction(db, () => {
|
|
11806
11689
|
const { recordRowid, status } = upsertRecord(
|
|
11807
11690
|
db,
|
|
11808
11691
|
projected.bundle,
|
|
11809
|
-
projected.product
|
|
11810
|
-
priors
|
|
11692
|
+
projected.product
|
|
11811
11693
|
);
|
|
11812
11694
|
replaceFtsAndAnchors(db, projected.bundle, projected.product, recordRowid);
|
|
11813
11695
|
if (isDeadStatus(status)) {
|
|
@@ -11830,7 +11712,6 @@ function projectBundleIndexRowWithinCurrentAuthority(opts) {
|
|
|
11830
11712
|
projectBundleIndexRowWithAuthority(opts, { withinHeldAuthority: true });
|
|
11831
11713
|
}
|
|
11832
11714
|
function projectBundleIndexRowWithAuthority(opts, authority) {
|
|
11833
|
-
const priors = opts.priors === void 0 ? void 0 : guardTrustPriorTable3(opts.priors);
|
|
11834
11715
|
const target = resolveProductQualifiedBundleDir({
|
|
11835
11716
|
knowledgeRoot: opts.knowledgeRoot,
|
|
11836
11717
|
recordId: opts.bundleId,
|
|
@@ -11854,7 +11735,7 @@ function projectBundleIndexRowWithAuthority(opts, authority) {
|
|
|
11854
11735
|
const writer = openIndexWriter(opts.knowledgeRoot);
|
|
11855
11736
|
const activeProfile = resolveActiveProfile(writer.db);
|
|
11856
11737
|
try {
|
|
11857
|
-
projectBundle(writer.db, writer.vec, projected, activeProfile, authority
|
|
11738
|
+
projectBundle(writer.db, writer.vec, projected, activeProfile, authority);
|
|
11858
11739
|
emitRelationEdges(writer.db, [projected], authority);
|
|
11859
11740
|
const scanIssues = [];
|
|
11860
11741
|
emitObservationEdges(
|
|
@@ -11903,8 +11784,8 @@ function emitRelationEdges(db, relationSources, authority) {
|
|
|
11903
11784
|
}, authority);
|
|
11904
11785
|
}
|
|
11905
11786
|
function safeObservationPath(knowledgeRoot, source) {
|
|
11906
|
-
const bundleDir2 =
|
|
11907
|
-
if (source.product === "" || source.product === "." || source.product === ".." || source.product !==
|
|
11787
|
+
const bundleDir2 = basename8(source.dir);
|
|
11788
|
+
if (source.product === "" || source.product === "." || source.product === ".." || source.product !== basename8(source.product) || bundleDir2 === "" || bundleDir2 === "." || bundleDir2 === ".." || source.dir !== join26(knowledgeRoot, "memory", source.product, "bundles", bundleDir2)) {
|
|
11908
11789
|
return void 0;
|
|
11909
11790
|
}
|
|
11910
11791
|
return join26(source.dir, "observations.jsonl");
|
|
@@ -12266,8 +12147,7 @@ function reconcileVecRows(db, vec, activeProfile, authority) {
|
|
|
12266
12147
|
}, authority);
|
|
12267
12148
|
}
|
|
12268
12149
|
async function rebuildIndex(opts) {
|
|
12269
|
-
const
|
|
12270
|
-
const digest3 = effectivePriorDigest(priors);
|
|
12150
|
+
const digest2 = effectivePriorDigest();
|
|
12271
12151
|
const writerAuthority = opts.writerAuthority;
|
|
12272
12152
|
if (writerAuthority !== void 0 && writerAuthority.knowledgeRoot !== opts.knowledgeRoot) {
|
|
12273
12153
|
throw new TypeError("rebuild writerAuthority must belong to knowledgeRoot");
|
|
@@ -12302,12 +12182,12 @@ async function rebuildIndex(opts) {
|
|
|
12302
12182
|
for (const entry of enumerateBundleDirs(opts.knowledgeRoot)) {
|
|
12303
12183
|
const outcome = loadBundle(entry.dir);
|
|
12304
12184
|
if (outcome.kind === "incomplete") {
|
|
12305
|
-
seenBundleIds.add(
|
|
12185
|
+
seenBundleIds.add(basename8(entry.dir));
|
|
12306
12186
|
report.skippedIncomplete += 1;
|
|
12307
12187
|
continue;
|
|
12308
12188
|
}
|
|
12309
12189
|
if (outcome.kind !== "loaded") {
|
|
12310
|
-
seenBundleIds.add(
|
|
12190
|
+
seenBundleIds.add(basename8(entry.dir));
|
|
12311
12191
|
const reason = "reason" in outcome ? `: ${outcome.reason}` : "";
|
|
12312
12192
|
report.scanIssues.push(`${entry.dir}: ${outcome.kind}${reason}`);
|
|
12313
12193
|
continue;
|
|
@@ -12327,9 +12207,9 @@ async function rebuildIndex(opts) {
|
|
|
12327
12207
|
`).get(outcome.bundle.manifest.id);
|
|
12328
12208
|
processedBundles += 1;
|
|
12329
12209
|
if (current?.mutable_state_hash === outcome.bundle.manifest.mutableStateHash) {
|
|
12330
|
-
if (current.trust_prior_digest !==
|
|
12210
|
+
if (current.trust_prior_digest !== digest2) {
|
|
12331
12211
|
transaction(writer.db, () => {
|
|
12332
|
-
writer.db.prepare("UPDATE records SET trust = ?, trust_prior_digest = ? WHERE bundle_id = ?").run(deriveBundleTrust(outcome.bundle
|
|
12212
|
+
writer.db.prepare("UPDATE records SET trust = ?, trust_prior_digest = ? WHERE bundle_id = ?").run(deriveBundleTrust(outcome.bundle).trust, digest2, outcome.bundle.manifest.id);
|
|
12333
12213
|
}, authority, opts.hooks?.beforeTransactionCommit, { family: "project-bundle", hooks: opts.hooks });
|
|
12334
12214
|
report.projected += 1;
|
|
12335
12215
|
}
|
|
@@ -12350,8 +12230,7 @@ async function rebuildIndex(opts) {
|
|
|
12350
12230
|
activeProfile,
|
|
12351
12231
|
authority,
|
|
12352
12232
|
opts.hooks?.beforeTransactionCommit,
|
|
12353
|
-
opts.hooks
|
|
12354
|
-
priors
|
|
12233
|
+
opts.hooks
|
|
12355
12234
|
);
|
|
12356
12235
|
projected.push(item);
|
|
12357
12236
|
report.projected += 1;
|
|
@@ -12398,9 +12277,9 @@ async function rebuildIndex(opts) {
|
|
|
12398
12277
|
);
|
|
12399
12278
|
if (writerAuthority !== void 0 && report.skippedIncomplete === 0 && report.scanIssues.length === 0) {
|
|
12400
12279
|
transaction(writer.db, () => {
|
|
12401
|
-
const mixed = writer.db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(
|
|
12280
|
+
const mixed = writer.db.prepare("SELECT 1 FROM records WHERE trust_prior_digest != ? LIMIT 1").get(digest2);
|
|
12402
12281
|
if (mixed !== void 0) return;
|
|
12403
|
-
writer.db.prepare("INSERT INTO meta (k, v) VALUES ('trust_prior_digest', ?) ON CONFLICT(k) DO UPDATE SET v = excluded.v").run(
|
|
12282
|
+
writer.db.prepare("INSERT INTO meta (k, v) VALUES ('trust_prior_digest', ?) ON CONFLICT(k) DO UPDATE SET v = excluded.v").run(digest2);
|
|
12404
12283
|
}, authority, void 0, { family: "complete-trust-epoch", hooks: opts.hooks });
|
|
12405
12284
|
}
|
|
12406
12285
|
report.pendingEmbeddings = selectPendingEmbeddingRows(writer.db).length;
|
|
@@ -12947,21 +12826,7 @@ function evaluateQuarantineForFold(db, projection, knowledgeRoot, opts) {
|
|
|
12947
12826
|
fingerprint: test.failure.fingerprint,
|
|
12948
12827
|
verdictClass: test.failure.verdictClass,
|
|
12949
12828
|
producer: test.failure.producer,
|
|
12950
|
-
//
|
|
12951
|
-
// `hasSameBuildPassAndFail` is called rather than re-derived: the exit path's
|
|
12952
|
-
// `distinctOrdinalOutcomes` and this entry-side read share one `groupByBuildOrdinal`, so
|
|
12953
|
-
// "what a build ordinal is" has exactly one spelling and the two directions cannot drift.
|
|
12954
|
-
// A test with no history row answers false through the `?? []` — typed absence, never a
|
|
12955
|
-
// throw and never a fabricated window. (Defensive in-tree: the reads below run after
|
|
12956
|
-
// `applyRunOutcomes` returned `applied`, so a crossing test always has a row by now.)
|
|
12957
|
-
//
|
|
12958
|
-
// AND IT IS SCOPED TO THIS CROSSING'S OWN RECURRENCE WINDOW (390-24, WR-05). The per-test
|
|
12959
|
-
// outcome window keeps LAST_OUTCOMES_LIMIT entries, which is DEEPER than the detection
|
|
12960
|
-
// window, so an unscoped read let a since-fixed flake episode license a new hard regression
|
|
12961
|
-
// several ordinals later — the gate silencing exactly what the disposition table exists to
|
|
12962
|
-
// keep failing the build. The floor here is `fingerprintRecurrence`'s floor, from the same
|
|
12963
|
-
// export: the evidence and the count are bounded by ONE window, so evidence expires with the
|
|
12964
|
-
// window that licensed nothing (D-07 windows-forgive; D-05 anti-silencing).
|
|
12829
|
+
// Scoped to this crossing's recurrence window, so old flake evidence licenses nothing.
|
|
12965
12830
|
sameBuildPassAndFail: hasSameBuildPassAndFail(
|
|
12966
12831
|
(readTestOutcomeHistory(db, {
|
|
12967
12832
|
product: projection.product,
|
|
@@ -13076,19 +12941,19 @@ function loadGcBundles(knowledgeRoot) {
|
|
|
13076
12941
|
return bundles;
|
|
13077
12942
|
}
|
|
13078
12943
|
function latestBuildOrdinal(bundles) {
|
|
13079
|
-
let
|
|
12944
|
+
let latest = 1;
|
|
13080
12945
|
for (const bundle of bundles) {
|
|
13081
|
-
|
|
13082
|
-
for (const event of bundle.events)
|
|
12946
|
+
latest = Math.max(latest, bundle.createdAtOrdinal);
|
|
12947
|
+
for (const event of bundle.events) latest = Math.max(latest, event.buildOrdinal);
|
|
13083
12948
|
}
|
|
13084
|
-
return
|
|
12949
|
+
return latest;
|
|
13085
12950
|
}
|
|
13086
12951
|
function latestSupersessionOrdinal(bundle) {
|
|
13087
|
-
let
|
|
12952
|
+
let latest = bundle.createdAtOrdinal;
|
|
13088
12953
|
for (const event of survivingOutcomeEvents6(bundle.events)) {
|
|
13089
|
-
if (event.type === "superseded")
|
|
12954
|
+
if (event.type === "superseded") latest = Math.max(latest, event.buildOrdinal);
|
|
13090
12955
|
}
|
|
13091
|
-
return
|
|
12956
|
+
return latest;
|
|
13092
12957
|
}
|
|
13093
12958
|
function unknownConflictRecordIds(bundle) {
|
|
13094
12959
|
let parsed;
|
|
@@ -13602,10 +13467,7 @@ var candidateSeedShape = {
|
|
|
13602
13467
|
executionContext: executionContextSchema,
|
|
13603
13468
|
kind: bundleKindSchema,
|
|
13604
13469
|
subtype: factSubtypeSchema.optional(),
|
|
13605
|
-
|
|
13606
|
-
* 379 D-16 additive-optional typed caution evidence. Existing queue-v2
|
|
13607
|
-
* bytes remain valid; when present this real evidence joins the address.
|
|
13608
|
-
*/
|
|
13470
|
+
// Optional, so existing queue-v2 bytes stay valid; when present it joins the address.
|
|
13609
13471
|
rootCauseClass: cautionRootCauseClassSchema.optional(),
|
|
13610
13472
|
anchors: z9.array(anchorSchema).min(1),
|
|
13611
13473
|
summarySeed: z9.string(),
|
|
@@ -13715,7 +13577,7 @@ import {
|
|
|
13715
13577
|
renameSync as renameSync8,
|
|
13716
13578
|
rmSync as rmSync10
|
|
13717
13579
|
} from "node:fs";
|
|
13718
|
-
import { basename as
|
|
13580
|
+
import { basename as basename9, isAbsolute as isAbsolute9, join as join29 } from "node:path";
|
|
13719
13581
|
import { canonicalJson as canonicalJson26 } from "@vostride/agent-qa-schema";
|
|
13720
13582
|
import { ZodError } from "zod";
|
|
13721
13583
|
|
|
@@ -13733,7 +13595,7 @@ import {
|
|
|
13733
13595
|
rmSync as rmSync9,
|
|
13734
13596
|
writeFileSync as writeFileSync9
|
|
13735
13597
|
} from "node:fs";
|
|
13736
|
-
import { dirname as
|
|
13598
|
+
import { dirname as dirname14 } from "node:path";
|
|
13737
13599
|
import { canonicalJson as canonicalJson25 } from "@vostride/agent-qa-schema";
|
|
13738
13600
|
import { z as z10 } from "zod";
|
|
13739
13601
|
var CURATION_JOB_STATE_SCHEMA_VERSION = 2;
|
|
@@ -13749,9 +13611,7 @@ var curationJobStateSchema = z10.object({
|
|
|
13749
13611
|
candidateId: z10.string().regex(/^[0-9a-f]{64}$/),
|
|
13750
13612
|
lifecycle: jobLifecycleSchema,
|
|
13751
13613
|
embedCrashCount: z10.number().int().nonnegative().default(0),
|
|
13752
|
-
|
|
13753
|
-
* Opaque transport slot. Plan 378-06's authoredCheckpointSchema owns semantic validation.
|
|
13754
|
-
*/
|
|
13614
|
+
// Opaque transport slot; the authored checkpoint schema validates its contents.
|
|
13755
13615
|
authored: z10.unknown().optional(),
|
|
13756
13616
|
/** Diagnostic wall-clock metadata only; never identity, ordering, or disposition input. */
|
|
13757
13617
|
updatedAt: z10.string()
|
|
@@ -13779,7 +13639,7 @@ function removeEmptyDir2(dir) {
|
|
|
13779
13639
|
}
|
|
13780
13640
|
}
|
|
13781
13641
|
function atomicRewrite3(file, state) {
|
|
13782
|
-
mkdirSync14(
|
|
13642
|
+
mkdirSync14(dirname14(file), { recursive: true });
|
|
13783
13643
|
const temporary = `${file}.tmp-${randomUUID8()}`;
|
|
13784
13644
|
let fd;
|
|
13785
13645
|
try {
|
|
@@ -13790,7 +13650,7 @@ function atomicRewrite3(file, state) {
|
|
|
13790
13650
|
closeSync6(fd);
|
|
13791
13651
|
fd = void 0;
|
|
13792
13652
|
renameSync7(temporary, file);
|
|
13793
|
-
bestEffortFsyncDirectory4(
|
|
13653
|
+
bestEffortFsyncDirectory4(dirname14(file));
|
|
13794
13654
|
} finally {
|
|
13795
13655
|
if (fd !== void 0) closeSync6(fd);
|
|
13796
13656
|
rmSync9(temporary, { force: true });
|
|
@@ -13919,7 +13779,7 @@ function readCurationCandidatePayload(candidateDir) {
|
|
|
13919
13779
|
}
|
|
13920
13780
|
try {
|
|
13921
13781
|
const parsed = curationCandidatePayloadSchema.safeParse(JSON.parse(raw));
|
|
13922
|
-
return parsed.success && parsed.data.candidateId ===
|
|
13782
|
+
return parsed.success && parsed.data.candidateId === basename9(candidateDir) ? { kind: "parsed", present: true, payload: parsed.data } : { kind: "malformed", present: true };
|
|
13923
13783
|
} catch {
|
|
13924
13784
|
return { kind: "malformed", present: true };
|
|
13925
13785
|
}
|
|
@@ -14306,7 +14166,7 @@ import {
|
|
|
14306
14166
|
rmSync as rmSync11,
|
|
14307
14167
|
writeFileSync as writeFileSync10
|
|
14308
14168
|
} from "node:fs";
|
|
14309
|
-
import { dirname as
|
|
14169
|
+
import { dirname as dirname15, isAbsolute as isAbsolute10, join as join30 } from "node:path";
|
|
14310
14170
|
import { canonicalJson as canonicalJson27 } from "@vostride/agent-qa-schema";
|
|
14311
14171
|
import { z as z11 } from "zod";
|
|
14312
14172
|
var JOURNAL_SUBDIR = "memory/queue/journal";
|
|
@@ -14348,7 +14208,7 @@ function bestEffortFsyncDirectory5(dir) {
|
|
|
14348
14208
|
}
|
|
14349
14209
|
}
|
|
14350
14210
|
function atomicRewrite4(file, text) {
|
|
14351
|
-
mkdirSync16(
|
|
14211
|
+
mkdirSync16(dirname15(file), { recursive: true });
|
|
14352
14212
|
const temporary = `${file}.tmp-${randomUUID10()}`;
|
|
14353
14213
|
let fd;
|
|
14354
14214
|
try {
|
|
@@ -14358,7 +14218,7 @@ function atomicRewrite4(file, text) {
|
|
|
14358
14218
|
closeSync8(fd);
|
|
14359
14219
|
fd = void 0;
|
|
14360
14220
|
renameSync9(temporary, file);
|
|
14361
|
-
bestEffortFsyncDirectory5(
|
|
14221
|
+
bestEffortFsyncDirectory5(dirname15(file));
|
|
14362
14222
|
} finally {
|
|
14363
14223
|
if (fd !== void 0) closeSync8(fd);
|
|
14364
14224
|
rmSync11(temporary, { force: true });
|
|
@@ -14391,22 +14251,22 @@ function writeReconciledEpochWithinCurrentAuthority(knowledgeRoot, epoch) {
|
|
|
14391
14251
|
}
|
|
14392
14252
|
function quarantineStaleCommitIntent(knowledgeRoot, candidateId, epoch) {
|
|
14393
14253
|
const file = intentPath(knowledgeRoot, candidateId);
|
|
14394
|
-
assertWithinKnowledgeRoot(knowledgeRoot,
|
|
14254
|
+
assertWithinKnowledgeRoot(knowledgeRoot, dirname15(file));
|
|
14395
14255
|
const quarantined = `.stale-${epoch}-${candidateId}-${randomUUID10()}.intent.json`;
|
|
14396
14256
|
try {
|
|
14397
|
-
renameSync9(file, join30(
|
|
14257
|
+
renameSync9(file, join30(dirname15(file), quarantined));
|
|
14398
14258
|
} catch (error) {
|
|
14399
14259
|
if (error.code !== "ENOENT") throw error;
|
|
14400
14260
|
return { kind: "already-gone" };
|
|
14401
14261
|
}
|
|
14402
|
-
bestEffortFsyncDirectory5(
|
|
14262
|
+
bestEffortFsyncDirectory5(dirname15(file));
|
|
14403
14263
|
return { kind: "quarantined", name: quarantined };
|
|
14404
14264
|
}
|
|
14405
14265
|
function clearCommitIntent(knowledgeRoot, candidateId) {
|
|
14406
14266
|
const file = intentPath(knowledgeRoot, candidateId);
|
|
14407
|
-
assertWithinKnowledgeRoot(knowledgeRoot,
|
|
14267
|
+
assertWithinKnowledgeRoot(knowledgeRoot, dirname15(file));
|
|
14408
14268
|
rmSync11(file, { force: true });
|
|
14409
|
-
bestEffortFsyncDirectory5(
|
|
14269
|
+
bestEffortFsyncDirectory5(dirname15(file));
|
|
14410
14270
|
}
|
|
14411
14271
|
function listCommitIntents(knowledgeRoot) {
|
|
14412
14272
|
let names;
|
|
@@ -14501,7 +14361,7 @@ var bundleDraftSchema = z12.object({
|
|
|
14501
14361
|
body: z12.string(),
|
|
14502
14362
|
distilledEvidenceRef: artifactRefSchema2,
|
|
14503
14363
|
originStage: z12.literal("run-curation"),
|
|
14504
|
-
|
|
14364
|
+
// Transient signal consumed when commit renders run-linked provenance.
|
|
14505
14365
|
needsEnrichment: z12.literal(true).optional()
|
|
14506
14366
|
}).strict().superRefine((bundle, ctx) => {
|
|
14507
14367
|
if (bundle.kind === "fact" && bundle.subtype === void 0) {
|
|
@@ -14532,13 +14392,11 @@ var curationAuthorshipSchema = z12.object({
|
|
|
14532
14392
|
fingerprint: z12.string().optional()
|
|
14533
14393
|
}).strict().optional(),
|
|
14534
14394
|
executionContext: z12.enum(["local-interactive", "local-headless", "ci", "cloud"]),
|
|
14535
|
-
//
|
|
14395
|
+
// Optional, so a checkpoint written before the stamp still parses.
|
|
14536
14396
|
fallbackReason: z12.enum(["malformed", "no-model", "token-budget", "model-error"]).optional()
|
|
14537
14397
|
}).strict();
|
|
14538
14398
|
var envelopeShape = {
|
|
14539
|
-
// Projected from the schema
|
|
14540
|
-
// member list is the class of defect this phase keeps closing: it is a second vocabulary that
|
|
14541
|
-
// has to be kept in step with the first, and nothing makes it.
|
|
14399
|
+
// Projected from the schema registry, so no second vocabulary has to be kept in step.
|
|
14542
14400
|
origin: z12.enum(DELTA_ORIGINS),
|
|
14543
14401
|
scope: scopeSchema2,
|
|
14544
14402
|
citedIds: z12.array(recordIdSchema),
|
|
@@ -14700,14 +14558,14 @@ function deltaTargetIds(delta) {
|
|
|
14700
14558
|
}
|
|
14701
14559
|
return [...ids];
|
|
14702
14560
|
}
|
|
14703
|
-
function truthLookup(knowledgeRoot
|
|
14561
|
+
function truthLookup(knowledgeRoot) {
|
|
14704
14562
|
const cache = /* @__PURE__ */ new Map();
|
|
14705
14563
|
return (id) => {
|
|
14706
14564
|
if (cache.has(id)) return cache.get(id);
|
|
14707
14565
|
for (const entry of enumerateBundleDirs(knowledgeRoot)) {
|
|
14708
14566
|
const loaded = loadBundle(entry.dir);
|
|
14709
14567
|
if (loaded.kind !== "loaded" || loaded.bundle.manifest.id !== id) continue;
|
|
14710
|
-
const trust = deriveBundleTrust(loaded.bundle
|
|
14568
|
+
const trust = deriveBundleTrust(loaded.bundle);
|
|
14711
14569
|
const truth = {
|
|
14712
14570
|
dir: entry.dir,
|
|
14713
14571
|
bundle: loaded.bundle,
|
|
@@ -14803,8 +14661,8 @@ function armThrashTripAndClosure(input, lookup, state) {
|
|
|
14803
14661
|
windowBuilds: Number.MAX_SAFE_INTEGER,
|
|
14804
14662
|
asOfBuildOrdinal: buildOrdinal
|
|
14805
14663
|
}).get(triggerKey);
|
|
14806
|
-
const
|
|
14807
|
-
if (
|
|
14664
|
+
const latest = folded?.latestSupersessionOrdinal;
|
|
14665
|
+
if (latest === void 0 || buildOrdinal - latest < STABLE_WINDOW_BUILDS) return;
|
|
14808
14666
|
for (const unknown of unresolvedUnknownsWithPrefix(input, `thrash:${triggerKey}:window:`)) {
|
|
14809
14667
|
pushUnknownResolution(state, {
|
|
14810
14668
|
targetId: unknown.recordId,
|
|
@@ -15279,12 +15137,11 @@ function procedureBindingIntegrityReject(payload) {
|
|
|
15279
15137
|
return void 0;
|
|
15280
15138
|
}
|
|
15281
15139
|
function disposeDelta(input) {
|
|
15282
|
-
const priors = snapshotTrustPriors(input.priors);
|
|
15283
15140
|
const procedureReject = disposeProcedureExtraction(input);
|
|
15284
15141
|
if (procedureReject !== void 0) {
|
|
15285
15142
|
return { kind: "noop", reason: procedureReject };
|
|
15286
15143
|
}
|
|
15287
|
-
const lookup = truthLookup(input.knowledgeRoot
|
|
15144
|
+
const lookup = truthLookup(input.knowledgeRoot);
|
|
15288
15145
|
const measurement = disposeMeasurementDrift(input, lookup);
|
|
15289
15146
|
const dispositionInput = measurement.input;
|
|
15290
15147
|
const state = {};
|
|
@@ -15431,8 +15288,7 @@ function discriminant(draft2, delta, structuralProcedureStepKeys) {
|
|
|
15431
15288
|
return {
|
|
15432
15289
|
kind: "procedure",
|
|
15433
15290
|
flowName: flow?.name ?? canonicalJson30(draft2.anchors[0]),
|
|
15434
|
-
//
|
|
15435
|
-
// naturalKeys are evidence prose and must never enter the content address.
|
|
15291
|
+
// Step keys are the identity; observation natural keys are prose and stay out of it.
|
|
15436
15292
|
stepSignature: computeStepSequenceSignature(structuralProcedureStepKeys)
|
|
15437
15293
|
};
|
|
15438
15294
|
}
|
|
@@ -15565,7 +15421,6 @@ function storeConfig(deps, productKey, writerLeaseId) {
|
|
|
15565
15421
|
return {
|
|
15566
15422
|
knowledgeRoot: deps.knowledgeRoot,
|
|
15567
15423
|
productKey,
|
|
15568
|
-
commitArtifacts: "none",
|
|
15569
15424
|
writerLeaseId,
|
|
15570
15425
|
writerEpoch: deps.epoch,
|
|
15571
15426
|
...Object.keys(hooks).length === 0 ? {} : { hooks }
|
|
@@ -15703,7 +15558,6 @@ function commitUnknownMintIntentWithinCurrentAuthority(deps, job, prepared) {
|
|
|
15703
15558
|
};
|
|
15704
15559
|
}
|
|
15705
15560
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
15706
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
15707
15561
|
knowledgeRoot: deps.knowledgeRoot,
|
|
15708
15562
|
bundleId: published.id,
|
|
15709
15563
|
product: prepared.intent.scope.key
|
|
@@ -15729,7 +15583,6 @@ function commitUnknownResolutionIntent(deps, job, intent, target) {
|
|
|
15729
15583
|
const failure = appendFailure(appended);
|
|
15730
15584
|
if (failure !== void 0) return failure;
|
|
15731
15585
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
15732
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
15733
15586
|
knowledgeRoot: deps.knowledgeRoot,
|
|
15734
15587
|
bundleId: intent.targetId,
|
|
15735
15588
|
product: target.product
|
|
@@ -15773,8 +15626,7 @@ function finishCommitWithinCurrentAuthority(deps, job, observation, projectSucce
|
|
|
15773
15626
|
if (projectSuccessfulPrefix) applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
15774
15627
|
knowledgeRoot: deps.knowledgeRoot,
|
|
15775
15628
|
bundleId: effect.recordId,
|
|
15776
|
-
product: effect.product
|
|
15777
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors }
|
|
15629
|
+
product: effect.product
|
|
15778
15630
|
});
|
|
15779
15631
|
writeCurationEffectReceiptWithinCurrentAuthority({
|
|
15780
15632
|
knowledgeRoot: deps.knowledgeRoot,
|
|
@@ -15810,11 +15662,9 @@ function mutationTarget(delta) {
|
|
|
15810
15662
|
return void 0;
|
|
15811
15663
|
}
|
|
15812
15664
|
function commitCurationDelta(deps, job, checkpoint) {
|
|
15813
|
-
deps = { ...deps, ...deps.priors === void 0 ? {} : { priors: snapshotTrustPriors(deps.priors) } };
|
|
15814
15665
|
const beforeWork = staleEpoch(deps);
|
|
15815
15666
|
if (beforeWork !== void 0) return beforeWork;
|
|
15816
15667
|
const disposed = disposeDelta({
|
|
15817
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
15818
15668
|
delta: checkpoint.delta,
|
|
15819
15669
|
checkpoint,
|
|
15820
15670
|
profile: deps.profile,
|
|
@@ -15825,8 +15675,7 @@ function commitCurationDelta(deps, job, checkpoint) {
|
|
|
15825
15675
|
buildOrdinal: job.payload.buildOrdinal,
|
|
15826
15676
|
curationJobId: job.candidateId,
|
|
15827
15677
|
...measurementSeedValue(job) === void 0 ? {} : { measurementValue: measurementSeedValue(job) },
|
|
15828
|
-
//
|
|
15829
|
-
// extraction wall receives the payload's code-derived facts (never LLM text).
|
|
15678
|
+
// Procedure deltas are checked against durable queue evidence, never model text.
|
|
15830
15679
|
...job.payload.kind === "procedure" ? {
|
|
15831
15680
|
procedureEvidence: {
|
|
15832
15681
|
distilledObservations: job.payload.distilledObservations
|
|
@@ -16137,13 +15986,10 @@ function commitCurationDelta(deps, job, checkpoint) {
|
|
|
16137
15986
|
const gate = evaluatePromotionGate(assemblePromotionGateInput({
|
|
16138
15987
|
knowledgeRoot: deps.knowledgeRoot,
|
|
16139
15988
|
bundleDir: promotionBundleDir,
|
|
16140
|
-
bundle: loaded.bundle
|
|
16141
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
16142
|
-
...deps.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: deps.resolvePromotionPosture }
|
|
15989
|
+
bundle: loaded.bundle
|
|
16143
15990
|
}));
|
|
16144
15991
|
if (gate.verdict === "promote") {
|
|
16145
15992
|
const promoted = appendOutcomeEvent(config, published.id, {
|
|
16146
|
-
// 416-DOOR: door-3 promoted
|
|
16147
15993
|
type: "promoted",
|
|
16148
15994
|
evidenceToken: derivePromotedEvidenceToken(job.payload.evidenceToken),
|
|
16149
15995
|
curationJobId: job.candidateId,
|
|
@@ -16195,7 +16041,6 @@ function commitCurationDelta(deps, job, checkpoint) {
|
|
|
16195
16041
|
throw new TypeError("born-active disposition requires a Supersede delta");
|
|
16196
16042
|
}
|
|
16197
16043
|
const promoted = appendOutcomeEvent(config, published.id, {
|
|
16198
|
-
// 416-DOOR: born-active promoted
|
|
16199
16044
|
type: "promoted",
|
|
16200
16045
|
evidenceToken: derivePromotedEvidenceToken(delta.evidenceToken),
|
|
16201
16046
|
curationJobId: job.candidateId,
|
|
@@ -16211,7 +16056,6 @@ function commitCurationDelta(deps, job, checkpoint) {
|
|
|
16211
16056
|
if (freshlyPublished) deps.hooks?.afterBundlePublished?.(published.id);
|
|
16212
16057
|
if (disposed.kind === "apply" && disposed.bornActive === true) {
|
|
16213
16058
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
16214
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
16215
16059
|
knowledgeRoot: deps.knowledgeRoot,
|
|
16216
16060
|
bundleId: published.id,
|
|
16217
16061
|
product: bundleProduct
|
|
@@ -16345,7 +16189,6 @@ function commitCurationDelta(deps, job, checkpoint) {
|
|
|
16345
16189
|
}
|
|
16346
16190
|
tailMutationAppended ||= closed.kind === "appended";
|
|
16347
16191
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
16348
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
16349
16192
|
knowledgeRoot: deps.knowledgeRoot,
|
|
16350
16193
|
bundleId: delta.victimId,
|
|
16351
16194
|
product: victim.product
|
|
@@ -16357,7 +16200,6 @@ function commitCurationDelta(deps, job, checkpoint) {
|
|
|
16357
16200
|
return { kind: "noop", reason: "evidence-token-consumed" };
|
|
16358
16201
|
}
|
|
16359
16202
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
16360
|
-
...deps.priors === void 0 ? {} : { priors: deps.priors },
|
|
16361
16203
|
knowledgeRoot: deps.knowledgeRoot,
|
|
16362
16204
|
bundleId,
|
|
16363
16205
|
product: bundleProduct
|
|
@@ -16424,7 +16266,7 @@ import {
|
|
|
16424
16266
|
rmdirSync as rmdirSync6,
|
|
16425
16267
|
rmSync as rmSync13
|
|
16426
16268
|
} from "node:fs";
|
|
16427
|
-
import { basename as
|
|
16269
|
+
import { basename as basename10, join as join32 } from "node:path";
|
|
16428
16270
|
function childDirectories2(dir) {
|
|
16429
16271
|
try {
|
|
16430
16272
|
return readdirSync11(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
@@ -16617,7 +16459,7 @@ function reconcileOnDrainStartWithinCurrentAuthority(deps) {
|
|
|
16617
16459
|
for (const [bundleId, dir] of bundles) {
|
|
16618
16460
|
if (bundleIdsWithIntent.has(bundleId) || deps.hasIndexRow(bundleId)) continue;
|
|
16619
16461
|
const outcome = loadBundle(dir);
|
|
16620
|
-
if (outcome.kind !== "loaded" ||
|
|
16462
|
+
if (outcome.kind !== "loaded" || basename10(dir) !== outcome.bundle.manifest.id) continue;
|
|
16621
16463
|
deps.deriveIndexRowFromBundle(bundleId);
|
|
16622
16464
|
}
|
|
16623
16465
|
writeReconciledEpochWithinCurrentAuthority(
|
|
@@ -16796,18 +16638,15 @@ import {
|
|
|
16796
16638
|
foldBundleTrust as foldBundleTrust2,
|
|
16797
16639
|
GATE_RECEIPT_SCHEMA_VERSION as GATE_RECEIPT_SCHEMA_VERSION2,
|
|
16798
16640
|
GateReceiptSchema as GateReceiptSchema2,
|
|
16799
|
-
GATE2_DEFAULT_STALE_CONFIRMATIONS,
|
|
16800
|
-
isPromotionReceipt as isPromotionReceipt4,
|
|
16801
16641
|
receiptDigestOf as receiptDigestOf3,
|
|
16802
16642
|
sha256hex as sha256hex6,
|
|
16803
|
-
stampReceiptDigest as stampReceiptDigest2,
|
|
16804
16643
|
survivingOutcomeEvents as survivingOutcomeEvents7,
|
|
16805
|
-
strongestPromotionPath as
|
|
16644
|
+
strongestPromotionPath as strongestPromotionPath2,
|
|
16806
16645
|
strongerPromotionPath
|
|
16807
16646
|
} from "@vostride/agent-qa-schema";
|
|
16808
16647
|
var KnowledgeStoreNotImplementedError = class extends Error {
|
|
16809
16648
|
operation;
|
|
16810
|
-
constructor(operation
|
|
16649
|
+
constructor(operation) {
|
|
16811
16650
|
super(`${operation} compatibility error is retired because the operation is implemented`);
|
|
16812
16651
|
this.name = "KnowledgeStoreNotImplementedError";
|
|
16813
16652
|
this.operation = operation;
|
|
@@ -16843,7 +16682,7 @@ var KnowledgeUnsupportedDeltaError = class extends Error {
|
|
|
16843
16682
|
this.reason = "procedure-evidence-unsupported";
|
|
16844
16683
|
}
|
|
16845
16684
|
};
|
|
16846
|
-
function resolveTruth(knowledgeRoot, id
|
|
16685
|
+
function resolveTruth(knowledgeRoot, id) {
|
|
16847
16686
|
let target;
|
|
16848
16687
|
try {
|
|
16849
16688
|
target = resolveProductQualifiedBundleDir({ knowledgeRoot, recordId: id });
|
|
@@ -16853,7 +16692,7 @@ function resolveTruth(knowledgeRoot, id, priors) {
|
|
|
16853
16692
|
}
|
|
16854
16693
|
const loaded = loadBundle(target.dir);
|
|
16855
16694
|
if (loaded.kind !== "loaded" || loaded.bundle.manifest.id !== id) return void 0;
|
|
16856
|
-
const trust = deriveBundleTrust(loaded.bundle
|
|
16695
|
+
const trust = deriveBundleTrust(loaded.bundle);
|
|
16857
16696
|
return {
|
|
16858
16697
|
id,
|
|
16859
16698
|
bundle: loaded.bundle,
|
|
@@ -16922,10 +16761,10 @@ function currentAuthority(config) {
|
|
|
16922
16761
|
epoch: config.epoch ?? readCurrentEpoch(config.knowledgeRoot)
|
|
16923
16762
|
};
|
|
16924
16763
|
}
|
|
16925
|
-
function bridgeDelta(config, delta
|
|
16926
|
-
const neighbors = delta.citedIds.map((id) => resolveTruth(config.knowledgeRoot, id
|
|
16764
|
+
function bridgeDelta(config, delta) {
|
|
16765
|
+
const neighbors = delta.citedIds.map((id) => resolveTruth(config.knowledgeRoot, id)).filter((truth) => truth !== void 0);
|
|
16927
16766
|
const target = targetId(delta);
|
|
16928
|
-
const targetTruth = target === void 0 ? void 0 : neighbors.find(({ id }) => id === target) ?? resolveTruth(config.knowledgeRoot, target
|
|
16767
|
+
const targetTruth = target === void 0 ? void 0 : neighbors.find(({ id }) => id === target) ?? resolveTruth(config.knowledgeRoot, target);
|
|
16929
16768
|
const observedOrdinals = [...neighbors, ...targetTruth === void 0 ? [] : [targetTruth]].map(({ observedOrdinal }) => observedOrdinal);
|
|
16930
16769
|
const buildOrdinal = config.sourceBuildOrdinal ?? (observedOrdinals.length === 0 ? 0 : Math.max(...observedOrdinals) + 1);
|
|
16931
16770
|
const fields = addressFields(config, delta, targetTruth, buildOrdinal);
|
|
@@ -16989,13 +16828,11 @@ function createExplicitReviewStore(config) {
|
|
|
16989
16828
|
return { commit, promote, recordGateReceipt };
|
|
16990
16829
|
}
|
|
16991
16830
|
function buildLocalKnowledgeStore(config, authority) {
|
|
16992
|
-
const priors = snapshotTrustPriors(config.resolveTrustPriors?.());
|
|
16993
16831
|
const operation = config.operations?.commitCurationDelta ?? commitCurationDelta;
|
|
16994
16832
|
function bundleStoreConfig(productKey) {
|
|
16995
16833
|
return {
|
|
16996
16834
|
knowledgeRoot: config.knowledgeRoot,
|
|
16997
16835
|
productKey,
|
|
16998
|
-
commitArtifacts: "none",
|
|
16999
16836
|
writerLeaseId: config.writerLeaseId
|
|
17000
16837
|
};
|
|
17001
16838
|
}
|
|
@@ -17012,7 +16849,7 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17012
16849
|
if (profile.mode === "propose-only") {
|
|
17013
16850
|
throw new KnowledgePromotionError(candidateId, "propose-only");
|
|
17014
16851
|
}
|
|
17015
|
-
const resolved = resolveTruth(config.knowledgeRoot, candidateId
|
|
16852
|
+
const resolved = resolveTruth(config.knowledgeRoot, candidateId);
|
|
17016
16853
|
if (resolved === void 0) {
|
|
17017
16854
|
throw new KnowledgePromotionError(candidateId, "not-found");
|
|
17018
16855
|
}
|
|
@@ -17021,9 +16858,7 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17021
16858
|
const gateInput = assemblePromotionGateInput({
|
|
17022
16859
|
knowledgeRoot: config.knowledgeRoot,
|
|
17023
16860
|
bundleDir: resolved.bundleDir,
|
|
17024
|
-
bundle: resolved.bundle
|
|
17025
|
-
resolvePromotionPosture: config.resolvePromotionPosture,
|
|
17026
|
-
...priors === void 0 ? {} : { priors }
|
|
16861
|
+
bundle: resolved.bundle
|
|
17027
16862
|
});
|
|
17028
16863
|
const setAside = foldBundleTrust2(
|
|
17029
16864
|
survivingOutcomeEvents7(resolved.bundle.events).filter(({ type }) => type !== "promoted"),
|
|
@@ -17031,12 +16866,11 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17031
16866
|
originClass: resolved.bundle.frontmatter.originClass,
|
|
17032
16867
|
evidenceIncomplete: resolved.bundle.manifest.evidenceIncomplete,
|
|
17033
16868
|
createdAtOrdinal: resolved.bundle.frontmatter.createdAtOrdinal
|
|
17034
|
-
}
|
|
17035
|
-
priors
|
|
16869
|
+
}
|
|
17036
16870
|
);
|
|
17037
16871
|
const revalidated = evaluatePromotionGate2({ ...gateInput, status: setAside.status });
|
|
17038
16872
|
if (revalidated.verdict === "promote") {
|
|
17039
|
-
const onDisk =
|
|
16873
|
+
const onDisk = strongestPromotionPath2(readGateReceipts(resolved.bundleDir, candidateId) ?? []);
|
|
17040
16874
|
if (onDisk === void 0 || revalidated.promotionPath !== onDisk && strongerPromotionPath(revalidated.promotionPath, onDisk) === revalidated.promotionPath) {
|
|
17041
16875
|
checkedAppend(candidateId, appendPromotionReceipt(appendConfig, candidateId, {
|
|
17042
16876
|
schemaVersion: GATE_RECEIPT_SCHEMA_VERSION2,
|
|
@@ -17049,12 +16883,11 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17049
16883
|
}));
|
|
17050
16884
|
}
|
|
17051
16885
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
17052
|
-
...priors === void 0 ? {} : { priors },
|
|
17053
16886
|
knowledgeRoot: config.knowledgeRoot,
|
|
17054
16887
|
bundleId: candidateId,
|
|
17055
16888
|
product: resolved.product
|
|
17056
16889
|
});
|
|
17057
|
-
const promotionPath =
|
|
16890
|
+
const promotionPath = strongestPromotionPath2(readGateReceipts(resolved.bundleDir, candidateId) ?? []);
|
|
17058
16891
|
config.onPromotionOutcome?.({ candidateId, ...promotionPath === void 0 ? {} : { promotionPath } });
|
|
17059
16892
|
return { kind: "already-active", ...promotionPath === void 0 ? {} : { promotionPath } };
|
|
17060
16893
|
}
|
|
@@ -17078,7 +16911,6 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17078
16911
|
}
|
|
17079
16912
|
}
|
|
17080
16913
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
17081
|
-
...priors === void 0 ? {} : { priors },
|
|
17082
16914
|
knowledgeRoot: config.knowledgeRoot,
|
|
17083
16915
|
bundleId: candidateId,
|
|
17084
16916
|
product: resolved.product
|
|
@@ -17088,9 +16920,7 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17088
16920
|
const gate = evaluatePromotionGate2(assemblePromotionGateInput({
|
|
17089
16921
|
knowledgeRoot: config.knowledgeRoot,
|
|
17090
16922
|
bundleDir: resolved.bundleDir,
|
|
17091
|
-
bundle: resolved.bundle
|
|
17092
|
-
resolvePromotionPosture: config.resolvePromotionPosture,
|
|
17093
|
-
...priors === void 0 ? {} : { priors }
|
|
16923
|
+
bundle: resolved.bundle
|
|
17094
16924
|
}));
|
|
17095
16925
|
if (gate.verdict === "hold") {
|
|
17096
16926
|
throw new KnowledgePromotionError(candidateId, gate.reason);
|
|
@@ -17105,7 +16935,6 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17105
16935
|
))].sort();
|
|
17106
16936
|
const promotionSource = recoveryBoundary.length === 0 ? candidateId : canonicalJson32({ candidateId, retractedPromotionEvents: recoveryBoundary });
|
|
17107
16937
|
const appended = appendOutcomeEvent(appendConfig, candidateId, {
|
|
17108
|
-
// 416-DOOR: door-1-2 promoted
|
|
17109
16938
|
type: "promoted",
|
|
17110
16939
|
evidenceToken: derivePromotedEvidenceToken(promotionSource),
|
|
17111
16940
|
curationJobId: `promote:${candidateId}`,
|
|
@@ -17125,7 +16954,6 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17125
16954
|
});
|
|
17126
16955
|
if (receipt.kind === "not-found") throw new KnowledgePromotionError(candidateId, receipt.kind);
|
|
17127
16956
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
17128
|
-
...priors === void 0 ? {} : { priors },
|
|
17129
16957
|
knowledgeRoot: config.knowledgeRoot,
|
|
17130
16958
|
bundleId: candidateId,
|
|
17131
16959
|
product: resolved.product
|
|
@@ -17141,15 +16969,13 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17141
16969
|
if (draft(delta)?.kind === "procedure") {
|
|
17142
16970
|
throw new KnowledgeUnsupportedDeltaError(delta.kind);
|
|
17143
16971
|
}
|
|
17144
|
-
const { job, checkpoint } = bridgeDelta(config, delta
|
|
16972
|
+
const { job, checkpoint } = bridgeDelta(config, delta);
|
|
17145
16973
|
const outcome = operation(
|
|
17146
16974
|
{
|
|
17147
16975
|
knowledgeRoot: config.knowledgeRoot,
|
|
17148
16976
|
epoch: currentAuthority(config).epoch,
|
|
17149
16977
|
profile,
|
|
17150
|
-
drainState
|
|
17151
|
-
...priors === void 0 ? {} : { priors },
|
|
17152
|
-
...config.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: config.resolvePromotionPosture }
|
|
16978
|
+
drainState
|
|
17153
16979
|
},
|
|
17154
16980
|
job,
|
|
17155
16981
|
checkpoint
|
|
@@ -17157,39 +16983,6 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17157
16983
|
if (!completed(outcome)) throw new KnowledgeCommitError(outcome);
|
|
17158
16984
|
}
|
|
17159
16985
|
}
|
|
17160
|
-
function gate2ReceiptFor(outcome, verdict) {
|
|
17161
|
-
if (outcome.corpusDigest === void 0) throw new TypeError("Gate-2 receipt requires a corpus digest");
|
|
17162
|
-
return stampReceiptDigest2({
|
|
17163
|
-
schemaVersion: GATE_RECEIPT_SCHEMA_VERSION2,
|
|
17164
|
-
gate: 2,
|
|
17165
|
-
candidateId: outcome.candidateId,
|
|
17166
|
-
verdict,
|
|
17167
|
-
producedAtOrdinal: outcome.buildOrdinal,
|
|
17168
|
-
producedBy: {
|
|
17169
|
-
...config.sourceJobId === void 0 ? {} : { jobId: config.sourceJobId },
|
|
17170
|
-
opId: "canary.record"
|
|
17171
|
-
},
|
|
17172
|
-
attributedObservationId: canaryOutcomeObservationId(outcome),
|
|
17173
|
-
corpusVersion: { corpusDigest: outcome.corpusDigest },
|
|
17174
|
-
benefit: outcome.runOutcome === "negative" ? "exercised-harmed" : outcome.benefit,
|
|
17175
|
-
stateValidity: outcome.stateValidity,
|
|
17176
|
-
runId: outcome.runId,
|
|
17177
|
-
testIndex: outcome.testIndex,
|
|
17178
|
-
stepIndex: outcome.stepIndex,
|
|
17179
|
-
attribution: outcome.attribution,
|
|
17180
|
-
...outcome.observedStateDigest === void 0 ? {} : { observedStateDigest: outcome.observedStateDigest },
|
|
17181
|
-
...outcome.ablation === void 0 ? {} : {
|
|
17182
|
-
crossCheck: outcome.ablation.crossCheck,
|
|
17183
|
-
samples: {
|
|
17184
|
-
k: outcome.ablation.k,
|
|
17185
|
-
seeds: outcome.ablation.seeds,
|
|
17186
|
-
seedHonored: outcome.ablation.seedHonored,
|
|
17187
|
-
modelCalls: outcome.ablation.spend.modelCalls
|
|
17188
|
-
},
|
|
17189
|
-
spend: outcome.ablation.spend
|
|
17190
|
-
}
|
|
17191
|
-
});
|
|
17192
|
-
}
|
|
17193
16986
|
const store = {
|
|
17194
16987
|
proposeDeltas(deltas) {
|
|
17195
16988
|
return commitWithProfile(deltas, { mode: "propose-only" });
|
|
@@ -17198,7 +16991,7 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17198
16991
|
return commitWithProfile(deltas, dispositionProfileFor(config, authority));
|
|
17199
16992
|
},
|
|
17200
16993
|
async recordCanaryOutcome(outcome) {
|
|
17201
|
-
const resolved = resolveTruth(config.knowledgeRoot, outcome.candidateId
|
|
16994
|
+
const resolved = resolveTruth(config.knowledgeRoot, outcome.candidateId);
|
|
17202
16995
|
if (resolved === void 0) {
|
|
17203
16996
|
throw new KnowledgePromotionError(outcome.candidateId, "not-found");
|
|
17204
16997
|
}
|
|
@@ -17225,11 +17018,6 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17225
17018
|
await store.commit([confirm]);
|
|
17226
17019
|
config.canaryAuthorityHooks?.beforePromotionAppend?.();
|
|
17227
17020
|
withCurrentWriterAuthority(config.knowledgeRoot, currentAuthority(config), () => {
|
|
17228
|
-
if (outcome.benefit === "exercised-benefited" && outcome.corpusDigest !== void 0) {
|
|
17229
|
-
const receipt = gate2ReceiptFor(outcome, "pass");
|
|
17230
|
-
const appendConfig = bundleStoreConfig(resolved.product);
|
|
17231
|
-
checkedAppend(outcome.candidateId, appendGateReceipt(appendConfig, outcome.candidateId, receipt));
|
|
17232
|
-
}
|
|
17233
17021
|
try {
|
|
17234
17022
|
promoteWithinCurrentAuthority(outcome.candidateId);
|
|
17235
17023
|
} catch (error) {
|
|
@@ -17244,19 +17032,6 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17244
17032
|
const appendConfig = bundleStoreConfig(resolved.product);
|
|
17245
17033
|
config.canaryAuthorityHooks?.beforeNegativeAppend?.();
|
|
17246
17034
|
withCurrentWriterAuthority(config.knowledgeRoot, currentAuthority(config), () => {
|
|
17247
|
-
if (outcome.corpusDigest !== void 0 && outcome.stateValidity === "stale") {
|
|
17248
|
-
const current = resolveTruth(config.knowledgeRoot, outcome.candidateId, priors);
|
|
17249
|
-
if (current === void 0) throw new KnowledgePromotionError(outcome.candidateId, "not-found");
|
|
17250
|
-
const validity = deriveBundleTrust(current.bundle, priors).validity;
|
|
17251
|
-
const insideWindow = (ordinal) => ordinal >= validity.openedAtOrdinal && (validity.closedAtOrdinal === void 0 || ordinal <= validity.closedAtOrdinal);
|
|
17252
|
-
const priorRuns = new Set((readGateReceipts(current.bundleDir, outcome.candidateId) ?? []).flatMap((receipt) => !isPromotionReceipt4(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] : []));
|
|
17253
|
-
if (!insideWindow(outcome.buildOrdinal) || priorRuns.size + 1 < GATE2_DEFAULT_STALE_CONFIRMATIONS) {
|
|
17254
|
-
const receipt = gate2ReceiptFor(outcome, "abstain");
|
|
17255
|
-
checkedAppend(outcome.candidateId, appendGateReceipt(appendConfig, outcome.candidateId, receipt));
|
|
17256
|
-
config.onCanaryTailWithinCurrentAuthority?.();
|
|
17257
|
-
return;
|
|
17258
|
-
}
|
|
17259
|
-
}
|
|
17260
17035
|
const appended = appendOutcomeEvent(appendConfig, outcome.candidateId, {
|
|
17261
17036
|
type: "contradicted",
|
|
17262
17037
|
evidenceToken,
|
|
@@ -17269,19 +17044,8 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17269
17044
|
if (appended.kind === "not-found") {
|
|
17270
17045
|
throw new KnowledgePromotionError(outcome.candidateId, appended.kind);
|
|
17271
17046
|
}
|
|
17272
|
-
if (outcome.corpusDigest !== void 0) {
|
|
17273
|
-
const receipt = gate2ReceiptFor(outcome, "fail");
|
|
17274
|
-
checkedAppend(outcome.candidateId, appendGateReceipt(appendConfig, outcome.candidateId, receipt));
|
|
17275
|
-
try {
|
|
17276
|
-
promoteWithinCurrentAuthority(outcome.candidateId);
|
|
17277
|
-
} catch (error) {
|
|
17278
|
-
if (!expectedPromotionHold(error)) throw error;
|
|
17279
|
-
reportHold(error);
|
|
17280
|
-
}
|
|
17281
|
-
}
|
|
17282
17047
|
config.canaryAuthorityHooks?.beforeIndexProjection?.();
|
|
17283
17048
|
applyIndexDeltaForBundleWithinCurrentAuthority({
|
|
17284
|
-
...priors === void 0 ? {} : { priors },
|
|
17285
17049
|
knowledgeRoot: config.knowledgeRoot,
|
|
17286
17050
|
bundleId: outcome.candidateId,
|
|
17287
17051
|
product: resolved.product
|
|
@@ -17300,7 +17064,7 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17300
17064
|
if (profile.mode === "propose-only") {
|
|
17301
17065
|
throw new KnowledgePromotionError(candidateId, "propose-only");
|
|
17302
17066
|
}
|
|
17303
|
-
const resolved = resolveTruth(config.knowledgeRoot, candidateId
|
|
17067
|
+
const resolved = resolveTruth(config.knowledgeRoot, candidateId);
|
|
17304
17068
|
if (resolved === void 0) throw new KnowledgePromotionError(candidateId, "not-found");
|
|
17305
17069
|
const validated = (receipts ?? []).map((receipt) => {
|
|
17306
17070
|
const parsed = GateReceiptSchema2.parse(receipt);
|
|
@@ -17321,7 +17085,7 @@ function buildLocalKnowledgeStore(config, authority) {
|
|
|
17321
17085
|
async recordGateReceipt(receipt) {
|
|
17322
17086
|
return withCurrentWriterAuthority(config.knowledgeRoot, currentAuthority(config), () => {
|
|
17323
17087
|
const candidateId = asRecordId7(receipt.candidateId);
|
|
17324
|
-
const resolved = resolveTruth(config.knowledgeRoot, candidateId
|
|
17088
|
+
const resolved = resolveTruth(config.knowledgeRoot, candidateId);
|
|
17325
17089
|
if (resolved === void 0) throw new KnowledgePromotionError(candidateId, "not-found");
|
|
17326
17090
|
return checkedAppend(candidateId, appendGateReceipt(bundleStoreConfig(resolved.product), candidateId, receipt));
|
|
17327
17091
|
});
|
|
@@ -17358,10 +17122,8 @@ async function runWriterPass(options, operations) {
|
|
|
17358
17122
|
const injectedRebuild = options.operations?.rebuildIndex !== void 0;
|
|
17359
17123
|
const rebuild = await operations.rebuildIndex({
|
|
17360
17124
|
knowledgeRoot: options.knowledgeRoot,
|
|
17361
|
-
...options.priors === void 0 ? {} : { priors: options.priors },
|
|
17362
17125
|
...capability.kind === "ready" ? { embedder: capability.embedder } : {},
|
|
17363
|
-
// Production rebuilds
|
|
17364
|
-
// Fault-injection rebuilds keep their historical call shape and own their injected behavior.
|
|
17126
|
+
// Production rebuilds re-check the authority fence at every mutation boundary.
|
|
17365
17127
|
...injectedRebuild ? {} : {
|
|
17366
17128
|
writerAuthority: {
|
|
17367
17129
|
knowledgeRoot: options.knowledgeRoot,
|
|
@@ -17380,8 +17142,6 @@ function shouldSurfaceAuthorityLoss(options, error) {
|
|
|
17380
17142
|
return options.surfaceAuthorityLoss !== false && error instanceof WriterAuthorityLostError;
|
|
17381
17143
|
}
|
|
17382
17144
|
async function runMaintenanceTail(options) {
|
|
17383
|
-
const priors = snapshotTrustPriors(options.priors);
|
|
17384
|
-
options = { ...options, ...priors === void 0 ? {} : { priors } };
|
|
17385
17145
|
const operations = {
|
|
17386
17146
|
...DEFAULT_OPERATIONS,
|
|
17387
17147
|
...options.operations
|
|
@@ -17516,10 +17276,6 @@ function readClaimedCanaryOutcome(claimed) {
|
|
|
17516
17276
|
candidateId: asRecordId8(read.payload.candidateId),
|
|
17517
17277
|
runOutcome: read.payload.outcome,
|
|
17518
17278
|
benefit: read.payload.benefit,
|
|
17519
|
-
stateValidity: read.payload.stateValidity,
|
|
17520
|
-
...read.payload.corpusDigest === void 0 ? {} : { corpusDigest: read.payload.corpusDigest },
|
|
17521
|
-
...read.payload.observedStateDigest === void 0 ? {} : { observedStateDigest: read.payload.observedStateDigest },
|
|
17522
|
-
...read.payload.ablation === void 0 ? {} : { ablation: read.payload.ablation },
|
|
17523
17279
|
runId: read.payload.runId,
|
|
17524
17280
|
testId: read.payload.testId,
|
|
17525
17281
|
testIndex: read.payload.testIndex,
|
|
@@ -17893,24 +17649,16 @@ function isSuccessfulTerminalCommitOutcome(outcome) {
|
|
|
17893
17649
|
return false;
|
|
17894
17650
|
}
|
|
17895
17651
|
}
|
|
17896
|
-
function reconcileDependencies(operations, knowledgeRoot, writerAuthority
|
|
17652
|
+
function reconcileDependencies(operations, knowledgeRoot, writerAuthority) {
|
|
17897
17653
|
return {
|
|
17898
17654
|
knowledgeRoot,
|
|
17899
17655
|
writerAuthority,
|
|
17900
17656
|
hasIndexRow: (bundleId) => operations.hasIndexRow(knowledgeRoot, bundleId),
|
|
17901
17657
|
applyIndexDelta: (intent) => {
|
|
17902
|
-
operations.applyIndexDeltaForBundle({
|
|
17903
|
-
knowledgeRoot,
|
|
17904
|
-
bundleId: intent.bundleId,
|
|
17905
|
-
...priors === void 0 ? {} : { priors }
|
|
17906
|
-
});
|
|
17658
|
+
operations.applyIndexDeltaForBundle({ knowledgeRoot, bundleId: intent.bundleId });
|
|
17907
17659
|
},
|
|
17908
17660
|
deriveIndexRowFromBundle: (bundleId) => {
|
|
17909
|
-
operations.deriveIndexRowFromBundle({
|
|
17910
|
-
knowledgeRoot,
|
|
17911
|
-
bundleId,
|
|
17912
|
-
...priors === void 0 ? {} : { priors }
|
|
17913
|
-
});
|
|
17661
|
+
operations.deriveIndexRowFromBundle({ knowledgeRoot, bundleId });
|
|
17914
17662
|
}
|
|
17915
17663
|
};
|
|
17916
17664
|
}
|
|
@@ -17923,7 +17671,6 @@ function budgetMs(options) {
|
|
|
17923
17671
|
return value;
|
|
17924
17672
|
}
|
|
17925
17673
|
async function drainQueue(options) {
|
|
17926
|
-
const priors = snapshotTrustPriors(options.priors);
|
|
17927
17674
|
const operations = { ...DEFAULT_OPERATIONS2, ...options.operations };
|
|
17928
17675
|
const now = options.now ?? Date.now;
|
|
17929
17676
|
const startedAt = now();
|
|
@@ -17958,7 +17705,7 @@ async function drainQueue(options) {
|
|
|
17958
17705
|
try {
|
|
17959
17706
|
try {
|
|
17960
17707
|
result.reconcile = operations.reconcileOnDrainStart(
|
|
17961
|
-
reconcileDependencies(operations, options.knowledgeRoot, lease
|
|
17708
|
+
reconcileDependencies(operations, options.knowledgeRoot, lease)
|
|
17962
17709
|
);
|
|
17963
17710
|
} catch (error) {
|
|
17964
17711
|
recordFailure(result, "reconcile", error);
|
|
@@ -18032,15 +17779,8 @@ async function drainQueue(options) {
|
|
|
18032
17779
|
sourceRunId: canaryOutcome.runId,
|
|
18033
17780
|
sourceJobId: claimed.candidateId,
|
|
18034
17781
|
writerLeaseId: lease.leaseId,
|
|
18035
|
-
...priors === void 0 ? {} : { resolveTrustPriors: () => priors },
|
|
18036
|
-
...options.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: options.resolvePromotionPosture },
|
|
18037
17782
|
onPromotionOutcome: (outcome) => result.promotions.push(outcome),
|
|
18038
|
-
|
|
18039
|
-
* CR-02: the terminal transition joins the canary tail's own held section through
|
|
18040
|
-
* the within-held form. Calling the fenced writeJobState here would re-enter
|
|
18041
|
-
* withCurrentWriterAuthority against a BEGIN IMMEDIATE the tail already holds and
|
|
18042
|
-
* deadlock (the Plan 25/28 within-held idiom).
|
|
18043
|
-
*/
|
|
17783
|
+
// Within-held form: the fenced write would re-enter the held transaction and deadlock.
|
|
18044
17784
|
onCanaryTailWithinCurrentAuthority: () => {
|
|
18045
17785
|
writeJobStateWithinCurrentAuthority({
|
|
18046
17786
|
knowledgeRoot: options.knowledgeRoot,
|
|
@@ -18158,8 +17898,6 @@ async function drainQueue(options) {
|
|
|
18158
17898
|
epoch: lease.epoch,
|
|
18159
17899
|
profile: resolveDispositionProfile(executionContext),
|
|
18160
17900
|
drainState,
|
|
18161
|
-
...priors === void 0 ? {} : { priors },
|
|
18162
|
-
...options.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: options.resolvePromotionPosture },
|
|
18163
17901
|
...!finalDelta || anySliceFailed ? { deferCompletion: true } : {}
|
|
18164
17902
|
},
|
|
18165
17903
|
claimed,
|
|
@@ -18234,7 +17972,6 @@ async function drainQueue(options) {
|
|
|
18234
17972
|
} else {
|
|
18235
17973
|
const maintenance = await runMaintenanceTail({
|
|
18236
17974
|
knowledgeRoot: options.knowledgeRoot,
|
|
18237
|
-
...priors === void 0 ? {} : { priors },
|
|
18238
17975
|
lease,
|
|
18239
17976
|
...options.embeddingCapability === void 0 ? {} : { embeddingCapability: options.embeddingCapability },
|
|
18240
17977
|
operations,
|
|
@@ -18298,7 +18035,7 @@ import {
|
|
|
18298
18035
|
rmSync as rmSync14,
|
|
18299
18036
|
writeFileSync as writeFileSync11
|
|
18300
18037
|
} from "node:fs";
|
|
18301
|
-
import { basename as
|
|
18038
|
+
import { basename as basename11, dirname as dirname16, isAbsolute as isAbsolute11, join as join34, relative as relative4, sep as sep4 } from "node:path";
|
|
18302
18039
|
import {
|
|
18303
18040
|
canonicalJson as canonicalJson34,
|
|
18304
18041
|
committedFileText as committedFileText3,
|
|
@@ -18540,7 +18277,7 @@ function payloadDirectories(root) {
|
|
|
18540
18277
|
return found.sort();
|
|
18541
18278
|
}
|
|
18542
18279
|
function removeEmptyQueueParents(candidateDir, root, beforeMutation) {
|
|
18543
|
-
let current =
|
|
18280
|
+
let current = dirname16(candidateDir);
|
|
18544
18281
|
while (current !== root && current.startsWith(`${root}${sep4}`)) {
|
|
18545
18282
|
try {
|
|
18546
18283
|
beforeMutation?.();
|
|
@@ -18548,13 +18285,13 @@ function removeEmptyQueueParents(candidateDir, root, beforeMutation) {
|
|
|
18548
18285
|
} catch (error) {
|
|
18549
18286
|
const code = error.code;
|
|
18550
18287
|
if (code === "ENOENT") {
|
|
18551
|
-
current =
|
|
18288
|
+
current = dirname16(current);
|
|
18552
18289
|
continue;
|
|
18553
18290
|
}
|
|
18554
18291
|
if (code === "ENOTEMPTY" || code === "EEXIST") return;
|
|
18555
18292
|
throw error;
|
|
18556
18293
|
}
|
|
18557
|
-
current =
|
|
18294
|
+
current = dirname16(current);
|
|
18558
18295
|
}
|
|
18559
18296
|
}
|
|
18560
18297
|
function lineageCandidateIds(matches) {
|
|
@@ -18582,8 +18319,8 @@ function contentSeeds(matches) {
|
|
|
18582
18319
|
function artifactDigests(matches) {
|
|
18583
18320
|
const digests = /* @__PURE__ */ new Set();
|
|
18584
18321
|
for (const { bundle } of matches) {
|
|
18585
|
-
for (const
|
|
18586
|
-
digests.add(
|
|
18322
|
+
for (const digest2 of Object.values(bundle.manifest.contentHashes)) {
|
|
18323
|
+
digests.add(digest2);
|
|
18587
18324
|
}
|
|
18588
18325
|
}
|
|
18589
18326
|
return digests;
|
|
@@ -18597,8 +18334,8 @@ function looselyCarriesPurgedContent(payload, seeds, digests) {
|
|
|
18597
18334
|
const inventory = Array.isArray(loose["artifactInventory"]) ? loose["artifactInventory"] : [];
|
|
18598
18335
|
return seedMatch || inventory.some((artifact) => {
|
|
18599
18336
|
if (typeof artifact !== "object" || artifact === null) return false;
|
|
18600
|
-
const
|
|
18601
|
-
return typeof
|
|
18337
|
+
const digest2 = artifact["sha256"];
|
|
18338
|
+
return typeof digest2 === "string" && digests.has(digest2);
|
|
18602
18339
|
});
|
|
18603
18340
|
}
|
|
18604
18341
|
function resolveQueueSweepTargets(knowledgeRoot, matches) {
|
|
@@ -18607,7 +18344,7 @@ function resolveQueueSweepTargets(knowledgeRoot, matches) {
|
|
|
18607
18344
|
const digests = artifactDigests(matches);
|
|
18608
18345
|
const targets = [];
|
|
18609
18346
|
for (const candidateDir of payloadDirectories(queueRoot(knowledgeRoot))) {
|
|
18610
|
-
const candidateId =
|
|
18347
|
+
const candidateId = basename11(candidateDir);
|
|
18611
18348
|
if (!QUEUE_CANDIDATE_ID.test(candidateId)) {
|
|
18612
18349
|
throw new PurgeQueueIdentityError(candidateDir, "non-canonical candidate directory");
|
|
18613
18350
|
}
|
|
@@ -18660,7 +18397,7 @@ function sweepQueuePayloads(input, targets) {
|
|
|
18660
18397
|
assertWithinKnowledgeRoot(input.knowledgeRoot, target.candidateDir);
|
|
18661
18398
|
assertWithinKnowledgeRoot(
|
|
18662
18399
|
input.knowledgeRoot,
|
|
18663
|
-
|
|
18400
|
+
dirname16(jobStatePath(input.knowledgeRoot, target.candidateId))
|
|
18664
18401
|
);
|
|
18665
18402
|
fenceWriterAuthority(input);
|
|
18666
18403
|
rmSync14(target.candidateDir, { recursive: true, force: true });
|
|
@@ -18724,7 +18461,7 @@ function verifyPurgeCompletion(input, intent) {
|
|
|
18724
18461
|
}
|
|
18725
18462
|
const candidateIds = new Set(intent.queueCandidateIds);
|
|
18726
18463
|
for (const dir of payloadDirectories(queueRoot(input.knowledgeRoot))) {
|
|
18727
|
-
if (candidateIds.has(
|
|
18464
|
+
if (candidateIds.has(basename11(dir))) {
|
|
18728
18465
|
throw new PurgeCompletionVerificationError(toReceiptPath(input.knowledgeRoot, dir));
|
|
18729
18466
|
}
|
|
18730
18467
|
}
|
|
@@ -18745,7 +18482,7 @@ function readReceiptAtCycle(knowledgeRoot, recordId, cycle) {
|
|
|
18745
18482
|
if (!existsSync23(file)) return void 0;
|
|
18746
18483
|
return guardPurgeReceiptForFile(
|
|
18747
18484
|
JSON.parse(readFileSync22(file, "utf8")),
|
|
18748
|
-
|
|
18485
|
+
basename11(file),
|
|
18749
18486
|
{ recordId, cycle }
|
|
18750
18487
|
);
|
|
18751
18488
|
}
|
|
@@ -19049,7 +18786,7 @@ function buildReceipt(input, matches, occurrenceOrdinal) {
|
|
|
19049
18786
|
});
|
|
19050
18787
|
}
|
|
19051
18788
|
function writeDurableExclusive(finalPath, text, beforeMutation) {
|
|
19052
|
-
const directory =
|
|
18789
|
+
const directory = dirname16(finalPath);
|
|
19053
18790
|
beforeMutation?.();
|
|
19054
18791
|
mkdirSync18(directory, { recursive: true });
|
|
19055
18792
|
const temporary = `${finalPath}.tmp-${randomUUID12()}`;
|
|
@@ -19092,13 +18829,13 @@ function retireIntent(input) {
|
|
|
19092
18829
|
if (!existsSync23(file)) return;
|
|
19093
18830
|
fenceWriterAuthority(input);
|
|
19094
18831
|
rmSync14(file, { force: true });
|
|
19095
|
-
fsyncDirectory(
|
|
18832
|
+
fsyncDirectory(dirname16(file));
|
|
19096
18833
|
}
|
|
19097
18834
|
function publishReceiptAndRetire(input, receiptText, receipt, receiptCycle) {
|
|
19098
18835
|
input.hooks?.beforeReceiptPublish?.();
|
|
19099
18836
|
assertWithinKnowledgeRoot(
|
|
19100
18837
|
input.knowledgeRoot,
|
|
19101
|
-
|
|
18838
|
+
dirname16(receiptCyclePath(input.knowledgeRoot, input.recordId, receiptCycle))
|
|
19102
18839
|
);
|
|
19103
18840
|
const writeOutcome = writeDurableExclusive(
|
|
19104
18841
|
receiptCyclePath(input.knowledgeRoot, input.recordId, receiptCycle),
|
|
@@ -19182,7 +18919,7 @@ function purgeRecord(input) {
|
|
|
19182
18919
|
queueSweepTargets,
|
|
19183
18920
|
resolved.affectedSet
|
|
19184
18921
|
);
|
|
19185
|
-
assertWithinKnowledgeRoot(input.knowledgeRoot,
|
|
18922
|
+
assertWithinKnowledgeRoot(input.knowledgeRoot, dirname16(intentPath2(input.knowledgeRoot, input.recordId)));
|
|
19186
18923
|
const intentOutcome = writeDurableExclusive(
|
|
19187
18924
|
intentPath2(input.knowledgeRoot, input.recordId),
|
|
19188
18925
|
committedFileText3(intent),
|
|
@@ -19307,7 +19044,7 @@ function toInspectRecordView(entry, bundle, trust) {
|
|
|
19307
19044
|
survivingEvents.map((event) => String(event.evidenceToken))
|
|
19308
19045
|
)].sort(compareText10);
|
|
19309
19046
|
const lastEventOrdinal = survivingEvents.reduce(
|
|
19310
|
-
(
|
|
19047
|
+
(latest, event) => Math.max(latest, event.buildOrdinal),
|
|
19311
19048
|
bundle.manifest.createdAtOrdinal
|
|
19312
19049
|
);
|
|
19313
19050
|
const trustNarrative = readTrustNarrative(entry.dir, bundle);
|
|
@@ -19474,12 +19211,12 @@ import {
|
|
|
19474
19211
|
asRecordId as asRecordId10,
|
|
19475
19212
|
canonicalJson as canonicalJson37,
|
|
19476
19213
|
deriveMarkStepId,
|
|
19477
|
-
stampReceiptDigest as
|
|
19214
|
+
stampReceiptDigest as stampReceiptDigest2
|
|
19478
19215
|
} from "@vostride/agent-qa-schema";
|
|
19479
19216
|
|
|
19480
19217
|
// src/policy/materialize.ts
|
|
19481
19218
|
import { closeSync as closeSync9, existsSync as existsSync25, fsyncSync as fsyncSync9, mkdirSync as mkdirSync19, openSync as openSync9, readFileSync as readFileSync24, renameSync as renameSync10, rmSync as rmSync15, writeFileSync as writeFileSync12 } from "node:fs";
|
|
19482
|
-
import { dirname as
|
|
19219
|
+
import { dirname as dirname17, join as join36, relative as relative5 } from "node:path";
|
|
19483
19220
|
import { slugBranch as slugBranch9 } from "@vostride/agent-qa-schema";
|
|
19484
19221
|
var PolicyTextRefusedError = class extends Error {
|
|
19485
19222
|
constructor() {
|
|
@@ -19503,7 +19240,7 @@ function materializeUnderAuthority(input) {
|
|
|
19503
19240
|
}
|
|
19504
19241
|
const { open, close } = policySectionMarkers(input.recordId);
|
|
19505
19242
|
const path = policyShelfPath(input.knowledgeRoot, input.scope);
|
|
19506
|
-
assertWithinKnowledgeRoot(input.knowledgeRoot,
|
|
19243
|
+
assertWithinKnowledgeRoot(input.knowledgeRoot, dirname17(path));
|
|
19507
19244
|
const relPath = relative5(input.knowledgeRoot, path);
|
|
19508
19245
|
const section = `
|
|
19509
19246
|
${open}
|
|
@@ -19541,7 +19278,7 @@ ${close}
|
|
|
19541
19278
|
if (input.existingOnly) throw new PolicyTextRefusedError();
|
|
19542
19279
|
const text = `${exists ? "" : `# Policies \u2014 ${input.scope}
|
|
19543
19280
|
`}${section}`;
|
|
19544
|
-
mkdirSync19(
|
|
19281
|
+
mkdirSync19(dirname17(path), { recursive: true });
|
|
19545
19282
|
const staged = `${path}.pending`;
|
|
19546
19283
|
let fd;
|
|
19547
19284
|
try {
|
|
@@ -19570,7 +19307,7 @@ import {
|
|
|
19570
19307
|
rmSync as rmSync16,
|
|
19571
19308
|
writeFileSync as writeFileSync13
|
|
19572
19309
|
} from "node:fs";
|
|
19573
|
-
import { dirname as
|
|
19310
|
+
import { dirname as dirname18, isAbsolute as isAbsolute12, join as join37 } from "node:path";
|
|
19574
19311
|
import {
|
|
19575
19312
|
ForgetReceiptV1Schema,
|
|
19576
19313
|
KnowledgeChangeIdSchema
|
|
@@ -19601,12 +19338,12 @@ function readRecordedForgetReceipt(knowledgeRoot, changeId) {
|
|
|
19601
19338
|
}
|
|
19602
19339
|
function recordForgetReceipt(knowledgeRoot, authority, receipt) {
|
|
19603
19340
|
const file = receiptFile(knowledgeRoot, ForgetReceiptV1Schema.parse(receipt).proposalId);
|
|
19604
|
-
assertWithinKnowledgeRoot(knowledgeRoot,
|
|
19341
|
+
assertWithinKnowledgeRoot(knowledgeRoot, dirname18(file));
|
|
19605
19342
|
const text = `${JSON.stringify(receipt)}
|
|
19606
19343
|
`;
|
|
19607
19344
|
withCurrentWriterAuthority(knowledgeRoot, authority, () => {
|
|
19608
|
-
mkdirSync20(
|
|
19609
|
-
fsyncDirectory(
|
|
19345
|
+
mkdirSync20(dirname18(file), { recursive: true });
|
|
19346
|
+
fsyncDirectory(dirname18(dirname18(file)));
|
|
19610
19347
|
const temporary = `${file}.tmp-${randomUUID13()}`;
|
|
19611
19348
|
let fd;
|
|
19612
19349
|
try {
|
|
@@ -19616,7 +19353,7 @@ function recordForgetReceipt(knowledgeRoot, authority, receipt) {
|
|
|
19616
19353
|
closeSync10(fd);
|
|
19617
19354
|
fd = void 0;
|
|
19618
19355
|
renameSync11(temporary, file);
|
|
19619
|
-
fsyncDirectory(
|
|
19356
|
+
fsyncDirectory(dirname18(file));
|
|
19620
19357
|
} finally {
|
|
19621
19358
|
if (fd !== void 0) closeSync10(fd);
|
|
19622
19359
|
rmSync16(temporary, { force: true });
|
|
@@ -19639,7 +19376,7 @@ var ApplyDelegateTimeoutError = class extends Error {
|
|
|
19639
19376
|
var ApplyDelegateUnavailableError = class extends Error {
|
|
19640
19377
|
constructor(changeId, holder) {
|
|
19641
19378
|
super(
|
|
19642
|
-
`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
|
|
19379
|
+
`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.`
|
|
19643
19380
|
);
|
|
19644
19381
|
this.changeId = changeId;
|
|
19645
19382
|
this.holder = holder;
|
|
@@ -19739,9 +19476,7 @@ function reviewStore(writer, change, lease, sourceBuildOrdinal) {
|
|
|
19739
19476
|
epoch: lease.epoch,
|
|
19740
19477
|
writerLeaseId: lease.leaseId,
|
|
19741
19478
|
...change.mark === void 0 ? {} : { sourceRunId: change.mark.runId },
|
|
19742
|
-
...sourceBuildOrdinal === void 0 ? {} : { sourceBuildOrdinal }
|
|
19743
|
-
...writer.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: writer.resolvePromotionPosture },
|
|
19744
|
-
...writer.resolveTrustPriors === void 0 ? {} : { resolveTrustPriors: writer.resolveTrustPriors }
|
|
19479
|
+
...sourceBuildOrdinal === void 0 ? {} : { sourceBuildOrdinal }
|
|
19745
19480
|
});
|
|
19746
19481
|
}
|
|
19747
19482
|
async function commitInProcess(writer, change, lease, sourceBuildOrdinal) {
|
|
@@ -19777,7 +19512,7 @@ function readBackCommittedIds(knowledgeRoot, preOrdinal, change) {
|
|
|
19777
19512
|
}
|
|
19778
19513
|
function mintGate3Receipt(candidateId, writer, change, producedAtOrdinal) {
|
|
19779
19514
|
if (change.mark === void 0) throw new TypeError("mark change has no mark stamp");
|
|
19780
|
-
return
|
|
19515
|
+
return stampReceiptDigest2({
|
|
19781
19516
|
schemaVersion: GATE_RECEIPT_SCHEMA_VERSION3,
|
|
19782
19517
|
gate: 3,
|
|
19783
19518
|
candidateId,
|
|
@@ -19898,7 +19633,7 @@ async function applyPolicyArm(writer, change, authority, recordId, record) {
|
|
|
19898
19633
|
throw new ReviewTargetVanishedError(change.id);
|
|
19899
19634
|
}
|
|
19900
19635
|
const committedAtOrdinal = currentOrdinal(writer.knowledgeRoot);
|
|
19901
|
-
const receipt =
|
|
19636
|
+
const receipt = stampReceiptDigest2({
|
|
19902
19637
|
schemaVersion: GATE_RECEIPT_SCHEMA_VERSION3,
|
|
19903
19638
|
gate: 3,
|
|
19904
19639
|
candidateId: recordId,
|
|
@@ -19937,7 +19672,7 @@ async function recoverPolicyArm(writer, change, authority, recordId) {
|
|
|
19937
19672
|
const shelfScope = scope.tier === "global" ? "global" : scope.key;
|
|
19938
19673
|
const relPath = relative6(writer.knowledgeRoot, policyShelfPath(writer.knowledgeRoot, shelfScope));
|
|
19939
19674
|
if (replacement?.bundle.frontmatter.kind !== "policy" || memoryStatusForBundle(replacement.status) === "tombstoned" || replacement.bundle.body !== `${relPath}#agent-qa:policy ${recordId}` || canonicalJson37(replacement.bundle.frontmatter.scope) !== canonicalJson37(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);
|
|
19940
|
-
const receipt =
|
|
19675
|
+
const receipt = stampReceiptDigest2({
|
|
19941
19676
|
schemaVersion: GATE_RECEIPT_SCHEMA_VERSION3,
|
|
19942
19677
|
gate: 3,
|
|
19943
19678
|
candidateId: recordId,
|
|
@@ -20098,13 +19833,10 @@ async function applyExplicitReview(input) {
|
|
|
20098
19833
|
if (typeof input.opId !== "string" || input.opId.length === 0) {
|
|
20099
19834
|
throw new TypeError("applyExplicitReview needs the op id that makes the change");
|
|
20100
19835
|
}
|
|
20101
|
-
const priors = snapshotTrustPriors(input.resolveTrustPriors?.());
|
|
20102
19836
|
const writer = {
|
|
20103
19837
|
knowledgeRoot: input.knowledgeRoot,
|
|
20104
19838
|
executionContext: input.executionContext,
|
|
20105
19839
|
opId: input.opId,
|
|
20106
|
-
...input.resolvePromotionPosture === void 0 ? {} : { resolvePromotionPosture: input.resolvePromotionPosture },
|
|
20107
|
-
...input.resolveTrustPriors === void 0 ? {} : { resolveTrustPriors: () => priors },
|
|
20108
19840
|
...input.now === void 0 ? {} : { now: input.now }
|
|
20109
19841
|
};
|
|
20110
19842
|
if (input.writerAuthority !== void 0) {
|
|
@@ -20642,7 +20374,6 @@ function bundleConfig(input, productKey) {
|
|
|
20642
20374
|
return {
|
|
20643
20375
|
knowledgeRoot: input.knowledgeRoot,
|
|
20644
20376
|
productKey,
|
|
20645
|
-
commitArtifacts: "none",
|
|
20646
20377
|
...input.writerAuthority === void 0 ? {} : { writerLeaseId: input.writerAuthority.leaseId }
|
|
20647
20378
|
};
|
|
20648
20379
|
}
|
|
@@ -20750,13 +20481,13 @@ function appendRetraction(input, resolution, target) {
|
|
|
20750
20481
|
);
|
|
20751
20482
|
}
|
|
20752
20483
|
function latestSurvivingLifecycleOrdinal(bundle) {
|
|
20753
|
-
let
|
|
20484
|
+
let latest = bundle.manifest.createdAtOrdinal;
|
|
20754
20485
|
for (const event of survivingOutcomeEvents9(bundle.events)) {
|
|
20755
|
-
if ((event.type === "promoted" || event.type === "superseded" || event.type === "deprecated") && event.buildOrdinal >
|
|
20756
|
-
|
|
20486
|
+
if ((event.type === "promoted" || event.type === "superseded" || event.type === "deprecated") && event.buildOrdinal > latest) {
|
|
20487
|
+
latest = event.buildOrdinal;
|
|
20757
20488
|
}
|
|
20758
20489
|
}
|
|
20759
|
-
return
|
|
20490
|
+
return latest;
|
|
20760
20491
|
}
|
|
20761
20492
|
function assertCausalResolution(input, resolution) {
|
|
20762
20493
|
const offenders = [];
|
|
@@ -20859,70 +20590,6 @@ function rollbackCampaign(input) {
|
|
|
20859
20590
|
return emitRollback(input, resolveCampaign(input), () => resolveCampaign(input));
|
|
20860
20591
|
}
|
|
20861
20592
|
|
|
20862
|
-
// src/gates/canary-posture-facts.ts
|
|
20863
|
-
import {
|
|
20864
|
-
asRecordId as asRecordId12,
|
|
20865
|
-
isPromotionReceipt as isPromotionReceipt5,
|
|
20866
|
-
standingReceiptsByGate,
|
|
20867
|
-
strongestPromotionPath as strongestPromotionPath4,
|
|
20868
|
-
survivingOutcomeEvents as survivingOutcomeEvents10
|
|
20869
|
-
} from "@vostride/agent-qa-schema";
|
|
20870
|
-
function readBundles(knowledgeRoot, resolveTrustPriors) {
|
|
20871
|
-
return enumerateMaintenanceBundleDirs(knowledgeRoot).map((entry) => {
|
|
20872
|
-
const bundle = loadMaintenanceBundle(entry);
|
|
20873
|
-
const lines = readGateReceipts(entry.dir, bundle.manifest.id) ?? [];
|
|
20874
|
-
return { ...entry, bundle, lines, active: deriveBundleTrust(bundle, resolveTrustPriors?.()).status === "active" };
|
|
20875
|
-
});
|
|
20876
|
-
}
|
|
20877
|
-
function latest(ordinals) {
|
|
20878
|
-
return ordinals.length === 0 ? void 0 : Math.max(...ordinals);
|
|
20879
|
-
}
|
|
20880
|
-
function canaryPostureFactsFor(input) {
|
|
20881
|
-
const id = asRecordId12(input.candidateId);
|
|
20882
|
-
const rows = readBundles(input.knowledgeRoot, input.resolveTrustPriors);
|
|
20883
|
-
const candidate2 = rows.find((row) => row.bundle.manifest.id === id);
|
|
20884
|
-
if (candidate2 === void 0) return { kind: "not-found" };
|
|
20885
|
-
const scope = candidate2.bundle.frontmatter.scope;
|
|
20886
|
-
if (scope.tier !== "product" || input.scope.tier !== "product" || scope.key !== input.scope.key) return { kind: "not-found" };
|
|
20887
|
-
const receipts = candidate2.lines.filter((line) => !isPromotionReceipt5(line));
|
|
20888
|
-
const pass = standingReceiptsByGate(receipts).find((row) => row.gate === 1 && row.verdict === "pass");
|
|
20889
|
-
const lowerTrustActiveGate1Digest = candidate2.active && strongestPromotionPath4(candidate2.lines) === "gate1-lower-trust" && survivingOutcomeEvents10(candidate2.bundle.events).some((event) => event.type === "promoted") && pass !== void 0 && candidate2.lines.some((line) => isPromotionReceipt5(line) && line.promotionPath === "gate1-lower-trust" && line.citedReceiptDigests.includes(pass.receiptDigest)) ? pass.receiptDigest : void 0;
|
|
20890
|
-
const latestAttributionOrdinal = latest(survivingOutcomeEvents10(candidate2.bundle.events).filter((event) => ["confirmed", "contradicted", "helpful", "harmful"].includes(event.type)).map((event) => event.buildOrdinal));
|
|
20891
|
-
const latestGate2Ordinal = latest(receipts.filter((row) => row.gate === 2).map((row) => row.producedAtOrdinal));
|
|
20892
|
-
const active = rows.filter((row) => row.active && row.product === candidate2.product && row.bundle.frontmatter.scope.tier === "product" && row.bundle.frontmatter.scope.key === scope.key);
|
|
20893
|
-
return {
|
|
20894
|
-
kind: "found",
|
|
20895
|
-
...pass === void 0 ? {} : { gate1PassOrdinal: pass.producedAtOrdinal, gate1PassDigest: pass.receiptDigest },
|
|
20896
|
-
...lowerTrustActiveGate1Digest === void 0 ? {} : { lowerTrustActiveGate1Digest },
|
|
20897
|
-
...latestAttributionOrdinal === void 0 ? {} : { latestAttributionOrdinal },
|
|
20898
|
-
...latestGate2Ordinal === void 0 ? {} : { latestGate2Ordinal },
|
|
20899
|
-
activeInScope: active.length,
|
|
20900
|
-
lowerTrustActiveInScope: active.filter((row) => strongestPromotionPath4(row.lines) === "gate1-lower-trust").length
|
|
20901
|
-
};
|
|
20902
|
-
}
|
|
20903
|
-
function standingReceiptDigestsFor(input) {
|
|
20904
|
-
return readBundles(input.knowledgeRoot).flatMap((row) => standingReceiptsByGate(
|
|
20905
|
-
row.lines.filter((line) => !isPromotionReceipt5(line))
|
|
20906
|
-
).map((receipt) => ({
|
|
20907
|
-
candidateId: receipt.candidateId,
|
|
20908
|
-
gate: receipt.gate,
|
|
20909
|
-
verdict: receipt.verdict,
|
|
20910
|
-
..."corpusVersion" in receipt ? { corpusDigest: receipt.corpusVersion.corpusDigest } : {},
|
|
20911
|
-
producedAtOrdinal: receipt.producedAtOrdinal
|
|
20912
|
-
})));
|
|
20913
|
-
}
|
|
20914
|
-
function lowerTrustSharesFor(input) {
|
|
20915
|
-
const products = /* @__PURE__ */ new Map();
|
|
20916
|
-
for (const row of readBundles(input.knowledgeRoot, input.resolveTrustPriors)) {
|
|
20917
|
-
const share = products.get(row.product) ?? { product: row.product, active: 0, lowerTrust: 0 };
|
|
20918
|
-
products.set(row.product, share);
|
|
20919
|
-
if (!row.active) continue;
|
|
20920
|
-
share.active += 1;
|
|
20921
|
-
if (strongestPromotionPath4(row.lines) === "gate1-lower-trust") share.lowerTrust += 1;
|
|
20922
|
-
}
|
|
20923
|
-
return [...products.values()];
|
|
20924
|
-
}
|
|
20925
|
-
|
|
20926
20593
|
// src/feedback/apply-feedback.ts
|
|
20927
20594
|
import {
|
|
20928
20595
|
IMPROVEMENT_PLAN_SCHEMA_VERSION,
|
|
@@ -20930,7 +20597,7 @@ import {
|
|
|
20930
20597
|
MARK_QUARANTINE_CLASSES,
|
|
20931
20598
|
actionDidNotFail,
|
|
20932
20599
|
asEvidenceToken as asEvidenceToken6,
|
|
20933
|
-
asRecordId as
|
|
20600
|
+
asRecordId as asRecordId12
|
|
20934
20601
|
} from "@vostride/agent-qa-schema";
|
|
20935
20602
|
|
|
20936
20603
|
// src/feedback/floor-prose.ts
|
|
@@ -21085,11 +20752,11 @@ function applyFeedback(input) {
|
|
|
21085
20752
|
// OriginStage is closed to run-curation; user authorship lives on the delta envelope.
|
|
21086
20753
|
originStage: target.originStage
|
|
21087
20754
|
};
|
|
21088
|
-
const envelope2 = { origin: "user", scope: target.scope, citedIds: [
|
|
20755
|
+
const envelope2 = { origin: "user", scope: target.scope, citedIds: [asRecordId12(target.recordId)] };
|
|
21089
20756
|
const delta = selection.fix === "fact" ? {
|
|
21090
20757
|
...envelope2,
|
|
21091
20758
|
kind: "Supersede",
|
|
21092
|
-
victimId:
|
|
20759
|
+
victimId: asRecordId12(target.recordId),
|
|
21093
20760
|
newBundle: bundle,
|
|
21094
20761
|
evidenceToken: asEvidenceToken6(`mark:${mark.markId}`)
|
|
21095
20762
|
} : { ...envelope2, kind: "Add", bundle };
|
|
@@ -21104,17 +20771,16 @@ function applyFeedback(input) {
|
|
|
21104
20771
|
}
|
|
21105
20772
|
|
|
21106
20773
|
// src/feedback/mark-evidence.ts
|
|
21107
|
-
import { asRecordId as
|
|
20774
|
+
import { asRecordId as asRecordId14 } from "@vostride/agent-qa-schema";
|
|
21108
20775
|
|
|
21109
20776
|
// src/feedback/mark-evidence-plan.ts
|
|
21110
|
-
import { basename as
|
|
20777
|
+
import { basename as basename12 } from "node:path";
|
|
21111
20778
|
import {
|
|
21112
20779
|
asEvidenceToken as asEvidenceToken7,
|
|
21113
|
-
asRecordId as
|
|
20780
|
+
asRecordId as asRecordId13,
|
|
21114
20781
|
deriveEvidenceToken as deriveEvidenceToken3,
|
|
21115
20782
|
eventDedupKey as eventDedupKey4,
|
|
21116
|
-
exercisedAnchors as exercisedAnchors2
|
|
21117
|
-
isPromotionReceipt as isPromotionReceipt6
|
|
20783
|
+
exercisedAnchors as exercisedAnchors2
|
|
21118
20784
|
} from "@vostride/agent-qa-schema";
|
|
21119
20785
|
var MARK_EVIDENCE_TOKEN_PREFIX = "mark:";
|
|
21120
20786
|
function markEvidenceEvent(effect, markId, buildOrdinal) {
|
|
@@ -21143,7 +20809,7 @@ function planMarkEvidence(input) {
|
|
|
21143
20809
|
...input.mark.kind === "false-pass" && input.handoff === void 0 ? { correlationIncomplete: true } : {}
|
|
21144
20810
|
};
|
|
21145
20811
|
const served = new Set(input.servedRecordIds);
|
|
21146
|
-
const targets = /* @__PURE__ */ new Set([...served, ...input.mark.kind === "false-pass" ? enumerateBundleDirs(input.knowledgeRoot).map((entry) =>
|
|
20812
|
+
const targets = /* @__PURE__ */ new Set([...served, ...input.mark.kind === "false-pass" ? enumerateBundleDirs(input.knowledgeRoot).map((entry) => basename12(entry.dir)) : []]);
|
|
21147
20813
|
for (const recordId of targets) {
|
|
21148
20814
|
let entry;
|
|
21149
20815
|
try {
|
|
@@ -21165,7 +20831,7 @@ function planMarkEvidence(input) {
|
|
|
21165
20831
|
for (const member of input.handoff?.tests ?? []) {
|
|
21166
20832
|
for (const step of member.steps) {
|
|
21167
20833
|
const canaryId = canaryOutcomeObservationId({
|
|
21168
|
-
candidateId:
|
|
20834
|
+
candidateId: asRecordId13(recordId),
|
|
21169
20835
|
runId: input.mark.runId,
|
|
21170
20836
|
testId: member.testId,
|
|
21171
20837
|
testIndex: member.testIndex,
|
|
@@ -21182,18 +20848,6 @@ function planMarkEvidence(input) {
|
|
|
21182
20848
|
}
|
|
21183
20849
|
}
|
|
21184
20850
|
}
|
|
21185
|
-
for (const receipt of readGateReceipts(entry.dir, asRecordId14(recordId)) ?? []) {
|
|
21186
|
-
if (!isPromotionReceipt6(receipt) && receipt.gate === 2 && receipt.runId === input.mark.runId) {
|
|
21187
|
-
observations.add(receipt.attributedObservationId);
|
|
21188
|
-
for (const anchor of bundleAnchors) {
|
|
21189
|
-
evidenceTokens.add(deriveEvidenceToken3({
|
|
21190
|
-
attributingObservationId: receipt.attributedObservationId,
|
|
21191
|
-
anchor,
|
|
21192
|
-
buildOrdinal: receipt.producedAtOrdinal
|
|
21193
|
-
}));
|
|
21194
|
-
}
|
|
21195
|
-
}
|
|
21196
|
-
}
|
|
21197
20851
|
const jobs = new Set(input.curationJobIds ?? []);
|
|
21198
20852
|
const provenance = bundle.provenance;
|
|
21199
20853
|
if (provenance.mode === "run-linked" && provenance.runId === input.mark.runId && provenance.curationJobId !== void 0) jobs.add(provenance.curationJobId);
|
|
@@ -21283,7 +20937,6 @@ async function appendMarkEvidence(input) {
|
|
|
21283
20937
|
const config = {
|
|
21284
20938
|
knowledgeRoot: input.knowledgeRoot,
|
|
21285
20939
|
productKey: target.productKey,
|
|
21286
|
-
commitArtifacts: "none",
|
|
21287
20940
|
writerLeaseId: input.lease.leaseId,
|
|
21288
20941
|
writerEpoch: input.lease.epoch
|
|
21289
20942
|
};
|
|
@@ -21291,7 +20944,7 @@ async function appendMarkEvidence(input) {
|
|
|
21291
20944
|
for (const effect of target.effects) {
|
|
21292
20945
|
const outcome = appendOutcomeEvent(
|
|
21293
20946
|
config,
|
|
21294
|
-
|
|
20947
|
+
asRecordId14(target.recordId),
|
|
21295
20948
|
markEvidenceEvent(effect, input.mark.markId, target.buildOrdinal)
|
|
21296
20949
|
);
|
|
21297
20950
|
if (outcome.kind !== "appended" && outcome.kind !== "duplicate") {
|
|
@@ -21380,7 +21033,6 @@ export {
|
|
|
21380
21033
|
NativeEmbeddingDimensionError,
|
|
21381
21034
|
NativeEmbeddingModuleLoadError,
|
|
21382
21035
|
PAYLOAD_BENEFITS,
|
|
21383
|
-
PAYLOAD_STATE_VALIDITIES,
|
|
21384
21036
|
PURGE_RECEIPT_SCHEMA_VERSION,
|
|
21385
21037
|
PolicyTextRefusedError,
|
|
21386
21038
|
PurgeChronologyRequiredError,
|
|
@@ -21442,7 +21094,6 @@ export {
|
|
|
21442
21094
|
authoredCheckpointSchema,
|
|
21443
21095
|
buildCurationCandidateAddressFields,
|
|
21444
21096
|
buildRetrievalQuery,
|
|
21445
|
-
canaryPostureFactsFor,
|
|
21446
21097
|
candidateContentAddress,
|
|
21447
21098
|
claimNextJob,
|
|
21448
21099
|
claimedCandidateDir,
|
|
@@ -21511,7 +21162,6 @@ export {
|
|
|
21511
21162
|
listTestsInFile,
|
|
21512
21163
|
loadBundle,
|
|
21513
21164
|
loadFloorAssets,
|
|
21514
|
-
lowerTrustSharesFor,
|
|
21515
21165
|
markEvidenceEvent,
|
|
21516
21166
|
materializePolicy,
|
|
21517
21167
|
openAddressingLedger,
|
|
@@ -21542,7 +21192,6 @@ export {
|
|
|
21542
21192
|
queuedCandidateDir,
|
|
21543
21193
|
queuedRoot,
|
|
21544
21194
|
readCanonicalBundleAnchors,
|
|
21545
|
-
readCanonicalBundleStateDigests,
|
|
21546
21195
|
readCurationCandidatePayload,
|
|
21547
21196
|
readCurationEffects,
|
|
21548
21197
|
readEmbedderWorkerRegistration,
|
|
@@ -21593,7 +21242,6 @@ export {
|
|
|
21593
21242
|
showRecord,
|
|
21594
21243
|
sightEntity,
|
|
21595
21244
|
sliceAuthoredCheckpoint,
|
|
21596
|
-
standingReceiptDigestsFor,
|
|
21597
21245
|
suiteFingerprintDeltas,
|
|
21598
21246
|
sweepEntityIndex,
|
|
21599
21247
|
testFingerprintElements,
|