@cleocode/contracts 2026.5.90 → 2026.5.93
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__/docs-taxonomy.test.d.ts +16 -0
- package/dist/__tests__/docs-taxonomy.test.d.ts.map +1 -0
- package/dist/__tests__/docs-taxonomy.test.js +404 -0
- package/dist/__tests__/docs-taxonomy.test.js.map +1 -0
- package/dist/docs-taxonomy.d.ts +286 -0
- package/dist/docs-taxonomy.d.ts.map +1 -0
- package/dist/docs-taxonomy.js +489 -0
- package/dist/docs-taxonomy.js.map +1 -0
- package/dist/doctor.d.ts +120 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +16 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +42 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +14 -0
- package/dist/logger.js.map +1 -0
- package/dist/memory.d.ts +145 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +22 -2
- package/dist/memory.js.map +1 -1
- package/dist/operations/docs.d.ts +89 -11
- package/dist/operations/docs.d.ts.map +1 -1
- package/dist/operations/docs.js +19 -12
- package/dist/operations/docs.js.map +1 -1
- package/dist/operations/session.d.ts +66 -0
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/validate.d.ts +32 -0
- package/dist/operations/validate.d.ts.map +1 -1
- package/dist/release/evidence-atoms.d.ts +103 -0
- package/dist/release/evidence-atoms.d.ts.map +1 -0
- package/dist/release/evidence-atoms.js +89 -0
- package/dist/release/evidence-atoms.js.map +1 -0
- package/dist/task.d.ts +43 -0
- package/dist/task.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/docs-taxonomy.test.ts +465 -0
- package/src/docs-taxonomy.ts +682 -0
- package/src/doctor.ts +130 -0
- package/src/index.ts +37 -0
- package/src/logger.ts +42 -0
- package/src/memory.ts +154 -2
- package/src/operations/docs.ts +92 -18
- package/src/operations/session.ts +71 -0
- package/src/operations/validate.ts +34 -0
- package/src/release/evidence-atoms.ts +118 -0
- package/src/task.ts +44 -0
|
@@ -277,6 +277,39 @@ export interface ValidateCanonResult {
|
|
|
277
277
|
assertions: Array<{ passed: boolean }>;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Params for `check.canon.docs` — the T9796 docs-routing CI gate.
|
|
282
|
+
*
|
|
283
|
+
* `baseRef` defaults to `origin/main` and is overridden in CI to
|
|
284
|
+
* `origin/${{ github.base_ref }}` so PRs targeting any branch work.
|
|
285
|
+
* `candidateFiles` is a test seam — when supplied, bypasses `git diff`
|
|
286
|
+
* and treats the list as the candidate set.
|
|
287
|
+
*
|
|
288
|
+
* @task T9796 — E-DOCS-CANON-LOCKDOWN
|
|
289
|
+
*/
|
|
290
|
+
export interface ValidateCanonDocsParams {
|
|
291
|
+
baseRef?: string;
|
|
292
|
+
candidateFiles?: ReadonlyArray<string>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Result envelope returned by `check.canon.docs`.
|
|
297
|
+
*
|
|
298
|
+
* @task T9796
|
|
299
|
+
*/
|
|
300
|
+
export interface ValidateCanonDocsResult {
|
|
301
|
+
passed: boolean;
|
|
302
|
+
baseRef: string;
|
|
303
|
+
scanned: number;
|
|
304
|
+
violations: ReadonlyArray<{
|
|
305
|
+
file: string;
|
|
306
|
+
kind: string;
|
|
307
|
+
matchedPath: string;
|
|
308
|
+
fix: string;
|
|
309
|
+
}>;
|
|
310
|
+
mode: 'enforced' | 'no-canon';
|
|
311
|
+
}
|
|
312
|
+
|
|
280
313
|
export interface ValidateWorkflowComplianceParams {
|
|
281
314
|
since?: string;
|
|
282
315
|
}
|
|
@@ -350,6 +383,7 @@ export type CheckOps = {
|
|
|
350
383
|
readonly grade: readonly [ValidateGradeParams, ValidateGradeResult];
|
|
351
384
|
readonly 'grade.list': readonly [ValidateGradeListParams, ValidateGradeListResult];
|
|
352
385
|
readonly canon: readonly [ValidateCanonParams, ValidateCanonResult];
|
|
386
|
+
readonly 'canon.docs': readonly [ValidateCanonDocsParams, ValidateCanonDocsResult];
|
|
353
387
|
readonly 'workflow.compliance': readonly [
|
|
354
388
|
ValidateWorkflowComplianceParams,
|
|
355
389
|
ValidateWorkflowComplianceResult,
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas + helper types for the `pr:<number>` evidence atom.
|
|
3
|
+
*
|
|
4
|
+
* Closes the release-verb dogfood gap (T9764): tasks that ship via the
|
|
5
|
+
* standard PR + admin-merge flow lacked a zero-friction way to record
|
|
6
|
+
* `testsPassed` / `qaPassed` evidence retroactively. The release-verb
|
|
7
|
+
* pipeline (`cleo release plan --epic <id>`) requires evidence atoms for
|
|
8
|
+
* every child task before a plan can be built. `tool:test` is overkill
|
|
9
|
+
* for one-line tasks (it re-runs the entire monorepo suite), and `note:`
|
|
10
|
+
* is rejected for hard gates on critical verifications.
|
|
11
|
+
*
|
|
12
|
+
* A `pr:<number>` atom proves the work shipped by interrogating GitHub
|
|
13
|
+
* directly: it resolves via `gh pr view <num> --json
|
|
14
|
+
* statusCheckRollup,mergeable,state,mergedAt,headRefOid` and accepts the
|
|
15
|
+
* atom IFF the PR was merged with all required-workflow checks green.
|
|
16
|
+
*
|
|
17
|
+
* @task T9764
|
|
18
|
+
* @epic T9762
|
|
19
|
+
* @saga T9758
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parsed `pr:<number>` atom before GitHub validation.
|
|
26
|
+
*
|
|
27
|
+
* Emitted by the evidence parser when the user supplies `--evidence
|
|
28
|
+
* "pr:357"`. The number is restricted to positive integers because
|
|
29
|
+
* GitHub PR numbers cannot be zero or negative.
|
|
30
|
+
*
|
|
31
|
+
* @task T9764
|
|
32
|
+
*/
|
|
33
|
+
export interface ParsedPrEvidenceAtom {
|
|
34
|
+
/** Discriminant — always `'pr'`. */
|
|
35
|
+
readonly kind: 'pr';
|
|
36
|
+
/** PR number (positive integer). */
|
|
37
|
+
readonly prNumber: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Zod schema for {@link ParsedPrEvidenceAtom}.
|
|
42
|
+
*
|
|
43
|
+
* Used by the verify pipeline (`packages/core/src/tasks/evidence.ts`) to
|
|
44
|
+
* validate the parser output before invoking `gh`. Exported so downstream
|
|
45
|
+
* packages can compose it (e.g. a future provenance-graph schema).
|
|
46
|
+
*
|
|
47
|
+
* @task T9764
|
|
48
|
+
*/
|
|
49
|
+
export const parsedPrEvidenceAtomSchema = z.object({
|
|
50
|
+
kind: z.literal('pr'),
|
|
51
|
+
prNumber: z.number().int().positive(),
|
|
52
|
+
}) satisfies z.ZodType<ParsedPrEvidenceAtom>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Raw shape returned by `gh pr view <num> --json
|
|
56
|
+
* statusCheckRollup,mergeable,state,mergedAt,headRefOid`.
|
|
57
|
+
*
|
|
58
|
+
* Kept permissive (`.passthrough()`) because GitHub adds fields without
|
|
59
|
+
* breaking us — we only consume what we need.
|
|
60
|
+
*
|
|
61
|
+
* @task T9764
|
|
62
|
+
*/
|
|
63
|
+
export const ghPrViewSchema = z
|
|
64
|
+
.object({
|
|
65
|
+
state: z.enum(['OPEN', 'CLOSED', 'MERGED']),
|
|
66
|
+
mergedAt: z.string().nullable(),
|
|
67
|
+
headRefOid: z.string().optional(),
|
|
68
|
+
mergeable: z.string().optional(),
|
|
69
|
+
statusCheckRollup: z
|
|
70
|
+
.array(
|
|
71
|
+
z
|
|
72
|
+
.object({
|
|
73
|
+
__typename: z.string().optional(),
|
|
74
|
+
name: z.string().optional(),
|
|
75
|
+
workflowName: z.string().optional(),
|
|
76
|
+
conclusion: z.string().nullable().optional(),
|
|
77
|
+
status: z.string().optional(),
|
|
78
|
+
})
|
|
79
|
+
.passthrough(),
|
|
80
|
+
)
|
|
81
|
+
.optional()
|
|
82
|
+
.default([]),
|
|
83
|
+
})
|
|
84
|
+
.passthrough();
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Inferred TypeScript type for the `gh pr view` JSON payload.
|
|
88
|
+
*
|
|
89
|
+
* @task T9764
|
|
90
|
+
*/
|
|
91
|
+
export type GhPrViewPayload = z.infer<typeof ghPrViewSchema>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Default required-workflow names enforced by `pr:<number>` validation.
|
|
95
|
+
*
|
|
96
|
+
* Mirrors the canonical branch-protection list documented in
|
|
97
|
+
* `docs/release/branch-protection-setup.md`. Override via
|
|
98
|
+
* {@link PR_REQUIRED_WORKFLOWS_ENV_VAR} when projects deviate (e.g. an
|
|
99
|
+
* out-of-tree consumer with different gating workflows).
|
|
100
|
+
*
|
|
101
|
+
* @task T9764
|
|
102
|
+
*/
|
|
103
|
+
export const PR_REQUIRED_WORKFLOWS: readonly string[] = Object.freeze([
|
|
104
|
+
'CI',
|
|
105
|
+
'Lockfile Check',
|
|
106
|
+
'Contracts Dep Lint',
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Name of the env var that overrides {@link PR_REQUIRED_WORKFLOWS}.
|
|
111
|
+
*
|
|
112
|
+
* Format: comma-separated workflow names (e.g.
|
|
113
|
+
* `"CI,Lockfile Check,MyExtraGate"`). Whitespace around commas is
|
|
114
|
+
* trimmed.
|
|
115
|
+
*
|
|
116
|
+
* @task T9764
|
|
117
|
+
*/
|
|
118
|
+
export const PR_REQUIRED_WORKFLOWS_ENV_VAR = 'CLEO_PR_REQUIRED_WORKFLOWS' as const;
|
package/src/task.ts
CHANGED
|
@@ -251,6 +251,50 @@ export type EvidenceAtom =
|
|
|
251
251
|
* (e.g. `"D-arch-001"`, `"AGT-abc123"`).
|
|
252
252
|
*/
|
|
253
253
|
decisionId: string;
|
|
254
|
+
}
|
|
255
|
+
| {
|
|
256
|
+
/**
|
|
257
|
+
* Pull-request atom — proves that a referenced GitHub PR shipped to
|
|
258
|
+
* the project's primary branch with CI green.
|
|
259
|
+
*
|
|
260
|
+
* Closes the release-verb dogfood gap (T9764): tasks that ship via the
|
|
261
|
+
* standard PR + admin-merge flow lacked a zero-friction way to record
|
|
262
|
+
* `testsPassed` / `qaPassed` evidence after the fact. Re-running
|
|
263
|
+
* `tool:test` against the entire monorepo is overkill for one-line
|
|
264
|
+
* tasks, and `note:` is rejected for hard gates on critical
|
|
265
|
+
* verifications.
|
|
266
|
+
*
|
|
267
|
+
* A `pr:<number>` atom satisfies BOTH `testsPassed` and `qaPassed`
|
|
268
|
+
* simultaneously when:
|
|
269
|
+
* 1. `state === 'MERGED'` (PR was actually shipped to main)
|
|
270
|
+
* 2. `mergedAt` is non-null (defends against API races)
|
|
271
|
+
* 3. The status-check rollup contains ≥1 SUCCESS check and zero
|
|
272
|
+
* FAILURE checks in the required workflows
|
|
273
|
+
* (`CI`, `Lockfile Check`, `Contracts Dep Lint`)
|
|
274
|
+
*
|
|
275
|
+
* Format: `pr:<positive integer>` (e.g. `pr:357`)
|
|
276
|
+
*
|
|
277
|
+
* Validation: CLEO calls `gh pr view <num> --json
|
|
278
|
+
* statusCheckRollup,mergeable,state,mergedAt,headRefOid` and parses
|
|
279
|
+
* the rollup. Results are cached under
|
|
280
|
+
* `.cleo/cache/evidence/pr-<num>.json` keyed on `(prNumber, mergedAt)`
|
|
281
|
+
* so re-verifies skip the network round trip.
|
|
282
|
+
*
|
|
283
|
+
* @task T9764
|
|
284
|
+
* @epic T9762
|
|
285
|
+
* @saga T9758
|
|
286
|
+
*/
|
|
287
|
+
kind: 'pr';
|
|
288
|
+
/** PR number (positive integer). */
|
|
289
|
+
prNumber: number;
|
|
290
|
+
/** Merge commit SHA (full 40-char hex) — captured at validate time. */
|
|
291
|
+
mergeCommitSha: string;
|
|
292
|
+
/** ISO 8601 timestamp when the PR was merged. */
|
|
293
|
+
mergedAt: string;
|
|
294
|
+
/** Number of `SUCCESS` checks across all required workflows. */
|
|
295
|
+
successCount: number;
|
|
296
|
+
/** Total number of checks evaluated in the rollup. */
|
|
297
|
+
totalChecks: number;
|
|
254
298
|
};
|
|
255
299
|
|
|
256
300
|
/**
|