@cleocode/contracts 2026.4.69 → 2026.4.72

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 (71) hide show
  1. package/dist/__tests__/acceptance-gate.test.d.ts +14 -0
  2. package/dist/__tests__/acceptance-gate.test.d.ts.map +1 -0
  3. package/dist/__tests__/acceptance-gate.test.js +642 -0
  4. package/dist/__tests__/acceptance-gate.test.js.map +1 -0
  5. package/dist/__tests__/attachment.test.d.ts +17 -0
  6. package/dist/__tests__/attachment.test.d.ts.map +1 -0
  7. package/dist/__tests__/attachment.test.js +505 -0
  8. package/dist/__tests__/attachment.test.js.map +1 -0
  9. package/dist/__tests__/evidence-record.test.d.ts +14 -0
  10. package/dist/__tests__/evidence-record.test.d.ts.map +1 -0
  11. package/dist/__tests__/evidence-record.test.js +362 -0
  12. package/dist/__tests__/evidence-record.test.js.map +1 -0
  13. package/dist/__tests__/invariants.test.d.ts +19 -0
  14. package/dist/__tests__/invariants.test.d.ts.map +1 -0
  15. package/dist/__tests__/invariants.test.js +351 -0
  16. package/dist/__tests__/invariants.test.js.map +1 -0
  17. package/dist/acceptance-gate-schema.d.ts +701 -0
  18. package/dist/acceptance-gate-schema.d.ts.map +1 -0
  19. package/dist/acceptance-gate-schema.js +303 -0
  20. package/dist/acceptance-gate-schema.js.map +1 -0
  21. package/dist/acceptance-gate.d.ts +350 -0
  22. package/dist/acceptance-gate.d.ts.map +1 -0
  23. package/dist/acceptance-gate.js +22 -0
  24. package/dist/acceptance-gate.js.map +1 -0
  25. package/dist/attachment-schema.d.ts +243 -0
  26. package/dist/attachment-schema.d.ts.map +1 -0
  27. package/dist/attachment-schema.js +200 -0
  28. package/dist/attachment-schema.js.map +1 -0
  29. package/dist/attachment.d.ts +224 -0
  30. package/dist/attachment.d.ts.map +1 -0
  31. package/dist/attachment.js +21 -0
  32. package/dist/attachment.js.map +1 -0
  33. package/dist/evidence-record-schema.d.ts +202 -0
  34. package/dist/evidence-record-schema.d.ts.map +1 -0
  35. package/dist/evidence-record-schema.js +130 -0
  36. package/dist/evidence-record-schema.js.map +1 -0
  37. package/dist/evidence-record.d.ts +167 -0
  38. package/dist/evidence-record.d.ts.map +1 -0
  39. package/dist/evidence-record.js +21 -0
  40. package/dist/evidence-record.js.map +1 -0
  41. package/dist/index.d.ts +12 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +6 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/task-evidence.d.ts +251 -0
  46. package/dist/task-evidence.d.ts.map +1 -0
  47. package/dist/task-evidence.js +89 -0
  48. package/dist/task-evidence.js.map +1 -0
  49. package/dist/task.d.ts +23 -4
  50. package/dist/task.d.ts.map +1 -1
  51. package/package.json +8 -2
  52. package/schemas/acceptance-gate.schema.json +9 -0
  53. package/schemas/attachment.schema.json +9 -0
  54. package/schemas/gate-result-details.schema.json +9 -0
  55. package/schemas/gate-result.schema.json +9 -0
  56. package/schemas/manifest-v1.json +176 -0
  57. package/schemas/task-evidence.schema.json +9 -0
  58. package/schemas/task.schema.json +9 -0
  59. package/src/__tests__/acceptance-gate.test.ts +736 -0
  60. package/src/__tests__/attachment.test.ts +601 -0
  61. package/src/__tests__/evidence-record.test.ts +412 -0
  62. package/src/__tests__/invariants.test.ts +445 -0
  63. package/src/acceptance-gate-schema.ts +347 -0
  64. package/src/acceptance-gate.ts +370 -0
  65. package/src/attachment-schema.ts +223 -0
  66. package/src/attachment.ts +245 -0
  67. package/src/evidence-record-schema.ts +158 -0
  68. package/src/evidence-record.ts +182 -0
  69. package/src/index.ts +114 -1
  70. package/src/task-evidence.ts +239 -0
  71. package/src/task.ts +24 -4
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Attachment discriminated union and metadata types.
3
+ *
4
+ * An `Attachment` represents any content artifact that can be associated
5
+ * with a CLEO owner (task, observation, session, decision, learning, pattern).
6
+ * Five attachment kinds are supported:
7
+ * - `local-file` — a file on disk, tracked by path + SHA-256 hash
8
+ * - `url` — a remote URL, optionally cached to the content-addressed store
9
+ * - `blob` — raw bytes stored content-addressed in `.cleo/attachments/sha256/`
10
+ * - `llms-txt` — a generated or fetched llms.txt site-index snapshot (RFC llmstxt.org)
11
+ * - `llmtxt-doc` — a pointer into an llmtxt document (local or remote backend)
12
+ *
13
+ * `AttachmentMetadata` is the row persisted in the attachment registry.
14
+ * `AttachmentRef` is the junction row linking an attachment to an owner.
15
+ *
16
+ * @epic T760
17
+ * @task T795
18
+ * @see {@link https://github.com/kryptobaseddev/cleo} T760 unified attachments
19
+ */
20
+
21
+ // ─── Attachment variants ──────────────────────────────────────────────────────
22
+
23
+ /**
24
+ * A file on disk inside or adjacent to the CLEO project.
25
+ *
26
+ * The `path` is stored as recorded at attach time; the `sha256` is the content
27
+ * hash computed at that moment. On fetch, the runtime re-hashes the file and
28
+ * emits a warning if the file has drifted from the stored hash.
29
+ */
30
+ export interface LocalFileAttachment {
31
+ kind: 'local-file';
32
+ /** Path to the file (absolute or project-root-relative, forward-slashes only). */
33
+ path: string;
34
+ /** SHA-256 hex digest of the file at attach time. */
35
+ sha256: string;
36
+ /** IANA MIME type (e.g., `"text/markdown"`, `"application/pdf"`). */
37
+ mime: string;
38
+ /** File size in bytes at attach time. */
39
+ size: number;
40
+ /** Optional free-text description of what this file contains. */
41
+ description?: string;
42
+ /** Labels for filtering (e.g., `["rfc", "spec"]`). */
43
+ labels?: string[];
44
+ }
45
+
46
+ /**
47
+ * A remote URL, optionally cached to the content-addressed store.
48
+ *
49
+ * When `--cache` is passed on attach, the body is fetched, hashed, and stored
50
+ * at `.cleo/attachments/sha256/<hash[0..2]>/<hash[2..]>.<ext>`. The
51
+ * `cachedSha256` and `cachedAt` fields are populated on a successful cache.
52
+ */
53
+ export interface UrlAttachment {
54
+ kind: 'url';
55
+ /** The remote URL. Must be a valid absolute URL. */
56
+ url: string;
57
+ /** SHA-256 of the fetched body if the URL has been cached locally. */
58
+ cachedSha256?: string;
59
+ /** ISO 8601 timestamp when the body was cached. */
60
+ cachedAt?: string;
61
+ /** IANA MIME type detected from the Content-Type header. */
62
+ mime?: string;
63
+ /** Optional free-text description. */
64
+ description?: string;
65
+ /** Labels for filtering. */
66
+ labels?: string[];
67
+ }
68
+
69
+ /**
70
+ * Raw bytes stored content-addressed in `.cleo/attachments/sha256/`.
71
+ *
72
+ * No external path dependency — the content is always retrievable by
73
+ * `storageKey` as long as the attachment has a positive `refCount`.
74
+ */
75
+ export interface BlobAttachment {
76
+ kind: 'blob';
77
+ /** SHA-256 hex digest of the uncompressed content. */
78
+ sha256: string;
79
+ /** Storage key inside `.cleo/attachments/sha256/` (e.g., `"ab/abcdef…12.pdf"`). */
80
+ storageKey: string;
81
+ /** IANA MIME type. */
82
+ mime: string;
83
+ /** Size of the uncompressed content in bytes. */
84
+ size: number;
85
+ /** Optional free-text description. */
86
+ description?: string;
87
+ /** Labels for filtering. */
88
+ labels?: string[];
89
+ }
90
+
91
+ /**
92
+ * A generated or fetched llms.txt site-index snapshot (per llmstxt.org spec).
93
+ *
94
+ * The content is stored inline — llms.txt files are small by design.
95
+ * `source: 'url'` means it was fetched from a remote site;
96
+ * `source: 'generated'` means it was produced by `cleo docs generate`.
97
+ */
98
+ export interface LlmsTxtAttachment {
99
+ kind: 'llms-txt';
100
+ /** Where the llms.txt content originated. */
101
+ source: 'url' | 'generated';
102
+ /**
103
+ * Full markdown content of the llms.txt (stored inline; small by design per
104
+ * the llmstxt.org spec).
105
+ */
106
+ content: string;
107
+ /** SHA-256 hex digest of `content`. */
108
+ sha256: string;
109
+ /** Optional free-text description. */
110
+ description?: string;
111
+ /** Labels for filtering. */
112
+ labels?: string[];
113
+ }
114
+
115
+ /**
116
+ * A pointer into an llmtxt document managed by a local or remote backend.
117
+ *
118
+ * `backend: 'local'` — the document lives in `.cleo/llmtxt/` (llmtxt LocalBackend).
119
+ * `backend: 'remote'` — the document lives on an llmtxt.my SaaS instance.
120
+ *
121
+ * This attachment kind delegates content storage to the llmtxt package; CLEO
122
+ * only stores the pointer (slug + backend + optional pinned version).
123
+ */
124
+ export interface LlmtxtDocAttachment {
125
+ kind: 'llmtxt-doc';
126
+ /** Document slug from the llmtxt backend (e.g., `"9fZLOnf5"`). */
127
+ slug: string;
128
+ /** Which backend owns the document. */
129
+ backend: 'local' | 'remote';
130
+ /**
131
+ * Version string pinned at attach time.
132
+ *
133
+ * For `local` backends this is the integer version number serialised as a
134
+ * string; for `remote` backends it is the version identifier returned by the
135
+ * API.
136
+ */
137
+ pinnedVersion?: string;
138
+ /** Optional free-text description. */
139
+ description?: string;
140
+ /** Labels for filtering. */
141
+ labels?: string[];
142
+ }
143
+
144
+ // ─── Discriminated union ──────────────────────────────────────────────────────
145
+
146
+ /**
147
+ * A content artifact attachable to any CLEO owner
148
+ * (task, observation, session, decision, learning, or pattern).
149
+ *
150
+ * The `kind` field is the discriminant. All variants share optional
151
+ * `description` and `labels` fields.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * const att: Attachment = {
156
+ * kind: 'local-file',
157
+ * path: 'docs/rfc-003.md',
158
+ * sha256: 'a1b2c3...ff',
159
+ * mime: 'text/markdown',
160
+ * size: 8192,
161
+ * description: 'RFC draft v3',
162
+ * labels: ['rfc', 'spec'],
163
+ * };
164
+ * ```
165
+ */
166
+ export type Attachment =
167
+ | LocalFileAttachment
168
+ | UrlAttachment
169
+ | BlobAttachment
170
+ | LlmsTxtAttachment
171
+ | LlmtxtDocAttachment;
172
+
173
+ /** All valid `kind` discriminants for `Attachment`. */
174
+ export type AttachmentKind = Attachment['kind'];
175
+
176
+ // ─── Registry row ─────────────────────────────────────────────────────────────
177
+
178
+ /**
179
+ * Persisted metadata row for one attachment in the attachment registry
180
+ * (`.cleo/attachments/index.db`).
181
+ *
182
+ * The full {@link Attachment} value is stored as a JSON blob in the `attachment`
183
+ * field so the registry does not need a column per variant.
184
+ */
185
+ export interface AttachmentMetadata {
186
+ /**
187
+ * Unique attachment ID.
188
+ *
189
+ * Pattern: `att_<base62>` — generated by `llmtxt.generateId()` or a UUID
190
+ * fallback.
191
+ */
192
+ id: string;
193
+ /**
194
+ * Content hash.
195
+ *
196
+ * For `local-file`, `blob`, and `llms-txt` variants this is the SHA-256
197
+ * of the bytes at attach time. For `url` it is `cachedSha256` when the URL
198
+ * has been cached, or the empty string when it has not. For `llmtxt-doc` it
199
+ * is the empty string (content is managed by the llmtxt backend).
200
+ */
201
+ sha256: string;
202
+ /** The full attachment value (all kind-specific fields). */
203
+ attachment: Attachment;
204
+ /** ISO 8601 timestamp when this attachment was first registered. */
205
+ createdAt: string;
206
+ /**
207
+ * How many {@link AttachmentRef} rows point at this attachment.
208
+ *
209
+ * When `refCount` drops to zero the blob is eligible for GC via
210
+ * `cleo docs attachments gc`. Blobs are NEVER auto-deleted.
211
+ */
212
+ refCount: number;
213
+ }
214
+
215
+ // ─── Junction row ─────────────────────────────────────────────────────────────
216
+
217
+ /**
218
+ * Junction row linking one attachment to one owner.
219
+ *
220
+ * Stored in the `attachment_refs` table of `.cleo/attachments/index.db`.
221
+ * A single attachment can be referenced by multiple owners simultaneously
222
+ * (e.g., the same RFC PDF attached to an epic and to every child task).
223
+ */
224
+ export interface AttachmentRef {
225
+ /** ID of the attachment (→ `attachments.id`). */
226
+ attachmentId: string;
227
+ /**
228
+ * The domain entity type that owns this attachment.
229
+ *
230
+ * Determines which CLEO store to query when resolving the owner's display
231
+ * name (`tasks.db` for task/session/decision/learning/pattern;
232
+ * `brain.db` for observation).
233
+ */
234
+ ownerType: 'task' | 'observation' | 'session' | 'decision' | 'learning' | 'pattern';
235
+ /** The ID of the owning entity (e.g., `"T766"`, `"O-abc123"`, `"ses_..."`). */
236
+ ownerId: string;
237
+ /** ISO 8601 timestamp when the ref was created. */
238
+ attachedAt: string;
239
+ /**
240
+ * Agent identity (or `"human"`) that created the ref.
241
+ *
242
+ * Populated from the active session's agent credential when available.
243
+ */
244
+ attachedBy?: string;
245
+ }
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Zod validation schemas for {@link EvidenceRecord} and its variants.
3
+ *
4
+ * Kept in a separate file from the plain TypeScript types so that consumers
5
+ * that do not need runtime validation (e.g. type-only imports) pay zero cost.
6
+ *
7
+ * All schemas are named `*RecordSchema` and derive their inferred types from
8
+ * the canonical TypeScript interfaces in `./evidence-record.ts`.
9
+ *
10
+ * The top-level {@link evidenceRecordSchema} is a `z.discriminatedUnion` on
11
+ * `"kind"` so Zod can route to the correct variant in O(1).
12
+ *
13
+ * @epic T810
14
+ * @task T816
15
+ */
16
+
17
+ import { z } from 'zod';
18
+
19
+ // ─── Shared base fields ───────────────────────────────────────────────────────
20
+
21
+ /**
22
+ * Zod schema for the provenance fields shared by every EvidenceRecord variant.
23
+ *
24
+ * Not exported as a standalone validator; always composed into a full record
25
+ * schema via `.extend()`.
26
+ */
27
+ const evidenceBaseSchema = z.object({
28
+ /** Identity string of the agent that produced this record. */
29
+ agentIdentity: z.string().min(1),
30
+ /** SHA-256 hex digest (64 chars) of the attached artifact. */
31
+ attachmentSha256: z.string().length(64),
32
+ /** ISO 8601 timestamp at which the action ran. */
33
+ ranAt: z.string().datetime(),
34
+ /** Wall-clock duration of the action in milliseconds. */
35
+ durationMs: z.number().nonnegative(),
36
+ });
37
+
38
+ // ─── Individual variant schemas ───────────────────────────────────────────────
39
+
40
+ /**
41
+ * Zod schema for {@link ImplDiffRecord}.
42
+ *
43
+ * Validates that `filesChanged` is a non-empty array and that `linesAdded` /
44
+ * `linesRemoved` are non-negative integers.
45
+ */
46
+ export const implDiffRecordSchema = evidenceBaseSchema.extend({
47
+ kind: z.literal('impl-diff'),
48
+ phase: z.literal('implement'),
49
+ filesChanged: z.array(z.string().min(1)).min(1),
50
+ linesAdded: z.number().int().nonnegative(),
51
+ linesRemoved: z.number().int().nonnegative(),
52
+ });
53
+
54
+ /** Inferred TypeScript type from {@link implDiffRecordSchema}. */
55
+ export type ImplDiffRecordInput = z.input<typeof implDiffRecordSchema>;
56
+
57
+ /**
58
+ * Zod schema for {@link ValidateSpecCheckRecord}.
59
+ *
60
+ * Validates that `reqIdsChecked` is non-empty and `details` is non-blank.
61
+ */
62
+ export const validateSpecCheckRecordSchema = evidenceBaseSchema.extend({
63
+ kind: z.literal('validate-spec-check'),
64
+ phase: z.literal('validate'),
65
+ reqIdsChecked: z.array(z.string().min(1)).min(1),
66
+ passed: z.boolean(),
67
+ details: z.string().min(1),
68
+ });
69
+
70
+ /** Inferred TypeScript type from {@link validateSpecCheckRecordSchema}. */
71
+ export type ValidateSpecCheckRecordInput = z.input<typeof validateSpecCheckRecordSchema>;
72
+
73
+ /**
74
+ * Zod schema for {@link TestOutputRecord}.
75
+ *
76
+ * Validates that `command` is non-blank and test counts are non-negative.
77
+ */
78
+ export const testOutputRecordSchema = evidenceBaseSchema.extend({
79
+ kind: z.literal('test-output'),
80
+ phase: z.literal('test'),
81
+ command: z.string().min(1),
82
+ exitCode: z.number().int(),
83
+ testsPassed: z.number().int().nonnegative(),
84
+ testsFailed: z.number().int().nonnegative(),
85
+ });
86
+
87
+ /** Inferred TypeScript type from {@link testOutputRecordSchema}. */
88
+ export type TestOutputRecordInput = z.input<typeof testOutputRecordSchema>;
89
+
90
+ /**
91
+ * Zod schema for {@link LintReportRecord}.
92
+ *
93
+ * `phase` is restricted to `'implement' | 'test'`.
94
+ * `warnings` and `errors` are non-negative integers.
95
+ */
96
+ export const lintReportRecordSchema = evidenceBaseSchema.extend({
97
+ kind: z.literal('lint-report'),
98
+ phase: z.enum(['implement', 'test']),
99
+ tool: z.string().min(1),
100
+ passed: z.boolean(),
101
+ warnings: z.number().int().nonnegative(),
102
+ errors: z.number().int().nonnegative(),
103
+ });
104
+
105
+ /** Inferred TypeScript type from {@link lintReportRecordSchema}. */
106
+ export type LintReportRecordInput = z.input<typeof lintReportRecordSchema>;
107
+
108
+ /**
109
+ * Zod schema for {@link CommandOutputRecord}.
110
+ *
111
+ * `phase` can be `'implement'`, `'validate'`, or `'test'`.
112
+ * `cmd` must be non-blank.
113
+ */
114
+ export const commandOutputRecordSchema = evidenceBaseSchema.extend({
115
+ kind: z.literal('command-output'),
116
+ phase: z.enum(['implement', 'validate', 'test']),
117
+ cmd: z.string().min(1),
118
+ exitCode: z.number().int(),
119
+ });
120
+
121
+ /** Inferred TypeScript type from {@link commandOutputRecordSchema}. */
122
+ export type CommandOutputRecordInput = z.input<typeof commandOutputRecordSchema>;
123
+
124
+ // ─── Discriminated union ──────────────────────────────────────────────────────
125
+
126
+ /**
127
+ * Zod discriminated-union schema for {@link EvidenceRecord}.
128
+ *
129
+ * Uses `z.discriminatedUnion('kind', [...])` for O(1) variant lookup.
130
+ * Parse with `evidenceRecordSchema.parse(input)` or
131
+ * `evidenceRecordSchema.safeParse(input)`.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const rec = evidenceRecordSchema.parse({
136
+ * kind: 'test-output',
137
+ * phase: 'test',
138
+ * agentIdentity: 'T816-worker',
139
+ * attachmentSha256: 'a'.repeat(64),
140
+ * command: 'pnpm test',
141
+ * exitCode: 0,
142
+ * testsPassed: 10,
143
+ * testsFailed: 0,
144
+ * ranAt: '2026-04-16T00:00:00.000Z',
145
+ * durationMs: 1234,
146
+ * });
147
+ * ```
148
+ */
149
+ export const evidenceRecordSchema = z.discriminatedUnion('kind', [
150
+ implDiffRecordSchema,
151
+ validateSpecCheckRecordSchema,
152
+ testOutputRecordSchema,
153
+ lintReportRecordSchema,
154
+ commandOutputRecordSchema,
155
+ ]);
156
+
157
+ /** Inferred TypeScript type from {@link evidenceRecordSchema}. */
158
+ export type EvidenceRecordInput = z.input<typeof evidenceRecordSchema>;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * EvidenceRecord discriminated union — typed proof artifacts produced by IVTR agents.
3
+ *
4
+ * Each variant represents a specific kind of evidence that an IVTR-phase agent
5
+ * (implement, validate, test) can emit. All variants share a common set of
6
+ * provenance fields (`agentIdentity`, `attachmentSha256`, `ranAt`, `durationMs`)
7
+ * so that evidence rows can be queried, correlated, and archived uniformly.
8
+ *
9
+ * Five kinds are defined:
10
+ * - `impl-diff` — a code change produced by an implement-phase agent
11
+ * - `validate-spec-check` — a spec-requirements check by a validate-phase agent
12
+ * - `test-output` — the output of a test command run by a test-phase agent
13
+ * - `lint-report` — a static-analysis run (biome, tsc, etc.)
14
+ * - `command-output` — a generic CLI command invocation with exit code
15
+ *
16
+ * @epic T810
17
+ * @task T816
18
+ * @see {@link EvidenceRecordKind} for all discriminant values
19
+ */
20
+
21
+ // ─── Variants ────────────────────────────────────────────────────────────────
22
+
23
+ /**
24
+ * Evidence that an implement-phase agent produced a code diff.
25
+ *
26
+ * `filesChanged` lists the relative paths of every modified file.
27
+ * `attachmentSha256` is the SHA-256 hex digest of the serialised diff attachment.
28
+ */
29
+ export interface ImplDiffRecord {
30
+ kind: 'impl-diff';
31
+ /** RCASD lifecycle phase that produced this record. */
32
+ phase: 'implement';
33
+ /** Identity string of the agent that ran this action (e.g. `"T816-worker"`). */
34
+ agentIdentity: string;
35
+ /** SHA-256 hex digest (64 chars) of the attached diff blob. */
36
+ attachmentSha256: string;
37
+ /** Relative paths of every file the diff touches. */
38
+ filesChanged: string[];
39
+ /** Net lines added across all changed files. */
40
+ linesAdded: number;
41
+ /** Net lines removed across all changed files. */
42
+ linesRemoved: number;
43
+ /** ISO 8601 timestamp at which the diff was captured. */
44
+ ranAt: string;
45
+ /** Wall-clock duration of the implement action in milliseconds. */
46
+ durationMs: number;
47
+ }
48
+
49
+ /**
50
+ * Evidence that a validate-phase agent checked one or more REQ-IDs against
51
+ * the implementation and recorded a pass/fail verdict.
52
+ */
53
+ export interface ValidateSpecCheckRecord {
54
+ kind: 'validate-spec-check';
55
+ /** RCASD lifecycle phase that produced this record. */
56
+ phase: 'validate';
57
+ /** Identity string of the agent that ran this action. */
58
+ agentIdentity: string;
59
+ /** SHA-256 hex digest (64 chars) of the spec-check report attachment. */
60
+ attachmentSha256: string;
61
+ /** REQ-IDs checked in this run (e.g. `["IVTR-01", "IVTR-02"]`). */
62
+ reqIdsChecked: string[];
63
+ /** `true` when all checked REQ-IDs passed; `false` if any failed. */
64
+ passed: boolean;
65
+ /** Human-readable summary of results per REQ-ID. */
66
+ details: string;
67
+ /** ISO 8601 timestamp at which the check ran. */
68
+ ranAt: string;
69
+ /** Wall-clock duration of the validation check in milliseconds. */
70
+ durationMs: number;
71
+ }
72
+
73
+ /**
74
+ * Evidence that a test-phase agent ran a test command and recorded counts.
75
+ */
76
+ export interface TestOutputRecord {
77
+ kind: 'test-output';
78
+ /** RCASD lifecycle phase that produced this record. */
79
+ phase: 'test';
80
+ /** Identity string of the agent that ran this action. */
81
+ agentIdentity: string;
82
+ /** SHA-256 hex digest (64 chars) of the test-output attachment. */
83
+ attachmentSha256: string;
84
+ /** The full test command that was executed (e.g. `"pnpm --filter @cleocode/contracts run test"`). */
85
+ command: string;
86
+ /** Exit code returned by the test command. */
87
+ exitCode: number;
88
+ /** Number of individual test cases that passed. */
89
+ testsPassed: number;
90
+ /** Number of individual test cases that failed. */
91
+ testsFailed: number;
92
+ /** ISO 8601 timestamp at which the test command started. */
93
+ ranAt: string;
94
+ /** Wall-clock duration of the full test run in milliseconds. */
95
+ durationMs: number;
96
+ }
97
+
98
+ /**
99
+ * Evidence that a lint / static-analysis tool was run.
100
+ *
101
+ * The `phase` field is `'implement' | 'test'` because lint is commonly run
102
+ * after a code change (implement) or as part of a test suite (test).
103
+ */
104
+ export interface LintReportRecord {
105
+ kind: 'lint-report';
106
+ /** RCASD lifecycle phase that produced this record. */
107
+ phase: 'implement' | 'test';
108
+ /** Identity string of the agent that ran this action. */
109
+ agentIdentity: string;
110
+ /** SHA-256 hex digest (64 chars) of the lint-output attachment. */
111
+ attachmentSha256: string;
112
+ /** Name of the lint tool that was invoked (e.g. `"biome"`, `"tsc"`). */
113
+ tool: string;
114
+ /** `true` when the lint run produced zero errors. */
115
+ passed: boolean;
116
+ /** Number of warnings emitted (may be > 0 even when `passed` is `true`). */
117
+ warnings: number;
118
+ /** Number of errors emitted. Non-zero means `passed` is `false`. */
119
+ errors: number;
120
+ /** ISO 8601 timestamp at which the lint tool was invoked. */
121
+ ranAt: string;
122
+ /** Wall-clock duration of the lint run in milliseconds. */
123
+ durationMs: number;
124
+ }
125
+
126
+ /**
127
+ * Evidence that an agent ran an arbitrary CLI command and recorded its exit code.
128
+ *
129
+ * Use this as the catch-all when none of the other variants fit.
130
+ */
131
+ export interface CommandOutputRecord {
132
+ kind: 'command-output';
133
+ /** RCASD lifecycle phase that produced this record. */
134
+ phase: 'implement' | 'validate' | 'test';
135
+ /** Identity string of the agent that ran this action. */
136
+ agentIdentity: string;
137
+ /** SHA-256 hex digest (64 chars) of the command-output attachment. */
138
+ attachmentSha256: string;
139
+ /** The CLI command that was executed. */
140
+ cmd: string;
141
+ /** Exit code returned by the command. */
142
+ exitCode: number;
143
+ /** ISO 8601 timestamp at which the command was invoked. */
144
+ ranAt: string;
145
+ /** Wall-clock duration of the command in milliseconds. */
146
+ durationMs: number;
147
+ }
148
+
149
+ // ─── Discriminated union ──────────────────────────────────────────────────────
150
+
151
+ /**
152
+ * A typed evidence record produced by an IVTR-phase agent.
153
+ *
154
+ * The `kind` discriminant selects the variant. All variants carry
155
+ * `agentIdentity`, `attachmentSha256`, `ranAt`, and `durationMs` for
156
+ * uniform provenance tracking.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * const rec: EvidenceRecord = {
161
+ * kind: 'test-output',
162
+ * phase: 'test',
163
+ * agentIdentity: 'T816-worker',
164
+ * attachmentSha256: 'a'.repeat(64),
165
+ * command: 'pnpm --filter @cleocode/contracts run test',
166
+ * exitCode: 0,
167
+ * testsPassed: 10,
168
+ * testsFailed: 0,
169
+ * ranAt: '2026-04-16T00:00:00.000Z',
170
+ * durationMs: 1234,
171
+ * };
172
+ * ```
173
+ */
174
+ export type EvidenceRecord =
175
+ | ImplDiffRecord
176
+ | ValidateSpecCheckRecord
177
+ | TestOutputRecord
178
+ | LintReportRecord
179
+ | CommandOutputRecord;
180
+
181
+ /** All valid `kind` discriminants for {@link EvidenceRecord}. */
182
+ export type EvidenceRecordKind = EvidenceRecord['kind'];