@cleocode/contracts 2026.5.111 → 2026.5.112
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/dist/__tests__/evidence-atom-schema.test.d.ts +16 -0
- package/dist/__tests__/evidence-atom-schema.test.d.ts.map +1 -0
- package/dist/__tests__/evidence-atom-schema.test.js +394 -0
- package/dist/__tests__/evidence-atom-schema.test.js.map +1 -0
- package/dist/evidence-atom-schema.d.ts +407 -0
- package/dist/evidence-atom-schema.d.ts.map +1 -0
- package/dist/evidence-atom-schema.js +505 -0
- package/dist/evidence-atom-schema.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/invariants/__tests__/registry.test.d.ts +14 -0
- package/dist/invariants/__tests__/registry.test.d.ts.map +1 -0
- package/dist/invariants/__tests__/registry.test.js +113 -0
- package/dist/invariants/__tests__/registry.test.js.map +1 -0
- package/dist/invariants/adr-073-saga.d.ts +32 -0
- package/dist/invariants/adr-073-saga.d.ts.map +1 -0
- package/dist/invariants/adr-073-saga.js +155 -0
- package/dist/invariants/adr-073-saga.js.map +1 -0
- package/dist/invariants/index.d.ts +159 -0
- package/dist/invariants/index.d.ts.map +1 -0
- package/dist/invariants/index.js +109 -0
- package/dist/invariants/index.js.map +1 -0
- package/package.json +2 -2
- package/src/__tests__/evidence-atom-schema.test.ts +499 -0
- package/src/evidence-atom-schema.ts +628 -0
- package/src/index.ts +39 -0
- package/src/invariants/__tests__/registry.test.ts +136 -0
- package/src/invariants/adr-073-saga.ts +167 -0
- package/src/invariants/index.ts +213 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema + gate-to-atom mapping for the ADR-051 evidence atom grammar.
|
|
3
|
+
*
|
|
4
|
+
* `cleo verify <task-id> --evidence "<atoms>"` accepts a semicolon-delimited
|
|
5
|
+
* list of evidence atoms. Each atom carries a kind prefix and a payload. The
|
|
6
|
+
* grammar lives in three places today:
|
|
7
|
+
*
|
|
8
|
+
* 1. {@link EvidenceAtomSchema} — Zod discriminated union covering every
|
|
9
|
+
* parseable atom shape (this file).
|
|
10
|
+
* 2. {@link GATE_EVIDENCE_REQUIREMENTS} — gate → satisfying atom-combination
|
|
11
|
+
* map (this file).
|
|
12
|
+
* 3. `packages/core/src/tasks/evidence.ts` — runtime parser + filesystem /
|
|
13
|
+
* git / tool validators. The runtime parser delegates to
|
|
14
|
+
* {@link parseEvidenceString} below for the syntactic split.
|
|
15
|
+
*
|
|
16
|
+
* The schema is exposed for LLM agents and IDE tooling that want to validate
|
|
17
|
+
* an evidence string client-side BEFORE invoking `cleo verify`. The CLI
|
|
18
|
+
* runtime continues to perform the full filesystem-aware validation pass
|
|
19
|
+
* because Zod cannot check that a commit SHA is reachable or that a file
|
|
20
|
+
* exists on disk.
|
|
21
|
+
*
|
|
22
|
+
* The atom shapes here mirror the `ParsedAtom` union in
|
|
23
|
+
* `packages/core/src/tasks/evidence.ts` exactly. Behavior parity with the
|
|
24
|
+
* pre-T10337 ad-hoc parser is required — see the T10337 test suite for the
|
|
25
|
+
* full parity matrix.
|
|
26
|
+
*
|
|
27
|
+
* @task T10337
|
|
28
|
+
* @saga T10326
|
|
29
|
+
* @adr ADR-051
|
|
30
|
+
*/
|
|
31
|
+
import { z } from 'zod';
|
|
32
|
+
import type { VerificationGate } from './task.js';
|
|
33
|
+
/**
|
|
34
|
+
* `commit:<sha>` atom — references a git commit by full or short SHA.
|
|
35
|
+
*
|
|
36
|
+
* Format: `commit:<7-40 hex chars>`. The schema accepts any 7-40-character
|
|
37
|
+
* lowercase hex SHA; the runtime validator additionally checks reachability
|
|
38
|
+
* from the task branch and the AC-file content-intersect rule (T9245).
|
|
39
|
+
*
|
|
40
|
+
* @task T832
|
|
41
|
+
*/
|
|
42
|
+
export declare const commitAtomSchema: z.ZodObject<{
|
|
43
|
+
kind: z.ZodLiteral<"commit">;
|
|
44
|
+
sha: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/**
|
|
47
|
+
* `files:<p1,p2,...>` atom — list of file paths that the task touched.
|
|
48
|
+
*
|
|
49
|
+
* Format: `files:<comma-separated paths>`. The runtime validator additionally
|
|
50
|
+
* stats each path and records its sha256.
|
|
51
|
+
*
|
|
52
|
+
* @task T832
|
|
53
|
+
*/
|
|
54
|
+
export declare const filesAtomSchema: z.ZodObject<{
|
|
55
|
+
kind: z.ZodLiteral<"files">;
|
|
56
|
+
paths: z.ZodArray<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* `test-run:<path>` atom — path to a structured test runner JSON output
|
|
60
|
+
* (vitest, jest, pytest, cargo-nextest, etc.).
|
|
61
|
+
*
|
|
62
|
+
* Format: `test-run:<absolute or project-relative path>`. The runtime validator
|
|
63
|
+
* loads the file, parses the JSON, and rejects when failedTests > 0 or
|
|
64
|
+
* totalTests === 0.
|
|
65
|
+
*
|
|
66
|
+
* @task T832
|
|
67
|
+
*/
|
|
68
|
+
export declare const testRunAtomSchema: z.ZodObject<{
|
|
69
|
+
kind: z.ZodLiteral<"test-run">;
|
|
70
|
+
path: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
/**
|
|
73
|
+
* `tool:<name>` atom — runs a project-resolved canonical tool and accepts
|
|
74
|
+
* exit-code 0.
|
|
75
|
+
*
|
|
76
|
+
* Format: `tool:<canonical name or legacy alias>`. Canonical names: `test`,
|
|
77
|
+
* `build`, `lint`, `typecheck`, `audit`, `security-scan`. Legacy aliases
|
|
78
|
+
* (`pnpm-test`, `tsc`, `biome`, `cargo-test`, `pytest`, …) still resolve via
|
|
79
|
+
* the runtime resolver (ADR-061 / T1534).
|
|
80
|
+
*
|
|
81
|
+
* @task T832
|
|
82
|
+
* @task T1534
|
|
83
|
+
*/
|
|
84
|
+
export declare const toolAtomSchema: z.ZodObject<{
|
|
85
|
+
kind: z.ZodLiteral<"tool">;
|
|
86
|
+
tool: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
/**
|
|
89
|
+
* `url:<href>` atom — soft evidence pointing to an external artifact (docs,
|
|
90
|
+
* dashboard, etc.).
|
|
91
|
+
*
|
|
92
|
+
* Format: `url:<http(s)://...>`. The runtime validator requires the
|
|
93
|
+
* `http://` or `https://` scheme.
|
|
94
|
+
*
|
|
95
|
+
* @task T832
|
|
96
|
+
*/
|
|
97
|
+
export declare const urlAtomSchema: z.ZodObject<{
|
|
98
|
+
kind: z.ZodLiteral<"url">;
|
|
99
|
+
url: z.ZodString;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
/**
|
|
102
|
+
* `note:<text>` atom — free-form note used for soft evidence and waivers.
|
|
103
|
+
*
|
|
104
|
+
* Format: `note:<1-512 chars>`. The runtime validator caps the note at 512
|
|
105
|
+
* characters to keep the gate-evidence record bounded.
|
|
106
|
+
*
|
|
107
|
+
* @task T832
|
|
108
|
+
*/
|
|
109
|
+
export declare const noteAtomSchema: z.ZodObject<{
|
|
110
|
+
kind: z.ZodLiteral<"note">;
|
|
111
|
+
note: z.ZodString;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
/**
|
|
114
|
+
* `decision:<id>` atom — references a `brain_decisions` row that IS the
|
|
115
|
+
* canonical artifact for a decision-only task. Satisfies the `implemented`
|
|
116
|
+
* gate when combined with `files:` pointing to a research note or with
|
|
117
|
+
* `note:` (T1875).
|
|
118
|
+
*
|
|
119
|
+
* Format: `decision:<id>` (e.g. `decision:D-arch-001`). The runtime validator
|
|
120
|
+
* looks up the row and requires `confirmation_state` ∈ {`accepted`,
|
|
121
|
+
* `proposed`}.
|
|
122
|
+
*
|
|
123
|
+
* @task T1875
|
|
124
|
+
*/
|
|
125
|
+
export declare const decisionAtomSchema: z.ZodObject<{
|
|
126
|
+
kind: z.ZodLiteral<"decision">;
|
|
127
|
+
decisionId: z.ZodString;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
/**
|
|
130
|
+
* `pr:<number>` atom — references a GitHub PR by number. Satisfies BOTH
|
|
131
|
+
* `testsPassed` and `qaPassed` simultaneously when the PR is MERGED and every
|
|
132
|
+
* required-workflow check is green (T9764). Extended in T9838 to satisfy
|
|
133
|
+
* `implemented` because the merge commit IS the landing artifact.
|
|
134
|
+
*
|
|
135
|
+
* Format: `pr:<positive integer>` (e.g. `pr:357`).
|
|
136
|
+
*
|
|
137
|
+
* @task T9764
|
|
138
|
+
* @task T9838
|
|
139
|
+
*/
|
|
140
|
+
export declare const prAtomSchema: z.ZodObject<{
|
|
141
|
+
kind: z.ZodLiteral<"pr">;
|
|
142
|
+
prNumber: z.ZodNumber;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
/**
|
|
145
|
+
* `loc-drop:<fromLines>:<toLines>` atom — proves that a migrated engine shed
|
|
146
|
+
* lines. Required for the `implemented` gate when the task carries the
|
|
147
|
+
* `engine-migration` label (T1604).
|
|
148
|
+
*
|
|
149
|
+
* Format: `loc-drop:<non-negative integer>:<non-negative integer>`.
|
|
150
|
+
* The schema admits any non-negative pair; the runtime validator additionally
|
|
151
|
+
* requires `fromLines > 0` and `toLines <= fromLines`.
|
|
152
|
+
*
|
|
153
|
+
* @task T1604
|
|
154
|
+
*/
|
|
155
|
+
export declare const locDropAtomSchema: z.ZodObject<{
|
|
156
|
+
kind: z.ZodLiteral<"loc-drop">;
|
|
157
|
+
fromLines: z.ZodNumber;
|
|
158
|
+
toLines: z.ZodNumber;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
/**
|
|
161
|
+
* `callsite-coverage:<symbol>:<sourcePath>` atom — proves that an exported
|
|
162
|
+
* symbol has ≥1 production callsite outside its own source file, test files,
|
|
163
|
+
* and dist directories. Required for the `implemented` gate when the task
|
|
164
|
+
* carries the `callsite-coverage` label (T1605).
|
|
165
|
+
*
|
|
166
|
+
* @task T1605
|
|
167
|
+
*/
|
|
168
|
+
export declare const callsiteCoverageAtomSchema: z.ZodObject<{
|
|
169
|
+
kind: z.ZodLiteral<"callsite-coverage">;
|
|
170
|
+
symbolName: z.ZodString;
|
|
171
|
+
relativeSourcePath: z.ZodString;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
/**
|
|
174
|
+
* Zod discriminated union covering every parseable evidence atom prefix.
|
|
175
|
+
*
|
|
176
|
+
* Use `EvidenceAtomSchema.safeParse(atom)` to validate a single atom client-
|
|
177
|
+
* side BEFORE invoking `cleo verify`. The runtime parser in
|
|
178
|
+
* `packages/core/src/tasks/evidence.ts` performs filesystem/git/tool checks
|
|
179
|
+
* on top of this syntactic schema.
|
|
180
|
+
*
|
|
181
|
+
* Atom kinds:
|
|
182
|
+
* - `commit` — git commit SHA (T832)
|
|
183
|
+
* - `files` — touched file paths (T832)
|
|
184
|
+
* - `test-run` — structured test runner JSON (T832)
|
|
185
|
+
* - `tool` — project-resolved tool exit code (T832 / T1534)
|
|
186
|
+
* - `url` — soft external pointer (T832)
|
|
187
|
+
* - `note` — free-form note (T832)
|
|
188
|
+
* - `decision` — brain_decisions row reference (T1875)
|
|
189
|
+
* - `pr` — merged-PR retroactive proof (T9764 / T9838)
|
|
190
|
+
* - `loc-drop` — engine-migration LOC reduction (T1604)
|
|
191
|
+
* - `callsite-coverage` — exported-symbol production callsite (T1605)
|
|
192
|
+
*
|
|
193
|
+
* @task T10337
|
|
194
|
+
* @adr ADR-051
|
|
195
|
+
*/
|
|
196
|
+
export declare const EvidenceAtomSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
197
|
+
kind: z.ZodLiteral<"commit">;
|
|
198
|
+
sha: z.ZodString;
|
|
199
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
200
|
+
kind: z.ZodLiteral<"files">;
|
|
201
|
+
paths: z.ZodArray<z.ZodString>;
|
|
202
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
203
|
+
kind: z.ZodLiteral<"test-run">;
|
|
204
|
+
path: z.ZodString;
|
|
205
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
206
|
+
kind: z.ZodLiteral<"tool">;
|
|
207
|
+
tool: z.ZodString;
|
|
208
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
209
|
+
kind: z.ZodLiteral<"url">;
|
|
210
|
+
url: z.ZodString;
|
|
211
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
212
|
+
kind: z.ZodLiteral<"note">;
|
|
213
|
+
note: z.ZodString;
|
|
214
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
215
|
+
kind: z.ZodLiteral<"decision">;
|
|
216
|
+
decisionId: z.ZodString;
|
|
217
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
218
|
+
kind: z.ZodLiteral<"pr">;
|
|
219
|
+
prNumber: z.ZodNumber;
|
|
220
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
221
|
+
kind: z.ZodLiteral<"loc-drop">;
|
|
222
|
+
fromLines: z.ZodNumber;
|
|
223
|
+
toLines: z.ZodNumber;
|
|
224
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
225
|
+
kind: z.ZodLiteral<"callsite-coverage">;
|
|
226
|
+
symbolName: z.ZodString;
|
|
227
|
+
relativeSourcePath: z.ZodString;
|
|
228
|
+
}, z.core.$strip>], "kind">;
|
|
229
|
+
/**
|
|
230
|
+
* Inferred TypeScript type for a parsed evidence atom.
|
|
231
|
+
*
|
|
232
|
+
* This is the pre-validation shape emitted by {@link parseEvidenceString}
|
|
233
|
+
* — distinct from the post-validation `EvidenceAtom` in `./task.ts` which
|
|
234
|
+
* carries fields populated by the runtime validator (sha256, exitCode, etc.).
|
|
235
|
+
*
|
|
236
|
+
* @task T10337
|
|
237
|
+
*/
|
|
238
|
+
export type EvidenceAtom = z.infer<typeof EvidenceAtomSchema>;
|
|
239
|
+
/** Discriminant union of every atom kind accepted by {@link EvidenceAtomSchema}. */
|
|
240
|
+
export type EvidenceAtomKind = EvidenceAtom['kind'];
|
|
241
|
+
/**
|
|
242
|
+
* Per-gate evidence requirement spec.
|
|
243
|
+
*
|
|
244
|
+
* Each entry of `oneOf` is a satisfying atom-combination — the gate is
|
|
245
|
+
* satisfied IFF EVERY kind listed in at least ONE of the combinations is
|
|
246
|
+
* present among the supplied atoms.
|
|
247
|
+
*
|
|
248
|
+
* A single-element combination `['pr']` means "one `pr:` atom alone
|
|
249
|
+
* satisfies the gate". A two-element combination `['commit', 'files']` means
|
|
250
|
+
* "both a `commit:` atom AND a `files:` atom must be present".
|
|
251
|
+
*
|
|
252
|
+
* @task T10337
|
|
253
|
+
* @adr ADR-051 §2.3
|
|
254
|
+
*/
|
|
255
|
+
export interface GateEvidenceRequirement {
|
|
256
|
+
/** Alternative satisfying combinations — ANY one is sufficient. */
|
|
257
|
+
oneOf: ReadonlyArray<ReadonlyArray<EvidenceAtomKind>>;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Mapping from each {@link VerificationGate} to its satisfying atom
|
|
261
|
+
* combinations. Mirrors the legacy `GATE_EVIDENCE_MINIMUMS` table in
|
|
262
|
+
* `packages/core/src/tasks/evidence.ts` exactly — behavior parity required
|
|
263
|
+
* by T10337.
|
|
264
|
+
*
|
|
265
|
+
* ## Why two alternatives for `implemented`?
|
|
266
|
+
*
|
|
267
|
+
* The `implemented` gate accepts six different evidence shapes:
|
|
268
|
+
*
|
|
269
|
+
* - `[commit, files]` — standard: commit SHA + touched file list.
|
|
270
|
+
* - `[commit, note]` — deletion-safe: commit SHA + descriptive note
|
|
271
|
+
* (when the implementation deleted files there
|
|
272
|
+
* are none left to anchor `files:`).
|
|
273
|
+
* - `[decision, files]` — decision-only task: brain_decisions row +
|
|
274
|
+
* research-note file (T1875).
|
|
275
|
+
* - `[decision, note]` — decision-only task without research note.
|
|
276
|
+
* - `[pr]` — merged-PR retroactive proof (T9838 extension
|
|
277
|
+
* of T9764).
|
|
278
|
+
*
|
|
279
|
+
* ## Why is `qaPassed` listed as `['tool']` not `['tool', 'tool']`?
|
|
280
|
+
*
|
|
281
|
+
* The pre-T10337 runtime enforced "at least one atom of kind `tool` is
|
|
282
|
+
* present" — it did NOT count distinct tool names. The convention `tool:lint`
|
|
283
|
+
* + `tool:typecheck` is documented in AGENTS.md as best-practice but the
|
|
284
|
+
* gate is satisfied by a single tool atom (e.g. `tool:test` when test
|
|
285
|
+
* already runs lint + typecheck pre-flight). Behavior parity requires that
|
|
286
|
+
* single-tool atoms continue to pass.
|
|
287
|
+
*
|
|
288
|
+
* @task T10337
|
|
289
|
+
* @adr ADR-051 §2.3
|
|
290
|
+
*/
|
|
291
|
+
export declare const GATE_EVIDENCE_REQUIREMENTS: Readonly<Record<VerificationGate, GateEvidenceRequirement>>;
|
|
292
|
+
/**
|
|
293
|
+
* Result of {@link validateEvidenceForGate}.
|
|
294
|
+
*
|
|
295
|
+
* Success carries no extra payload (the caller already holds the atom list).
|
|
296
|
+
* Failure carries a human-readable message in the legacy
|
|
297
|
+
* `Gate '<gate>' requires evidence: [<combo>] OR [<combo>]` format so error
|
|
298
|
+
* surfaces (E_EVIDENCE_INSUFFICIENT) read identically across the CLI and any
|
|
299
|
+
* client-side validator built on top of this schema.
|
|
300
|
+
*/
|
|
301
|
+
export type EvidenceValidationResult = {
|
|
302
|
+
readonly ok: true;
|
|
303
|
+
} | {
|
|
304
|
+
readonly ok: false;
|
|
305
|
+
readonly message: string;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Format the satisfying-combinations spec for a gate as the legacy
|
|
309
|
+
* `[commit AND files] OR [pr]` string used in CLI error messages.
|
|
310
|
+
*
|
|
311
|
+
* Exposed so consumers can render the same hint text without re-computing it.
|
|
312
|
+
*
|
|
313
|
+
* @task T10337
|
|
314
|
+
*/
|
|
315
|
+
export declare function formatGateRequirement(gate: VerificationGate): string;
|
|
316
|
+
/**
|
|
317
|
+
* Check whether a set of parsed atoms satisfies the requirement spec for
|
|
318
|
+
* `gate`.
|
|
319
|
+
*
|
|
320
|
+
* Returns `{ ok: true }` when ANY combination in `GATE_EVIDENCE_REQUIREMENTS[gate].oneOf`
|
|
321
|
+
* is fully present in `atoms` (matched by kind). Returns
|
|
322
|
+
* `{ ok: false, message }` otherwise — the message matches the legacy
|
|
323
|
+
* `checkGateEvidenceMinimum()` format byte-for-byte so error surfaces do not
|
|
324
|
+
* regress.
|
|
325
|
+
*
|
|
326
|
+
* Atoms must already be parsed (via {@link parseEvidenceString} or
|
|
327
|
+
* {@link EvidenceAtomSchema}); the helper does NOT re-validate the atom
|
|
328
|
+
* payload. Use {@link EvidenceAtomSchema.safeParse} first if the input came
|
|
329
|
+
* from an untrusted source.
|
|
330
|
+
*
|
|
331
|
+
* @param gate - Verification gate being checked.
|
|
332
|
+
* @param atoms - Already-parsed evidence atoms.
|
|
333
|
+
* @returns Pass / fail with a human-readable failure message.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* const atoms = parseEvidenceString('commit:abc1234;files:src/foo.ts');
|
|
338
|
+
* validateEvidenceForGate('implemented', atoms); // { ok: true }
|
|
339
|
+
* validateEvidenceForGate('testsPassed', atoms);
|
|
340
|
+
* // { ok: false, message: "Gate 'testsPassed' requires evidence: [test-run] OR [tool] OR [pr]" }
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @task T10337
|
|
344
|
+
* @adr ADR-051 §2.3
|
|
345
|
+
*/
|
|
346
|
+
export declare function validateEvidenceForGate(gate: VerificationGate, atoms: ReadonlyArray<{
|
|
347
|
+
kind: EvidenceAtomKind;
|
|
348
|
+
}>): EvidenceValidationResult;
|
|
349
|
+
/**
|
|
350
|
+
* Error class thrown by {@link parseEvidenceString} when the input is
|
|
351
|
+
* malformed. Carries a {@link reason} suitable for the CLI `fix:` hint.
|
|
352
|
+
*
|
|
353
|
+
* Pure data — no dependency on `@cleocode/contracts/errors` (which would
|
|
354
|
+
* pull the CleoError import surface into every consumer that just wants
|
|
355
|
+
* syntactic validation).
|
|
356
|
+
*
|
|
357
|
+
* @task T10337
|
|
358
|
+
*/
|
|
359
|
+
export declare class EvidenceParseError extends Error {
|
|
360
|
+
/** Hint text suitable for an `fix:` message in the CLI surface. */
|
|
361
|
+
readonly fix: string;
|
|
362
|
+
constructor(message: string, fix: string);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Parse the raw CLI `--evidence` string into structured atoms.
|
|
366
|
+
*
|
|
367
|
+
* Syntax:
|
|
368
|
+
* ```
|
|
369
|
+
* evidence-list := atom (';' atom)*
|
|
370
|
+
* atom := kind ':' payload
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* The payload format depends on `kind`:
|
|
374
|
+
*
|
|
375
|
+
* - `files` — comma-separated paths
|
|
376
|
+
* - `loc-drop` — `<fromLines>:<toLines>` (two integers)
|
|
377
|
+
* - `callsite-coverage` — `<symbolName>:<relativeSourcePath>`
|
|
378
|
+
* - `pr` — positive integer
|
|
379
|
+
* - everything else — opaque payload string until the next `;`
|
|
380
|
+
*
|
|
381
|
+
* A `state:MERGED` modifier may follow a `pr:<num>` atom and is consumed
|
|
382
|
+
* in-place (no separate atom is emitted) — see T9838. Any other usage of
|
|
383
|
+
* `state:` is rejected.
|
|
384
|
+
*
|
|
385
|
+
* Whitespace surrounding the `;` separators and around `kind`/`payload` is
|
|
386
|
+
* trimmed. Empty chunks are skipped (consecutive `;;` is tolerated).
|
|
387
|
+
*
|
|
388
|
+
* @param raw - Raw `--evidence` string.
|
|
389
|
+
* @returns Parsed atoms ready for {@link validateEvidenceForGate} or for
|
|
390
|
+
* the runtime validator in `packages/core/src/tasks/evidence.ts`.
|
|
391
|
+
* @throws {@link EvidenceParseError} when the input is malformed.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* parseEvidenceString('commit:abc1234;files:src/foo.ts,src/bar.ts;tool:lint');
|
|
396
|
+
* // [
|
|
397
|
+
* // { kind: 'commit', sha: 'abc1234' },
|
|
398
|
+
* // { kind: 'files', paths: ['src/foo.ts', 'src/bar.ts'] },
|
|
399
|
+
* // { kind: 'tool', tool: 'lint' },
|
|
400
|
+
* // ]
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @task T10337
|
|
404
|
+
* @adr ADR-051
|
|
405
|
+
*/
|
|
406
|
+
export declare function parseEvidenceString(raw: string): EvidenceAtom[];
|
|
407
|
+
//# sourceMappingURL=evidence-atom-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-atom-schema.d.ts","sourceRoot":"","sources":["../src/evidence-atom-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAMlD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;iBAG1B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;iBAG5B,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc;;;iBAGzB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;;;iBAMxB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;iBAMzB,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY;;;iBAGvB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B;;;;iBAMrC,CAAC;AAMH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAW7B,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,oFAAoF;AACpF,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAMpD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,uBAAuB;IACtC,mEAAmE;IACnE,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAC/C,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAiBjD,CAAC;AAMH;;;;;;;;GAQG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAGpE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GAC/C,wBAAwB,CAe1B;AAED;;;;;;;;;GASG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,mEAAmE;IACnE,SAAgB,GAAG,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAKzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,EAAE,CA8J/D"}
|