eval-quality 0.1.0 → 0.3.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.
Files changed (179) hide show
  1. package/README.md +142 -67
  2. package/corpus/dev/README.md +20 -13
  3. package/corpus/dev/compile-seal-example/brief.json +1 -1
  4. package/corpus/dev/compile-seal-example/contract.json +1 -1
  5. package/corpus/dev/contracts/absent-collection-locations.json +1 -1
  6. package/corpus/dev/contracts/absent-sibling-groups.json +1 -1
  7. package/corpus/dev/contracts/absent-success-indicator.json +1 -1
  8. package/corpus/dev/contracts/empty-channel-roles.json +1 -1
  9. package/corpus/dev/contracts/empty-collection-locations.json +1 -1
  10. package/corpus/dev/contracts/empty-request-shapes.json +1 -1
  11. package/corpus/dev/contracts/empty-sibling-groups.json +1 -1
  12. package/corpus/dev/contracts/fragment-selection.json +1 -0
  13. package/corpus/dev/contracts/no-collection-quantifier.json +1 -1
  14. package/corpus/dev/contracts/no-operation-inventory.json +1 -1
  15. package/corpus/dev/contracts/no-read-back-relation.json +1 -1
  16. package/corpus/dev/contracts/no-state-change-marker.json +1 -1
  17. package/corpus/dev/contracts/no-type-violating-step.json +1 -1
  18. package/corpus/dev/contracts/per-key-split-oracles.json +1 -1
  19. package/corpus/dev/contracts/review-corpus.json +1 -0
  20. package/corpus/dev/contracts/satisfied-declarations.json +1 -1
  21. package/corpus/dev/contracts/single-required-response-key.json +1 -1
  22. package/corpus/dev/contracts/split-indicator-oracle.json +1 -1
  23. package/corpus/dev/contracts/unaddressed-parameter-sibling.json +1 -1
  24. package/corpus/dev/contracts/unnamed-reference-set.json +1 -1
  25. package/corpus/dev/contracts/wrong-cardinality-form.json +1 -1
  26. package/corpus/dev/index.json +1 -1
  27. package/dist/application/index.d.ts +2 -0
  28. package/dist/application/index.js +1 -0
  29. package/dist/application/score.d.ts +48 -0
  30. package/dist/application/score.js +186 -0
  31. package/dist/cli/arguments.d.ts +7 -3
  32. package/dist/cli/arguments.js +73 -5
  33. package/dist/cli/exit-codes.d.ts +6 -2
  34. package/dist/cli/exit-codes.js +8 -9
  35. package/dist/cli/main.js +9 -0
  36. package/dist/cli/render.d.ts +3 -6
  37. package/dist/cli/render.js +57 -5
  38. package/dist/cli/run.d.ts +13 -3
  39. package/dist/cli/run.js +136 -16
  40. package/dist/core/canonical/canonicalize.d.ts +12 -0
  41. package/dist/core/canonical/canonicalize.js +18 -4
  42. package/dist/core/compile/bindings.d.ts +89 -0
  43. package/dist/core/compile/bindings.js +334 -0
  44. package/dist/core/compile/compile.d.ts +17 -0
  45. package/dist/core/compile/compile.js +37 -1
  46. package/dist/core/compile/excluded-content.d.ts +11 -0
  47. package/dist/core/compile/excluded-content.js +42 -0
  48. package/dist/core/compile/expression-legality.d.ts +49 -0
  49. package/dist/core/compile/expression-legality.js +158 -38
  50. package/dist/core/compile/forbidden-inputs.d.ts +8 -1
  51. package/dist/core/compile/forbidden-inputs.js +16 -3
  52. package/dist/core/compile/interface-inventory.d.ts +57 -2
  53. package/dist/core/compile/interface-inventory.js +119 -13
  54. package/dist/core/compile/reachability.d.ts +28 -1
  55. package/dist/core/compile/reachability.js +167 -35
  56. package/dist/core/compile/schema-version.d.ts +2 -0
  57. package/dist/core/compile/schema-version.js +25 -0
  58. package/dist/core/compile/sensitivity-witness.d.ts +31 -12
  59. package/dist/core/compile/sensitivity-witness.js +110 -23
  60. package/dist/core/compile/step-reference.d.ts +2 -0
  61. package/dist/core/compile/step-reference.js +49 -0
  62. package/dist/core/coverage/operations.d.ts +62 -0
  63. package/dist/core/coverage/operations.js +57 -0
  64. package/dist/core/coverage/relevance.d.ts +4 -2
  65. package/dist/core/coverage/relevance.js +22 -23
  66. package/dist/core/coverage/satisfaction.d.ts +2 -2
  67. package/dist/core/coverage/satisfaction.js +73 -48
  68. package/dist/core/declared-inputs.d.ts +83 -4
  69. package/dist/core/declared-inputs.js +105 -8
  70. package/dist/core/emit/emit.d.ts +9 -0
  71. package/dist/core/emit/emit.js +214 -0
  72. package/dist/core/emit/private-artifact-digest.d.ts +11 -0
  73. package/dist/core/emit/private-artifact-digest.js +31 -0
  74. package/dist/core/evaluate/evidence-resolution.d.ts +10 -3
  75. package/dist/core/evaluate/evidence-resolution.js +74 -11
  76. package/dist/core/evaluate/operators.d.ts +22 -0
  77. package/dist/core/evaluate/operators.js +17 -1
  78. package/dist/core/evaluate/resolution.d.ts +14 -3
  79. package/dist/core/evaluate/resolution.js +63 -3
  80. package/dist/core/excluded-content.d.ts +65 -0
  81. package/dist/core/excluded-content.js +113 -0
  82. package/dist/core/failure-codes.d.ts +2 -2
  83. package/dist/core/failure-codes.js +7 -2
  84. package/dist/core/ingest/conditions.d.ts +201 -0
  85. package/dist/core/ingest/conditions.js +48 -0
  86. package/dist/core/ingest/index.d.ts +13 -0
  87. package/dist/core/ingest/index.js +11 -0
  88. package/dist/core/ingest/ingest.d.ts +68 -0
  89. package/dist/core/ingest/ingest.js +318 -0
  90. package/dist/core/lineage/stage-table.d.ts +21 -4
  91. package/dist/core/lineage/stage-table.js +35 -3
  92. package/dist/core/preflight/plan.d.ts +7 -5
  93. package/dist/core/preflight/plan.js +75 -32
  94. package/dist/core/preflight/projection.d.ts +6 -3
  95. package/dist/core/preflight/projection.js +22 -2
  96. package/dist/core/preflight/reduce.js +47 -7
  97. package/dist/core/preflight/witness-evidence.d.ts +5 -5
  98. package/dist/core/preflight/witness-evidence.js +73 -20
  99. package/dist/core/schemas/artifact.d.ts +1049 -30
  100. package/dist/core/schemas/constraint-ledger.js +51 -0
  101. package/dist/core/schemas/defect-signature.d.ts +695 -0
  102. package/dist/core/schemas/defect-signature.js +175 -0
  103. package/dist/core/schemas/eval-contract.d.ts +550 -12
  104. package/dist/core/schemas/eval-contract.js +32 -2
  105. package/dist/core/schemas/evidence-artifact.d.ts +109 -19
  106. package/dist/core/schemas/evidence-artifact.js +64 -8
  107. package/dist/core/schemas/interface.d.ts +741 -13
  108. package/dist/core/schemas/interface.js +120 -7
  109. package/dist/core/schemas/isolation-manifest.js +16 -9
  110. package/dist/core/schemas/plan.d.ts +329 -3
  111. package/dist/core/schemas/plan.js +89 -3
  112. package/dist/core/schemas/pointer.d.ts +47 -1
  113. package/dist/core/schemas/pointer.js +89 -8
  114. package/dist/core/schemas/port-messages.d.ts +194 -10
  115. package/dist/core/schemas/port-messages.js +73 -6
  116. package/dist/core/schemas/probe-body.d.ts +18 -0
  117. package/dist/core/schemas/probe-body.js +13 -0
  118. package/dist/core/schemas/probe-qualification.d.ts +168 -0
  119. package/dist/core/schemas/probe-qualification.js +106 -0
  120. package/dist/core/schemas/probe.d.ts +431 -0
  121. package/dist/core/schemas/probe.js +6 -2
  122. package/dist/core/schemas/scoring-policy.d.ts +1 -0
  123. package/dist/core/schemas/scoring-policy.js +6 -1
  124. package/dist/core/schemas/sealed-evaluator-brief.d.ts +1 -0
  125. package/dist/core/schemas/sealed-evaluator-brief.js +4 -1
  126. package/dist/core/schemas/sealed-run-record.d.ts +161 -12
  127. package/dist/core/schemas/sealed-run-record.js +92 -15
  128. package/dist/core/schemas/sensitivity-witness.d.ts +108 -6
  129. package/dist/core/schemas/sensitivity-witness.js +61 -5
  130. package/dist/core/score/binding-order.d.ts +31 -0
  131. package/dist/core/score/binding-order.js +88 -0
  132. package/dist/core/score/bindings.d.ts +93 -0
  133. package/dist/core/score/bindings.js +309 -0
  134. package/dist/core/score/ladder-table.d.ts +23 -0
  135. package/dist/core/score/ladder-table.js +109 -0
  136. package/dist/core/score/ladder.d.ts +229 -0
  137. package/dist/core/score/ladder.js +464 -0
  138. package/dist/core/score/mode-agreement.d.ts +30 -0
  139. package/dist/core/score/mode-agreement.js +16 -0
  140. package/dist/core/score/outcome-table.d.ts +17 -0
  141. package/dist/core/score/outcome-table.js +172 -0
  142. package/dist/core/score/outcome.d.ts +466 -0
  143. package/dist/core/score/outcome.js +562 -0
  144. package/dist/core/score/qualification.d.ts +83 -0
  145. package/dist/core/score/qualification.js +645 -0
  146. package/dist/core/score/quotation.d.ts +56 -0
  147. package/dist/core/score/quotation.js +226 -0
  148. package/dist/core/score/reduce-trials.d.ts +80 -0
  149. package/dist/core/score/reduce-trials.js +90 -0
  150. package/dist/core/score/score.d.ts +72 -0
  151. package/dist/core/score/score.js +607 -0
  152. package/dist/core/score/selection.d.ts +80 -0
  153. package/dist/core/score/selection.js +98 -0
  154. package/dist/core/score/strength.d.ts +58 -0
  155. package/dist/core/score/strength.js +227 -0
  156. package/dist/core/score/witness.d.ts +138 -0
  157. package/dist/core/score/witness.js +320 -0
  158. package/dist/core/seal/derived-reference.d.ts +2 -9
  159. package/dist/core/seal/derived-reference.js +293 -46
  160. package/dist/core/seal/plan-index.d.ts +18 -3
  161. package/dist/core/seal/plan-index.js +44 -8
  162. package/dist/core/seal/seal.js +8 -3
  163. package/dist/core/stage-contracts.d.ts +62 -2
  164. package/dist/index.d.ts +1 -1
  165. package/dist/index.js +1 -1
  166. package/dist/ports/environment-probe-port.d.ts +60 -4
  167. package/dist/testing/index.d.ts +2 -0
  168. package/dist/testing/index.js +1 -0
  169. package/dist/testing/probe-conformance.d.ts +29 -0
  170. package/dist/testing/probe-conformance.js +34 -5
  171. package/package.json +12 -3
  172. package/schemas/eval-contract.schema.json +1787 -797
  173. package/schemas/evidence-artifact.schema.json +126 -9
  174. package/schemas/isolation-manifest.schema.json +17 -10
  175. package/schemas/probe.schema.json +636 -5
  176. package/schemas/rubric.schema.json +1 -1
  177. package/schemas/scoring-policy.schema.json +8 -1
  178. package/schemas/sealed-evaluator-brief.schema.json +11 -1
  179. package/schemas/sealed-run-record.schema.json +314 -40
@@ -0,0 +1,175 @@
1
+ /** AD-40's machine-readable defect signature and its probe-side selector. */
2
+ import { z } from 'zod';
3
+ import { Expression } from './expression.js';
4
+ import { CommandInvocation, HttpMethod, PathTemplate } from './interface.js';
5
+ import { LiteralBindingValue, MatcherBindingValue } from './plan.js';
6
+ import { EvidenceChannel } from './pointer.js';
7
+ import { KeyName } from './primitives.js';
8
+ /**
9
+ * The reserved step identifier every pointer in a discriminating condition is
10
+ * rooted at. AD-40 requires the predicate to be rooted at the selected
11
+ * observation rather than at a step identifier, and the shipped `Expression`
12
+ * addresses evidence only through an interaction-rooted pointer, so the
13
+ * signature spends one fixed word instead of minting a fourth pointer grammar:
14
+ *
15
+ * /interactions/observed/response-status
16
+ * /interactions/observed/response-body/error/code
17
+ *
18
+ * A fixed word, so no contract-local choice reaches the corpus, and the gate
19
+ * checks contract-independence instead of asserting it. Evaluation is the
20
+ * shipped path with no adapter: build the resolver map with exactly this one
21
+ * key, and resolve.
22
+ *
23
+ * `observed` is a legal `Identifier` and nothing reserves it, so a contract may
24
+ * declare a step by that name. The design is safe because the resolver map is
25
+ * built fresh with exactly one key and is never merged with a plan's
26
+ * observations. That is a stated invariant of this module;
27
+ * `compile/sensitivity-witness.ts` guards the same collision one level in.
28
+ */
29
+ export const OBSERVED_STEP_ID = 'observed';
30
+ /**
31
+ * The probe-side binding value: `{ literal }` and `{ matcher }` only.
32
+ *
33
+ * Deliberately its own union rather than a reuse of `BindingValue`, which also
34
+ * admits `{ captured }` and `{ principal }`. A captured pointer names an
35
+ * earlier step of a contract's plan, and a principal names an entry of a
36
+ * contract's `testData`; both are contract-local vocabulary, and a corpus
37
+ * signature that carried either would resolve nothing against a second
38
+ * contract. The rejection is structural, so a probe carrying one fails to parse
39
+ * rather than qualifying and then matching nothing.
40
+ */
41
+ export const ProbeBindingValue = z.union([
42
+ LiteralBindingValue,
43
+ MatcherBindingValue,
44
+ ]);
45
+ /** the constraint identifier the ledger carries for the check below. */
46
+ export const PROBE_BINDING_CHANNEL_NON_EMPTY = 'probe-binding-channel-non-empty';
47
+ // Caller-keyed by the author's own parameter names, and `{}` is rejected for
48
+ // the same reason the contract-side channel rejects it: a binding channel has
49
+ // exactly one spelling for "binds nothing", which is `null`.
50
+ //
51
+ // Named, like `InputBindingChannel`, so the constraint ledger has one stable
52
+ // address to inject `minProperties` at. Verified rather than assumed: leaving
53
+ // it inlined at four addresses left the rejection Zod-only, and the
54
+ // published-schema differential caught the disagreement on a synthesised
55
+ // witness carrying `{}` in three of the four channels.
56
+ export const ProbeBindingChannel = z
57
+ .record(KeyName, ProbeBindingValue)
58
+ .refine((entries) => Object.keys(entries).length > 0, {
59
+ error: 'a signature selector channel names at least one parameter; an unbound channel is null',
60
+ })
61
+ .nullable()
62
+ .meta({
63
+ id: 'ProbeInputBindingChannel',
64
+ description: "A parameter-name-to-binding-value map for one input channel of a defect signature's selector, or `null` for a channel the selector binds nothing in. An empty map is rejected: `null` is the only spelling for unbound. Admits `{ literal }` and `{ matcher }` only; `{ captured }` and `{ principal }` are contract-local vocabulary and a corpus signature cannot carry either.",
65
+ });
66
+ /**
67
+ * Every input channel of either kind, spelled exactly as `ObservedCallInputs`
68
+ * spells them. The two shapes agree on channel names, on the eight-key strict
69
+ * form, and on flatness, so the selector filters recorded call inputs with no
70
+ * shape to bridge.
71
+ *
72
+ * One object over both kinds rather than a union, on `ObservedCallInputs`'s own
73
+ * reasoning: `null` already means "binds nothing here", so a selector that
74
+ * binds only command channels writes `null` in the transport four and nothing
75
+ * is ambiguous. `InputBinding` on the contract side is a union instead, because
76
+ * a request-shape channel's "declared, no keys" state is not the same as
77
+ * unused and the two spellings had to stay apart.
78
+ */
79
+ export const ProbeInputBinding = z.strictObject({
80
+ path: ProbeBindingChannel,
81
+ query: ProbeBindingChannel,
82
+ header: ProbeBindingChannel,
83
+ body: ProbeBindingChannel,
84
+ argument: ProbeBindingChannel,
85
+ option: ProbeBindingChannel,
86
+ environment: ProbeBindingChannel,
87
+ stdin: ProbeBindingChannel,
88
+ });
89
+ /**
90
+ * AD-39's selector grammar, duplicated on the corpus side, minus the two
91
+ * members a corpus cannot fill. The operation is the signature's own home
92
+ * operation and is not repeated here; the temporal clause is dropped because no
93
+ * corpus signature needs it. A state-corruption defect that only fires on a
94
+ * second call is already expressible as a predicate over any single
95
+ * observation, and AD-40's mapping is per probe rather than per call sequence.
96
+ * What would reopen the question is pair-defect signatures across the monotonic
97
+ * observation sequence, a future need `preflight/witness-evidence.ts` already
98
+ * records.
99
+ */
100
+ export const ProbeStepSelector = z.strictObject({
101
+ inputBinding: ProbeInputBinding,
102
+ });
103
+ /**
104
+ * AD-40's discriminating condition: a selector over observations paired with a
105
+ * predicate over the selected observation's response.
106
+ *
107
+ * The predicate is the shipped `Expression` in AD-4's closed operator
108
+ * vocabulary, never a second relation language. A second vocabulary is a second
109
+ * set of degenerate cases to fix, and AD-4's are already fixed and fixtured.
110
+ * Every pointer in the predicate is rooted at `OBSERVED_STEP_ID`; that rule,
111
+ * the response-channel rule, and AD-4's own legality rules are checked at
112
+ * corpus qualification time rather than here, because each of them is a
113
+ * cross-field or cross-artifact rule the published export cannot carry.
114
+ */
115
+ export const DiscriminatingCondition = z.strictObject({
116
+ selector: ProbeStepSelector,
117
+ predicate: Expression.describe("An AD-4 expression over AD-26 response channels, every pointer rooted at the reserved step identifier `observed`. Legality is the corpus qualification gate's: an unchecked predicate admits `existence` over a literal, which is true of every observation and makes the catch rate 1.00 by construction."),
118
+ });
119
+ /**
120
+ * AD-40's four declarations: the interface kind, the defect's home operation as
121
+ * a method and a path template, the observable channel it manifests in, and the
122
+ * discriminating condition that separates it from correct behaviour.
123
+ *
124
+ * Method and path template rather than an operation identifier, because AD-19
125
+ * declares both per operation and both are contract-independent: an identifier
126
+ * is contract-local and would bind nothing against a second contract.
127
+ * Resolution erases parameter names before comparing, so a signature on
128
+ * `/notes/{id}` binds a contract declaring `/notes/{noteId}`; a post-erasure
129
+ * collision inside one contract has already failed compilation under
130
+ * `duplicate-operation-signature`.
131
+ */
132
+ const signatureCommon = {
133
+ observableChannel: EvidenceChannel.describe('AD-26\'s channel the seeded defect manifests in. The qualification gate reads it: a condition passes only if its pointers name this channel, or name two channels with at least one response-side member. That rule exists to reject a condition collapsing to "the evidence contains the string I sent", which is satisfied by a finding that merely echoes its own input. It must also be a channel the declared kind produces: an api interface writes nothing to standard output and a command returns no HTTP status.'),
134
+ condition: DiscriminatingCondition,
135
+ };
136
+ /**
137
+ * A signature against an interface that speaks HTTP. `web` and `mcp` share the
138
+ * shape and are still rejected by the qualification gate, which is what keeps
139
+ * `signature-interface-kind-unsupported` fireable on the kinds whose probe
140
+ * semantics are undeclared.
141
+ *
142
+ * One branch over the three kinds rather than three identical branches. Three
143
+ * would publish three byte-identical subschemas, and AD-13's mutation sweep
144
+ * cannot attribute a keyword deletion to one of several identical branches:
145
+ * deleting `pathTemplate`'s pattern from the second still leaves the first
146
+ * accepting everything the corpus carries, so nothing flips.
147
+ */
148
+ export const ApiDefectSignature = z.strictObject({
149
+ interfaceKind: z.enum(['api', 'web', 'mcp']),
150
+ method: HttpMethod,
151
+ pathTemplate: PathTemplate,
152
+ ...signatureCommon,
153
+ });
154
+ /**
155
+ * A signature against an interface that runs behind a command. It declares the
156
+ * transport identity a command operation declares, for the reason AD-40 gives
157
+ * for method and path template: the identity has to be contract-independent so
158
+ * a signature authored against a corpus binds a second contract's operation.
159
+ * An operation identifier is contract-local and would bind nothing.
160
+ */
161
+ export const CommandDefectSignature = z.strictObject({
162
+ interfaceKind: z.literal('cli'),
163
+ invocation: CommandInvocation,
164
+ ...signatureCommon,
165
+ });
166
+ /**
167
+ * A plain union rather than a discriminated one: the discriminator would have
168
+ * to be `interfaceKind`, and the api-shaped branch carries three values for it.
169
+ * The two branches are told apart by the identity they declare, exactly as
170
+ * `InputBinding`'s two are told apart by the channels they name.
171
+ */
172
+ export const DefectSignature = z.union([
173
+ ApiDefectSignature,
174
+ CommandDefectSignature,
175
+ ]);