assertledger 1.0.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/CONTRIBUTING.md +31 -0
- package/LICENSE +21 -0
- package/README.fr.md +236 -0
- package/README.md +224 -0
- package/SECURITY.md +51 -0
- package/benchmarks/agentic-profile/README.md +15 -0
- package/benchmarks/agentic-profile/public/README.md +5 -0
- package/benchmarks/self-hosted-core/README.md +113 -0
- package/benchmarks/self-hosted-core/adapter.mjs +293 -0
- package/benchmarks/self-hosted-core/builder.ts +193 -0
- package/benchmarks/self-hosted-core/campaign.ts +233 -0
- package/benchmarks/self-hosted-core/existing-tests-builder.ts +217 -0
- package/benchmarks/self-hosted-core/existing-tests.ts +146 -0
- package/benchmarks/self-hosted-core/liveness.test.mjs +8 -0
- package/conformance/v1/bundle.json +104 -0
- package/conformance/v1/expected/canonical-order-a.json +4 -0
- package/conformance/v1/expected/canonical-order-b.json +4 -0
- package/conformance/v1/expected/create-benchmark-v1-measured.json +575 -0
- package/conformance/v1/expected/create-profile-v1-qualified.json +280 -0
- package/conformance/v1/expected/decide-collection-failure-non-kill.json +192 -0
- package/conformance/v1/expected/decide-compile-failure-non-kill.json +192 -0
- package/conformance/v1/expected/decide-infra-error-non-kill.json +192 -0
- package/conformance/v1/expected/decide-no-test-discovered-non-kill.json +192 -0
- package/conformance/v1/expected/decide-process-crash-non-kill.json +192 -0
- package/conformance/v1/expected/decide-timeout-non-kill.json +192 -0
- package/conformance/v1/expected/decide-verified.json +192 -0
- package/conformance/v1/expected/replay-benchmark-v1-resealed-summary-forgery.json +12 -0
- package/conformance/v1/expected/replay-evidence-raw-tamper.json +6 -0
- package/conformance/v1/expected/replay-evidence-resealed-semantic-forgery.json +6 -0
- package/conformance/v1/inputs/canonical-order-a.json +8 -0
- package/conformance/v1/inputs/canonical-order-b.json +8 -0
- package/conformance/v1/inputs/create-benchmark-v1-measured.json +459 -0
- package/conformance/v1/inputs/create-profile-v1-qualified.json +228 -0
- package/conformance/v1/inputs/decide-collection-failure-non-kill.json +143 -0
- package/conformance/v1/inputs/decide-compile-failure-non-kill.json +143 -0
- package/conformance/v1/inputs/decide-infra-error-non-kill.json +143 -0
- package/conformance/v1/inputs/decide-no-test-discovered-non-kill.json +143 -0
- package/conformance/v1/inputs/decide-process-crash-non-kill.json +143 -0
- package/conformance/v1/inputs/decide-timeout-non-kill.json +143 -0
- package/conformance/v1/inputs/decide-verified.json +143 -0
- package/conformance/v1/inputs/replay-benchmark-v1-resealed-summary-forgery.json +575 -0
- package/conformance/v1/inputs/replay-evidence-raw-tamper.json +201 -0
- package/conformance/v1/inputs/replay-evidence-resealed-semantic-forgery.json +192 -0
- package/conformance/v1/schemas/expected-digests.json +175 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +951 -0
- package/dist/cli.js.map +1 -0
- package/dist/contracts/diagnostics.d.ts +18 -0
- package/dist/contracts/diagnostics.d.ts.map +1 -0
- package/dist/contracts/diagnostics.js +13 -0
- package/dist/contracts/diagnostics.js.map +1 -0
- package/dist/contracts/index.d.ts +3908 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +2569 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/runtime-doctor.d.ts +107 -0
- package/dist/contracts/runtime-doctor.d.ts.map +1 -0
- package/dist/contracts/runtime-doctor.js +91 -0
- package/dist/contracts/runtime-doctor.js.map +1 -0
- package/dist/core/index.d.ts +200 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2587 -0
- package/dist/core/index.js.map +1 -0
- package/dist/diagnostics.d.ts +7 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +252 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/engine/adapters/node-test-profile.d.ts +14 -0
- package/dist/engine/adapters/node-test-profile.d.ts.map +1 -0
- package/dist/engine/adapters/node-test-profile.js +14 -0
- package/dist/engine/adapters/node-test-profile.js.map +1 -0
- package/dist/engine/adapters/node-test-runtime.d.ts +39 -0
- package/dist/engine/adapters/node-test-runtime.d.ts.map +1 -0
- package/dist/engine/adapters/node-test-runtime.js +173 -0
- package/dist/engine/adapters/node-test-runtime.js.map +1 -0
- package/dist/engine/adapters/runtime-facts.d.ts +26 -0
- package/dist/engine/adapters/runtime-facts.d.ts.map +1 -0
- package/dist/engine/adapters/runtime-facts.js +73 -0
- package/dist/engine/adapters/runtime-facts.js.map +1 -0
- package/dist/engine/connection.d.ts +22 -0
- package/dist/engine/connection.d.ts.map +1 -0
- package/dist/engine/connection.js +343 -0
- package/dist/engine/connection.js.map +1 -0
- package/dist/engine/git-regression.d.ts +25 -0
- package/dist/engine/git-regression.d.ts.map +1 -0
- package/dist/engine/git-regression.js +803 -0
- package/dist/engine/git-regression.js.map +1 -0
- package/dist/engine/index.d.ts +55 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +2782 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/node-test-reporter.d.ts +2 -0
- package/dist/engine/node-test-reporter.d.ts.map +1 -0
- package/dist/engine/node-test-reporter.js +70 -0
- package/dist/engine/node-test-reporter.js.map +1 -0
- package/dist/engine/runtime-doctor.d.ts +16 -0
- package/dist/engine/runtime-doctor.d.ts.map +1 -0
- package/dist/engine/runtime-doctor.js +100 -0
- package/dist/engine/runtime-doctor.js.map +1 -0
- package/dist/evaluation/agentic-corpus.d.ts +161 -0
- package/dist/evaluation/agentic-corpus.d.ts.map +1 -0
- package/dist/evaluation/agentic-corpus.js +710 -0
- package/dist/evaluation/agentic-corpus.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +391 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/stdio.d.ts +3 -0
- package/dist/mcp/stdio.d.ts.map +1 -0
- package/dist/mcp/stdio.js +13 -0
- package/dist/mcp/stdio.js.map +1 -0
- package/dist/sdk/index.d.ts +52 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +224 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/docs/adapter-protocol.md +196 -0
- package/docs/agentic-benchmark.md +118 -0
- package/docs/agentic-corpus-experiment-h3.md +89 -0
- package/docs/agentic-corpus-plan.md +105 -0
- package/docs/agentic-corpus-provenance.md +59 -0
- package/docs/agentic-test-profile-pilot.md +57 -0
- package/docs/agentic-test-profile-v2.md +116 -0
- package/docs/agentic-test-profile.md +274 -0
- package/docs/architecture.md +157 -0
- package/docs/ci.md +37 -0
- package/docs/client-connections.md +61 -0
- package/docs/conformance-v1.md +72 -0
- package/docs/decisions/0001-typescript-runtime.md +24 -0
- package/docs/developer-experience.md +55 -0
- package/docs/diagnostics.md +35 -0
- package/docs/distribution.md +40 -0
- package/docs/git-regression.md +39 -0
- package/docs/migration-repository-validation-order.md +35 -0
- package/docs/migration-testforge-to-assertledger.md +64 -0
- package/docs/project-intent.md +173 -0
- package/docs/proof-model.md +116 -0
- package/docs/reference.md +336 -0
- package/docs/release-1.0.md +63 -0
- package/docs/repository-audit.md +52 -0
- package/docs/repository-init.md +60 -0
- package/docs/research-basis.md +27 -0
- package/docs/roadmap.md +74 -0
- package/docs/runtime-doctor.md +65 -0
- package/docs/testexplora-calibration.md +71 -0
- package/examples/agentic-benchmark/benchmark-request.mjs +19 -0
- package/examples/agentic-benchmark/structured-phase-adapter-fixture.mjs +35 -0
- package/examples/agentic-profile/profile-benchmark.mjs +34 -0
- package/examples/agentic-profile/profile-manifest.mjs +28 -0
- package/examples/git-history/README.md +44 -0
- package/examples/git-history/create-demo.mjs +128 -0
- package/examples/git-history/escape-string-regexp/LICENSE +9 -0
- package/examples/git-history/escape-string-regexp/before.cjs.txt +11 -0
- package/examples/git-history/escape-string-regexp/fixed.cjs.txt +13 -0
- package/examples/git-history/escape-string-regexp/provenance.json +28 -0
- package/examples/node-test/repository/package.json +5 -0
- package/examples/node-test/repository/src/is-even.js +3 -0
- package/examples/node-test/repository/tests/base.test.js +6 -0
- package/examples/node-test/request.json +93 -0
- package/integrations/skill/SKILL.md +51 -0
- package/package.json +88 -0
- package/schemas/agentic-benchmark-acquisition-replay-result.v1.json +70 -0
- package/schemas/agentic-benchmark-acquisition-request.v1.json +564 -0
- package/schemas/agentic-benchmark-acquisition-result.v1.json +1409 -0
- package/schemas/agentic-benchmark-artifact.v1.json +1251 -0
- package/schemas/agentic-benchmark-replay-result.v1.json +84 -0
- package/schemas/agentic-benchmark-request.v1.json +1034 -0
- package/schemas/agentic-corpus-allocation-commitment-replay-result.v1.json +58 -0
- package/schemas/agentic-corpus-allocation-commitment.v1.json +141 -0
- package/schemas/agentic-corpus-allocation-replay-result.v1.json +34 -0
- package/schemas/agentic-corpus-allocation-request.v1.json +65 -0
- package/schemas/agentic-corpus-allocation-reveal.v1.json +66 -0
- package/schemas/agentic-corpus-allocation.v1.json +167 -0
- package/schemas/agentic-corpus-experiment-artifact.v1.json +329 -0
- package/schemas/agentic-corpus-experiment-plan-replay-result.v1.json +50 -0
- package/schemas/agentic-corpus-experiment-plan.v1.json +424 -0
- package/schemas/agentic-corpus-experiment-replay-request.v1.json +336 -0
- package/schemas/agentic-corpus-experiment-replay-result.v1.json +106 -0
- package/schemas/agentic-corpus-experiment-request.v1.json +204 -0
- package/schemas/agentic-corpus-provenance.v1.json +143 -0
- package/schemas/agentic-corpus-trust-policy.v1.json +133 -0
- package/schemas/agentic-profile-replay-result.v1.json +56 -0
- package/schemas/agentic-profile-replay-result.v2.json +63 -0
- package/schemas/agentic-profile-report.v1.json +961 -0
- package/schemas/agentic-profile-report.v2.json +1674 -0
- package/schemas/agentic-profile-request.v1.json +671 -0
- package/schemas/agentic-profile-request.v2.json +1338 -0
- package/schemas/evidence-manifest.v1.json +636 -0
- package/schemas/replay-result.v1.json +49 -0
- package/schemas/repository-analysis.v1.json +119 -0
- package/schemas/repository-audit.v1.json +811 -0
- package/schemas/repository-init-config.v1.json +183 -0
- package/schemas/repository-init-lock.v1.json +162 -0
- package/schemas/repository-init-result.v1.json +212 -0
- package/schemas/verification-request.v1.json +389 -0
|
@@ -0,0 +1,2569 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
export * from "./runtime-doctor.js";
|
|
5
|
+
export const SCHEMA_VERSION = "1.0.0";
|
|
6
|
+
export const POLICY_VERSION = "1.0.0";
|
|
7
|
+
const IdentifierSchema = z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(128)
|
|
11
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
12
|
+
const Sha256DigestSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
13
|
+
const ReasonCodeSchema = z
|
|
14
|
+
.string()
|
|
15
|
+
.min(1)
|
|
16
|
+
.max(128)
|
|
17
|
+
.regex(/^[A-Z][A-Z0-9_]*$/);
|
|
18
|
+
export const ObservationOutcomeSchema = z.enum([
|
|
19
|
+
"PASS",
|
|
20
|
+
"ASSERTION_FAILURE",
|
|
21
|
+
"COLLECTION_FAILURE",
|
|
22
|
+
"COMPILE_FAILURE",
|
|
23
|
+
"PROCESS_CRASH",
|
|
24
|
+
"TIMEOUT",
|
|
25
|
+
"INFRA_ERROR",
|
|
26
|
+
"NO_TEST_DISCOVERED",
|
|
27
|
+
]);
|
|
28
|
+
export const FileOverlaySchema = z.strictObject({
|
|
29
|
+
path: z.string().min(1).max(512),
|
|
30
|
+
content: z.string().max(1_048_576),
|
|
31
|
+
});
|
|
32
|
+
export const WorldSchema = z.strictObject({
|
|
33
|
+
id: IdentifierSchema,
|
|
34
|
+
kind: z.enum(["REFERENCE", "TARGET", "NEUTRAL"]),
|
|
35
|
+
required: z.boolean(),
|
|
36
|
+
weight: z.int().min(0).max(1_000_000),
|
|
37
|
+
provenance: z.string().min(1).max(1_024),
|
|
38
|
+
files: z.array(FileOverlaySchema).max(1_000),
|
|
39
|
+
});
|
|
40
|
+
export const CandidateSchema = z.strictObject({
|
|
41
|
+
id: IdentifierSchema,
|
|
42
|
+
files: z.array(FileOverlaySchema).min(1).max(100),
|
|
43
|
+
});
|
|
44
|
+
export const NodeTestAdapterSchema = z.strictObject({
|
|
45
|
+
kind: z.literal("node-test"),
|
|
46
|
+
executable: z.string().min(1),
|
|
47
|
+
baseTestFiles: z.array(z.string().min(1)).min(1).max(1_000),
|
|
48
|
+
extraArguments: z.array(z.string()).max(0).optional(),
|
|
49
|
+
});
|
|
50
|
+
export const StructuredCommandAdapterSchema = z.strictObject({
|
|
51
|
+
kind: z.literal("testforge-command"),
|
|
52
|
+
executable: z.string().min(1),
|
|
53
|
+
arguments: z.array(z.string()).max(100),
|
|
54
|
+
protocolVersion: z.literal("1.0.0"),
|
|
55
|
+
});
|
|
56
|
+
export const AdapterSchema = z.discriminatedUnion("kind", [
|
|
57
|
+
NodeTestAdapterSchema,
|
|
58
|
+
StructuredCommandAdapterSchema,
|
|
59
|
+
]);
|
|
60
|
+
export const StructuredCommandSchema = z.strictObject({
|
|
61
|
+
executable: z.string().min(1).max(512),
|
|
62
|
+
arguments: z.array(z.string().max(1_024)).max(100),
|
|
63
|
+
});
|
|
64
|
+
const EnvironmentVariableSchema = z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1)
|
|
67
|
+
.max(128)
|
|
68
|
+
.regex(/^(?!(?:[Nn][Oo][Dd][Ee]_[Oo][Pp][Tt][Ii][Oo][Nn][Ss]$|[Tt][Ee][Ss][Tt][Ff][Oo][Rr][Gg][Ee]_|[Nn][Oo][Dd][Ee]_[Tt][Ee][Ss][Tt]_)).+$/);
|
|
69
|
+
export const TrustedLocalIsolationSchema = z.strictObject({
|
|
70
|
+
kind: z.literal("trusted-local"),
|
|
71
|
+
acknowledgedUnsafeExecution: z.boolean(),
|
|
72
|
+
environmentAllowlist: z.array(EnvironmentVariableSchema).max(100),
|
|
73
|
+
});
|
|
74
|
+
export const BudgetsSchema = z.strictObject({
|
|
75
|
+
maximumCandidates: z.int().min(1).max(1_000),
|
|
76
|
+
maximumWorlds: z.int().min(3).max(1_000),
|
|
77
|
+
maximumExecutions: z.int().min(1).max(1_000_000),
|
|
78
|
+
maximumRepositoryFiles: z.int().min(1).max(10_000_000),
|
|
79
|
+
maximumRepositoryBytes: z.int().min(1).max(1_000_000_000_000),
|
|
80
|
+
maximumWorldOverlayBytes: z.int().min(1).max(1_000_000_000_000),
|
|
81
|
+
maximumCandidateBytes: z.int().min(1).max(100_000_000),
|
|
82
|
+
maximumTotalCandidateBytes: z.int().min(1).max(100_000_000_000),
|
|
83
|
+
timeoutMsPerExecution: z.int().min(10).max(86_400_000),
|
|
84
|
+
maximumOutputBytes: z.int().min(128).max(100_000_000),
|
|
85
|
+
});
|
|
86
|
+
export const PolicySchema = z.strictObject({
|
|
87
|
+
policyVersion: z.literal(POLICY_VERSION),
|
|
88
|
+
requiredAttempts: z.int().min(1).max(1_000),
|
|
89
|
+
minimumTargetWeightPermille: z.int().min(1).max(1_000),
|
|
90
|
+
maximumSelectedCandidates: z.int().min(1).max(1_000),
|
|
91
|
+
acceptedTargetOutcomes: z.array(z.literal("ASSERTION_FAILURE")).length(1),
|
|
92
|
+
});
|
|
93
|
+
export const VerificationRequestSchema = z
|
|
94
|
+
.strictObject({
|
|
95
|
+
schemaVersion: z.literal(SCHEMA_VERSION),
|
|
96
|
+
repository: z.strictObject({
|
|
97
|
+
root: z.string().min(1),
|
|
98
|
+
exclude: z.array(z.string().min(1).max(512)).max(1_000),
|
|
99
|
+
}),
|
|
100
|
+
adapter: AdapterSchema,
|
|
101
|
+
isolation: TrustedLocalIsolationSchema,
|
|
102
|
+
candidateRoots: z.array(z.string().min(1).max(512)).min(1).max(100),
|
|
103
|
+
budgets: BudgetsSchema,
|
|
104
|
+
policy: PolicySchema,
|
|
105
|
+
worlds: z.array(WorldSchema).min(1).max(1_000),
|
|
106
|
+
candidates: z.array(CandidateSchema).min(1).max(1_000),
|
|
107
|
+
})
|
|
108
|
+
.meta({
|
|
109
|
+
id: "https://testforge.dev/schemas/verification-request.v1.json",
|
|
110
|
+
title: "TestForge verification request",
|
|
111
|
+
description: "A versioned campaign describing operator-owned worlds, candidate test overlays, budgets, and evidence policy.",
|
|
112
|
+
});
|
|
113
|
+
export const RepositoryAnalysisSchema = z
|
|
114
|
+
.strictObject({
|
|
115
|
+
root: z.string().min(1),
|
|
116
|
+
fileCount: z.int().min(0),
|
|
117
|
+
files: z.array(z.string().min(1).max(1_024)).max(1_000_000),
|
|
118
|
+
languages: z.array(z.strictObject({
|
|
119
|
+
name: z.string().min(1).max(128),
|
|
120
|
+
files: z.int().min(1),
|
|
121
|
+
})),
|
|
122
|
+
detectedTestFrameworks: z.array(z.string().min(1).max(128)),
|
|
123
|
+
repositoryDigest: Sha256DigestSchema,
|
|
124
|
+
capabilities: z.strictObject({
|
|
125
|
+
canExecuteCandidates: z.boolean(),
|
|
126
|
+
supportedAdapters: z.array(z.enum(["node-test", "testforge-command"])),
|
|
127
|
+
isolationLevels: z.array(z.literal("UNSANDBOXED")),
|
|
128
|
+
}),
|
|
129
|
+
})
|
|
130
|
+
.meta({
|
|
131
|
+
id: "https://testforge.dev/schemas/repository-analysis.v1.json",
|
|
132
|
+
title: "TestForge repository analysis",
|
|
133
|
+
description: "A deterministic repository inventory and the execution capabilities exposed by TestForge.",
|
|
134
|
+
});
|
|
135
|
+
const NullableNonNegativeIntegerSchema = z.int().min(0).nullable();
|
|
136
|
+
export const RepositoryAuditSchema = z
|
|
137
|
+
.strictObject({
|
|
138
|
+
schemaVersion: z.literal("1.0.0"),
|
|
139
|
+
root: z.string().min(1),
|
|
140
|
+
repositoryDigest: Sha256DigestSchema,
|
|
141
|
+
fileCount: z.int().min(0),
|
|
142
|
+
repositoryBytes: z.int().min(0),
|
|
143
|
+
reasonCodes: z.array(ReasonCodeSchema),
|
|
144
|
+
git: z.strictObject({
|
|
145
|
+
supported: z.boolean(),
|
|
146
|
+
headTimestamp: z.int().min(0).nullable(),
|
|
147
|
+
windowDays: z.literal(90),
|
|
148
|
+
maximumCommits: z.literal(1_000),
|
|
149
|
+
shallow: z.boolean().nullable(),
|
|
150
|
+
truncated: z.boolean().nullable(),
|
|
151
|
+
}),
|
|
152
|
+
files: z.array(z.strictObject({
|
|
153
|
+
path: z.string().min(1).max(1_024),
|
|
154
|
+
language: z.string().min(1).max(128).nullable(),
|
|
155
|
+
supported: z.boolean(),
|
|
156
|
+
bytes: z.int().min(0),
|
|
157
|
+
decisionPoints: NullableNonNegativeIntegerSchema,
|
|
158
|
+
declaredExports: z.array(z.string().min(1).max(256)).nullable(),
|
|
159
|
+
noObservedTestReference: z.array(z.string().min(1).max(256)).nullable(),
|
|
160
|
+
associatedTests: z.array(z.string().min(1).max(1_024)),
|
|
161
|
+
sourceChangedAfterAssociatedTest: z.boolean().nullable(),
|
|
162
|
+
commitsInWindow: NullableNonNegativeIntegerSchema,
|
|
163
|
+
fixCommitsInWindow: NullableNonNegativeIntegerSchema,
|
|
164
|
+
weakAssertions: z
|
|
165
|
+
.array(z.strictObject({
|
|
166
|
+
category: z.enum([
|
|
167
|
+
"TRUTHINESS_ONLY",
|
|
168
|
+
"CONSTANT_BOOLEAN_EQUALITY",
|
|
169
|
+
"DEFINEDNESS_ONLY",
|
|
170
|
+
"NON_THROW_ONLY",
|
|
171
|
+
"TYPE_ONLY",
|
|
172
|
+
]),
|
|
173
|
+
count: z.int().min(1),
|
|
174
|
+
}))
|
|
175
|
+
.nullable(),
|
|
176
|
+
})),
|
|
177
|
+
modules: z.array(z.strictObject({
|
|
178
|
+
pathPrefix: z.string().min(1).max(1_024),
|
|
179
|
+
rank: z.int().min(1),
|
|
180
|
+
files: z.int().min(1),
|
|
181
|
+
factualTuple: z.tuple([
|
|
182
|
+
z.int().min(0),
|
|
183
|
+
z.int().min(0),
|
|
184
|
+
z.int().min(0),
|
|
185
|
+
z.int().min(0),
|
|
186
|
+
z.int().min(0),
|
|
187
|
+
z.int().min(0),
|
|
188
|
+
]),
|
|
189
|
+
})),
|
|
190
|
+
cost: z.strictObject({
|
|
191
|
+
candidates: z.int().min(0),
|
|
192
|
+
worlds: z.int().min(0),
|
|
193
|
+
attempts: z.int().min(0),
|
|
194
|
+
executions: z.string().regex(/^\d+$/),
|
|
195
|
+
controlExecutions: z.string().regex(/^\d+$/),
|
|
196
|
+
candidateExecutions: z.string().regex(/^\d+$/),
|
|
197
|
+
overlayBytes: z.string().regex(/^\d+$/),
|
|
198
|
+
materializationBytes: z.string().regex(/^\d+$/),
|
|
199
|
+
timeoutLimitMs: z.string().regex(/^\d+$/),
|
|
200
|
+
capturedStreamLimitBytes: z.string().regex(/^\d+$/),
|
|
201
|
+
}),
|
|
202
|
+
verificationRequest: VerificationRequestSchema.nullable(),
|
|
203
|
+
})
|
|
204
|
+
.meta({
|
|
205
|
+
id: "https://testforge.dev/schemas/repository-audit.v1.json",
|
|
206
|
+
title: "AssertLedger repository audit",
|
|
207
|
+
description: "A deterministic static repository audit and campaign cost projection.",
|
|
208
|
+
});
|
|
209
|
+
const RepositoryInitEvidenceSchema = z.strictObject({
|
|
210
|
+
path: z.string().min(1).max(1_024),
|
|
211
|
+
digest: Sha256DigestSchema,
|
|
212
|
+
kind: z.enum(["PACKAGE_MANIFEST", "LOCKFILE", "TEST_SOURCE", "CI_CONFIG", "ADAPTER_CONFIG"]),
|
|
213
|
+
});
|
|
214
|
+
export const RepositoryInitDetectionsSchema = z.strictObject({
|
|
215
|
+
packageManager: z.enum(["pnpm", "npm", "yarn", "bun", "uv", "poetry", "pip"]).nullable(),
|
|
216
|
+
framework: z.enum(["node:test", "vitest", "jest", "bun:test", "pytest"]).nullable(),
|
|
217
|
+
testCommand: StructuredCommandSchema.nullable(),
|
|
218
|
+
ciProviders: z.array(z.enum(["github-actions", "gitlab-ci", "azure-pipelines", "circleci"])),
|
|
219
|
+
adapterRecommendation: z.enum(["node-test", "operator-supplied", "unavailable"]),
|
|
220
|
+
reasonCodes: z.array(ReasonCodeSchema),
|
|
221
|
+
});
|
|
222
|
+
export const RepositoryInitConfigSchema = z
|
|
223
|
+
.strictObject({
|
|
224
|
+
schemaVersion: z.literal(SCHEMA_VERSION),
|
|
225
|
+
repository: z.strictObject({
|
|
226
|
+
root: z.literal("."),
|
|
227
|
+
exclude: z.array(z.string().min(1).max(512)).max(1_000),
|
|
228
|
+
}),
|
|
229
|
+
packageManager: z.enum(["pnpm", "npm", "yarn", "bun", "uv", "poetry", "pip"]),
|
|
230
|
+
framework: z.enum(["node:test", "vitest", "jest", "bun:test", "pytest"]),
|
|
231
|
+
testCommand: StructuredCommandSchema,
|
|
232
|
+
adapter: AdapterSchema,
|
|
233
|
+
candidateRoots: z.array(z.string().min(1).max(512)).min(1).max(100),
|
|
234
|
+
})
|
|
235
|
+
.meta({
|
|
236
|
+
id: "https://testforge.dev/schemas/repository-init-config.v1.json",
|
|
237
|
+
title: "AssertLedger repository init config",
|
|
238
|
+
description: "Portable static configuration produced by assertledger init.",
|
|
239
|
+
});
|
|
240
|
+
export const RepositoryInitLockSchema = z
|
|
241
|
+
.strictObject({
|
|
242
|
+
schemaVersion: z.literal(SCHEMA_VERSION),
|
|
243
|
+
configDigest: Sha256DigestSchema,
|
|
244
|
+
detector: z.strictObject({
|
|
245
|
+
name: z.literal("assertledger-init"),
|
|
246
|
+
version: z.literal("1.0.0"),
|
|
247
|
+
}),
|
|
248
|
+
evidence: z.array(RepositoryInitEvidenceSchema),
|
|
249
|
+
detections: RepositoryInitDetectionsSchema,
|
|
250
|
+
lockDigest: Sha256DigestSchema,
|
|
251
|
+
})
|
|
252
|
+
.meta({
|
|
253
|
+
id: "https://testforge.dev/schemas/repository-init-lock.v1.json",
|
|
254
|
+
title: "AssertLedger repository init lock",
|
|
255
|
+
description: "Deterministic evidence lock binding an initialized repository configuration.",
|
|
256
|
+
});
|
|
257
|
+
export const RepositoryInitResultSchema = z
|
|
258
|
+
.strictObject({
|
|
259
|
+
schemaVersion: z.literal(SCHEMA_VERSION),
|
|
260
|
+
status: z.enum(["CREATED", "UNCHANGED", "WOULD_CREATE", "BLOCKED", "CONFLICT"]),
|
|
261
|
+
reasonCodes: z.array(ReasonCodeSchema),
|
|
262
|
+
detections: RepositoryInitDetectionsSchema,
|
|
263
|
+
actions: z.array(z.strictObject({
|
|
264
|
+
kind: z.enum(["CREATE", "REGENERATE"]),
|
|
265
|
+
path: z.enum(["assertledger.config.json", "assertledger.lock.json"]),
|
|
266
|
+
})),
|
|
267
|
+
files: z.array(z.strictObject({
|
|
268
|
+
path: z.enum(["assertledger.config.json", "assertledger.lock.json"]),
|
|
269
|
+
digest: Sha256DigestSchema,
|
|
270
|
+
content: z
|
|
271
|
+
.string()
|
|
272
|
+
.min(1)
|
|
273
|
+
.max(16 * 1024 * 1024),
|
|
274
|
+
})),
|
|
275
|
+
requiredOperatorInputs: z.tuple([z.literal("worlds"), z.literal("candidates")]),
|
|
276
|
+
nextCommands: z.array(StructuredCommandSchema),
|
|
277
|
+
})
|
|
278
|
+
.meta({
|
|
279
|
+
id: "https://testforge.dev/schemas/repository-init-result.v1.json",
|
|
280
|
+
title: "AssertLedger repository init result",
|
|
281
|
+
description: "Deterministic initialization plan and outcome without campaign execution.",
|
|
282
|
+
});
|
|
283
|
+
const EvidenceWorldSchema = z.strictObject({
|
|
284
|
+
id: IdentifierSchema,
|
|
285
|
+
kind: z.enum(["REFERENCE", "TARGET", "NEUTRAL"]),
|
|
286
|
+
required: z.boolean(),
|
|
287
|
+
weight: z.int().min(0).max(1_000_000),
|
|
288
|
+
});
|
|
289
|
+
const EvidenceContextSchema = z.strictObject({
|
|
290
|
+
engine: z.strictObject({
|
|
291
|
+
name: z.string().min(1).max(128),
|
|
292
|
+
version: z.string().min(1).max(128),
|
|
293
|
+
}),
|
|
294
|
+
adapter: z.strictObject({
|
|
295
|
+
name: z.string().min(1).max(128),
|
|
296
|
+
version: z.string().min(1).max(128),
|
|
297
|
+
configuration: z.json(),
|
|
298
|
+
}),
|
|
299
|
+
execution: z.strictObject({
|
|
300
|
+
isolation: z.string().min(1).max(128),
|
|
301
|
+
environmentAllowlist: z.array(z.string().min(1).max(128)).max(100),
|
|
302
|
+
budgets: z.json(),
|
|
303
|
+
candidateRoots: z.array(z.string().min(1).max(512)).max(100),
|
|
304
|
+
}),
|
|
305
|
+
worlds: z.array(z.strictObject({
|
|
306
|
+
id: IdentifierSchema,
|
|
307
|
+
provenance: z.string().min(1).max(1_024),
|
|
308
|
+
digest: Sha256DigestSchema,
|
|
309
|
+
})),
|
|
310
|
+
});
|
|
311
|
+
export const GateResultSchema = z.strictObject({
|
|
312
|
+
name: z.enum([
|
|
313
|
+
"COMPLETENESS",
|
|
314
|
+
"STABILITY",
|
|
315
|
+
"DISCOVERY",
|
|
316
|
+
"REFERENCE",
|
|
317
|
+
"NEUTRAL",
|
|
318
|
+
"TARGET_STRENGTH",
|
|
319
|
+
]),
|
|
320
|
+
status: z.enum(["PASSED", "FAILED", "NOT_RUN"]),
|
|
321
|
+
evidenceRunIds: z.array(z.string().min(1).max(512)),
|
|
322
|
+
reasonCodes: z.array(ReasonCodeSchema),
|
|
323
|
+
});
|
|
324
|
+
export const EvidenceObservationSchema = z.strictObject({
|
|
325
|
+
runId: z.string().min(1).max(512),
|
|
326
|
+
candidateId: IdentifierSchema.nullable(),
|
|
327
|
+
worldId: IdentifierSchema,
|
|
328
|
+
attempt: z.int().min(1),
|
|
329
|
+
outcome: ObservationOutcomeSchema,
|
|
330
|
+
testsDiscovered: z.int().min(0),
|
|
331
|
+
candidateTestsDiscovered: z.int().min(0),
|
|
332
|
+
attributed: z.boolean(),
|
|
333
|
+
durationMs: z.number().finite().min(0).optional(),
|
|
334
|
+
exitCode: z.int().min(0).nullable().optional(),
|
|
335
|
+
stdoutDigest: Sha256DigestSchema.optional(),
|
|
336
|
+
stderrDigest: Sha256DigestSchema.optional(),
|
|
337
|
+
});
|
|
338
|
+
export const CandidateAssessmentSchema = z.strictObject({
|
|
339
|
+
id: IdentifierSchema,
|
|
340
|
+
digest: Sha256DigestSchema,
|
|
341
|
+
sizeBytes: z.int().min(0),
|
|
342
|
+
status: z.enum(["ELIGIBLE", "UNSTABLE", "INCONCLUSIVE", "INVALID", "WEAK_ORACLE"]),
|
|
343
|
+
killedTargetIds: z.array(IdentifierSchema),
|
|
344
|
+
targetWeightKilled: z.int().min(0),
|
|
345
|
+
gates: z.array(GateResultSchema),
|
|
346
|
+
reasonCodes: z.array(ReasonCodeSchema),
|
|
347
|
+
});
|
|
348
|
+
const FinalAdapterSummarySchema = z.discriminatedUnion("kind", [
|
|
349
|
+
z.strictObject({ kind: z.literal("node-test") }),
|
|
350
|
+
z.strictObject({
|
|
351
|
+
kind: z.literal("testforge-command"),
|
|
352
|
+
protocolVersion: z.literal("1.0.0"),
|
|
353
|
+
}),
|
|
354
|
+
]);
|
|
355
|
+
const InvalidEvidencePolicySchema = z.strictObject({
|
|
356
|
+
policyVersion: z.literal("invalid"),
|
|
357
|
+
requiredAttempts: z.literal(1),
|
|
358
|
+
minimumTargetWeightPermille: z.literal(1_000),
|
|
359
|
+
maximumSelectedCandidates: z.literal(0),
|
|
360
|
+
acceptedTargetOutcomes: z.array(z.literal("ASSERTION_FAILURE")).max(0),
|
|
361
|
+
});
|
|
362
|
+
export const EvidenceManifestSchema = z
|
|
363
|
+
.strictObject({
|
|
364
|
+
schemaVersion: z.literal(SCHEMA_VERSION),
|
|
365
|
+
repositoryDigest: z.union([Sha256DigestSchema, z.literal("invalid")]),
|
|
366
|
+
evidenceContext: EvidenceContextSchema,
|
|
367
|
+
policy: z.union([PolicySchema, InvalidEvidencePolicySchema]),
|
|
368
|
+
worlds: z.array(EvidenceWorldSchema),
|
|
369
|
+
candidates: z.array(CandidateAssessmentSchema),
|
|
370
|
+
observations: z.array(EvidenceObservationSchema),
|
|
371
|
+
decision: z.strictObject({
|
|
372
|
+
status: z.enum(["VERIFIED", "REJECTED", "INCONCLUSIVE", "ENGINE_ERROR"]),
|
|
373
|
+
selectedCandidateIds: z.array(IdentifierSchema),
|
|
374
|
+
reasonCodes: z.array(ReasonCodeSchema),
|
|
375
|
+
}),
|
|
376
|
+
decisionDigest: Sha256DigestSchema,
|
|
377
|
+
artifactDigest: Sha256DigestSchema,
|
|
378
|
+
adapter: FinalAdapterSummarySchema,
|
|
379
|
+
isolation: z.strictObject({
|
|
380
|
+
kind: z.literal("trusted-local"),
|
|
381
|
+
level: z.literal("UNSANDBOXED"),
|
|
382
|
+
acknowledgedUnsafeExecution: z.literal(true),
|
|
383
|
+
}),
|
|
384
|
+
limitations: z.array(z.string().min(1).max(2_048)),
|
|
385
|
+
})
|
|
386
|
+
.meta({
|
|
387
|
+
id: "https://testforge.dev/schemas/evidence-manifest.v1.json",
|
|
388
|
+
title: "TestForge evidence manifest",
|
|
389
|
+
description: "The final auditable campaign artifact, including evidence, deterministic gates, decisions, and integrity digests.",
|
|
390
|
+
});
|
|
391
|
+
export const ReplayResultSchema = z
|
|
392
|
+
.strictObject({
|
|
393
|
+
valid: z.boolean(),
|
|
394
|
+
schemaValid: z.boolean(),
|
|
395
|
+
decisionDigestValid: z.boolean(),
|
|
396
|
+
artifactDigestValid: z.boolean(),
|
|
397
|
+
decisionSemanticsValid: z.boolean(),
|
|
398
|
+
})
|
|
399
|
+
.meta({
|
|
400
|
+
id: "https://testforge.dev/schemas/replay-result.v1.json",
|
|
401
|
+
title: "TestForge replay result",
|
|
402
|
+
description: "Independent integrity and semantic replay verdicts for a TestForge evidence manifest.",
|
|
403
|
+
});
|
|
404
|
+
export const AgenticProfileLaneSchema = z.strictObject({
|
|
405
|
+
id: IdentifierSchema,
|
|
406
|
+
maximumReferenceP95Ms: z.int().min(1).max(86_400_000),
|
|
407
|
+
});
|
|
408
|
+
export const AgenticProfilePolicySchema = z.strictObject({
|
|
409
|
+
profileVersion: z.literal("1.0.0"),
|
|
410
|
+
profileId: z.string().min(1).max(256),
|
|
411
|
+
mode: z.literal("HARDENING"),
|
|
412
|
+
minimumTimingSamples: z.int().min(1).max(1_000),
|
|
413
|
+
lanes: z.array(AgenticProfileLaneSchema).min(1).max(100),
|
|
414
|
+
});
|
|
415
|
+
// Embedded copies deliberately omit the standalone manifest's schema id. Some JSON Schema
|
|
416
|
+
// consumers interpret a nested id as a new resolution scope and cannot resolve its local $defs.
|
|
417
|
+
const EmbeddedEvidenceManifestSchema = z.strictObject({ ...EvidenceManifestSchema.shape });
|
|
418
|
+
export const AgenticProfileRequestSchema = z
|
|
419
|
+
.strictObject({
|
|
420
|
+
schemaVersion: z.literal("1.0.0"),
|
|
421
|
+
manifest: EmbeddedEvidenceManifestSchema,
|
|
422
|
+
policy: AgenticProfilePolicySchema,
|
|
423
|
+
})
|
|
424
|
+
.meta({
|
|
425
|
+
id: "https://testforge.dev/schemas/agentic-profile-request.v1.json",
|
|
426
|
+
title: "TestForge Agentic Test Profile request",
|
|
427
|
+
description: "A replay-valid evidence manifest and repository-scoped feedback policy.",
|
|
428
|
+
});
|
|
429
|
+
const AgenticProfileClassificationSchema = z.enum([
|
|
430
|
+
"QUALIFIED",
|
|
431
|
+
"BUDGET_MISSED",
|
|
432
|
+
"INSUFFICIENT_TIMING_EVIDENCE",
|
|
433
|
+
"NOT_QUALIFIED",
|
|
434
|
+
]);
|
|
435
|
+
const AgenticProfileCandidateSchema = z.strictObject({
|
|
436
|
+
id: IdentifierSchema,
|
|
437
|
+
evidenceStatus: z.enum(["ELIGIBLE", "UNSTABLE", "INCONCLUSIVE", "INVALID", "WEAK_ORACLE"]),
|
|
438
|
+
classification: AgenticProfileClassificationSchema,
|
|
439
|
+
satisfiedLaneIds: z.array(IdentifierSchema),
|
|
440
|
+
bestLaneId: IdentifierSchema.nullable(),
|
|
441
|
+
targetWeightKilled: z.int().min(0),
|
|
442
|
+
totalTargetWeight: z.int().min(0),
|
|
443
|
+
targetWeightPermille: z.int().min(0).max(1_000),
|
|
444
|
+
requiredTargetsKilled: z.int().min(0),
|
|
445
|
+
requiredTargetsTotal: z.int().min(0),
|
|
446
|
+
killedTargetIds: z.array(IdentifierSchema),
|
|
447
|
+
marginalTargetWeight: z.int().min(0),
|
|
448
|
+
consistency: z.strictObject({
|
|
449
|
+
claim: z.enum(["OBSERVED_CONSISTENT", "OBSERVED_INCONSISTENT"]),
|
|
450
|
+
attempts: z.int().min(0),
|
|
451
|
+
}),
|
|
452
|
+
latency: z.strictObject({
|
|
453
|
+
kind: z.literal("RECORDED_REFERENCE_WALL_TIME"),
|
|
454
|
+
samples: z.int().min(0),
|
|
455
|
+
minimumMs: z.number().finite().min(0).nullable(),
|
|
456
|
+
p50Ms: z.number().finite().min(0).nullable(),
|
|
457
|
+
p95Ms: z.number().finite().min(0).nullable(),
|
|
458
|
+
maximumMs: z.number().finite().min(0).nullable(),
|
|
459
|
+
totalCandidateDurationMs: z.number().finite().min(0),
|
|
460
|
+
}),
|
|
461
|
+
paretoFrontier: z.boolean(),
|
|
462
|
+
});
|
|
463
|
+
const AgenticProfilePortfolioSchema = z.strictObject({
|
|
464
|
+
laneId: IdentifierSchema,
|
|
465
|
+
budgetMs: z.int().min(1).max(86_400_000),
|
|
466
|
+
selectedCandidateIds: z.array(IdentifierSchema),
|
|
467
|
+
totalReferenceP95Ms: z.number().finite().min(0),
|
|
468
|
+
targetWeight: z.int().min(0),
|
|
469
|
+
targetWeightPermille: z.int().min(0).max(1_000),
|
|
470
|
+
requiredTargetsKilled: z.int().min(0),
|
|
471
|
+
requiredTargetsTotal: z.int().min(0),
|
|
472
|
+
});
|
|
473
|
+
export const AgenticProfileReportSchema = z
|
|
474
|
+
.strictObject({
|
|
475
|
+
schemaVersion: z.literal("1.0.0"),
|
|
476
|
+
sourceManifest: EmbeddedEvidenceManifestSchema,
|
|
477
|
+
sourceArtifactDigest: Sha256DigestSchema,
|
|
478
|
+
policy: AgenticProfilePolicySchema,
|
|
479
|
+
policyDigest: Sha256DigestSchema,
|
|
480
|
+
status: AgenticProfileClassificationSchema,
|
|
481
|
+
candidates: z.array(AgenticProfileCandidateSchema),
|
|
482
|
+
portfolios: z.array(AgenticProfilePortfolioSchema),
|
|
483
|
+
qualifiedCandidateIds: z.array(IdentifierSchema),
|
|
484
|
+
limitations: z.array(z.string().min(1).max(2_048)),
|
|
485
|
+
reportDigest: Sha256DigestSchema,
|
|
486
|
+
})
|
|
487
|
+
.meta({
|
|
488
|
+
id: "https://testforge.dev/schemas/agentic-profile-report.v1.json",
|
|
489
|
+
title: "TestForge Agentic Test Profile report",
|
|
490
|
+
description: "A self-contained, replayable profile of declared evidence and observed cost.",
|
|
491
|
+
});
|
|
492
|
+
export const AgenticProfileReplayResultSchema = z
|
|
493
|
+
.strictObject({
|
|
494
|
+
valid: z.boolean(),
|
|
495
|
+
schemaValid: z.boolean(),
|
|
496
|
+
sourceManifestValid: z.boolean(),
|
|
497
|
+
policyDigestValid: z.boolean(),
|
|
498
|
+
reportDigestValid: z.boolean(),
|
|
499
|
+
semanticsValid: z.boolean(),
|
|
500
|
+
})
|
|
501
|
+
.meta({
|
|
502
|
+
id: "https://testforge.dev/schemas/agentic-profile-replay-result.v1.json",
|
|
503
|
+
title: "TestForge Agentic Test Profile replay result",
|
|
504
|
+
description: "Independent schema, source, digest, and semantic replay verdicts for a profile.",
|
|
505
|
+
});
|
|
506
|
+
const BenchmarkPhaseNameSchema = z.enum([
|
|
507
|
+
"PREPARATION",
|
|
508
|
+
"STARTUP",
|
|
509
|
+
"COMPILE_OR_COLLECTION",
|
|
510
|
+
"EXECUTION",
|
|
511
|
+
]);
|
|
512
|
+
export const AgenticBenchmarkPolicySchema = z.strictObject({
|
|
513
|
+
benchmarkVersion: z.literal("1.0.0"),
|
|
514
|
+
minimumMeasuredSamplesPerRegime: z.int().min(1).max(1_000),
|
|
515
|
+
coldMeasuredSamples: z.int().min(1).max(1_000),
|
|
516
|
+
warmupSamples: z.int().min(1).max(1_000),
|
|
517
|
+
warmMeasuredSamples: z.int().min(1).max(1_000),
|
|
518
|
+
maximumExecutions: z.int().min(1).max(1_000_000),
|
|
519
|
+
});
|
|
520
|
+
export const AgenticBenchmarkProtocolSchema = z.strictObject({
|
|
521
|
+
protocolVersion: z.literal("1.0.0"),
|
|
522
|
+
clock: z.literal("MONOTONIC"),
|
|
523
|
+
unit: z.literal("MICROSECOND"),
|
|
524
|
+
quantile: z.literal("NEAREST_RANK"),
|
|
525
|
+
phases: z.tuple([
|
|
526
|
+
z.literal("PREPARATION"),
|
|
527
|
+
z.literal("STARTUP"),
|
|
528
|
+
z.literal("COMPILE_OR_COLLECTION"),
|
|
529
|
+
z.literal("EXECUTION"),
|
|
530
|
+
]),
|
|
531
|
+
coldDefinition: z.literal("FRESH_WORKSPACE_FRESH_PROCESS_RESET_DECLARED_CACHES"),
|
|
532
|
+
warmDefinition: z.literal("FRESH_WORKSPACE_FRESH_PROCESS_RETAIN_DECLARED_CACHES"),
|
|
533
|
+
});
|
|
534
|
+
const AgenticBenchmarkToolSchema = z.strictObject({
|
|
535
|
+
role: IdentifierSchema,
|
|
536
|
+
name: z.string().min(1).max(256),
|
|
537
|
+
version: z.string().min(1).max(256),
|
|
538
|
+
digest: Sha256DigestSchema,
|
|
539
|
+
configurationDigest: Sha256DigestSchema,
|
|
540
|
+
});
|
|
541
|
+
export const AgenticBenchmarkFingerprintSchema = z.strictObject({
|
|
542
|
+
environmentId: IdentifierSchema,
|
|
543
|
+
os: z.strictObject({
|
|
544
|
+
platform: z.string().min(1).max(128),
|
|
545
|
+
release: z.string().min(1).max(128),
|
|
546
|
+
arch: z.string().min(1).max(128),
|
|
547
|
+
}),
|
|
548
|
+
cpu: z.strictObject({
|
|
549
|
+
arch: z.string().min(1).max(128),
|
|
550
|
+
model: z.string().min(1).max(512),
|
|
551
|
+
logicalCores: z.int().min(1).max(1_000_000),
|
|
552
|
+
}),
|
|
553
|
+
logicalCpuLimit: z.int().min(1).max(1_000_000).nullable(),
|
|
554
|
+
memoryLimitBytes: z.int().min(1).max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
555
|
+
executionBoundary: z.literal("UNSANDBOXED"),
|
|
556
|
+
tools: z.array(AgenticBenchmarkToolSchema).min(1).max(100),
|
|
557
|
+
dependencyGraphDigest: Sha256DigestSchema,
|
|
558
|
+
phaseReporterDigest: Sha256DigestSchema,
|
|
559
|
+
});
|
|
560
|
+
const AgenticBenchmarkPhaseTimingSchema = z.strictObject({
|
|
561
|
+
phase: BenchmarkPhaseNameSchema,
|
|
562
|
+
durationUs: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
563
|
+
});
|
|
564
|
+
const AgenticBenchmarkRunBaseSchema = z.strictObject({
|
|
565
|
+
candidateId: IdentifierSchema,
|
|
566
|
+
candidateDigest: Sha256DigestSchema,
|
|
567
|
+
regime: z.enum(["COLD", "WARM"]),
|
|
568
|
+
role: z.enum(["WARMUP", "MEASUREMENT"]),
|
|
569
|
+
ordinal: z.int().min(1).max(1_000_000),
|
|
570
|
+
});
|
|
571
|
+
const AgenticBenchmarkCompleteRunSchema = AgenticBenchmarkRunBaseSchema.extend({
|
|
572
|
+
status: z.literal("COMPLETE"),
|
|
573
|
+
outcome: z.literal("PASS"),
|
|
574
|
+
phases: z.array(AgenticBenchmarkPhaseTimingSchema).length(4),
|
|
575
|
+
totalUs: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
576
|
+
cpuTimeUs: z.int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
577
|
+
});
|
|
578
|
+
const AgenticBenchmarkIncompleteRunSchema = AgenticBenchmarkRunBaseSchema.extend({
|
|
579
|
+
status: z.literal("INCOMPLETE"),
|
|
580
|
+
outcome: z.enum([
|
|
581
|
+
"ASSERTION_FAILURE",
|
|
582
|
+
"COLLECTION_FAILURE",
|
|
583
|
+
"COMPILE_FAILURE",
|
|
584
|
+
"PROCESS_CRASH",
|
|
585
|
+
"TIMEOUT",
|
|
586
|
+
"INFRA_ERROR",
|
|
587
|
+
"NO_TEST_DISCOVERED",
|
|
588
|
+
]),
|
|
589
|
+
phases: z.null(),
|
|
590
|
+
totalUs: z.null(),
|
|
591
|
+
cpuTimeUs: z.null(),
|
|
592
|
+
});
|
|
593
|
+
export const AgenticBenchmarkRunSchema = z.discriminatedUnion("status", [
|
|
594
|
+
AgenticBenchmarkCompleteRunSchema,
|
|
595
|
+
AgenticBenchmarkIncompleteRunSchema,
|
|
596
|
+
]);
|
|
597
|
+
export const AgenticBenchmarkRequestSchema = z
|
|
598
|
+
.strictObject({
|
|
599
|
+
schemaVersion: z.literal("1.0.0"),
|
|
600
|
+
sourceManifest: EmbeddedEvidenceManifestSchema,
|
|
601
|
+
referenceWorldId: IdentifierSchema,
|
|
602
|
+
policy: AgenticBenchmarkPolicySchema,
|
|
603
|
+
protocol: AgenticBenchmarkProtocolSchema,
|
|
604
|
+
fingerprint: AgenticBenchmarkFingerprintSchema,
|
|
605
|
+
runs: z.array(AgenticBenchmarkRunSchema).max(1_000_000),
|
|
606
|
+
})
|
|
607
|
+
.meta({
|
|
608
|
+
id: "https://testforge.dev/schemas/agentic-benchmark-request.v1.json",
|
|
609
|
+
title: "TestForge Agentic Benchmark request",
|
|
610
|
+
description: "A replay-valid source manifest and raw cold/warm benchmark observations.",
|
|
611
|
+
});
|
|
612
|
+
const AgenticBenchmarkQuantilesSchema = z.strictObject({
|
|
613
|
+
minimumUs: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
614
|
+
p50Us: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
615
|
+
p95Us: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
616
|
+
maximumUs: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
617
|
+
});
|
|
618
|
+
const AgenticBenchmarkWallSummarySchema = z.strictObject({
|
|
619
|
+
total: AgenticBenchmarkQuantilesSchema.nullable(),
|
|
620
|
+
phases: z.strictObject({
|
|
621
|
+
PREPARATION: AgenticBenchmarkQuantilesSchema.nullable(),
|
|
622
|
+
STARTUP: AgenticBenchmarkQuantilesSchema.nullable(),
|
|
623
|
+
COMPILE_OR_COLLECTION: AgenticBenchmarkQuantilesSchema.nullable(),
|
|
624
|
+
EXECUTION: AgenticBenchmarkQuantilesSchema.nullable(),
|
|
625
|
+
}),
|
|
626
|
+
});
|
|
627
|
+
const AgenticBenchmarkSummarySchema = z.strictObject({
|
|
628
|
+
candidateId: IdentifierSchema,
|
|
629
|
+
candidateDigest: Sha256DigestSchema,
|
|
630
|
+
regime: z.enum(["COLD", "WARM"]),
|
|
631
|
+
status: z.enum(["MEASURED", "INSUFFICIENT_SAMPLES", "OBSERVED_RUN_FAILURE"]),
|
|
632
|
+
counters: z.strictObject({
|
|
633
|
+
planned: z.int().min(1).max(1_000),
|
|
634
|
+
recorded: z.int().min(0).max(1_000),
|
|
635
|
+
accepted: z.int().min(0).max(1_000),
|
|
636
|
+
failed: z.int().min(0).max(2_000),
|
|
637
|
+
warmup: z.int().min(0).max(1_000),
|
|
638
|
+
}),
|
|
639
|
+
wall: AgenticBenchmarkWallSummarySchema,
|
|
640
|
+
cpu: z.strictObject({
|
|
641
|
+
availability: z.enum(["UNAVAILABLE", "PARTIAL", "COMPLETE"]),
|
|
642
|
+
quantiles: AgenticBenchmarkQuantilesSchema.nullable(),
|
|
643
|
+
}),
|
|
644
|
+
});
|
|
645
|
+
export const AgenticBenchmarkArtifactSchema = z
|
|
646
|
+
.strictObject({
|
|
647
|
+
schemaVersion: z.literal("1.0.0"),
|
|
648
|
+
sourceManifest: EmbeddedEvidenceManifestSchema,
|
|
649
|
+
sourceArtifactDigest: Sha256DigestSchema,
|
|
650
|
+
sourceDecisionDigest: Sha256DigestSchema,
|
|
651
|
+
referenceWorldId: IdentifierSchema,
|
|
652
|
+
policy: AgenticBenchmarkPolicySchema,
|
|
653
|
+
protocol: AgenticBenchmarkProtocolSchema,
|
|
654
|
+
fingerprint: AgenticBenchmarkFingerprintSchema,
|
|
655
|
+
policyDigest: Sha256DigestSchema,
|
|
656
|
+
protocolDigest: Sha256DigestSchema,
|
|
657
|
+
fingerprintDigest: Sha256DigestSchema,
|
|
658
|
+
comparisonScopeDigest: Sha256DigestSchema,
|
|
659
|
+
runs: z.array(AgenticBenchmarkRunSchema).max(1_000_000),
|
|
660
|
+
summaries: z.array(AgenticBenchmarkSummarySchema).min(1).max(2_000),
|
|
661
|
+
limitations: z.array(z.string().min(1).max(2_048)),
|
|
662
|
+
artifactDigest: Sha256DigestSchema,
|
|
663
|
+
})
|
|
664
|
+
.meta({
|
|
665
|
+
id: "https://testforge.dev/schemas/agentic-benchmark-artifact.v1.json",
|
|
666
|
+
title: "TestForge Agentic Benchmark artifact",
|
|
667
|
+
description: "A self-contained replayable cold/warm benchmark artifact.",
|
|
668
|
+
});
|
|
669
|
+
export const AgenticBenchmarkReplayResultSchema = z
|
|
670
|
+
.strictObject({
|
|
671
|
+
valid: z.boolean(),
|
|
672
|
+
schemaValid: z.boolean(),
|
|
673
|
+
sourceManifestValid: z.boolean(),
|
|
674
|
+
sourceBindingValid: z.boolean(),
|
|
675
|
+
policyDigestValid: z.boolean(),
|
|
676
|
+
protocolDigestValid: z.boolean(),
|
|
677
|
+
fingerprintDigestValid: z.boolean(),
|
|
678
|
+
comparisonScopeDigestValid: z.boolean(),
|
|
679
|
+
artifactDigestValid: z.boolean(),
|
|
680
|
+
summarySemanticsValid: z.boolean(),
|
|
681
|
+
})
|
|
682
|
+
.meta({
|
|
683
|
+
id: "https://testforge.dev/schemas/agentic-benchmark-replay-result.v1.json",
|
|
684
|
+
title: "TestForge Agentic Benchmark replay result",
|
|
685
|
+
description: "Independent integrity and semantic replay rails for a benchmark artifact.",
|
|
686
|
+
});
|
|
687
|
+
const AgenticBenchmarkAcquisitionIdentityFilesSchema = z.strictObject({
|
|
688
|
+
phaseReporter: z.string().min(1).max(512),
|
|
689
|
+
dependencyGraph: z.array(z.string().min(1).max(512)).min(1).max(100),
|
|
690
|
+
});
|
|
691
|
+
const EmbeddedVerificationRequestSchema = z.strictObject({ ...VerificationRequestSchema.shape });
|
|
692
|
+
export const AgenticBenchmarkAcquisitionRequestSchema = z
|
|
693
|
+
.strictObject({
|
|
694
|
+
schemaVersion: z.literal("1.0.0"),
|
|
695
|
+
verificationRequest: EmbeddedVerificationRequestSchema,
|
|
696
|
+
referenceWorldId: IdentifierSchema,
|
|
697
|
+
policy: AgenticBenchmarkPolicySchema,
|
|
698
|
+
protocol: AgenticBenchmarkProtocolSchema,
|
|
699
|
+
environment: z.strictObject({
|
|
700
|
+
environmentId: IdentifierSchema,
|
|
701
|
+
logicalCpuLimit: z.int().min(1).max(1_000_000).nullable(),
|
|
702
|
+
memoryLimitBytes: z.int().min(1).max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
703
|
+
}),
|
|
704
|
+
identityFiles: AgenticBenchmarkAcquisitionIdentityFilesSchema,
|
|
705
|
+
})
|
|
706
|
+
.meta({
|
|
707
|
+
id: "https://testforge.dev/schemas/agentic-benchmark-acquisition-request.v1.json",
|
|
708
|
+
title: "TestForge Agentic Benchmark acquisition request",
|
|
709
|
+
description: "A fresh verification campaign plus strict phase-aware acquisition policy and identity bindings.",
|
|
710
|
+
});
|
|
711
|
+
const AgenticBenchmarkAcquisitionContextSchema = z.strictObject({
|
|
712
|
+
snapshotRepositoryDigest: Sha256DigestSchema,
|
|
713
|
+
referenceWorldId: IdentifierSchema,
|
|
714
|
+
candidateIds: z.array(IdentifierSchema),
|
|
715
|
+
adapter: z.strictObject({
|
|
716
|
+
executable: z.string().min(1),
|
|
717
|
+
arguments: z.array(z.string()).max(100),
|
|
718
|
+
executableDigest: Sha256DigestSchema,
|
|
719
|
+
identityFilePath: z.string().min(1).max(512),
|
|
720
|
+
identityDigest: Sha256DigestSchema,
|
|
721
|
+
}),
|
|
722
|
+
dependencyFiles: z.array(z.strictObject({ path: z.string().min(1).max(512), digest: Sha256DigestSchema })),
|
|
723
|
+
dependencyGraphDigest: Sha256DigestSchema,
|
|
724
|
+
cachePolicy: z.strictObject({
|
|
725
|
+
cold: z.literal("UNIQUE_EMPTY_DIRECTORY_PER_RUN"),
|
|
726
|
+
warm: z.literal("ONE_INITIALLY_EMPTY_DIRECTORY_PER_CANDIDATE"),
|
|
727
|
+
sharedAcrossCandidates: z.literal(false),
|
|
728
|
+
}),
|
|
729
|
+
});
|
|
730
|
+
export const AgenticBenchmarkAcquisitionResultSchema = z
|
|
731
|
+
.strictObject({
|
|
732
|
+
schemaVersion: z.literal("1.0.0"),
|
|
733
|
+
requestDigest: Sha256DigestSchema,
|
|
734
|
+
status: z.enum([
|
|
735
|
+
"COMPLETE",
|
|
736
|
+
"SOURCE_NOT_VERIFIED",
|
|
737
|
+
"OBSERVED_RUN_FAILURE",
|
|
738
|
+
"INSUFFICIENT_SAMPLES",
|
|
739
|
+
]),
|
|
740
|
+
reasonCodes: z.array(ReasonCodeSchema).min(1),
|
|
741
|
+
sourceManifest: EmbeddedEvidenceManifestSchema,
|
|
742
|
+
benchmarkArtifact: z.strictObject({ ...AgenticBenchmarkArtifactSchema.shape }).nullable(),
|
|
743
|
+
acquisitionContext: AgenticBenchmarkAcquisitionContextSchema,
|
|
744
|
+
limitations: z.array(z.string().min(1).max(2_048)),
|
|
745
|
+
resultDigest: Sha256DigestSchema,
|
|
746
|
+
})
|
|
747
|
+
.meta({
|
|
748
|
+
id: "https://testforge.dev/schemas/agentic-benchmark-acquisition-result.v1.json",
|
|
749
|
+
title: "TestForge Agentic Benchmark acquisition result",
|
|
750
|
+
description: "Fresh VERIFIED evidence and optional replay-valid benchmark timing evidence, sealed independently.",
|
|
751
|
+
});
|
|
752
|
+
export const AgenticBenchmarkAcquisitionReplayResultSchema = z
|
|
753
|
+
.strictObject({
|
|
754
|
+
valid: z.boolean(),
|
|
755
|
+
schemaValid: z.boolean(),
|
|
756
|
+
sourceManifestValid: z.boolean(),
|
|
757
|
+
sourceBindingValid: z.boolean(),
|
|
758
|
+
artifactReplayValid: z.boolean(),
|
|
759
|
+
contextBindingValid: z.boolean(),
|
|
760
|
+
resultDigestValid: z.boolean(),
|
|
761
|
+
statusSemanticsValid: z.boolean(),
|
|
762
|
+
})
|
|
763
|
+
.meta({
|
|
764
|
+
id: "https://testforge.dev/schemas/agentic-benchmark-acquisition-replay-result.v1.json",
|
|
765
|
+
title: "TestForge Agentic Benchmark acquisition replay result",
|
|
766
|
+
description: "Independent source, artifact, context, digest, and status replay rails for benchmark acquisition.",
|
|
767
|
+
});
|
|
768
|
+
const EmbeddedAgenticBenchmarkArtifactSchema = z.strictObject({
|
|
769
|
+
...AgenticBenchmarkArtifactSchema.shape,
|
|
770
|
+
});
|
|
771
|
+
export const AgenticProfileLaneV2Schema = z.strictObject({
|
|
772
|
+
id: IdentifierSchema,
|
|
773
|
+
maximumWarmTotalWallP95Us: z.int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
774
|
+
});
|
|
775
|
+
export const AgenticProfileCostBasisV2Schema = z.strictObject({
|
|
776
|
+
regime: z.literal("WARM"),
|
|
777
|
+
measure: z.literal("WALL"),
|
|
778
|
+
aggregation: z.literal("TOTAL"),
|
|
779
|
+
statistic: z.literal("P95"),
|
|
780
|
+
unit: z.literal("MICROSECOND"),
|
|
781
|
+
portfolioAggregation: z.literal("SUM_OF_INDIVIDUAL_P95"),
|
|
782
|
+
});
|
|
783
|
+
export const AgenticProfilePolicyV2Schema = z.strictObject({
|
|
784
|
+
profileVersion: z.literal("2.0.0"),
|
|
785
|
+
profileId: z.string().min(1).max(256),
|
|
786
|
+
mode: z.literal("HARDENING"),
|
|
787
|
+
requiredComparisonScopeDigest: Sha256DigestSchema,
|
|
788
|
+
costBasis: AgenticProfileCostBasisV2Schema,
|
|
789
|
+
lanes: z.array(AgenticProfileLaneV2Schema).min(1).max(100),
|
|
790
|
+
});
|
|
791
|
+
export const AgenticProfileRequestV2Schema = z
|
|
792
|
+
.strictObject({
|
|
793
|
+
schemaVersion: z.literal("2.0.0"),
|
|
794
|
+
benchmarkArtifact: EmbeddedAgenticBenchmarkArtifactSchema,
|
|
795
|
+
policy: AgenticProfilePolicyV2Schema,
|
|
796
|
+
})
|
|
797
|
+
.meta({
|
|
798
|
+
id: "https://testforge.dev/schemas/agentic-profile-request.v2.json",
|
|
799
|
+
title: "TestForge Agentic Test Profile v2 request",
|
|
800
|
+
description: "A replay-valid benchmark artifact and an exact warm-cost profile policy.",
|
|
801
|
+
});
|
|
802
|
+
const AgenticProfileStatusV2Schema = z.enum([
|
|
803
|
+
"QUALIFIED",
|
|
804
|
+
"BUDGET_MISSED",
|
|
805
|
+
"INSUFFICIENT_TIMING_EVIDENCE",
|
|
806
|
+
"OBSERVED_BENCHMARK_FAILURE",
|
|
807
|
+
"COMPARISON_SCOPE_MISMATCH",
|
|
808
|
+
]);
|
|
809
|
+
const AgenticProfileCandidateV2Schema = z.strictObject({
|
|
810
|
+
id: IdentifierSchema,
|
|
811
|
+
candidateDigest: Sha256DigestSchema,
|
|
812
|
+
evidenceStatus: z.literal("ELIGIBLE"),
|
|
813
|
+
classification: AgenticProfileStatusV2Schema,
|
|
814
|
+
status: z.enum(["MEASURED", "INSUFFICIENT_SAMPLES", "OBSERVED_RUN_FAILURE"]),
|
|
815
|
+
reasonCodes: z.array(z.string().min(1).max(256)),
|
|
816
|
+
strength: z.strictObject({
|
|
817
|
+
targetWeightKilled: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
818
|
+
totalTargetWeight: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
819
|
+
targetWeightPermille: z.int().min(0).max(1_000),
|
|
820
|
+
requiredTargetsKilled: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
821
|
+
requiredTargetsTotal: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
822
|
+
killedTargetIds: z.array(IdentifierSchema),
|
|
823
|
+
}),
|
|
824
|
+
consistency: z.strictObject({
|
|
825
|
+
claim: z.enum(["OBSERVED_CONSISTENT", "OBSERVED_INCONSISTENT"]),
|
|
826
|
+
attempts: z.int().min(0).max(1_000),
|
|
827
|
+
}),
|
|
828
|
+
cost: z.strictObject({
|
|
829
|
+
kind: z.literal("BENCHMARK_WARM_TOTAL_WALL_P95"),
|
|
830
|
+
acceptedSamples: z.int().min(0).max(1_000),
|
|
831
|
+
p95Us: z.int().min(0).max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
832
|
+
}),
|
|
833
|
+
paretoStatus: z.enum(["ON_FRONTIER", "DOMINATED", "NOT_EVALUATED"]),
|
|
834
|
+
});
|
|
835
|
+
const AgenticProfilePortfolioStepV2Schema = z.strictObject({
|
|
836
|
+
ordinal: z.int().min(1).max(2_000),
|
|
837
|
+
candidateId: IdentifierSchema,
|
|
838
|
+
marginalTargetIds: z.array(IdentifierSchema),
|
|
839
|
+
marginalTargetWeight: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
840
|
+
candidateWarmTotalWallP95Us: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
841
|
+
cumulativeCostUs: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
842
|
+
cumulativeTargetWeight: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
843
|
+
});
|
|
844
|
+
const AgenticProfilePortfolioV2Schema = z.strictObject({
|
|
845
|
+
laneId: IdentifierSchema,
|
|
846
|
+
maximumWarmTotalWallP95Us: z.int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
847
|
+
costModel: z.literal("SUM_OF_INDIVIDUAL_P95"),
|
|
848
|
+
selectedCandidateIds: z.array(IdentifierSchema),
|
|
849
|
+
steps: z.array(AgenticProfilePortfolioStepV2Schema),
|
|
850
|
+
sumIndividualWarmTotalWallP95Us: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
851
|
+
targetWeight: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
852
|
+
targetWeightPermille: z.int().min(0).max(1_000),
|
|
853
|
+
requiredTargetsKilled: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
854
|
+
requiredTargetsTotal: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
855
|
+
});
|
|
856
|
+
export const AgenticProfileReportV2Schema = z
|
|
857
|
+
.strictObject({
|
|
858
|
+
schemaVersion: z.literal("2.0.0"),
|
|
859
|
+
benchmarkArtifact: EmbeddedAgenticBenchmarkArtifactSchema,
|
|
860
|
+
sourceBenchmarkArtifactDigest: Sha256DigestSchema,
|
|
861
|
+
comparisonScopeDigest: Sha256DigestSchema,
|
|
862
|
+
policy: AgenticProfilePolicyV2Schema,
|
|
863
|
+
policyDigest: Sha256DigestSchema,
|
|
864
|
+
status: AgenticProfileStatusV2Schema,
|
|
865
|
+
candidateUniverse: z.strictObject({
|
|
866
|
+
kind: z.literal("SOURCE_SELECTED_ELIGIBLE"),
|
|
867
|
+
candidateIds: z.array(IdentifierSchema),
|
|
868
|
+
excludedEligibleCandidateIds: z.array(IdentifierSchema),
|
|
869
|
+
}),
|
|
870
|
+
candidates: z.array(AgenticProfileCandidateV2Schema),
|
|
871
|
+
portfolios: z.array(AgenticProfilePortfolioV2Schema),
|
|
872
|
+
limitations: z.array(z.string().min(1).max(2_048)),
|
|
873
|
+
reportDigest: Sha256DigestSchema,
|
|
874
|
+
})
|
|
875
|
+
.meta({
|
|
876
|
+
id: "https://testforge.dev/schemas/agentic-profile-report.v2.json",
|
|
877
|
+
title: "TestForge Agentic Test Profile v2 report",
|
|
878
|
+
description: "A replayable strength and exact warm-cost profile over a declared benchmark cohort.",
|
|
879
|
+
});
|
|
880
|
+
export const AgenticProfileReplayResultV2Schema = z
|
|
881
|
+
.strictObject({
|
|
882
|
+
valid: z.boolean(),
|
|
883
|
+
schemaValid: z.boolean(),
|
|
884
|
+
sourceBenchmarkValid: z.boolean(),
|
|
885
|
+
sourceBindingValid: z.boolean(),
|
|
886
|
+
policyDigestValid: z.boolean(),
|
|
887
|
+
reportDigestValid: z.boolean(),
|
|
888
|
+
semanticsValid: z.boolean(),
|
|
889
|
+
})
|
|
890
|
+
.meta({
|
|
891
|
+
id: "https://testforge.dev/schemas/agentic-profile-replay-result.v2.json",
|
|
892
|
+
title: "TestForge Agentic Test Profile v2 replay result",
|
|
893
|
+
description: "Independent benchmark, binding, digest, and semantic replay rails for Profile v2.",
|
|
894
|
+
});
|
|
895
|
+
const AgenticCorpusRoleSchema = z.enum(["AUTHOR", "REVIEWER"]);
|
|
896
|
+
const Base64UrlSchema = z
|
|
897
|
+
.string()
|
|
898
|
+
.min(1)
|
|
899
|
+
.regex(/^[A-Za-z0-9_-]+$/);
|
|
900
|
+
export const AgenticCorpusTrustPolicySchema = z
|
|
901
|
+
.strictObject({
|
|
902
|
+
schemaVersion: z.literal("1.0.0"),
|
|
903
|
+
policyId: IdentifierSchema,
|
|
904
|
+
keys: z
|
|
905
|
+
.array(z.strictObject({
|
|
906
|
+
keyId: Sha256DigestSchema,
|
|
907
|
+
subjectId: IdentifierSchema,
|
|
908
|
+
roles: z.array(AgenticCorpusRoleSchema).min(1).max(2),
|
|
909
|
+
publicKey: z.strictObject({
|
|
910
|
+
algorithm: z.literal("Ed25519"),
|
|
911
|
+
format: z.literal("SPKI_DER_BASE64URL"),
|
|
912
|
+
data: Base64UrlSchema,
|
|
913
|
+
}),
|
|
914
|
+
}))
|
|
915
|
+
.min(2),
|
|
916
|
+
sources: z
|
|
917
|
+
.array(z.strictObject({
|
|
918
|
+
sourceId: IdentifierSchema,
|
|
919
|
+
sourceIdentityDigest: Sha256DigestSchema,
|
|
920
|
+
authorizedAuthorSubjectIds: z.array(IdentifierSchema).min(1),
|
|
921
|
+
authorizedReviewerSubjectIds: z.array(IdentifierSchema).min(1),
|
|
922
|
+
}))
|
|
923
|
+
.min(1),
|
|
924
|
+
policyDigest: Sha256DigestSchema,
|
|
925
|
+
})
|
|
926
|
+
.meta({
|
|
927
|
+
id: "https://testforge.dev/schemas/agentic-corpus-trust-policy.v1.json",
|
|
928
|
+
title: "TestForge agentic corpus trust policy",
|
|
929
|
+
description: "An externally pinned Ed25519 trust root for agentic corpus provenance.",
|
|
930
|
+
});
|
|
931
|
+
export const AgenticCorpusProvenanceSchema = z
|
|
932
|
+
.strictObject({
|
|
933
|
+
schemaVersion: z.literal("1.0.0"),
|
|
934
|
+
domain: z.literal("TESTFORGE_AGENTIC_CORPUS_CASE_V1"),
|
|
935
|
+
trustPolicyDigest: Sha256DigestSchema,
|
|
936
|
+
caseId: IdentifierSchema,
|
|
937
|
+
caseDigest: Sha256DigestSchema,
|
|
938
|
+
source: z.strictObject({
|
|
939
|
+
sourceId: IdentifierSchema,
|
|
940
|
+
sourceRevision: Sha256DigestSchema,
|
|
941
|
+
sourceIdentityDigest: Sha256DigestSchema,
|
|
942
|
+
}),
|
|
943
|
+
execution: z.strictObject({
|
|
944
|
+
status: z.literal("EXECUTED"),
|
|
945
|
+
protocolId: IdentifierSchema,
|
|
946
|
+
evidenceDigests: z.array(Sha256DigestSchema).min(1),
|
|
947
|
+
receiptDigest: Sha256DigestSchema,
|
|
948
|
+
}),
|
|
949
|
+
author: z.strictObject({ keyId: Sha256DigestSchema, signature: Base64UrlSchema }),
|
|
950
|
+
reviewer: z.strictObject({ keyId: Sha256DigestSchema, signature: Base64UrlSchema }),
|
|
951
|
+
provenanceDigest: Sha256DigestSchema,
|
|
952
|
+
})
|
|
953
|
+
.meta({
|
|
954
|
+
id: "https://testforge.dev/schemas/agentic-corpus-provenance.v1.json",
|
|
955
|
+
title: "TestForge agentic corpus provenance",
|
|
956
|
+
description: "Paired, dual-signed provenance for one unchanged agentic corpus case v1.",
|
|
957
|
+
});
|
|
958
|
+
const AgenticCorpusAllocationAlgorithmSchema = z.literal("SHA256_ASCENDING_SPLIT_V1");
|
|
959
|
+
const AgenticCorpusAllocationPartitionSchema = z.enum(["CALIBRATION", "HOLDOUT"]);
|
|
960
|
+
const AgenticCorpusAllocationIdentifierSchema = z
|
|
961
|
+
.string()
|
|
962
|
+
.min(1)
|
|
963
|
+
.max(128)
|
|
964
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
965
|
+
const AgenticCorpusAllocationDigestSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
966
|
+
const AgenticCorpusAllocationStratumRequestSchema = z.strictObject({
|
|
967
|
+
sourceId: AgenticCorpusAllocationIdentifierSchema,
|
|
968
|
+
sourceIdentityDigest: AgenticCorpusAllocationDigestSchema,
|
|
969
|
+
calibrationCount: z.int().min(1).max(99_999),
|
|
970
|
+
caseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(2).max(100_000),
|
|
971
|
+
});
|
|
972
|
+
export const AgenticCorpusAllocationRequestSchema = z.strictObject({
|
|
973
|
+
schemaVersion: z.literal("1.0.0"),
|
|
974
|
+
allocationId: AgenticCorpusAllocationIdentifierSchema,
|
|
975
|
+
seedDigest: AgenticCorpusAllocationDigestSchema,
|
|
976
|
+
strata: z.array(AgenticCorpusAllocationStratumRequestSchema).min(1).max(100_000),
|
|
977
|
+
});
|
|
978
|
+
const AgenticCorpusAssignmentSchema = z.strictObject({
|
|
979
|
+
caseId: AgenticCorpusAllocationIdentifierSchema,
|
|
980
|
+
sourceId: AgenticCorpusAllocationIdentifierSchema,
|
|
981
|
+
sourceIdentityDigest: AgenticCorpusAllocationDigestSchema,
|
|
982
|
+
scoreDigest: AgenticCorpusAllocationDigestSchema,
|
|
983
|
+
partition: AgenticCorpusAllocationPartitionSchema,
|
|
984
|
+
});
|
|
985
|
+
const AgenticCorpusAllocationStratumSchema = z.strictObject({
|
|
986
|
+
sourceId: AgenticCorpusAllocationIdentifierSchema,
|
|
987
|
+
sourceIdentityDigest: AgenticCorpusAllocationDigestSchema,
|
|
988
|
+
calibrationCount: z.int().min(1).max(99_999),
|
|
989
|
+
sourceCaseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(2).max(100_000),
|
|
990
|
+
calibrationCaseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(1).max(99_999),
|
|
991
|
+
holdoutCaseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(1).max(99_999),
|
|
992
|
+
});
|
|
993
|
+
export const AgenticCorpusAllocationSchema = z.strictObject({
|
|
994
|
+
schemaVersion: z.literal("1.0.0"),
|
|
995
|
+
allocationId: AgenticCorpusAllocationIdentifierSchema,
|
|
996
|
+
algorithm: AgenticCorpusAllocationAlgorithmSchema,
|
|
997
|
+
seedDigest: AgenticCorpusAllocationDigestSchema,
|
|
998
|
+
calibrationCount: z.int().min(1).max(99_999),
|
|
999
|
+
sourceCaseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(2).max(100_000),
|
|
1000
|
+
strata: z.array(AgenticCorpusAllocationStratumSchema).min(1).max(100_000),
|
|
1001
|
+
calibrationCaseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(1).max(99_999),
|
|
1002
|
+
holdoutCaseIds: z.array(AgenticCorpusAllocationIdentifierSchema).min(1).max(99_999),
|
|
1003
|
+
assignments: z.array(AgenticCorpusAssignmentSchema).min(2).max(100_000),
|
|
1004
|
+
allocationDigest: AgenticCorpusAllocationDigestSchema,
|
|
1005
|
+
});
|
|
1006
|
+
export const AgenticCorpusAllocationReplayResultSchema = z.strictObject({
|
|
1007
|
+
valid: z.boolean(),
|
|
1008
|
+
schemaValid: z.boolean(),
|
|
1009
|
+
allocationDigestValid: z.boolean(),
|
|
1010
|
+
sourceCaseIdsValid: z.boolean(),
|
|
1011
|
+
assignmentScoresValid: z.boolean(),
|
|
1012
|
+
partitionSemanticsValid: z.boolean(),
|
|
1013
|
+
});
|
|
1014
|
+
const AgenticCorpusExperimentProtocolSchema = z.strictObject({
|
|
1015
|
+
protocolId: IdentifierSchema,
|
|
1016
|
+
protocolVersion: z.literal("1.0.0"),
|
|
1017
|
+
minimumStableAttempts: z.int().min(2).max(1_000),
|
|
1018
|
+
taxonomy: z.literal("TESTFORGE_OBSERVATION_V1"),
|
|
1019
|
+
detectionRule: z.literal("ATTRIBUTED_ASSERTION_FAILURE_ON_BUGGY_PASS_ON_FIXED"),
|
|
1020
|
+
nonEvidenceRule: z.literal("ERRORS_ARE_INSUFFICIENT_NOT_DETECTIONS"),
|
|
1021
|
+
maximumDetectionDeficitCases: z.int().min(0).max(100_000),
|
|
1022
|
+
});
|
|
1023
|
+
const AgenticCorpusCaseIdentitySchema = z.strictObject({
|
|
1024
|
+
caseId: IdentifierSchema,
|
|
1025
|
+
caseDigest: Sha256DigestSchema,
|
|
1026
|
+
provenanceDigest: Sha256DigestSchema,
|
|
1027
|
+
sourceId: IdentifierSchema,
|
|
1028
|
+
sourceIdentityDigest: Sha256DigestSchema,
|
|
1029
|
+
});
|
|
1030
|
+
const SignatureSchema = z
|
|
1031
|
+
.string()
|
|
1032
|
+
.min(1)
|
|
1033
|
+
.max(512)
|
|
1034
|
+
.regex(/^[A-Za-z0-9_-]+$/);
|
|
1035
|
+
const SecretShareSchema = z
|
|
1036
|
+
.string()
|
|
1037
|
+
.length(43)
|
|
1038
|
+
.regex(/^[A-Za-z0-9_-]{43}$/);
|
|
1039
|
+
const AgenticCorpusAllocationCommitmentSignerSchema = z.strictObject({
|
|
1040
|
+
keyId: Sha256DigestSchema,
|
|
1041
|
+
role: z.enum(["AUTHOR", "REVIEWER"]),
|
|
1042
|
+
shareCommitmentDigest: Sha256DigestSchema,
|
|
1043
|
+
signature: SignatureSchema,
|
|
1044
|
+
});
|
|
1045
|
+
export const AgenticCorpusAllocationCommitmentSchema = z.strictObject({
|
|
1046
|
+
schemaVersion: z.literal("1.0.0"),
|
|
1047
|
+
commitmentVersion: z.literal("1.0.0"),
|
|
1048
|
+
commitmentId: IdentifierSchema,
|
|
1049
|
+
allocationId: IdentifierSchema,
|
|
1050
|
+
trustPolicyDigest: Sha256DigestSchema,
|
|
1051
|
+
caseSet: z.array(AgenticCorpusCaseIdentitySchema).min(2).max(100_000),
|
|
1052
|
+
strata: z
|
|
1053
|
+
.array(z.strictObject({
|
|
1054
|
+
sourceId: IdentifierSchema,
|
|
1055
|
+
sourceIdentityDigest: Sha256DigestSchema,
|
|
1056
|
+
calibrationCount: z.int().min(1).max(99_999),
|
|
1057
|
+
}))
|
|
1058
|
+
.min(1)
|
|
1059
|
+
.max(100_000),
|
|
1060
|
+
signers: z.tuple([
|
|
1061
|
+
AgenticCorpusAllocationCommitmentSignerSchema,
|
|
1062
|
+
AgenticCorpusAllocationCommitmentSignerSchema,
|
|
1063
|
+
]),
|
|
1064
|
+
commitmentDigest: Sha256DigestSchema,
|
|
1065
|
+
});
|
|
1066
|
+
export const AgenticCorpusAllocationRevealSchema = z.strictObject({
|
|
1067
|
+
schemaVersion: z.literal("1.0.0"),
|
|
1068
|
+
revealVersion: z.literal("1.0.0"),
|
|
1069
|
+
commitmentDigest: Sha256DigestSchema,
|
|
1070
|
+
shares: z.tuple([
|
|
1071
|
+
z.strictObject({ keyId: Sha256DigestSchema, secret: SecretShareSchema }),
|
|
1072
|
+
z.strictObject({ keyId: Sha256DigestSchema, secret: SecretShareSchema }),
|
|
1073
|
+
]),
|
|
1074
|
+
revealDigest: Sha256DigestSchema,
|
|
1075
|
+
});
|
|
1076
|
+
export const AgenticCorpusAllocationCommitmentReplayResultSchema = z.strictObject({
|
|
1077
|
+
valid: z.boolean(),
|
|
1078
|
+
schemaValid: z.boolean(),
|
|
1079
|
+
externalTrustAnchorValid: z.boolean(),
|
|
1080
|
+
externalCommitmentAnchorValid: z.boolean(),
|
|
1081
|
+
commitmentDigestValid: z.boolean(),
|
|
1082
|
+
caseSetValid: z.boolean(),
|
|
1083
|
+
commitmentSignaturesValid: z.boolean(),
|
|
1084
|
+
principalsDistinct: z.boolean(),
|
|
1085
|
+
revealValid: z.boolean(),
|
|
1086
|
+
finalSeedDigestValid: z.boolean(),
|
|
1087
|
+
allocationReplayValid: z.boolean(),
|
|
1088
|
+
allocationBindingValid: z.boolean(),
|
|
1089
|
+
});
|
|
1090
|
+
const AgenticCorpusExperimentSubjectSchema = AgenticCorpusCaseIdentitySchema.extend({
|
|
1091
|
+
buggyRevisionDigest: Sha256DigestSchema,
|
|
1092
|
+
fixedRevisionDigest: Sha256DigestSchema,
|
|
1093
|
+
reconstructionDigest: Sha256DigestSchema,
|
|
1094
|
+
requiredSuiteDigest: Sha256DigestSchema,
|
|
1095
|
+
qualificationReceiptDigest: Sha256DigestSchema,
|
|
1096
|
+
});
|
|
1097
|
+
const AgenticCorpusCandidateReferenceSchema = z.strictObject({
|
|
1098
|
+
candidateId: IdentifierSchema,
|
|
1099
|
+
candidateDigest: Sha256DigestSchema,
|
|
1100
|
+
});
|
|
1101
|
+
const AgenticCorpusExperimentArmSchema = z.strictObject({
|
|
1102
|
+
candidateUniverse: z.array(AgenticCorpusCandidateReferenceSchema).min(1).max(100_000),
|
|
1103
|
+
selectedCandidates: z.array(AgenticCorpusCandidateReferenceSchema).min(1).max(100_000),
|
|
1104
|
+
selectedSuiteDigest: Sha256DigestSchema,
|
|
1105
|
+
});
|
|
1106
|
+
const AgenticCorpusExperimentObservationSchema = z.strictObject({
|
|
1107
|
+
outcome: ObservationOutcomeSchema,
|
|
1108
|
+
attributed: z.boolean(),
|
|
1109
|
+
});
|
|
1110
|
+
const AgenticCorpusExperimentCommandSchema = z.strictObject({
|
|
1111
|
+
commandId: IdentifierSchema,
|
|
1112
|
+
adapterId: IdentifierSchema,
|
|
1113
|
+
arm: z.enum(["BASELINE", "PROFILE"]),
|
|
1114
|
+
executableIdentityDigest: Sha256DigestSchema,
|
|
1115
|
+
executable: z.string().min(1).max(1_024),
|
|
1116
|
+
arguments: z.array(z.string().max(4_096)).max(1_000),
|
|
1117
|
+
subjectState: z.enum(["BUGGY", "FIXED", "REQUIRED_SUITE"]),
|
|
1118
|
+
testSuiteDigest: Sha256DigestSchema,
|
|
1119
|
+
timeoutMs: z.int().min(1).max(86_400_000),
|
|
1120
|
+
maxStdoutBytes: z.int().min(0).max(16_777_216),
|
|
1121
|
+
maxStderrBytes: z.int().min(0).max(16_777_216),
|
|
1122
|
+
});
|
|
1123
|
+
const AgenticCorpusExperimentScheduleEntrySchema = z.strictObject({
|
|
1124
|
+
runId: IdentifierSchema,
|
|
1125
|
+
caseId: IdentifierSchema,
|
|
1126
|
+
arm: z.enum(["BASELINE", "PROFILE"]),
|
|
1127
|
+
attemptOrdinal: z.int().min(1).max(1_000),
|
|
1128
|
+
subjectState: z.enum(["BUGGY", "FIXED", "REQUIRED_SUITE"]),
|
|
1129
|
+
commandId: IdentifierSchema,
|
|
1130
|
+
});
|
|
1131
|
+
export const AgenticCorpusExperimentPlanSchema = z.strictObject({
|
|
1132
|
+
schemaVersion: z.literal("1.0.0"),
|
|
1133
|
+
planVersion: z.literal("1.0.0"),
|
|
1134
|
+
experimentId: IdentifierSchema,
|
|
1135
|
+
hypothesis: z.literal("H3"),
|
|
1136
|
+
partition: z.literal("HOLDOUT"),
|
|
1137
|
+
trustPolicyDigest: Sha256DigestSchema,
|
|
1138
|
+
allocationCommitmentDigest: Sha256DigestSchema,
|
|
1139
|
+
allocationDigest: Sha256DigestSchema,
|
|
1140
|
+
protocol: AgenticCorpusExperimentProtocolSchema,
|
|
1141
|
+
subjects: z.array(AgenticCorpusExperimentSubjectSchema).min(1).max(100_000),
|
|
1142
|
+
adapters: z
|
|
1143
|
+
.array(z.strictObject({
|
|
1144
|
+
adapterId: IdentifierSchema,
|
|
1145
|
+
adapterVersion: z.literal("1.0.0"),
|
|
1146
|
+
identityDigest: Sha256DigestSchema,
|
|
1147
|
+
resultProtocol: z.literal("TESTFORGE_H3_STRUCTURED_RESULT_V1"),
|
|
1148
|
+
}))
|
|
1149
|
+
.min(1)
|
|
1150
|
+
.max(1_000),
|
|
1151
|
+
arms: z.strictObject({
|
|
1152
|
+
baseline: AgenticCorpusExperimentArmSchema,
|
|
1153
|
+
profile: AgenticCorpusExperimentArmSchema,
|
|
1154
|
+
}),
|
|
1155
|
+
commands: z.array(AgenticCorpusExperimentCommandSchema).min(1).max(1_000_000),
|
|
1156
|
+
schedule: z.array(AgenticCorpusExperimentScheduleEntrySchema).min(1).max(1_000_000),
|
|
1157
|
+
budget: z.strictObject({
|
|
1158
|
+
unit: z.literal("PLANNED_PROCESS_EXECUTION"),
|
|
1159
|
+
baselinePlannedProcessExecutions: z.int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
1160
|
+
profilePlannedProcessExecutions: z.int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
1161
|
+
equalPlannedProcessExecutions: z.boolean(),
|
|
1162
|
+
baselinePlannedTimeoutMs: z.int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
1163
|
+
profilePlannedTimeoutMs: z.int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
1164
|
+
equalPlannedTimeoutBudget: z.boolean(),
|
|
1165
|
+
}),
|
|
1166
|
+
limitations: z.array(z.string().min(1).max(2_048)).min(1).max(100),
|
|
1167
|
+
planDigest: Sha256DigestSchema,
|
|
1168
|
+
});
|
|
1169
|
+
export const AgenticCorpusExperimentPlanReplayResultSchema = z.strictObject({
|
|
1170
|
+
valid: z.boolean(),
|
|
1171
|
+
schemaValid: z.boolean(),
|
|
1172
|
+
externalPlanAnchorValid: z.boolean(),
|
|
1173
|
+
planDigestValid: z.boolean(),
|
|
1174
|
+
allocationBindingValid: z.boolean(),
|
|
1175
|
+
subjectSetValid: z.boolean(),
|
|
1176
|
+
armsValid: z.boolean(),
|
|
1177
|
+
commandsValid: z.boolean(),
|
|
1178
|
+
scheduleValid: z.boolean(),
|
|
1179
|
+
budgetValid: z.boolean(),
|
|
1180
|
+
});
|
|
1181
|
+
export const AgenticCorpusExperimentReceiptSchema = z.strictObject({
|
|
1182
|
+
schemaVersion: z.literal("1.0.0"),
|
|
1183
|
+
receiptVersion: z.literal("1.0.0"),
|
|
1184
|
+
runId: IdentifierSchema,
|
|
1185
|
+
planDigest: Sha256DigestSchema,
|
|
1186
|
+
commandId: IdentifierSchema,
|
|
1187
|
+
commandDigest: Sha256DigestSchema,
|
|
1188
|
+
caseId: IdentifierSchema,
|
|
1189
|
+
arm: z.enum(["BASELINE", "PROFILE"]),
|
|
1190
|
+
attemptOrdinal: z.int().min(1).max(1_000),
|
|
1191
|
+
subjectState: z.enum(["BUGGY", "FIXED", "REQUIRED_SUITE"]),
|
|
1192
|
+
repositoryDigest: Sha256DigestSchema,
|
|
1193
|
+
testSuiteDigest: Sha256DigestSchema,
|
|
1194
|
+
appliedTimeoutMs: z.int().min(1).max(86_400_000),
|
|
1195
|
+
process: z.strictObject({
|
|
1196
|
+
exitCode: z.int().min(0).max(255).nullable(),
|
|
1197
|
+
timedOut: z.boolean(),
|
|
1198
|
+
stdoutDigest: Sha256DigestSchema,
|
|
1199
|
+
stderrDigest: Sha256DigestSchema,
|
|
1200
|
+
}),
|
|
1201
|
+
structuredResultDigest: Sha256DigestSchema,
|
|
1202
|
+
receiptDigest: Sha256DigestSchema,
|
|
1203
|
+
});
|
|
1204
|
+
export const AgenticCorpusExperimentStructuredResultSchema = z.strictObject({
|
|
1205
|
+
schemaVersion: z.literal("1.0.0"),
|
|
1206
|
+
protocol: z.literal("TESTFORGE_H3_STRUCTURED_RESULT_V1"),
|
|
1207
|
+
outcome: ObservationOutcomeSchema,
|
|
1208
|
+
attributed: z.boolean(),
|
|
1209
|
+
});
|
|
1210
|
+
const AgenticCorpusExperimentAttemptSchema = z.strictObject({
|
|
1211
|
+
ordinal: z.int().min(1).max(1_000),
|
|
1212
|
+
buggy: AgenticCorpusExperimentObservationSchema,
|
|
1213
|
+
fixed: AgenticCorpusExperimentObservationSchema,
|
|
1214
|
+
requiredSuite: AgenticCorpusExperimentObservationSchema,
|
|
1215
|
+
runIds: z.strictObject({
|
|
1216
|
+
buggy: IdentifierSchema,
|
|
1217
|
+
fixed: IdentifierSchema,
|
|
1218
|
+
requiredSuite: IdentifierSchema,
|
|
1219
|
+
}),
|
|
1220
|
+
});
|
|
1221
|
+
const AgenticCorpusExperimentPayloadSchema = z.strictObject({
|
|
1222
|
+
cases: z
|
|
1223
|
+
.array(z.strictObject({
|
|
1224
|
+
caseId: IdentifierSchema,
|
|
1225
|
+
baselineAttempts: z.array(AgenticCorpusExperimentAttemptSchema).min(1).max(1_000),
|
|
1226
|
+
profileAttempts: z.array(AgenticCorpusExperimentAttemptSchema).min(1).max(1_000),
|
|
1227
|
+
}))
|
|
1228
|
+
.min(1)
|
|
1229
|
+
.max(100_000),
|
|
1230
|
+
});
|
|
1231
|
+
const AgenticCorpusExperimentResultSchema = z.strictObject({
|
|
1232
|
+
status: z.enum(["SUPPORTED", "NOT_SUPPORTED", "INSUFFICIENT"]),
|
|
1233
|
+
evaluatedCaseIds: z.array(IdentifierSchema).min(1),
|
|
1234
|
+
baselineDetectedCaseIds: z.array(IdentifierSchema),
|
|
1235
|
+
profileDetectedCaseIds: z.array(IdentifierSchema),
|
|
1236
|
+
insufficientCaseIds: z.array(IdentifierSchema),
|
|
1237
|
+
baselineDetectedCount: z.int().min(0),
|
|
1238
|
+
profileDetectedCount: z.int().min(0),
|
|
1239
|
+
maximumDetectionDeficitCases: z.int().min(0),
|
|
1240
|
+
nonInferior: z.boolean(),
|
|
1241
|
+
sourceResults: z.array(z.strictObject({
|
|
1242
|
+
sourceId: IdentifierSchema,
|
|
1243
|
+
sourceIdentityDigest: Sha256DigestSchema,
|
|
1244
|
+
evaluatedCaseIds: z.array(IdentifierSchema).min(1),
|
|
1245
|
+
baselineDetectedCount: z.int().min(0),
|
|
1246
|
+
profileDetectedCount: z.int().min(0),
|
|
1247
|
+
nonInferior: z.boolean(),
|
|
1248
|
+
})),
|
|
1249
|
+
});
|
|
1250
|
+
export const AgenticCorpusExperimentRequestSchema = z.strictObject({
|
|
1251
|
+
schemaVersion: z.literal("1.0.0"),
|
|
1252
|
+
experimentVersion: z.literal("1.0.0"),
|
|
1253
|
+
experimentId: IdentifierSchema,
|
|
1254
|
+
hypothesis: z.literal("H3"),
|
|
1255
|
+
partition: z.literal("HOLDOUT"),
|
|
1256
|
+
planDigest: Sha256DigestSchema,
|
|
1257
|
+
allocationDigest: Sha256DigestSchema,
|
|
1258
|
+
trustPolicyDigest: Sha256DigestSchema,
|
|
1259
|
+
evidenceBindings: z
|
|
1260
|
+
.array(z.strictObject({
|
|
1261
|
+
runId: IdentifierSchema,
|
|
1262
|
+
receiptDigest: Sha256DigestSchema,
|
|
1263
|
+
receiptContentDigest: Sha256DigestSchema,
|
|
1264
|
+
}))
|
|
1265
|
+
.min(1)
|
|
1266
|
+
.max(1_000_000),
|
|
1267
|
+
payloadSchemaId: z.literal("https://testforge.dev/payloads/agentic-corpus-experiment-h3.v1.json"),
|
|
1268
|
+
payload: AgenticCorpusExperimentPayloadSchema,
|
|
1269
|
+
limitations: z.array(z.string().min(1).max(2_048)).min(1).max(100),
|
|
1270
|
+
});
|
|
1271
|
+
export const AgenticCorpusExperimentArtifactSchema = AgenticCorpusExperimentRequestSchema.extend({
|
|
1272
|
+
candidateSetDigest: Sha256DigestSchema,
|
|
1273
|
+
evidenceSetDigest: Sha256DigestSchema,
|
|
1274
|
+
payloadDigest: Sha256DigestSchema,
|
|
1275
|
+
result: AgenticCorpusExperimentResultSchema,
|
|
1276
|
+
artifactDigest: Sha256DigestSchema,
|
|
1277
|
+
});
|
|
1278
|
+
export const AgenticCorpusExperimentReplayRequestSchema = z.strictObject({
|
|
1279
|
+
artifact: AgenticCorpusExperimentArtifactSchema,
|
|
1280
|
+
});
|
|
1281
|
+
export const AgenticCorpusExperimentReplayResultSchema = z.strictObject({
|
|
1282
|
+
valid: z.boolean(),
|
|
1283
|
+
schemaValid: z.boolean(),
|
|
1284
|
+
artifactDigestValid: z.boolean(),
|
|
1285
|
+
externalTrustAnchorValid: z.boolean(),
|
|
1286
|
+
externalCommitmentAnchorValid: z.boolean(),
|
|
1287
|
+
commitmentRevealValid: z.boolean(),
|
|
1288
|
+
allocationReplayValid: z.boolean(),
|
|
1289
|
+
allocationBindingValid: z.boolean(),
|
|
1290
|
+
externalPlanAnchorValid: z.boolean(),
|
|
1291
|
+
planDigestValid: z.boolean(),
|
|
1292
|
+
planSemanticsValid: z.boolean(),
|
|
1293
|
+
subjectDigestsValid: z.boolean(),
|
|
1294
|
+
provenanceReplayValid: z.boolean(),
|
|
1295
|
+
scheduleValid: z.boolean(),
|
|
1296
|
+
budgetValid: z.boolean(),
|
|
1297
|
+
evidenceSetDigestValid: z.boolean(),
|
|
1298
|
+
receiptBindingsValid: z.boolean(),
|
|
1299
|
+
candidateEvidenceValid: z.boolean(),
|
|
1300
|
+
outputBytesResolved: z.boolean(),
|
|
1301
|
+
structuredResultsValid: z.boolean(),
|
|
1302
|
+
payloadSupported: z.boolean(),
|
|
1303
|
+
payloadDigestValid: z.boolean(),
|
|
1304
|
+
observationSemanticsValid: z.boolean(),
|
|
1305
|
+
resultSemanticsValid: z.boolean(),
|
|
1306
|
+
});
|
|
1307
|
+
export class ContractError extends Error {
|
|
1308
|
+
code;
|
|
1309
|
+
constructor(code, detail) {
|
|
1310
|
+
super(detail ? `${code}: ${detail}` : code);
|
|
1311
|
+
this.name = "ContractError";
|
|
1312
|
+
this.code = code;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
function assertUniqueIdentifiers(items, code) {
|
|
1316
|
+
const seen = new Set();
|
|
1317
|
+
for (const item of items) {
|
|
1318
|
+
if (seen.has(item.id)) {
|
|
1319
|
+
throw new ContractError(code, item.id);
|
|
1320
|
+
}
|
|
1321
|
+
seen.add(item.id);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
function assertWorldKinds(request) {
|
|
1325
|
+
if (!request.worlds.some((world) => world.kind === "REFERENCE" && world.required)) {
|
|
1326
|
+
throw new ContractError("REFERENCE_WORLD_REQUIRED");
|
|
1327
|
+
}
|
|
1328
|
+
if (!request.worlds.some((world) => world.kind === "TARGET" && world.required)) {
|
|
1329
|
+
throw new ContractError("TARGET_WORLD_REQUIRED");
|
|
1330
|
+
}
|
|
1331
|
+
if (!request.worlds.some((world) => world.kind === "NEUTRAL" && world.required)) {
|
|
1332
|
+
throw new ContractError("NEUTRAL_WORLD_REQUIRED");
|
|
1333
|
+
}
|
|
1334
|
+
for (const world of request.worlds) {
|
|
1335
|
+
if (world.kind === "TARGET" && world.weight < 1) {
|
|
1336
|
+
throw new ContractError("TARGET_WEIGHT_REQUIRED", world.id);
|
|
1337
|
+
}
|
|
1338
|
+
if (world.kind !== "TARGET" && world.weight !== 0) {
|
|
1339
|
+
throw new ContractError("NON_TARGET_WEIGHT_FORBIDDEN", world.id);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
function assertBudgets(request) {
|
|
1344
|
+
if (request.candidates.length > request.budgets.maximumCandidates) {
|
|
1345
|
+
throw new ContractError("CANDIDATE_BUDGET_EXCEEDED");
|
|
1346
|
+
}
|
|
1347
|
+
if (request.worlds.length > request.budgets.maximumWorlds) {
|
|
1348
|
+
throw new ContractError("WORLD_BUDGET_EXCEEDED");
|
|
1349
|
+
}
|
|
1350
|
+
const executions = request.worlds.length * request.policy.requiredAttempts * (request.candidates.length + 1);
|
|
1351
|
+
if (executions > request.budgets.maximumExecutions) {
|
|
1352
|
+
throw new ContractError("EXECUTION_BUDGET_EXCEEDED", `planned=${executions}, maximum=${request.budgets.maximumExecutions}`);
|
|
1353
|
+
}
|
|
1354
|
+
const worldOverlayBytes = request.worlds.reduce((worldTotal, world) => worldTotal +
|
|
1355
|
+
world.files.reduce((fileTotal, file) => fileTotal + Buffer.byteLength(file.content, "utf8"), 0), 0);
|
|
1356
|
+
if (worldOverlayBytes > request.budgets.maximumWorldOverlayBytes) {
|
|
1357
|
+
throw new ContractError("WORLD_OVERLAY_BYTES_EXCEEDED", `${worldOverlayBytes} > ${request.budgets.maximumWorldOverlayBytes}`);
|
|
1358
|
+
}
|
|
1359
|
+
let totalCandidateBytes = 0;
|
|
1360
|
+
for (const candidate of request.candidates) {
|
|
1361
|
+
const bytes = candidate.files.reduce((total, file) => total + Buffer.byteLength(file.content, "utf8"), 0);
|
|
1362
|
+
totalCandidateBytes += bytes;
|
|
1363
|
+
if (bytes > request.budgets.maximumCandidateBytes) {
|
|
1364
|
+
throw new ContractError("CANDIDATE_BYTES_EXCEEDED", `${candidate.id}: ${bytes} > ${request.budgets.maximumCandidateBytes}`);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
if (totalCandidateBytes > request.budgets.maximumTotalCandidateBytes) {
|
|
1368
|
+
throw new ContractError("TOTAL_CANDIDATE_BYTES_EXCEEDED", `${totalCandidateBytes} > ${request.budgets.maximumTotalCandidateBytes}`);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
function findUnsafeNodeTestArgument(value) {
|
|
1372
|
+
if (typeof value !== "object" || value === null || !("adapter" in value))
|
|
1373
|
+
return undefined;
|
|
1374
|
+
const adapter = value.adapter;
|
|
1375
|
+
if (typeof adapter !== "object" ||
|
|
1376
|
+
adapter === null ||
|
|
1377
|
+
!("kind" in adapter) ||
|
|
1378
|
+
adapter.kind !== "node-test" ||
|
|
1379
|
+
!("extraArguments" in adapter) ||
|
|
1380
|
+
!Array.isArray(adapter.extraArguments)) {
|
|
1381
|
+
return undefined;
|
|
1382
|
+
}
|
|
1383
|
+
if (adapter.extraArguments.length === 0)
|
|
1384
|
+
return undefined;
|
|
1385
|
+
const firstArgument = adapter.extraArguments[0];
|
|
1386
|
+
return typeof firstArgument === "string" ? firstArgument : "non-string argument";
|
|
1387
|
+
}
|
|
1388
|
+
function findReservedEnvironmentVariable(value) {
|
|
1389
|
+
if (typeof value !== "object" || value === null || !("isolation" in value))
|
|
1390
|
+
return undefined;
|
|
1391
|
+
const isolation = value.isolation;
|
|
1392
|
+
if (typeof isolation !== "object" ||
|
|
1393
|
+
isolation === null ||
|
|
1394
|
+
!("environmentAllowlist" in isolation) ||
|
|
1395
|
+
!Array.isArray(isolation.environmentAllowlist)) {
|
|
1396
|
+
return undefined;
|
|
1397
|
+
}
|
|
1398
|
+
return isolation.environmentAllowlist.find((variable) => {
|
|
1399
|
+
if (typeof variable !== "string")
|
|
1400
|
+
return false;
|
|
1401
|
+
const normalized = variable.toUpperCase();
|
|
1402
|
+
return (normalized === "NODE_OPTIONS" ||
|
|
1403
|
+
normalized.startsWith("TESTFORGE_") ||
|
|
1404
|
+
normalized.startsWith("NODE_TEST_"));
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
export function parseVerificationRequest(value) {
|
|
1408
|
+
if (typeof value !== "object" ||
|
|
1409
|
+
value === null ||
|
|
1410
|
+
!("schemaVersion" in value) ||
|
|
1411
|
+
value.schemaVersion !== SCHEMA_VERSION) {
|
|
1412
|
+
throw new ContractError("SCHEMA_VERSION_UNSUPPORTED");
|
|
1413
|
+
}
|
|
1414
|
+
const rawPolicy = "policy" in value ? value.policy : undefined;
|
|
1415
|
+
if (typeof rawPolicy === "object" &&
|
|
1416
|
+
rawPolicy !== null &&
|
|
1417
|
+
"acceptedTargetOutcomes" in rawPolicy &&
|
|
1418
|
+
Array.isArray(rawPolicy.acceptedTargetOutcomes) &&
|
|
1419
|
+
rawPolicy.acceptedTargetOutcomes.some((outcome) => outcome !== "ASSERTION_FAILURE")) {
|
|
1420
|
+
throw new ContractError("UNSAFE_TARGET_OUTCOME", "v1 only admits attributed assertion failures as target evidence");
|
|
1421
|
+
}
|
|
1422
|
+
const unsafeNodeTestArgument = findUnsafeNodeTestArgument(value);
|
|
1423
|
+
if (unsafeNodeTestArgument !== undefined) {
|
|
1424
|
+
throw new ContractError("UNSAFE_NODE_TEST_ARGUMENT", unsafeNodeTestArgument);
|
|
1425
|
+
}
|
|
1426
|
+
const reservedEnvironmentVariable = findReservedEnvironmentVariable(value);
|
|
1427
|
+
if (reservedEnvironmentVariable !== undefined) {
|
|
1428
|
+
throw new ContractError("RESERVED_ENVIRONMENT_VARIABLE", reservedEnvironmentVariable);
|
|
1429
|
+
}
|
|
1430
|
+
const parsed = VerificationRequestSchema.safeParse(value);
|
|
1431
|
+
if (!parsed.success) {
|
|
1432
|
+
throw new ContractError("REQUEST_SCHEMA_INVALID", z.prettifyError(parsed.error));
|
|
1433
|
+
}
|
|
1434
|
+
const request = parsed.data;
|
|
1435
|
+
assertUniqueIdentifiers(request.worlds, "DUPLICATE_WORLD_ID");
|
|
1436
|
+
assertUniqueIdentifiers(request.candidates, "DUPLICATE_CANDIDATE_ID");
|
|
1437
|
+
assertWorldKinds(request);
|
|
1438
|
+
assertBudgets(request);
|
|
1439
|
+
return request;
|
|
1440
|
+
}
|
|
1441
|
+
export function parseRepositoryAnalysis(value) {
|
|
1442
|
+
const parsed = RepositoryAnalysisSchema.safeParse(value);
|
|
1443
|
+
if (!parsed.success) {
|
|
1444
|
+
throw new ContractError("REPOSITORY_ANALYSIS_INVALID", z.prettifyError(parsed.error));
|
|
1445
|
+
}
|
|
1446
|
+
if (parsed.data.fileCount !== parsed.data.files.length) {
|
|
1447
|
+
throw new ContractError("REPOSITORY_ANALYSIS_INCONSISTENT", `fileCount=${parsed.data.fileCount}, files=${parsed.data.files.length}`);
|
|
1448
|
+
}
|
|
1449
|
+
return parsed.data;
|
|
1450
|
+
}
|
|
1451
|
+
function repositoryAuditPortableKey(value) {
|
|
1452
|
+
return value.normalize("NFC").toLowerCase();
|
|
1453
|
+
}
|
|
1454
|
+
function compareRepositoryAuditPaths(left, right) {
|
|
1455
|
+
const leftKey = repositoryAuditPortableKey(left);
|
|
1456
|
+
const rightKey = repositoryAuditPortableKey(right);
|
|
1457
|
+
return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
|
|
1458
|
+
}
|
|
1459
|
+
function repositoryAuditModulePrefix(file) {
|
|
1460
|
+
const segments = file.split("/");
|
|
1461
|
+
return segments.length > 2 ? segments.slice(0, 2).join("/") : (segments[0] ?? file);
|
|
1462
|
+
}
|
|
1463
|
+
function expectedRepositoryAuditModules(files) {
|
|
1464
|
+
const grouped = new Map();
|
|
1465
|
+
for (const file of files) {
|
|
1466
|
+
const prefix = repositoryAuditModulePrefix(file.path);
|
|
1467
|
+
grouped.set(prefix, [...(grouped.get(prefix) ?? []), file]);
|
|
1468
|
+
}
|
|
1469
|
+
return [...grouped]
|
|
1470
|
+
.map(([pathPrefix, members]) => ({
|
|
1471
|
+
pathPrefix,
|
|
1472
|
+
files: members.length,
|
|
1473
|
+
factualTuple: [
|
|
1474
|
+
members.reduce((sum, file) => sum + (file.decisionPoints ?? 0), 0),
|
|
1475
|
+
members.reduce((sum, file) => sum + (file.noObservedTestReference?.length ?? 0), 0),
|
|
1476
|
+
members.reduce((sum, file) => sum + (file.fixCommitsInWindow ?? 0), 0),
|
|
1477
|
+
members.reduce((sum, file) => sum + (file.commitsInWindow ?? 0), 0),
|
|
1478
|
+
members.filter((file) => file.sourceChangedAfterAssociatedTest === true).length,
|
|
1479
|
+
members.reduce((sum, file) => sum + (file.weakAssertions ?? []).reduce((inner, item) => inner + item.count, 0), 0),
|
|
1480
|
+
],
|
|
1481
|
+
}))
|
|
1482
|
+
.sort((left, right) => {
|
|
1483
|
+
for (let index = 0; index < left.factualTuple.length; index += 1) {
|
|
1484
|
+
const delta = (right.factualTuple[index] ?? 0) - (left.factualTuple[index] ?? 0);
|
|
1485
|
+
if (delta !== 0)
|
|
1486
|
+
return delta;
|
|
1487
|
+
}
|
|
1488
|
+
return compareRepositoryAuditPaths(left.pathPrefix, right.pathPrefix);
|
|
1489
|
+
})
|
|
1490
|
+
.map((module, index) => ({ ...module, rank: index + 1 }));
|
|
1491
|
+
}
|
|
1492
|
+
function expectedRepositoryAuditCost(audit) {
|
|
1493
|
+
const request = audit.verificationRequest;
|
|
1494
|
+
const candidates = request?.candidates.length ?? 0;
|
|
1495
|
+
const worlds = request?.worlds.length ?? 0;
|
|
1496
|
+
const attempts = request?.policy.requiredAttempts ?? 0;
|
|
1497
|
+
const C = BigInt(candidates);
|
|
1498
|
+
const W = BigInt(worlds);
|
|
1499
|
+
const A = BigInt(attempts);
|
|
1500
|
+
const executions = (C + 1n) * W * A;
|
|
1501
|
+
const worldBytes = BigInt(request?.worlds.reduce((sum, world) => sum + world.files.reduce((fileSum, file) => fileSum + Buffer.byteLength(file.content), 0), 0) ?? 0);
|
|
1502
|
+
const candidateBytes = BigInt(request?.candidates.reduce((sum, candidate) => sum +
|
|
1503
|
+
candidate.files.reduce((fileSum, file) => fileSum + Buffer.byteLength(file.content), 0), 0) ?? 0);
|
|
1504
|
+
const overlayBytes = A * ((C + 1n) * worldBytes + W * candidateBytes);
|
|
1505
|
+
return {
|
|
1506
|
+
candidates,
|
|
1507
|
+
worlds,
|
|
1508
|
+
attempts,
|
|
1509
|
+
executions: executions.toString(),
|
|
1510
|
+
controlExecutions: (W * A).toString(),
|
|
1511
|
+
candidateExecutions: (C * W * A).toString(),
|
|
1512
|
+
overlayBytes: overlayBytes.toString(),
|
|
1513
|
+
materializationBytes: (BigInt(audit.repositoryBytes) * (executions + 1n) +
|
|
1514
|
+
overlayBytes).toString(),
|
|
1515
|
+
timeoutLimitMs: (executions * BigInt(request?.budgets.timeoutMsPerExecution ?? 0)).toString(),
|
|
1516
|
+
capturedStreamLimitBytes: (executions *
|
|
1517
|
+
BigInt(request?.budgets.maximumOutputBytes ?? 0) *
|
|
1518
|
+
2n).toString(),
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
export function parseRepositoryAudit(value) {
|
|
1522
|
+
const parsed = RepositoryAuditSchema.safeParse(value);
|
|
1523
|
+
if (!parsed.success) {
|
|
1524
|
+
throw new ContractError("REPOSITORY_AUDIT_INVALID", z.prettifyError(parsed.error));
|
|
1525
|
+
}
|
|
1526
|
+
if (parsed.data.modules.some((module, index) => module.rank !== index + 1)) {
|
|
1527
|
+
throw new ContractError("REPOSITORY_AUDIT_RANKS_INVALID");
|
|
1528
|
+
}
|
|
1529
|
+
const audit = parsed.data;
|
|
1530
|
+
if (audit.fileCount !== audit.files.length ||
|
|
1531
|
+
audit.repositoryBytes !== audit.files.reduce((sum, file) => sum + file.bytes, 0)) {
|
|
1532
|
+
throw new ContractError("REPOSITORY_AUDIT_INVENTORY_INCONSISTENT");
|
|
1533
|
+
}
|
|
1534
|
+
const fileKeys = audit.files.map((file) => repositoryAuditPortableKey(file.path));
|
|
1535
|
+
if (new Set(fileKeys).size !== fileKeys.length ||
|
|
1536
|
+
fileKeys.some((key, index) => index > 0 && (fileKeys[index - 1] ?? "") >= key)) {
|
|
1537
|
+
throw new ContractError("REPOSITORY_AUDIT_FILES_INVALID");
|
|
1538
|
+
}
|
|
1539
|
+
for (const file of audit.files) {
|
|
1540
|
+
const arrays = [file.declaredExports, file.noObservedTestReference, file.associatedTests];
|
|
1541
|
+
const weakCategories = file.weakAssertions?.map((item) => item.category) ?? [];
|
|
1542
|
+
if (arrays.some((items) => items !== null &&
|
|
1543
|
+
(new Set(items).size !== items.length ||
|
|
1544
|
+
items.some((item, index) => index > 0 && (items[index - 1] ?? "") >= item))) ||
|
|
1545
|
+
(file.declaredExports !== null &&
|
|
1546
|
+
file.noObservedTestReference?.some((name) => !file.declaredExports?.includes(name))) ||
|
|
1547
|
+
(file.supported
|
|
1548
|
+
? file.decisionPoints === null ||
|
|
1549
|
+
file.declaredExports === null ||
|
|
1550
|
+
file.noObservedTestReference === null ||
|
|
1551
|
+
file.weakAssertions === null
|
|
1552
|
+
: file.decisionPoints !== null ||
|
|
1553
|
+
file.declaredExports !== null ||
|
|
1554
|
+
file.noObservedTestReference !== null ||
|
|
1555
|
+
file.weakAssertions !== null) ||
|
|
1556
|
+
(file.commitsInWindow === null) !== (file.fixCommitsInWindow === null) ||
|
|
1557
|
+
(file.commitsInWindow !== null &&
|
|
1558
|
+
file.fixCommitsInWindow !== null &&
|
|
1559
|
+
file.fixCommitsInWindow > file.commitsInWindow) ||
|
|
1560
|
+
new Set(weakCategories).size !== weakCategories.length ||
|
|
1561
|
+
weakCategories.some((category, index) => index > 0 && (weakCategories[index - 1] ?? "") >= category)) {
|
|
1562
|
+
throw new ContractError("REPOSITORY_AUDIT_FILE_FACTS_INVALID");
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
const gitReasonCodes = new Set(audit.reasonCodes);
|
|
1566
|
+
const fatalGitReasonCodes = [
|
|
1567
|
+
"GIT_DISABLED",
|
|
1568
|
+
"GIT_UNAVAILABLE",
|
|
1569
|
+
"GIT_HEAD_UNAVAILABLE",
|
|
1570
|
+
"GIT_INDEX_UNAVAILABLE",
|
|
1571
|
+
"GIT_HISTORY_UNAVAILABLE",
|
|
1572
|
+
"GIT_HISTORY_SHALLOW",
|
|
1573
|
+
"GIT_HISTORY_TRUNCATED",
|
|
1574
|
+
];
|
|
1575
|
+
const gitReasonSemanticsValid = audit.git.supported
|
|
1576
|
+
? !fatalGitReasonCodes.some((code) => gitReasonCodes.has(code))
|
|
1577
|
+
: audit.git.headTimestamp === null
|
|
1578
|
+
? audit.git.shallow === null &&
|
|
1579
|
+
audit.git.truncated === null &&
|
|
1580
|
+
["GIT_DISABLED", "GIT_UNAVAILABLE", "GIT_HEAD_UNAVAILABLE"].some((code) => gitReasonCodes.has(code))
|
|
1581
|
+
: audit.git.shallow === true
|
|
1582
|
+
? gitReasonCodes.has("GIT_HISTORY_SHALLOW") && audit.git.truncated === null
|
|
1583
|
+
: audit.git.truncated === true
|
|
1584
|
+
? gitReasonCodes.has("GIT_HISTORY_TRUNCATED") && audit.git.shallow === false
|
|
1585
|
+
: ["GIT_INDEX_UNAVAILABLE", "GIT_HISTORY_UNAVAILABLE"].some((code) => gitReasonCodes.has(code));
|
|
1586
|
+
if (audit.reasonCodes.some((code, index) => index > 0 && (audit.reasonCodes[index - 1] ?? "") >= code) ||
|
|
1587
|
+
(audit.git.supported &&
|
|
1588
|
+
(audit.git.headTimestamp === null ||
|
|
1589
|
+
audit.git.shallow !== false ||
|
|
1590
|
+
audit.git.truncated !== false)) ||
|
|
1591
|
+
!gitReasonSemanticsValid ||
|
|
1592
|
+
((!audit.git.supported || audit.git.shallow === true || audit.git.truncated === true) &&
|
|
1593
|
+
audit.files.some((file) => file.commitsInWindow !== null ||
|
|
1594
|
+
file.fixCommitsInWindow !== null ||
|
|
1595
|
+
file.sourceChangedAfterAssociatedTest !== null))) {
|
|
1596
|
+
throw new ContractError("REPOSITORY_AUDIT_GIT_FACTS_INVALID");
|
|
1597
|
+
}
|
|
1598
|
+
const expectedModules = expectedRepositoryAuditModules(audit.files);
|
|
1599
|
+
if (audit.modules.length !== expectedModules.length ||
|
|
1600
|
+
audit.modules.some((module, index) => {
|
|
1601
|
+
const expected = expectedModules[index];
|
|
1602
|
+
return (expected === undefined ||
|
|
1603
|
+
module.pathPrefix !== expected.pathPrefix ||
|
|
1604
|
+
module.rank !== expected.rank ||
|
|
1605
|
+
module.files !== expected.files ||
|
|
1606
|
+
module.factualTuple.some((value, tupleIndex) => value !== expected.factualTuple[tupleIndex]));
|
|
1607
|
+
})) {
|
|
1608
|
+
throw new ContractError("REPOSITORY_AUDIT_MODULES_INCONSISTENT");
|
|
1609
|
+
}
|
|
1610
|
+
if (!path.isAbsolute(audit.root) ||
|
|
1611
|
+
path.normalize(audit.root) !== audit.root ||
|
|
1612
|
+
JSON.stringify(audit.cost) !== JSON.stringify(expectedRepositoryAuditCost(audit)) ||
|
|
1613
|
+
(audit.verificationRequest === null) !==
|
|
1614
|
+
audit.reasonCodes.includes("VERIFICATION_REQUEST_UNAVAILABLE") ||
|
|
1615
|
+
audit.verificationRequest?.isolation.acknowledgedUnsafeExecution === true ||
|
|
1616
|
+
(audit.verificationRequest !== null && audit.verificationRequest.repository.root !== audit.root)) {
|
|
1617
|
+
throw new ContractError("REPOSITORY_AUDIT_VERIFICATION_INCONSISTENT");
|
|
1618
|
+
}
|
|
1619
|
+
return audit;
|
|
1620
|
+
}
|
|
1621
|
+
function initCanonicalize(value) {
|
|
1622
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
1623
|
+
return JSON.stringify(value);
|
|
1624
|
+
}
|
|
1625
|
+
if (typeof value === "number") {
|
|
1626
|
+
if (!Number.isFinite(value))
|
|
1627
|
+
throw new ContractError("REPOSITORY_INIT_CANONICAL_INVALID");
|
|
1628
|
+
return JSON.stringify(value);
|
|
1629
|
+
}
|
|
1630
|
+
if (Array.isArray(value))
|
|
1631
|
+
return `[${value.map(initCanonicalize).join(",")}]`;
|
|
1632
|
+
if (typeof value === "object") {
|
|
1633
|
+
const record = value;
|
|
1634
|
+
return `{${Object.keys(record)
|
|
1635
|
+
.sort()
|
|
1636
|
+
.map((key) => `${JSON.stringify(key)}:${initCanonicalize(record[key])}`)
|
|
1637
|
+
.join(",")}}`;
|
|
1638
|
+
}
|
|
1639
|
+
throw new ContractError("REPOSITORY_INIT_CANONICAL_INVALID");
|
|
1640
|
+
}
|
|
1641
|
+
function initDigest(value) {
|
|
1642
|
+
return `sha256:${createHash("sha256").update(initCanonicalize(value)).digest("hex")}`;
|
|
1643
|
+
}
|
|
1644
|
+
function initBytesDigest(value) {
|
|
1645
|
+
return `sha256:${createHash("sha256").update(value).digest("hex")}`;
|
|
1646
|
+
}
|
|
1647
|
+
function initPortablePath(value) {
|
|
1648
|
+
if (value.length === 0 ||
|
|
1649
|
+
value.includes("\0") ||
|
|
1650
|
+
value.includes("\\") ||
|
|
1651
|
+
/^(?:[a-zA-Z]:|[/]{1,2})/u.test(value) ||
|
|
1652
|
+
value.includes(":") ||
|
|
1653
|
+
path.posix.normalize(value) !== value) {
|
|
1654
|
+
return false;
|
|
1655
|
+
}
|
|
1656
|
+
const segments = value.split("/");
|
|
1657
|
+
if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
1658
|
+
return false;
|
|
1659
|
+
}
|
|
1660
|
+
return segments.every((segment) => {
|
|
1661
|
+
const hasControl = [...segment].some((character) => {
|
|
1662
|
+
const codePoint = character.codePointAt(0);
|
|
1663
|
+
return codePoint !== undefined && (codePoint <= 0x1f || codePoint === 0x7f);
|
|
1664
|
+
});
|
|
1665
|
+
return (segment.normalize("NFC") === segment &&
|
|
1666
|
+
!hasControl &&
|
|
1667
|
+
!/[<>"|?*]/u.test(segment) &&
|
|
1668
|
+
!/[. ]$/u.test(segment) &&
|
|
1669
|
+
!/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(segment));
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
function sortedUnique(values) {
|
|
1673
|
+
return values.every((value, index) => index === 0 || (values[index - 1] ?? "") < value);
|
|
1674
|
+
}
|
|
1675
|
+
function initPortableKey(value) {
|
|
1676
|
+
return value.toLowerCase().normalize("NFC");
|
|
1677
|
+
}
|
|
1678
|
+
function validateInitDetections(detections, code) {
|
|
1679
|
+
if (!sortedUnique(detections.ciProviders) ||
|
|
1680
|
+
!sortedUnique(detections.reasonCodes) ||
|
|
1681
|
+
(detections.testCommand !== null && !initCommandSafe(detections.testCommand))) {
|
|
1682
|
+
throw new ContractError(code);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
function initCommandSafe(command) {
|
|
1686
|
+
const absoluteLike = (value) => /^(?:[a-zA-Z]:|[\\/]{1,2})/u.test(value) || path.isAbsolute(value);
|
|
1687
|
+
return (command.executable.length > 0 &&
|
|
1688
|
+
!absoluteLike(command.executable) &&
|
|
1689
|
+
!/[\s;&|<>`]/u.test(command.executable) &&
|
|
1690
|
+
![...command.executable].some((character) => {
|
|
1691
|
+
const codePoint = character.codePointAt(0);
|
|
1692
|
+
return codePoint !== undefined && (codePoint <= 0x1f || codePoint === 0x7f);
|
|
1693
|
+
}) &&
|
|
1694
|
+
command.arguments.every((argument) => !absoluteLike(argument) &&
|
|
1695
|
+
![...argument].some((character) => {
|
|
1696
|
+
const codePoint = character.codePointAt(0);
|
|
1697
|
+
return codePoint !== undefined && (codePoint <= 0x1f || codePoint === 0x7f);
|
|
1698
|
+
})));
|
|
1699
|
+
}
|
|
1700
|
+
function expectedInitEvidenceKind(evidencePath) {
|
|
1701
|
+
if (evidencePath === "package.json" ||
|
|
1702
|
+
evidencePath === "pyproject.toml" ||
|
|
1703
|
+
evidencePath === "requirements.txt") {
|
|
1704
|
+
return "PACKAGE_MANIFEST";
|
|
1705
|
+
}
|
|
1706
|
+
if ([
|
|
1707
|
+
"pnpm-lock.yaml",
|
|
1708
|
+
"package-lock.json",
|
|
1709
|
+
"npm-shrinkwrap.json",
|
|
1710
|
+
"yarn.lock",
|
|
1711
|
+
"bun.lock",
|
|
1712
|
+
"bun.lockb",
|
|
1713
|
+
"uv.lock",
|
|
1714
|
+
"poetry.lock",
|
|
1715
|
+
"Pipfile.lock",
|
|
1716
|
+
].includes(evidencePath)) {
|
|
1717
|
+
return "LOCKFILE";
|
|
1718
|
+
}
|
|
1719
|
+
if (evidencePath.startsWith(".github/workflows/") ||
|
|
1720
|
+
evidencePath === ".gitlab-ci.yml" ||
|
|
1721
|
+
evidencePath === "azure-pipelines.yml" ||
|
|
1722
|
+
evidencePath === ".circleci/config.yml") {
|
|
1723
|
+
return "CI_CONFIG";
|
|
1724
|
+
}
|
|
1725
|
+
if (/((^|\/)test[^/]*|\.test|\.spec)\.(?:[cm]?[jt]s|tsx?|py)$/u.test(evidencePath)) {
|
|
1726
|
+
return "TEST_SOURCE";
|
|
1727
|
+
}
|
|
1728
|
+
return undefined;
|
|
1729
|
+
}
|
|
1730
|
+
export function parseRepositoryInitConfig(value) {
|
|
1731
|
+
const parsed = RepositoryInitConfigSchema.safeParse(value);
|
|
1732
|
+
if (!parsed.success) {
|
|
1733
|
+
throw new ContractError("REPOSITORY_INIT_CONFIG_INVALID", z.prettifyError(parsed.error));
|
|
1734
|
+
}
|
|
1735
|
+
const config = parsed.data;
|
|
1736
|
+
const candidateRootKeys = config.candidateRoots.map(initPortableKey);
|
|
1737
|
+
const baseTestFiles = config.adapter.kind === "node-test" ? config.adapter.baseTestFiles : [];
|
|
1738
|
+
const baseTestKeys = baseTestFiles.map(initPortableKey);
|
|
1739
|
+
if (!sortedUnique(config.repository.exclude) ||
|
|
1740
|
+
!sortedUnique(config.candidateRoots) ||
|
|
1741
|
+
[...config.repository.exclude, ...config.candidateRoots].some((entry) => !initPortablePath(entry)) ||
|
|
1742
|
+
!initCommandSafe(config.testCommand) ||
|
|
1743
|
+
!initCommandSafe({
|
|
1744
|
+
executable: config.adapter.executable,
|
|
1745
|
+
arguments: config.adapter.kind === "testforge-command" ? config.adapter.arguments : [],
|
|
1746
|
+
}) ||
|
|
1747
|
+
(config.adapter.kind === "node-test" && config.framework !== "node:test") ||
|
|
1748
|
+
!sortedUnique(baseTestKeys) ||
|
|
1749
|
+
baseTestFiles.some((entry) => expectedInitEvidenceKind(entry) !== "TEST_SOURCE") ||
|
|
1750
|
+
baseTestKeys.some((baseTestKey) => candidateRootKeys.some((candidateRootKey) => baseTestKey === candidateRootKey || baseTestKey.startsWith(`${candidateRootKey}/`))) ||
|
|
1751
|
+
(config.adapter.kind === "node-test" &&
|
|
1752
|
+
config.adapter.baseTestFiles.some((entry) => !initPortablePath(entry))) ||
|
|
1753
|
+
(config.adapter.kind === "testforge-command" &&
|
|
1754
|
+
config.adapter.arguments.some((argument) => path.isAbsolute(argument)))) {
|
|
1755
|
+
throw new ContractError("REPOSITORY_INIT_CONFIG_INCONSISTENT");
|
|
1756
|
+
}
|
|
1757
|
+
return config;
|
|
1758
|
+
}
|
|
1759
|
+
export function repositoryInitConfigDigest(config) {
|
|
1760
|
+
return initDigest(parseRepositoryInitConfig(config));
|
|
1761
|
+
}
|
|
1762
|
+
export function repositoryInitLockDigest(lock) {
|
|
1763
|
+
return initDigest(lock);
|
|
1764
|
+
}
|
|
1765
|
+
export function parseRepositoryInitLock(value) {
|
|
1766
|
+
const parsed = RepositoryInitLockSchema.safeParse(value);
|
|
1767
|
+
if (!parsed.success) {
|
|
1768
|
+
throw new ContractError("REPOSITORY_INIT_LOCK_INVALID", z.prettifyError(parsed.error));
|
|
1769
|
+
}
|
|
1770
|
+
const lock = parsed.data;
|
|
1771
|
+
const adapterEvidenceCount = lock.evidence.filter((entry) => entry.kind === "ADAPTER_CONFIG").length;
|
|
1772
|
+
validateInitDetections(lock.detections, "REPOSITORY_INIT_LOCK_INCONSISTENT");
|
|
1773
|
+
if (lock.detections.packageManager === null ||
|
|
1774
|
+
lock.detections.framework === null ||
|
|
1775
|
+
lock.detections.testCommand === null ||
|
|
1776
|
+
lock.detections.adapterRecommendation === "unavailable" ||
|
|
1777
|
+
(lock.detections.adapterRecommendation === "node-test" && adapterEvidenceCount !== 0) ||
|
|
1778
|
+
(lock.detections.adapterRecommendation === "operator-supplied" && adapterEvidenceCount !== 1) ||
|
|
1779
|
+
!sortedUnique(lock.evidence.map((entry) => entry.path)) ||
|
|
1780
|
+
lock.evidence.some((entry) => {
|
|
1781
|
+
if (!initPortablePath(entry.path))
|
|
1782
|
+
return true;
|
|
1783
|
+
const expectedKind = expectedInitEvidenceKind(entry.path);
|
|
1784
|
+
return entry.kind === "ADAPTER_CONFIG"
|
|
1785
|
+
? expectedKind !== undefined
|
|
1786
|
+
: expectedKind !== entry.kind;
|
|
1787
|
+
}) ||
|
|
1788
|
+
lock.lockDigest !==
|
|
1789
|
+
repositoryInitLockDigest({
|
|
1790
|
+
schemaVersion: lock.schemaVersion,
|
|
1791
|
+
configDigest: lock.configDigest,
|
|
1792
|
+
detector: lock.detector,
|
|
1793
|
+
evidence: lock.evidence,
|
|
1794
|
+
detections: lock.detections,
|
|
1795
|
+
})) {
|
|
1796
|
+
throw new ContractError("REPOSITORY_INIT_LOCK_INCONSISTENT");
|
|
1797
|
+
}
|
|
1798
|
+
return lock;
|
|
1799
|
+
}
|
|
1800
|
+
export function parseRepositoryInitResult(value) {
|
|
1801
|
+
const parsed = RepositoryInitResultSchema.safeParse(value);
|
|
1802
|
+
if (!parsed.success) {
|
|
1803
|
+
throw new ContractError("REPOSITORY_INIT_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
1804
|
+
}
|
|
1805
|
+
const result = parsed.data;
|
|
1806
|
+
validateInitDetections(result.detections, "REPOSITORY_INIT_RESULT_INCONSISTENT");
|
|
1807
|
+
const paths = result.files.map((file) => file.path);
|
|
1808
|
+
const actionPaths = result.actions.map((action) => action.path);
|
|
1809
|
+
const successWithPlan = ["CREATED", "WOULD_CREATE"].includes(result.status);
|
|
1810
|
+
let config;
|
|
1811
|
+
let lock;
|
|
1812
|
+
try {
|
|
1813
|
+
const configFile = result.files.find((file) => file.path === "assertledger.config.json");
|
|
1814
|
+
const lockFile = result.files.find((file) => file.path === "assertledger.lock.json");
|
|
1815
|
+
if (configFile !== undefined)
|
|
1816
|
+
config = parseRepositoryInitConfig(JSON.parse(configFile.content));
|
|
1817
|
+
if (lockFile !== undefined)
|
|
1818
|
+
lock = parseRepositoryInitLock(JSON.parse(lockFile.content));
|
|
1819
|
+
}
|
|
1820
|
+
catch (error) {
|
|
1821
|
+
throw new ContractError("REPOSITORY_INIT_RESULT_INCONSISTENT", error instanceof Error ? error.message : String(error));
|
|
1822
|
+
}
|
|
1823
|
+
const nodeBaseTestFiles = config?.adapter.kind === "node-test" ? config.adapter.baseTestFiles : [];
|
|
1824
|
+
const lockTestEvidence = new Set(lock?.evidence
|
|
1825
|
+
.filter((entry) => entry.kind === "TEST_SOURCE")
|
|
1826
|
+
.map((entry) => initPortableKey(entry.path)) ?? []);
|
|
1827
|
+
if (!sortedUnique(result.reasonCodes) ||
|
|
1828
|
+
!sortedUnique(paths) ||
|
|
1829
|
+
!sortedUnique(actionPaths) ||
|
|
1830
|
+
result.actions.some((action) => !paths.includes(action.path)) ||
|
|
1831
|
+
JSON.stringify(result.reasonCodes) !== JSON.stringify(result.detections.reasonCodes) ||
|
|
1832
|
+
result.files.some((file) => file.digest !== initBytesDigest(file.content) ||
|
|
1833
|
+
!file.content.endsWith("\n") ||
|
|
1834
|
+
`${initCanonicalize(JSON.parse(file.content))}\n` !== file.content) ||
|
|
1835
|
+
(successWithPlan && (result.files.length !== 2 || result.actions.length === 0)) ||
|
|
1836
|
+
result.actions.some((action) => (action.path === "assertledger.config.json" && action.kind !== "CREATE") ||
|
|
1837
|
+
(action.kind === "REGENERATE" && action.path !== "assertledger.lock.json")) ||
|
|
1838
|
+
(["BLOCKED", "CONFLICT", "UNCHANGED"].includes(result.status) && result.actions.length !== 0) ||
|
|
1839
|
+
(["BLOCKED", "CONFLICT"].includes(result.status) && result.files.length !== 0) ||
|
|
1840
|
+
(result.status === "UNCHANGED" && result.files.length !== 2) ||
|
|
1841
|
+
(config !== undefined &&
|
|
1842
|
+
(lock === undefined ||
|
|
1843
|
+
lock.configDigest !== repositoryInitConfigDigest(config) ||
|
|
1844
|
+
lock.detections.packageManager !== config.packageManager ||
|
|
1845
|
+
lock.detections.framework !== config.framework ||
|
|
1846
|
+
JSON.stringify(lock.detections.testCommand) !== JSON.stringify(config.testCommand) ||
|
|
1847
|
+
JSON.stringify(lock.detections) !== JSON.stringify(result.detections) ||
|
|
1848
|
+
nodeBaseTestFiles.some((file) => !lockTestEvidence.has(initPortableKey(file))))) ||
|
|
1849
|
+
result.nextCommands.length !== 1 ||
|
|
1850
|
+
result.nextCommands[0]?.executable !== "assertledger" ||
|
|
1851
|
+
JSON.stringify(result.nextCommands[0]?.arguments) !== JSON.stringify(["audit", ".", "--json"])) {
|
|
1852
|
+
throw new ContractError("REPOSITORY_INIT_RESULT_INCONSISTENT");
|
|
1853
|
+
}
|
|
1854
|
+
return result;
|
|
1855
|
+
}
|
|
1856
|
+
function isJsonObject(value) {
|
|
1857
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1858
|
+
}
|
|
1859
|
+
function manifestSummariesAreConsistent(manifest) {
|
|
1860
|
+
const engineError = manifest.decision.status === "ENGINE_ERROR";
|
|
1861
|
+
const invalidEvidence = manifest.repositoryDigest === "invalid" || manifest.policy.policyVersion === "invalid";
|
|
1862
|
+
if (engineError !== invalidEvidence)
|
|
1863
|
+
return false;
|
|
1864
|
+
if (engineError)
|
|
1865
|
+
return true;
|
|
1866
|
+
if (manifest.adapter.kind !== manifest.evidenceContext.adapter.name ||
|
|
1867
|
+
manifest.isolation.level !== manifest.evidenceContext.execution.isolation) {
|
|
1868
|
+
return false;
|
|
1869
|
+
}
|
|
1870
|
+
const configuration = manifest.evidenceContext.adapter.configuration;
|
|
1871
|
+
if (!isJsonObject(configuration) || configuration.kind !== manifest.adapter.kind)
|
|
1872
|
+
return false;
|
|
1873
|
+
if (manifest.adapter.kind === "testforge-command") {
|
|
1874
|
+
return (manifest.adapter.protocolVersion === manifest.evidenceContext.adapter.version &&
|
|
1875
|
+
configuration.protocolVersion === manifest.adapter.protocolVersion);
|
|
1876
|
+
}
|
|
1877
|
+
return true;
|
|
1878
|
+
}
|
|
1879
|
+
export function parseEvidenceManifest(value) {
|
|
1880
|
+
const parsed = EvidenceManifestSchema.safeParse(value);
|
|
1881
|
+
if (!parsed.success) {
|
|
1882
|
+
throw new ContractError("EVIDENCE_MANIFEST_INVALID", z.prettifyError(parsed.error));
|
|
1883
|
+
}
|
|
1884
|
+
const manifest = parsed.data;
|
|
1885
|
+
const worldIds = new Set(manifest.worlds.map((world) => world.id));
|
|
1886
|
+
const candidateIds = new Set(manifest.candidates.map((candidate) => candidate.id));
|
|
1887
|
+
const runIds = new Set(manifest.observations.map((observation) => observation.runId));
|
|
1888
|
+
const contextWorldIds = new Set(manifest.evidenceContext.worlds.map((world) => world.id));
|
|
1889
|
+
const inconsistent = !manifestSummariesAreConsistent(manifest) ||
|
|
1890
|
+
worldIds.size !== manifest.worlds.length ||
|
|
1891
|
+
candidateIds.size !== manifest.candidates.length ||
|
|
1892
|
+
runIds.size !== manifest.observations.length ||
|
|
1893
|
+
contextWorldIds.size !== manifest.evidenceContext.worlds.length ||
|
|
1894
|
+
contextWorldIds.size !== worldIds.size ||
|
|
1895
|
+
[...contextWorldIds].some((id) => !worldIds.has(id)) ||
|
|
1896
|
+
manifest.decision.selectedCandidateIds.some((id) => !candidateIds.has(id)) ||
|
|
1897
|
+
manifest.observations.some((observation) => !worldIds.has(observation.worldId) ||
|
|
1898
|
+
observation.candidateTestsDiscovered > observation.testsDiscovered ||
|
|
1899
|
+
(observation.candidateId !== null && !candidateIds.has(observation.candidateId))) ||
|
|
1900
|
+
manifest.candidates.some((candidate) => candidate.killedTargetIds.some((id) => !worldIds.has(id)) ||
|
|
1901
|
+
candidate.gates.some((gate) => gate.evidenceRunIds.some((id) => !runIds.has(id))));
|
|
1902
|
+
if (inconsistent) {
|
|
1903
|
+
throw new ContractError("EVIDENCE_MANIFEST_INCONSISTENT");
|
|
1904
|
+
}
|
|
1905
|
+
return manifest;
|
|
1906
|
+
}
|
|
1907
|
+
export function parseReplayResult(value) {
|
|
1908
|
+
const parsed = ReplayResultSchema.safeParse(value);
|
|
1909
|
+
if (!parsed.success) {
|
|
1910
|
+
throw new ContractError("REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
1911
|
+
}
|
|
1912
|
+
const result = parsed.data;
|
|
1913
|
+
if (result.valid !==
|
|
1914
|
+
(result.schemaValid &&
|
|
1915
|
+
result.decisionDigestValid &&
|
|
1916
|
+
result.artifactDigestValid &&
|
|
1917
|
+
result.decisionSemanticsValid)) {
|
|
1918
|
+
throw new ContractError("REPLAY_RESULT_INCONSISTENT");
|
|
1919
|
+
}
|
|
1920
|
+
return result;
|
|
1921
|
+
}
|
|
1922
|
+
function validateAgenticProfilePolicy(policy) {
|
|
1923
|
+
const laneIds = new Set();
|
|
1924
|
+
let previousMaximum = 0;
|
|
1925
|
+
for (const lane of policy.lanes) {
|
|
1926
|
+
if (laneIds.has(lane.id) || lane.maximumReferenceP95Ms <= previousMaximum) {
|
|
1927
|
+
throw new ContractError("AGENTIC_PROFILE_POLICY_INVALID");
|
|
1928
|
+
}
|
|
1929
|
+
laneIds.add(lane.id);
|
|
1930
|
+
previousMaximum = lane.maximumReferenceP95Ms;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
export function parseAgenticProfileRequest(value) {
|
|
1934
|
+
const parsed = AgenticProfileRequestSchema.safeParse(value);
|
|
1935
|
+
if (!parsed.success) {
|
|
1936
|
+
throw new ContractError("AGENTIC_PROFILE_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
1937
|
+
}
|
|
1938
|
+
const request = parsed.data;
|
|
1939
|
+
parseEvidenceManifest(request.manifest);
|
|
1940
|
+
validateAgenticProfilePolicy(request.policy);
|
|
1941
|
+
return request;
|
|
1942
|
+
}
|
|
1943
|
+
export function parseAgenticProfileReport(value) {
|
|
1944
|
+
const parsed = AgenticProfileReportSchema.safeParse(value);
|
|
1945
|
+
if (!parsed.success) {
|
|
1946
|
+
throw new ContractError("AGENTIC_PROFILE_REPORT_INVALID", z.prettifyError(parsed.error));
|
|
1947
|
+
}
|
|
1948
|
+
const report = parsed.data;
|
|
1949
|
+
parseEvidenceManifest(report.sourceManifest);
|
|
1950
|
+
validateAgenticProfilePolicy(report.policy);
|
|
1951
|
+
const candidateIds = new Set(report.candidates.map((candidate) => candidate.id));
|
|
1952
|
+
if (candidateIds.size !== report.candidates.length ||
|
|
1953
|
+
report.qualifiedCandidateIds.some((id) => !candidateIds.has(id))) {
|
|
1954
|
+
throw new ContractError("AGENTIC_PROFILE_REPORT_INCONSISTENT");
|
|
1955
|
+
}
|
|
1956
|
+
return report;
|
|
1957
|
+
}
|
|
1958
|
+
export function parseAgenticProfileReplayResult(value) {
|
|
1959
|
+
const parsed = AgenticProfileReplayResultSchema.safeParse(value);
|
|
1960
|
+
if (!parsed.success) {
|
|
1961
|
+
throw new ContractError("AGENTIC_PROFILE_REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
1962
|
+
}
|
|
1963
|
+
const result = parsed.data;
|
|
1964
|
+
if (result.valid !==
|
|
1965
|
+
(result.schemaValid &&
|
|
1966
|
+
result.sourceManifestValid &&
|
|
1967
|
+
result.policyDigestValid &&
|
|
1968
|
+
result.reportDigestValid &&
|
|
1969
|
+
result.semanticsValid)) {
|
|
1970
|
+
throw new ContractError("AGENTIC_PROFILE_REPLAY_RESULT_INCONSISTENT");
|
|
1971
|
+
}
|
|
1972
|
+
return result;
|
|
1973
|
+
}
|
|
1974
|
+
function validateAgenticBenchmarkInputs(request) {
|
|
1975
|
+
parseEvidenceManifest(request.sourceManifest);
|
|
1976
|
+
const { policy } = request;
|
|
1977
|
+
const selectedCandidates = request.sourceManifest.decision.selectedCandidateIds.map((id) => request.sourceManifest.candidates.find((candidate) => candidate.id === id));
|
|
1978
|
+
if (selectedCandidates.some((candidate) => candidate === undefined)) {
|
|
1979
|
+
throw new ContractError("AGENTIC_BENCHMARK_SOURCE_BINDING_INVALID");
|
|
1980
|
+
}
|
|
1981
|
+
const plannedPerCandidate = policy.coldMeasuredSamples + policy.warmupSamples + policy.warmMeasuredSamples;
|
|
1982
|
+
if (selectedCandidates.length * plannedPerCandidate > policy.maximumExecutions) {
|
|
1983
|
+
throw new ContractError("AGENTIC_BENCHMARK_EXECUTION_BUDGET_EXCEEDED");
|
|
1984
|
+
}
|
|
1985
|
+
const toolRoles = new Set();
|
|
1986
|
+
for (const tool of request.fingerprint.tools) {
|
|
1987
|
+
if (toolRoles.has(tool.role)) {
|
|
1988
|
+
throw new ContractError("AGENTIC_BENCHMARK_DUPLICATE_TOOL_ROLE", tool.role);
|
|
1989
|
+
}
|
|
1990
|
+
toolRoles.add(tool.role);
|
|
1991
|
+
}
|
|
1992
|
+
const expectedPhaseNames = [
|
|
1993
|
+
"PREPARATION",
|
|
1994
|
+
"STARTUP",
|
|
1995
|
+
"COMPILE_OR_COLLECTION",
|
|
1996
|
+
"EXECUTION",
|
|
1997
|
+
];
|
|
1998
|
+
const groups = new Map();
|
|
1999
|
+
for (const run of request.runs) {
|
|
2000
|
+
if (run.regime === "COLD" && run.role === "WARMUP") {
|
|
2001
|
+
throw new ContractError("AGENTIC_BENCHMARK_COLD_WARMUP_FORBIDDEN");
|
|
2002
|
+
}
|
|
2003
|
+
if (run.status === "COMPLETE") {
|
|
2004
|
+
const phaseTotalUs = run.phases.reduce((total, phase) => total + phase.durationUs, 0);
|
|
2005
|
+
if (run.phases.some((phase, index) => phase.phase !== expectedPhaseNames[index]) ||
|
|
2006
|
+
!Number.isSafeInteger(phaseTotalUs) ||
|
|
2007
|
+
run.totalUs !== phaseTotalUs) {
|
|
2008
|
+
throw new ContractError("AGENTIC_BENCHMARK_TIMING_INVALID");
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
const key = `${run.candidateId}\u0000${run.regime}\u0000${run.role}`;
|
|
2012
|
+
const ordinals = groups.get(key) ?? [];
|
|
2013
|
+
ordinals.push(run.ordinal);
|
|
2014
|
+
groups.set(key, ordinals);
|
|
2015
|
+
}
|
|
2016
|
+
for (const ordinals of groups.values()) {
|
|
2017
|
+
ordinals.sort((left, right) => left - right);
|
|
2018
|
+
if (ordinals.some((ordinal, index) => ordinal !== index + 1)) {
|
|
2019
|
+
throw new ContractError("AGENTIC_BENCHMARK_ORDINALS_INVALID");
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
const selectedById = new Map(selectedCandidates.map((candidate) => [candidate?.id, candidate]));
|
|
2023
|
+
for (const run of request.runs) {
|
|
2024
|
+
const candidate = selectedById.get(run.candidateId);
|
|
2025
|
+
if (candidate === undefined || candidate.status !== "ELIGIBLE") {
|
|
2026
|
+
throw new ContractError("AGENTIC_BENCHMARK_SUBJECT_INVALID", run.candidateId);
|
|
2027
|
+
}
|
|
2028
|
+
if (run.candidateDigest !== candidate.digest) {
|
|
2029
|
+
throw new ContractError("AGENTIC_BENCHMARK_CANDIDATE_DIGEST_MISMATCH", run.candidateId);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
for (const candidate of selectedCandidates) {
|
|
2033
|
+
if (candidate === undefined || candidate.status !== "ELIGIBLE") {
|
|
2034
|
+
throw new ContractError("AGENTIC_BENCHMARK_SUBJECT_INVALID");
|
|
2035
|
+
}
|
|
2036
|
+
const counts = { cold: 0, warmup: 0, warm: 0 };
|
|
2037
|
+
for (const run of request.runs) {
|
|
2038
|
+
if (run.candidateId !== candidate.id)
|
|
2039
|
+
continue;
|
|
2040
|
+
if (run.regime === "COLD")
|
|
2041
|
+
counts.cold += 1;
|
|
2042
|
+
else if (run.role === "WARMUP")
|
|
2043
|
+
counts.warmup += 1;
|
|
2044
|
+
else
|
|
2045
|
+
counts.warm += 1;
|
|
2046
|
+
}
|
|
2047
|
+
if (counts.cold !== policy.coldMeasuredSamples ||
|
|
2048
|
+
counts.warmup !== policy.warmupSamples ||
|
|
2049
|
+
counts.warm !== policy.warmMeasuredSamples) {
|
|
2050
|
+
throw new ContractError("AGENTIC_BENCHMARK_RUN_PLAN_INVALID", candidate.id);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
export function parseAgenticBenchmarkRequest(value) {
|
|
2055
|
+
const parsed = AgenticBenchmarkRequestSchema.safeParse(value);
|
|
2056
|
+
if (!parsed.success) {
|
|
2057
|
+
throw new ContractError("AGENTIC_BENCHMARK_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
2058
|
+
}
|
|
2059
|
+
validateAgenticBenchmarkInputs(parsed.data);
|
|
2060
|
+
return parsed.data;
|
|
2061
|
+
}
|
|
2062
|
+
export function parseAgenticBenchmarkArtifact(value) {
|
|
2063
|
+
const parsed = AgenticBenchmarkArtifactSchema.safeParse(value);
|
|
2064
|
+
if (!parsed.success) {
|
|
2065
|
+
throw new ContractError("AGENTIC_BENCHMARK_ARTIFACT_INVALID", z.prettifyError(parsed.error));
|
|
2066
|
+
}
|
|
2067
|
+
const artifact = parsed.data;
|
|
2068
|
+
validateAgenticBenchmarkInputs({
|
|
2069
|
+
schemaVersion: artifact.schemaVersion,
|
|
2070
|
+
sourceManifest: artifact.sourceManifest,
|
|
2071
|
+
referenceWorldId: artifact.referenceWorldId,
|
|
2072
|
+
policy: artifact.policy,
|
|
2073
|
+
protocol: artifact.protocol,
|
|
2074
|
+
fingerprint: artifact.fingerprint,
|
|
2075
|
+
runs: artifact.runs,
|
|
2076
|
+
});
|
|
2077
|
+
const summaryKeys = new Set();
|
|
2078
|
+
for (const summary of artifact.summaries) {
|
|
2079
|
+
const key = `${summary.candidateId}\u0000${summary.regime}`;
|
|
2080
|
+
if (summaryKeys.has(key)) {
|
|
2081
|
+
throw new ContractError("AGENTIC_BENCHMARK_SUMMARY_DUPLICATE");
|
|
2082
|
+
}
|
|
2083
|
+
summaryKeys.add(key);
|
|
2084
|
+
}
|
|
2085
|
+
return artifact;
|
|
2086
|
+
}
|
|
2087
|
+
export function parseAgenticBenchmarkReplayResult(value) {
|
|
2088
|
+
const parsed = AgenticBenchmarkReplayResultSchema.safeParse(value);
|
|
2089
|
+
if (!parsed.success) {
|
|
2090
|
+
throw new ContractError("AGENTIC_BENCHMARK_REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2091
|
+
}
|
|
2092
|
+
const result = parsed.data;
|
|
2093
|
+
if (result.valid !==
|
|
2094
|
+
(result.schemaValid &&
|
|
2095
|
+
result.sourceManifestValid &&
|
|
2096
|
+
result.sourceBindingValid &&
|
|
2097
|
+
result.policyDigestValid &&
|
|
2098
|
+
result.protocolDigestValid &&
|
|
2099
|
+
result.fingerprintDigestValid &&
|
|
2100
|
+
result.comparisonScopeDigestValid &&
|
|
2101
|
+
result.artifactDigestValid &&
|
|
2102
|
+
result.summarySemanticsValid)) {
|
|
2103
|
+
throw new ContractError("AGENTIC_BENCHMARK_REPLAY_RESULT_INCONSISTENT");
|
|
2104
|
+
}
|
|
2105
|
+
return result;
|
|
2106
|
+
}
|
|
2107
|
+
export function parseAgenticBenchmarkAcquisitionRequest(value) {
|
|
2108
|
+
const parsed = AgenticBenchmarkAcquisitionRequestSchema.safeParse(value);
|
|
2109
|
+
if (!parsed.success) {
|
|
2110
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
2111
|
+
}
|
|
2112
|
+
parseVerificationRequest(parsed.data.verificationRequest);
|
|
2113
|
+
if (!parsed.data.verificationRequest.worlds.some((world) => world.id === parsed.data.referenceWorldId && world.kind === "REFERENCE" && world.required)) {
|
|
2114
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_REFERENCE_INVALID");
|
|
2115
|
+
}
|
|
2116
|
+
const maximumAcquisitionExecutions = parsed.data.verificationRequest.policy.maximumSelectedCandidates *
|
|
2117
|
+
(parsed.data.policy.coldMeasuredSamples +
|
|
2118
|
+
parsed.data.policy.warmupSamples +
|
|
2119
|
+
parsed.data.policy.warmMeasuredSamples);
|
|
2120
|
+
if (!Number.isSafeInteger(maximumAcquisitionExecutions) ||
|
|
2121
|
+
maximumAcquisitionExecutions > parsed.data.policy.maximumExecutions) {
|
|
2122
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_EXECUTION_BUDGET_EXCEEDED");
|
|
2123
|
+
}
|
|
2124
|
+
const dependencyPaths = new Set(parsed.data.identityFiles.dependencyGraph);
|
|
2125
|
+
if (dependencyPaths.size !== parsed.data.identityFiles.dependencyGraph.length) {
|
|
2126
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_IDENTITY_INVALID");
|
|
2127
|
+
}
|
|
2128
|
+
return parsed.data;
|
|
2129
|
+
}
|
|
2130
|
+
export function parseAgenticBenchmarkAcquisitionResult(value) {
|
|
2131
|
+
const parsed = AgenticBenchmarkAcquisitionResultSchema.safeParse(value);
|
|
2132
|
+
if (!parsed.success) {
|
|
2133
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2134
|
+
}
|
|
2135
|
+
parseEvidenceManifest(parsed.data.sourceManifest);
|
|
2136
|
+
if (parsed.data.benchmarkArtifact !== null) {
|
|
2137
|
+
parseAgenticBenchmarkArtifact(parsed.data.benchmarkArtifact);
|
|
2138
|
+
}
|
|
2139
|
+
if ((parsed.data.status === "SOURCE_NOT_VERIFIED") !== (parsed.data.benchmarkArtifact === null)) {
|
|
2140
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_RESULT_INCONSISTENT");
|
|
2141
|
+
}
|
|
2142
|
+
return parsed.data;
|
|
2143
|
+
}
|
|
2144
|
+
export function parseAgenticBenchmarkAcquisitionReplayResult(value) {
|
|
2145
|
+
const parsed = AgenticBenchmarkAcquisitionReplayResultSchema.safeParse(value);
|
|
2146
|
+
if (!parsed.success) {
|
|
2147
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2148
|
+
}
|
|
2149
|
+
const result = parsed.data;
|
|
2150
|
+
if (result.valid !==
|
|
2151
|
+
(result.schemaValid &&
|
|
2152
|
+
result.sourceManifestValid &&
|
|
2153
|
+
result.sourceBindingValid &&
|
|
2154
|
+
result.artifactReplayValid &&
|
|
2155
|
+
result.contextBindingValid &&
|
|
2156
|
+
result.resultDigestValid &&
|
|
2157
|
+
result.statusSemanticsValid)) {
|
|
2158
|
+
throw new ContractError("AGENTIC_BENCHMARK_ACQUISITION_REPLAY_RESULT_INCONSISTENT");
|
|
2159
|
+
}
|
|
2160
|
+
return result;
|
|
2161
|
+
}
|
|
2162
|
+
function validateAgenticProfilePolicyV2(policy) {
|
|
2163
|
+
const laneIds = new Set();
|
|
2164
|
+
let previousMaximum = 0;
|
|
2165
|
+
for (const lane of policy.lanes) {
|
|
2166
|
+
if (laneIds.has(lane.id) || lane.maximumWarmTotalWallP95Us <= previousMaximum) {
|
|
2167
|
+
throw new ContractError("AGENTIC_PROFILE_V2_POLICY_INVALID");
|
|
2168
|
+
}
|
|
2169
|
+
laneIds.add(lane.id);
|
|
2170
|
+
previousMaximum = lane.maximumWarmTotalWallP95Us;
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
export function parseAgenticProfileRequestV2(value) {
|
|
2174
|
+
const parsed = AgenticProfileRequestV2Schema.safeParse(value);
|
|
2175
|
+
if (!parsed.success) {
|
|
2176
|
+
throw new ContractError("AGENTIC_PROFILE_V2_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
2177
|
+
}
|
|
2178
|
+
parseAgenticBenchmarkArtifact(parsed.data.benchmarkArtifact);
|
|
2179
|
+
validateAgenticProfilePolicyV2(parsed.data.policy);
|
|
2180
|
+
return parsed.data;
|
|
2181
|
+
}
|
|
2182
|
+
export function parseAgenticProfileReportV2(value) {
|
|
2183
|
+
const parsed = AgenticProfileReportV2Schema.safeParse(value);
|
|
2184
|
+
if (!parsed.success) {
|
|
2185
|
+
throw new ContractError("AGENTIC_PROFILE_V2_REPORT_INVALID", z.prettifyError(parsed.error));
|
|
2186
|
+
}
|
|
2187
|
+
const report = parsed.data;
|
|
2188
|
+
parseAgenticBenchmarkArtifact(report.benchmarkArtifact);
|
|
2189
|
+
validateAgenticProfilePolicyV2(report.policy);
|
|
2190
|
+
const universeIds = new Set(report.candidateUniverse.candidateIds);
|
|
2191
|
+
const candidateIds = new Set(report.candidates.map((candidate) => candidate.id));
|
|
2192
|
+
const excludedIds = new Set(report.candidateUniverse.excludedEligibleCandidateIds);
|
|
2193
|
+
if (universeIds.size !== report.candidateUniverse.candidateIds.length ||
|
|
2194
|
+
candidateIds.size !== report.candidates.length ||
|
|
2195
|
+
excludedIds.size !== report.candidateUniverse.excludedEligibleCandidateIds.length ||
|
|
2196
|
+
candidateIds.size !== universeIds.size ||
|
|
2197
|
+
[...candidateIds].some((id) => !universeIds.has(id)) ||
|
|
2198
|
+
[...excludedIds].some((id) => universeIds.has(id))) {
|
|
2199
|
+
throw new ContractError("AGENTIC_PROFILE_V2_REPORT_INCONSISTENT");
|
|
2200
|
+
}
|
|
2201
|
+
return report;
|
|
2202
|
+
}
|
|
2203
|
+
export function parseAgenticProfileReplayResultV2(value) {
|
|
2204
|
+
const parsed = AgenticProfileReplayResultV2Schema.safeParse(value);
|
|
2205
|
+
if (!parsed.success) {
|
|
2206
|
+
throw new ContractError("AGENTIC_PROFILE_V2_REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2207
|
+
}
|
|
2208
|
+
const result = parsed.data;
|
|
2209
|
+
if (result.valid !==
|
|
2210
|
+
(result.schemaValid &&
|
|
2211
|
+
result.sourceBenchmarkValid &&
|
|
2212
|
+
result.sourceBindingValid &&
|
|
2213
|
+
result.policyDigestValid &&
|
|
2214
|
+
result.reportDigestValid &&
|
|
2215
|
+
result.semanticsValid)) {
|
|
2216
|
+
throw new ContractError("AGENTIC_PROFILE_V2_REPLAY_RESULT_INCONSISTENT");
|
|
2217
|
+
}
|
|
2218
|
+
return result;
|
|
2219
|
+
}
|
|
2220
|
+
export function parseAgenticCorpusTrustPolicy(value) {
|
|
2221
|
+
const parsed = AgenticCorpusTrustPolicySchema.safeParse(value);
|
|
2222
|
+
if (!parsed.success) {
|
|
2223
|
+
throw new ContractError("AGENTIC_CORPUS_TRUST_POLICY_INVALID", z.prettifyError(parsed.error));
|
|
2224
|
+
}
|
|
2225
|
+
const keyIds = new Set(parsed.data.keys.map((key) => key.keyId));
|
|
2226
|
+
const sourceIds = new Set(parsed.data.sources.map((source) => source.sourceId));
|
|
2227
|
+
const sourceIdentityDigests = new Set(parsed.data.sources.map((source) => source.sourceIdentityDigest));
|
|
2228
|
+
if (keyIds.size !== parsed.data.keys.length ||
|
|
2229
|
+
sourceIds.size !== parsed.data.sources.length ||
|
|
2230
|
+
sourceIdentityDigests.size !== parsed.data.sources.length ||
|
|
2231
|
+
parsed.data.keys.some((key) => new Set(key.roles).size !== key.roles.length) ||
|
|
2232
|
+
parsed.data.sources.some((source) => new Set(source.authorizedAuthorSubjectIds).size !==
|
|
2233
|
+
source.authorizedAuthorSubjectIds.length ||
|
|
2234
|
+
new Set(source.authorizedReviewerSubjectIds).size !==
|
|
2235
|
+
source.authorizedReviewerSubjectIds.length)) {
|
|
2236
|
+
throw new ContractError("AGENTIC_CORPUS_TRUST_POLICY_INVALID");
|
|
2237
|
+
}
|
|
2238
|
+
return parsed.data;
|
|
2239
|
+
}
|
|
2240
|
+
export function parseAgenticCorpusProvenance(value) {
|
|
2241
|
+
const parsed = AgenticCorpusProvenanceSchema.safeParse(value);
|
|
2242
|
+
if (!parsed.success) {
|
|
2243
|
+
throw new ContractError("AGENTIC_CORPUS_PROVENANCE_INVALID", z.prettifyError(parsed.error));
|
|
2244
|
+
}
|
|
2245
|
+
if (new Set(parsed.data.execution.evidenceDigests).size !==
|
|
2246
|
+
parsed.data.execution.evidenceDigests.length) {
|
|
2247
|
+
throw new ContractError("AGENTIC_CORPUS_PROVENANCE_INVALID");
|
|
2248
|
+
}
|
|
2249
|
+
return parsed.data;
|
|
2250
|
+
}
|
|
2251
|
+
function assertPortableIdentifierCollection(values, code) {
|
|
2252
|
+
const portableKeys = new Set(values.map((value) => value.normalize("NFC").toLowerCase()));
|
|
2253
|
+
if (portableKeys.size !== values.length)
|
|
2254
|
+
throw new ContractError(code);
|
|
2255
|
+
}
|
|
2256
|
+
export function parseAgenticCorpusAllocationRequest(value) {
|
|
2257
|
+
const parsed = AgenticCorpusAllocationRequestSchema.safeParse(value);
|
|
2258
|
+
if (!parsed.success) {
|
|
2259
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
2260
|
+
}
|
|
2261
|
+
assertPortableIdentifierCollection(parsed.data.strata.map((stratum) => stratum.sourceId), "AGENTIC_CORPUS_ALLOCATION_REQUEST_INVALID");
|
|
2262
|
+
assertUniqueStrings(parsed.data.strata.map((stratum) => stratum.sourceIdentityDigest), "AGENTIC_CORPUS_ALLOCATION_REQUEST_INVALID");
|
|
2263
|
+
assertPortableIdentifierCollection(parsed.data.strata.flatMap((stratum) => stratum.caseIds), "AGENTIC_CORPUS_ALLOCATION_REQUEST_INVALID");
|
|
2264
|
+
if (parsed.data.strata.some((stratum) => stratum.calibrationCount >= stratum.caseIds.length))
|
|
2265
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_REQUEST_INVALID");
|
|
2266
|
+
return parsed.data;
|
|
2267
|
+
}
|
|
2268
|
+
export function parseAgenticCorpusAllocation(value) {
|
|
2269
|
+
const parsed = AgenticCorpusAllocationSchema.safeParse(value);
|
|
2270
|
+
if (!parsed.success) {
|
|
2271
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_INVALID", z.prettifyError(parsed.error));
|
|
2272
|
+
}
|
|
2273
|
+
const allocation = parsed.data;
|
|
2274
|
+
const stratumCalibrationCount = allocation.strata.reduce((total, stratum) => total + stratum.calibrationCount, 0);
|
|
2275
|
+
const stratumSourceCaseIds = allocation.strata.flatMap((stratum) => stratum.sourceCaseIds);
|
|
2276
|
+
const stratumCalibrationCaseIds = allocation.strata.flatMap((stratum) => stratum.calibrationCaseIds);
|
|
2277
|
+
const stratumHoldoutCaseIds = allocation.strata.flatMap((stratum) => stratum.holdoutCaseIds);
|
|
2278
|
+
if (allocation.calibrationCount !== stratumCalibrationCount ||
|
|
2279
|
+
allocation.calibrationCaseIds.length !== allocation.calibrationCount ||
|
|
2280
|
+
allocation.holdoutCaseIds.length !==
|
|
2281
|
+
allocation.sourceCaseIds.length - allocation.calibrationCount ||
|
|
2282
|
+
allocation.assignments.length !== allocation.sourceCaseIds.length ||
|
|
2283
|
+
new Set(allocation.strata.map((stratum) => stratum.sourceId)).size !==
|
|
2284
|
+
allocation.strata.length ||
|
|
2285
|
+
new Set(allocation.strata.map((stratum) => stratum.sourceIdentityDigest)).size !==
|
|
2286
|
+
allocation.strata.length ||
|
|
2287
|
+
allocation.strata.some((stratum) => stratum.calibrationCount >= stratum.sourceCaseIds.length ||
|
|
2288
|
+
stratum.calibrationCaseIds.length !== stratum.calibrationCount ||
|
|
2289
|
+
stratum.holdoutCaseIds.length !== stratum.sourceCaseIds.length - stratum.calibrationCount) ||
|
|
2290
|
+
new Set(stratumSourceCaseIds).size !== stratumSourceCaseIds.length ||
|
|
2291
|
+
new Set(stratumCalibrationCaseIds).size !== stratumCalibrationCaseIds.length ||
|
|
2292
|
+
new Set(stratumHoldoutCaseIds).size !== stratumHoldoutCaseIds.length) {
|
|
2293
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_INVALID");
|
|
2294
|
+
}
|
|
2295
|
+
assertPortableIdentifierCollection(allocation.sourceCaseIds, "AGENTIC_CORPUS_ALLOCATION_INVALID");
|
|
2296
|
+
assertPortableIdentifierCollection([...allocation.calibrationCaseIds, ...allocation.holdoutCaseIds], "AGENTIC_CORPUS_ALLOCATION_INVALID");
|
|
2297
|
+
assertPortableIdentifierCollection(allocation.assignments.map((assignment) => assignment.caseId), "AGENTIC_CORPUS_ALLOCATION_INVALID");
|
|
2298
|
+
return allocation;
|
|
2299
|
+
}
|
|
2300
|
+
export function parseAgenticCorpusAllocationReplayResult(value) {
|
|
2301
|
+
const parsed = AgenticCorpusAllocationReplayResultSchema.safeParse(value);
|
|
2302
|
+
if (!parsed.success) {
|
|
2303
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2304
|
+
}
|
|
2305
|
+
const result = parsed.data;
|
|
2306
|
+
if (result.valid !==
|
|
2307
|
+
(result.schemaValid &&
|
|
2308
|
+
result.allocationDigestValid &&
|
|
2309
|
+
result.sourceCaseIdsValid &&
|
|
2310
|
+
result.assignmentScoresValid &&
|
|
2311
|
+
result.partitionSemanticsValid)) {
|
|
2312
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_REPLAY_RESULT_INCONSISTENT");
|
|
2313
|
+
}
|
|
2314
|
+
return result;
|
|
2315
|
+
}
|
|
2316
|
+
function assertUniqueStrings(values, code) {
|
|
2317
|
+
if (new Set(values).size !== values.length)
|
|
2318
|
+
throw new ContractError(code);
|
|
2319
|
+
}
|
|
2320
|
+
export function parseAgenticCorpusAllocationCommitment(value) {
|
|
2321
|
+
const parsed = AgenticCorpusAllocationCommitmentSchema.safeParse(value);
|
|
2322
|
+
if (!parsed.success) {
|
|
2323
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID", z.prettifyError(parsed.error));
|
|
2324
|
+
}
|
|
2325
|
+
assertPortableIdentifierCollection(parsed.data.caseSet.map((item) => item.caseId), "AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID");
|
|
2326
|
+
assertUniqueStrings(parsed.data.signers.map((item) => item.keyId), "AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID");
|
|
2327
|
+
assertUniqueStrings(parsed.data.signers.map((item) => item.role), "AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID");
|
|
2328
|
+
assertPortableIdentifierCollection(parsed.data.strata.map((item) => item.sourceId), "AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID");
|
|
2329
|
+
assertUniqueStrings(parsed.data.strata.map((item) => item.sourceIdentityDigest), "AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID");
|
|
2330
|
+
const casesBySource = new Map();
|
|
2331
|
+
for (const item of parsed.data.caseSet) {
|
|
2332
|
+
const key = `${item.sourceId}\0${item.sourceIdentityDigest}`;
|
|
2333
|
+
casesBySource.set(key, (casesBySource.get(key) ?? 0) + 1);
|
|
2334
|
+
}
|
|
2335
|
+
if (parsed.data.strata.length !== casesBySource.size ||
|
|
2336
|
+
parsed.data.strata.some((stratum) => {
|
|
2337
|
+
const count = casesBySource.get(`${stratum.sourceId}\0${stratum.sourceIdentityDigest}`) ?? 0;
|
|
2338
|
+
return count < 2 || stratum.calibrationCount >= count;
|
|
2339
|
+
})) {
|
|
2340
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_COMMITMENT_INVALID");
|
|
2341
|
+
}
|
|
2342
|
+
return parsed.data;
|
|
2343
|
+
}
|
|
2344
|
+
export function parseAgenticCorpusAllocationReveal(value) {
|
|
2345
|
+
const parsed = AgenticCorpusAllocationRevealSchema.safeParse(value);
|
|
2346
|
+
if (!parsed.success) {
|
|
2347
|
+
throw new ContractError("AGENTIC_CORPUS_ALLOCATION_REVEAL_INVALID", z.prettifyError(parsed.error));
|
|
2348
|
+
}
|
|
2349
|
+
assertUniqueStrings(parsed.data.shares.map((item) => item.keyId), "AGENTIC_CORPUS_ALLOCATION_REVEAL_INVALID");
|
|
2350
|
+
return parsed.data;
|
|
2351
|
+
}
|
|
2352
|
+
function parseConjunctiveResult(schema, value, code) {
|
|
2353
|
+
const parsed = schema.safeParse(value);
|
|
2354
|
+
if (!parsed.success)
|
|
2355
|
+
throw new ContractError(code, z.prettifyError(parsed.error));
|
|
2356
|
+
const { valid: _valid, ...rails } = parsed.data;
|
|
2357
|
+
if (parsed.data.valid !== Object.values(rails).every(Boolean)) {
|
|
2358
|
+
throw new ContractError(`${code}_INCONSISTENT`);
|
|
2359
|
+
}
|
|
2360
|
+
return parsed.data;
|
|
2361
|
+
}
|
|
2362
|
+
export function parseAgenticCorpusAllocationCommitmentReplayResult(value) {
|
|
2363
|
+
return parseConjunctiveResult(AgenticCorpusAllocationCommitmentReplayResultSchema, value, "AGENTIC_CORPUS_ALLOCATION_COMMITMENT_REPLAY_RESULT_INVALID");
|
|
2364
|
+
}
|
|
2365
|
+
export function parseAgenticCorpusExperimentPlan(value) {
|
|
2366
|
+
const parsed = AgenticCorpusExperimentPlanSchema.safeParse(value);
|
|
2367
|
+
if (!parsed.success) {
|
|
2368
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_PLAN_INVALID", z.prettifyError(parsed.error));
|
|
2369
|
+
}
|
|
2370
|
+
const code = "AGENTIC_CORPUS_EXPERIMENT_PLAN_INVALID";
|
|
2371
|
+
assertPortableIdentifierCollection(parsed.data.subjects.map((item) => item.caseId), code);
|
|
2372
|
+
assertPortableIdentifierCollection(parsed.data.adapters.map((item) => item.adapterId), code);
|
|
2373
|
+
assertPortableIdentifierCollection(parsed.data.commands.map((item) => item.commandId), code);
|
|
2374
|
+
assertPortableIdentifierCollection(parsed.data.schedule.map((item) => item.runId), code);
|
|
2375
|
+
for (const arm of [parsed.data.arms.baseline, parsed.data.arms.profile]) {
|
|
2376
|
+
assertPortableIdentifierCollection(arm.candidateUniverse.map((candidate) => candidate.candidateId), code);
|
|
2377
|
+
assertPortableIdentifierCollection(arm.selectedCandidates.map((candidate) => candidate.candidateId), code);
|
|
2378
|
+
const universe = new Map(arm.candidateUniverse.map((candidate) => [candidate.candidateId, candidate.candidateDigest]));
|
|
2379
|
+
if (arm.selectedCandidates.some((candidate) => universe.get(candidate.candidateId) !== candidate.candidateDigest)) {
|
|
2380
|
+
throw new ContractError(code);
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
return parsed.data;
|
|
2384
|
+
}
|
|
2385
|
+
export function parseAgenticCorpusExperimentPlanReplayResult(value) {
|
|
2386
|
+
return parseConjunctiveResult(AgenticCorpusExperimentPlanReplayResultSchema, value, "AGENTIC_CORPUS_EXPERIMENT_PLAN_REPLAY_RESULT_INVALID");
|
|
2387
|
+
}
|
|
2388
|
+
function validateAgenticCorpusExperimentCommon(value, code) {
|
|
2389
|
+
assertPortableIdentifierCollection(value.payload.cases.map((item) => item.caseId), code);
|
|
2390
|
+
assertPortableIdentifierCollection(value.evidenceBindings.map((item) => item.runId), code);
|
|
2391
|
+
assertUniqueStrings(value.evidenceBindings.map((item) => item.receiptDigest), code);
|
|
2392
|
+
assertUniqueStrings(value.evidenceBindings.map((item) => item.receiptContentDigest), code);
|
|
2393
|
+
const runIds = [];
|
|
2394
|
+
for (const item of value.payload.cases) {
|
|
2395
|
+
for (const attempts of [item.baselineAttempts, item.profileAttempts]) {
|
|
2396
|
+
assertUniqueStrings(attempts.map((attempt) => String(attempt.ordinal)), code);
|
|
2397
|
+
for (const attempt of attempts)
|
|
2398
|
+
runIds.push(...Object.values(attempt.runIds));
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
assertUniqueStrings(runIds, code);
|
|
2402
|
+
}
|
|
2403
|
+
export function parseAgenticCorpusExperimentRequest(value) {
|
|
2404
|
+
const parsed = AgenticCorpusExperimentRequestSchema.safeParse(value);
|
|
2405
|
+
if (!parsed.success) {
|
|
2406
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
2407
|
+
}
|
|
2408
|
+
validateAgenticCorpusExperimentCommon(parsed.data, "AGENTIC_CORPUS_EXPERIMENT_REQUEST_INVALID");
|
|
2409
|
+
return parsed.data;
|
|
2410
|
+
}
|
|
2411
|
+
export function parseAgenticCorpusExperimentArtifact(value) {
|
|
2412
|
+
const parsed = AgenticCorpusExperimentArtifactSchema.safeParse(value);
|
|
2413
|
+
if (!parsed.success) {
|
|
2414
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_ARTIFACT_INVALID", z.prettifyError(parsed.error));
|
|
2415
|
+
}
|
|
2416
|
+
validateAgenticCorpusExperimentCommon(parsed.data, "AGENTIC_CORPUS_EXPERIMENT_ARTIFACT_INVALID");
|
|
2417
|
+
return parsed.data;
|
|
2418
|
+
}
|
|
2419
|
+
export function parseAgenticCorpusExperimentReplayRequest(value) {
|
|
2420
|
+
const parsed = AgenticCorpusExperimentReplayRequestSchema.safeParse(value);
|
|
2421
|
+
if (!parsed.success) {
|
|
2422
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_REPLAY_REQUEST_INVALID", z.prettifyError(parsed.error));
|
|
2423
|
+
}
|
|
2424
|
+
parseAgenticCorpusExperimentArtifact(parsed.data.artifact);
|
|
2425
|
+
return parsed.data;
|
|
2426
|
+
}
|
|
2427
|
+
export function parseAgenticCorpusExperimentReplayResult(value) {
|
|
2428
|
+
const parsed = AgenticCorpusExperimentReplayResultSchema.safeParse(value);
|
|
2429
|
+
if (!parsed.success) {
|
|
2430
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_REPLAY_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2431
|
+
}
|
|
2432
|
+
const result = parsed.data;
|
|
2433
|
+
const { valid: _valid, ...rails } = result;
|
|
2434
|
+
if (result.valid !== Object.values(rails).every(Boolean)) {
|
|
2435
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_REPLAY_RESULT_INCONSISTENT");
|
|
2436
|
+
}
|
|
2437
|
+
return result;
|
|
2438
|
+
}
|
|
2439
|
+
export function parseAgenticCorpusExperimentReceipt(value) {
|
|
2440
|
+
const parsed = AgenticCorpusExperimentReceiptSchema.safeParse(value);
|
|
2441
|
+
if (!parsed.success) {
|
|
2442
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_RECEIPT_INVALID", z.prettifyError(parsed.error));
|
|
2443
|
+
}
|
|
2444
|
+
return parsed.data;
|
|
2445
|
+
}
|
|
2446
|
+
export function parseAgenticCorpusExperimentStructuredResult(value) {
|
|
2447
|
+
const parsed = AgenticCorpusExperimentStructuredResultSchema.safeParse(value);
|
|
2448
|
+
if (!parsed.success) {
|
|
2449
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_STRUCTURED_RESULT_INVALID", z.prettifyError(parsed.error));
|
|
2450
|
+
}
|
|
2451
|
+
if (parsed.data.attributed && parsed.data.outcome !== "ASSERTION_FAILURE") {
|
|
2452
|
+
throw new ContractError("AGENTIC_CORPUS_EXPERIMENT_STRUCTURED_RESULT_INVALID");
|
|
2453
|
+
}
|
|
2454
|
+
return parsed.data;
|
|
2455
|
+
}
|
|
2456
|
+
function jsonSchemaFor(schema, id) {
|
|
2457
|
+
const generated = z.toJSONSchema(schema, {
|
|
2458
|
+
target: "draft-2020-12",
|
|
2459
|
+
reused: "ref",
|
|
2460
|
+
});
|
|
2461
|
+
return {
|
|
2462
|
+
...generated,
|
|
2463
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2464
|
+
$id: id,
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
export function verificationRequestJsonSchema() {
|
|
2468
|
+
return jsonSchemaFor(VerificationRequestSchema, "https://testforge.dev/schemas/verification-request.v1.json");
|
|
2469
|
+
}
|
|
2470
|
+
export function repositoryAnalysisJsonSchema() {
|
|
2471
|
+
return jsonSchemaFor(RepositoryAnalysisSchema, "https://testforge.dev/schemas/repository-analysis.v1.json");
|
|
2472
|
+
}
|
|
2473
|
+
export function repositoryAuditJsonSchema() {
|
|
2474
|
+
return jsonSchemaFor(RepositoryAuditSchema, "https://testforge.dev/schemas/repository-audit.v1.json");
|
|
2475
|
+
}
|
|
2476
|
+
export function repositoryInitConfigJsonSchema() {
|
|
2477
|
+
return jsonSchemaFor(RepositoryInitConfigSchema, "https://testforge.dev/schemas/repository-init-config.v1.json");
|
|
2478
|
+
}
|
|
2479
|
+
export function repositoryInitLockJsonSchema() {
|
|
2480
|
+
return jsonSchemaFor(RepositoryInitLockSchema, "https://testforge.dev/schemas/repository-init-lock.v1.json");
|
|
2481
|
+
}
|
|
2482
|
+
export function repositoryInitResultJsonSchema() {
|
|
2483
|
+
return jsonSchemaFor(RepositoryInitResultSchema, "https://testforge.dev/schemas/repository-init-result.v1.json");
|
|
2484
|
+
}
|
|
2485
|
+
export function evidenceManifestJsonSchema() {
|
|
2486
|
+
return jsonSchemaFor(EvidenceManifestSchema, "https://testforge.dev/schemas/evidence-manifest.v1.json");
|
|
2487
|
+
}
|
|
2488
|
+
export function replayResultJsonSchema() {
|
|
2489
|
+
return jsonSchemaFor(ReplayResultSchema, "https://testforge.dev/schemas/replay-result.v1.json");
|
|
2490
|
+
}
|
|
2491
|
+
export function agenticProfileRequestJsonSchema() {
|
|
2492
|
+
return jsonSchemaFor(AgenticProfileRequestSchema, "https://testforge.dev/schemas/agentic-profile-request.v1.json");
|
|
2493
|
+
}
|
|
2494
|
+
export function agenticProfileReportJsonSchema() {
|
|
2495
|
+
return jsonSchemaFor(AgenticProfileReportSchema, "https://testforge.dev/schemas/agentic-profile-report.v1.json");
|
|
2496
|
+
}
|
|
2497
|
+
export function agenticProfileReplayResultJsonSchema() {
|
|
2498
|
+
return jsonSchemaFor(AgenticProfileReplayResultSchema, "https://testforge.dev/schemas/agentic-profile-replay-result.v1.json");
|
|
2499
|
+
}
|
|
2500
|
+
export function agenticBenchmarkRequestJsonSchema() {
|
|
2501
|
+
return jsonSchemaFor(AgenticBenchmarkRequestSchema, "https://testforge.dev/schemas/agentic-benchmark-request.v1.json");
|
|
2502
|
+
}
|
|
2503
|
+
export function agenticBenchmarkArtifactJsonSchema() {
|
|
2504
|
+
return jsonSchemaFor(AgenticBenchmarkArtifactSchema, "https://testforge.dev/schemas/agentic-benchmark-artifact.v1.json");
|
|
2505
|
+
}
|
|
2506
|
+
export function agenticBenchmarkReplayResultJsonSchema() {
|
|
2507
|
+
return jsonSchemaFor(AgenticBenchmarkReplayResultSchema, "https://testforge.dev/schemas/agentic-benchmark-replay-result.v1.json");
|
|
2508
|
+
}
|
|
2509
|
+
export function agenticBenchmarkAcquisitionRequestJsonSchema() {
|
|
2510
|
+
return jsonSchemaFor(AgenticBenchmarkAcquisitionRequestSchema, "https://testforge.dev/schemas/agentic-benchmark-acquisition-request.v1.json");
|
|
2511
|
+
}
|
|
2512
|
+
export function agenticBenchmarkAcquisitionResultJsonSchema() {
|
|
2513
|
+
return jsonSchemaFor(AgenticBenchmarkAcquisitionResultSchema, "https://testforge.dev/schemas/agentic-benchmark-acquisition-result.v1.json");
|
|
2514
|
+
}
|
|
2515
|
+
export function agenticBenchmarkAcquisitionReplayResultJsonSchema() {
|
|
2516
|
+
return jsonSchemaFor(AgenticBenchmarkAcquisitionReplayResultSchema, "https://testforge.dev/schemas/agentic-benchmark-acquisition-replay-result.v1.json");
|
|
2517
|
+
}
|
|
2518
|
+
export function agenticProfileRequestV2JsonSchema() {
|
|
2519
|
+
return jsonSchemaFor(AgenticProfileRequestV2Schema, "https://testforge.dev/schemas/agentic-profile-request.v2.json");
|
|
2520
|
+
}
|
|
2521
|
+
export function agenticProfileReportV2JsonSchema() {
|
|
2522
|
+
return jsonSchemaFor(AgenticProfileReportV2Schema, "https://testforge.dev/schemas/agentic-profile-report.v2.json");
|
|
2523
|
+
}
|
|
2524
|
+
export function agenticProfileReplayResultV2JsonSchema() {
|
|
2525
|
+
return jsonSchemaFor(AgenticProfileReplayResultV2Schema, "https://testforge.dev/schemas/agentic-profile-replay-result.v2.json");
|
|
2526
|
+
}
|
|
2527
|
+
export function agenticCorpusTrustPolicyJsonSchema() {
|
|
2528
|
+
return jsonSchemaFor(AgenticCorpusTrustPolicySchema, "https://testforge.dev/schemas/agentic-corpus-trust-policy.v1.json");
|
|
2529
|
+
}
|
|
2530
|
+
export function agenticCorpusProvenanceJsonSchema() {
|
|
2531
|
+
return jsonSchemaFor(AgenticCorpusProvenanceSchema, "https://testforge.dev/schemas/agentic-corpus-provenance.v1.json");
|
|
2532
|
+
}
|
|
2533
|
+
export function agenticCorpusAllocationRequestJsonSchema() {
|
|
2534
|
+
return jsonSchemaFor(AgenticCorpusAllocationRequestSchema, "https://testforge.dev/schemas/agentic-corpus-allocation-request.v1.json");
|
|
2535
|
+
}
|
|
2536
|
+
export function agenticCorpusAllocationJsonSchema() {
|
|
2537
|
+
return jsonSchemaFor(AgenticCorpusAllocationSchema, "https://testforge.dev/schemas/agentic-corpus-allocation.v1.json");
|
|
2538
|
+
}
|
|
2539
|
+
export function agenticCorpusAllocationReplayResultJsonSchema() {
|
|
2540
|
+
return jsonSchemaFor(AgenticCorpusAllocationReplayResultSchema, "https://testforge.dev/schemas/agentic-corpus-allocation-replay-result.v1.json");
|
|
2541
|
+
}
|
|
2542
|
+
export function agenticCorpusAllocationCommitmentJsonSchema() {
|
|
2543
|
+
return jsonSchemaFor(AgenticCorpusAllocationCommitmentSchema, "https://testforge.dev/schemas/agentic-corpus-allocation-commitment.v1.json");
|
|
2544
|
+
}
|
|
2545
|
+
export function agenticCorpusAllocationRevealJsonSchema() {
|
|
2546
|
+
return jsonSchemaFor(AgenticCorpusAllocationRevealSchema, "https://testforge.dev/schemas/agentic-corpus-allocation-reveal.v1.json");
|
|
2547
|
+
}
|
|
2548
|
+
export function agenticCorpusAllocationCommitmentReplayResultJsonSchema() {
|
|
2549
|
+
return jsonSchemaFor(AgenticCorpusAllocationCommitmentReplayResultSchema, "https://testforge.dev/schemas/agentic-corpus-allocation-commitment-replay-result.v1.json");
|
|
2550
|
+
}
|
|
2551
|
+
export function agenticCorpusExperimentPlanJsonSchema() {
|
|
2552
|
+
return jsonSchemaFor(AgenticCorpusExperimentPlanSchema, "https://testforge.dev/schemas/agentic-corpus-experiment-plan.v1.json");
|
|
2553
|
+
}
|
|
2554
|
+
export function agenticCorpusExperimentPlanReplayResultJsonSchema() {
|
|
2555
|
+
return jsonSchemaFor(AgenticCorpusExperimentPlanReplayResultSchema, "https://testforge.dev/schemas/agentic-corpus-experiment-plan-replay-result.v1.json");
|
|
2556
|
+
}
|
|
2557
|
+
export function agenticCorpusExperimentRequestJsonSchema() {
|
|
2558
|
+
return jsonSchemaFor(AgenticCorpusExperimentRequestSchema, "https://testforge.dev/schemas/agentic-corpus-experiment-request.v1.json");
|
|
2559
|
+
}
|
|
2560
|
+
export function agenticCorpusExperimentArtifactJsonSchema() {
|
|
2561
|
+
return jsonSchemaFor(AgenticCorpusExperimentArtifactSchema, "https://testforge.dev/schemas/agentic-corpus-experiment-artifact.v1.json");
|
|
2562
|
+
}
|
|
2563
|
+
export function agenticCorpusExperimentReplayRequestJsonSchema() {
|
|
2564
|
+
return jsonSchemaFor(AgenticCorpusExperimentReplayRequestSchema, "https://testforge.dev/schemas/agentic-corpus-experiment-replay-request.v1.json");
|
|
2565
|
+
}
|
|
2566
|
+
export function agenticCorpusExperimentReplayResultJsonSchema() {
|
|
2567
|
+
return jsonSchemaFor(AgenticCorpusExperimentReplayResultSchema, "https://testforge.dev/schemas/agentic-corpus-experiment-replay-result.v1.json");
|
|
2568
|
+
}
|
|
2569
|
+
//# sourceMappingURL=index.js.map
|