niceeval 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/bootstrap.cjs +7 -1
- package/dist/cli/bootstrap.cjs.map +1 -1
- package/dist/cli/project-configuration.cjs +8 -11
- package/dist/cli/project-configuration.cjs.map +1 -1
- package/dist/expect/index.cjs.map +1 -1
- package/dist/expect/index.d.cts +1 -0
- package/dist/expect/index.d.mts +1 -0
- package/dist/expect/index.d.ts +1 -0
- package/dist/experiment/host/cli/contribution.cjs +6 -11
- package/dist/experiment/host/cli/contribution.cjs.map +1 -1
- package/dist/experiment/host/cli/contribution.d.cts +0 -16
- package/dist/experiment/host/cli/contribution.d.mts +0 -16
- package/dist/experiment/host/cli/contribution.d.ts +0 -16
- package/dist/experiment/host/operations.cjs +3 -3
- package/dist/experiment/host/operations.cjs.map +1 -1
- package/dist/experiment/host/types.cjs.map +1 -1
- package/dist/experiment/host/types.d.cts +0 -4
- package/dist/experiment/host/types.d.mts +0 -4
- package/dist/experiment/host/types.d.ts +0 -4
- package/dist/fresh-import.cjs +2 -2
- package/dist/fresh-import.cjs.map +1 -1
- package/dist/fresh-import.d.cts +3 -3
- package/dist/fresh-import.d.mts +3 -3
- package/dist/fresh-import.d.ts +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/inspection/codec.cjs.map +1 -1
- package/dist/inspection/codec.d.cts +1 -1
- package/dist/inspection/codec.d.mts +1 -1
- package/dist/inspection/codec.d.ts +1 -1
- package/dist/inspection/facts.cjs +66 -9
- package/dist/inspection/facts.cjs.map +1 -1
- package/dist/inspection/facts.d.cts +4 -0
- package/dist/inspection/facts.d.mts +4 -0
- package/dist/inspection/facts.d.ts +4 -0
- package/dist/inspection/facts.js +4 -2
- package/dist/inspection/index.cjs +1 -3
- package/dist/inspection/index.cjs.map +1 -1
- package/dist/inspection/index.d.cts +1 -1
- package/dist/inspection/index.d.mts +1 -1
- package/dist/inspection/index.d.ts +1 -1
- package/dist/inspection/index.js +44 -48
- package/dist/inspection/limits.cjs +3 -1
- package/dist/inspection/limits.cjs.map +1 -1
- package/dist/inspection/limits.d.cts +2 -0
- package/dist/inspection/limits.d.mts +2 -0
- package/dist/inspection/limits.d.ts +2 -0
- package/dist/inspection/limits.js +6 -4
- package/dist/inspection/project-source.cjs +4 -1
- package/dist/inspection/project-source.cjs.map +1 -1
- package/dist/inspection/protocol.cjs +10 -18
- package/dist/inspection/protocol.cjs.map +1 -1
- package/dist/inspection/protocol.d.cts +111 -173
- package/dist/inspection/protocol.d.mts +111 -173
- package/dist/inspection/protocol.d.ts +111 -173
- package/dist/inspection/public.mjs +73 -109
- package/dist/inspection/results.cjs +12 -48
- package/dist/inspection/results.cjs.map +1 -1
- package/dist/inspection/results.d.cts +124 -122
- package/dist/inspection/results.d.mts +124 -122
- package/dist/inspection/results.d.ts +124 -122
- package/dist/inspection/results.js +16 -20
- package/dist/inspection/select.cjs +80 -117
- package/dist/inspection/select.cjs.map +1 -1
- package/dist/inspection/source.cjs +14 -15
- package/dist/inspection/source.cjs.map +1 -1
- package/dist/inspection/source.d.cts +6 -3
- package/dist/inspection/source.d.mts +6 -3
- package/dist/inspection/source.d.ts +6 -3
- package/dist/inspection/trace.cjs +1 -1
- package/dist/inspection/trace.cjs.map +1 -1
- package/dist/load-config.cjs +17 -11
- package/dist/load-config.cjs.map +1 -1
- package/dist/load-config.d.cts +3 -2
- package/dist/load-config.d.mts +3 -2
- package/dist/load-config.d.ts +3 -2
- package/dist/o11y/adapter-usage-projection.cjs +5 -1
- package/dist/o11y/adapter-usage-projection.cjs.map +1 -1
- package/dist/o11y/adapter-usage-projection.d.cts +109 -1
- package/dist/o11y/adapter-usage-projection.d.mts +109 -1
- package/dist/o11y/adapter-usage-projection.d.ts +109 -1
- package/dist/o11y/cache-read.cjs +113 -0
- package/dist/o11y/cache-read.cjs.map +1 -0
- package/dist/o11y/cache-read.d.cts +80 -0
- package/dist/o11y/cache-read.d.mts +80 -0
- package/dist/o11y/cache-read.d.ts +80 -0
- package/dist/o11y/cache-read.js +8 -0
- package/dist/o11y/cache-read.js.map +1 -0
- package/dist/o11y/eval-usage.cjs +4 -1
- package/dist/o11y/eval-usage.cjs.map +1 -1
- package/dist/o11y/eval-usage.d.cts +4 -1
- package/dist/o11y/eval-usage.d.mts +4 -1
- package/dist/o11y/eval-usage.d.ts +4 -1
- package/dist/record/host/sqlite-host.cjs +188 -53
- package/dist/record/host/sqlite-host.cjs.map +1 -1
- package/dist/record/host/sqlite-host.d.cts +37 -1
- package/dist/record/host/sqlite-host.d.mts +37 -1
- package/dist/record/host/sqlite-host.d.ts +37 -1
- package/dist/record/host/sqlite-host.js +16 -8
- package/dist/record/maintenance/runtime.cjs +3 -3
- package/dist/record/maintenance/runtime.cjs.map +1 -1
- package/dist/record/sqlite/admission-repository.cjs +18 -18
- package/dist/record/sqlite/admission-repository.cjs.map +1 -1
- package/dist/record/sqlite/case-repository.cjs +6 -6
- package/dist/record/sqlite/case-repository.cjs.map +1 -1
- package/dist/record/sqlite/coordination-repository.cjs +25 -25
- package/dist/record/sqlite/coordination-repository.cjs.map +1 -1
- package/dist/record/sqlite/current-schema.cjs +115 -111
- package/dist/record/sqlite/current-schema.cjs.map +1 -1
- package/dist/record/sqlite/current-schema.d.cts +3 -3
- package/dist/record/sqlite/current-schema.d.mts +3 -3
- package/dist/record/sqlite/current-schema.d.ts +3 -3
- package/dist/record/sqlite/database.cjs +56 -53
- package/dist/record/sqlite/database.cjs.map +1 -1
- package/dist/record/sqlite/index.cjs +3 -1
- package/dist/record/sqlite/index.cjs.map +1 -1
- package/dist/record/sqlite/index.d.cts +5 -2
- package/dist/record/sqlite/index.d.mts +5 -2
- package/dist/record/sqlite/index.d.ts +5 -2
- package/dist/record/sqlite/legacy-schema-018.cjs +443 -0
- package/dist/record/sqlite/legacy-schema-018.cjs.map +1 -0
- package/dist/record/sqlite/legacy-schema-018.d.cts +6 -0
- package/dist/record/sqlite/legacy-schema-018.d.mts +6 -0
- package/dist/record/sqlite/legacy-schema-018.d.ts +6 -0
- package/dist/record/sqlite/legacy-schema-018.js +6 -0
- package/dist/record/sqlite/legacy-schema-018.js.map +1 -0
- package/dist/record/sqlite/migration.cjs +105 -46
- package/dist/record/sqlite/migration.cjs.map +1 -1
- package/dist/record/sqlite/migration.d.cts +2 -1
- package/dist/record/sqlite/migration.d.mts +2 -1
- package/dist/record/sqlite/migration.d.ts +2 -1
- package/dist/record/sqlite/portable-capture.cjs +13 -13
- package/dist/record/sqlite/portable-capture.cjs.map +1 -1
- package/dist/record/sqlite/registry-repository.cjs +22 -22
- package/dist/record/sqlite/registry-repository.cjs.map +1 -1
- package/dist/record/sqlite/schema.cjs +10 -2
- package/dist/record/sqlite/schema.cjs.map +1 -1
- package/dist/record/sqlite/schema.d.cts +4 -1
- package/dist/record/sqlite/schema.d.mts +4 -1
- package/dist/record/sqlite/schema.d.ts +4 -1
- package/dist/record/sqlite/schema.js +20 -14
- package/dist/record/sqlite/storage-worker.cjs +1 -1
- package/dist/record/sqlite/storage-worker.cjs.map +1 -1
- package/dist/record/sqlite/storage.cjs +316 -232
- package/dist/record/sqlite/storage.cjs.map +1 -1
- package/dist/record/sqlite/storage.d.cts +10 -2
- package/dist/record/sqlite/storage.d.mts +10 -2
- package/dist/record/sqlite/storage.d.ts +10 -2
- package/dist/record/sqlite/storage.js +54 -50
- package/dist/record/sqlite/types.cjs +1 -1
- package/dist/record/sqlite/types.cjs.map +1 -1
- package/dist/record/sqlite/types.d.cts +13 -1
- package/dist/record/sqlite/types.d.mts +13 -1
- package/dist/record/sqlite/types.d.ts +13 -1
- package/dist/run/cli/contribution.cjs +17 -12
- package/dist/run/cli/contribution.cjs.map +1 -1
- package/dist/run/host/lifecycle-adapter.cjs +1 -1
- package/dist/run/host/lifecycle-adapter.cjs.map +1 -1
- package/dist/run/storage/owner-identity.cjs +78 -16
- package/dist/run/storage/owner-identity.cjs.map +1 -1
- package/dist/run/storage/owner-identity.d.cts +2 -1
- package/dist/run/storage/owner-identity.d.mts +2 -1
- package/dist/run/storage/owner-identity.d.ts +2 -1
- package/dist/run/storage/sqlite.cjs +55 -55
- package/dist/run/storage/sqlite.cjs.map +1 -1
- package/dist/runner/accept.cjs +12 -42
- package/dist/runner/accept.cjs.map +1 -1
- package/dist/runner/accept.d.cts +2 -3
- package/dist/runner/accept.d.mts +2 -3
- package/dist/runner/accept.d.ts +2 -3
- package/dist/runner/adapter-usage.cjs +2 -2
- package/dist/runner/adapter-usage.cjs.map +1 -1
- package/dist/runner/adoption.cjs +14 -26
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/adoption.d.cts +5 -13
- package/dist/runner/adoption.d.mts +5 -13
- package/dist/runner/adoption.d.ts +5 -13
- package/dist/runner/adoption.js +2 -4
- package/dist/runner/record.cjs +24 -18
- package/dist/runner/record.cjs.map +1 -1
- package/dist/runner/rename-experiment.cjs +5 -7
- package/dist/runner/rename-experiment.cjs.map +1 -1
- package/dist/runner/reuse-plan.cjs +37 -18
- package/dist/runner/reuse-plan.cjs.map +1 -1
- package/dist/runner/reuse-plan.d.cts +4 -1
- package/dist/runner/reuse-plan.d.mts +4 -1
- package/dist/runner/reuse-plan.d.ts +4 -1
- package/dist/runner/setup-prefix-plan.cjs +17 -12
- package/dist/runner/setup-prefix-plan.cjs.map +1 -1
- package/dist/runner/setup-prefix-plan.d.cts +0 -2
- package/dist/runner/setup-prefix-plan.d.mts +0 -2
- package/dist/runner/setup-prefix-plan.d.ts +0 -2
- package/dist/runner/setup-prefix-plan.js +8 -12
- package/dist/sandbox/backend.cjs +10 -1
- package/dist/sandbox/backend.cjs.map +1 -1
- package/dist/sandbox/backend.d.cts +16 -8
- package/dist/sandbox/backend.d.mts +16 -8
- package/dist/sandbox/backend.d.ts +16 -8
- package/dist/sandbox/backend.js +28 -26
- package/dist/sandbox/docker.cjs +7 -1
- package/dist/sandbox/docker.cjs.map +1 -1
- package/dist/sandbox/e2b-cache-repository.cjs +13 -3
- package/dist/sandbox/e2b-cache-repository.cjs.map +1 -1
- package/dist/sandbox/e2b-cache-repository.d.cts +3 -0
- package/dist/sandbox/e2b-cache-repository.d.mts +3 -0
- package/dist/sandbox/e2b-cache-repository.d.ts +3 -0
- package/dist/sandbox/e2b-cache-repository.js +16 -12
- package/dist/sandbox/e2b.cjs +2 -2
- package/dist/sandbox/e2b.cjs.map +1 -1
- package/dist/sandbox/incus/materialize.cjs +1 -1
- package/dist/sandbox/incus/materialize.cjs.map +1 -1
- package/dist/show/contribution.cjs +3 -3
- package/dist/show/contribution.cjs.map +1 -1
- package/dist/show/model.cjs +14 -13
- package/dist/show/model.cjs.map +1 -1
- package/dist/show/model.d.cts +7 -7
- package/dist/show/model.d.mts +7 -7
- package/dist/show/model.d.ts +7 -7
- package/dist/show/render.cjs +14 -0
- package/dist/show/render.cjs.map +1 -1
- package/dist/user-database/storage-worker.cjs +13 -3
- package/dist/user-database/storage-worker.cjs.map +1 -1
- package/dist/view/app-dist/.vite/manifest.json +2 -2
- package/dist/view/app-dist/assets/{index-CmVoXbwG.js → index-B3ijZRph.js} +17 -17
- package/dist/view/app-dist/assets/{quality-cost-scatter-BuLISaH4.js → quality-cost-scatter-B--DfJ9s.js} +1 -1
- package/dist/view/app-dist/index.html +1 -1
- package/dist/view/application-runtime.cjs +8 -0
- package/dist/view/application-runtime.cjs.map +1 -0
- package/dist/view/application-runtime.d.cts +9 -0
- package/dist/view/application-runtime.d.mts +9 -0
- package/dist/view/application-runtime.d.ts +9 -0
- package/dist/view/application-runtime.js +6 -0
- package/dist/view/application-runtime.js.map +1 -0
- package/dist/view/cli/contribution.cjs +5 -2
- package/dist/view/cli/contribution.cjs.map +1 -1
- package/dist/view/cli/contribution.d.cts +2 -1
- package/dist/view/cli/contribution.d.mts +2 -1
- package/dist/view/cli/contribution.d.ts +2 -1
- package/dist/view/function-runtime.mjs +1019 -456
- package/dist/view/http-protocol.d.cts +1 -9
- package/dist/view/http-protocol.d.mts +1 -9
- package/dist/view/http-protocol.d.ts +1 -9
- package/dist/view/inspection-host.cjs +39 -30
- package/dist/view/inspection-host.cjs.map +1 -1
- package/dist/view/inspection-host.d.cts +7545 -2
- package/dist/view/inspection-host.d.mts +7545 -2
- package/dist/view/inspection-host.d.ts +7545 -2
- package/dist/view/server.cjs +8 -5
- package/dist/view/server.cjs.map +1 -1
- package/dist/view/server.d.cts +4 -2
- package/dist/view/server.d.mts +4 -2
- package/dist/view/server.d.ts +4 -2
- package/docs-site/zh/reference/cli.mdx +1 -2
- package/docs-site/zh/tutorials/control-run-cost.mdx +22 -0
- package/docs-site/zh/tutorials/niceeval-taste-application.mdx +21 -0
- package/package.json +1 -1
|
@@ -4504,6 +4504,141 @@ var AssertionDetailResultSchema = Schema.toType(Schema.Union([Schema.Struct({
|
|
|
4504
4504
|
check: DiagnosticNodeSchema,
|
|
4505
4505
|
matcher: MatcherProjectionSchema
|
|
4506
4506
|
})]));
|
|
4507
|
+
//#endregion
|
|
4508
|
+
//#region src/o11y/cache-read.ts
|
|
4509
|
+
var Reason = Schema.Literals([
|
|
4510
|
+
"usage-not-recorded",
|
|
4511
|
+
"source-invalid",
|
|
4512
|
+
"adapter-usage-required",
|
|
4513
|
+
"collection-incomplete",
|
|
4514
|
+
"call-status-unknown",
|
|
4515
|
+
"no-calls",
|
|
4516
|
+
"cache-read-missing",
|
|
4517
|
+
"input-total-missing",
|
|
4518
|
+
"zero-input-total",
|
|
4519
|
+
"unsafe-token-total"
|
|
4520
|
+
]);
|
|
4521
|
+
var fields = {
|
|
4522
|
+
rate: Schema.Union([Schema.Struct({
|
|
4523
|
+
state: Schema.Literal("exact"),
|
|
4524
|
+
value: Schema.Number.check(Schema.makeFilter((value) => Number.isFinite(value) && value >= 0 && value <= 1))
|
|
4525
|
+
}), Schema.Struct({
|
|
4526
|
+
state: Schema.Literal("unavailable"),
|
|
4527
|
+
reason: Reason
|
|
4528
|
+
})]),
|
|
4529
|
+
recordedCalls: NonNegativeSafeIntegerSchema$2,
|
|
4530
|
+
coveredCalls: NonNegativeSafeIntegerSchema$2,
|
|
4531
|
+
missingCacheReadCalls: NonNegativeSafeIntegerSchema$2,
|
|
4532
|
+
missingInputTotalCalls: NonNegativeSafeIntegerSchema$2,
|
|
4533
|
+
unknownStatusCalls: NonNegativeSafeIntegerSchema$2,
|
|
4534
|
+
collectionComplete: Schema.Boolean,
|
|
4535
|
+
reasons: Schema.Array(Reason)
|
|
4536
|
+
};
|
|
4537
|
+
var consistent = (value) => {
|
|
4538
|
+
const count = value.recordedCalls;
|
|
4539
|
+
return count <= 4e3 && value.coveredCalls <= count && value.unknownStatusCalls <= count && value.missingCacheReadCalls <= count && value.missingInputTotalCalls <= count && value.coveredCalls <= count - Math.max(value.missingCacheReadCalls, value.missingInputTotalCalls) && value.coveredCalls >= count - value.missingCacheReadCalls - value.missingInputTotalCalls && new Set(value.reasons).size === value.reasons.length && (value.rate.state === "exact" ? value.reasons.length === 0 && value.collectionComplete && count > 0 && value.coveredCalls === count && value.unknownStatusCalls === 0 : value.rate.reason === value.reasons[0]);
|
|
4540
|
+
};
|
|
4541
|
+
var Summary = Schema.Struct(fields).check(Schema.makeFilter(consistent));
|
|
4542
|
+
var CacheReadReportSchema = Schema.Struct({
|
|
4543
|
+
total: Summary,
|
|
4544
|
+
modelSlots: Schema.Array(Schema.Struct({
|
|
4545
|
+
modelSlot: Schema.NullOr(Schema.String),
|
|
4546
|
+
...fields
|
|
4547
|
+
}).check(Schema.makeFilter(consistent))),
|
|
4548
|
+
models: Schema.Array(Schema.Struct({
|
|
4549
|
+
modelSlot: Schema.NullOr(Schema.String),
|
|
4550
|
+
provider: Schema.NullOr(Schema.String),
|
|
4551
|
+
model: Schema.NullOr(Schema.String),
|
|
4552
|
+
...fields
|
|
4553
|
+
}).check(Schema.makeFilter(consistent)))
|
|
4554
|
+
}).check(Schema.makeFilter((value) => value.modelSlots.length <= 65 && value.models.length <= 4e3));
|
|
4555
|
+
function summary(calls, collectionComplete, absent) {
|
|
4556
|
+
let numerator = 0;
|
|
4557
|
+
let denominator = 0;
|
|
4558
|
+
let coveredCalls = 0;
|
|
4559
|
+
let missingCacheReadCalls = 0;
|
|
4560
|
+
let missingInputTotalCalls = 0;
|
|
4561
|
+
let unknownStatusCalls = 0;
|
|
4562
|
+
let unsafe = false;
|
|
4563
|
+
for (const call of calls) {
|
|
4564
|
+
const total = call.inputTotalTokens ?? (call.inputTokens !== null && call.cacheReadTokens !== null && call.cacheWriteTokens !== null ? call.inputTokens + call.cacheReadTokens + call.cacheWriteTokens : null);
|
|
4565
|
+
if (call.status === "unknown") unknownStatusCalls++;
|
|
4566
|
+
if (call.cacheReadTokens === null) missingCacheReadCalls++;
|
|
4567
|
+
else numerator += call.cacheReadTokens;
|
|
4568
|
+
if (total === null) missingInputTotalCalls++;
|
|
4569
|
+
else denominator += total;
|
|
4570
|
+
if (total !== null && call.cacheReadTokens !== null) coveredCalls++;
|
|
4571
|
+
if (total !== null && !Number.isSafeInteger(total) || !Number.isSafeInteger(numerator) || !Number.isSafeInteger(denominator)) unsafe = true;
|
|
4572
|
+
}
|
|
4573
|
+
const reasons = absent === void 0 ? [
|
|
4574
|
+
...!collectionComplete ? ["collection-incomplete"] : [],
|
|
4575
|
+
...unknownStatusCalls > 0 ? ["call-status-unknown"] : [],
|
|
4576
|
+
...calls.length === 0 ? ["no-calls"] : [],
|
|
4577
|
+
...missingCacheReadCalls > 0 ? ["cache-read-missing"] : [],
|
|
4578
|
+
...missingInputTotalCalls > 0 ? ["input-total-missing"] : [],
|
|
4579
|
+
...calls.length > 0 && missingInputTotalCalls === 0 && denominator === 0 ? ["zero-input-total"] : [],
|
|
4580
|
+
...unsafe ? ["unsafe-token-total"] : []
|
|
4581
|
+
] : [absent];
|
|
4582
|
+
const rate = reasons.length === 0 ? Object.freeze({
|
|
4583
|
+
state: "exact",
|
|
4584
|
+
value: numerator / denominator
|
|
4585
|
+
}) : Object.freeze({
|
|
4586
|
+
state: "unavailable",
|
|
4587
|
+
reason: reasons[0]
|
|
4588
|
+
});
|
|
4589
|
+
return Object.freeze({
|
|
4590
|
+
rate,
|
|
4591
|
+
recordedCalls: calls.length,
|
|
4592
|
+
coveredCalls,
|
|
4593
|
+
missingCacheReadCalls,
|
|
4594
|
+
missingInputTotalCalls,
|
|
4595
|
+
unknownStatusCalls,
|
|
4596
|
+
collectionComplete,
|
|
4597
|
+
reasons: Object.freeze(reasons)
|
|
4598
|
+
});
|
|
4599
|
+
}
|
|
4600
|
+
var compare$1 = (a, b) => a === b ? 0 : a === null ? -1 : b === null ? 1 : a < b ? -1 : 1;
|
|
4601
|
+
/** A historical collection marked complete is not proof of an explicit producer seal. */
|
|
4602
|
+
function projectCacheRead(usage, slots, producerCompletenessKnown, absent = "usage-not-recorded") {
|
|
4603
|
+
if (usage === null) return Object.freeze({
|
|
4604
|
+
total: summary([], false, absent),
|
|
4605
|
+
modelSlots: Object.freeze([]),
|
|
4606
|
+
models: Object.freeze([])
|
|
4607
|
+
});
|
|
4608
|
+
const complete = producerCompletenessKnown && usage.collection.state === "complete";
|
|
4609
|
+
const bySlot = new Map(Object.keys(slots ?? {}).map((slot) => [slot, []]));
|
|
4610
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
4611
|
+
for (const call of usage.calls) {
|
|
4612
|
+
const slot = bySlot.get(call.modelSlot);
|
|
4613
|
+
if (slot === void 0) bySlot.set(call.modelSlot, [call]);
|
|
4614
|
+
else slot.push(call);
|
|
4615
|
+
const key = JSON.stringify([
|
|
4616
|
+
call.modelSlot,
|
|
4617
|
+
call.provider,
|
|
4618
|
+
call.model
|
|
4619
|
+
]);
|
|
4620
|
+
const model = byModel.get(key);
|
|
4621
|
+
if (model === void 0) byModel.set(key, [call]);
|
|
4622
|
+
else model.push(call);
|
|
4623
|
+
}
|
|
4624
|
+
const models = [...byModel.values()].map((calls) => {
|
|
4625
|
+
const { modelSlot, provider, model } = calls[0];
|
|
4626
|
+
return Object.freeze({
|
|
4627
|
+
modelSlot,
|
|
4628
|
+
provider,
|
|
4629
|
+
model,
|
|
4630
|
+
...summary(calls, complete)
|
|
4631
|
+
});
|
|
4632
|
+
}).sort((a, b) => compare$1(a.modelSlot, b.modelSlot) || compare$1(a.provider, b.provider) || compare$1(a.model, b.model));
|
|
4633
|
+
return Object.freeze({
|
|
4634
|
+
total: summary(usage.calls, complete),
|
|
4635
|
+
modelSlots: Object.freeze([...bySlot].sort(([a], [b]) => compare$1(a, b)).map(([modelSlot, calls]) => Object.freeze({
|
|
4636
|
+
modelSlot,
|
|
4637
|
+
...summary(calls, complete)
|
|
4638
|
+
}))),
|
|
4639
|
+
models: Object.freeze(models)
|
|
4640
|
+
});
|
|
4641
|
+
}
|
|
4507
4642
|
Object.freeze({
|
|
4508
4643
|
errors: "all",
|
|
4509
4644
|
onExcessProperty: "error"
|
|
@@ -5459,7 +5594,8 @@ function compareAdapterModelGroups(left, right) {
|
|
|
5459
5594
|
function projectAdapterModelUsage(usage, models, unavailable = {
|
|
5460
5595
|
basis: "unavailable",
|
|
5461
5596
|
reason: "usage-not-recorded"
|
|
5462
|
-
}) {
|
|
5597
|
+
}, producerCompletenessKnown = true) {
|
|
5598
|
+
const cacheRead = projectCacheRead(usage, models, producerCompletenessKnown, unavailable.reason === "physical-call-identity-not-recorded" ? "adapter-usage-required" : unavailable.reason);
|
|
5463
5599
|
const counts = /* @__PURE__ */ new Map();
|
|
5464
5600
|
for (const call of usage?.calls ?? []) if (call.modelSlot !== null) counts.set(call.modelSlot, (counts.get(call.modelSlot) ?? 0) + 1);
|
|
5465
5601
|
const configuredModels = models === void 0 ? Object.freeze({ state: "not-recorded" }) : Object.freeze({
|
|
@@ -5471,6 +5607,7 @@ function projectAdapterModelUsage(usage, models, unavailable = {
|
|
|
5471
5607
|
})))
|
|
5472
5608
|
});
|
|
5473
5609
|
if (usage === null) return Object.freeze({
|
|
5610
|
+
cacheRead,
|
|
5474
5611
|
configuredModels,
|
|
5475
5612
|
modelGroups: Object.freeze({
|
|
5476
5613
|
state: "unavailable",
|
|
@@ -5513,6 +5650,7 @@ function projectAdapterModelUsage(usage, models, unavailable = {
|
|
|
5513
5650
|
});
|
|
5514
5651
|
});
|
|
5515
5652
|
return Object.freeze({
|
|
5653
|
+
cacheRead,
|
|
5516
5654
|
configuredModels,
|
|
5517
5655
|
modelGroups: Object.freeze({
|
|
5518
5656
|
state: "available",
|
|
@@ -7050,23 +7188,7 @@ var InspectionRunValueSchema = Schema.Struct({
|
|
|
7050
7188
|
completedAt: Schema.optional(UtcMillisSchema),
|
|
7051
7189
|
expectedSlots: Schema.Array(RecordSlotIdentitySchema)
|
|
7052
7190
|
});
|
|
7053
|
-
var
|
|
7054
|
-
value: InspectionRunValueSchema,
|
|
7055
|
-
members: Schema.Array(MemberDocumentSchema),
|
|
7056
|
-
attempts: Schema.Array(AttemptDocumentSchema)
|
|
7057
|
-
});
|
|
7058
|
-
Schema.Array(Schema.Struct({
|
|
7059
|
-
runId: RunIdSchema,
|
|
7060
|
-
state: Schema.Literal("completed"),
|
|
7061
|
-
experimentId: ExperimentIdSchema,
|
|
7062
|
-
invocationId: Schema.Null,
|
|
7063
|
-
startedAt: UtcMillisSchema,
|
|
7064
|
-
completedAt: UtcMillisSchema,
|
|
7065
|
-
coverage: Schema.Struct({
|
|
7066
|
-
published: Schema.Number,
|
|
7067
|
-
expected: Schema.Number
|
|
7068
|
-
})
|
|
7069
|
-
}));
|
|
7191
|
+
var InspectionRunListResultSchema = Schema.Array(RunSummarySchema);
|
|
7070
7192
|
var InspectionScoredValueSchema = Schema.Union([
|
|
7071
7193
|
Schema.Struct({ state: Schema.Literal("not-scored") }),
|
|
7072
7194
|
Schema.Struct({
|
|
@@ -7087,37 +7209,6 @@ var VerdictSchema = Schema.NullOr(Schema.Literals([
|
|
|
7087
7209
|
"errored",
|
|
7088
7210
|
"skipped"
|
|
7089
7211
|
]));
|
|
7090
|
-
var InspectionRunSummaryResultSchema = Schema.Struct({
|
|
7091
|
-
runs: Schema.Array(RunDocumentSchema),
|
|
7092
|
-
denominator: Schema.Struct({
|
|
7093
|
-
expected: Schema.Number,
|
|
7094
|
-
observed: Schema.Number
|
|
7095
|
-
}),
|
|
7096
|
-
members: Schema.Array(Schema.Struct({
|
|
7097
|
-
runId: Schema.String,
|
|
7098
|
-
slotId: Schema.String,
|
|
7099
|
-
evalId: Schema.String,
|
|
7100
|
-
attemptOrdinal: Schema.Number,
|
|
7101
|
-
executionIdentityDigest: Schema.String,
|
|
7102
|
-
state: Schema.Literals([
|
|
7103
|
-
"executed",
|
|
7104
|
-
"carried",
|
|
7105
|
-
"accepted",
|
|
7106
|
-
"not-dispatched",
|
|
7107
|
-
"interrupted",
|
|
7108
|
-
"missing"
|
|
7109
|
-
]),
|
|
7110
|
-
locator: Schema.NullOr(Schema.String),
|
|
7111
|
-
outcome: Schema.NullOr(Schema.Literals([
|
|
7112
|
-
"completed",
|
|
7113
|
-
"errored",
|
|
7114
|
-
"cancelled",
|
|
7115
|
-
"interrupted"
|
|
7116
|
-
])),
|
|
7117
|
-
verdict: VerdictSchema,
|
|
7118
|
-
score: Schema.optional(InspectionScoredValueSchema)
|
|
7119
|
-
}))
|
|
7120
|
-
});
|
|
7121
7212
|
var AttemptCoverageFactSchema = Schema.Struct({
|
|
7122
7213
|
channel: Schema.Literals([
|
|
7123
7214
|
"events",
|
|
@@ -8097,6 +8188,7 @@ var UsageTotalsSchema = Schema.Struct({
|
|
|
8097
8188
|
costs: Schema.optional(EffectiveCostTotalSchema)
|
|
8098
8189
|
});
|
|
8099
8190
|
var InspectionAttemptUsageResultSchema = Schema.Struct({
|
|
8191
|
+
cacheRead: CacheReadReportSchema,
|
|
8100
8192
|
configuredModels: ConfiguredModelsSchema,
|
|
8101
8193
|
modelGroups: ModelGroupsSchema,
|
|
8102
8194
|
judgeUsage: JudgeUsageSchema,
|
|
@@ -8169,7 +8261,8 @@ var RunOverviewMemberLimitationSchema = Schema.Union([
|
|
|
8169
8261
|
})
|
|
8170
8262
|
]);
|
|
8171
8263
|
var RunOverviewMemberSchema = Schema.Struct({
|
|
8172
|
-
|
|
8264
|
+
...RecordSlotIdentitySchema.fields,
|
|
8265
|
+
publication: RunSlotPublicationSchema,
|
|
8173
8266
|
state: Schema.Literals([
|
|
8174
8267
|
"executed",
|
|
8175
8268
|
"carried",
|
|
@@ -8197,20 +8290,16 @@ var RunOverviewLocatedLimitationSchema = Schema.Struct({
|
|
|
8197
8290
|
locator: Schema.NullOr(Schema.String),
|
|
8198
8291
|
limitation: RunOverviewMemberLimitationSchema
|
|
8199
8292
|
});
|
|
8200
|
-
var
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
adapter: Schema.NullOr(AdapterIdentitySchema)
|
|
8205
|
-
}),
|
|
8206
|
-
state: RunStateSchema,
|
|
8207
|
-
startedAt: UtcMillisSchema,
|
|
8208
|
-
completedAt: Schema.optional(UtcMillisSchema),
|
|
8293
|
+
var InspectionRunResultSchema = Schema.Struct({
|
|
8294
|
+
value: InspectionRunValueSchema,
|
|
8295
|
+
members: Schema.Array(MemberDocumentSchema),
|
|
8296
|
+
attempts: Schema.Array(AttemptDocumentSchema),
|
|
8209
8297
|
denominator: Schema.Struct({
|
|
8210
8298
|
expected: Schema.Number,
|
|
8211
|
-
|
|
8299
|
+
published: Schema.Number,
|
|
8300
|
+
missing: Schema.Number
|
|
8212
8301
|
}),
|
|
8213
|
-
|
|
8302
|
+
slots: Schema.Array(RunOverviewMemberSchema),
|
|
8214
8303
|
coverage: Schema.Struct({
|
|
8215
8304
|
state: RunOverviewStateSchema,
|
|
8216
8305
|
expectedMemberCount: Schema.Number,
|
|
@@ -8387,16 +8476,11 @@ var operation = (kind, fields) => Schema.Struct({
|
|
|
8387
8476
|
});
|
|
8388
8477
|
var SourceSchema = Schema.Struct({
|
|
8389
8478
|
kind: Schema.Literals(["project-record", "external-record"]),
|
|
8390
|
-
|
|
8479
|
+
publicationCutoffIdentity: Schema.String
|
|
8391
8480
|
});
|
|
8392
|
-
var
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
runCount: Schema.Number,
|
|
8396
|
-
runs: Schema.Array(Schema.Struct({
|
|
8397
|
-
runId: Schema.String,
|
|
8398
|
-
logicalSealIdentity: Schema.String
|
|
8399
|
-
}))
|
|
8481
|
+
var PublicationCutoffSchema = Schema.Struct({
|
|
8482
|
+
storeGeneration: Schema.String,
|
|
8483
|
+
revision: Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))
|
|
8400
8484
|
});
|
|
8401
8485
|
var SelectionSchema = Schema.Struct({
|
|
8402
8486
|
requestedRunIds: Schema.Array(Schema.String),
|
|
@@ -8408,7 +8492,7 @@ var SuccessMetadataSchema = Schema.Struct({
|
|
|
8408
8492
|
outcome: Schema.Literal("success"),
|
|
8409
8493
|
behaviorVersion: Schema.Literal(INSPECTION_BEHAVIOR_VERSION),
|
|
8410
8494
|
source: SourceSchema,
|
|
8411
|
-
|
|
8495
|
+
publicationCutoff: PublicationCutoffSchema,
|
|
8412
8496
|
selection: SelectionSchema,
|
|
8413
8497
|
issues: Schema.Tuple([]),
|
|
8414
8498
|
evidence: Schema.Struct({ refs: Schema.Array(Schema.String) })
|
|
@@ -8418,17 +8502,12 @@ var RunsListSuccessMetadataSchema = Schema.Struct({
|
|
|
8418
8502
|
outcome: Schema.Literal("success"),
|
|
8419
8503
|
behaviorVersion: Schema.Literal(INSPECTION_BEHAVIOR_VERSION),
|
|
8420
8504
|
source: SourceSchema,
|
|
8421
|
-
|
|
8422
|
-
kind: Schema.Literal("inspection-sealed-cutoff"),
|
|
8423
|
-
identity: Schema.String,
|
|
8424
|
-
runCount: Schema.Number
|
|
8425
|
-
}),
|
|
8505
|
+
publicationCutoff: PublicationCutoffSchema,
|
|
8426
8506
|
selection: Schema.Struct({
|
|
8427
8507
|
requestedRunIds: Schema.Array(Schema.String),
|
|
8428
8508
|
selectedRunIds: Schema.Array(Schema.String),
|
|
8429
8509
|
missingRunIds: Schema.Array(Schema.String),
|
|
8430
8510
|
returnedRunCount: Schema.Number,
|
|
8431
|
-
totalRunCount: Schema.Number,
|
|
8432
8511
|
truncated: Schema.Boolean
|
|
8433
8512
|
}),
|
|
8434
8513
|
issues: Schema.Tuple([]),
|
|
@@ -8457,19 +8536,6 @@ var ArtifactsResultSchema = Schema.Union([Schema.Struct({ state: Schema.Literal(
|
|
|
8457
8536
|
})),
|
|
8458
8537
|
contentsTruncated: Schema.Boolean
|
|
8459
8538
|
})]);
|
|
8460
|
-
var SealedRunSummarySchema = Schema.Struct({
|
|
8461
|
-
runId: Schema.String,
|
|
8462
|
-
writerGeneration: Schema.String,
|
|
8463
|
-
startedAt: Schema.String,
|
|
8464
|
-
logicalSealIdentity: Schema.String,
|
|
8465
|
-
slotCount: Schema.Number,
|
|
8466
|
-
memberCount: Schema.Number,
|
|
8467
|
-
attemptCount: Schema.Number,
|
|
8468
|
-
attachmentCount: Schema.Number,
|
|
8469
|
-
contentCount: Schema.Number,
|
|
8470
|
-
contentByteLength: Schema.Number,
|
|
8471
|
-
sealEntryCount: Schema.Number
|
|
8472
|
-
});
|
|
8473
8539
|
var ComparisonMemberSchema = Schema.Struct({
|
|
8474
8540
|
key: Schema.String,
|
|
8475
8541
|
runId: Schema.String,
|
|
@@ -8533,10 +8599,10 @@ var inspectionProtocolRegistry = Object.freeze({
|
|
|
8533
8599
|
"judge-usage"
|
|
8534
8600
|
]
|
|
8535
8601
|
}),
|
|
8536
|
-
"
|
|
8537
|
-
request: operation("
|
|
8602
|
+
"run.list": spec({
|
|
8603
|
+
request: operation("run.list", { continuation: Schema.optional(Schema.String) }),
|
|
8538
8604
|
result: {
|
|
8539
|
-
runs:
|
|
8605
|
+
runs: InspectionRunListResultSchema,
|
|
8540
8606
|
continuation: Schema.optional(Schema.String)
|
|
8541
8607
|
},
|
|
8542
8608
|
factKinds: ["core"]
|
|
@@ -8544,24 +8610,12 @@ var inspectionProtocolRegistry = Object.freeze({
|
|
|
8544
8610
|
"run.get": spec({
|
|
8545
8611
|
request: operation("run.get", { runId: RunIdSchema }),
|
|
8546
8612
|
result: { run: InspectionRunResultSchema },
|
|
8547
|
-
factKinds: ["core"]
|
|
8548
|
-
}),
|
|
8549
|
-
"run.summary": spec({
|
|
8550
|
-
request: operation("run.summary", { runId: RunIdSchema }),
|
|
8551
|
-
result: { summary: InspectionRunSummaryResultSchema },
|
|
8552
|
-
factKinds: [
|
|
8553
|
-
"core",
|
|
8554
|
-
"assertions",
|
|
8555
|
-
"agent-turns"
|
|
8556
|
-
]
|
|
8557
|
-
}),
|
|
8558
|
-
"run.overview": spec({
|
|
8559
|
-
request: operation("run.overview", { runId: RunIdSchema }),
|
|
8560
|
-
result: { runOverview: InspectionRunOverviewResultSchema },
|
|
8561
8613
|
factKinds: [
|
|
8562
8614
|
"core",
|
|
8563
8615
|
"assertions",
|
|
8564
|
-
"agent-turns"
|
|
8616
|
+
"agent-turns",
|
|
8617
|
+
"adapter-usage",
|
|
8618
|
+
"judge-usage"
|
|
8565
8619
|
]
|
|
8566
8620
|
}),
|
|
8567
8621
|
"attempt.get": spec({
|
|
@@ -8716,7 +8770,7 @@ var successSchema = (id, entry) => {
|
|
|
8716
8770
|
operation: Schema.Literal(id),
|
|
8717
8771
|
...entry.result
|
|
8718
8772
|
});
|
|
8719
|
-
return id === "
|
|
8773
|
+
return id === "run.list" ? RunsListSuccessMetadataSchema.pipe(fields) : id === "runs.compare" ? CompareSuccessMetadataSchema.pipe(fields) : SuccessMetadataSchema.pipe(fields);
|
|
8720
8774
|
};
|
|
8721
8775
|
var InspectionSuccessDocumentSchema = Schema.Union(specs.map(([id, entry]) => successSchema(id, entry)));
|
|
8722
8776
|
var explanationSchema = (id, entry) => {
|
|
@@ -8725,7 +8779,7 @@ var explanationSchema = (id, entry) => {
|
|
|
8725
8779
|
operation: Schema.Literal(id),
|
|
8726
8780
|
factKinds: Schema.Tuple(entry.factKinds.map((value) => Schema.Literal(value)))
|
|
8727
8781
|
});
|
|
8728
|
-
if (id === "
|
|
8782
|
+
if (id === "run.list") return RunsListSuccessMetadataSchema.pipe(fields);
|
|
8729
8783
|
return SuccessMetadataSchema.pipe(fields);
|
|
8730
8784
|
};
|
|
8731
8785
|
var InspectionExplanationDocumentSchema = Schema.Union(specs.map(([id, entry]) => explanationSchema(id, entry)));
|
|
@@ -8958,11 +9012,456 @@ function encodeRecordJsonUtf8(value) {
|
|
|
8958
9012
|
//#endregion
|
|
8959
9013
|
//#region src/record/sqlite/current-schema.ts
|
|
8960
9014
|
/**
|
|
8961
|
-
* Exact current ProjectDatabase 0.
|
|
9015
|
+
* Exact current ProjectDatabase 0.19 schema, independent of frozen historical
|
|
8962
9016
|
* baselines. Keep these bytes stable within this format: they own its fingerprint.
|
|
8963
|
-
* The disjoint namespace fences writers prepared against the 0.
|
|
9017
|
+
* The disjoint namespace fences writers prepared against the 0.18 tables.
|
|
8964
9018
|
*/
|
|
8965
9019
|
var RECORD_SQLITE_BASELINE_SQL = `
|
|
9020
|
+
CREATE TABLE ne19_record_metadata (
|
|
9021
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
9022
|
+
format TEXT NOT NULL,
|
|
9023
|
+
storage_revision INTEGER NOT NULL CHECK (storage_revision > 0),
|
|
9024
|
+
storage_generation TEXT NOT NULL,
|
|
9025
|
+
schema_fingerprint TEXT NOT NULL CHECK (length(schema_fingerprint) = 64),
|
|
9026
|
+
created_at TEXT NOT NULL,
|
|
9027
|
+
barrier_state TEXT NOT NULL CHECK (barrier_state IN ('open','draining','portable')),
|
|
9028
|
+
portable_generation TEXT,
|
|
9029
|
+
portable_revision INTEGER CHECK (portable_revision IS NULL OR portable_revision >= 0),
|
|
9030
|
+
portable_gate_id TEXT,
|
|
9031
|
+
record_payload BLOB,
|
|
9032
|
+
record_digest TEXT,
|
|
9033
|
+
CHECK ((record_payload IS NULL) = (record_digest IS NULL)),
|
|
9034
|
+
CHECK (record_digest IS NULL OR length(record_digest) = 64),
|
|
9035
|
+
CHECK ((barrier_state = 'portable') = (portable_generation IS NOT NULL)),
|
|
9036
|
+
CHECK ((barrier_state = 'portable') = (portable_revision IS NOT NULL)),
|
|
9037
|
+
CHECK ((barrier_state = 'open') = (portable_gate_id IS NULL))
|
|
9038
|
+
) STRICT;
|
|
9039
|
+
CREATE TABLE ne19_coordination_state (
|
|
9040
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
9041
|
+
revision INTEGER NOT NULL CHECK (revision >= 0),
|
|
9042
|
+
operational_generation TEXT NOT NULL,
|
|
9043
|
+
next_writer_sequence INTEGER NOT NULL CHECK (next_writer_sequence > 0),
|
|
9044
|
+
writer_ticket_id TEXT,
|
|
9045
|
+
writer_sequence INTEGER CHECK (writer_sequence IS NULL OR writer_sequence > 0),
|
|
9046
|
+
writer_host TEXT,
|
|
9047
|
+
writer_pid INTEGER CHECK (writer_pid IS NULL OR writer_pid > 0),
|
|
9048
|
+
writer_boot_id TEXT,
|
|
9049
|
+
writer_process_start TEXT,
|
|
9050
|
+
writer_deadline INTEGER CHECK (writer_deadline IS NULL OR writer_deadline > 0),
|
|
9051
|
+
writer_enqueued_at INTEGER CHECK (writer_enqueued_at IS NULL OR writer_enqueued_at > 0),
|
|
9052
|
+
writer_nonce TEXT,
|
|
9053
|
+
writer_admitted_at INTEGER CHECK (writer_admitted_at IS NULL OR writer_admitted_at > 0),
|
|
9054
|
+
writer_lease_expires_at INTEGER CHECK (writer_lease_expires_at IS NULL OR writer_lease_expires_at > 0),
|
|
9055
|
+
barrier_id TEXT,
|
|
9056
|
+
barrier_nonce TEXT,
|
|
9057
|
+
barrier_host TEXT,
|
|
9058
|
+
barrier_pid INTEGER CHECK (barrier_pid IS NULL OR barrier_pid > 0),
|
|
9059
|
+
barrier_boot_id TEXT,
|
|
9060
|
+
barrier_process_start TEXT,
|
|
9061
|
+
barrier_deadline INTEGER CHECK (barrier_deadline IS NULL OR barrier_deadline > 0),
|
|
9062
|
+
barrier_requested_at INTEGER CHECK (barrier_requested_at IS NULL OR barrier_requested_at > 0),
|
|
9063
|
+
barrier_lease_expires_at INTEGER CHECK (barrier_lease_expires_at IS NULL OR barrier_lease_expires_at > 0),
|
|
9064
|
+
barrier_status TEXT CHECK (barrier_status IS NULL OR barrier_status IN ('requested','active')),
|
|
9065
|
+
barrier_active_at INTEGER CHECK (barrier_active_at IS NULL OR barrier_active_at > 0),
|
|
9066
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_sequence IS NULL)),
|
|
9067
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_host IS NULL)),
|
|
9068
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_pid IS NULL)),
|
|
9069
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_boot_id IS NULL)),
|
|
9070
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_process_start IS NULL)),
|
|
9071
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_deadline IS NULL)),
|
|
9072
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_enqueued_at IS NULL)),
|
|
9073
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_nonce IS NULL)),
|
|
9074
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_admitted_at IS NULL)),
|
|
9075
|
+
CHECK ((writer_ticket_id IS NULL) = (writer_lease_expires_at IS NULL)),
|
|
9076
|
+
CHECK ((barrier_id IS NULL) = (barrier_nonce IS NULL)),
|
|
9077
|
+
CHECK ((barrier_id IS NULL) = (barrier_host IS NULL)),
|
|
9078
|
+
CHECK ((barrier_id IS NULL) = (barrier_pid IS NULL)),
|
|
9079
|
+
CHECK ((barrier_id IS NULL) = (barrier_boot_id IS NULL)),
|
|
9080
|
+
CHECK ((barrier_id IS NULL) = (barrier_process_start IS NULL)),
|
|
9081
|
+
CHECK ((barrier_id IS NULL) = (barrier_deadline IS NULL)),
|
|
9082
|
+
CHECK ((barrier_id IS NULL) = (barrier_requested_at IS NULL)),
|
|
9083
|
+
CHECK ((barrier_id IS NULL) = (barrier_lease_expires_at IS NULL)),
|
|
9084
|
+
CHECK ((barrier_id IS NULL) = (barrier_status IS NULL)),
|
|
9085
|
+
CHECK (
|
|
9086
|
+
(barrier_status IS NULL AND barrier_active_at IS NULL) OR
|
|
9087
|
+
(barrier_status = 'requested' AND barrier_active_at IS NULL) OR
|
|
9088
|
+
(barrier_status = 'active' AND barrier_active_at IS NOT NULL)
|
|
9089
|
+
)
|
|
9090
|
+
) STRICT;
|
|
9091
|
+
CREATE TABLE ne19_coordination_tickets (
|
|
9092
|
+
ticket_id TEXT PRIMARY KEY,
|
|
9093
|
+
sequence INTEGER NOT NULL UNIQUE CHECK (sequence > 0),
|
|
9094
|
+
host TEXT NOT NULL,
|
|
9095
|
+
pid INTEGER NOT NULL CHECK (pid > 0),
|
|
9096
|
+
boot_id TEXT NOT NULL,
|
|
9097
|
+
process_start TEXT NOT NULL,
|
|
9098
|
+
deadline INTEGER NOT NULL CHECK (deadline > 0),
|
|
9099
|
+
enqueued_at INTEGER NOT NULL CHECK (enqueued_at > 0)
|
|
9100
|
+
) STRICT;
|
|
9101
|
+
CREATE TABLE ne19_runs (
|
|
9102
|
+
run_id TEXT PRIMARY KEY,
|
|
9103
|
+
experiment_id TEXT NOT NULL,
|
|
9104
|
+
status TEXT NOT NULL CHECK (status IN ('open','sealing','sealed')),
|
|
9105
|
+
writer_generation TEXT NOT NULL,
|
|
9106
|
+
started_at TEXT NOT NULL,
|
|
9107
|
+
core_payload BLOB,
|
|
9108
|
+
core_digest TEXT CHECK (core_digest IS NULL OR length(core_digest) = 64),
|
|
9109
|
+
mutation_sequence INTEGER NOT NULL DEFAULT 0 CHECK (mutation_sequence >= 0),
|
|
9110
|
+
candidate_seal_identity TEXT CHECK (candidate_seal_identity IS NULL OR length(candidate_seal_identity) = 64),
|
|
9111
|
+
candidate_seal_entry_count INTEGER CHECK (candidate_seal_entry_count IS NULL OR candidate_seal_entry_count >= 0),
|
|
9112
|
+
candidate_seal_staged_count INTEGER NOT NULL DEFAULT 0 CHECK (candidate_seal_staged_count >= 0),
|
|
9113
|
+
logical_seal_identity TEXT,
|
|
9114
|
+
CHECK ((core_payload IS NULL) = (core_digest IS NULL)),
|
|
9115
|
+
CHECK ((candidate_seal_identity IS NULL) = (candidate_seal_entry_count IS NULL)),
|
|
9116
|
+
CHECK ((status = 'open') = (candidate_seal_identity IS NULL)),
|
|
9117
|
+
CHECK (candidate_seal_entry_count IS NULL OR candidate_seal_staged_count <= candidate_seal_entry_count),
|
|
9118
|
+
CHECK (status != 'open' OR candidate_seal_staged_count = 0),
|
|
9119
|
+
CHECK ((status = 'sealed') = (logical_seal_identity IS NOT NULL)),
|
|
9120
|
+
CHECK (status = 'open' OR core_payload IS NOT NULL)
|
|
9121
|
+
) STRICT;
|
|
9122
|
+
CREATE TABLE ne19_slots (
|
|
9123
|
+
run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
|
|
9124
|
+
slot_id TEXT NOT NULL,
|
|
9125
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9126
|
+
core_payload BLOB NOT NULL,
|
|
9127
|
+
core_digest TEXT NOT NULL CHECK (length(core_digest) = 64),
|
|
9128
|
+
PRIMARY KEY (run_id, slot_id),
|
|
9129
|
+
UNIQUE (run_id, ordinal)
|
|
9130
|
+
) STRICT;
|
|
9131
|
+
CREATE TABLE ne19_attempts (
|
|
9132
|
+
origin_run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
|
|
9133
|
+
attempt_id TEXT NOT NULL,
|
|
9134
|
+
attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),
|
|
9135
|
+
publication_state TEXT NOT NULL DEFAULT 'staging' CHECK (publication_state IN ('staging','sealing','published')),
|
|
9136
|
+
core_payload BLOB,
|
|
9137
|
+
core_digest TEXT CHECK (core_digest IS NULL OR length(core_digest) = 64),
|
|
9138
|
+
CHECK ((core_payload IS NULL) = (core_digest IS NULL)),
|
|
9139
|
+
PRIMARY KEY (origin_run_id, attempt_id)
|
|
9140
|
+
) STRICT;
|
|
9141
|
+
CREATE TABLE ne19_members (
|
|
9142
|
+
target_run_id TEXT NOT NULL,
|
|
9143
|
+
slot_id TEXT NOT NULL,
|
|
9144
|
+
origin_run_id TEXT,
|
|
9145
|
+
attempt_id TEXT,
|
|
9146
|
+
action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted','not-dispatched','interrupted')),
|
|
9147
|
+
core_payload BLOB NOT NULL,
|
|
9148
|
+
core_digest TEXT NOT NULL CHECK (length(core_digest) = 64),
|
|
9149
|
+
PRIMARY KEY (target_run_id, slot_id),
|
|
9150
|
+
CHECK (
|
|
9151
|
+
(action IN ('executed','carried','accepted') AND origin_run_id IS NOT NULL AND attempt_id IS NOT NULL) OR
|
|
9152
|
+
(action IN ('not-dispatched','interrupted') AND origin_run_id IS NULL AND attempt_id IS NULL)
|
|
9153
|
+
),
|
|
9154
|
+
FOREIGN KEY (target_run_id, slot_id) REFERENCES ne19_slots(run_id, slot_id) ON DELETE CASCADE
|
|
9155
|
+
) STRICT;
|
|
9156
|
+
CREATE TABLE ne19_attachments (
|
|
9157
|
+
attachment_id TEXT PRIMARY KEY,
|
|
9158
|
+
owner_kind TEXT NOT NULL CHECK (owner_kind IN ('run','attempt')),
|
|
9159
|
+
owner_run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
|
|
9160
|
+
owner_attempt_id TEXT,
|
|
9161
|
+
family TEXT NOT NULL,
|
|
9162
|
+
family_revision INTEGER NOT NULL CHECK (family_revision > 0),
|
|
9163
|
+
logical_identity TEXT,
|
|
9164
|
+
canonical_payload BLOB,
|
|
9165
|
+
canonical_digest TEXT CHECK (canonical_digest IS NULL OR length(canonical_digest) = 64),
|
|
9166
|
+
logical_inventory BLOB,
|
|
9167
|
+
inventory_digest TEXT CHECK (inventory_digest IS NULL OR length(inventory_digest) = 64),
|
|
9168
|
+
CHECK ((canonical_payload IS NULL) = (canonical_digest IS NULL)),
|
|
9169
|
+
CHECK ((logical_inventory IS NULL) = (inventory_digest IS NULL)),
|
|
9170
|
+
CHECK ((owner_kind = 'run' AND owner_attempt_id IS NULL) OR (owner_kind = 'attempt' AND owner_attempt_id IS NOT NULL)),
|
|
9171
|
+
UNIQUE (owner_kind, owner_run_id, owner_attempt_id, family),
|
|
9172
|
+
FOREIGN KEY (owner_run_id, owner_attempt_id) REFERENCES ne19_attempts(origin_run_id, attempt_id) ON DELETE CASCADE
|
|
9173
|
+
) STRICT;
|
|
9174
|
+
CREATE TABLE ne19_attachment_references (
|
|
9175
|
+
attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,
|
|
9176
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9177
|
+
target_owner_kind TEXT NOT NULL CHECK (target_owner_kind IN ('run','attempt')),
|
|
9178
|
+
target_family TEXT NOT NULL,
|
|
9179
|
+
canonical_payload BLOB NOT NULL,
|
|
9180
|
+
reference_digest TEXT NOT NULL CHECK (length(reference_digest) = 64),
|
|
9181
|
+
PRIMARY KEY (attachment_id, ordinal)
|
|
9182
|
+
) STRICT;
|
|
9183
|
+
CREATE TABLE ne19_collection_items (
|
|
9184
|
+
attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,
|
|
9185
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9186
|
+
logical_identity TEXT NOT NULL,
|
|
9187
|
+
canonical_payload BLOB NOT NULL,
|
|
9188
|
+
canonical_digest TEXT NOT NULL CHECK (length(canonical_digest) = 64),
|
|
9189
|
+
PRIMARY KEY (attachment_id, ordinal),
|
|
9190
|
+
UNIQUE (attachment_id, logical_identity)
|
|
9191
|
+
) STRICT;
|
|
9192
|
+
CREATE TABLE ne19_contents (
|
|
9193
|
+
content_id TEXT PRIMARY KEY,
|
|
9194
|
+
attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,
|
|
9195
|
+
logical_handle TEXT NOT NULL,
|
|
9196
|
+
byte_length INTEGER CHECK (byte_length IS NULL OR byte_length >= 0),
|
|
9197
|
+
overall_digest TEXT CHECK (overall_digest IS NULL OR length(overall_digest) = 64),
|
|
9198
|
+
chunk_count INTEGER CHECK (chunk_count IS NULL OR chunk_count >= 0),
|
|
9199
|
+
CHECK ((byte_length IS NULL) = (overall_digest IS NULL) AND (overall_digest IS NULL) = (chunk_count IS NULL)),
|
|
9200
|
+
UNIQUE (attachment_id, logical_handle)
|
|
9201
|
+
) STRICT;
|
|
9202
|
+
CREATE TABLE ne19_content_chunks (
|
|
9203
|
+
content_id TEXT NOT NULL REFERENCES ne19_contents(content_id) ON DELETE CASCADE,
|
|
9204
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9205
|
+
bytes BLOB NOT NULL CHECK (length(bytes) <= 262144),
|
|
9206
|
+
chunk_digest TEXT NOT NULL CHECK (length(chunk_digest) = 64),
|
|
9207
|
+
PRIMARY KEY (content_id, ordinal)
|
|
9208
|
+
) STRICT;
|
|
9209
|
+
CREATE TABLE ne19_run_seal_entries (
|
|
9210
|
+
run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
|
|
9211
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9212
|
+
entry_kind TEXT NOT NULL CHECK (entry_kind IN ('record','run','slot','member','attempt','attachment','attachment-reference','collection-item','content','content-chunk')),
|
|
9213
|
+
logical_identity TEXT NOT NULL,
|
|
9214
|
+
digest TEXT NOT NULL CHECK (length(digest) = 64),
|
|
9215
|
+
PRIMARY KEY (run_id, ordinal),
|
|
9216
|
+
UNIQUE (run_id, entry_kind, logical_identity)
|
|
9217
|
+
) STRICT;
|
|
9218
|
+
CREATE INDEX ne19_attachments_owner_family ON ne19_attachments(owner_kind, owner_run_id, owner_attempt_id, family);
|
|
9219
|
+
CREATE UNIQUE INDEX ne19_attachments_owner_family_unique ON ne19_attachments(owner_kind, owner_run_id, coalesce(owner_attempt_id,''), family);
|
|
9220
|
+
CREATE INDEX ne19_members_origin_attempt ON ne19_members(origin_run_id, attempt_id, target_run_id);
|
|
9221
|
+
CREATE INDEX ne19_attempts_locator ON ne19_attempts(attempt_locator, origin_run_id, attempt_id);
|
|
9222
|
+
CREATE INDEX ne19_references_target_family ON ne19_attachment_references(target_owner_kind, target_family);
|
|
9223
|
+
CREATE INDEX ne19_content_chunks_page ON ne19_content_chunks(content_id, ordinal);
|
|
9224
|
+
CREATE INDEX ne19_coordination_tickets_fifo ON ne19_coordination_tickets(sequence);
|
|
9225
|
+
CREATE TRIGGER ne19_coordination_ticket_barrier_insert BEFORE INSERT ON ne19_coordination_tickets WHEN (SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;
|
|
9226
|
+
CREATE TRIGGER ne19_coordination_writer_barrier_update BEFORE UPDATE ON ne19_coordination_state WHEN NEW.writer_ticket_id IS NOT NULL AND (SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;
|
|
9227
|
+
CREATE TRIGGER ne19_runs_sealed_update BEFORE UPDATE ON ne19_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;
|
|
9228
|
+
CREATE TRIGGER ne19_runs_sealed_delete BEFORE DELETE ON ne19_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;
|
|
9229
|
+
CREATE TRIGGER ne19_slots_sealed_insert BEFORE INSERT ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9230
|
+
CREATE TRIGGER ne19_slots_sealed_update BEFORE UPDATE ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9231
|
+
CREATE TRIGGER ne19_slots_sealed_delete BEFORE DELETE ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9232
|
+
CREATE TRIGGER ne19_attempts_sealed_insert BEFORE INSERT ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9233
|
+
CREATE TRIGGER ne19_attempts_sealed_update BEFORE UPDATE ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9234
|
+
CREATE TRIGGER ne19_attempts_sealed_delete BEFORE DELETE ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9235
|
+
CREATE TRIGGER ne19_members_sealed_insert BEFORE INSERT ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9236
|
+
CREATE TRIGGER ne19_members_sealed_update BEFORE UPDATE ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9237
|
+
CREATE TRIGGER ne19_members_sealed_delete BEFORE DELETE ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9238
|
+
CREATE TRIGGER ne19_attachments_sealed_insert BEFORE INSERT ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9239
|
+
CREATE TRIGGER ne19_attachments_attempt_published_insert BEFORE INSERT ON ne19_attachments WHEN NEW.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=NEW.owner_run_id AND attempt_id=NEW.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
|
|
9240
|
+
CREATE TRIGGER ne19_attachments_sealed_update BEFORE UPDATE ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9241
|
+
CREATE TRIGGER ne19_attachments_attempt_published_update BEFORE UPDATE ON ne19_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
|
|
9242
|
+
CREATE TRIGGER ne19_attachments_sealed_delete BEFORE DELETE ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9243
|
+
CREATE TRIGGER ne19_attachments_attempt_published_delete BEFORE DELETE ON ne19_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
|
|
9244
|
+
CREATE TRIGGER ne19_references_sealed_insert BEFORE INSERT ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9245
|
+
CREATE TRIGGER ne19_references_sealed_update BEFORE UPDATE ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9246
|
+
CREATE TRIGGER ne19_references_sealed_delete BEFORE DELETE ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9247
|
+
CREATE TRIGGER ne19_items_sealed_insert BEFORE INSERT ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9248
|
+
CREATE TRIGGER ne19_items_sealed_update BEFORE UPDATE ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9249
|
+
CREATE TRIGGER ne19_items_sealed_delete BEFORE DELETE ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9250
|
+
CREATE TRIGGER ne19_contents_sealed_insert BEFORE INSERT ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9251
|
+
CREATE TRIGGER ne19_contents_sealed_update BEFORE UPDATE ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9252
|
+
CREATE TRIGGER ne19_contents_sealed_delete BEFORE DELETE ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9253
|
+
CREATE TRIGGER ne19_chunks_sealed_insert BEFORE INSERT ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=NEW.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9254
|
+
CREATE TRIGGER ne19_chunks_sealed_update BEFORE UPDATE ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9255
|
+
CREATE TRIGGER ne19_chunks_sealed_delete BEFORE DELETE ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
|
|
9256
|
+
CREATE TRIGGER ne19_seal_entries_sealed_insert BEFORE INSERT ON ne19_run_seal_entries WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.run_id) != 'sealing' BEGIN SELECT RAISE(ABORT, 'Seal candidates require sealing state'); END;
|
|
9257
|
+
CREATE TRIGGER ne19_seal_entries_sealed_update BEFORE UPDATE ON ne19_run_seal_entries BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;
|
|
9258
|
+
CREATE TRIGGER ne19_seal_entries_sealed_delete BEFORE DELETE ON ne19_run_seal_entries WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;
|
|
9259
|
+
|
|
9260
|
+
|
|
9261
|
+
CREATE TABLE ne19_run_publication_clock (
|
|
9262
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
9263
|
+
revision INTEGER NOT NULL CHECK (revision >= 0)
|
|
9264
|
+
) STRICT;
|
|
9265
|
+
CREATE TABLE ne19_run_resources (
|
|
9266
|
+
run_id TEXT PRIMARY KEY,
|
|
9267
|
+
invocation_id TEXT NOT NULL,
|
|
9268
|
+
experiment_id TEXT NOT NULL,
|
|
9269
|
+
started_at TEXT NOT NULL,
|
|
9270
|
+
initial_writer_generation TEXT NOT NULL,
|
|
9271
|
+
current_writer_generation TEXT NOT NULL,
|
|
9272
|
+
terminal_state TEXT CHECK (terminal_state IS NULL OR terminal_state IN ('completed','interrupted','failed')),
|
|
9273
|
+
completed_at TEXT,
|
|
9274
|
+
created_revision INTEGER NOT NULL UNIQUE CHECK (created_revision > 0),
|
|
9275
|
+
close_revision INTEGER UNIQUE CHECK (close_revision IS NULL OR close_revision > created_revision),
|
|
9276
|
+
CHECK ((terminal_state IS NULL) = (completed_at IS NULL)),
|
|
9277
|
+
CHECK ((terminal_state IS NULL) = (close_revision IS NULL))
|
|
9278
|
+
) STRICT;
|
|
9279
|
+
CREATE TABLE ne19_run_expected_slots (
|
|
9280
|
+
run_id TEXT NOT NULL REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
|
|
9281
|
+
slot_id TEXT NOT NULL,
|
|
9282
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9283
|
+
eval_id TEXT NOT NULL,
|
|
9284
|
+
attempt_ordinal INTEGER NOT NULL CHECK (attempt_ordinal >= 0),
|
|
9285
|
+
execution_identity_digest TEXT NOT NULL CHECK (length(execution_identity_digest) = 64),
|
|
9286
|
+
PRIMARY KEY (run_id, slot_id),
|
|
9287
|
+
UNIQUE (run_id, ordinal)
|
|
9288
|
+
) STRICT;
|
|
9289
|
+
CREATE TABLE ne19_attempt_publications (
|
|
9290
|
+
attempt_id TEXT PRIMARY KEY,
|
|
9291
|
+
attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),
|
|
9292
|
+
origin_run_id TEXT NOT NULL,
|
|
9293
|
+
origin_slot_id TEXT NOT NULL,
|
|
9294
|
+
closure_payload BLOB NOT NULL,
|
|
9295
|
+
closure_digest TEXT NOT NULL CHECK (length(closure_digest) = 64),
|
|
9296
|
+
published_revision INTEGER NOT NULL UNIQUE CHECK (published_revision > 0),
|
|
9297
|
+
FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
|
|
9298
|
+
) STRICT;
|
|
9299
|
+
CREATE TABLE ne19_run_slot_bindings (
|
|
9300
|
+
target_run_id TEXT NOT NULL,
|
|
9301
|
+
slot_id TEXT NOT NULL,
|
|
9302
|
+
attempt_id TEXT NOT NULL REFERENCES ne19_attempt_publications(attempt_id) ON DELETE RESTRICT,
|
|
9303
|
+
origin_run_id TEXT NOT NULL,
|
|
9304
|
+
origin_slot_id TEXT NOT NULL,
|
|
9305
|
+
attempt_publication_revision INTEGER NOT NULL CHECK (attempt_publication_revision > 0),
|
|
9306
|
+
action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted')),
|
|
9307
|
+
binding_revision INTEGER NOT NULL UNIQUE CHECK (binding_revision > 0),
|
|
9308
|
+
PRIMARY KEY (target_run_id, slot_id),
|
|
9309
|
+
FOREIGN KEY (target_run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT,
|
|
9310
|
+
FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
|
|
9311
|
+
) STRICT;
|
|
9312
|
+
CREATE TABLE ne19_run_slot_absences (
|
|
9313
|
+
run_id TEXT NOT NULL,
|
|
9314
|
+
slot_id TEXT NOT NULL,
|
|
9315
|
+
reason TEXT NOT NULL CHECK (reason IN ('early-exit-satisfied','budget-exhausted','stopped-by-failure','interrupted-before-publication','dispatch-failed')),
|
|
9316
|
+
absence_revision INTEGER NOT NULL CHECK (absence_revision > 0),
|
|
9317
|
+
PRIMARY KEY (run_id, slot_id),
|
|
9318
|
+
FOREIGN KEY (run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
|
|
9319
|
+
) STRICT;
|
|
9320
|
+
CREATE TABLE ne19_run_recoveries (
|
|
9321
|
+
run_id TEXT PRIMARY KEY REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
|
|
9322
|
+
previous_writer_generation TEXT NOT NULL,
|
|
9323
|
+
recovery_writer_generation TEXT NOT NULL,
|
|
9324
|
+
evidence_kind TEXT NOT NULL,
|
|
9325
|
+
evidence_identity TEXT NOT NULL,
|
|
9326
|
+
evidence_observed_at TEXT NOT NULL,
|
|
9327
|
+
recovery_revision INTEGER NOT NULL UNIQUE CHECK (recovery_revision > 0)
|
|
9328
|
+
) STRICT;
|
|
9329
|
+
CREATE TABLE ne19_run_deletion_tombstones (
|
|
9330
|
+
run_id TEXT PRIMARY KEY REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
|
|
9331
|
+
terminal_state TEXT NOT NULL CHECK (terminal_state IN ('completed','interrupted','failed')),
|
|
9332
|
+
deleted_at TEXT NOT NULL,
|
|
9333
|
+
deletion_revision INTEGER NOT NULL UNIQUE CHECK (deletion_revision > 0)
|
|
9334
|
+
) STRICT;
|
|
9335
|
+
CREATE INDEX ne19_runs_experiment ON ne19_runs(experiment_id,run_id);
|
|
9336
|
+
CREATE INDEX ne19_run_resources_experiment ON ne19_run_resources(experiment_id,created_revision,run_id);
|
|
9337
|
+
CREATE INDEX ne19_run_expected_slots_position ON ne19_run_expected_slots(eval_id,attempt_ordinal,run_id);
|
|
9338
|
+
CREATE INDEX ne19_run_resources_list ON ne19_run_resources(created_revision, run_id);
|
|
9339
|
+
CREATE INDEX ne19_run_resources_invocation ON ne19_run_resources(invocation_id, created_revision, run_id);
|
|
9340
|
+
CREATE INDEX ne19_attempt_publications_origin ON ne19_attempt_publications(origin_run_id, origin_slot_id);
|
|
9341
|
+
CREATE INDEX ne19_attempt_publications_locator ON ne19_attempt_publications(attempt_locator, origin_run_id, attempt_id);
|
|
9342
|
+
CREATE INDEX ne19_run_slot_bindings_attempt ON ne19_run_slot_bindings(attempt_id, target_run_id, slot_id);
|
|
9343
|
+
CREATE INDEX ne19_run_deletion_revision ON ne19_run_deletion_tombstones(deletion_revision, run_id);
|
|
9344
|
+
INSERT INTO ne19_run_publication_clock(singleton,revision) VALUES (1,0);
|
|
9345
|
+
|
|
9346
|
+
|
|
9347
|
+
CREATE TABLE ne19_invocation_sessions (
|
|
9348
|
+
invocation_id TEXT PRIMARY KEY,
|
|
9349
|
+
state TEXT NOT NULL CHECK (state IN ('active','recovering','completed','interrupted','failed')),
|
|
9350
|
+
owner_id TEXT NOT NULL,
|
|
9351
|
+
owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),
|
|
9352
|
+
owner_host TEXT NOT NULL,
|
|
9353
|
+
owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),
|
|
9354
|
+
owner_boot_id TEXT NOT NULL,
|
|
9355
|
+
owner_process_start TEXT NOT NULL,
|
|
9356
|
+
started_at TEXT NOT NULL,
|
|
9357
|
+
heartbeat_at TEXT NOT NULL,
|
|
9358
|
+
active_projection BLOB,
|
|
9359
|
+
recovering_at TEXT,
|
|
9360
|
+
closed_at TEXT,
|
|
9361
|
+
terminal_projection BLOB,
|
|
9362
|
+
CHECK ((state IN ('completed','interrupted','failed')) = (closed_at IS NOT NULL)),
|
|
9363
|
+
CHECK ((state IN ('completed','interrupted','failed')) = (terminal_projection IS NOT NULL)),
|
|
9364
|
+
CHECK (state IN ('active','recovering') OR active_projection IS NULL),
|
|
9365
|
+
CHECK ((state = 'recovering') = (recovering_at IS NOT NULL))
|
|
9366
|
+
) STRICT;
|
|
9367
|
+
CREATE TABLE ne19_invocation_session_experiments (
|
|
9368
|
+
invocation_id TEXT NOT NULL REFERENCES ne19_invocation_sessions(invocation_id) ON DELETE RESTRICT,
|
|
9369
|
+
experiment_id TEXT NOT NULL,
|
|
9370
|
+
run_id TEXT NOT NULL UNIQUE REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
|
|
9371
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9372
|
+
PRIMARY KEY (invocation_id, experiment_id),
|
|
9373
|
+
UNIQUE (invocation_id, ordinal)
|
|
9374
|
+
) STRICT;
|
|
9375
|
+
CREATE TABLE ne19_invocation_session_queued_attempts (
|
|
9376
|
+
invocation_id TEXT NOT NULL REFERENCES ne19_invocation_sessions(invocation_id) ON DELETE RESTRICT,
|
|
9377
|
+
attempt_id TEXT NOT NULL,
|
|
9378
|
+
run_id TEXT NOT NULL REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
|
|
9379
|
+
slot_id TEXT NOT NULL,
|
|
9380
|
+
ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
|
|
9381
|
+
PRIMARY KEY (invocation_id, attempt_id),
|
|
9382
|
+
UNIQUE (invocation_id, ordinal),
|
|
9383
|
+
FOREIGN KEY (run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
|
|
9384
|
+
) STRICT;
|
|
9385
|
+
CREATE TABLE ne19_case_locks (
|
|
9386
|
+
case_id TEXT PRIMARY KEY,
|
|
9387
|
+
owner_id TEXT NOT NULL,
|
|
9388
|
+
owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),
|
|
9389
|
+
owner_host TEXT NOT NULL,
|
|
9390
|
+
owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),
|
|
9391
|
+
owner_boot_id TEXT NOT NULL,
|
|
9392
|
+
owner_process_start TEXT NOT NULL,
|
|
9393
|
+
acquired_at TEXT NOT NULL,
|
|
9394
|
+
heartbeat_at TEXT NOT NULL
|
|
9395
|
+
) STRICT;
|
|
9396
|
+
CREATE INDEX ne19_invocation_sessions_state ON ne19_invocation_sessions(state, started_at, invocation_id);
|
|
9397
|
+
CREATE INDEX ne19_invocation_session_experiments_invocation ON ne19_invocation_session_experiments(invocation_id, ordinal);
|
|
9398
|
+
CREATE INDEX ne19_invocation_session_queued_attempts_run ON ne19_invocation_session_queued_attempts(run_id, slot_id);
|
|
9399
|
+
CREATE INDEX ne19_case_locks_owner ON ne19_case_locks(owner_id, owner_generation);
|
|
9400
|
+
CREATE TABLE ne19_teardown_obligations (
|
|
9401
|
+
obligation_id TEXT PRIMARY KEY,
|
|
9402
|
+
experiment_id TEXT NOT NULL,
|
|
9403
|
+
owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),
|
|
9404
|
+
owner_host TEXT NOT NULL,
|
|
9405
|
+
generation INTEGER NOT NULL DEFAULT 1 CHECK (generation > 0),
|
|
9406
|
+
payload BLOB NOT NULL,
|
|
9407
|
+
UNIQUE (experiment_id, owner_pid)
|
|
9408
|
+
) STRICT;
|
|
9409
|
+
CREATE TABLE ne19_shared_state_generations (
|
|
9410
|
+
state_key TEXT NOT NULL,
|
|
9411
|
+
generation INTEGER NOT NULL CHECK (generation > 0),
|
|
9412
|
+
parent_generation INTEGER NOT NULL CHECK (parent_generation >= 0),
|
|
9413
|
+
state_kind TEXT NOT NULL CHECK (state_kind IN ('active','recovering','free')),
|
|
9414
|
+
owner_token TEXT NOT NULL,
|
|
9415
|
+
owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),
|
|
9416
|
+
owner_host TEXT NOT NULL,
|
|
9417
|
+
owner_process_identity TEXT NOT NULL,
|
|
9418
|
+
heartbeat_at TEXT NOT NULL,
|
|
9419
|
+
payload BLOB NOT NULL,
|
|
9420
|
+
PRIMARY KEY (state_key, generation),
|
|
9421
|
+
CHECK (parent_generation = generation - 1)
|
|
9422
|
+
) STRICT;
|
|
9423
|
+
CREATE TABLE ne19_kept_sandboxes (
|
|
9424
|
+
entry_id TEXT PRIMARY KEY,
|
|
9425
|
+
provider TEXT NOT NULL,
|
|
9426
|
+
sandbox_id TEXT NOT NULL,
|
|
9427
|
+
kept_at TEXT NOT NULL,
|
|
9428
|
+
operation_generation INTEGER NOT NULL DEFAULT 0 CHECK (operation_generation >= 0),
|
|
9429
|
+
payload BLOB NOT NULL,
|
|
9430
|
+
UNIQUE (provider, sandbox_id)
|
|
9431
|
+
) STRICT;
|
|
9432
|
+
CREATE TABLE ne19_kept_sandbox_operation_leases (
|
|
9433
|
+
entry_id TEXT PRIMARY KEY REFERENCES ne19_kept_sandboxes(entry_id) ON DELETE CASCADE,
|
|
9434
|
+
generation INTEGER NOT NULL CHECK (generation > 0),
|
|
9435
|
+
token TEXT NOT NULL,
|
|
9436
|
+
holder TEXT NOT NULL,
|
|
9437
|
+
owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),
|
|
9438
|
+
owner_host TEXT NOT NULL,
|
|
9439
|
+
owner_process_identity TEXT NOT NULL,
|
|
9440
|
+
operation TEXT NOT NULL,
|
|
9441
|
+
acquired_at TEXT NOT NULL,
|
|
9442
|
+
ttl_ms INTEGER NOT NULL CHECK (ttl_ms > 0)
|
|
9443
|
+
) STRICT;
|
|
9444
|
+
CREATE INDEX ne19_teardown_obligations_experiment ON ne19_teardown_obligations(experiment_id, owner_pid);
|
|
9445
|
+
CREATE INDEX ne19_shared_state_generations_head ON ne19_shared_state_generations(state_key, generation DESC);
|
|
9446
|
+
CREATE INDEX ne19_kept_sandboxes_kept_at ON ne19_kept_sandboxes(kept_at, entry_id);
|
|
9447
|
+
|
|
9448
|
+
|
|
9449
|
+
CREATE TABLE ne19_migration_state (
|
|
9450
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
9451
|
+
state TEXT NOT NULL CHECK (state IN ('committed','ready')),
|
|
9452
|
+
source_format TEXT,
|
|
9453
|
+
source_digest TEXT CHECK (source_digest IS NULL OR length(source_digest) = 64),
|
|
9454
|
+
CHECK ((source_format IS NULL) = (source_digest IS NULL)),
|
|
9455
|
+
CHECK (state != 'committed' OR source_format IS NOT NULL)
|
|
9456
|
+
) STRICT;`;
|
|
9457
|
+
//#endregion
|
|
9458
|
+
//#region src/record/sqlite/legacy-schema-018.ts
|
|
9459
|
+
/**
|
|
9460
|
+
* Frozen ProjectDatabase 0.18 schema. Keep the SQL bytes stable:
|
|
9461
|
+
* they own the historical format fingerprint.
|
|
9462
|
+
* The disjoint namespace fences writers prepared against the 0.17 tables.
|
|
9463
|
+
*/
|
|
9464
|
+
var RECORD_SQLITE_018_BASELINE_SQL = `
|
|
8966
9465
|
CREATE TABLE ne18_record_metadata (
|
|
8967
9466
|
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
8968
9467
|
format TEXT NOT NULL,
|
|
@@ -10302,7 +10801,8 @@ Object.freeze([
|
|
|
10302
10801
|
"kept_sandboxes",
|
|
10303
10802
|
"kept_sandbox_operation_leases"
|
|
10304
10803
|
]);
|
|
10305
|
-
|
|
10804
|
+
/** Complete fixed table allowlist for the historical 0.17 `ne_` namespace. */
|
|
10805
|
+
var RECORD_SQLITE_017_TABLE_NAMES = Object.freeze([
|
|
10306
10806
|
"ne_record_metadata",
|
|
10307
10807
|
"ne_coordination_state",
|
|
10308
10808
|
"ne_coordination_tickets",
|
|
@@ -10334,15 +10834,17 @@ Object.freeze([
|
|
|
10334
10834
|
"ne_kept_sandbox_operation_leases",
|
|
10335
10835
|
"ne_migration_state"
|
|
10336
10836
|
]);
|
|
10337
|
-
var RECORD_SQLITE_BASELINE_FINGERPRINT = createHash("sha256").update("niceeval.project-database.bootstrap/0.
|
|
10837
|
+
var RECORD_SQLITE_BASELINE_FINGERPRINT = createHash("sha256").update("niceeval.project-database.bootstrap/0.19\0").update(RECORD_SQLITE_BASELINE_SQL).digest("hex");
|
|
10338
10838
|
createHash("sha256").update("niceeval.project-database.bootstrap/0.17\0").update(RECORD_SQLITE_017_BASELINE_SQL).digest("hex");
|
|
10339
10839
|
Object.freeze({
|
|
10340
10840
|
"niceeval.project-database/0.15": createHash("sha256").update("niceeval.project-database.bootstrap/0.15\0").update(RECORD_SQLITE_LEGACY_BASELINE_SQL).digest("hex"),
|
|
10341
10841
|
"niceeval.project-database/0.16": createHash("sha256").update("niceeval.project-database.bootstrap/0.16\0").update(RECORD_SQLITE_LEGACY_BASELINE_SQL).digest("hex")
|
|
10342
10842
|
});
|
|
10843
|
+
Object.freeze(RECORD_SQLITE_017_TABLE_NAMES.map((table) => table.replace(/^ne_/u, "ne18_")));
|
|
10844
|
+
createHash("sha256").update("niceeval.project-database.bootstrap/0.18\0").update(RECORD_SQLITE_018_BASELINE_SQL).digest("hex");
|
|
10343
10845
|
//#endregion
|
|
10344
10846
|
//#region src/record/sqlite/types.ts
|
|
10345
|
-
var RECORD_SQLITE_FORMAT = "niceeval.project-database/0.
|
|
10847
|
+
var RECORD_SQLITE_FORMAT = "niceeval.project-database/0.19";
|
|
10346
10848
|
var RECORD_SQLITE_MAX_ROW_BYTES = 1048576;
|
|
10347
10849
|
var RECORD_SQLITE_MAX_VALIDATION_RUNS = 1e5;
|
|
10348
10850
|
var RECORD_SQLITE_VALIDATION_DEADLINE_MS = 3e4;
|
|
@@ -10634,7 +11136,7 @@ function validateSchemaObjects(connection, sql) {
|
|
|
10634
11136
|
if (actual.length !== expected.length || actual.some((row, index) => row !== expected[index])) throw sqliteError("record-schema-unsupported", "validate-schema", "database objects do not match the exact Project Record schema allowlist");
|
|
10635
11137
|
}
|
|
10636
11138
|
function storageRevision(connection) {
|
|
10637
|
-
const row = currentStatement(connection.db, "SELECT storage_revision FROM
|
|
11139
|
+
const row = currentStatement(connection.db, "SELECT storage_revision FROM ne19_record_metadata WHERE singleton=1").get();
|
|
10638
11140
|
if (row === void 0) throw sqliteError("record-schema-unsupported", "validate-schema", "ProjectDatabase identity is missing");
|
|
10639
11141
|
return decodeInteger(row.storage_revision, "record_metadata.storage_revision");
|
|
10640
11142
|
}
|
|
@@ -10660,12 +11162,12 @@ function validateCurrentRecordDomain(connection) {
|
|
|
10660
11162
|
let metadata;
|
|
10661
11163
|
try {
|
|
10662
11164
|
metadata = currentStatement(connection.db, `SELECT format,storage_revision,storage_generation,schema_fingerprint,barrier_state
|
|
10663
|
-
FROM
|
|
11165
|
+
FROM ne19_record_metadata WHERE singleton=1`).get();
|
|
10664
11166
|
} catch (cause) {
|
|
10665
11167
|
throw sqliteError("record-schema-unsupported", "validate-schema", "database does not expose the ProjectDatabase identity", cause);
|
|
10666
11168
|
}
|
|
10667
11169
|
if (metadata === void 0) throw sqliteError("record-schema-unsupported", "validate-schema", "ProjectDatabase identity is missing");
|
|
10668
|
-
if (decodeText(metadata.format, "record_metadata.format") !== "niceeval.project-database/0.
|
|
11170
|
+
if (decodeText(metadata.format, "record_metadata.format") !== "niceeval.project-database/0.19") throw sqliteError("record-schema-unsupported", "validate-schema", "record format is unsupported");
|
|
10669
11171
|
const revision = decodeInteger(metadata.storage_revision, "record_metadata.storage_revision");
|
|
10670
11172
|
if (revision !== 1) throw sqliteError("record-schema-unsupported", "validate-schema", `record storage revision ${revision} is not 1`);
|
|
10671
11173
|
if (decodeText(metadata.schema_fingerprint, "record_metadata.schema_fingerprint") !== RECORD_SQLITE_BASELINE_FINGERPRINT) throw sqliteError("record-schema-unsupported", "validate-schema", "ProjectDatabase baseline fingerprint is unsupported");
|
|
@@ -10673,16 +11175,16 @@ function validateCurrentRecordDomain(connection) {
|
|
|
10673
11175
|
if (barrierState !== "open" && barrierState !== "draining" && barrierState !== "portable") throw sqliteError("record-database-invalid", "validate-schema", "ProjectDatabase barrier state is invalid");
|
|
10674
11176
|
validateSchemaObjects(connection);
|
|
10675
11177
|
const coordination = currentStatement(connection.db, `SELECT revision,operational_generation,next_writer_sequence,
|
|
10676
|
-
writer_ticket_id,barrier_id FROM
|
|
11178
|
+
writer_ticket_id,barrier_id FROM ne19_coordination_state WHERE singleton=1`).get();
|
|
10677
11179
|
if (coordination === void 0) throw sqliteError("record-database-invalid", "validate-schema", "host coordination generation is missing");
|
|
10678
11180
|
if (decodeText(coordination.operational_generation, "coordination_state.operational_generation") !== decodeText(metadata.storage_generation, "record_metadata.storage_generation")) throw sqliteError("record-database-invalid", "validate-schema", "operational coordination generation does not match ProjectDatabase");
|
|
10679
|
-
const migration = currentStatement(connection.db, "SELECT state FROM
|
|
11181
|
+
const migration = currentStatement(connection.db, "SELECT state FROM ne19_migration_state WHERE singleton=1").get();
|
|
10680
11182
|
if (migration === void 0) throw sqliteError("record-database-invalid", "validate-schema", "ProjectDatabase migration state is missing");
|
|
10681
11183
|
const migrationState = decodeText(migration.state, "migration_state.state");
|
|
10682
11184
|
if (migrationState !== "committed" && migrationState !== "ready") throw sqliteError("record-database-invalid", "validate-schema", "ProjectDatabase migration state is invalid");
|
|
10683
11185
|
}
|
|
10684
11186
|
function requireMigrationReady(connection) {
|
|
10685
|
-
const row = currentStatement(connection.db, "SELECT state FROM
|
|
11187
|
+
const row = currentStatement(connection.db, "SELECT state FROM ne19_migration_state WHERE singleton=1").get();
|
|
10686
11188
|
if (row === void 0 || decodeText(row.state, "migration_state.state") !== "ready") throw sqliteError("record-schema-migration-required", "open", "ProjectDatabase migration committed but requires Host verification");
|
|
10687
11189
|
}
|
|
10688
11190
|
function validateExactSchema(connection) {
|
|
@@ -10735,12 +11237,12 @@ function openRecordWriter(path, busyTimeoutMs = 5e3) {
|
|
|
10735
11237
|
db.exec("BEGIN IMMEDIATE");
|
|
10736
11238
|
try {
|
|
10737
11239
|
db.exec(RECORD_SQLITE_BASELINE_SQL);
|
|
10738
|
-
currentStatement(db, `INSERT INTO
|
|
11240
|
+
currentStatement(db, `INSERT INTO ne19_record_metadata(singleton,format,storage_revision,storage_generation,schema_fingerprint,
|
|
10739
11241
|
created_at,barrier_state,portable_generation,portable_revision,portable_gate_id,record_payload,record_digest)
|
|
10740
11242
|
VALUES (1,?,?,?,?,?,'open',NULL,NULL,NULL,NULL,NULL)`).run(RECORD_SQLITE_FORMAT, 1, generation, RECORD_SQLITE_BASELINE_FINGERPRINT, appliedAt);
|
|
10741
|
-
currentStatement(db, `INSERT INTO
|
|
11243
|
+
currentStatement(db, `INSERT INTO ne19_coordination_state(singleton,revision,operational_generation,next_writer_sequence)
|
|
10742
11244
|
VALUES (1,0,?,1)`).run(generation);
|
|
10743
|
-
currentStatement(db, `INSERT INTO
|
|
11245
|
+
currentStatement(db, `INSERT INTO ne19_migration_state(singleton,state,source_format,source_digest)
|
|
10744
11246
|
VALUES (1,'ready',NULL,NULL)`).run();
|
|
10745
11247
|
db.exec("COMMIT");
|
|
10746
11248
|
created = true;
|
|
@@ -10826,7 +11328,7 @@ function makeProjectDatabasePortable(path) {
|
|
|
10826
11328
|
let connection = openRecordWriter(path);
|
|
10827
11329
|
try {
|
|
10828
11330
|
connection.db.exec("BEGIN IMMEDIATE");
|
|
10829
|
-
const metadata = currentStatement(connection.db, "SELECT barrier_state,portable_gate_id FROM
|
|
11331
|
+
const metadata = currentStatement(connection.db, "SELECT barrier_state,portable_gate_id FROM ne19_record_metadata WHERE singleton=1").get();
|
|
10830
11332
|
if (metadata === void 0) throw sqliteError("record-database-invalid", "portable-gate", "ProjectDatabase barrier is missing");
|
|
10831
11333
|
const barrierState = decodeText(metadata.barrier_state, "barrier_state");
|
|
10832
11334
|
if (barrierState === "portable") {
|
|
@@ -10835,7 +11337,7 @@ function makeProjectDatabasePortable(path) {
|
|
|
10835
11337
|
}
|
|
10836
11338
|
if (barrierState === "draining") {
|
|
10837
11339
|
const previous = currentStatement(connection.db, `SELECT barrier_id,barrier_nonce,barrier_host,barrier_pid,
|
|
10838
|
-
barrier_boot_id,barrier_process_start FROM
|
|
11340
|
+
barrier_boot_id,barrier_process_start FROM ne19_coordination_state WHERE singleton=1`).get();
|
|
10839
11341
|
if (previous === void 0 || previous.barrier_id === null || previous.barrier_nonce === null) throw sqliteError("record-database-invalid", "portable-gate", "draining portable gate has no fenced owner");
|
|
10840
11342
|
const previousOwner = {
|
|
10841
11343
|
ownerId: decodeText(previous.barrier_id, "barrier_id"),
|
|
@@ -10845,58 +11347,58 @@ function makeProjectDatabasePortable(path) {
|
|
|
10845
11347
|
processStart: decodeText(previous.barrier_process_start, "barrier_process_start")
|
|
10846
11348
|
};
|
|
10847
11349
|
if (!(previousOwner.host === gateOwner.host && previousOwner.pid === gateOwner.pid && previousOwner.bootId === gateOwner.bootId && previousOwner.processStart === gateOwner.processStart) && exactProcessState(previousOwner) !== "dead") throw sqliteError("record-command-conflict", "portable-gate", "draining portable gate owner is not proven dead");
|
|
10848
|
-
const fenced = currentStatement(connection.db, `UPDATE
|
|
11350
|
+
const fenced = currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=?,barrier_nonce=?,barrier_host=?,
|
|
10849
11351
|
barrier_pid=?,barrier_boot_id=?,barrier_process_start=?,barrier_deadline=?,barrier_requested_at=?,
|
|
10850
11352
|
barrier_lease_expires_at=?,barrier_status='active',barrier_active_at=?,revision=revision+1
|
|
10851
11353
|
WHERE singleton=1 AND barrier_id=? AND barrier_nonce=?`).run(gateId, gateNonce, gateOwner.host, gateOwner.pid, gateOwner.bootId, gateOwner.processStart, admissionDrainDeadline, Date.now(), admissionDrainDeadline, Date.now(), previous.barrier_id, previous.barrier_nonce);
|
|
10852
|
-
const metadataFenced = currentStatement(connection.db, `UPDATE
|
|
11354
|
+
const metadataFenced = currentStatement(connection.db, `UPDATE ne19_record_metadata SET portable_gate_id=?
|
|
10853
11355
|
WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId, metadata.portable_gate_id);
|
|
10854
11356
|
if (Number(fenced.changes) !== 1 || Number(metadataFenced.changes) !== 1) throw sqliteError("record-command-conflict", "portable-gate", "draining portable gate changed during recovery");
|
|
10855
11357
|
} else if (barrierState === "open") {
|
|
10856
|
-
const entered = recordStatement(connection, `UPDATE
|
|
11358
|
+
const entered = recordStatement(connection, `UPDATE ne19_record_metadata SET barrier_state='draining',portable_gate_id=?
|
|
10857
11359
|
WHERE singleton=1 AND barrier_state='open' AND portable_gate_id IS NULL`).run(gateId);
|
|
10858
|
-
const established = currentStatement(connection.db, `UPDATE
|
|
11360
|
+
const established = currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=?,barrier_nonce=?,barrier_host=?,
|
|
10859
11361
|
barrier_pid=?,barrier_boot_id=?,barrier_process_start=?,barrier_deadline=?,barrier_requested_at=?,
|
|
10860
11362
|
barrier_lease_expires_at=?,barrier_status='active',barrier_active_at=?,revision=revision+1
|
|
10861
11363
|
WHERE singleton=1 AND barrier_id IS NULL`).run(gateId, gateNonce, gateOwner.host, gateOwner.pid, gateOwner.bootId, gateOwner.processStart, admissionDrainDeadline, Date.now(), admissionDrainDeadline, Date.now());
|
|
10862
11364
|
if (Number(entered.changes) !== 1 || Number(established.changes) !== 1) throw sqliteError("record-command-conflict", "portable-gate", "ProjectDatabase barrier is not open");
|
|
10863
11365
|
} else throw sqliteError("record-database-invalid", "portable-gate", "ProjectDatabase barrier state is invalid");
|
|
10864
11366
|
if (decodeInteger(currentStatement(connection.db, `SELECT
|
|
10865
|
-
(SELECT count(*) FROM
|
|
10866
|
-
(SELECT count(*) FROM
|
|
10867
|
-
(SELECT count(*) FROM
|
|
10868
|
-
(SELECT count(*) FROM
|
|
10869
|
-
(SELECT count(*) FROM
|
|
10870
|
-
(SELECT count(*) FROM
|
|
10871
|
-
currentStatement(connection.db, `UPDATE
|
|
11367
|
+
(SELECT count(*) FROM ne19_run_resources WHERE terminal_state IS NULL)+
|
|
11368
|
+
(SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+
|
|
11369
|
+
(SELECT count(*) FROM ne19_case_locks)+
|
|
11370
|
+
(SELECT count(*) FROM ne19_teardown_obligations)+
|
|
11371
|
+
(SELECT count(*) FROM ne19_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne19_shared_state_generations WHERE state_key=s.state_key))+
|
|
11372
|
+
(SELECT count(*) FROM ne19_kept_sandbox_operation_leases) AS count`).get().count, "active_runs") !== 0) {
|
|
11373
|
+
currentStatement(connection.db, `UPDATE ne19_record_metadata SET barrier_state='open',portable_gate_id=NULL
|
|
10872
11374
|
WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId);
|
|
10873
|
-
currentStatement(connection.db, `UPDATE
|
|
11375
|
+
currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,
|
|
10874
11376
|
barrier_pid=NULL,barrier_boot_id=NULL,barrier_process_start=NULL,barrier_deadline=NULL,
|
|
10875
11377
|
barrier_requested_at=NULL,barrier_lease_expires_at=NULL,barrier_status=NULL,barrier_active_at=NULL,
|
|
10876
11378
|
revision=revision+1 WHERE singleton=1 AND barrier_id=? AND barrier_nonce=?`).run(gateId, gateNonce);
|
|
10877
11379
|
connection.db.exec("COMMIT");
|
|
10878
11380
|
return false;
|
|
10879
11381
|
}
|
|
10880
|
-
currentStatement(connection.db, "DELETE FROM
|
|
11382
|
+
currentStatement(connection.db, "DELETE FROM ne19_coordination_tickets").run();
|
|
10881
11383
|
connection.db.exec("COMMIT");
|
|
10882
11384
|
while (true) {
|
|
10883
11385
|
const coordination = currentStatement(connection.db, `SELECT
|
|
10884
11386
|
(writer_ticket_id IS NOT NULL OR (barrier_id IS NOT NULL AND barrier_id!=?)) AS active
|
|
10885
|
-
FROM
|
|
11387
|
+
FROM ne19_coordination_state WHERE singleton=1`).get(gateId);
|
|
10886
11388
|
if (coordination === void 0) throw sqliteError("record-database-invalid", "portable-gate", "coordination singleton is missing");
|
|
10887
11389
|
if (decodeInteger(coordination.active, "portable_admission") === 0) break;
|
|
10888
11390
|
if (Date.now() >= admissionDrainDeadline) throw sqliteError("record-write-busy", "portable-gate", "admitted writer did not drain before the portable deadline");
|
|
10889
11391
|
Atomics.wait(waitCell, 0, 0, 15);
|
|
10890
11392
|
}
|
|
10891
11393
|
connection.db.exec("BEGIN IMMEDIATE");
|
|
10892
|
-
if (decodeInteger(currentStatement(connection.db, "SELECT count(*) AS count FROM
|
|
11394
|
+
if (decodeInteger(currentStatement(connection.db, "SELECT count(*) AS count FROM ne19_run_resources WHERE terminal_state IS NULL").get().count, "active_runs") !== 0) throw sqliteError("record-command-conflict", "portable-gate", "active Run owners prevent portable close");
|
|
10893
11395
|
if (decodeInteger(currentStatement(connection.db, `SELECT
|
|
10894
|
-
(SELECT count(*) FROM
|
|
10895
|
-
(SELECT count(*) FROM
|
|
10896
|
-
(SELECT count(*) FROM
|
|
10897
|
-
currentExec(connection.db, `DELETE FROM
|
|
10898
|
-
(SELECT 1 FROM
|
|
10899
|
-
currentStatement(connection.db, `UPDATE
|
|
11396
|
+
(SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+
|
|
11397
|
+
(SELECT count(*) FROM ne19_invocation_session_queued_attempts)+
|
|
11398
|
+
(SELECT count(*) FROM ne19_case_locks) AS count`).get().count, "invocation_work") !== 0) throw sqliteError("record-command-conflict", "portable-gate", "invocation coordination work prevents portable close");
|
|
11399
|
+
currentExec(connection.db, `DELETE FROM ne19_runs WHERE status!='sealed' AND NOT EXISTS
|
|
11400
|
+
(SELECT 1 FROM ne19_attempt_publications WHERE origin_run_id=ne19_runs.run_id); DELETE FROM ne19_coordination_tickets;`);
|
|
11401
|
+
currentStatement(connection.db, `UPDATE ne19_coordination_state SET revision=revision+1,next_writer_sequence=1,
|
|
10900
11402
|
writer_ticket_id=NULL,writer_sequence=NULL,writer_host=NULL,writer_pid=NULL,writer_deadline=NULL,
|
|
10901
11403
|
writer_boot_id=NULL,writer_process_start=NULL,
|
|
10902
11404
|
writer_enqueued_at=NULL,writer_nonce=NULL,writer_admitted_at=NULL,writer_lease_expires_at=NULL,
|
|
@@ -10904,9 +11406,9 @@ function makeProjectDatabasePortable(path) {
|
|
|
10904
11406
|
barrier_boot_id=NULL,barrier_process_start=NULL,
|
|
10905
11407
|
barrier_requested_at=NULL,barrier_lease_expires_at=NULL,barrier_status=NULL,barrier_active_at=NULL
|
|
10906
11408
|
WHERE singleton=1`).run();
|
|
10907
|
-
const clock = currentStatement(connection.db, "SELECT revision FROM
|
|
10908
|
-
const generation = currentStatement(connection.db, "SELECT storage_generation FROM
|
|
10909
|
-
currentStatement(connection.db, `UPDATE
|
|
11409
|
+
const clock = currentStatement(connection.db, "SELECT revision FROM ne19_run_publication_clock WHERE singleton=1").get();
|
|
11410
|
+
const generation = currentStatement(connection.db, "SELECT storage_generation FROM ne19_record_metadata WHERE singleton=1").get();
|
|
11411
|
+
currentStatement(connection.db, `UPDATE ne19_record_metadata SET barrier_state='portable',portable_generation=?,portable_revision=?
|
|
10910
11412
|
WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(decodeText(generation.storage_generation, "storage_generation"), decodeInteger(clock.revision, "publication_revision"), gateId);
|
|
10911
11413
|
connection.db.exec("COMMIT");
|
|
10912
11414
|
checkpointRecordDatabase(connection);
|
|
@@ -10919,23 +11421,23 @@ function makeProjectDatabasePortable(path) {
|
|
|
10919
11421
|
connection = openRecordReader(path);
|
|
10920
11422
|
try {
|
|
10921
11423
|
const state = currentStatement(connection.db, `SELECT barrier_state,portable_generation,portable_revision,storage_generation
|
|
10922
|
-
FROM
|
|
11424
|
+
FROM ne19_record_metadata WHERE singleton=1`).get();
|
|
10923
11425
|
const active = currentStatement(connection.db, `SELECT
|
|
10924
|
-
(SELECT count(*) FROM
|
|
10925
|
-
(SELECT count(*) FROM
|
|
10926
|
-
(EXISTS (SELECT 1 FROM
|
|
10927
|
-
EXISTS (SELECT 1 FROM
|
|
10928
|
-
(SELECT count(*) FROM
|
|
11426
|
+
(SELECT count(*) FROM ne19_run_resources WHERE terminal_state IS NULL)+
|
|
11427
|
+
(SELECT count(*) FROM ne19_runs r WHERE status!='sealed' AND
|
|
11428
|
+
(EXISTS (SELECT 1 FROM ne19_attempts a WHERE a.origin_run_id=r.run_id AND a.publication_state!='published') OR
|
|
11429
|
+
EXISTS (SELECT 1 FROM ne19_run_resources rr WHERE rr.run_id=r.run_id AND rr.terminal_state IS NULL)))+
|
|
11430
|
+
(SELECT count(*) FROM ne19_coordination_tickets) AS count`).get();
|
|
10929
11431
|
const invocationWork = currentStatement(connection.db, `SELECT
|
|
10930
|
-
(SELECT count(*) FROM
|
|
10931
|
-
(SELECT count(*) FROM
|
|
10932
|
-
(SELECT count(*) FROM
|
|
11432
|
+
(SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+
|
|
11433
|
+
(SELECT count(*) FROM ne19_invocation_session_queued_attempts)+
|
|
11434
|
+
(SELECT count(*) FROM ne19_case_locks) AS count`).get();
|
|
10933
11435
|
const registryWork = currentStatement(connection.db, `SELECT
|
|
10934
|
-
(SELECT count(*) FROM
|
|
10935
|
-
(SELECT count(*) FROM
|
|
10936
|
-
(SELECT count(*) FROM
|
|
10937
|
-
const coordination = currentStatement(connection.db, `SELECT writer_ticket_id,barrier_id FROM
|
|
10938
|
-
const clock = currentStatement(connection.db, "SELECT revision FROM
|
|
11436
|
+
(SELECT count(*) FROM ne19_teardown_obligations)+
|
|
11437
|
+
(SELECT count(*) FROM ne19_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne19_shared_state_generations WHERE state_key=s.state_key))+
|
|
11438
|
+
(SELECT count(*) FROM ne19_kept_sandbox_operation_leases) AS count`).get();
|
|
11439
|
+
const coordination = currentStatement(connection.db, `SELECT writer_ticket_id,barrier_id FROM ne19_coordination_state WHERE singleton=1`).get();
|
|
11440
|
+
const clock = currentStatement(connection.db, "SELECT revision FROM ne19_run_publication_clock WHERE singleton=1").get();
|
|
10939
11441
|
if (state === void 0 || decodeText(state.barrier_state, "barrier_state") !== "portable" || decodeText(state.portable_generation, "portable_generation") !== decodeText(state.storage_generation, "storage_generation") || clock === void 0 || decodeInteger(state.portable_revision, "portable_revision") !== decodeInteger(clock.revision, "publication_revision") || decodeInteger(active.count, "portable_work") !== 0 || decodeInteger(invocationWork.count, "portable_invocation_work") !== 0 || decodeInteger(registryWork.count, "portable_registry_work") !== 0 || coordination === void 0 || coordination.writer_ticket_id !== null || coordination.barrier_id !== null) throw sqliteError("record-database-invalid", "portable-gate", "hostile reopen did not prove a portable ProjectDatabase");
|
|
10940
11442
|
} finally {
|
|
10941
11443
|
closeRecordDatabase(connection);
|
|
@@ -11083,30 +11585,30 @@ function assertBoundedBatch(operation, rowCount, byteCount) {
|
|
|
11083
11585
|
function readSealedRunSummary(connection, runId) {
|
|
11084
11586
|
const row = recordStatement(connection, `SELECT r.run_id,r.writer_generation,r.started_at,
|
|
11085
11587
|
coalesce(r.logical_seal_identity,'published:' || (SELECT max(p.published_revision)
|
|
11086
|
-
FROM
|
|
11087
|
-
(SELECT count(*) FROM
|
|
11088
|
-
CASE WHEN EXISTS (SELECT 1 FROM
|
|
11089
|
-
(SELECT count(*) FROM
|
|
11090
|
-
(SELECT count(*) FROM
|
|
11091
|
-
ELSE (SELECT count(*) FROM
|
|
11092
|
-
(SELECT count(*) FROM
|
|
11093
|
-
(NOT EXISTS (SELECT 1 FROM
|
|
11094
|
-
(SELECT 1 FROM
|
|
11095
|
-
(SELECT count(*) FROM
|
|
11096
|
-
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM
|
|
11097
|
-
(SELECT 1 FROM
|
|
11098
|
-
(SELECT count(*) FROM
|
|
11588
|
+
FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id)) logical_seal_identity,
|
|
11589
|
+
(SELECT count(*) FROM ne19_slots WHERE run_id=r.run_id) slot_count,
|
|
11590
|
+
CASE WHEN EXISTS (SELECT 1 FROM ne19_run_resources WHERE run_id=r.run_id) THEN
|
|
11591
|
+
(SELECT count(*) FROM ne19_run_slot_bindings WHERE target_run_id=r.run_id)+
|
|
11592
|
+
(SELECT count(*) FROM ne19_run_slot_absences WHERE run_id=r.run_id)
|
|
11593
|
+
ELSE (SELECT count(*) FROM ne19_members WHERE target_run_id=r.run_id) END member_count,
|
|
11594
|
+
(SELECT count(*) FROM ne19_attempts a WHERE a.origin_run_id=r.run_id AND
|
|
11595
|
+
(NOT EXISTS (SELECT 1 FROM ne19_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
11596
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=a.origin_run_id AND p.attempt_id=a.attempt_id))) attempt_count,
|
|
11597
|
+
(SELECT count(*) FROM ne19_attachments a WHERE a.owner_run_id=r.run_id AND a.canonical_payload IS NOT NULL AND
|
|
11598
|
+
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM ne19_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
11599
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))) attachment_count,
|
|
11600
|
+
(SELECT count(*) FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id
|
|
11099
11601
|
WHERE a.owner_run_id=r.run_id AND a.canonical_payload IS NOT NULL AND
|
|
11100
|
-
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM
|
|
11101
|
-
(SELECT 1 FROM
|
|
11102
|
-
(SELECT coalesce(sum(c.byte_length),0) FROM
|
|
11602
|
+
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM ne19_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
11603
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))) content_count,
|
|
11604
|
+
(SELECT coalesce(sum(c.byte_length),0) FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id
|
|
11103
11605
|
WHERE a.owner_run_id=r.run_id AND a.canonical_payload IS NOT NULL AND
|
|
11104
|
-
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM
|
|
11105
|
-
(SELECT 1 FROM
|
|
11106
|
-
(SELECT count(*) FROM
|
|
11107
|
-
FROM
|
|
11108
|
-
(SELECT 1 FROM
|
|
11109
|
-
AND (r.status='sealed' OR EXISTS (SELECT 1 FROM
|
|
11606
|
+
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM ne19_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
11607
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))) content_bytes,
|
|
11608
|
+
(SELECT count(*) FROM ne19_run_seal_entries WHERE run_id=r.run_id) seal_count
|
|
11609
|
+
FROM ne19_runs r WHERE r.run_id=? AND NOT EXISTS
|
|
11610
|
+
(SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
11611
|
+
AND (r.status='sealed' OR EXISTS (SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id))`).get(runId);
|
|
11110
11612
|
if (row === void 0) return void 0;
|
|
11111
11613
|
return Object.freeze({
|
|
11112
11614
|
runId: text$2(row, "run_id"),
|
|
@@ -11124,22 +11626,64 @@ function readSealedRunSummary(connection, runId) {
|
|
|
11124
11626
|
}
|
|
11125
11627
|
/** Pinned publication identity, plus a metadata-only count; no Seal hashing. */
|
|
11126
11628
|
function readSealedRunCutoff(connection, identity) {
|
|
11127
|
-
const row = recordStatement(connection, `SELECT count(*) count FROM
|
|
11128
|
-
WHERE NOT EXISTS (SELECT 1 FROM
|
|
11129
|
-
AND (status='sealed' OR EXISTS (SELECT 1 FROM
|
|
11629
|
+
const row = recordStatement(connection, `SELECT count(*) count FROM ne19_runs r
|
|
11630
|
+
WHERE NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
11631
|
+
AND (status='sealed' OR EXISTS (SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id))`).get();
|
|
11130
11632
|
return Object.freeze({
|
|
11131
11633
|
identity,
|
|
11132
11634
|
runCount: integer$1(row, "count")
|
|
11133
11635
|
});
|
|
11134
11636
|
}
|
|
11135
11637
|
/** Filter lightweight Run metadata before loading any selected Core or payload. */
|
|
11638
|
+
function findSourceBarrierCandidate(connection, request, cutoffRevision) {
|
|
11639
|
+
requireIdentity$1(request.experimentId, "experimentId");
|
|
11640
|
+
requireIdentity$1(request.evalId, "evalId");
|
|
11641
|
+
if (!Number.isSafeInteger(request.attemptOrdinal) || request.attemptOrdinal < 0) throw sqliteError("record-content-invalid", "find-source-barrier", "Attempt ordinal must be non-negative");
|
|
11642
|
+
const current = rows(connection, `SELECT r.run_id,r.created_revision
|
|
11643
|
+
FROM ne19_run_resources r
|
|
11644
|
+
WHERE r.experiment_id=? AND r.created_revision<=? AND r.run_id<>?
|
|
11645
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
11646
|
+
AND EXISTS (SELECT 1 FROM ne19_run_expected_slots s
|
|
11647
|
+
WHERE s.eval_id=? AND s.attempt_ordinal=? AND s.run_id=r.run_id)
|
|
11648
|
+
ORDER BY r.created_revision DESC,r.run_id COLLATE BINARY DESC LIMIT 1`, request.experimentId, cutoffRevision, request.excludeRunId ?? "", request.evalId, request.attemptOrdinal)[0];
|
|
11649
|
+
if (current !== void 0) return Object.freeze({
|
|
11650
|
+
runId: text$2(current, "run_id"),
|
|
11651
|
+
createdRevision: integer$1(current, "created_revision")
|
|
11652
|
+
});
|
|
11653
|
+
const legacy = rows(connection, `SELECT r.run_id FROM ne19_runs r
|
|
11654
|
+
WHERE r.experiment_id=? AND r.status='sealed' AND r.run_id<>?
|
|
11655
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_resources rr WHERE rr.run_id=r.run_id)
|
|
11656
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
11657
|
+
AND EXISTS (SELECT 1 FROM ne19_slots s WHERE s.run_id=r.run_id AND
|
|
11658
|
+
CASE WHEN json_valid(CAST(s.core_payload AS TEXT)) THEN
|
|
11659
|
+
CASE WHEN json_type(CAST(s.core_payload AS TEXT),'$.evalId') IS NOT 'text' OR
|
|
11660
|
+
json_type(CAST(s.core_payload AS TEXT),'$.attemptOrdinal') IS NOT 'integer' THEN 1
|
|
11661
|
+
ELSE (json_extract(CAST(s.core_payload AS TEXT),'$.evalId')=? AND
|
|
11662
|
+
json_extract(CAST(s.core_payload AS TEXT),'$.attemptOrdinal')=?) END
|
|
11663
|
+
ELSE 1 END)
|
|
11664
|
+
ORDER BY r.run_id COLLATE BINARY DESC LIMIT 1`, request.experimentId, request.excludeRunId ?? "", request.evalId, request.attemptOrdinal)[0];
|
|
11665
|
+
return legacy === void 0 ? void 0 : Object.freeze({
|
|
11666
|
+
runId: text$2(legacy, "run_id"),
|
|
11667
|
+
createdRevision: 0
|
|
11668
|
+
});
|
|
11669
|
+
}
|
|
11670
|
+
/** Locate adoption proofs for one exact Attempt without scanning Run Core. */
|
|
11671
|
+
function findAcceptedAttemptRunIds(connection, request, cutoffRevision) {
|
|
11672
|
+
const selected = rows(connection, `SELECT b.target_run_id FROM ne19_run_slot_bindings b
|
|
11673
|
+
JOIN ne19_run_resources r ON r.run_id=b.target_run_id
|
|
11674
|
+
WHERE b.attempt_id=? AND b.origin_run_id=? AND b.action='accepted'
|
|
11675
|
+
AND r.experiment_id=? AND b.binding_revision<=? AND b.binding_revision<=?
|
|
11676
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=b.target_run_id)
|
|
11677
|
+
ORDER BY b.target_run_id LIMIT ?`, request.attemptId, request.originRunId, request.experimentId, request.bindingRevision, cutoffRevision, RECORD_SQLITE_MAX_VALIDATION_RUNS + 1);
|
|
11678
|
+
if (selected.length > 1e5) throw sqliteError("record-resource-limit-exceeded", "find-accepted-attempt-runs", "Attempt exceeds its adoption proof ceiling");
|
|
11679
|
+
return Object.freeze(selected.map((row) => text$2(row, "target_run_id")));
|
|
11680
|
+
}
|
|
11136
11681
|
function findExperimentRunIds(connection, experimentId) {
|
|
11137
11682
|
requireIdentity$1(experimentId, "experimentId");
|
|
11138
|
-
const selected = rows(connection, `SELECT r.run_id FROM
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
AND
|
|
11142
|
-
AND (r.status='sealed' OR EXISTS (SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=r.run_id))
|
|
11683
|
+
const selected = rows(connection, `SELECT r.run_id FROM ne19_runs r
|
|
11684
|
+
WHERE r.experiment_id=?
|
|
11685
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
11686
|
+
AND (r.status='sealed' OR EXISTS (SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id))
|
|
11143
11687
|
ORDER BY r.run_id LIMIT ?`, experimentId, RECORD_SQLITE_MAX_VALIDATION_RUNS + 1);
|
|
11144
11688
|
if (selected.length > 1e5) throw sqliteError("record-resource-limit-exceeded", "find-experiment-runs", "Experiment exceeds its Run ceiling");
|
|
11145
11689
|
return Object.freeze(selected.map((row) => text$2(row, "run_id")));
|
|
@@ -11156,11 +11700,11 @@ function readSealedRunSummaryPage(connection, afterRunId = "", pageSize = 100, e
|
|
|
11156
11700
|
cutoffHash.update("[");
|
|
11157
11701
|
let runCount = 0;
|
|
11158
11702
|
const inventory = recordStatement(connection, `SELECT run_id,
|
|
11159
|
-
coalesce(logical_seal_identity,'published:' || (SELECT max(p.published_revision) FROM
|
|
11160
|
-
WHERE p.origin_run_id=
|
|
11161
|
-
FROM
|
|
11703
|
+
coalesce(logical_seal_identity,'published:' || (SELECT max(p.published_revision) FROM ne19_attempt_publications p
|
|
11704
|
+
WHERE p.origin_run_id=ne19_runs.run_id)) logical_seal_identity
|
|
11705
|
+
FROM ne19_runs WHERE NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=ne19_runs.run_id)
|
|
11162
11706
|
AND (status='sealed' OR EXISTS
|
|
11163
|
-
(SELECT 1 FROM
|
|
11707
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=ne19_runs.run_id))
|
|
11164
11708
|
ORDER BY run_id`).iterate();
|
|
11165
11709
|
for (const row of inventory) {
|
|
11166
11710
|
if (runCount >= 1e5) throw sqliteError("record-resource-limit-exceeded", "page-sealed-runs", "sealed cutoff exceeds its Run ceiling");
|
|
@@ -11180,10 +11724,10 @@ function readSealedRunSummaryPage(connection, afterRunId = "", pageSize = 100, e
|
|
|
11180
11724
|
});
|
|
11181
11725
|
})();
|
|
11182
11726
|
if (expectedCutoffIdentity !== void 0 && expectedCutoffIdentity !== identity) throw sqliteError("record-command-conflict", "page-sealed-runs", "sealed cutoff changed; restart pagination");
|
|
11183
|
-
const pageRows = rows(connection, `SELECT run_id FROM
|
|
11184
|
-
AND NOT EXISTS (SELECT 1 FROM
|
|
11727
|
+
const pageRows = rows(connection, `SELECT run_id FROM ne19_runs WHERE run_id>?
|
|
11728
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=ne19_runs.run_id)
|
|
11185
11729
|
AND (status='sealed' OR EXISTS
|
|
11186
|
-
(SELECT 1 FROM
|
|
11730
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=ne19_runs.run_id)) ORDER BY run_id LIMIT ?`, afterRunId, pageSize + 1);
|
|
11187
11731
|
const summaries = pageRows.slice(0, pageSize).map((row) => {
|
|
11188
11732
|
const summary = readSealedRunSummary(connection, text$2(row, "run_id"));
|
|
11189
11733
|
if (summary === void 0) throw sqliteError("record-database-invalid", "page-sealed-runs", "sealed Run disappeared inside pinned read generation");
|
|
@@ -11201,11 +11745,11 @@ function readSealedRunSummaryPage(connection, afterRunId = "", pageSize = 100, e
|
|
|
11201
11745
|
});
|
|
11202
11746
|
}
|
|
11203
11747
|
/** Indexed, bounded locator projection. No Core or attachment payload is selected. */
|
|
11204
|
-
function findAttemptLocatorCandidates(connection, locator, maximumCandidateRuns) {
|
|
11748
|
+
function findAttemptLocatorCandidates(connection, locator, maximumCandidateRuns, includeTargets = true) {
|
|
11205
11749
|
if (!parseAttemptLocator(locator).valid) throw sqliteError("record-content-invalid", "find-attempt-locator", "Attempt locator is malformed");
|
|
11206
11750
|
if (!Number.isSafeInteger(maximumCandidateRuns) || maximumCandidateRuns < 1 || maximumCandidateRuns > 256) throw sqliteError("record-resource-limit-exceeded", "find-attempt-locator", "candidate Run limit must be between 1 and 256");
|
|
11207
|
-
const matching = rows(connection, `SELECT a.origin_run_id,a.attempt_id FROM
|
|
11208
|
-
JOIN
|
|
11751
|
+
const matching = rows(connection, `SELECT a.origin_run_id,a.attempt_id FROM ne19_attempts a
|
|
11752
|
+
JOIN ne19_runs origin ON origin.run_id=a.origin_run_id
|
|
11209
11753
|
WHERE a.attempt_locator=? ORDER BY a.origin_run_id,a.attempt_id LIMIT ?`, locator, maximumCandidateRuns + 1);
|
|
11210
11754
|
const identities = /* @__PURE__ */ new Set();
|
|
11211
11755
|
const candidates = [];
|
|
@@ -11216,9 +11760,9 @@ function findAttemptLocatorCandidates(connection, locator, maximumCandidateRuns)
|
|
|
11216
11760
|
for (const row of matching) {
|
|
11217
11761
|
const originRunId = text$2(row, "origin_run_id");
|
|
11218
11762
|
const attemptId = text$2(row, "attempt_id");
|
|
11219
|
-
if (recordStatement(connection, `SELECT 1 FROM
|
|
11220
|
-
((r.status='sealed' AND NOT EXISTS (SELECT 1 FROM
|
|
11221
|
-
EXISTS (SELECT 1 FROM
|
|
11763
|
+
if (recordStatement(connection, `SELECT 1 FROM ne19_runs r WHERE r.run_id=? AND
|
|
11764
|
+
((r.status='sealed' AND NOT EXISTS (SELECT 1 FROM ne19_run_resources rr WHERE rr.run_id=r.run_id)) OR
|
|
11765
|
+
EXISTS (SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id AND p.attempt_id=?))`).get(originRunId, attemptId) === void 0) continue;
|
|
11222
11766
|
identities.add(hashCanonicalTuple("niceeval.record.attempt-candidate/v1", [originRunId, attemptId]));
|
|
11223
11767
|
add({
|
|
11224
11768
|
locator,
|
|
@@ -11227,8 +11771,9 @@ function findAttemptLocatorCandidates(connection, locator, maximumCandidateRuns)
|
|
|
11227
11771
|
relation: "origin",
|
|
11228
11772
|
runId: originRunId
|
|
11229
11773
|
});
|
|
11230
|
-
|
|
11231
|
-
|
|
11774
|
+
if (!includeTargets) continue;
|
|
11775
|
+
const targets = rows(connection, `SELECT DISTINCT m.target_run_id FROM ne19_members m
|
|
11776
|
+
JOIN ne19_runs target ON target.run_id=m.target_run_id AND target.status='sealed'
|
|
11232
11777
|
WHERE m.origin_run_id=? AND m.attempt_id=? ORDER BY m.target_run_id LIMIT ?`, originRunId, attemptId, maximumCandidateRuns - candidates.length + 1);
|
|
11233
11778
|
for (const target of targets) add({
|
|
11234
11779
|
locator,
|
|
@@ -11252,12 +11797,12 @@ function readCollectionItemPage(connection, attachmentId, afterOrdinal, pageSize
|
|
|
11252
11797
|
let pageBytes = 0;
|
|
11253
11798
|
let hasMore = false;
|
|
11254
11799
|
const pageRows = recordStatement(connection, `SELECT i.ordinal,i.logical_identity,i.canonical_payload,i.canonical_digest,
|
|
11255
|
-
EXISTS(SELECT 1 FROM
|
|
11256
|
-
FROM
|
|
11257
|
-
JOIN
|
|
11800
|
+
EXISTS(SELECT 1 FROM ne19_collection_items more WHERE more.attachment_id=i.attachment_id AND more.ordinal>i.ordinal) AS has_more
|
|
11801
|
+
FROM ne19_collection_items i
|
|
11802
|
+
JOIN ne19_attachments a ON a.attachment_id=i.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id
|
|
11258
11803
|
WHERE i.attachment_id=? AND i.ordinal>? AND
|
|
11259
|
-
((r.status='sealed' AND (NOT EXISTS (SELECT 1 FROM
|
|
11260
|
-
(a.owner_kind='attempt' AND EXISTS (SELECT 1 FROM
|
|
11804
|
+
((r.status='sealed' AND (NOT EXISTS (SELECT 1 FROM ne19_run_resources rr WHERE rr.run_id=r.run_id) OR a.owner_kind='run')) OR
|
|
11805
|
+
(a.owner_kind='attempt' AND EXISTS (SELECT 1 FROM ne19_attempt_publications p
|
|
11261
11806
|
WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id)))
|
|
11262
11807
|
ORDER BY i.ordinal LIMIT ?`).iterate(attachmentId, afterOrdinal, pageSize);
|
|
11263
11808
|
for (const row of pageRows) {
|
|
@@ -11307,14 +11852,14 @@ function memoRecordRead(read, defer) {
|
|
|
11307
11852
|
}
|
|
11308
11853
|
function readPublishedSealedRun(connection, runId, defer) {
|
|
11309
11854
|
const run = recordStatement(connection, `SELECT run_id,writer_generation,started_at,status,
|
|
11310
|
-
coalesce(logical_seal_identity,'published:' || (SELECT max(p.published_revision) FROM
|
|
11311
|
-
WHERE p.origin_run_id=
|
|
11312
|
-
(SELECT p.closure_payload FROM
|
|
11855
|
+
coalesce(logical_seal_identity,'published:' || (SELECT max(p.published_revision) FROM ne19_attempt_publications p
|
|
11856
|
+
WHERE p.origin_run_id=ne19_runs.run_id)) logical_seal_identity,core_payload,core_digest,
|
|
11857
|
+
(SELECT p.closure_payload FROM ne19_attempt_publications p WHERE p.origin_run_id=ne19_runs.run_id
|
|
11313
11858
|
ORDER BY p.published_revision DESC LIMIT 1) publication_closure
|
|
11314
|
-
FROM
|
|
11315
|
-
AND NOT EXISTS (SELECT 1 FROM
|
|
11859
|
+
FROM ne19_runs WHERE run_id=?
|
|
11860
|
+
AND NOT EXISTS (SELECT 1 FROM ne19_run_deletion_tombstones d WHERE d.run_id=ne19_runs.run_id)
|
|
11316
11861
|
AND (status='sealed' OR EXISTS
|
|
11317
|
-
(SELECT 1 FROM
|
|
11862
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=ne19_runs.run_id))`).get(runId);
|
|
11318
11863
|
if (run === void 0) return void 0;
|
|
11319
11864
|
let runCoreBytes;
|
|
11320
11865
|
let runCoreDigest;
|
|
@@ -11334,32 +11879,32 @@ function readPublishedSealedRun(connection, runId, defer) {
|
|
|
11334
11879
|
runCoreDigest = digestBytes(runCoreBytes);
|
|
11335
11880
|
}
|
|
11336
11881
|
const admission = recordStatement(connection, `SELECT
|
|
11337
|
-
1+(SELECT count(*) FROM
|
|
11338
|
-
(SELECT count(*) FROM
|
|
11339
|
-
(SELECT count(*) FROM
|
|
11340
|
-
(SELECT count(*) FROM
|
|
11341
|
-
coalesce(length(r.core_payload),(SELECT max(length(p.closure_payload)) FROM
|
|
11342
|
-
(SELECT coalesce(sum(length(core_payload)),0) FROM
|
|
11343
|
-
(SELECT coalesce(sum(length(core_payload)),0) FROM
|
|
11344
|
-
(SELECT coalesce(sum(length(core_payload)),0) FROM
|
|
11345
|
-
(SELECT coalesce(sum(length(canonical_payload)+length(logical_inventory)),0) FROM
|
|
11346
|
-
(SELECT coalesce(sum(length(rr.canonical_payload)),0) FROM
|
|
11347
|
-
FROM
|
|
11348
|
-
(SELECT 1 FROM
|
|
11882
|
+
1+(SELECT count(*) FROM ne19_slots WHERE run_id=?)+(SELECT count(*) FROM ne19_attempts WHERE origin_run_id=?)+
|
|
11883
|
+
(SELECT count(*) FROM ne19_members WHERE target_run_id=?)+(SELECT count(*) FROM ne19_attachments WHERE owner_run_id=?)+
|
|
11884
|
+
(SELECT count(*) FROM ne19_attachment_references rr JOIN ne19_attachments aa ON aa.attachment_id=rr.attachment_id WHERE aa.owner_run_id=?)+
|
|
11885
|
+
(SELECT count(*) FROM ne19_contents cc JOIN ne19_attachments aa ON aa.attachment_id=cc.attachment_id WHERE aa.owner_run_id=?) row_count,
|
|
11886
|
+
coalesce(length(r.core_payload),(SELECT max(length(p.closure_payload)) FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id),0)+
|
|
11887
|
+
(SELECT coalesce(sum(length(core_payload)),0) FROM ne19_slots WHERE run_id=?)+
|
|
11888
|
+
(SELECT coalesce(sum(length(core_payload)),0) FROM ne19_attempts WHERE origin_run_id=?)+
|
|
11889
|
+
(SELECT coalesce(sum(length(core_payload)),0) FROM ne19_members WHERE target_run_id=?)+
|
|
11890
|
+
(SELECT coalesce(sum(length(canonical_payload)+length(logical_inventory)),0) FROM ne19_attachments WHERE owner_run_id=?)+
|
|
11891
|
+
(SELECT coalesce(sum(length(rr.canonical_payload)),0) FROM ne19_attachment_references rr JOIN ne19_attachments aa ON aa.attachment_id=rr.attachment_id WHERE aa.owner_run_id=?) byte_count
|
|
11892
|
+
FROM ne19_runs r WHERE r.run_id=? AND (r.status='sealed' OR EXISTS
|
|
11893
|
+
(SELECT 1 FROM ne19_attempt_publications p WHERE p.origin_run_id=r.run_id))`).get(runId, runId, runId, runId, runId, runId, runId, runId, runId, runId, runId, runId);
|
|
11349
11894
|
assertBoundedBatch("read-sealed-run-core", integer$1(admission, "row_count"), integer$1(admission, "byte_count"));
|
|
11350
|
-
const record = recordStatement(connection, "SELECT record_payload,record_digest FROM
|
|
11351
|
-
const slots = rows(connection, "SELECT slot_id,ordinal,core_payload,core_digest FROM
|
|
11895
|
+
const record = recordStatement(connection, "SELECT record_payload,record_digest FROM ne19_record_metadata WHERE singleton=1").get();
|
|
11896
|
+
const slots = rows(connection, "SELECT slot_id,ordinal,core_payload,core_digest FROM ne19_slots WHERE run_id=? ORDER BY ordinal", runId).map((row) => Object.freeze({
|
|
11352
11897
|
slotId: text$2(row, "slot_id"),
|
|
11353
11898
|
ordinal: integer$1(row, "ordinal"),
|
|
11354
11899
|
coreBytes: transferableBytes(bytes(row, "core_payload")),
|
|
11355
11900
|
coreDigest: text$2(row, "core_digest")
|
|
11356
11901
|
}));
|
|
11357
|
-
const publicationResource = recordStatement(connection, "SELECT created_revision FROM
|
|
11902
|
+
const publicationResource = recordStatement(connection, "SELECT created_revision FROM ne19_run_resources WHERE run_id=?").get(runId);
|
|
11358
11903
|
const publicationManaged = publicationResource !== void 0;
|
|
11359
|
-
const attempts = rows(connection, publicationManaged ? `SELECT a.attempt_id,a.attempt_locator,a.core_payload,a.core_digest,p.published_revision FROM
|
|
11360
|
-
JOIN
|
|
11361
|
-
WHERE a.origin_run_id=? AND EXISTS (SELECT 1 FROM
|
|
11362
|
-
WHERE p.origin_run_id=a.origin_run_id AND p.attempt_id=a.attempt_id) ORDER BY a.attempt_id` : "SELECT attempt_id,attempt_locator,core_payload,core_digest FROM
|
|
11904
|
+
const attempts = rows(connection, publicationManaged ? `SELECT a.attempt_id,a.attempt_locator,a.core_payload,a.core_digest,p.published_revision FROM ne19_attempts a
|
|
11905
|
+
JOIN ne19_attempt_publications p ON p.origin_run_id=a.origin_run_id AND p.attempt_id=a.attempt_id
|
|
11906
|
+
WHERE a.origin_run_id=? AND EXISTS (SELECT 1 FROM ne19_attempt_publications p
|
|
11907
|
+
WHERE p.origin_run_id=a.origin_run_id AND p.attempt_id=a.attempt_id) ORDER BY a.attempt_id` : "SELECT attempt_id,attempt_locator,core_payload,core_digest FROM ne19_attempts WHERE origin_run_id=? ORDER BY attempt_id", runId).map((row) => {
|
|
11363
11908
|
if (!(row.core_payload instanceof Uint8Array)) throw sqliteError("record-database-invalid", "read-published-run-core", `Attempt ${text$2(row, "attempt_id")} Core is not published`);
|
|
11364
11909
|
const attemptId = text$2(row, "attempt_id");
|
|
11365
11910
|
return Object.freeze({
|
|
@@ -11377,16 +11922,17 @@ function readPublishedSealedRun(connection, runId, defer) {
|
|
|
11377
11922
|
const members = (publicationManaged ? [...rows(connection, `SELECT 'binding' publication_kind,b.slot_id,b.origin_run_id,b.attempt_id,b.action,b.attempt_publication_revision,b.binding_revision,
|
|
11378
11923
|
m.origin_run_id member_origin_run_id,m.attempt_id member_attempt_id,m.action member_action,
|
|
11379
11924
|
m.core_payload,m.core_digest,p.published_revision
|
|
11380
|
-
FROM
|
|
11381
|
-
LEFT JOIN
|
|
11382
|
-
LEFT JOIN
|
|
11925
|
+
FROM ne19_run_slot_bindings b
|
|
11926
|
+
LEFT JOIN ne19_members m ON m.target_run_id=b.target_run_id AND m.slot_id=b.slot_id
|
|
11927
|
+
LEFT JOIN ne19_attempt_publications p ON p.attempt_id=b.attempt_id AND p.origin_run_id=b.origin_run_id
|
|
11383
11928
|
AND p.published_revision=b.attempt_publication_revision
|
|
11384
11929
|
WHERE b.target_run_id=?`, runId), ...rows(connection, `SELECT 'absence' publication_kind,a.slot_id,NULL origin_run_id,NULL attempt_id,
|
|
11385
11930
|
NULL action,NULL attempt_publication_revision,NULL member_origin_run_id,NULL member_attempt_id,
|
|
11386
11931
|
NULL member_action,NULL core_payload,NULL core_digest,NULL published_revision,a.reason absence_reason
|
|
11387
|
-
FROM
|
|
11388
|
-
WHERE a.run_id=?`, runId)].sort((left, right) => text$2(left, "slot_id").localeCompare(text$2(right, "slot_id"))) : rows(connection, "SELECT slot_id,origin_run_id,attempt_id,action,core_payload,core_digest FROM
|
|
11932
|
+
FROM ne19_run_slot_absences a
|
|
11933
|
+
WHERE a.run_id=?`, runId)].sort((left, right) => text$2(left, "slot_id").localeCompare(text$2(right, "slot_id"))) : rows(connection, "SELECT slot_id,origin_run_id,attempt_id,action,core_payload,core_digest FROM ne19_members WHERE target_run_id=? ORDER BY slot_id", runId)).map((row) => {
|
|
11389
11934
|
const attemptId = optionalText$1(row, "attempt_id");
|
|
11935
|
+
let referenceCore;
|
|
11390
11936
|
if (publicationManaged) {
|
|
11391
11937
|
const kind = text$2(row, "publication_kind");
|
|
11392
11938
|
if (kind === "absence") {
|
|
@@ -11399,7 +11945,26 @@ function readPublishedSealedRun(connection, runId, defer) {
|
|
|
11399
11945
|
coreDigest: projected.coreDigest
|
|
11400
11946
|
});
|
|
11401
11947
|
}
|
|
11402
|
-
|
|
11948
|
+
const projectReference = (row.action === "carried" || row.action === "accepted") && row.core_payload == null;
|
|
11949
|
+
if (kind === "binding" && (attemptId === void 0 || optionalInteger(row, "published_revision") !== optionalInteger(row, "attempt_publication_revision") || !projectReference && (optionalText$1(row, "member_origin_run_id") !== optionalText$1(row, "origin_run_id") || optionalText$1(row, "member_attempt_id") !== attemptId || optionalText$1(row, "member_action") !== optionalText$1(row, "action")))) throw sqliteError("record-database-invalid", "read-published-run", `Published Slot ${text$2(row, "slot_id")} does not close over one matching Member`);
|
|
11950
|
+
if (projectReference) {
|
|
11951
|
+
const decoded = decodeMemberDocument({
|
|
11952
|
+
slotId: text$2(row, "slot_id"),
|
|
11953
|
+
action: text$2(row, "action"),
|
|
11954
|
+
attempt: {
|
|
11955
|
+
originRunId: text$2(row, "origin_run_id"),
|
|
11956
|
+
attemptId
|
|
11957
|
+
}
|
|
11958
|
+
});
|
|
11959
|
+
if (Result.isFailure(decoded)) throw sqliteError("record-database-invalid", "read-published-run", "Reference binding cannot project a Member");
|
|
11960
|
+
const encoded = encodeMemberDocument(decoded.success);
|
|
11961
|
+
if (Result.isFailure(encoded)) throw sqliteError("record-database-invalid", "read-published-run", "Reference Member cannot be encoded");
|
|
11962
|
+
const projectedBytes = encodeRecordJsonUtf8(encoded.success);
|
|
11963
|
+
referenceCore = {
|
|
11964
|
+
bytes: projectedBytes,
|
|
11965
|
+
digest: digestBytes(projectedBytes)
|
|
11966
|
+
};
|
|
11967
|
+
}
|
|
11403
11968
|
}
|
|
11404
11969
|
return Object.freeze({
|
|
11405
11970
|
slotId: text$2(row, "slot_id"),
|
|
@@ -11412,25 +11977,25 @@ function readPublishedSealedRun(connection, runId, defer) {
|
|
|
11412
11977
|
attemptId,
|
|
11413
11978
|
revision: integer$1(row, "published_revision")
|
|
11414
11979
|
}) } : {},
|
|
11415
|
-
coreBytes: transferableBytes(bytes(row, "core_payload")),
|
|
11416
|
-
coreDigest: text$2(row, "core_digest")
|
|
11980
|
+
coreBytes: transferableBytes(referenceCore?.bytes ?? bytes(row, "core_payload")),
|
|
11981
|
+
coreDigest: referenceCore?.digest ?? text$2(row, "core_digest")
|
|
11417
11982
|
});
|
|
11418
11983
|
});
|
|
11419
11984
|
const attachments = rows(connection, `SELECT attachment_id,owner_kind,owner_run_id,owner_attempt_id,family,family_revision,
|
|
11420
11985
|
logical_identity,canonical_digest,inventory_digest
|
|
11421
|
-
FROM
|
|
11422
|
-
(owner_kind='run' OR EXISTS (SELECT 1 FROM
|
|
11986
|
+
FROM ne19_attachments a WHERE owner_run_id=?${publicationManaged ? ` AND canonical_payload IS NOT NULL AND
|
|
11987
|
+
(owner_kind='run' OR EXISTS (SELECT 1 FROM ne19_attempt_publications p
|
|
11423
11988
|
WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))` : ""} ORDER BY attachment_id`, runId).map((row) => {
|
|
11424
11989
|
const attachmentId = text$2(row, "attachment_id");
|
|
11425
11990
|
const payload = memoRecordRead(() => {
|
|
11426
|
-
const stored = recordStatement(connection, `SELECT canonical_payload,logical_inventory FROM
|
|
11991
|
+
const stored = recordStatement(connection, `SELECT canonical_payload,logical_inventory FROM ne19_attachments WHERE attachment_id=?`).get(attachmentId);
|
|
11427
11992
|
return {
|
|
11428
11993
|
canonicalBytes: transferableBytes(bytes(stored, "canonical_payload")),
|
|
11429
11994
|
logicalInventoryBytes: transferableBytes(bytes(stored, "logical_inventory"))
|
|
11430
11995
|
};
|
|
11431
11996
|
}, defer);
|
|
11432
11997
|
const references = memoRecordRead(() => Object.freeze(rows(connection, `SELECT ordinal,target_owner_kind,target_family,canonical_payload,reference_digest
|
|
11433
|
-
FROM
|
|
11998
|
+
FROM ne19_attachment_references WHERE attachment_id=? ORDER BY ordinal`, attachmentId).map((reference) => Object.freeze({
|
|
11434
11999
|
ordinal: integer$1(reference, "ordinal"),
|
|
11435
12000
|
owner: ownerKind(reference, "target_owner_kind"),
|
|
11436
12001
|
family: text$2(reference, "target_family"),
|
|
@@ -11438,7 +12003,7 @@ function readPublishedSealedRun(connection, runId, defer) {
|
|
|
11438
12003
|
referenceDigest: text$2(reference, "reference_digest")
|
|
11439
12004
|
}))), defer);
|
|
11440
12005
|
const contents = memoRecordRead(() => Object.freeze(rows(connection, `SELECT content_id,logical_handle,byte_length,overall_digest,chunk_count
|
|
11441
|
-
FROM
|
|
12006
|
+
FROM ne19_contents WHERE attachment_id=? ORDER BY content_id`, attachmentId).map((content) => Object.freeze({
|
|
11442
12007
|
contentId: text$2(content, "content_id"),
|
|
11443
12008
|
logicalHandle: text$2(content, "logical_handle"),
|
|
11444
12009
|
byteLength: integer$1(content, "byte_length"),
|
|
@@ -11447,7 +12012,7 @@ function readPublishedSealedRun(connection, runId, defer) {
|
|
|
11447
12012
|
}))), defer);
|
|
11448
12013
|
const collection = memoRecordRead(() => {
|
|
11449
12014
|
const aggregate = recordStatement(connection, `SELECT count(*) item_count,coalesce(sum(length(canonical_payload)),0) item_bytes
|
|
11450
|
-
FROM
|
|
12015
|
+
FROM ne19_collection_items WHERE attachment_id=?`).get(attachmentId);
|
|
11451
12016
|
return {
|
|
11452
12017
|
count: integer$1(aggregate, "item_count"),
|
|
11453
12018
|
byteLength: integer$1(aggregate, "item_bytes")
|
|
@@ -11515,25 +12080,25 @@ function readSealedRunCore(connection, runId, defer) {
|
|
|
11515
12080
|
/** Fixed, decoded projection sufficient to rebuild sealed Core and attachment metadata. */
|
|
11516
12081
|
function readSealedRunDocument(connection, runId) {
|
|
11517
12082
|
const run = recordStatement(connection, `SELECT run_id,writer_generation,started_at,logical_seal_identity,core_payload,core_digest
|
|
11518
|
-
FROM
|
|
12083
|
+
FROM ne19_runs WHERE run_id=? AND status='sealed'`).get(runId);
|
|
11519
12084
|
if (run === void 0) return void 0;
|
|
11520
12085
|
const whole = recordStatement(connection, `SELECT count(*) row_count,coalesce(sum(length(i.canonical_payload)),0) byte_count
|
|
11521
|
-
FROM
|
|
12086
|
+
FROM ne19_collection_items i JOIN ne19_attachments a ON a.attachment_id=i.attachment_id WHERE a.owner_run_id=?`).get(runId);
|
|
11522
12087
|
assertBoundedBatch("read-sealed-run-document", integer$1(whole, "row_count"), integer$1(whole, "byte_count"));
|
|
11523
|
-
const record = recordStatement(connection, "SELECT record_payload,record_digest FROM
|
|
11524
|
-
const slots = rows(connection, "SELECT slot_id,ordinal,core_payload,core_digest FROM
|
|
12088
|
+
const record = recordStatement(connection, "SELECT record_payload,record_digest FROM ne19_record_metadata WHERE singleton=1").get();
|
|
12089
|
+
const slots = rows(connection, "SELECT slot_id,ordinal,core_payload,core_digest FROM ne19_slots WHERE run_id=? ORDER BY ordinal", runId).map((row) => Object.freeze({
|
|
11525
12090
|
slotId: text$2(row, "slot_id"),
|
|
11526
12091
|
ordinal: integer$1(row, "ordinal"),
|
|
11527
12092
|
coreBytes: transferableBytes(bytes(row, "core_payload")),
|
|
11528
12093
|
coreDigest: text$2(row, "core_digest")
|
|
11529
12094
|
}));
|
|
11530
|
-
const attempts = rows(connection, "SELECT attempt_id,attempt_locator,core_payload,core_digest FROM
|
|
12095
|
+
const attempts = rows(connection, "SELECT attempt_id,attempt_locator,core_payload,core_digest FROM ne19_attempts WHERE origin_run_id=? ORDER BY attempt_id", runId).map((row) => Object.freeze({
|
|
11531
12096
|
attemptId: text$2(row, "attempt_id"),
|
|
11532
12097
|
attemptLocator: text$2(row, "attempt_locator"),
|
|
11533
12098
|
coreBytes: transferableBytes(bytes(row, "core_payload")),
|
|
11534
12099
|
coreDigest: text$2(row, "core_digest")
|
|
11535
12100
|
}));
|
|
11536
|
-
const members = rows(connection, `SELECT slot_id,origin_run_id,attempt_id,action,core_payload,core_digest FROM
|
|
12101
|
+
const members = rows(connection, `SELECT slot_id,origin_run_id,attempt_id,action,core_payload,core_digest FROM ne19_members
|
|
11537
12102
|
WHERE target_run_id=? ORDER BY slot_id`, runId).map((row) => Object.freeze({
|
|
11538
12103
|
slotId: text$2(row, "slot_id"),
|
|
11539
12104
|
...optionalText$1(row, "origin_run_id") === void 0 ? {} : { originRunId: optionalText$1(row, "origin_run_id") },
|
|
@@ -11543,11 +12108,11 @@ function readSealedRunDocument(connection, runId) {
|
|
|
11543
12108
|
coreDigest: text$2(row, "core_digest")
|
|
11544
12109
|
}));
|
|
11545
12110
|
const attachments = rows(connection, `SELECT attachment_id,owner_kind,owner_run_id,owner_attempt_id,family,family_revision,
|
|
11546
|
-
logical_identity,canonical_payload,canonical_digest,logical_inventory,inventory_digest FROM
|
|
12111
|
+
logical_identity,canonical_payload,canonical_digest,logical_inventory,inventory_digest FROM ne19_attachments
|
|
11547
12112
|
WHERE owner_run_id=? ORDER BY attachment_id`, runId).map((row) => {
|
|
11548
12113
|
const attachmentId = text$2(row, "attachment_id");
|
|
11549
12114
|
const references = rows(connection, `SELECT ordinal,target_owner_kind,target_family,
|
|
11550
|
-
canonical_payload,reference_digest FROM
|
|
12115
|
+
canonical_payload,reference_digest FROM ne19_attachment_references WHERE attachment_id=? ORDER BY ordinal`, attachmentId).map((reference) => Object.freeze({
|
|
11551
12116
|
ordinal: integer$1(reference, "ordinal"),
|
|
11552
12117
|
owner: ownerKind(reference, "target_owner_kind"),
|
|
11553
12118
|
family: text$2(reference, "target_family"),
|
|
@@ -11555,14 +12120,14 @@ function readSealedRunDocument(connection, runId) {
|
|
|
11555
12120
|
referenceDigest: text$2(reference, "reference_digest")
|
|
11556
12121
|
}));
|
|
11557
12122
|
const collectionItems = rows(connection, `SELECT ordinal,logical_identity,canonical_payload,canonical_digest
|
|
11558
|
-
FROM
|
|
12123
|
+
FROM ne19_collection_items WHERE attachment_id=? ORDER BY ordinal`, attachmentId).map((item) => Object.freeze({
|
|
11559
12124
|
ordinal: integer$1(item, "ordinal"),
|
|
11560
12125
|
logicalIdentity: text$2(item, "logical_identity"),
|
|
11561
12126
|
canonicalBytes: transferableBytes(bytes(item, "canonical_payload")),
|
|
11562
12127
|
canonicalDigest: text$2(item, "canonical_digest")
|
|
11563
12128
|
}));
|
|
11564
12129
|
const contents = rows(connection, `SELECT content_id,logical_handle,byte_length,overall_digest,chunk_count
|
|
11565
|
-
FROM
|
|
12130
|
+
FROM ne19_contents WHERE attachment_id=? ORDER BY content_id`, attachmentId).map((content) => Object.freeze({
|
|
11566
12131
|
contentId: text$2(content, "content_id"),
|
|
11567
12132
|
logicalHandle: text$2(content, "logical_handle"),
|
|
11568
12133
|
byteLength: integer$1(content, "byte_length"),
|
|
@@ -11610,12 +12175,12 @@ function readContentChunkPage(connection, contentId, afterOrdinal, pageSize) {
|
|
|
11610
12175
|
let pageBytes = 0;
|
|
11611
12176
|
let hasMore = false;
|
|
11612
12177
|
const pageRows = recordStatement(connection, `SELECT c.ordinal,c.bytes,c.chunk_digest,
|
|
11613
|
-
EXISTS(SELECT 1 FROM
|
|
11614
|
-
FROM
|
|
11615
|
-
JOIN
|
|
11616
|
-
JOIN
|
|
11617
|
-
((r.status='sealed' AND (NOT EXISTS (SELECT 1 FROM
|
|
11618
|
-
(a.owner_kind='attempt' AND EXISTS (SELECT 1 FROM
|
|
12178
|
+
EXISTS(SELECT 1 FROM ne19_content_chunks more WHERE more.content_id=c.content_id AND more.ordinal>c.ordinal) AS has_more
|
|
12179
|
+
FROM ne19_content_chunks c
|
|
12180
|
+
JOIN ne19_contents n ON n.content_id=c.content_id JOIN ne19_attachments a ON a.attachment_id=n.attachment_id
|
|
12181
|
+
JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=? AND c.ordinal>? AND
|
|
12182
|
+
((r.status='sealed' AND (NOT EXISTS (SELECT 1 FROM ne19_run_resources rr WHERE rr.run_id=r.run_id) OR a.owner_kind='run')) OR
|
|
12183
|
+
(a.owner_kind='attempt' AND EXISTS (SELECT 1 FROM ne19_attempt_publications p
|
|
11619
12184
|
WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id)))
|
|
11620
12185
|
ORDER BY c.ordinal LIMIT ?`).iterate(contentId, afterOrdinal, pageSize);
|
|
11621
12186
|
for (const row of pageRows) {
|
|
@@ -12256,12 +12821,12 @@ function requireAbsenceReason(value) {
|
|
|
12256
12821
|
if (!RUN_ABSENCE_REASONS.includes(value)) throw invalid$2(`Run absence reason ${value} is invalid`);
|
|
12257
12822
|
}
|
|
12258
12823
|
function metadataGeneration(connection) {
|
|
12259
|
-
const row = recordStatement(connection, "SELECT storage_generation FROM
|
|
12824
|
+
const row = recordStatement(connection, "SELECT storage_generation FROM ne19_record_metadata WHERE singleton=1").get();
|
|
12260
12825
|
if (row === void 0) throw invalid$2("ProjectDatabase storage generation is missing");
|
|
12261
12826
|
return text$1(row, "storage_generation");
|
|
12262
12827
|
}
|
|
12263
12828
|
function currentRevision(connection) {
|
|
12264
|
-
const row = recordStatement(connection, "SELECT revision FROM
|
|
12829
|
+
const row = recordStatement(connection, "SELECT revision FROM ne19_run_publication_clock WHERE singleton=1").get();
|
|
12265
12830
|
if (row === void 0) throw invalid$2("Run publication clock is missing");
|
|
12266
12831
|
return integer(row, "revision");
|
|
12267
12832
|
}
|
|
@@ -12289,8 +12854,8 @@ function publicationIdentity(row) {
|
|
|
12289
12854
|
}
|
|
12290
12855
|
function readSlotPublication(connection, runId, slotId, cutoff) {
|
|
12291
12856
|
const binding = recordStatement(connection, `SELECT b.action,b.binding_revision,b.attempt_id,b.origin_run_id,b.origin_slot_id,
|
|
12292
|
-
b.attempt_publication_revision,a.attempt_locator FROM
|
|
12293
|
-
JOIN
|
|
12857
|
+
b.attempt_publication_revision,a.attempt_locator FROM ne19_run_slot_bindings b
|
|
12858
|
+
JOIN ne19_attempt_publications a ON a.attempt_id=b.attempt_id
|
|
12294
12859
|
WHERE b.target_run_id=? AND b.slot_id=? AND b.binding_revision<=?`).get(runId, slotId, cutoff.revision);
|
|
12295
12860
|
if (binding !== void 0) {
|
|
12296
12861
|
const action = text$1(binding, "action");
|
|
@@ -12306,7 +12871,7 @@ function readSlotPublication(connection, runId, slotId, cutoff) {
|
|
|
12306
12871
|
bindingRevision: integer(binding, "binding_revision")
|
|
12307
12872
|
});
|
|
12308
12873
|
}
|
|
12309
|
-
const absence = recordStatement(connection, `SELECT reason,absence_revision FROM
|
|
12874
|
+
const absence = recordStatement(connection, `SELECT reason,absence_revision FROM ne19_run_slot_absences
|
|
12310
12875
|
WHERE run_id=? AND slot_id=? AND absence_revision<=?`).get(runId, slotId, cutoff.revision);
|
|
12311
12876
|
if (absence !== void 0) {
|
|
12312
12877
|
const reason = text$1(absence, "reason");
|
|
@@ -12322,7 +12887,7 @@ function readSlotPublication(connection, runId, slotId, cutoff) {
|
|
|
12322
12887
|
function readRunAtCutoff(connection, runId, cutoff) {
|
|
12323
12888
|
const row = recordStatement(connection, `SELECT r.run_id,r.invocation_id,r.experiment_id,r.started_at,r.initial_writer_generation,r.current_writer_generation,
|
|
12324
12889
|
r.terminal_state,r.completed_at,r.created_revision,r.close_revision,d.deletion_revision
|
|
12325
|
-
FROM
|
|
12890
|
+
FROM ne19_run_resources r LEFT JOIN ne19_run_deletion_tombstones d ON d.run_id=r.run_id WHERE r.run_id=?`).get(runId);
|
|
12326
12891
|
if (row === void 0 || integer(row, "created_revision") > cutoff.revision || row.deletion_revision !== null && row.deletion_revision !== void 0 && integer(row, "deletion_revision") <= cutoff.revision) return;
|
|
12327
12892
|
const closeRevision = row.close_revision === null ? void 0 : integer(row, "close_revision");
|
|
12328
12893
|
const closeVisible = closeRevision !== void 0 && closeRevision <= cutoff.revision;
|
|
@@ -12332,7 +12897,7 @@ function readRunAtCutoff(connection, runId, cutoff) {
|
|
|
12332
12897
|
throw invalid$2(`Run ${runId} close revision lacks terminal state`);
|
|
12333
12898
|
})() : "active";
|
|
12334
12899
|
const slotRows = recordStatement(connection, `SELECT slot_id,eval_id,attempt_ordinal,execution_identity_digest
|
|
12335
|
-
FROM
|
|
12900
|
+
FROM ne19_run_expected_slots WHERE run_id=? ORDER BY ordinal LIMIT ?`).all(runId, Math.trunc(RECORD_SQLITE_MAX_ROW_BYTES / 256) + 1);
|
|
12336
12901
|
if (slotRows.length > 4096) throw invalid$2(`Run ${runId} expected slot inventory exceeds its bounded read`);
|
|
12337
12902
|
const slots = slotRows.map((slot) => Object.freeze({
|
|
12338
12903
|
slotId: text$1(slot, "slot_id"),
|
|
@@ -12368,11 +12933,11 @@ function listRunResourcesOnConnection(connection, input = {}) {
|
|
|
12368
12933
|
const pageSize = input.pageSize ?? 100;
|
|
12369
12934
|
if (input.invocationId !== void 0) requireIdentity(input.invocationId, "invocationId");
|
|
12370
12935
|
if (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 256) throw invalid$2("Run page size must be between 1 and 256");
|
|
12371
|
-
const rows = input.invocationId === void 0 ? recordStatement(connection, `SELECT r.run_id FROM
|
|
12372
|
-
LEFT JOIN
|
|
12936
|
+
const rows = input.invocationId === void 0 ? recordStatement(connection, `SELECT r.run_id FROM ne19_run_resources r
|
|
12937
|
+
LEFT JOIN ne19_run_deletion_tombstones d ON d.run_id=r.run_id
|
|
12373
12938
|
WHERE r.created_revision<=? AND (d.deletion_revision IS NULL OR d.deletion_revision>?) AND r.run_id>?
|
|
12374
|
-
ORDER BY r.run_id LIMIT ?`).all(cutoff.revision, cutoff.revision, afterRunId, pageSize + 1) : recordStatement(connection, `SELECT r.run_id FROM
|
|
12375
|
-
LEFT JOIN
|
|
12939
|
+
ORDER BY r.run_id LIMIT ?`).all(cutoff.revision, cutoff.revision, afterRunId, pageSize + 1) : recordStatement(connection, `SELECT r.run_id FROM ne19_run_resources r
|
|
12940
|
+
LEFT JOIN ne19_run_deletion_tombstones d ON d.run_id=r.run_id
|
|
12376
12941
|
WHERE r.created_revision<=? AND (d.deletion_revision IS NULL OR d.deletion_revision>?) AND r.invocation_id=? AND r.run_id>?
|
|
12377
12942
|
ORDER BY r.run_id LIMIT ?`).all(cutoff.revision, cutoff.revision, input.invocationId, afterRunId, pageSize + 1);
|
|
12378
12943
|
const selected = rows.slice(0, pageSize);
|
|
@@ -12448,7 +13013,9 @@ function openPinnedRecordReadSession(path, kind, deadlineEpochMs) {
|
|
|
12448
13013
|
})
|
|
12449
13014
|
});
|
|
12450
13015
|
}),
|
|
12451
|
-
|
|
13016
|
+
findSourceBarrierCandidate: (request) => readBounded("find-source-barrier", () => findSourceBarrierCandidate(connection, request, publicationCutoff.revision)),
|
|
13017
|
+
findAcceptedAttemptRunIds: (request) => readBounded("find-accepted-attempt-runs", () => findAcceptedAttemptRunIds(connection, request, publicationCutoff.revision)),
|
|
13018
|
+
findAttemptLocatorCandidates: (locator, maximumCandidateRuns, includeTargets = true) => readBounded("find-attempt-locator", () => findAttemptLocatorCandidates(connection, locator, maximumCandidateRuns, includeTargets)),
|
|
12452
13019
|
readSealedRunDocument: (runId) => readBounded("read-sealed-run-document", () => readSealedRunDocument(connection, runId)),
|
|
12453
13020
|
readSealedRunCore: (runId, lazyAttachments = false) => readBounded("read-sealed-run-core", () => readSealedRunCore(connection, runId, lazyAttachments ? (read) => readBounded("read-sealed-attachment", read) : void 0)),
|
|
12454
13021
|
readContentChunkPage: (contentId, afterOrdinal, pageSize) => readBounded("read-content-page", () => readContentChunkPage(connection, contentId, afterOrdinal, pageSize)),
|
|
@@ -12505,24 +13072,25 @@ function openHostOwnedInspectionSource(recordPath) {
|
|
|
12505
13072
|
}
|
|
12506
13073
|
Object.freeze({
|
|
12507
13074
|
identity: EMPTY_PUBLICATION_CUTOFF_IDENTITY,
|
|
12508
|
-
|
|
13075
|
+
storeGeneration: EMPTY_PUBLICATION_CUTOFF_IDENTITY,
|
|
13076
|
+
revision: 0
|
|
12509
13077
|
});
|
|
12510
13078
|
function sessionFacts(session, kind) {
|
|
12511
|
-
|
|
12512
|
-
const
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
observedCutoff = page.cutoff;
|
|
12518
|
-
return page;
|
|
12519
|
-
};
|
|
12520
|
-
const readPage = (afterRunId = "", pageSize = 100, expectedCutoffIdentity) => remember(session.readSealedRunSummaryPage(afterRunId, pageSize, expectedCutoffIdentity ?? observedCutoff?.identity));
|
|
13079
|
+
const publication = session.publicationCutoff();
|
|
13080
|
+
const cutoff = Object.freeze({
|
|
13081
|
+
...publication,
|
|
13082
|
+
identity: publicationCutoffIdentity(publication)
|
|
13083
|
+
});
|
|
13084
|
+
const readPage = (afterRunId = "", pageSize = 100, expectedCutoffIdentity) => session.readSealedRunSummaryPage(afterRunId, pageSize, expectedCutoffIdentity ?? cutoff.identity);
|
|
12521
13085
|
return Object.freeze({
|
|
12522
13086
|
kind,
|
|
12523
|
-
cutoff: () =>
|
|
13087
|
+
cutoff: () => cutoff,
|
|
12524
13088
|
findExperimentRunIds: session.findExperimentRunIds,
|
|
12525
13089
|
readRunResource: (runId) => session.readRunResource(runId),
|
|
13090
|
+
readRunResourcePage: (afterRunId = "", pageSize = 100) => session.listRunResources({
|
|
13091
|
+
afterRunId,
|
|
13092
|
+
pageSize
|
|
13093
|
+
}),
|
|
12526
13094
|
readSealedRunSummaryPage: readPage,
|
|
12527
13095
|
findAttemptLocatorCandidates: (locator, maximumCandidateRuns) => session.findAttemptLocatorCandidates(locator, maximumCandidateRuns),
|
|
12528
13096
|
readSealedRunCore: (runId) => session.readSealedRunCore(runId, true),
|
|
@@ -13467,10 +14035,12 @@ function loadInspectionRuns(source) {
|
|
|
13467
14035
|
const cutoff = source.cutoff();
|
|
13468
14036
|
const summaries = [];
|
|
13469
14037
|
const seen = /* @__PURE__ */ new Set();
|
|
14038
|
+
let expectedRunCount;
|
|
13470
14039
|
let afterRunId = "";
|
|
13471
14040
|
for (;;) {
|
|
13472
14041
|
const page = source.readSealedRunSummaryPage(afterRunId, RUN_PAGE_SIZE, cutoff.identity);
|
|
13473
|
-
|
|
14042
|
+
if (page.cutoff.identity !== cutoff.identity || expectedRunCount !== void 0 && page.cutoff.runCount !== expectedRunCount) throw factsError("Run inventory changed its pinned cutoff or count");
|
|
14043
|
+
expectedRunCount ??= page.cutoff.runCount;
|
|
13474
14044
|
if (page.afterRunId !== afterRunId) throw factsError("Run pagination returned a different cursor");
|
|
13475
14045
|
let previous = afterRunId;
|
|
13476
14046
|
for (const summary of page.summaries) {
|
|
@@ -13483,7 +14053,7 @@ function loadInspectionRuns(source) {
|
|
|
13483
14053
|
if (page.summaries.length === 0 || page.nextAfterRunId !== page.summaries.at(-1).runId || page.nextAfterRunId === afterRunId) throw factsError("Run pagination returned an invalid continuation cursor");
|
|
13484
14054
|
afterRunId = page.nextAfterRunId;
|
|
13485
14055
|
}
|
|
13486
|
-
if (summaries.length !==
|
|
14056
|
+
if (summaries.length !== expectedRunCount) throw factsError("Run pagination did not close the pinned sealed cutoff");
|
|
13487
14057
|
return Object.freeze(summaries.map((summary) => {
|
|
13488
14058
|
const run = readInspectionRun(source, summary.runId);
|
|
13489
14059
|
if (run === void 0) throw factsError(`Sealed Run ${summary.runId} disappeared from the pinned cutoff`);
|
|
@@ -13507,12 +14077,37 @@ function loadInspectionRunResource(source, runId) {
|
|
|
13507
14077
|
const resource = source.readRunResource(runId);
|
|
13508
14078
|
if (resource === void 0) return void 0;
|
|
13509
14079
|
const published = readInspectionRun(source, runId);
|
|
13510
|
-
requireCutoff(source.cutoff(), cutoff);
|
|
13511
|
-
if (resource.published > 0 && published === void 0) throw factsError(`Run ${runId} has published bindings without a readable Core`);
|
|
13512
14080
|
if (published !== void 0) validateRunResourceCore(resource, published);
|
|
14081
|
+
const originIds = resource.slots.flatMap(({ publication }) => publication.state === "published" ? [publication.originRunId] : []);
|
|
14082
|
+
const supporting = loadSelectedInspectionRuns(source, [...published === void 0 ? [] : [runId], ...originIds]);
|
|
14083
|
+
const index = memberIndex(supporting);
|
|
14084
|
+
const publications = new Map(supporting.flatMap((origin) => origin.physical.attempts.map((attempt) => [`${origin.run.runId}\u0000${attempt.attemptId}`, attempt])));
|
|
14085
|
+
const members = resource.slots.flatMap(({ slotId, publication }) => {
|
|
14086
|
+
if (publication.state === "pending") return [];
|
|
14087
|
+
if (publication.state === "absent") return [decodedRight(decodeMemberDocument({
|
|
14088
|
+
slotId,
|
|
14089
|
+
action: publication.reason === "interrupted-before-publication" || publication.reason === "dispatch-failed" ? "interrupted" : "not-dispatched",
|
|
14090
|
+
attempt: null,
|
|
14091
|
+
absenceReason: publication.reason
|
|
14092
|
+
}), "Run resource absence is invalid")];
|
|
14093
|
+
const attempt = index.origins.get(publication.originRunId)?.attempts.get(publication.attemptId);
|
|
14094
|
+
const stored = publications.get(`${publication.originRunId}\u0000${publication.attemptId}`);
|
|
14095
|
+
if (attempt === void 0 || stored === void 0 || attempt.slotId !== publication.originSlotId || stored.attemptLocator !== publication.attemptLocator || stored.publicationIdentity?.originRunId !== publication.publicationIdentity.originRunId || stored.publicationIdentity?.attemptId !== publication.publicationIdentity.attemptId || stored.publicationIdentity?.revision !== publication.publicationIdentity.revision || publication.publicationIdentity.originRunId !== publication.originRunId || publication.publicationIdentity.attemptId !== publication.attemptId || publication.action === "executed" && publication.originRunId !== runId) throw factsError(`Run ${runId} Slot ${slotId} does not bind a matching published origin Attempt`);
|
|
14096
|
+
return [decodedRight(decodeMemberDocument({
|
|
14097
|
+
slotId,
|
|
14098
|
+
action: publication.action,
|
|
14099
|
+
attempt: {
|
|
14100
|
+
originRunId: publication.originRunId,
|
|
14101
|
+
attemptId: publication.attemptId
|
|
14102
|
+
}
|
|
14103
|
+
}), "Run resource binding is invalid")];
|
|
14104
|
+
}).sort((left, right) => compareText$1(left.slotId, right.slotId));
|
|
14105
|
+
requireCutoff(source.cutoff(), cutoff);
|
|
13513
14106
|
return Object.freeze({
|
|
13514
14107
|
source,
|
|
13515
14108
|
resource,
|
|
14109
|
+
members: Object.freeze(members),
|
|
14110
|
+
supporting,
|
|
13516
14111
|
...published === void 0 ? {} : { published }
|
|
13517
14112
|
});
|
|
13518
14113
|
}
|
|
@@ -13653,6 +14248,21 @@ function resolveInspectionMemberAttempt(runs, target, member) {
|
|
|
13653
14248
|
targets
|
|
13654
14249
|
});
|
|
13655
14250
|
}
|
|
14251
|
+
/** A target binding does not require the target to have published its own Run Core. */
|
|
14252
|
+
function resolveInspectionResourceMemberAttempt(target, member) {
|
|
14253
|
+
if (member.attempt === null) return void 0;
|
|
14254
|
+
const index = memberIndex(target.supporting);
|
|
14255
|
+
const origin = index.origins.get(member.attempt.originRunId);
|
|
14256
|
+
const attempt = origin?.attempts.get(member.attempt.attemptId);
|
|
14257
|
+
if (origin === void 0 || attempt === void 0) return void 0;
|
|
14258
|
+
const targets = index.targets.get(attempt.originRunId)?.get(attempt.attemptId) ?? [];
|
|
14259
|
+
return Object.freeze({
|
|
14260
|
+
attempt,
|
|
14261
|
+
origin: origin.run,
|
|
14262
|
+
locator: encodeAttemptLocator(attempt.attemptId),
|
|
14263
|
+
targets
|
|
14264
|
+
});
|
|
14265
|
+
}
|
|
13656
14266
|
function attemptAttachment(resolved, family) {
|
|
13657
14267
|
return resolved.origin.attachments.find(({ physical }) => physical.ownerKind === "attempt" && physical.ownerAttemptId === resolved.attempt.attemptId && physical.family === family);
|
|
13658
14268
|
}
|
|
@@ -13760,7 +14370,7 @@ function targetMembers(run, attempt) {
|
|
|
13760
14370
|
return run.members.filter((member) => member.attempt !== null && member.attempt.originRunId === attempt.originRunId && member.attempt.attemptId === attempt.attemptId);
|
|
13761
14371
|
}
|
|
13762
14372
|
function requireCutoff(actual, expected) {
|
|
13763
|
-
if (actual.
|
|
14373
|
+
if (actual.storeGeneration !== expected.storeGeneration || actual.revision !== expected.revision) throw factsError("Inspection source changed its pinned sealed cutoff");
|
|
13764
14374
|
}
|
|
13765
14375
|
function parseJson$1(bytes, owner) {
|
|
13766
14376
|
try {
|
|
@@ -13880,6 +14490,8 @@ var INSPECTION_RESULT_BYTE_LIMIT = 524288;
|
|
|
13880
14490
|
var INSPECTION_EXPERIMENT_RESULT_BYTE_LIMIT = 4194304;
|
|
13881
14491
|
/** Full source content, Judge audit and base64 encoding for assertion detail only. */
|
|
13882
14492
|
var INSPECTION_ASSERTION_DETAIL_BYTE_LIMIT = 33554432;
|
|
14493
|
+
/** Complete cache groups for all 4000 admitted physical calls, including maximum escaped identities. */
|
|
14494
|
+
var INSPECTION_ATTEMPT_USAGE_RESULT_BYTE_LIMIT = 16777216;
|
|
13883
14495
|
var PAGE_ROWS = 64;
|
|
13884
14496
|
var IDENTITY_INDEX_LIMIT = 256;
|
|
13885
14497
|
var TARGET_LIMITS = Object.freeze({
|
|
@@ -15381,7 +15993,7 @@ function projectApplicationUsage(attachments, models) {
|
|
|
15381
15993
|
const modelUsage = projectAdapterModelUsage(read.state === "available" ? read.value : null, models, {
|
|
15382
15994
|
basis: "recorded-calls",
|
|
15383
15995
|
reason: read.state === "invalid" ? "source-invalid" : "usage-not-recorded"
|
|
15384
|
-
});
|
|
15996
|
+
}, attachments.adapterUsage.physical.familyRevision === 4);
|
|
15385
15997
|
const empty = {
|
|
15386
15998
|
source: "adapter",
|
|
15387
15999
|
coverage: "recorded-calls",
|
|
@@ -18935,34 +19547,13 @@ function selectOperation(source, operation) {
|
|
|
18935
19547
|
experiment: decodeRequiredResult(operation.kind, InspectionExperimentResultSchema, experimentResult())
|
|
18936
19548
|
}));
|
|
18937
19549
|
}
|
|
18938
|
-
case "
|
|
19550
|
+
case "run.list": return runsListDocument(source, operation);
|
|
18939
19551
|
case "run.get": {
|
|
18940
19552
|
const run = requireRunResource(source, operation.kind, operation.runId);
|
|
18941
19553
|
const supporting = supportingRunFacts(source, run);
|
|
18942
19554
|
return Object.freeze({
|
|
18943
19555
|
...runResourceMetadata(source, operation.kind, run, supporting),
|
|
18944
|
-
run: decodeRequiredResult(operation.kind, InspectionRunResultSchema,
|
|
18945
|
-
value: inspectionRunValue(run),
|
|
18946
|
-
members: run.published?.members ?? Object.freeze([]),
|
|
18947
|
-
attempts: run.published?.attempts ?? Object.freeze([])
|
|
18948
|
-
}))
|
|
18949
|
-
});
|
|
18950
|
-
}
|
|
18951
|
-
case "run.summary": {
|
|
18952
|
-
const selected = selectRuns(loadRuns(source, [operation.runId]), [operation.runId]);
|
|
18953
|
-
const run = requireOne(operation.kind, selected.selected, operation.runId);
|
|
18954
|
-
const all = loadSummaryFacts(source, run);
|
|
18955
|
-
return Object.freeze({
|
|
18956
|
-
...resultMetadata(source, operation.kind, all, [operation.runId], selected.missing, locators(all)),
|
|
18957
|
-
summary: decodeRequiredResult(operation.kind, InspectionRunSummaryResultSchema, runSummary(all, run))
|
|
18958
|
-
});
|
|
18959
|
-
}
|
|
18960
|
-
case "run.overview": {
|
|
18961
|
-
const run = requireRunResource(source, operation.kind, operation.runId);
|
|
18962
|
-
const all = supportingRunFacts(source, run);
|
|
18963
|
-
return Object.freeze({
|
|
18964
|
-
...runResourceMetadata(source, operation.kind, run, all),
|
|
18965
|
-
runOverview: decodeRequiredResult(operation.kind, InspectionRunOverviewResultSchema, runOverview(all, run))
|
|
19556
|
+
run: decodeRequiredResult(operation.kind, InspectionRunResultSchema, runDetail(supporting, run))
|
|
18966
19557
|
});
|
|
18967
19558
|
}
|
|
18968
19559
|
case "attempt.get": {
|
|
@@ -19036,7 +19627,7 @@ function selectOperation(source, operation) {
|
|
|
19036
19627
|
while (utf8ByteLength$2(JSON.stringify({
|
|
19037
19628
|
...metadata,
|
|
19038
19629
|
usage
|
|
19039
|
-
})) >
|
|
19630
|
+
})) > 16777216 && (usage.judgeUsage.state === "complete" || usage.judgeUsage.state === "partial") && usage.judgeUsage.calls.length > 0) usage = Object.freeze({
|
|
19040
19631
|
...usage,
|
|
19041
19632
|
judgeUsage: takeJudgeUsagePreview(usage.judgeUsage, usage.judgeUsage.calls.length - 1)
|
|
19042
19633
|
});
|
|
@@ -19142,24 +19733,38 @@ function selectOperation(source, operation) {
|
|
|
19142
19733
|
function runsListDocument(source, operation) {
|
|
19143
19734
|
const page = runSummaryPage(source, operation.continuation);
|
|
19144
19735
|
return Object.freeze({
|
|
19145
|
-
...runsListBase(source,
|
|
19736
|
+
...runsListBase(source, source.cutoff(), page.items, page.truncated),
|
|
19146
19737
|
runs: closeJson(page.items),
|
|
19147
19738
|
...page.continuation === void 0 ? {} : { continuation: page.continuation }
|
|
19148
19739
|
});
|
|
19149
19740
|
}
|
|
19150
19741
|
function runSummaryPage(source, continuation) {
|
|
19151
19742
|
const binding = continuation === void 0 ? void 0 : decodeContinuation(continuation);
|
|
19743
|
+
const cutoff = source.cutoff();
|
|
19152
19744
|
let page;
|
|
19153
19745
|
try {
|
|
19154
|
-
|
|
19746
|
+
if (binding !== void 0 && binding.cutoffIdentity !== cutoff.identity) throw new Error("Publication cutoff changed");
|
|
19747
|
+
page = source.readRunResourcePage(binding?.afterRunId ?? "", RUN_LIST_PAGE_SIZE);
|
|
19155
19748
|
} catch (cause) {
|
|
19156
|
-
throw operationFailure("
|
|
19749
|
+
throw operationFailure("run.list", "Continuation is invalid or its publication cutoff changed; restart run.list", cause);
|
|
19157
19750
|
}
|
|
19158
19751
|
return Object.freeze({
|
|
19159
|
-
cutoff
|
|
19160
|
-
items: page.
|
|
19752
|
+
cutoff,
|
|
19753
|
+
items: Object.freeze(page.runs.map((run) => Object.freeze({
|
|
19754
|
+
runId: run.runId,
|
|
19755
|
+
invocationId: run.invocationId,
|
|
19756
|
+
experimentId: run.experimentId,
|
|
19757
|
+
state: run.state,
|
|
19758
|
+
startedAt: run.startedAt,
|
|
19759
|
+
...run.completedAt === void 0 ? {} : { completedAt: run.completedAt },
|
|
19760
|
+
coverage: Object.freeze({
|
|
19761
|
+
expected: run.expected,
|
|
19762
|
+
published: run.published,
|
|
19763
|
+
missing: run.missing
|
|
19764
|
+
})
|
|
19765
|
+
}))),
|
|
19161
19766
|
truncated: page.nextAfterRunId !== null,
|
|
19162
|
-
continuation: page.nextAfterRunId === null ? void 0 : encodeContinuation(page.nextAfterRunId,
|
|
19767
|
+
continuation: page.nextAfterRunId === null ? void 0 : encodeContinuation(page.nextAfterRunId, cutoff.identity)
|
|
19163
19768
|
});
|
|
19164
19769
|
}
|
|
19165
19770
|
function runsListBase(source, cutoff, selected, truncated) {
|
|
@@ -19167,19 +19772,17 @@ function runsListBase(source, cutoff, selected, truncated) {
|
|
|
19167
19772
|
protocol: QUERY_PROTOCOL,
|
|
19168
19773
|
behaviorVersion: INSPECTION_BEHAVIOR_VERSION,
|
|
19169
19774
|
outcome: "success",
|
|
19170
|
-
operation: "
|
|
19775
|
+
operation: "run.list",
|
|
19171
19776
|
source: sourceProvenance(source, cutoff),
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
runCount: cutoff.runCount
|
|
19777
|
+
publicationCutoff: Object.freeze({
|
|
19778
|
+
storeGeneration: cutoff.storeGeneration,
|
|
19779
|
+
revision: cutoff.revision
|
|
19176
19780
|
}),
|
|
19177
19781
|
selection: Object.freeze({
|
|
19178
19782
|
requestedRunIds: Object.freeze([]),
|
|
19179
19783
|
selectedRunIds: Object.freeze(selected.map(({ runId }) => runId)),
|
|
19180
19784
|
missingRunIds: Object.freeze([]),
|
|
19181
19785
|
returnedRunCount: selected.length,
|
|
19182
|
-
totalRunCount: cutoff.runCount,
|
|
19183
19786
|
truncated
|
|
19184
19787
|
}),
|
|
19185
19788
|
issues: Object.freeze([]),
|
|
@@ -19188,7 +19791,7 @@ function runsListBase(source, cutoff, selected, truncated) {
|
|
|
19188
19791
|
}
|
|
19189
19792
|
function encodeContinuation(afterRunId, cutoffIdentity) {
|
|
19190
19793
|
return encodeBase64UrlUtf8(JSON.stringify([
|
|
19191
|
-
"
|
|
19794
|
+
"run.list",
|
|
19192
19795
|
cutoffIdentity,
|
|
19193
19796
|
afterRunId
|
|
19194
19797
|
]));
|
|
@@ -19196,13 +19799,13 @@ function encodeContinuation(afterRunId, cutoffIdentity) {
|
|
|
19196
19799
|
function decodeContinuation(token) {
|
|
19197
19800
|
try {
|
|
19198
19801
|
const decoded = JSON.parse(decodeBase64UrlUtf8(token));
|
|
19199
|
-
if (!Array.isArray(decoded) || decoded.length !== 3 || decoded[0] !== "
|
|
19802
|
+
if (!Array.isArray(decoded) || decoded.length !== 3 || decoded[0] !== "run.list" || typeof decoded[1] !== "string" || typeof decoded[2] !== "string") throw new Error("continuation binding changed");
|
|
19200
19803
|
return Object.freeze({
|
|
19201
19804
|
cutoffIdentity: decoded[1],
|
|
19202
19805
|
afterRunId: decoded[2]
|
|
19203
19806
|
});
|
|
19204
19807
|
} catch (cause) {
|
|
19205
|
-
throw operationFailure("
|
|
19808
|
+
throw operationFailure("run.list", "Continuation is invalid or its sealed cutoff changed; restart run.list", cause);
|
|
19206
19809
|
}
|
|
19207
19810
|
}
|
|
19208
19811
|
function requireCurrentProject(source, experimentIds) {
|
|
@@ -19242,8 +19845,8 @@ function inspectionRunValue(run) {
|
|
|
19242
19845
|
}))
|
|
19243
19846
|
}));
|
|
19244
19847
|
}
|
|
19245
|
-
function supportingRunFacts(
|
|
19246
|
-
return run.
|
|
19848
|
+
function supportingRunFacts(_source, run) {
|
|
19849
|
+
return run.supporting;
|
|
19247
19850
|
}
|
|
19248
19851
|
function runResourceMetadata(source, operation, run, supporting) {
|
|
19249
19852
|
const metadata = resultMetadata(source, operation, supporting, [run.resource.runId], [], locators(supporting));
|
|
@@ -19260,9 +19863,6 @@ function loadReferencedOrigins(source, targets) {
|
|
|
19260
19863
|
const originIds = [...new Set(targets.flatMap(({ members }) => members.flatMap(({ attempt }) => attempt === null || targetIds.has(attempt.originRunId) ? [] : [attempt.originRunId])))];
|
|
19261
19864
|
return uniqueRuns([...targets, ...loadRuns(source, originIds)]);
|
|
19262
19865
|
}
|
|
19263
|
-
function loadSummaryFacts(source, target) {
|
|
19264
|
-
return loadReferencedOrigins(source, [target]);
|
|
19265
|
-
}
|
|
19266
19866
|
function selectRuns(all, runIds) {
|
|
19267
19867
|
const byId = new Map(all.map((run) => [run.run.runId, run]));
|
|
19268
19868
|
const requested = [...new Set(runIds)];
|
|
@@ -19274,11 +19874,6 @@ function selectRuns(all, runIds) {
|
|
|
19274
19874
|
missing: Object.freeze(requested.filter((runId) => !byId.has(runId)))
|
|
19275
19875
|
});
|
|
19276
19876
|
}
|
|
19277
|
-
function requireOne(operation, selected, runId) {
|
|
19278
|
-
const run = selected[0];
|
|
19279
|
-
if (run === void 0) throw selectionMissing(operation, `Run ${runId} was not found`);
|
|
19280
|
-
return run;
|
|
19281
|
-
}
|
|
19282
19877
|
function requireAttemptFromSource(source, operation, locator) {
|
|
19283
19878
|
const resolved = resolveInspectionAttempt(source, locator);
|
|
19284
19879
|
if (resolved === void 0) throw selectionMissing(operation, `Attempt ${locator} was not found or is ambiguous`);
|
|
@@ -19388,49 +19983,11 @@ function containsState(value, expected) {
|
|
|
19388
19983
|
const record = value;
|
|
19389
19984
|
return record.state === expected || Object.values(record).some((entry) => containsState(entry, expected));
|
|
19390
19985
|
}
|
|
19391
|
-
function
|
|
19392
|
-
const slots = selected.run.expectedSlots.map((slot) => {
|
|
19393
|
-
const member = selected.members.find((candidate) => candidate.slotId === slot.slotId);
|
|
19394
|
-
if (member === void 0 || member.attempt === null) return Object.freeze({
|
|
19395
|
-
runId: selected.run.runId,
|
|
19396
|
-
...slot,
|
|
19397
|
-
state: member?.action ?? "missing",
|
|
19398
|
-
locator: null,
|
|
19399
|
-
outcome: null,
|
|
19400
|
-
verdict: null
|
|
19401
|
-
});
|
|
19402
|
-
const resolved = resolveInspectionMemberAttempt(all, selected, member);
|
|
19403
|
-
if (resolved === void 0) return Object.freeze({
|
|
19404
|
-
runId: selected.run.runId,
|
|
19405
|
-
...slot,
|
|
19406
|
-
state: "missing",
|
|
19407
|
-
locator: null,
|
|
19408
|
-
outcome: null,
|
|
19409
|
-
verdict: null
|
|
19410
|
-
});
|
|
19411
|
-
const assertions = readInspectionAssertions(resolved);
|
|
19412
|
-
return Object.freeze({
|
|
19413
|
-
runId: selected.run.runId,
|
|
19414
|
-
...slot,
|
|
19415
|
-
state: member.action,
|
|
19416
|
-
locator: resolved.locator,
|
|
19417
|
-
outcome: resolved.attempt.outcome,
|
|
19418
|
-
verdict: attemptVerdict(resolved, assertions),
|
|
19419
|
-
score: assertionScore(assertions.state === "available" ? assertions.value.entries : [])
|
|
19420
|
-
});
|
|
19421
|
-
});
|
|
19422
|
-
return Object.freeze({
|
|
19423
|
-
runs: Object.freeze([selected.run]),
|
|
19424
|
-
denominator: Object.freeze({
|
|
19425
|
-
expected: slots.length,
|
|
19426
|
-
observed: slots.filter(({ locator }) => locator !== null).length
|
|
19427
|
-
}),
|
|
19428
|
-
members: Object.freeze(slots)
|
|
19429
|
-
});
|
|
19430
|
-
}
|
|
19431
|
-
function runOverview(all, selectedResource) {
|
|
19986
|
+
function runDetail(_all, selectedResource) {
|
|
19432
19987
|
const selected = selectedResource.published;
|
|
19433
19988
|
const value = inspectionRunValue(selectedResource);
|
|
19989
|
+
const publications = new Map(selectedResource.resource.slots.map((slot) => [slot.slotId, slot.publication]));
|
|
19990
|
+
const bindings = new Map(selectedResource.members.map((member) => [member.slotId, member]));
|
|
19434
19991
|
const unavailableUsage = () => Object.freeze({
|
|
19435
19992
|
state: "unavailable",
|
|
19436
19993
|
summary: null,
|
|
@@ -19445,16 +20002,30 @@ function runOverview(all, selectedResource) {
|
|
|
19445
20002
|
limitations: Object.freeze([])
|
|
19446
20003
|
});
|
|
19447
20004
|
const projected = value.expectedSlots.map((slot) => {
|
|
19448
|
-
const
|
|
20005
|
+
const binding = publications.get(slot.slotId);
|
|
20006
|
+
if (binding === void 0) throw new Error(`Run ${value.runId} has no Slot ${slot.slotId}`);
|
|
20007
|
+
const publication = binding.state === "published" ? Object.freeze({
|
|
20008
|
+
state: "published",
|
|
20009
|
+
action: binding.action,
|
|
20010
|
+
attemptId: binding.attemptId,
|
|
20011
|
+
attemptLocator: binding.attemptLocator,
|
|
20012
|
+
originRunId: binding.originRunId,
|
|
20013
|
+
originSlotId: binding.originSlotId
|
|
20014
|
+
}) : binding.state === "absent" ? Object.freeze({
|
|
20015
|
+
state: "absent",
|
|
20016
|
+
reason: binding.reason
|
|
20017
|
+
}) : Object.freeze({ state: "pending" });
|
|
20018
|
+
const targetMember = bindings.get(slot.slotId);
|
|
19449
20019
|
if (targetMember === void 0) {
|
|
19450
|
-
if (
|
|
20020
|
+
if (publication.state !== "pending" && publication.state !== "absent") throw new Error(`Terminal Run ${value.runId} has no binding or absence for Slot ${slot.slotId}`);
|
|
19451
20021
|
const limitation = Object.freeze({
|
|
19452
20022
|
kind: "member-not-observed",
|
|
19453
|
-
state: "pending"
|
|
20023
|
+
state: publication.state === "absent" ? publication.reason === "interrupted-before-publication" ? "interrupted" : "not-dispatched" : "pending"
|
|
19454
20024
|
});
|
|
19455
20025
|
return Object.freeze({ member: Object.freeze({
|
|
19456
|
-
slot,
|
|
19457
|
-
|
|
20026
|
+
...slot,
|
|
20027
|
+
publication,
|
|
20028
|
+
state: limitation.state,
|
|
19458
20029
|
locator: null,
|
|
19459
20030
|
relation: null,
|
|
19460
20031
|
outcome: null,
|
|
@@ -19471,7 +20042,8 @@ function runOverview(all, selectedResource) {
|
|
|
19471
20042
|
state: targetMember.action
|
|
19472
20043
|
});
|
|
19473
20044
|
return Object.freeze({ member: Object.freeze({
|
|
19474
|
-
slot,
|
|
20045
|
+
...slot,
|
|
20046
|
+
publication,
|
|
19475
20047
|
state: targetMember.action,
|
|
19476
20048
|
locator: null,
|
|
19477
20049
|
relation: null,
|
|
@@ -19483,8 +20055,7 @@ function runOverview(all, selectedResource) {
|
|
|
19483
20055
|
limitations: Object.freeze([limitation])
|
|
19484
20056
|
}) });
|
|
19485
20057
|
}
|
|
19486
|
-
|
|
19487
|
-
const resolved = resolveInspectionMemberAttempt(all, selected, targetMember);
|
|
20058
|
+
const resolved = resolveInspectionResourceMemberAttempt(selectedResource, targetMember);
|
|
19488
20059
|
if (resolved === void 0) {
|
|
19489
20060
|
const limitation = Object.freeze({
|
|
19490
20061
|
kind: "attempt-unresolved",
|
|
@@ -19492,7 +20063,8 @@ function runOverview(all, selectedResource) {
|
|
|
19492
20063
|
attemptId: targetMember.attempt.attemptId
|
|
19493
20064
|
});
|
|
19494
20065
|
return Object.freeze({ member: Object.freeze({
|
|
19495
|
-
slot,
|
|
20066
|
+
...slot,
|
|
20067
|
+
publication,
|
|
19496
20068
|
state: targetMember.action,
|
|
19497
20069
|
locator: null,
|
|
19498
20070
|
relation: null,
|
|
@@ -19519,7 +20091,8 @@ function runOverview(all, selectedResource) {
|
|
|
19519
20091
|
return Object.freeze({
|
|
19520
20092
|
usage,
|
|
19521
20093
|
member: Object.freeze({
|
|
19522
|
-
slot,
|
|
20094
|
+
...slot,
|
|
20095
|
+
publication,
|
|
19523
20096
|
state: targetMember.action,
|
|
19524
20097
|
locator: resolved.locator,
|
|
19525
20098
|
relation: resolved.attempt.originRunId === value.runId ? "origin" : "reference",
|
|
@@ -19548,7 +20121,7 @@ function runOverview(all, selectedResource) {
|
|
|
19548
20121
|
});
|
|
19549
20122
|
const members = Object.freeze(projected.map(({ member }) => member));
|
|
19550
20123
|
const locatedLimitations = Object.freeze(members.flatMap((member) => member.limitations.map((limitation) => Object.freeze({
|
|
19551
|
-
slotId: member.
|
|
20124
|
+
slotId: member.slotId,
|
|
19552
20125
|
locator: member.locator,
|
|
19553
20126
|
limitation
|
|
19554
20127
|
}))));
|
|
@@ -19558,19 +20131,15 @@ function runOverview(all, selectedResource) {
|
|
|
19558
20131
|
const coverageLimitations = Object.freeze(locatedLimitations.filter(({ limitation }) => limitation.kind !== "usage"));
|
|
19559
20132
|
const usageLimitations = Object.freeze(locatedLimitations.filter(({ limitation }) => limitation.kind !== "coverage"));
|
|
19560
20133
|
return Object.freeze({
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
adapter: value.context?.execution.adapter ?? null
|
|
19565
|
-
}),
|
|
19566
|
-
state: value.state,
|
|
19567
|
-
startedAt: value.startedAt,
|
|
19568
|
-
...value.completedAt === void 0 ? {} : { completedAt: value.completedAt },
|
|
20134
|
+
value,
|
|
20135
|
+
members: selectedResource.members,
|
|
20136
|
+
attempts: selected?.attempts ?? Object.freeze([]),
|
|
19569
20137
|
denominator: Object.freeze({
|
|
19570
|
-
expected:
|
|
19571
|
-
|
|
20138
|
+
expected: selectedResource.resource.expected,
|
|
20139
|
+
published: selectedResource.resource.published,
|
|
20140
|
+
missing: selectedResource.resource.missing
|
|
19572
20141
|
}),
|
|
19573
|
-
members,
|
|
20142
|
+
slots: members,
|
|
19574
20143
|
coverage: Object.freeze({
|
|
19575
20144
|
state: aggregateRunOverviewState(members.map(({ coverage }) => coverage.state)),
|
|
19576
20145
|
expectedMemberCount: members.length,
|
|
@@ -19793,10 +20362,6 @@ function comparisonMembers(all, runs) {
|
|
|
19793
20362
|
}
|
|
19794
20363
|
function baseDocument(source, operation, selectedInput, requestedRunIds, missingRunIds, evidence, issues = []) {
|
|
19795
20364
|
const selected = uniqueRuns(selectedInput);
|
|
19796
|
-
const seals = selected.map(({ run, physical }) => Object.freeze({
|
|
19797
|
-
runId: run.runId,
|
|
19798
|
-
logicalSealIdentity: physical.logicalSealIdentity
|
|
19799
|
-
}));
|
|
19800
20365
|
const cutoff = source.cutoff();
|
|
19801
20366
|
return Object.freeze({
|
|
19802
20367
|
protocol: QUERY_PROTOCOL,
|
|
@@ -19804,11 +20369,9 @@ function baseDocument(source, operation, selectedInput, requestedRunIds, missing
|
|
|
19804
20369
|
outcome: "success",
|
|
19805
20370
|
operation,
|
|
19806
20371
|
source: sourceProvenance(source, cutoff),
|
|
19807
|
-
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
runCount: cutoff.runCount,
|
|
19811
|
-
runs: Object.freeze(seals)
|
|
20372
|
+
publicationCutoff: Object.freeze({
|
|
20373
|
+
storeGeneration: cutoff.storeGeneration,
|
|
20374
|
+
revision: cutoff.revision
|
|
19812
20375
|
}),
|
|
19813
20376
|
selection: Object.freeze({
|
|
19814
20377
|
requestedRunIds: Object.freeze([...requestedRunIds]),
|
|
@@ -19828,14 +20391,9 @@ function resultMetadata(source, operation, selectedInput, requestedRunIds, missi
|
|
|
19828
20391
|
outcome: "success",
|
|
19829
20392
|
operation,
|
|
19830
20393
|
source: sourceProvenance(source, cutoff),
|
|
19831
|
-
|
|
19832
|
-
|
|
19833
|
-
|
|
19834
|
-
runCount: cutoff.runCount,
|
|
19835
|
-
runs: Object.freeze(selected.map(({ run, physical }) => Object.freeze({
|
|
19836
|
-
runId: run.runId,
|
|
19837
|
-
logicalSealIdentity: physical.logicalSealIdentity
|
|
19838
|
-
})))
|
|
20394
|
+
publicationCutoff: Object.freeze({
|
|
20395
|
+
storeGeneration: cutoff.storeGeneration,
|
|
20396
|
+
revision: cutoff.revision
|
|
19839
20397
|
}),
|
|
19840
20398
|
selection: Object.freeze({
|
|
19841
20399
|
requestedRunIds: Object.freeze([...requestedRunIds]),
|
|
@@ -19856,7 +20414,7 @@ function decodeRequiredResult(operation, schema, input) {
|
|
|
19856
20414
|
return decoded.success;
|
|
19857
20415
|
}
|
|
19858
20416
|
function requireInspectionResultBudget(operation, value) {
|
|
19859
|
-
const byteLimit = operation === "experiment.get" ? INSPECTION_EXPERIMENT_RESULT_BYTE_LIMIT : INSPECTION_RESULT_BYTE_LIMIT;
|
|
20417
|
+
const byteLimit = operation === "experiment.get" ? INSPECTION_EXPERIMENT_RESULT_BYTE_LIMIT : operation === "attempt.usage" ? INSPECTION_ATTEMPT_USAGE_RESULT_BYTE_LIMIT : INSPECTION_RESULT_BYTE_LIMIT;
|
|
19860
20418
|
if (utf8ByteLength$2(JSON.stringify(value)) > byteLimit) throw new InspectionOperationError({
|
|
19861
20419
|
code: "evidence-budget-exceeded",
|
|
19862
20420
|
operation,
|
|
@@ -19890,7 +20448,7 @@ function arraysEqual(left, right) {
|
|
|
19890
20448
|
function sourceProvenance(source, cutoff) {
|
|
19891
20449
|
return Object.freeze({
|
|
19892
20450
|
kind: source.kind,
|
|
19893
|
-
|
|
20451
|
+
publicationCutoffIdentity: cutoff.identity
|
|
19894
20452
|
});
|
|
19895
20453
|
}
|
|
19896
20454
|
function evaluateInspectionSuccess(operation, evaluate) {
|
|
@@ -19953,32 +20511,37 @@ function integrityFailure(operation, cause) {
|
|
|
19953
20511
|
}
|
|
19954
20512
|
//#endregion
|
|
19955
20513
|
//#region src/view/inspection-host.ts
|
|
19956
|
-
|
|
19957
|
-
|
|
19958
|
-
|
|
19959
|
-
|
|
19960
|
-
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19968
|
-
if (
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19973
|
-
|
|
19974
|
-
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
|
|
19980
|
-
|
|
19981
|
-
|
|
20514
|
+
function inspectViewGeneration(generation, input) {
|
|
20515
|
+
return Effect.suspend(() => {
|
|
20516
|
+
const decoded = decodeInspectionRequest(input);
|
|
20517
|
+
if (Result.isFailure(decoded)) return Effect.fail(decoded.failure);
|
|
20518
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
20519
|
+
const opened = yield* openHostOwnedInspectionSource(generation.recordPath);
|
|
20520
|
+
const facts = decoded.success.operation.kind === "project.get" && generation.target.kind === "current" ? Object.freeze({
|
|
20521
|
+
...opened,
|
|
20522
|
+
kind: "project-record"
|
|
20523
|
+
}) : opened;
|
|
20524
|
+
const cutoff = facts.cutoff();
|
|
20525
|
+
if (cutoff.identity !== generation.sourceCutoffIdentity) return yield* Effect.fail(/* @__PURE__ */ new Error("Pinned generation cutoff did not match its descriptor"));
|
|
20526
|
+
if (decoded.success.operation.kind === "project.get" && generation.target.kind === "current") {
|
|
20527
|
+
if (generation.target.input.cutoffIdentity !== cutoff.identity || generation.target.input.target.identity !== generation.target.identity) return yield* Effect.fail(/* @__PURE__ */ new Error("Pinned current target did not match its descriptor"));
|
|
20528
|
+
bindProjectInput(facts, {
|
|
20529
|
+
...generation.target.input,
|
|
20530
|
+
runs: loadSelectedInspectionRuns(facts, generation.target.input.runs.map((run) => run.run.runId))
|
|
20531
|
+
});
|
|
20532
|
+
}
|
|
20533
|
+
return selectInspectionOperation(facts, decoded.success.operation);
|
|
20534
|
+
})).pipe(Effect.catch(() => Effect.succeed(Object.freeze({
|
|
20535
|
+
protocol: QUERY_PROTOCOL,
|
|
20536
|
+
outcome: "failure",
|
|
20537
|
+
operation: decoded.success.operation.kind,
|
|
20538
|
+
failure: Object.freeze({
|
|
20539
|
+
code: "inspection-operation-failed",
|
|
20540
|
+
reason: "Inspection could not be completed for this generation.",
|
|
20541
|
+
correction: "retry"
|
|
20542
|
+
})
|
|
20543
|
+
}))));
|
|
20544
|
+
});
|
|
19982
20545
|
}
|
|
19983
20546
|
//#endregion
|
|
19984
20547
|
export { ViewGenerationDescriptorSchema, decodeGenerationCommitRequest, decodeViewInspectionRequest, inspectViewGeneration };
|