eval-quality 0.1.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/LICENSE +190 -0
- package/README.md +355 -0
- package/corpus/dev/README.md +36 -0
- package/corpus/dev/compile-seal-example/brief.json +1 -0
- package/corpus/dev/compile-seal-example/contract.json +1 -0
- package/corpus/dev/contracts/absent-collection-locations.json +1 -0
- package/corpus/dev/contracts/absent-sibling-groups.json +1 -0
- package/corpus/dev/contracts/absent-success-indicator.json +1 -0
- package/corpus/dev/contracts/empty-channel-roles.json +1 -0
- package/corpus/dev/contracts/empty-collection-locations.json +1 -0
- package/corpus/dev/contracts/empty-request-shapes.json +1 -0
- package/corpus/dev/contracts/empty-sibling-groups.json +1 -0
- package/corpus/dev/contracts/no-collection-quantifier.json +1 -0
- package/corpus/dev/contracts/no-operation-inventory.json +1 -0
- package/corpus/dev/contracts/no-read-back-relation.json +1 -0
- package/corpus/dev/contracts/no-state-change-marker.json +1 -0
- package/corpus/dev/contracts/no-type-violating-step.json +1 -0
- package/corpus/dev/contracts/per-key-split-oracles.json +1 -0
- package/corpus/dev/contracts/satisfied-declarations.json +1 -0
- package/corpus/dev/contracts/single-required-response-key.json +1 -0
- package/corpus/dev/contracts/split-indicator-oracle.json +1 -0
- package/corpus/dev/contracts/unaddressed-parameter-sibling.json +1 -0
- package/corpus/dev/contracts/unnamed-reference-set.json +1 -0
- package/corpus/dev/contracts/wrong-cardinality-form.json +1 -0
- package/corpus/dev/index.json +1 -0
- package/dist/adapters/index.d.ts +12 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/local-corpus-adapter.d.ts +7 -0
- package/dist/adapters/local-corpus-adapter.js +78 -0
- package/dist/adapters/node-file-system-adapter.d.ts +7 -0
- package/dist/adapters/node-file-system-adapter.js +39 -0
- package/dist/adapters/port-boundary.d.ts +18 -0
- package/dist/adapters/port-boundary.js +83 -0
- package/dist/adapters/system-clock-adapter.d.ts +10 -0
- package/dist/adapters/system-clock-adapter.js +18 -0
- package/dist/application/compile.d.ts +4 -0
- package/dist/application/compile.js +24 -0
- package/dist/application/diagnostics.d.ts +22 -0
- package/dist/application/diagnostics.js +18 -0
- package/dist/application/index.d.ts +23 -0
- package/dist/application/index.js +17 -0
- package/dist/application/invoke-port.d.ts +2 -0
- package/dist/application/invoke-port.js +45 -0
- package/dist/application/preflight.d.ts +27 -0
- package/dist/application/preflight.js +131 -0
- package/dist/application/seal.d.ts +4 -0
- package/dist/application/seal.js +28 -0
- package/dist/application/serialize.d.ts +6 -0
- package/dist/application/serialize.js +9 -0
- package/dist/cli/arguments.d.ts +28 -0
- package/dist/cli/arguments.js +167 -0
- package/dist/cli/exit-codes.d.ts +36 -0
- package/dist/cli/exit-codes.js +39 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +143 -0
- package/dist/cli/render.d.ts +26 -0
- package/dist/cli/render.js +53 -0
- package/dist/cli/run.d.ts +41 -0
- package/dist/cli/run.js +203 -0
- package/dist/core/canonical/canonicalize.d.ts +1 -0
- package/dist/core/canonical/canonicalize.js +113 -0
- package/dist/core/canonical/digest.d.ts +7 -0
- package/dist/core/canonical/digest.js +81 -0
- package/dist/core/canonical/scan-json.d.ts +1 -0
- package/dist/core/canonical/scan-json.js +298 -0
- package/dist/core/canonical/value-domain.d.ts +4 -0
- package/dist/core/canonical/value-domain.js +113 -0
- package/dist/core/compile/compile.d.ts +24 -0
- package/dist/core/compile/compile.js +67 -0
- package/dist/core/compile/declarations.d.ts +5 -0
- package/dist/core/compile/declarations.js +22 -0
- package/dist/core/compile/expression-legality.d.ts +14 -0
- package/dist/core/compile/expression-legality.js +346 -0
- package/dist/core/compile/forbidden-inputs.d.ts +5 -0
- package/dist/core/compile/forbidden-inputs.js +19 -0
- package/dist/core/compile/interface-inventory.d.ts +10 -0
- package/dist/core/compile/interface-inventory.js +55 -0
- package/dist/core/compile/oracle-alignment.d.ts +14 -0
- package/dist/core/compile/oracle-alignment.js +93 -0
- package/dist/core/compile/reachability.d.ts +17 -0
- package/dist/core/compile/reachability.js +177 -0
- package/dist/core/compile/rubrics.d.ts +55 -0
- package/dist/core/compile/rubrics.js +198 -0
- package/dist/core/compile/scripting-bound.d.ts +5 -0
- package/dist/core/compile/scripting-bound.js +151 -0
- package/dist/core/compile/sensitivity-witness.d.ts +73 -0
- package/dist/core/compile/sensitivity-witness.js +232 -0
- package/dist/core/compile/waivers.d.ts +3 -0
- package/dist/core/compile/waivers.js +21 -0
- package/dist/core/coverage/coverage.d.ts +18 -0
- package/dist/core/coverage/coverage.js +47 -0
- package/dist/core/coverage/relevance.d.ts +75 -0
- package/dist/core/coverage/relevance.js +186 -0
- package/dist/core/coverage/rules.d.ts +7 -0
- package/dist/core/coverage/rules.js +18 -0
- package/dist/core/coverage/satisfaction.d.ts +107 -0
- package/dist/core/coverage/satisfaction.js +415 -0
- package/dist/core/coverage/table.d.ts +26 -0
- package/dist/core/coverage/table.js +222 -0
- package/dist/core/declared-inputs.d.ts +16 -0
- package/dist/core/declared-inputs.js +18 -0
- package/dist/core/evaluate/evidence-resolution.d.ts +54 -0
- package/dist/core/evaluate/evidence-resolution.js +153 -0
- package/dist/core/evaluate/operators.d.ts +87 -0
- package/dist/core/evaluate/operators.js +350 -0
- package/dist/core/evaluate/resolution.d.ts +40 -0
- package/dist/core/evaluate/resolution.js +336 -0
- package/dist/core/evaluate/resolved-value.d.ts +9 -0
- package/dist/core/evaluate/resolved-value.js +6 -0
- package/dist/core/failure-codes.d.ts +18 -0
- package/dist/core/failure-codes.js +50 -0
- package/dist/core/lineage/chain.d.ts +49 -0
- package/dist/core/lineage/chain.js +210 -0
- package/dist/core/lineage/freeze.d.ts +12 -0
- package/dist/core/lineage/freeze.js +35 -0
- package/dist/core/lineage/stage-table.d.ts +43 -0
- package/dist/core/lineage/stage-table.js +106 -0
- package/dist/core/preflight/plan.d.ts +67 -0
- package/dist/core/preflight/plan.js +313 -0
- package/dist/core/preflight/projection.d.ts +40 -0
- package/dist/core/preflight/projection.js +96 -0
- package/dist/core/preflight/reduce.d.ts +8 -0
- package/dist/core/preflight/reduce.js +180 -0
- package/dist/core/preflight/witness-evidence.d.ts +42 -0
- package/dist/core/preflight/witness-evidence.js +88 -0
- package/dist/core/probe/target-policy.d.ts +63 -0
- package/dist/core/probe/target-policy.js +328 -0
- package/dist/core/schemas/artifact-reference.d.ts +19 -0
- package/dist/core/schemas/artifact-reference.js +30 -0
- package/dist/core/schemas/artifact.d.ts +1153 -0
- package/dist/core/schemas/artifact.js +84 -0
- package/dist/core/schemas/constraint-ledger.d.ts +57 -0
- package/dist/core/schemas/constraint-ledger.js +143 -0
- package/dist/core/schemas/eval-contract.d.ts +402 -0
- package/dist/core/schemas/eval-contract.js +147 -0
- package/dist/core/schemas/evaluator-configuration.d.ts +37 -0
- package/dist/core/schemas/evaluator-configuration.js +43 -0
- package/dist/core/schemas/evidence-artifact.d.ts +471 -0
- package/dist/core/schemas/evidence-artifact.js +232 -0
- package/dist/core/schemas/expression.d.ts +197 -0
- package/dist/core/schemas/expression.js +284 -0
- package/dist/core/schemas/faults.d.ts +9 -0
- package/dist/core/schemas/faults.js +32 -0
- package/dist/core/schemas/interface.d.ts +417 -0
- package/dist/core/schemas/interface.js +115 -0
- package/dist/core/schemas/isolation-manifest.d.ts +136 -0
- package/dist/core/schemas/isolation-manifest.js +92 -0
- package/dist/core/schemas/lineage.d.ts +21 -0
- package/dist/core/schemas/lineage.js +28 -0
- package/dist/core/schemas/oracle.d.ts +72 -0
- package/dist/core/schemas/oracle.js +35 -0
- package/dist/core/schemas/plan.d.ts +115 -0
- package/dist/core/schemas/plan.js +58 -0
- package/dist/core/schemas/pointer.d.ts +63 -0
- package/dist/core/schemas/pointer.js +94 -0
- package/dist/core/schemas/port-messages.d.ts +103 -0
- package/dist/core/schemas/port-messages.js +90 -0
- package/dist/core/schemas/preflight-verdict.d.ts +60 -0
- package/dist/core/schemas/preflight-verdict.js +38 -0
- package/dist/core/schemas/primitives.d.ts +78 -0
- package/dist/core/schemas/primitives.js +121 -0
- package/dist/core/schemas/private-artifact-manifest.d.ts +56 -0
- package/dist/core/schemas/private-artifact-manifest.js +46 -0
- package/dist/core/schemas/probe-body.d.ts +25 -0
- package/dist/core/schemas/probe-body.js +23 -0
- package/dist/core/schemas/probe-policy.d.ts +76 -0
- package/dist/core/schemas/probe-policy.js +33 -0
- package/dist/core/schemas/probe.d.ts +189 -0
- package/dist/core/schemas/probe.js +82 -0
- package/dist/core/schemas/publish.d.ts +30 -0
- package/dist/core/schemas/publish.js +135 -0
- package/dist/core/schemas/reference-set.d.ts +18 -0
- package/dist/core/schemas/reference-set.js +27 -0
- package/dist/core/schemas/rubric.d.ts +62 -0
- package/dist/core/schemas/rubric.js +68 -0
- package/dist/core/schemas/scoring-policy.d.ts +28 -0
- package/dist/core/schemas/scoring-policy.js +51 -0
- package/dist/core/schemas/sealed-evaluator-brief.d.ts +80 -0
- package/dist/core/schemas/sealed-evaluator-brief.js +59 -0
- package/dist/core/schemas/sealed-run-record.d.ts +382 -0
- package/dist/core/schemas/sealed-run-record.js +215 -0
- package/dist/core/schemas/sensitivity-witness.d.ts +138 -0
- package/dist/core/schemas/sensitivity-witness.js +86 -0
- package/dist/core/schemas/verdict.d.ts +25 -0
- package/dist/core/schemas/verdict.js +20 -0
- package/dist/core/schemas/waiver.d.ts +17 -0
- package/dist/core/schemas/waiver.js +24 -0
- package/dist/core/seal/derived-reference.d.ts +36 -0
- package/dist/core/seal/derived-reference.js +383 -0
- package/dist/core/seal/direction-prose.d.ts +13 -0
- package/dist/core/seal/direction-prose.js +120 -0
- package/dist/core/seal/plan-index.d.ts +63 -0
- package/dist/core/seal/plan-index.js +155 -0
- package/dist/core/seal/scripting-audit.d.ts +15 -0
- package/dist/core/seal/scripting-audit.js +51 -0
- package/dist/core/seal/seal.d.ts +18 -0
- package/dist/core/seal/seal.js +155 -0
- package/dist/core/stage-contracts.d.ts +30 -0
- package/dist/core/stage-contracts.js +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +22 -0
- package/dist/ports/clock-port.d.ts +13 -0
- package/dist/ports/clock-port.js +7 -0
- package/dist/ports/corpus-port.d.ts +16 -0
- package/dist/ports/corpus-port.js +7 -0
- package/dist/ports/environment-probe-port.d.ts +76 -0
- package/dist/ports/environment-probe-port.js +32 -0
- package/dist/ports/file-system-port.d.ts +27 -0
- package/dist/ports/file-system-port.js +11 -0
- package/dist/ports/port.d.ts +33 -0
- package/dist/ports/port.js +14 -0
- package/dist/testing/conformance.d.ts +88 -0
- package/dist/testing/conformance.js +281 -0
- package/dist/testing/index.d.ts +26 -0
- package/dist/testing/index.js +18 -0
- package/dist/testing/probe-conformance.d.ts +45 -0
- package/dist/testing/probe-conformance.js +186 -0
- package/package.json +130 -0
- package/schemas/artifact-reference.schema.json +64 -0
- package/schemas/eval-contract.schema.json +2145 -0
- package/schemas/evaluator-configuration.schema.json +199 -0
- package/schemas/evidence-artifact.schema.json +1229 -0
- package/schemas/isolation-manifest.schema.json +394 -0
- package/schemas/preflight-verdict.schema.json +114 -0
- package/schemas/private-artifact-manifest.schema.json +103 -0
- package/schemas/probe.schema.json +1151 -0
- package/schemas/rubric.schema.json +148 -0
- package/schemas/scoring-policy.schema.json +90 -0
- package/schemas/sealed-evaluator-brief.schema.json +268 -0
- package/schemas/sealed-run-record.schema.json +875 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** AD-35's default-deny target authorization, as a declared mapping. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* One authorized target. AD-35: "An adapter denies by default and permits only
|
|
5
|
+
* what that mapping names." Every field is required and none has a default:
|
|
6
|
+
* an omitted cap is an unbounded cap, which is the failure this declaration
|
|
7
|
+
* exists to prevent.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ProbeTargetAuthorization: z.ZodObject<{
|
|
10
|
+
interfaceId: z.ZodString;
|
|
11
|
+
scheme: z.ZodEnum<{
|
|
12
|
+
http: "http";
|
|
13
|
+
https: "https";
|
|
14
|
+
}>;
|
|
15
|
+
host: z.ZodString;
|
|
16
|
+
port: z.ZodInt;
|
|
17
|
+
addresses: z.ZodArray<z.ZodString>;
|
|
18
|
+
methods: z.ZodArray<z.ZodEnum<{
|
|
19
|
+
DELETE: "DELETE";
|
|
20
|
+
GET: "GET";
|
|
21
|
+
HEAD: "HEAD";
|
|
22
|
+
OPTIONS: "OPTIONS";
|
|
23
|
+
PATCH: "PATCH";
|
|
24
|
+
POST: "POST";
|
|
25
|
+
PUT: "PUT";
|
|
26
|
+
}>>;
|
|
27
|
+
safeMethods: z.ZodArray<z.ZodEnum<{
|
|
28
|
+
DELETE: "DELETE";
|
|
29
|
+
GET: "GET";
|
|
30
|
+
HEAD: "HEAD";
|
|
31
|
+
OPTIONS: "OPTIONS";
|
|
32
|
+
PATCH: "PATCH";
|
|
33
|
+
POST: "POST";
|
|
34
|
+
PUT: "PUT";
|
|
35
|
+
}>>;
|
|
36
|
+
maxRedirects: z.ZodInt;
|
|
37
|
+
maxElapsedMs: z.ZodInt;
|
|
38
|
+
maxRequestBytes: z.ZodInt;
|
|
39
|
+
maxResponseBytes: z.ZodInt;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export declare const ProbeTargetPolicy: z.ZodObject<{
|
|
42
|
+
authorizations: z.ZodArray<z.ZodObject<{
|
|
43
|
+
interfaceId: z.ZodString;
|
|
44
|
+
scheme: z.ZodEnum<{
|
|
45
|
+
http: "http";
|
|
46
|
+
https: "https";
|
|
47
|
+
}>;
|
|
48
|
+
host: z.ZodString;
|
|
49
|
+
port: z.ZodInt;
|
|
50
|
+
addresses: z.ZodArray<z.ZodString>;
|
|
51
|
+
methods: z.ZodArray<z.ZodEnum<{
|
|
52
|
+
DELETE: "DELETE";
|
|
53
|
+
GET: "GET";
|
|
54
|
+
HEAD: "HEAD";
|
|
55
|
+
OPTIONS: "OPTIONS";
|
|
56
|
+
PATCH: "PATCH";
|
|
57
|
+
POST: "POST";
|
|
58
|
+
PUT: "PUT";
|
|
59
|
+
}>>;
|
|
60
|
+
safeMethods: z.ZodArray<z.ZodEnum<{
|
|
61
|
+
DELETE: "DELETE";
|
|
62
|
+
GET: "GET";
|
|
63
|
+
HEAD: "HEAD";
|
|
64
|
+
OPTIONS: "OPTIONS";
|
|
65
|
+
PATCH: "PATCH";
|
|
66
|
+
POST: "POST";
|
|
67
|
+
PUT: "PUT";
|
|
68
|
+
}>>;
|
|
69
|
+
maxRedirects: z.ZodInt;
|
|
70
|
+
maxElapsedMs: z.ZodInt;
|
|
71
|
+
maxRequestBytes: z.ZodInt;
|
|
72
|
+
maxResponseBytes: z.ZodInt;
|
|
73
|
+
}, z.core.$strict>>;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
export type ProbeTargetAuthorization = z.infer<typeof ProbeTargetAuthorization>;
|
|
76
|
+
export type ProbeTargetPolicy = z.infer<typeof ProbeTargetPolicy>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** AD-35's default-deny target authorization, as a declared mapping. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { HttpMethod } from './interface.js';
|
|
4
|
+
import { Identifier } from './primitives.js';
|
|
5
|
+
/**
|
|
6
|
+
* One authorized target. AD-35: "An adapter denies by default and permits only
|
|
7
|
+
* what that mapping names." Every field is required and none has a default:
|
|
8
|
+
* an omitted cap is an unbounded cap, which is the failure this declaration
|
|
9
|
+
* exists to prevent.
|
|
10
|
+
*/
|
|
11
|
+
export const ProbeTargetAuthorization = z.strictObject({
|
|
12
|
+
interfaceId: Identifier.describe('The logical identifier the contract names. This mapping is where it becomes a target, outside the contract.'),
|
|
13
|
+
scheme: z.enum(['http', 'https']),
|
|
14
|
+
host: z.string().min(1),
|
|
15
|
+
port: z.int().min(1).max(65535),
|
|
16
|
+
addresses: z
|
|
17
|
+
.array(z.string().min(1))
|
|
18
|
+
.min(1)
|
|
19
|
+
.describe('The exact resolved addresses this authorization permits, compared after parsing rather than as strings. AD-35 requires every resolved address and every redirect to be revalidated, and requires a loopback, private, link-local, or metadata address to be authorized explicitly rather than by class, so the authorization names addresses rather than a range.'),
|
|
20
|
+
methods: z.array(HttpMethod).min(1),
|
|
21
|
+
safeMethods: z
|
|
22
|
+
.array(HttpMethod)
|
|
23
|
+
.describe('AD-35: "Differential body-sensitivity probes use only methods the mapping marks safe for that target." Empty is legal and means no method is safe for a differential here; it is not a synonym for "all of them".'),
|
|
24
|
+
maxRedirects: z.int().min(0),
|
|
25
|
+
maxElapsedMs: z.int().min(1),
|
|
26
|
+
maxRequestBytes: z.int().min(1),
|
|
27
|
+
maxResponseBytes: z.int().min(1),
|
|
28
|
+
});
|
|
29
|
+
export const ProbeTargetPolicy = z.strictObject({
|
|
30
|
+
authorizations: z
|
|
31
|
+
.array(ProbeTargetAuthorization)
|
|
32
|
+
.describe('An empty array is legal and authorizes nothing, which is the default-deny base case and must stay representable.'),
|
|
33
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/** a corpus probe: its class, its control status, and the defects it seeds. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* AD-9's closed four, one per probe, in scope because AD-7's strength vector
|
|
5
|
+
* is keyed by probe class and needs this vocabulary. AD-7's exclusion rule
|
|
6
|
+
* reads directly off this field and `expectedClean`: canary probes and clean
|
|
7
|
+
* controls never enter the vector.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PROBE_CLASSES: readonly ['defect', 'gameability', 'zero-action', 'canary'];
|
|
10
|
+
export declare const ProbeClass: z.ZodEnum<{
|
|
11
|
+
canary: "canary";
|
|
12
|
+
defect: "defect";
|
|
13
|
+
gameability: "gameability";
|
|
14
|
+
"zero-action": "zero-action";
|
|
15
|
+
}>;
|
|
16
|
+
/** the prior art's six-field seeded defect, carried unchanged. */
|
|
17
|
+
export declare const Defect: z.ZodObject<{
|
|
18
|
+
defectId: z.ZodString;
|
|
19
|
+
behaviorId: z.ZodString;
|
|
20
|
+
summary: z.ZodString;
|
|
21
|
+
severity: z.ZodEnum<{
|
|
22
|
+
critical: "critical";
|
|
23
|
+
low: "low";
|
|
24
|
+
material: "material";
|
|
25
|
+
}>;
|
|
26
|
+
oracleEvidence: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
storage: z.ZodLiteral<"public">;
|
|
28
|
+
path: z.ZodString;
|
|
29
|
+
privateRef: z.ZodNull;
|
|
30
|
+
digest: z.ZodString;
|
|
31
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
32
|
+
storage: z.ZodLiteral<"private">;
|
|
33
|
+
path: z.ZodNull;
|
|
34
|
+
privateRef: z.ZodString;
|
|
35
|
+
digest: z.ZodString;
|
|
36
|
+
}, z.core.$strict>], "storage">>;
|
|
37
|
+
source: z.ZodEnum<{
|
|
38
|
+
"controlled-mutation": "controlled-mutation";
|
|
39
|
+
natural: "natural";
|
|
40
|
+
}>;
|
|
41
|
+
manifestationWitness: z.ZodNullable<z.ZodObject<{
|
|
42
|
+
legId: z.ZodString;
|
|
43
|
+
interfaceId: z.ZodString;
|
|
44
|
+
operationId: z.ZodString;
|
|
45
|
+
inputs: z.ZodObject<{
|
|
46
|
+
path: z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>;
|
|
47
|
+
query: z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>;
|
|
48
|
+
header: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
49
|
+
body: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"json">;
|
|
51
|
+
value: z.ZodType<import("./primitives.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonValue, unknown>>;
|
|
52
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<"absent">;
|
|
54
|
+
}, z.core.$strict>], "kind">;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
relation: z.ZodType<import("./expression.ts").Expression, unknown, z.core.$ZodTypeInternals<import("./expression.ts").Expression, unknown>>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
/**
|
|
60
|
+
* The prior art's `expectedClean` conditional, re-expressed as a discriminated
|
|
61
|
+
* union per AD-13 (a boolean literal discriminator parses on this pin,
|
|
62
|
+
* verified).
|
|
63
|
+
*
|
|
64
|
+
* `expectedClean: true` marks a clean control: AD-9's reason for the boolean
|
|
65
|
+
* is "ratifying the prior art's record-level field rather than adding a fifth
|
|
66
|
+
* class".
|
|
67
|
+
*/
|
|
68
|
+
export declare const Probe: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
69
|
+
schemaVersion: z.ZodInt;
|
|
70
|
+
parentDigest: z.ZodNullable<z.ZodString>;
|
|
71
|
+
revisionCount: z.ZodInt;
|
|
72
|
+
probeId: z.ZodString;
|
|
73
|
+
probeClass: z.ZodEnum<{
|
|
74
|
+
canary: "canary";
|
|
75
|
+
defect: "defect";
|
|
76
|
+
gameability: "gameability";
|
|
77
|
+
"zero-action": "zero-action";
|
|
78
|
+
}>;
|
|
79
|
+
behaviorId: z.ZodString;
|
|
80
|
+
systemId: z.ZodString;
|
|
81
|
+
implementationDigest: z.ZodString;
|
|
82
|
+
artifactDigest: z.ZodString;
|
|
83
|
+
commitDigest: z.ZodString;
|
|
84
|
+
rationale: z.ZodString;
|
|
85
|
+
expectedClean: z.ZodLiteral<true>;
|
|
86
|
+
defects: z.ZodArray<z.ZodObject<{
|
|
87
|
+
defectId: z.ZodString;
|
|
88
|
+
behaviorId: z.ZodString;
|
|
89
|
+
summary: z.ZodString;
|
|
90
|
+
severity: z.ZodEnum<{
|
|
91
|
+
critical: "critical";
|
|
92
|
+
low: "low";
|
|
93
|
+
material: "material";
|
|
94
|
+
}>;
|
|
95
|
+
oracleEvidence: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
storage: z.ZodLiteral<"public">;
|
|
97
|
+
path: z.ZodString;
|
|
98
|
+
privateRef: z.ZodNull;
|
|
99
|
+
digest: z.ZodString;
|
|
100
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
101
|
+
storage: z.ZodLiteral<"private">;
|
|
102
|
+
path: z.ZodNull;
|
|
103
|
+
privateRef: z.ZodString;
|
|
104
|
+
digest: z.ZodString;
|
|
105
|
+
}, z.core.$strict>], "storage">>;
|
|
106
|
+
source: z.ZodEnum<{
|
|
107
|
+
"controlled-mutation": "controlled-mutation";
|
|
108
|
+
natural: "natural";
|
|
109
|
+
}>;
|
|
110
|
+
manifestationWitness: z.ZodNullable<z.ZodObject<{
|
|
111
|
+
legId: z.ZodString;
|
|
112
|
+
interfaceId: z.ZodString;
|
|
113
|
+
operationId: z.ZodString;
|
|
114
|
+
inputs: z.ZodObject<{
|
|
115
|
+
path: z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>;
|
|
116
|
+
query: z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>;
|
|
117
|
+
header: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
118
|
+
body: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
119
|
+
kind: z.ZodLiteral<"json">;
|
|
120
|
+
value: z.ZodType<import("./primitives.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonValue, unknown>>;
|
|
121
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
122
|
+
kind: z.ZodLiteral<"absent">;
|
|
123
|
+
}, z.core.$strict>], "kind">;
|
|
124
|
+
}, z.core.$strict>;
|
|
125
|
+
relation: z.ZodType<import("./expression.ts").Expression, unknown, z.core.$ZodTypeInternals<import("./expression.ts").Expression, unknown>>;
|
|
126
|
+
}, z.core.$strict>>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
129
|
+
schemaVersion: z.ZodInt;
|
|
130
|
+
parentDigest: z.ZodNullable<z.ZodString>;
|
|
131
|
+
revisionCount: z.ZodInt;
|
|
132
|
+
probeId: z.ZodString;
|
|
133
|
+
probeClass: z.ZodEnum<{
|
|
134
|
+
canary: "canary";
|
|
135
|
+
defect: "defect";
|
|
136
|
+
gameability: "gameability";
|
|
137
|
+
"zero-action": "zero-action";
|
|
138
|
+
}>;
|
|
139
|
+
behaviorId: z.ZodString;
|
|
140
|
+
systemId: z.ZodString;
|
|
141
|
+
implementationDigest: z.ZodString;
|
|
142
|
+
artifactDigest: z.ZodString;
|
|
143
|
+
commitDigest: z.ZodString;
|
|
144
|
+
rationale: z.ZodString;
|
|
145
|
+
expectedClean: z.ZodLiteral<false>;
|
|
146
|
+
defects: z.ZodArray<z.ZodObject<{
|
|
147
|
+
defectId: z.ZodString;
|
|
148
|
+
behaviorId: z.ZodString;
|
|
149
|
+
summary: z.ZodString;
|
|
150
|
+
severity: z.ZodEnum<{
|
|
151
|
+
critical: "critical";
|
|
152
|
+
low: "low";
|
|
153
|
+
material: "material";
|
|
154
|
+
}>;
|
|
155
|
+
oracleEvidence: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
156
|
+
storage: z.ZodLiteral<"public">;
|
|
157
|
+
path: z.ZodString;
|
|
158
|
+
privateRef: z.ZodNull;
|
|
159
|
+
digest: z.ZodString;
|
|
160
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
161
|
+
storage: z.ZodLiteral<"private">;
|
|
162
|
+
path: z.ZodNull;
|
|
163
|
+
privateRef: z.ZodString;
|
|
164
|
+
digest: z.ZodString;
|
|
165
|
+
}, z.core.$strict>], "storage">>;
|
|
166
|
+
source: z.ZodEnum<{
|
|
167
|
+
"controlled-mutation": "controlled-mutation";
|
|
168
|
+
natural: "natural";
|
|
169
|
+
}>;
|
|
170
|
+
manifestationWitness: z.ZodNullable<z.ZodObject<{
|
|
171
|
+
legId: z.ZodString;
|
|
172
|
+
interfaceId: z.ZodString;
|
|
173
|
+
operationId: z.ZodString;
|
|
174
|
+
inputs: z.ZodObject<{
|
|
175
|
+
path: z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>;
|
|
176
|
+
query: z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>;
|
|
177
|
+
header: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
178
|
+
body: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
179
|
+
kind: z.ZodLiteral<"json">;
|
|
180
|
+
value: z.ZodType<import("./primitives.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonValue, unknown>>;
|
|
181
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
182
|
+
kind: z.ZodLiteral<"absent">;
|
|
183
|
+
}, z.core.$strict>], "kind">;
|
|
184
|
+
}, z.core.$strict>;
|
|
185
|
+
relation: z.ZodType<import("./expression.ts").Expression, unknown, z.core.$ZodTypeInternals<import("./expression.ts").Expression, unknown>>;
|
|
186
|
+
}, z.core.$strict>>;
|
|
187
|
+
}, z.core.$strict>>;
|
|
188
|
+
}, z.core.$strict>], "expectedClean">;
|
|
189
|
+
export type Probe = z.infer<typeof Probe>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** a corpus probe: its class, its control status, and the defects it seeds. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { ArtifactReference } from './artifact-reference.js';
|
|
4
|
+
import { Severity } from './eval-contract.js';
|
|
5
|
+
import { lineageFields } from './lineage.js';
|
|
6
|
+
import { BehaviorId, DefectId, Digest, ProbeId } from './primitives.js';
|
|
7
|
+
import { ManifestationWitness } from './sensitivity-witness.js';
|
|
8
|
+
/**
|
|
9
|
+
* AD-9's closed four, one per probe, in scope because AD-7's strength vector
|
|
10
|
+
* is keyed by probe class and needs this vocabulary. AD-7's exclusion rule
|
|
11
|
+
* reads directly off this field and `expectedClean`: canary probes and clean
|
|
12
|
+
* controls never enter the vector.
|
|
13
|
+
*/
|
|
14
|
+
export const PROBE_CLASSES = [
|
|
15
|
+
'defect',
|
|
16
|
+
'gameability',
|
|
17
|
+
'zero-action',
|
|
18
|
+
'canary',
|
|
19
|
+
];
|
|
20
|
+
export const ProbeClass = z.enum(PROBE_CLASSES);
|
|
21
|
+
/** the prior art's six-field seeded defect, carried unchanged. */
|
|
22
|
+
export const Defect = z.strictObject({
|
|
23
|
+
defectId: DefectId,
|
|
24
|
+
behaviorId: BehaviorId.describe('The behaviour this defect breaks. AD-9 also puts a behaviour on the probe itself and this schema carries both; that the two may disagree is a cross-field rule with no AD-5 code and is left unenforced in v0 rather than silently refined here.'),
|
|
25
|
+
summary: z.string().min(1),
|
|
26
|
+
severity: Severity,
|
|
27
|
+
oracleEvidence: z.array(ArtifactReference),
|
|
28
|
+
source: z.enum(['natural', 'controlled-mutation']),
|
|
29
|
+
manifestationWitness: ManifestationWitness.nullable().describe("AD-10: what pre-flight probes to observe this defect fire. `null` parses, so the prior art's six-field defect still round-trips, and pre-flight records a null witness as a **failed** `seeded-fault-fired` check rather than as an exemption. A seeded fault that cannot be observed to fire is the vacuous probe AD-40 resolves to `infrastructure-error`, and pre-flight is the one place where invalidating is the cheap outcome."),
|
|
30
|
+
});
|
|
31
|
+
// Shared by both branches of the `expectedClean` union. AD-9's per-probe
|
|
32
|
+
// `artifactDigest` and `commitDigest` sit at the root here, matching the prior
|
|
33
|
+
// art's record-level `implementationSha`: one spelling instead of five.
|
|
34
|
+
const probeCommonFields = {
|
|
35
|
+
...lineageFields,
|
|
36
|
+
probeId: ProbeId,
|
|
37
|
+
probeClass: ProbeClass,
|
|
38
|
+
behaviorId: BehaviorId.describe('AD-9 puts the behaviour on the probe. The prior art put one on each seeded defect only, and this schema carries both.'),
|
|
39
|
+
systemId: z
|
|
40
|
+
.string()
|
|
41
|
+
.min(1)
|
|
42
|
+
.describe('An opaque caller label for the system under test.'),
|
|
43
|
+
implementationDigest: Digest.describe("The prior art's `implementationSha`, renamed against the shared AD-27 primitive. An AD-24 divergence."),
|
|
44
|
+
artifactDigest: Digest,
|
|
45
|
+
commitDigest: Digest,
|
|
46
|
+
rationale: z.string().min(1),
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The prior art's `expectedClean` conditional, re-expressed as a discriminated
|
|
50
|
+
* union per AD-13 (a boolean literal discriminator parses on this pin,
|
|
51
|
+
* verified).
|
|
52
|
+
*
|
|
53
|
+
* `expectedClean: true` marks a clean control: AD-9's reason for the boolean
|
|
54
|
+
* is "ratifying the prior art's record-level field rather than adding a fifth
|
|
55
|
+
* class".
|
|
56
|
+
*/
|
|
57
|
+
export const Probe = z
|
|
58
|
+
.discriminatedUnion('expectedClean', [
|
|
59
|
+
z
|
|
60
|
+
.strictObject({
|
|
61
|
+
...probeCommonFields,
|
|
62
|
+
expectedClean: z.literal(true),
|
|
63
|
+
defects: z
|
|
64
|
+
.array(Defect)
|
|
65
|
+
.max(0)
|
|
66
|
+
.describe("A known-clean control seeds nothing, which is the prior art's own `if`/`then` expressed structurally."),
|
|
67
|
+
})
|
|
68
|
+
.describe("A known-clean control. Never enters AD-7's dominance vector."),
|
|
69
|
+
z
|
|
70
|
+
.strictObject({
|
|
71
|
+
...probeCommonFields,
|
|
72
|
+
expectedClean: z.literal(false),
|
|
73
|
+
defects: z
|
|
74
|
+
.array(Defect)
|
|
75
|
+
.describe('No minimum. AD-9 states none, and a minimum would make a canary unrepresentable, since a canary indicts the fixture rather than seeding a defect.'),
|
|
76
|
+
})
|
|
77
|
+
.describe('A probe that is not a known-clean control.'),
|
|
78
|
+
])
|
|
79
|
+
.meta({
|
|
80
|
+
id: 'Probe',
|
|
81
|
+
description: "One corpus probe. Succeeds the prior-art `h0-ground-truth` schema per AD-24, carrying its system identifier, implementation digest, `expectedClean` flag, seeded defects, and rationale, and adding AD-9's probe class and AD-9's per-probe artifact and commit digests. Divergences: `implementationSha` becomes `implementationDigest`, `taskId` does not survive because the probe pins what it describes by digest, and `expectedGate` does not survive because AD-40 makes detection a signature match rather than a verdict comparison and AD-7 keeps comparisons inside the dominance vector, so carrying an expected gate would invite a comparison the architecture forbids. Two constructions are deliberately absent: AD-9's per-class QUALIFICATION record, whose five prose routes name no fields and whose acceptance criteria of record do not command it, and AD-40's machine-readable DEFECT SIGNATURE, which Owed item 7 records as having no fixture to land in because this repository contains no probe at all. Both arrive as additive `schemaVersion` bumps under AD-11 once a corpus exists to carry them. The cost is named rather than hidden: AD-9's \"an unqualified probe cannot enter a sealed set\" is enforced by nothing in v0: not this schema, not an AD-5 code, and not an AD-21 rung.",
|
|
82
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type InterchangeArtifactKey } from './artifact.ts';
|
|
2
|
+
import { type ConstraintLedgerEntry } from './constraint-ledger.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A URN rather than an `https://` locator: every document is self-contained
|
|
5
|
+
* with local `#/$defs/...` references only, so the base never needs to
|
|
6
|
+
* resolve. The version is deliberately absent: `schemaVersion` is the in-band
|
|
7
|
+
* field, and AD-11's additive-bump discipline keeps this identifier stable
|
|
8
|
+
* across bumps.
|
|
9
|
+
*/
|
|
10
|
+
export declare const publishedSchemaId: (key: InterchangeArtifactKey) => string;
|
|
11
|
+
export declare const injectConstraint: (document: Record<string, unknown>, entry: ConstraintLedgerEntry) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The one pure builder (AD-13): output mode, because published schemas
|
|
14
|
+
* describe artifacts as consumers receive them, though
|
|
15
|
+
* `tests/schemas/artifact-registry.test.ts` asserts all twelve export
|
|
16
|
+
* byte-identically in both modes either way. Zod emits no `$id` at any level,
|
|
17
|
+
* so it is synthesised here, second after `$schema`, with Zod's own key order
|
|
18
|
+
* unchanged after it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const publishedDocument: (key: InterchangeArtifactKey) => Record<string, unknown>;
|
|
21
|
+
/** all twelve, keyed by registry key; the registry is the only list walked. */
|
|
22
|
+
export declare const publishedDocuments: () => Record<InterchangeArtifactKey, Record<string, unknown>>;
|
|
23
|
+
/**
|
|
24
|
+
* The exact byte form of a published document, shared by the generator and the
|
|
25
|
+
* drift check so the two cannot disagree: 2-space indent, one trailing newline,
|
|
26
|
+
* and every code unit above U+007F escaped as `\uXXXX` so the committed files
|
|
27
|
+
* are pure ASCII. The test fixtures follow the same rule, which removes one
|
|
28
|
+
* byte-level encoding variable from a byte-exact comparison.
|
|
29
|
+
*/
|
|
30
|
+
export declare const serializePublishedDocument: (document: Record<string, unknown>) => string;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/** the published JSON Schema export: twelve self-contained documents. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { INTERCHANGE_ARTIFACT_KEYS, INTERCHANGE_ARTIFACTS, } from './artifact.js';
|
|
4
|
+
import { CONSTRAINT_LEDGER, } from './constraint-ledger.js';
|
|
5
|
+
// Downstream of every schema module and the constraint ledger; no module
|
|
6
|
+
// under `src/core/schemas/` may import it back, or the cycle fails at load
|
|
7
|
+
// with a temporal-dead-zone ReferenceError. Pure (AD-1): no filesystem,
|
|
8
|
+
// network, clock, randomness, or validator import, so the runtime dependency
|
|
9
|
+
// stays Zod alone.
|
|
10
|
+
/**
|
|
11
|
+
* A URN rather than an `https://` locator: every document is self-contained
|
|
12
|
+
* with local `#/$defs/...` references only, so the base never needs to
|
|
13
|
+
* resolve. The version is deliberately absent: `schemaVersion` is the in-band
|
|
14
|
+
* field, and AD-11's additive-bump discipline keeps this identifier stable
|
|
15
|
+
* across bumps.
|
|
16
|
+
*/
|
|
17
|
+
export const publishedSchemaId = (key) => `urn:eval-quality:schema:${key}`;
|
|
18
|
+
const unresolved = (entry, segment) => new Error(`constraint "${entry.id}" does not resolve: ${segment}. ` +
|
|
19
|
+
'A silently skipped injection is the failure AD-13 exists to prevent, so this is a throw rather than a warning.');
|
|
20
|
+
const isNode = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
21
|
+
/** the branch's discriminator const, or undefined where the shape has none. */
|
|
22
|
+
const opConstOf = (candidate) => {
|
|
23
|
+
if (!isNode(candidate) || !isNode(candidate.properties))
|
|
24
|
+
return undefined;
|
|
25
|
+
const op = candidate.properties.op;
|
|
26
|
+
return isNode(op) ? op.const : undefined;
|
|
27
|
+
};
|
|
28
|
+
const propertyOf = (candidate, field) => isNode(candidate) && isNode(candidate.properties)
|
|
29
|
+
? candidate.properties[field]
|
|
30
|
+
: undefined;
|
|
31
|
+
export const injectConstraint = (document, entry) => {
|
|
32
|
+
if (entry.disposition.kind !== 'inject')
|
|
33
|
+
throw unresolved(entry, 'its disposition is not "inject"');
|
|
34
|
+
// `items: false` bounds a tuple only beside 2020-12's `prefixItems`; under
|
|
35
|
+
// draft-7 the same injection overwrites the exported tuple and every operand
|
|
36
|
+
// list rejects everything. Read the field, never assume it.
|
|
37
|
+
if (entry.disposition.dialect !== 'draft-2020-12')
|
|
38
|
+
throw unresolved(entry, `dialect "${entry.disposition.dialect}" is not the export target "draft-2020-12"`);
|
|
39
|
+
const definitions = document.$defs;
|
|
40
|
+
const definition = entry.location.kind === 'root'
|
|
41
|
+
? document
|
|
42
|
+
: isNode(definitions)
|
|
43
|
+
? definitions[entry.location.name]
|
|
44
|
+
: undefined;
|
|
45
|
+
if (!isNode(definition))
|
|
46
|
+
throw unresolved(entry, entry.location.kind === 'root'
|
|
47
|
+
? 'the document root is not an object'
|
|
48
|
+
: `no definition named "${entry.location.name}"`);
|
|
49
|
+
const branches = Array.isArray(definition.oneOf)
|
|
50
|
+
? definition.oneOf
|
|
51
|
+
: undefined;
|
|
52
|
+
// Matched rather than found: two branches carrying the same discriminator
|
|
53
|
+
// would make `find` inject into the first and skip the rest, which is the
|
|
54
|
+
// silent skip every other throw in this function exists to prevent.
|
|
55
|
+
const matched = entry.branch === null
|
|
56
|
+
? undefined
|
|
57
|
+
: (branches?.filter((candidate) => opConstOf(candidate) === entry.branch) ?? []);
|
|
58
|
+
if (matched !== undefined && matched.length > 1)
|
|
59
|
+
throw unresolved(entry, `${matched.length} oneOf branches carry op const "${entry.branch}", so the address names more than one shape`);
|
|
60
|
+
const target = entry.branch === null ? definition : matched?.[0];
|
|
61
|
+
if (!isNode(target))
|
|
62
|
+
throw unresolved(entry, `no oneOf branch whose op const is "${entry.branch}"`);
|
|
63
|
+
// The union fallback, kept for parity with the resolver of record: a
|
|
64
|
+
// union-rooted shape exports `{ $schema, oneOf, description }` with no
|
|
65
|
+
// `properties` object, and the field is spread into every branch. The copies
|
|
66
|
+
// are equal by construction, but aliasing is neither guaranteed nor
|
|
67
|
+
// excluded, so assigning to just one would inject into a single branch and
|
|
68
|
+
// silently skip the rest.
|
|
69
|
+
const field = entry.field;
|
|
70
|
+
const targetBranches = Array.isArray(target.oneOf)
|
|
71
|
+
? target.oneOf
|
|
72
|
+
: undefined;
|
|
73
|
+
const sites = field === null
|
|
74
|
+
? [target]
|
|
75
|
+
: isNode(target.properties)
|
|
76
|
+
? [target.properties[field]]
|
|
77
|
+
: targetBranches !== undefined && targetBranches.length > 0
|
|
78
|
+
? targetBranches.map((branch) => propertyOf(branch, field))
|
|
79
|
+
: [undefined];
|
|
80
|
+
if (!sites.every(isNode))
|
|
81
|
+
throw unresolved(entry, `no property named "${entry.field}" at the located shape`);
|
|
82
|
+
// Deduped by object identity: where two branches DO alias one copy, writing
|
|
83
|
+
// through the first alias would make the second trip the no-overwrite guard
|
|
84
|
+
// below on a keyword this very call just planted.
|
|
85
|
+
for (const site of new Set(sites)) {
|
|
86
|
+
for (const [keyword, value] of Object.entries(entry.disposition.keywords)) {
|
|
87
|
+
// An injection never overwrites: a keyword already present means the
|
|
88
|
+
// export changed under the ledger, and clobbering it would hide that.
|
|
89
|
+
if (keyword in site)
|
|
90
|
+
throw unresolved(entry, `keyword "${keyword}" is already present at the site`);
|
|
91
|
+
site[keyword] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The one pure builder (AD-13): output mode, because published schemas
|
|
97
|
+
* describe artifacts as consumers receive them, though
|
|
98
|
+
* `tests/schemas/artifact-registry.test.ts` asserts all twelve export
|
|
99
|
+
* byte-identically in both modes either way. Zod emits no `$id` at any level,
|
|
100
|
+
* so it is synthesised here, second after `$schema`, with Zod's own key order
|
|
101
|
+
* unchanged after it.
|
|
102
|
+
*/
|
|
103
|
+
export const publishedDocument = (key) => {
|
|
104
|
+
const exported = z.toJSONSchema(INTERCHANGE_ARTIFACTS[key].schema, {
|
|
105
|
+
io: 'output',
|
|
106
|
+
});
|
|
107
|
+
// Cloned before injection so mutation never reaches objects Zod may retain
|
|
108
|
+
// or share across toJSONSchema calls. structuredClone preserves aliasing
|
|
109
|
+
// within the cloned graph, which `injectConstraint`'s identity-based dedup
|
|
110
|
+
// (above) depends on.
|
|
111
|
+
const { $schema, ...rest } = structuredClone(exported);
|
|
112
|
+
const document = {
|
|
113
|
+
$schema,
|
|
114
|
+
$id: publishedSchemaId(key),
|
|
115
|
+
...rest,
|
|
116
|
+
};
|
|
117
|
+
for (const entry of CONSTRAINT_LEDGER) {
|
|
118
|
+
if (entry.disposition.kind !== 'inject')
|
|
119
|
+
continue;
|
|
120
|
+
if (entry.location.artifact !== key)
|
|
121
|
+
continue;
|
|
122
|
+
injectConstraint(document, entry);
|
|
123
|
+
}
|
|
124
|
+
return document;
|
|
125
|
+
};
|
|
126
|
+
/** all twelve, keyed by registry key; the registry is the only list walked. */
|
|
127
|
+
export const publishedDocuments = () => Object.fromEntries(INTERCHANGE_ARTIFACT_KEYS.map((key) => [key, publishedDocument(key)]));
|
|
128
|
+
/**
|
|
129
|
+
* The exact byte form of a published document, shared by the generator and the
|
|
130
|
+
* drift check so the two cannot disagree: 2-space indent, one trailing newline,
|
|
131
|
+
* and every code unit above U+007F escaped as `\uXXXX` so the committed files
|
|
132
|
+
* are pure ASCII. The test fixtures follow the same rule, which removes one
|
|
133
|
+
* byte-level encoding variable from a byte-exact comparison.
|
|
134
|
+
*/
|
|
135
|
+
export const serializePublishedDocument = (document) => `${JSON.stringify(document, null, 2).replace(/[\u0080-\uffff]/g, (unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, '0')}`)}\n`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** a declared reference set: what a collection is reconciled against. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* AD-19 fixes members as objects rather than scalars: `covers-by-key`
|
|
5
|
+
* compares on named keys, and a `set-membership` operand against the same set
|
|
6
|
+
* reads the single named key, so one declared form serves both operators and
|
|
7
|
+
* needs no second field for AD-20's rule 6 injection form.
|
|
8
|
+
*
|
|
9
|
+
* Members are `JsonValue` objects per the Consistency Conventions' placement
|
|
10
|
+
* of them under "expression literals, declared reference-set members, and
|
|
11
|
+
* every ingested response body", which is why they are not a seventh
|
|
12
|
+
* caller-keyed control map.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ReferenceSetDeclaration: z.ZodObject<{
|
|
15
|
+
keys: z.ZodArray<z.ZodString>;
|
|
16
|
+
members: z.ZodArray<z.ZodType<import("./primitives.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("./primitives.ts").JsonObject, unknown>>>;
|
|
17
|
+
commentary: z.ZodNullable<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** a declared reference set: what a collection is reconciled against. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { JsonObjectValue, KeyName } from './primitives.js';
|
|
4
|
+
/**
|
|
5
|
+
* AD-19 fixes members as objects rather than scalars: `covers-by-key`
|
|
6
|
+
* compares on named keys, and a `set-membership` operand against the same set
|
|
7
|
+
* reads the single named key, so one declared form serves both operators and
|
|
8
|
+
* needs no second field for AD-20's rule 6 injection form.
|
|
9
|
+
*
|
|
10
|
+
* Members are `JsonValue` objects per the Consistency Conventions' placement
|
|
11
|
+
* of them under "expression literals, declared reference-set members, and
|
|
12
|
+
* every ingested response body", which is why they are not a seventh
|
|
13
|
+
* caller-keyed control map.
|
|
14
|
+
*/
|
|
15
|
+
export const ReferenceSetDeclaration = z.strictObject({
|
|
16
|
+
keys: z
|
|
17
|
+
.array(KeyName)
|
|
18
|
+
.min(1)
|
|
19
|
+
.describe('The key names members are compared on. A reference set with no keys names nothing to compare, and no AD-5 code fires on it, so the schema is the enforcement point.'),
|
|
20
|
+
members: z
|
|
21
|
+
.array(JsonObjectValue)
|
|
22
|
+
.describe('Objects carrying at least the declared keys. That they do is deliberately not refined: no AD-5 code names it, and a refinement would be invisible to a non-TypeScript consumer and become a disagreement in the published-schema differential check.'),
|
|
23
|
+
commentary: z
|
|
24
|
+
.string()
|
|
25
|
+
.nullable()
|
|
26
|
+
.describe("Author documentation. Named `commentary` rather than the Gate C fixture's `note` so the sealed brief has one word to exclude, matching the oracle field of the same name. No predicate reads it."),
|
|
27
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** the rubric body a contract embeds, and the published Rubric artifact. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const ScaleLevel: z.ZodObject<{
|
|
4
|
+
level: z.ZodInt;
|
|
5
|
+
anchor: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const FailureModePenalty: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export declare const RubricCriterion: z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
text: z.ZodString;
|
|
14
|
+
evidence: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
/**
|
|
17
|
+
* The embeddable rubric body: the published `Rubric` artifact below adds
|
|
18
|
+
* `schemaVersion`, lineage, and a prior-art declaration on top of this.
|
|
19
|
+
*/
|
|
20
|
+
export declare const RubricBody: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
scaleLevels: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
23
|
+
level: z.ZodInt;
|
|
24
|
+
anchor: z.ZodString;
|
|
25
|
+
}, z.core.$strict>>>;
|
|
26
|
+
failureModePenalties: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
description: z.ZodString;
|
|
29
|
+
}, z.core.$strict>>>;
|
|
30
|
+
maxLength: z.ZodNullable<z.ZodInt>;
|
|
31
|
+
criteria: z.ZodArray<z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
text: z.ZodString;
|
|
34
|
+
evidence: z.ZodString;
|
|
35
|
+
}, z.core.$strict>>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export type RubricBody = z.infer<typeof RubricBody>;
|
|
38
|
+
/**
|
|
39
|
+
* The published Rubric artifact: `RubricBody` above, spread flat, plus
|
|
40
|
+
* AD-11's version and AD-29's lineage.
|
|
41
|
+
*/
|
|
42
|
+
export declare const Rubric: z.ZodObject<{
|
|
43
|
+
schemaVersion: z.ZodInt;
|
|
44
|
+
parentDigest: z.ZodNullable<z.ZodString>;
|
|
45
|
+
revisionCount: z.ZodInt;
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
scaleLevels: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
48
|
+
level: z.ZodInt;
|
|
49
|
+
anchor: z.ZodString;
|
|
50
|
+
}, z.core.$strict>>>;
|
|
51
|
+
failureModePenalties: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
52
|
+
name: z.ZodString;
|
|
53
|
+
description: z.ZodString;
|
|
54
|
+
}, z.core.$strict>>>;
|
|
55
|
+
maxLength: z.ZodNullable<z.ZodInt>;
|
|
56
|
+
criteria: z.ZodArray<z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
text: z.ZodString;
|
|
59
|
+
evidence: z.ZodString;
|
|
60
|
+
}, z.core.$strict>>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
export type Rubric = z.infer<typeof Rubric>;
|