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,232 @@
|
|
|
1
|
+
/** the scored output `emit` owns: outcomes, strength, and one verdict. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Severity } from './eval-contract.js';
|
|
4
|
+
import { lineageFields } from './lineage.js';
|
|
5
|
+
import { Digest, FindingId, Identifier, OracleId, ProbeId, } from './primitives.js';
|
|
6
|
+
import { OracleDispositionValue } from './sealed-run-record.js';
|
|
7
|
+
import { EvaluatorRecommendation, Verdict } from './verdict.js';
|
|
8
|
+
/**
|
|
9
|
+
* AD-6's closed twelve. Exported so a later reader can walk the list
|
|
10
|
+
* directly, and asserted at twelve by a test: AD-6 says the set "stays closed
|
|
11
|
+
* at twelve", so adding a thirteenth member means amending that AD first.
|
|
12
|
+
*/
|
|
13
|
+
export const OUTCOME_STATES = [
|
|
14
|
+
'caught',
|
|
15
|
+
'confirmed',
|
|
16
|
+
'missed',
|
|
17
|
+
'passed-clean-control',
|
|
18
|
+
'false-positive',
|
|
19
|
+
'abstained',
|
|
20
|
+
'bypassed',
|
|
21
|
+
'unreached',
|
|
22
|
+
'oracle-error',
|
|
23
|
+
'judge-error',
|
|
24
|
+
'infrastructure-error',
|
|
25
|
+
'not-applicable',
|
|
26
|
+
];
|
|
27
|
+
export const OutcomeState = z.enum(OUTCOME_STATES);
|
|
28
|
+
/** AD-33's closed three. */
|
|
29
|
+
export const CORROBORATION_VALUES = [
|
|
30
|
+
'agrees',
|
|
31
|
+
'disagrees',
|
|
32
|
+
'not-evaluable',
|
|
33
|
+
];
|
|
34
|
+
export const Corroboration = z.enum(CORROBORATION_VALUES);
|
|
35
|
+
/**
|
|
36
|
+
* AD-4 requires that "each node's resolution and, where it is
|
|
37
|
+
* `insufficient-evidence`, the introduction condition that fired, are recorded
|
|
38
|
+
* in the evidence". A single verdict per oracle would erase that distinction,
|
|
39
|
+
* so the record mirrors the oracle's own `check` tree. Self-referential, so
|
|
40
|
+
* it carries `.meta({ id })`; without it the tree exports as a positional
|
|
41
|
+
* `__schema0` that the published-schema drift check would pin.
|
|
42
|
+
* `core/evaluate/resolution.ts` populates it.
|
|
43
|
+
*/
|
|
44
|
+
export const CheckResolution = z
|
|
45
|
+
.lazy(() => z.strictObject({
|
|
46
|
+
resolution: z.enum(['true', 'false', 'insufficient-evidence']),
|
|
47
|
+
introductionCondition: z.enum(['empty-collection']).nullable(),
|
|
48
|
+
children: z.array(CheckResolution),
|
|
49
|
+
}))
|
|
50
|
+
.meta({
|
|
51
|
+
id: 'CheckResolution',
|
|
52
|
+
description: "One node of an oracle's `check` tree as it resolved. AD-4's resolution is three-valued rather than two, and the introduction vocabulary has exactly one member because AD-4 closes the introduction set at one: an empty collection. `null` where the resolution is not `insufficient-evidence`. A leaf carries an empty `children` array.",
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* AD-11's five named inputs, transcribed so a reader can recompute the
|
|
56
|
+
* digest and see what was compared (AD-8's "by digest and opaque reference,
|
|
57
|
+
* never by content or path"). Named object rather than a concatenated tuple:
|
|
58
|
+
* revision 1 let two conforming scorers compute different versions from
|
|
59
|
+
* identical inputs if they hashed a different ordering. The scorer computes
|
|
60
|
+
* the scoring version over this shape.
|
|
61
|
+
*/
|
|
62
|
+
export const SCORING_VERSION_INPUT_NAMES = [
|
|
63
|
+
'contractSchemaVersion',
|
|
64
|
+
'corpusDigest',
|
|
65
|
+
'fixtureDigest',
|
|
66
|
+
'evaluatorConfigurationDigest',
|
|
67
|
+
'scoringPolicyDigest',
|
|
68
|
+
];
|
|
69
|
+
export const ScoringVersionInputName = z.enum(SCORING_VERSION_INPUT_NAMES);
|
|
70
|
+
export const ScoringVersionInputs = z.strictObject({
|
|
71
|
+
contractSchemaVersion: z.int().min(1),
|
|
72
|
+
corpusDigest: Digest,
|
|
73
|
+
fixtureDigest: Digest,
|
|
74
|
+
evaluatorConfigurationDigest: Digest,
|
|
75
|
+
scoringPolicyDigest: Digest,
|
|
76
|
+
});
|
|
77
|
+
export const InvalidatedAttempt = z.strictObject({
|
|
78
|
+
attempt: z.int().min(1),
|
|
79
|
+
reason: z
|
|
80
|
+
.string()
|
|
81
|
+
.min(1)
|
|
82
|
+
.describe("AD-6 requires each attempt's reason. Non-empty: a reason that says nothing is not a reason, no AD-5 code names the condition, and the schema is therefore the enforcement point."),
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* AD-6: "Every artifact records its trial count, its invalidated attempts, and
|
|
86
|
+
* each attempt's reason, including on a PASS." None of the three is nullable,
|
|
87
|
+
* because "including on a PASS" is exactly the case a nullable field would let
|
|
88
|
+
* a producer skip.
|
|
89
|
+
*/
|
|
90
|
+
export const Trials = z.strictObject({
|
|
91
|
+
declaredMinimum: z.int().min(1),
|
|
92
|
+
completed: z.int().min(0),
|
|
93
|
+
invalidatedAttempts: z.array(InvalidatedAttempt),
|
|
94
|
+
});
|
|
95
|
+
export const Outcome = z.strictObject({
|
|
96
|
+
oracleId: OracleId,
|
|
97
|
+
probeId: ProbeId.nullable(),
|
|
98
|
+
state: OutcomeState.describe("AD-6's closed twelve, assigned by AD-33. `not-applicable` is excluded from every count and is legal in exactly two cases: against an unexpired waiver, and against a probe AD-40 records as unexercised."),
|
|
99
|
+
severity: Severity,
|
|
100
|
+
disposition: OracleDispositionValue.describe("The evaluator's own statement, carried through from the run record's dispositions rather than re-derived. One vocabulary, spelled once, in the artifact the caller produces."),
|
|
101
|
+
resolvedFrom: FindingId.nullable().describe('The finding this outcome resolved from, or `null` where no finding was cited. A finding citing no oracle is recorded in `uncitedFindings` rather than discarded or forced into a state.'),
|
|
102
|
+
corroboration: Corroboration.describe("AD-33's closed three. `not-evaluable` and AD-4's `insufficient-evidence` are DIFFERENT conditions and AD-33 forbids merging them: `not-evaluable` means the expression never ran, while `insufficient-evidence` means it ran to completion and found nothing to examine. That is why both vocabularies appear on one outcome, this field and `checkResolution`, rather than collapsing into one."),
|
|
103
|
+
selectedObservationIds: z
|
|
104
|
+
.array(Identifier)
|
|
105
|
+
.describe('The cited observation identifiers AD-40 names as "what the witness match resolves against and what AD-33 records on the outcome". Recorded now rather than deferred: Owed item 2 is about selection DETERMINISM, meaning a monotonic sequence and a declared selector cardinality, which is a different question from whether the selection is recorded.'),
|
|
106
|
+
checkResolution: CheckResolution.nullable().describe("The oracle's `check` tree as it resolved, per AD-4. `null` for an oracle whose check never ran, which is the `not-evaluable` corroboration case; the two fields are read together and neither substitutes for the other."),
|
|
107
|
+
});
|
|
108
|
+
export const CoverageGap = z.strictObject({
|
|
109
|
+
rule: z
|
|
110
|
+
.string()
|
|
111
|
+
.min(1)
|
|
112
|
+
.describe('Opaque and deliberately not an enum, for the reason `Waiver.rule` is opaque: AD-20 enumerates its seven discipline rules in prose and assigns them no identifiers, so an enum here would be this schema minting the vocabulary AD-20 declined to.'),
|
|
113
|
+
relevancePredicate: z.string().min(1),
|
|
114
|
+
satisfactionPredicate: z.string().min(1),
|
|
115
|
+
satisfied: z.boolean(),
|
|
116
|
+
severity: Severity,
|
|
117
|
+
});
|
|
118
|
+
export const ClassStrength = z.strictObject({
|
|
119
|
+
caught: z.int().min(0),
|
|
120
|
+
exercised: z.int().min(0),
|
|
121
|
+
rate: z
|
|
122
|
+
.number()
|
|
123
|
+
.min(0)
|
|
124
|
+
.max(1)
|
|
125
|
+
.nullable()
|
|
126
|
+
.describe('Nullable because `exercised` may be zero and a rate over an empty denominator is undefined rather than zero. There is no separate `rawCounts` block: AD-7 wants raw counts recorded alongside the rate so a consumer can recompute, and this entry already carries both; a second copy is one more thing to disagree with itself. That `rate` equals `caught` over `exercised` is a cross-field rule with no AD-5 code and is left to the scorer.'),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* A fixed three-key object instead of a map keyed by probe class. AD-7 is
|
|
130
|
+
* explicit that "canary probes and clean controls never enter the vector", so
|
|
131
|
+
* the fourth class has no key here at all and its absence is structural.
|
|
132
|
+
*/
|
|
133
|
+
export const StrengthVector = z.strictObject({
|
|
134
|
+
defect: ClassStrength.nullable(),
|
|
135
|
+
gameability: ClassStrength.nullable(),
|
|
136
|
+
'zero-action': ClassStrength.nullable(),
|
|
137
|
+
});
|
|
138
|
+
export const Strength = z.strictObject({
|
|
139
|
+
denominator: z
|
|
140
|
+
.string()
|
|
141
|
+
.min(1)
|
|
142
|
+
.describe('AD-7 requires the denominator to be named in the artifact "so two consumers cannot derive two different recalls".'),
|
|
143
|
+
basis: z
|
|
144
|
+
.enum(['measured', 'reconstructed'])
|
|
145
|
+
.describe('AD-40 forbids pooling a containment-reconstructed detection with a measured catch rate. Without this field the two are identical on disk and pooling is the default reading.'),
|
|
146
|
+
vector: StrengthVector,
|
|
147
|
+
comparable: z
|
|
148
|
+
.boolean()
|
|
149
|
+
.describe("AD-21: a run that resolved `unreached` or completed fewer trials than the policy's declared minimum marks the vector non-comparable rather than silently comparing it."),
|
|
150
|
+
note: z.string().nullable(),
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* AD-12's three named checks, transcribed from the same sentence the field
|
|
154
|
+
* comes from: the package "validates a caller-presented lineage chain (length
|
|
155
|
+
* consistent with the declared revision, no repeated digest, no gap) and
|
|
156
|
+
* emits evidence of compliance." A single boolean would tell a reader a chain
|
|
157
|
+
* failed without saying which of three ways, on an artifact whose purpose is
|
|
158
|
+
* to be read. AD-21's FAIL rung reads the conjunction.
|
|
159
|
+
*/
|
|
160
|
+
export const LineageChain = z.strictObject({
|
|
161
|
+
lengthConsistent: z.boolean(),
|
|
162
|
+
noRepeatedDigest: z.boolean(),
|
|
163
|
+
noGap: z.boolean(),
|
|
164
|
+
});
|
|
165
|
+
export const Remediation = z.strictObject({
|
|
166
|
+
revisionCount: z
|
|
167
|
+
.int()
|
|
168
|
+
.min(0)
|
|
169
|
+
.describe("AD-12's REMEDIATION count, meaning how many times the contract was revised in response to results, and NOT AD-29's lineage `revisionCount` at the root of this artifact. The two are distinguished only by nesting, so both descriptions say so."),
|
|
170
|
+
cap: z.int().min(0),
|
|
171
|
+
capSource: z
|
|
172
|
+
.literal('caller-attested')
|
|
173
|
+
.describe('A literal because AD-12 states the package validates the cap rather than enforcing it. There is no second legal value, and inventing one would claim an enforcement the architecture disclaims.'),
|
|
174
|
+
lineageChain: LineageChain,
|
|
175
|
+
});
|
|
176
|
+
// Common to both modes. AD-21 separates only the verdict fields; everything a
|
|
177
|
+
// reader needs to audit the run is on both.
|
|
178
|
+
const evidenceCommonFields = {
|
|
179
|
+
...lineageFields,
|
|
180
|
+
runId: z.string().min(1),
|
|
181
|
+
scoringVersion: Digest.describe('AD-11: computed by the scorer over the five named inputs below and never caller-supplied.'),
|
|
182
|
+
scoringVersionInputs: ScoringVersionInputs,
|
|
183
|
+
comparabilityKey: Digest.describe("AD-7's declared key: the scoring policy digest plus the corpus digest restricted to the probes both results cover. Deliberately weaker than the scoring version, so adding a probe narrows a comparison rather than voiding every prior result."),
|
|
184
|
+
excludedProbeIds: z
|
|
185
|
+
.array(ProbeId)
|
|
186
|
+
.describe('The probes a narrowed comparison excluded, per AD-7. Empty is the ordinary case.'),
|
|
187
|
+
exitCode: z
|
|
188
|
+
.int()
|
|
189
|
+
.describe("AD-21's exit code for the verdict this artifact carries. Recorded rather than derived at read time so the artifact and the process agree."),
|
|
190
|
+
verdictBasis: z
|
|
191
|
+
.array(z.string().min(1))
|
|
192
|
+
.describe('Every condition that fired, in AD-21 terms. Free text by design: the rungs are prose in AD-21 and assigning them identifiers would be minting a vocabulary that AD has not. Each member is non-empty, on the same reasoning that `InvalidatedAttempt.reason` is: a condition that names itself with nothing has not been recorded. An empty array is legal and is what a PASS with no firing condition carries.'),
|
|
193
|
+
callerAttestedInputs: z
|
|
194
|
+
.array(ScoringVersionInputName)
|
|
195
|
+
.describe('Which of the five scoring-version inputs were caller-attested rather than computed by this package. An enum over the five key names rather than free strings, because AD-32 requires the artifact to state *which* inputs were attested and an unconstrained string cannot be checked against anything. AD-11 names three of the five as caller-attested; the enum admits any subset so a stricter or looser integration stays representable.'),
|
|
196
|
+
trials: Trials,
|
|
197
|
+
outcomes: z.array(Outcome),
|
|
198
|
+
uncitedFindings: z
|
|
199
|
+
.array(FindingId)
|
|
200
|
+
.describe('Findings citing no oracle, retained rather than discarded or forced into a state, per AD-33. Discarding them would hide exactly the evaluator-chosen detection AD-23 exists to preserve.'),
|
|
201
|
+
coverageGaps: z.array(CoverageGap),
|
|
202
|
+
strength: Strength,
|
|
203
|
+
remediation: Remediation,
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* A discriminated union, because AD-21 requires that no shape hold a
|
|
207
|
+
* production verdict and a contract verdict at once, with neither mode able
|
|
208
|
+
* to read a field as the other's.
|
|
209
|
+
*/
|
|
210
|
+
export const EvidenceArtifact = z
|
|
211
|
+
.discriminatedUnion('mode', [
|
|
212
|
+
z
|
|
213
|
+
.strictObject({
|
|
214
|
+
...evidenceCommonFields,
|
|
215
|
+
mode: z.literal('production'),
|
|
216
|
+
productionVerdict: Verdict,
|
|
217
|
+
})
|
|
218
|
+
.describe("Production mode: the verdict is about the system under test, and an ingested evaluator recommendation promotes as AD-21's ladder describes."),
|
|
219
|
+
z
|
|
220
|
+
.strictObject({
|
|
221
|
+
...evidenceCommonFields,
|
|
222
|
+
mode: z.literal('contract-scoring'),
|
|
223
|
+
contractVerdict: Verdict,
|
|
224
|
+
systemRecommendationRecorded: EvaluatorRecommendation.describe("The evaluator's recommendation about the SYSTEM, recorded and never promoted. On a knowingly defective probe a system-directed FAIL is an input rather than a signal about the contract."),
|
|
225
|
+
systemRecommendationNote: z.string().nullable(),
|
|
226
|
+
})
|
|
227
|
+
.describe("Contract-scoring mode: the verdict is about the contract, and the evaluator's recommendation about the system is recorded beside it rather than promoted."),
|
|
228
|
+
])
|
|
229
|
+
.meta({
|
|
230
|
+
id: 'EvidenceArtifact',
|
|
231
|
+
description: "The scored output, owned by `emit` per AD-24, with no prior art; `score` produces the outcome and verdict values it serializes. The two modes are separate branches because AD-21 requires that the production verdict and the contract verdict never share a field. This expresses that settled sentence and no more: Owed item 4's remaining half stays open, namely mode being fixed before ingest and entering AD-11's identity inputs rather than appearing first here; and the Sealed Run Record still carries no mode.",
|
|
232
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/** the operand union and the recursive check expression tree. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { JsonValue, KeyedShapeDescriptor } from './primitives.ts';
|
|
4
|
+
export declare const PointerOperand: z.ZodObject<{
|
|
5
|
+
pointer: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const LiteralOperand: z.ZodObject<{
|
|
8
|
+
literal: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export declare const ReferenceSetOperand: z.ZodObject<{
|
|
11
|
+
referenceSet: z.ZodString;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
/**
|
|
14
|
+
* Every tuple position takes this full union. Per-position operand legality is
|
|
15
|
+
* the compiler's: AD-26 makes a reference-set operand outside its three legal
|
|
16
|
+
* positions fire `malformed-operator-expression`, which only stays fireable if
|
|
17
|
+
* the other positions admit it.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Operand: z.ZodUnion<readonly [z.ZodObject<{
|
|
20
|
+
pointer: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
21
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
22
|
+
literal: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
23
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
24
|
+
referenceSet: z.ZodString;
|
|
25
|
+
}, z.core.$strict>]>;
|
|
26
|
+
export type Operand = {
|
|
27
|
+
pointer: string;
|
|
28
|
+
} | {
|
|
29
|
+
literal: JsonValue;
|
|
30
|
+
} | {
|
|
31
|
+
referenceSet: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const LiteralSetOperand: z.ZodObject<{
|
|
34
|
+
literal: z.ZodArray<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export declare const SetOperand: z.ZodUnion<readonly [z.ZodObject<{
|
|
37
|
+
referenceSet: z.ZodString;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
literal: z.ZodArray<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
40
|
+
}, z.core.$strict>]>;
|
|
41
|
+
export type SetOperand = {
|
|
42
|
+
referenceSet: string;
|
|
43
|
+
} | {
|
|
44
|
+
literal: JsonValue[];
|
|
45
|
+
};
|
|
46
|
+
/** AD-33: one polarity per check, and one on the direction it must align with. */
|
|
47
|
+
export declare const Polarity: z.ZodEnum<{
|
|
48
|
+
"expects-hold": "expects-hold";
|
|
49
|
+
"expects-violation": "expects-violation";
|
|
50
|
+
}>;
|
|
51
|
+
export type Polarity = z.infer<typeof Polarity>;
|
|
52
|
+
export declare const SortOrder: z.ZodEnum<{
|
|
53
|
+
ascending: "ascending";
|
|
54
|
+
descending: "descending";
|
|
55
|
+
}>;
|
|
56
|
+
/** AD-4's eleven operators. */
|
|
57
|
+
export declare const OPERATOR_NAMES: readonly ['equality', 'deep-equality', 'containment', 'existence', 'absence', 'regex', 'set-membership', 'ordering', 'count-tolerance', 'shape', 'covers-by-key'];
|
|
58
|
+
/** AD-4's three connectives. */
|
|
59
|
+
export declare const CONNECTIVE_NAMES: readonly ['all', 'any', 'not'];
|
|
60
|
+
/** AD-4's two collection quantifiers. */
|
|
61
|
+
export declare const QUANTIFIER_NAMES: readonly ['for-all', 'for-any'];
|
|
62
|
+
/**
|
|
63
|
+
* The sixteen-member vocabulary a direction's relation is drawn from. AD-3
|
|
64
|
+
* fixes it as "AD-4's operator set", read as all sixteen: seven of the eight
|
|
65
|
+
* Gate C oracles declare `all`, `not`, or `for-all` as their relation (only
|
|
66
|
+
* O-001 is a bare operator, `deep-equality`), so narrowing this to the eleven
|
|
67
|
+
* operators alone would fail the primary accept fixture on seven of eight.
|
|
68
|
+
*/
|
|
69
|
+
export declare const RELATION_VOCABULARY: readonly ["equality", "deep-equality", "containment", "existence", "absence", "regex", "set-membership", "ordering", "count-tolerance", "shape", "covers-by-key", "all", "any", "not", "for-all", "for-any"];
|
|
70
|
+
export declare const Relation: z.ZodEnum<{
|
|
71
|
+
absence: "absence";
|
|
72
|
+
all: "all";
|
|
73
|
+
any: "any";
|
|
74
|
+
containment: "containment";
|
|
75
|
+
"count-tolerance": "count-tolerance";
|
|
76
|
+
"covers-by-key": "covers-by-key";
|
|
77
|
+
"deep-equality": "deep-equality";
|
|
78
|
+
equality: "equality";
|
|
79
|
+
existence: "existence";
|
|
80
|
+
"for-all": "for-all";
|
|
81
|
+
"for-any": "for-any";
|
|
82
|
+
not: "not";
|
|
83
|
+
ordering: "ordering";
|
|
84
|
+
regex: "regex";
|
|
85
|
+
"set-membership": "set-membership";
|
|
86
|
+
shape: "shape";
|
|
87
|
+
}>;
|
|
88
|
+
export type Relation = z.infer<typeof Relation>;
|
|
89
|
+
export declare const ANCHORING_RESIDUAL = "positional check: admits an unanchored alternation, rejects an anchored pattern wrapped in a group";
|
|
90
|
+
export declare const ANCHORED_PATTERN_FORM: RegExp;
|
|
91
|
+
export declare const AnchoredPattern: z.ZodString;
|
|
92
|
+
/**
|
|
93
|
+
* The minimum operand count for `all` and `any`, settled here because AD-4
|
|
94
|
+
* leaves connective arity unstated. Zero would certify vacuously, the
|
|
95
|
+
* fail-open shape AD-4's three-valued resolution guards against; one is the
|
|
96
|
+
* identity; and two spellings of one tree would defeat the structural
|
|
97
|
+
* containment AD-3's alignment predicate computes, hence a floor of two.
|
|
98
|
+
*/
|
|
99
|
+
export declare const CONNECTIVE_MINIMUM_ARITY = 2;
|
|
100
|
+
/**
|
|
101
|
+
* Every expression form whose operands are a fixed-length tuple, with its
|
|
102
|
+
* arity. `not` is here because its one operand is a nested `Expression`, not
|
|
103
|
+
* the `Operand` union; `all`, `any`, `for-all`, and `for-any` are excluded
|
|
104
|
+
* because their operand counts are variable or their operands are named
|
|
105
|
+
* fields.
|
|
106
|
+
*
|
|
107
|
+
* The constraint ledger is built from this table so the two cannot drift; a
|
|
108
|
+
* test asserts each entry against what the schema actually rejects.
|
|
109
|
+
*/
|
|
110
|
+
export declare const TUPLE_ARITY: {
|
|
111
|
+
readonly equality: 2;
|
|
112
|
+
readonly 'deep-equality': 2;
|
|
113
|
+
readonly containment: 2;
|
|
114
|
+
readonly existence: 1;
|
|
115
|
+
readonly absence: 1;
|
|
116
|
+
readonly regex: 1;
|
|
117
|
+
readonly 'set-membership': 2;
|
|
118
|
+
readonly ordering: 1;
|
|
119
|
+
readonly 'count-tolerance': 1;
|
|
120
|
+
readonly shape: 1;
|
|
121
|
+
readonly 'covers-by-key': 2;
|
|
122
|
+
readonly not: 1;
|
|
123
|
+
};
|
|
124
|
+
export type Expression = {
|
|
125
|
+
op: 'equality';
|
|
126
|
+
operands: [Operand, Operand];
|
|
127
|
+
} | {
|
|
128
|
+
op: 'deep-equality';
|
|
129
|
+
operands: [Operand, Operand];
|
|
130
|
+
} | {
|
|
131
|
+
op: 'containment';
|
|
132
|
+
operands: [Operand, Operand];
|
|
133
|
+
} | {
|
|
134
|
+
op: 'existence';
|
|
135
|
+
operands: [Operand];
|
|
136
|
+
} | {
|
|
137
|
+
op: 'absence';
|
|
138
|
+
operands: [Operand];
|
|
139
|
+
} | {
|
|
140
|
+
op: 'regex';
|
|
141
|
+
operands: [Operand];
|
|
142
|
+
pattern: string;
|
|
143
|
+
} | {
|
|
144
|
+
op: 'set-membership';
|
|
145
|
+
operands: [Operand, SetOperand];
|
|
146
|
+
} | {
|
|
147
|
+
op: 'ordering';
|
|
148
|
+
operands: [Operand];
|
|
149
|
+
key: string;
|
|
150
|
+
order: z.infer<typeof SortOrder>;
|
|
151
|
+
} | {
|
|
152
|
+
op: 'count-tolerance';
|
|
153
|
+
operands: [Operand];
|
|
154
|
+
expected: number;
|
|
155
|
+
tolerance: number;
|
|
156
|
+
relative: boolean;
|
|
157
|
+
} | {
|
|
158
|
+
op: 'shape';
|
|
159
|
+
operands: [Operand];
|
|
160
|
+
descriptor: KeyedShapeDescriptor;
|
|
161
|
+
} | {
|
|
162
|
+
op: 'covers-by-key';
|
|
163
|
+
operands: [Operand, Operand];
|
|
164
|
+
expectedKey: string;
|
|
165
|
+
actualKey: string;
|
|
166
|
+
} | {
|
|
167
|
+
op: 'not';
|
|
168
|
+
operands: [Expression];
|
|
169
|
+
} | {
|
|
170
|
+
op: 'all';
|
|
171
|
+
operands: Expression[];
|
|
172
|
+
} | {
|
|
173
|
+
op: 'any';
|
|
174
|
+
operands: Expression[];
|
|
175
|
+
} | {
|
|
176
|
+
op: 'for-all';
|
|
177
|
+
collection: Operand;
|
|
178
|
+
predicate: Expression;
|
|
179
|
+
} | {
|
|
180
|
+
op: 'for-any';
|
|
181
|
+
collection: Operand;
|
|
182
|
+
predicate: Expression;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* `check` is a recursive discriminated union on `op`. Arity is enforced as
|
|
186
|
+
* fixed-length tuples, the one deliberate exception to the admit-rule (AD-13
|
|
187
|
+
* verified constraint injection specifically for arity), so
|
|
188
|
+
* `malformed-operator-expression`'s arity limb is schema-covered in v0; its
|
|
189
|
+
* live limbs are the rejected regex constructs and the operand-type
|
|
190
|
+
* violations the schema deliberately does not narrow.
|
|
191
|
+
*
|
|
192
|
+
* Carries `.meta({ id })` for the same reason `JsonValue` does: without it
|
|
193
|
+
* the tree exports as a generated `$defs.__schema0`, pinning a positional
|
|
194
|
+
* name into the published-schema drift check and leaving the ledger's twelve
|
|
195
|
+
* arity entries with no stable address.
|
|
196
|
+
*/
|
|
197
|
+
export declare const Expression: z.ZodType<Expression>;
|