@gate-forge/core 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.
Files changed (242) hide show
  1. package/LICENSE +202 -0
  2. package/dist/baselines/adoption.d.ts +76 -0
  3. package/dist/baselines/adoption.d.ts.map +1 -0
  4. package/dist/baselines/adoption.js +163 -0
  5. package/dist/baselines/adoption.js.map +1 -0
  6. package/dist/baselines/index.d.ts +102 -0
  7. package/dist/baselines/index.d.ts.map +1 -0
  8. package/dist/baselines/index.js +186 -0
  9. package/dist/baselines/index.js.map +1 -0
  10. package/dist/canonical-json.d.ts +51 -0
  11. package/dist/canonical-json.d.ts.map +1 -0
  12. package/dist/canonical-json.js +112 -0
  13. package/dist/canonical-json.js.map +1 -0
  14. package/dist/classifier/bind.d.ts +64 -0
  15. package/dist/classifier/bind.d.ts.map +1 -0
  16. package/dist/classifier/bind.js +188 -0
  17. package/dist/classifier/bind.js.map +1 -0
  18. package/dist/classifier/classify.d.ts +154 -0
  19. package/dist/classifier/classify.d.ts.map +1 -0
  20. package/dist/classifier/classify.js +1207 -0
  21. package/dist/classifier/classify.js.map +1 -0
  22. package/dist/classifier/glob.d.ts +48 -0
  23. package/dist/classifier/glob.d.ts.map +1 -0
  24. package/dist/classifier/glob.js +104 -0
  25. package/dist/classifier/glob.js.map +1 -0
  26. package/dist/classifier/index.d.ts +10 -0
  27. package/dist/classifier/index.d.ts.map +1 -0
  28. package/dist/classifier/index.js +21 -0
  29. package/dist/classifier/index.js.map +1 -0
  30. package/dist/classifier/schema.d.ts +150 -0
  31. package/dist/classifier/schema.d.ts.map +1 -0
  32. package/dist/classifier/schema.js +139 -0
  33. package/dist/classifier/schema.js.map +1 -0
  34. package/dist/config/index.d.ts +259 -0
  35. package/dist/config/index.d.ts.map +1 -0
  36. package/dist/config/index.js +523 -0
  37. package/dist/config/index.js.map +1 -0
  38. package/dist/fingerprints.d.ts +56 -0
  39. package/dist/fingerprints.d.ts.map +1 -0
  40. package/dist/fingerprints.js +59 -0
  41. package/dist/fingerprints.js.map +1 -0
  42. package/dist/graph/build.d.ts +16 -0
  43. package/dist/graph/build.d.ts.map +1 -0
  44. package/dist/graph/build.js +423 -0
  45. package/dist/graph/build.js.map +1 -0
  46. package/dist/graph/index.d.ts +12 -0
  47. package/dist/graph/index.d.ts.map +1 -0
  48. package/dist/graph/index.js +10 -0
  49. package/dist/graph/index.js.map +1 -0
  50. package/dist/graph/schema.d.ts +448 -0
  51. package/dist/graph/schema.d.ts.map +1 -0
  52. package/dist/graph/schema.js +237 -0
  53. package/dist/graph/schema.js.map +1 -0
  54. package/dist/graph/symbols.d.ts +129 -0
  55. package/dist/graph/symbols.d.ts.map +1 -0
  56. package/dist/graph/symbols.js +177 -0
  57. package/dist/graph/symbols.js.map +1 -0
  58. package/dist/graph/util.d.ts +40 -0
  59. package/dist/graph/util.d.ts.map +1 -0
  60. package/dist/graph/util.js +41 -0
  61. package/dist/graph/util.js.map +1 -0
  62. package/dist/index.d.ts +683 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +563 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/mapping/resolve.d.ts +177 -0
  67. package/dist/mapping/resolve.d.ts.map +1 -0
  68. package/dist/mapping/resolve.js +523 -0
  69. package/dist/mapping/resolve.js.map +1 -0
  70. package/dist/policy/coverage.d.ts +79 -0
  71. package/dist/policy/coverage.d.ts.map +1 -0
  72. package/dist/policy/coverage.js +119 -0
  73. package/dist/policy/coverage.js.map +1 -0
  74. package/dist/policy/evaluate.d.ts +275 -0
  75. package/dist/policy/evaluate.d.ts.map +1 -0
  76. package/dist/policy/evaluate.js +382 -0
  77. package/dist/policy/evaluate.js.map +1 -0
  78. package/dist/policy/index.d.ts +15 -0
  79. package/dist/policy/index.d.ts.map +1 -0
  80. package/dist/policy/index.js +14 -0
  81. package/dist/policy/index.js.map +1 -0
  82. package/dist/policy/trusted.d.ts +59 -0
  83. package/dist/policy/trusted.d.ts.map +1 -0
  84. package/dist/policy/trusted.js +96 -0
  85. package/dist/policy/trusted.js.map +1 -0
  86. package/dist/provenance.d.ts +170 -0
  87. package/dist/provenance.d.ts.map +1 -0
  88. package/dist/provenance.js +306 -0
  89. package/dist/provenance.js.map +1 -0
  90. package/dist/receipt/index.d.ts +74 -0
  91. package/dist/receipt/index.d.ts.map +1 -0
  92. package/dist/receipt/index.js +154 -0
  93. package/dist/receipt/index.js.map +1 -0
  94. package/dist/report/index.d.ts +100 -0
  95. package/dist/report/index.d.ts.map +1 -0
  96. package/dist/report/index.js +355 -0
  97. package/dist/report/index.js.map +1 -0
  98. package/dist/schemas/adoption.d.ts +40 -0
  99. package/dist/schemas/adoption.d.ts.map +1 -0
  100. package/dist/schemas/adoption.js +87 -0
  101. package/dist/schemas/adoption.js.map +1 -0
  102. package/dist/schemas/baseline.d.ts +19 -0
  103. package/dist/schemas/baseline.d.ts.map +1 -0
  104. package/dist/schemas/baseline.js +45 -0
  105. package/dist/schemas/baseline.js.map +1 -0
  106. package/dist/schemas/claim.d.ts +32 -0
  107. package/dist/schemas/claim.d.ts.map +1 -0
  108. package/dist/schemas/claim.js +34 -0
  109. package/dist/schemas/claim.js.map +1 -0
  110. package/dist/schemas/classification-policy.d.ts +84 -0
  111. package/dist/schemas/classification-policy.d.ts.map +1 -0
  112. package/dist/schemas/classification-policy.js +130 -0
  113. package/dist/schemas/classification-policy.js.map +1 -0
  114. package/dist/schemas/classification-signal.d.ts +125 -0
  115. package/dist/schemas/classification-signal.d.ts.map +1 -0
  116. package/dist/schemas/classification-signal.js +126 -0
  117. package/dist/schemas/classification-signal.js.map +1 -0
  118. package/dist/schemas/classification.d.ts +120 -0
  119. package/dist/schemas/classification.d.ts.map +1 -0
  120. package/dist/schemas/classification.js +154 -0
  121. package/dist/schemas/classification.js.map +1 -0
  122. package/dist/schemas/common.d.ts +73 -0
  123. package/dist/schemas/common.d.ts.map +1 -0
  124. package/dist/schemas/common.js +60 -0
  125. package/dist/schemas/common.js.map +1 -0
  126. package/dist/schemas/coverage-policy.d.ts +89 -0
  127. package/dist/schemas/coverage-policy.d.ts.map +1 -0
  128. package/dist/schemas/coverage-policy.js +81 -0
  129. package/dist/schemas/coverage-policy.js.map +1 -0
  130. package/dist/schemas/evidence.d.ts +65 -0
  131. package/dist/schemas/evidence.d.ts.map +1 -0
  132. package/dist/schemas/evidence.js +64 -0
  133. package/dist/schemas/evidence.js.map +1 -0
  134. package/dist/schemas/execution-result.d.ts +214 -0
  135. package/dist/schemas/execution-result.d.ts.map +1 -0
  136. package/dist/schemas/execution-result.js +240 -0
  137. package/dist/schemas/execution-result.js.map +1 -0
  138. package/dist/schemas/gate-receipt.d.ts +86 -0
  139. package/dist/schemas/gate-receipt.d.ts.map +1 -0
  140. package/dist/schemas/gate-receipt.js +193 -0
  141. package/dist/schemas/gate-receipt.js.map +1 -0
  142. package/dist/schemas/index.d.ts +22 -0
  143. package/dist/schemas/index.d.ts.map +1 -0
  144. package/dist/schemas/index.js +22 -0
  145. package/dist/schemas/index.js.map +1 -0
  146. package/dist/schemas/obligation.d.ts +37 -0
  147. package/dist/schemas/obligation.d.ts.map +1 -0
  148. package/dist/schemas/obligation.js +46 -0
  149. package/dist/schemas/obligation.js.map +1 -0
  150. package/dist/schemas/plugin.d.ts +19 -0
  151. package/dist/schemas/plugin.d.ts.map +1 -0
  152. package/dist/schemas/plugin.js +20 -0
  153. package/dist/schemas/plugin.js.map +1 -0
  154. package/dist/schemas/policy.d.ts +73 -0
  155. package/dist/schemas/policy.d.ts.map +1 -0
  156. package/dist/schemas/policy.js +46 -0
  157. package/dist/schemas/policy.js.map +1 -0
  158. package/dist/schemas/resource.d.ts +26 -0
  159. package/dist/schemas/resource.d.ts.map +1 -0
  160. package/dist/schemas/resource.js +29 -0
  161. package/dist/schemas/resource.js.map +1 -0
  162. package/dist/schemas/run-manifest.d.ts +72 -0
  163. package/dist/schemas/run-manifest.d.ts.map +1 -0
  164. package/dist/schemas/run-manifest.js +125 -0
  165. package/dist/schemas/run-manifest.js.map +1 -0
  166. package/dist/schemas/runner-adapter.d.ts +169 -0
  167. package/dist/schemas/runner-adapter.d.ts.map +1 -0
  168. package/dist/schemas/runner-adapter.js +2 -0
  169. package/dist/schemas/runner-adapter.js.map +1 -0
  170. package/dist/schemas/test-catalog.d.ts +472 -0
  171. package/dist/schemas/test-catalog.d.ts.map +1 -0
  172. package/dist/schemas/test-catalog.js +311 -0
  173. package/dist/schemas/test-catalog.js.map +1 -0
  174. package/dist/schemas/test-map.d.ts +99 -0
  175. package/dist/schemas/test-map.d.ts.map +1 -0
  176. package/dist/schemas/test-map.js +103 -0
  177. package/dist/schemas/test-map.js.map +1 -0
  178. package/dist/schemas/verdict.d.ts +73 -0
  179. package/dist/schemas/verdict.d.ts.map +1 -0
  180. package/dist/schemas/verdict.js +92 -0
  181. package/dist/schemas/verdict.js.map +1 -0
  182. package/dist/schemas/waiver.d.ts +36 -0
  183. package/dist/schemas/waiver.d.ts.map +1 -0
  184. package/dist/schemas/waiver.js +42 -0
  185. package/dist/schemas/waiver.js.map +1 -0
  186. package/dist/supervision/index.d.ts +170 -0
  187. package/dist/supervision/index.d.ts.map +1 -0
  188. package/dist/supervision/index.js +354 -0
  189. package/dist/supervision/index.js.map +1 -0
  190. package/dist/testing/clock.d.ts +50 -0
  191. package/dist/testing/clock.d.ts.map +1 -0
  192. package/dist/testing/clock.js +75 -0
  193. package/dist/testing/clock.js.map +1 -0
  194. package/dist/testing/env.d.ts +66 -0
  195. package/dist/testing/env.d.ts.map +1 -0
  196. package/dist/testing/env.js +106 -0
  197. package/dist/testing/env.js.map +1 -0
  198. package/dist/testing/gate-runner.d.ts +141 -0
  199. package/dist/testing/gate-runner.d.ts.map +1 -0
  200. package/dist/testing/gate-runner.js +173 -0
  201. package/dist/testing/gate-runner.js.map +1 -0
  202. package/dist/testing/gf19.d.ts +106 -0
  203. package/dist/testing/gf19.d.ts.map +1 -0
  204. package/dist/testing/gf19.js +282 -0
  205. package/dist/testing/gf19.js.map +1 -0
  206. package/dist/testing/index.d.ts +20 -0
  207. package/dist/testing/index.d.ts.map +1 -0
  208. package/dist/testing/index.js +14 -0
  209. package/dist/testing/index.js.map +1 -0
  210. package/dist/testing/red-probe.d.ts +138 -0
  211. package/dist/testing/red-probe.d.ts.map +1 -0
  212. package/dist/testing/red-probe.js +251 -0
  213. package/dist/testing/red-probe.js.map +1 -0
  214. package/dist/testing/temp-repo.d.ts +126 -0
  215. package/dist/testing/temp-repo.d.ts.map +1 -0
  216. package/dist/testing/temp-repo.js +214 -0
  217. package/dist/testing/temp-repo.js.map +1 -0
  218. package/dist/verdict/cause.d.ts +99 -0
  219. package/dist/verdict/cause.d.ts.map +1 -0
  220. package/dist/verdict/cause.js +206 -0
  221. package/dist/verdict/cause.js.map +1 -0
  222. package/dist/verdict/evaluate.d.ts +135 -0
  223. package/dist/verdict/evaluate.d.ts.map +1 -0
  224. package/dist/verdict/evaluate.js +1513 -0
  225. package/dist/verdict/evaluate.js.map +1 -0
  226. package/dist/verdict/index.d.ts +21 -0
  227. package/dist/verdict/index.d.ts.map +1 -0
  228. package/dist/verdict/index.js +20 -0
  229. package/dist/verdict/index.js.map +1 -0
  230. package/dist/verdict/pack-verifiers.d.ts +97 -0
  231. package/dist/verdict/pack-verifiers.d.ts.map +1 -0
  232. package/dist/verdict/pack-verifiers.js +763 -0
  233. package/dist/verdict/pack-verifiers.js.map +1 -0
  234. package/dist/verdict/registry.d.ts +180 -0
  235. package/dist/verdict/registry.d.ts.map +1 -0
  236. package/dist/verdict/registry.js +67 -0
  237. package/dist/verdict/registry.js.map +1 -0
  238. package/dist/waivers/index.d.ts +103 -0
  239. package/dist/waivers/index.d.ts.map +1 -0
  240. package/dist/waivers/index.js +192 -0
  241. package/dist/waivers/index.js.map +1 -0
  242. package/package.json +40 -0
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Execution-result record (plan 2026-09-13 §5.1 row "Execution result",
3
+ * Phase 4 work item 3, ADR 0005 D2): the trusted supervisor's OWN account
4
+ * of a run — planned versus executed instances, per-instance outcomes and
5
+ * attempts, runner exit, fixture/teardown outcome, shard completeness,
6
+ * selection + catalog digests, trusted policy digest, engine versions,
7
+ * and environment identity.
8
+ *
9
+ * Trust boundary (ADR 0005 D2): the suite reporter is INPUT, never
10
+ * signature authority. This record is written by trusted supervision
11
+ * under the excluded run-state directory; its digest (see
12
+ * {@link executionResultDigestOf}) is what the gate receipt binds —
13
+ * never a reporter aggregate. `outcomes` rows are supervision-normalized
14
+ * data, not the reporter's own summary.
15
+ */
16
+ import { z } from 'zod';
17
+ import { SchemaVersionField } from './common.js';
18
+ import { sha256Canonical } from '../canonical-json.js';
19
+ /** Domain tag separating execution-result digests from every other hash. */
20
+ export const EXECUTION_RESULT_DOMAIN = 'gateforge.execution-result.v1';
21
+ /** Domain tag separating selection digests from every other hash. */
22
+ export const SELECTION_DOMAIN = 'gateforge.selection.v1';
23
+ /** Hex pattern shared by every 64-char lowercase digest field. */
24
+ const HEX64 = /^[0-9a-f]{64}$/;
25
+ /** One planned instance (fixed BEFORE the run; ADR 0005 D2). */
26
+ export const PlannedInstanceSchema = z
27
+ .object({
28
+ /** Stable logical key (§5.2). */
29
+ logicalKey: z.string().min(1),
30
+ /** Runner project, or null when no enumeration bound one. */
31
+ project: z.string().min(1).nullable(),
32
+ /** Repo-relative posix file. */
33
+ file: z.string().min(1),
34
+ /** Full title path (describe stack, then the test title). */
35
+ titlePath: z.array(z.string().min(1)).min(1),
36
+ /** The framework's own instance id, or null when unbound. */
37
+ frameworkId: z.string().nullable(),
38
+ })
39
+ .strict();
40
+ /** Per-instance execution status the supervisor accepts from the runner. */
41
+ export const InstanceStatusSchema = z.enum(['passed', 'failed', 'skipped', 'fixme', 'not-run']);
42
+ /** One executed instance outcome (supervision-normalized; input only). */
43
+ export const ExecutedOutcomeSchema = z
44
+ .object({
45
+ /** Stable logical key the executed instance resolved to. */
46
+ logicalKey: z.string().min(1),
47
+ /** Runner project, or null when the runner did not report one. */
48
+ project: z.string().nullable(),
49
+ /** Repo-relative posix file (the instance identity join key). */
50
+ file: z.string().min(1),
51
+ /** Full title path (the instance identity join key). */
52
+ titlePath: z.array(z.string().min(1)),
53
+ /** Observed outcome on this attempt. */
54
+ status: InstanceStatusSchema,
55
+ /** Attempt number (1 = first attempt; required retries stay zero). */
56
+ attempt: z.number().int().min(1),
57
+ /** True when the instance was an expected failure (never proves behavior). */
58
+ expectedFailure: z.boolean(),
59
+ })
60
+ .strict();
61
+ /** One typed supervision finding (plan §5.4 run rows). */
62
+ export const SupervisionFindingSchema = z
63
+ .object({
64
+ /** Stable cause code (TEST_NOT_EXECUTED / TEST_FAILED / RUN_INCOMPLETE). */
65
+ cause: z.enum(['TEST_NOT_EXECUTED', 'TEST_FAILED', 'RUN_INCOMPLETE']),
66
+ /** Single-cause human explanation (instance-scoped when known). */
67
+ detail: z.string().min(1),
68
+ /** The logical key the finding is scoped to, or null for run-scoped. */
69
+ logicalKey: z.string().nullable(),
70
+ })
71
+ .strict();
72
+ /** One witness-recorded session of an expected test (execution authority). */
73
+ export const TracedSessionSchema = z
74
+ .object({
75
+ /** Witness-issued session id (UUID). */
76
+ sessionId: z.string().min(1),
77
+ /** Witness-monotonic tick at open. */
78
+ openedTick: z.number().int().min(0),
79
+ /** Witness-monotonic tick at seal (null = never sealed — blocking). */
80
+ sealedTick: z.number().int().min(0).nullable(),
81
+ /** The outcome the supervisor observed at close (null = unknown). */
82
+ outcome: z.string().nullable(),
83
+ /**
84
+ * Witness-side activity bound to the session (review recheck fix
85
+ * 2026-09-14): records issued under the session + recorded intervals
86
+ * + engine-observed exchanges. A sealed-passed session with zero
87
+ * activity blocks supervision (fabricated-lifecycle signature).
88
+ */
89
+ activity: z.number().int().min(0),
90
+ })
91
+ .strict();
92
+ /** The witness-side session trace for ONE expected test. */
93
+ export const TracedTestSchema = z
94
+ .object({
95
+ /** The runner-assigned id the session was opened under (diagnostic). */
96
+ testId: z.string().min(1).nullable(),
97
+ /** Registered runner project (the expected-set identity join key). */
98
+ project: z.string().min(1).nullable(),
99
+ /** Registered repo-relative posix file (the identity join key). */
100
+ file: z.string().min(1),
101
+ /** Registered full title path (the identity join key). */
102
+ titlePath: z.array(z.string().min(1)).min(1),
103
+ /** Every session the witness recorded for this expected test. */
104
+ sessions: z.array(TracedSessionSchema),
105
+ })
106
+ .strict();
107
+ /**
108
+ * The sealed execution result. Strict: unknown keys are rejected so a
109
+ * hostile run-state edit cannot smuggle extra authority in.
110
+ */
111
+ export const ExecutionResultSchema = z
112
+ .object({
113
+ schemaVersion: SchemaVersionField,
114
+ /** Run manifest identity the execution belongs to. */
115
+ runId: z.string().uuid(),
116
+ /** Fresh trusted invocation identity of the supervising run. */
117
+ invocationId: z.string().uuid(),
118
+ /** 64-hex digest of the canonical input snapshot this run tested. */
119
+ inputDigest: z.string().regex(HEX64, 'inputDigest must be 64-char lowercase hex'),
120
+ /** 64-hex trusted policy/config revision digest (ADR 0005 D6). */
121
+ trustedPolicyDigest: z.string().regex(HEX64, 'trustedPolicyDigest must be 64-char lowercase hex'),
122
+ /** The selection the supervisor fixed BEFORE the run. */
123
+ selection: z
124
+ .object({
125
+ /** Runner the selection executes under. */
126
+ runner: z.string().min(1),
127
+ /** Selection mode; `full-relevant-suite` until narrower selection is proven safe. */
128
+ mode: z.enum(['full-relevant-suite', 'mapped-selection']),
129
+ /** Exact logical keys the run was expected to cover (sorted). */
130
+ logicalKeys: z.array(z.string().min(1)),
131
+ })
132
+ .strict(),
133
+ /** 64-hex digest binding the selection (domain-separated). */
134
+ selectionDigest: z.string().regex(HEX64, 'selectionDigest must be 64-char lowercase hex'),
135
+ /** 64-hex digest of the catalog the selection was planned from. */
136
+ catalogDigest: z.string().regex(HEX64, 'catalogDigest must be 64-char lowercase hex'),
137
+ /** The planned instances (the expected test set, fixed pre-run). */
138
+ planned: z.array(PlannedInstanceSchema),
139
+ /** The executed instance outcomes (reporter data = input only). */
140
+ outcomes: z.array(ExecutedOutcomeSchema),
141
+ /**
142
+ * 64-hex digest over the expected set the witness registered BEFORE
143
+ * the run (enforcement-review fix 2d; additive). Present only when
144
+ * the supervisor registered an expected set with the witness.
145
+ */
146
+ enumerationDigest: z.string().regex(HEX64).optional(),
147
+ /**
148
+ * The witness-side per-test session trace (enforcement-review fix 2d;
149
+ * additive): sessionIds + outcomes per expected test, so receipts
150
+ * bind the CORROBORATED execution trace — not just the runner's own
151
+ * account. Present only when the supervisor fetched it.
152
+ */
153
+ sessionTrace: z.array(TracedTestSchema).optional(),
154
+ /** Framework process exit code (supplementary, never decisive). */
155
+ runnerExit: z.number().int().nullable(),
156
+ /** Supervision verdict: true only when the complete expected set passed. */
157
+ complete: z.boolean(),
158
+ /** Typed findings (empty only when complete). */
159
+ causes: z.array(SupervisionFindingSchema),
160
+ /** Setup/teardown/runner-body outcome the supervisor observed. */
161
+ fixtureOutcome: z.enum(['passed', 'failed', 'unknown']),
162
+ /** Shard completeness the supervisor verified. */
163
+ shardCompleteness: z
164
+ .object({
165
+ /** True only when every expected shard ran. */
166
+ complete: z.boolean(),
167
+ /** Single-cause detail when incomplete. */
168
+ detail: z.string(),
169
+ })
170
+ .strict(),
171
+ /** Highest attempt number observed (must be 1 — required retries are zero). */
172
+ maxAttemptObserved: z.number().int().min(1),
173
+ /** Engine/runtime versions the supervisor captured (honest subset). */
174
+ engines: z.record(z.string().min(1), z.string()),
175
+ /** Browser versions when the runner reports them (may be empty). */
176
+ browsers: z.record(z.string().min(1), z.string()),
177
+ /** 64-hex domain-separated environment identity (node/platform/arch/engines). */
178
+ environmentIdentity: z.string().regex(HEX64, 'environmentIdentity must be 64-char lowercase hex'),
179
+ /** Run start instant (ISO-8601). */
180
+ startedAt: z.string().datetime(),
181
+ /** Run end instant (ISO-8601). */
182
+ finishedAt: z.string().datetime(),
183
+ })
184
+ .strict()
185
+ .superRefine((result, ctx) => {
186
+ // A complete run with findings is a contradiction — fail closed on
187
+ // the inconsistent document instead of trusting either field.
188
+ if (result.complete && result.causes.length > 0) {
189
+ ctx.addIssue({
190
+ code: 'custom',
191
+ path: ['complete'],
192
+ message: 'a complete execution result cannot carry supervision causes',
193
+ });
194
+ }
195
+ if (!result.complete && result.causes.length === 0) {
196
+ ctx.addIssue({
197
+ code: 'custom',
198
+ path: ['causes'],
199
+ message: 'an incomplete execution result requires at least one typed cause',
200
+ });
201
+ }
202
+ });
203
+ /**
204
+ * Computes the domain-separated digest of an execution result (plan §5.1:
205
+ * the receipt binds THIS digest, never a reporter aggregate). The digest
206
+ * covers every field except the `causes`-vs-`complete` consistency check
207
+ * (which is structural, not content).
208
+ *
209
+ * Args:
210
+ * result: a validated execution result.
211
+ *
212
+ * Returns:
213
+ * string: 64-char lowercase hex digest.
214
+ *
215
+ * Throws:
216
+ * TypeError: when the result contains non-JSON-representable values.
217
+ */
218
+ export function executionResultDigestOf(result) {
219
+ return sha256Canonical({ domain: EXECUTION_RESULT_DOMAIN, result });
220
+ }
221
+ /**
222
+ * Computes the domain-separated selection digest (plan Phase 4 item 3:
223
+ * the expected test set is hashed BEFORE the run so a receipt binds the
224
+ * exact selection, and any selection change forces a fresh run).
225
+ *
226
+ * Args:
227
+ * selection: the runner, mode, and logical keys selected.
228
+ *
229
+ * Returns:
230
+ * string: 64-char lowercase hex digest.
231
+ */
232
+ export function selectionDigestOf(selection) {
233
+ return sha256Canonical({
234
+ domain: SELECTION_DOMAIN,
235
+ runner: selection.runner,
236
+ mode: selection.mode,
237
+ logicalKeys: [...new Set(selection.logicalKeys)].sort(),
238
+ });
239
+ }
240
+ //# sourceMappingURL=execution-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-result.js","sourceRoot":"","sources":["../../src/schemas/execution-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEv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AAC;YAClB,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,OAAO,EAAE,kEAAkE;SAC5E,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAKL;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAuB;IAC7D,OAAO,eAAe,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAIjC;IACC,OAAO,eAAe,CAAC;QACrB,MAAM,EAAE,gBAAgB;QACxB,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,WAAW,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE;KACxD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Gate receipt schema (plan 2026-09-13 §5.1 row "Gate receipt", ADR 0005
3
+ * D3): a NEW versioned, domain-separated envelope issued by trusted
4
+ * supervision only after complete run success and evidence grading.
5
+ *
6
+ * A receipt NEVER reuses or repurposes the v2 witness attestation
7
+ * (`gateforge.ledger.v2`): old evidence stays valid only for its original
8
+ * weaker contract. The receipt binds — in one authenticated object — the
9
+ * tested input digest, base/parent Git identity, the trusted policy
10
+ * revision digest (ADR 0005 D6), the invocation, the selection/catalog
11
+ * digests, the supervision execution-result digest, the evidence
12
+ * attestation digest, and the final verdict summary. The MAC is computed
13
+ * with the SAME authority as witness records (the witness verifier key,
14
+ * HMAC-SHA256 over GF-canonical JSON) — see `src/receipt/index.ts`.
15
+ *
16
+ * Scope extension (opt-in scoped supervised runs): a receipt also names
17
+ * its evaluation scope (`scope`, absent = `full` for pre-extension
18
+ * receipts) and, for `changed`-scope receipts, the pin-#2 fingerprints of
19
+ * the obligations the sealed slice covers. Both fields sit inside the
20
+ * signed body (the MAC covers every field but `mac` by construction), so
21
+ * a covered set cannot be widened or trimmed without breaking the
22
+ * signature.
23
+ */
24
+ import { z } from 'zod';
25
+ /**
26
+ * The evaluation scope a receipt seals (opt-in scoped supervised runs):
27
+ * - `full` — the whole relevant suite ran and the whole-repo gate was
28
+ * green (the historical, default shape);
29
+ * - `changed` — only the SLICE of tests claiming obligations affected by
30
+ * the changed files ran, and only those obligations were graded.
31
+ * OPTIONAL/additive like `approvedPolicyDigest`: receipts sealed before
32
+ * scoped runs existed omit it and are read as `full` (that is exactly
33
+ * what the old seal process certified).
34
+ */
35
+ export declare const ReceiptScopeSchema: z.ZodEnum<{
36
+ changed: "changed";
37
+ full: "full";
38
+ }>;
39
+ /** Inferred receipt-scope shape. */
40
+ export type ReceiptScope = z.infer<typeof ReceiptScopeSchema>;
41
+ /** The final verdict summary the receipt seals. */
42
+ export declare const ReceiptVerdictSummarySchema: z.ZodObject<{
43
+ total: z.ZodNumber;
44
+ satisfied: z.ZodNumber;
45
+ waived: z.ZodNumber;
46
+ blocking: z.ZodNumber;
47
+ }, z.core.$strict>;
48
+ /** Inferred receipt verdict-summary shape. */
49
+ export type ReceiptVerdictSummary = z.infer<typeof ReceiptVerdictSummarySchema>;
50
+ /**
51
+ * The gate receipt. Unsigned fields first, `mac` last; the signed body is
52
+ * exactly `{domain, receiptVersion, ...everything except mac}`.
53
+ */
54
+ export declare const GateReceiptSchema: z.ZodObject<{
55
+ schemaVersion: z.ZodLiteral<1>;
56
+ receiptVersion: z.ZodLiteral<1>;
57
+ receiptId: z.ZodString;
58
+ runId: z.ZodString;
59
+ invocationId: z.ZodString;
60
+ inputDigest: z.ZodString;
61
+ gitSha: z.ZodNullable<z.ZodString>;
62
+ parentSha: z.ZodNullable<z.ZodString>;
63
+ trustedPolicyDigest: z.ZodString;
64
+ approvedPolicyDigest: z.ZodOptional<z.ZodString>;
65
+ scope: z.ZodOptional<z.ZodEnum<{
66
+ changed: "changed";
67
+ full: "full";
68
+ }>>;
69
+ coveredObligationFingerprints: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ invocation: z.ZodString;
71
+ selectionDigest: z.ZodString;
72
+ catalogDigest: z.ZodString;
73
+ executionResultDigest: z.ZodString;
74
+ evidenceAttestationDigest: z.ZodNullable<z.ZodString>;
75
+ verdictSummary: z.ZodObject<{
76
+ total: z.ZodNumber;
77
+ satisfied: z.ZodNumber;
78
+ waived: z.ZodNumber;
79
+ blocking: z.ZodNumber;
80
+ }, z.core.$strict>;
81
+ issuedAt: z.ZodString;
82
+ mac: z.ZodString;
83
+ }, z.core.$strict>;
84
+ /** Inferred gate-receipt shape. */
85
+ export type GateReceipt = z.infer<typeof GateReceiptSchema>;
86
+ //# sourceMappingURL=gate-receipt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-receipt.d.ts","sourceRoot":"","sources":["../../src/schemas/gate-receipt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;EAA8B,CAAC;AAE9D,oCAAoC;AACpC,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,mDAAmD;AACnD,eAAO,MAAM,2BAA2B;;;;;kBAmBpC,CAAC;AAEL,8CAA8C;AAC9C,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAGhF;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgI1B,CAAC;AAEL,mCAAmC;AACnC,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Gate receipt schema (plan 2026-09-13 §5.1 row "Gate receipt", ADR 0005
3
+ * D3): a NEW versioned, domain-separated envelope issued by trusted
4
+ * supervision only after complete run success and evidence grading.
5
+ *
6
+ * A receipt NEVER reuses or repurposes the v2 witness attestation
7
+ * (`gateforge.ledger.v2`): old evidence stays valid only for its original
8
+ * weaker contract. The receipt binds — in one authenticated object — the
9
+ * tested input digest, base/parent Git identity, the trusted policy
10
+ * revision digest (ADR 0005 D6), the invocation, the selection/catalog
11
+ * digests, the supervision execution-result digest, the evidence
12
+ * attestation digest, and the final verdict summary. The MAC is computed
13
+ * with the SAME authority as witness records (the witness verifier key,
14
+ * HMAC-SHA256 over GF-canonical JSON) — see `src/receipt/index.ts`.
15
+ *
16
+ * Scope extension (opt-in scoped supervised runs): a receipt also names
17
+ * its evaluation scope (`scope`, absent = `full` for pre-extension
18
+ * receipts) and, for `changed`-scope receipts, the pin-#2 fingerprints of
19
+ * the obligations the sealed slice covers. Both fields sit inside the
20
+ * signed body (the MAC covers every field but `mac` by construction), so
21
+ * a covered set cannot be widened or trimmed without breaking the
22
+ * signature.
23
+ */
24
+ import { z } from 'zod';
25
+ import { SchemaVersionField } from './common.js';
26
+ import { FingerprintHexSchema } from './baseline.js';
27
+ /** Hex pattern shared by every digest field. */
28
+ const HEX64 = /^[0-9a-f]{64}$/;
29
+ /**
30
+ * The evaluation scope a receipt seals (opt-in scoped supervised runs):
31
+ * - `full` — the whole relevant suite ran and the whole-repo gate was
32
+ * green (the historical, default shape);
33
+ * - `changed` — only the SLICE of tests claiming obligations affected by
34
+ * the changed files ran, and only those obligations were graded.
35
+ * OPTIONAL/additive like `approvedPolicyDigest`: receipts sealed before
36
+ * scoped runs existed omit it and are read as `full` (that is exactly
37
+ * what the old seal process certified).
38
+ */
39
+ export const ReceiptScopeSchema = z.enum(['full', 'changed']);
40
+ /** The final verdict summary the receipt seals. */
41
+ export const ReceiptVerdictSummarySchema = z
42
+ .object({
43
+ /** Number of obligations evaluated. */
44
+ total: z.number().int().min(0),
45
+ /** Obligations graded `satisfied`. */
46
+ satisfied: z.number().int().min(0),
47
+ /** Obligations graded `waived` (legacy/reporting; not strict proof). */
48
+ waived: z.number().int().min(0),
49
+ /** Blocking obligations + blocking entries (must be 0 for issuance). */
50
+ blocking: z.number().int().min(0),
51
+ })
52
+ .strict()
53
+ .superRefine((summary, ctx) => {
54
+ if (summary.satisfied + summary.waived > summary.total) {
55
+ ctx.addIssue({
56
+ code: 'custom',
57
+ message: 'satisfied + waived cannot exceed total obligations',
58
+ });
59
+ }
60
+ });
61
+ /**
62
+ * The gate receipt. Unsigned fields first, `mac` last; the signed body is
63
+ * exactly `{domain, receiptVersion, ...everything except mac}`.
64
+ */
65
+ export const GateReceiptSchema = z
66
+ .object({
67
+ schemaVersion: SchemaVersionField,
68
+ /** Envelope version; only `1` is produced or honored. */
69
+ receiptVersion: z.literal(1),
70
+ /** Receipt identity (UUID) — the `reused receipt <id>` surface value. */
71
+ receiptId: z.string().uuid(),
72
+ /** Run manifest identity of the sealed run. */
73
+ runId: z.string().uuid(),
74
+ /** Fresh trusted invocation identity of the sealed run. */
75
+ invocationId: z.string().uuid(),
76
+ /** 64-hex digest of the canonical input snapshot the run tested. */
77
+ inputDigest: z.string().regex(HEX64, 'inputDigest must be 64-char lowercase hex'),
78
+ /** Candidate HEAD sha, or null when unavailable (base identity). */
79
+ gitSha: z
80
+ .string()
81
+ .regex(/^[0-9a-f]{40}$/, 'gitSha must be a 40-char lowercase sha1 hex')
82
+ .nullable(),
83
+ /** Parent commit sha, or null when unavailable (parent identity). */
84
+ parentSha: z
85
+ .string()
86
+ .regex(/^[0-9a-f]{40}$/, 'parentSha must be a 40-char lowercase sha1 hex')
87
+ .nullable(),
88
+ /** 64-hex trusted policy/config revision digest (ADR 0005 D6). */
89
+ trustedPolicyDigest: z.string().regex(HEX64, 'trustedPolicyDigest must be 64-char lowercase hex'),
90
+ /**
91
+ * ADDITIVE v1 field: 64-hex digest of the OWNER-APPROVED policy
92
+ * revision the sealing run was pinned to (from
93
+ * `GATEFORGE_APPROVED_POLICY_DIGEST` / `--approved-policy-digest` /
94
+ * a trusted config outside the candidate). OPTIONAL for backward
95
+ * compatibility: receipts sealed before a policy pin was provisioned
96
+ * omit it and remain verifiable without a pin; verification under a
97
+ * provisioned pin demands it and rejects a missing or different value
98
+ * as "policy revision changed after sealing" (fail closed).
99
+ */
100
+ approvedPolicyDigest: z
101
+ .string()
102
+ .regex(HEX64, 'approvedPolicyDigest must be 64-char lowercase hex')
103
+ .optional(),
104
+ /**
105
+ * ADDITIVE v1 field: the evaluation scope the receipt seals. OPTIONAL
106
+ * for backward compatibility — absent reads as `full`, which is what
107
+ * the historical seal process (whole relevant suite, whole-repo clean
108
+ * gate) certified. See {@link ReceiptScopeSchema}.
109
+ */
110
+ scope: ReceiptScopeSchema.optional(),
111
+ /**
112
+ * ADDITIVE v1 field, `scope: 'changed'` receipts ONLY: the pin-#2
113
+ * fingerprints of the obligations the sealed slice covers (sorted,
114
+ * duplicate-free). Fingerprints — not obligation ids — because they
115
+ * are the SAME identity the baseline/waiver layers hash
116
+ * (`obligationFingerprint`), so every consumer joins covered sets
117
+ * through one hash and a policy/lifecycle change (which moves the
118
+ * fingerprint) cannot let an old receipt claim a reshaped obligation.
119
+ * A `full` receipt must NOT carry the field (it covers everything by
120
+ * definition); a `changed` receipt must (an empty slice seals
121
+ * nothing and is refused at planning, never receipted).
122
+ */
123
+ coveredObligationFingerprints: z.array(FingerprintHexSchema).optional(),
124
+ /** Normalized invocation that produced the receipt (e.g. `test-gates --changed`). */
125
+ invocation: z.string().min(1),
126
+ /** 64-hex selection digest (the expected test set, fixed pre-run). */
127
+ selectionDigest: z.string().regex(HEX64, 'selectionDigest must be 64-char lowercase hex'),
128
+ /** 64-hex digest of the catalog the selection was planned from. */
129
+ catalogDigest: z.string().regex(HEX64, 'catalogDigest must be 64-char lowercase hex'),
130
+ /** 64-hex digest of the supervision execution result (ADR 0005 D2). */
131
+ executionResultDigest: z.string().regex(HEX64, 'executionResultDigest must be 64-char lowercase hex'),
132
+ /**
133
+ * 64-hex digest of the v2 evidence attestation envelope sealed into
134
+ * the receipt, or null when the run carried none (such a run can only
135
+ * be clean when no evidence was required).
136
+ */
137
+ evidenceAttestationDigest: z.string().regex(HEX64, 'evidenceAttestationDigest must be 64-char lowercase hex').nullable(),
138
+ /** Final verdict summary (blocking must have been 0 at issuance). */
139
+ verdictSummary: ReceiptVerdictSummarySchema,
140
+ /** Issuance instant (ISO-8601). */
141
+ issuedAt: z.string().datetime(),
142
+ /** HMAC-SHA256 over the receipt body, domain `gateforge.receipt.v1`. */
143
+ mac: z.string().regex(HEX64, 'mac must be a 64-char lowercase hex HMAC'),
144
+ })
145
+ .strict()
146
+ .superRefine((receipt, ctx) => {
147
+ // Scope/coverage coherence (fail closed): the covered set exists only
148
+ // for changed-scope receipts, and a changed-scope receipt without one
149
+ // would claim authority over an unnamed slice. Ordering/duplication
150
+ // are enforced so the canonical signed bytes are deterministic.
151
+ if (receipt.scope === 'changed') {
152
+ const covered = receipt.coveredObligationFingerprints;
153
+ if (covered === undefined || covered.length === 0) {
154
+ ctx.addIssue({
155
+ code: 'custom',
156
+ path: ['coveredObligationFingerprints'],
157
+ message: "a 'changed'-scope receipt must carry its coveredObligationFingerprints",
158
+ });
159
+ return;
160
+ }
161
+ const sorted = [...covered].sort();
162
+ for (let index = 0; index < covered.length; index += 1) {
163
+ const current = covered[index];
164
+ const expected = sorted[index];
165
+ if (current !== expected) {
166
+ ctx.addIssue({
167
+ code: 'custom',
168
+ path: ['coveredObligationFingerprints', index],
169
+ message: "coveredObligationFingerprints must be sorted; expected '" + expected +
170
+ "' at index " + index + ", got '" + current + "'",
171
+ });
172
+ return;
173
+ }
174
+ if (index > 0 && current === covered[index - 1]) {
175
+ ctx.addIssue({
176
+ code: 'custom',
177
+ path: ['coveredObligationFingerprints', index],
178
+ message: `duplicate covered fingerprint '${current}'`,
179
+ });
180
+ return;
181
+ }
182
+ }
183
+ return;
184
+ }
185
+ if (receipt.coveredObligationFingerprints !== undefined) {
186
+ ctx.addIssue({
187
+ code: 'custom',
188
+ path: ['coveredObligationFingerprints'],
189
+ message: "only a 'changed'-scope receipt may carry coveredObligationFingerprints",
190
+ });
191
+ }
192
+ });
193
+ //# sourceMappingURL=gate-receipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-receipt.js","sourceRoot":"","sources":["../../src/schemas/gate-receipt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,gDAAgD;AAChD,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAK9D,mDAAmD;AACnD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC;KACzC,MAAM,CAAC;IACN,uCAAuC;IACvC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,sCAAsC;IACtC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,wEAAwE;IACxE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B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B,KAAK,SAAS,EAAE,CAAC;QACxD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,+BAA+B,CAAC;YACvC,OAAO,EAAE,wEAAwE;SAClF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Barrel for all gateforge artifact schemas (zod) and their inferred
3
+ * types. This barrel plus `src/index.ts` form the frozen public surface.
4
+ */
5
+ export * from './common.js';
6
+ export * from './resource.js';
7
+ export * from './classification.js';
8
+ export * from './policy.js';
9
+ export * from './obligation.js';
10
+ export * from './claim.js';
11
+ export * from './evidence.js';
12
+ export * from './waiver.js';
13
+ export * from './baseline.js';
14
+ export * from './run-manifest.js';
15
+ export * from './verdict.js';
16
+ export * from './coverage-policy.js';
17
+ export * from './test-catalog.js';
18
+ export * from './runner-adapter.js';
19
+ export * from './plugin.js';
20
+ export * from './execution-result.js';
21
+ export * from './gate-receipt.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Barrel for all gateforge artifact schemas (zod) and their inferred
3
+ * types. This barrel plus `src/index.ts` form the frozen public surface.
4
+ */
5
+ export * from './common.js';
6
+ export * from './resource.js';
7
+ export * from './classification.js';
8
+ export * from './policy.js';
9
+ export * from './obligation.js';
10
+ export * from './claim.js';
11
+ export * from './evidence.js';
12
+ export * from './waiver.js';
13
+ export * from './baseline.js';
14
+ export * from './run-manifest.js';
15
+ export * from './verdict.js';
16
+ export * from './coverage-policy.js';
17
+ export * from './test-catalog.js';
18
+ export * from './runner-adapter.js';
19
+ export * from './plugin.js';
20
+ export * from './execution-result.js';
21
+ export * from './gate-receipt.js';
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Obligation schema (plan §4.5): a concrete test requirement generated
3
+ * from a resource and a policy. Obligation ids are
4
+ * `<resourceId>:<contract>` (e.g. `tenant.accounts:crud:update`) and the
5
+ * fingerprint over their identity is what baselines store (pin #2).
6
+ *
7
+ * Id grammar: the id splits at the FIRST colon — `resourceId` never
8
+ * contains a colon, `contract` may (e.g. `crud:update`).
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * The obligation artifact. `lifecycle` carries the classification
13
+ * lifecycle attributes relevant to this obligation — it is part of the
14
+ * fingerprint identity (pin #2), so it must travel with the obligation.
15
+ */
16
+ export declare const ObligationSchema: z.ZodObject<{
17
+ schemaVersion: z.ZodLiteral<1>;
18
+ id: z.ZodString;
19
+ resourceId: z.ZodString;
20
+ contract: z.ZodString;
21
+ policyId: z.ZodString;
22
+ lifecycle: z.ZodObject<{
23
+ create: z.ZodBoolean;
24
+ read: z.ZodBoolean;
25
+ update: z.ZodBoolean;
26
+ delete: z.ZodBoolean;
27
+ deleteSemantics: z.ZodOptional<z.ZodEnum<{
28
+ hard: "hard";
29
+ archive: "archive";
30
+ }>>;
31
+ archiveFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
32
+ updateableFields: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
+ }, z.core.$strict>;
34
+ }, z.core.$strict>;
35
+ /** Inferred obligation shape. */
36
+ export type Obligation = z.infer<typeof ObligationSchema>;
37
+ //# sourceMappingURL=obligation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obligation.d.ts","sourceRoot":"","sources":["../../src/schemas/obligation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;kBA2BzB,CAAC;AAEL,iCAAiC;AACjC,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}