@cleocode/contracts 2026.5.95 → 2026.5.97
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__/enums.test.d.ts +14 -0
- package/dist/__tests__/enums.test.d.ts.map +1 -0
- package/dist/__tests__/enums.test.js +75 -0
- package/dist/__tests__/enums.test.js.map +1 -0
- package/dist/__tests__/jobs.test.d.ts +11 -0
- package/dist/__tests__/jobs.test.d.ts.map +1 -0
- package/dist/__tests__/jobs.test.js +48 -0
- package/dist/__tests__/jobs.test.js.map +1 -0
- package/dist/__tests__/memory-wire-shapes.test.d.ts +19 -0
- package/dist/__tests__/memory-wire-shapes.test.d.ts.map +1 -0
- package/dist/__tests__/memory-wire-shapes.test.js +119 -0
- package/dist/__tests__/memory-wire-shapes.test.js.map +1 -0
- package/dist/__tests__/operation-def.test.d.ts +20 -0
- package/dist/__tests__/operation-def.test.d.ts.map +1 -0
- package/dist/__tests__/operation-def.test.js +111 -0
- package/dist/__tests__/operation-def.test.js.map +1 -0
- package/dist/__tests__/provenance.test.d.ts +18 -0
- package/dist/__tests__/provenance.test.d.ts.map +1 -0
- package/dist/__tests__/provenance.test.js +142 -0
- package/dist/__tests__/provenance.test.js.map +1 -0
- package/dist/__tests__/scaffold-diagnostics.test.d.ts +19 -0
- package/dist/__tests__/scaffold-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/scaffold-diagnostics.test.js +70 -0
- package/dist/__tests__/scaffold-diagnostics.test.js.map +1 -0
- package/dist/dispatch/identity.d.ts +72 -0
- package/dist/dispatch/identity.d.ts.map +1 -0
- package/dist/dispatch/identity.js +72 -0
- package/dist/dispatch/identity.js.map +1 -0
- package/dist/dispatch/operation-def.d.ts +92 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -0
- package/dist/dispatch/operation-def.js +31 -0
- package/dist/dispatch/operation-def.js.map +1 -0
- package/dist/doctor.d.ts +52 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +7 -0
- package/dist/doctor.js.map +1 -1
- package/dist/enums.d.ts +123 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +139 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +39 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +19 -0
- package/dist/jobs.js.map +1 -0
- package/dist/memory/budgeted.d.ts +67 -0
- package/dist/memory/budgeted.d.ts.map +1 -0
- package/dist/memory/budgeted.js +17 -0
- package/dist/memory/budgeted.js.map +1 -0
- package/dist/memory/fetch.d.ts +58 -0
- package/dist/memory/fetch.d.ts.map +1 -0
- package/dist/memory/fetch.js +19 -0
- package/dist/memory/fetch.js.map +1 -0
- package/dist/memory/observe.d.ts +158 -0
- package/dist/memory/observe.d.ts.map +1 -0
- package/dist/memory/observe.js +46 -0
- package/dist/memory/observe.js.map +1 -0
- package/dist/memory/search.d.ts +137 -0
- package/dist/memory/search.d.ts.map +1 -0
- package/dist/memory/search.js +22 -0
- package/dist/memory/search.js.map +1 -0
- package/dist/memory/timeline.d.ts +89 -0
- package/dist/memory/timeline.d.ts.map +1 -0
- package/dist/memory/timeline.js +22 -0
- package/dist/memory/timeline.js.map +1 -0
- package/dist/operations/focus.d.ts +199 -0
- package/dist/operations/focus.d.ts.map +1 -0
- package/dist/operations/focus.js +15 -0
- package/dist/operations/focus.js.map +1 -0
- package/dist/operations/index.d.ts +1 -0
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +1 -0
- package/dist/operations/index.js.map +1 -1
- package/dist/operations/session.d.ts +54 -0
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/tasks.d.ts +38 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/operations/worktree.d.ts +138 -1
- package/dist/operations/worktree.d.ts.map +1 -1
- package/dist/provenance.d.ts +257 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +42 -0
- package/dist/provenance.js.map +1 -0
- package/dist/release/plan.d.ts +7 -7
- package/dist/scaffold-diagnostics.d.ts +110 -0
- package/dist/scaffold-diagnostics.d.ts.map +1 -0
- package/dist/scaffold-diagnostics.js +28 -0
- package/dist/scaffold-diagnostics.js.map +1 -0
- package/dist/session.d.ts +37 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/dist/tasks/archive.d.ts +3 -3
- package/package.json +42 -2
- package/src/__tests__/enums.test.ts +114 -0
- package/src/__tests__/jobs.test.ts +76 -0
- package/src/__tests__/memory-wire-shapes.test.ts +371 -0
- package/src/__tests__/operation-def.test.ts +185 -0
- package/src/__tests__/provenance.test.ts +259 -0
- package/src/__tests__/scaffold-diagnostics.test.ts +137 -0
- package/src/dispatch/identity.ts +109 -0
- package/src/dispatch/operation-def.ts +102 -0
- package/src/doctor.ts +62 -0
- package/src/enums.ts +144 -0
- package/src/index.ts +89 -2
- package/src/jobs.ts +45 -0
- package/src/memory/budgeted.ts +75 -0
- package/src/memory/fetch.ts +66 -0
- package/src/memory/observe.ts +176 -0
- package/src/memory/search.ts +145 -0
- package/src/memory/timeline.ts +100 -0
- package/src/operations/focus.ts +226 -0
- package/src/operations/index.ts +1 -0
- package/src/operations/session.ts +56 -0
- package/src/operations/tasks.ts +40 -0
- package/src/operations/worktree.ts +149 -1
- package/src/provenance.ts +335 -0
- package/src/scaffold-diagnostics.ts +119 -0
- package/src/session.ts +37 -0
|
@@ -159,6 +159,25 @@ export interface CreateWorktreeOptions {
|
|
|
159
159
|
* @task T1927
|
|
160
160
|
*/
|
|
161
161
|
forceReset?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Sparse-checkout scope pattern (T9807). When set, `createWorktree` runs
|
|
164
|
+
* `git sparse-checkout init --cone` followed by
|
|
165
|
+
* `git sparse-checkout set <spawnScope>` after `git worktree add` completes,
|
|
166
|
+
* limiting the worktree's checked-out tree to paths matching `<spawnScope>`.
|
|
167
|
+
*
|
|
168
|
+
* Exposed on `cleo orchestrate spawn` as the `--scope` flag so callers can
|
|
169
|
+
* request a lean worktree containing only the paths relevant to a task
|
|
170
|
+
* (e.g. `packages/cleo` to contain a CLI-only fix).
|
|
171
|
+
*
|
|
172
|
+
* Cone mode (`--cone`) is used for maximum checkout performance — the scope
|
|
173
|
+
* string must be a directory prefix, not an arbitrary glob.
|
|
174
|
+
*
|
|
175
|
+
* Failures are silently swallowed (best-effort) — the worktree is returned
|
|
176
|
+
* in full-checkout mode when sparse-checkout setup fails.
|
|
177
|
+
*
|
|
178
|
+
* @task T9807
|
|
179
|
+
*/
|
|
180
|
+
spawnScope?: string;
|
|
162
181
|
}
|
|
163
182
|
|
|
164
183
|
/**
|
|
@@ -247,6 +266,14 @@ export interface DestroyWorktreeOptions {
|
|
|
247
266
|
force?: boolean;
|
|
248
267
|
/** Declarative hooks to run during destruction lifecycle. */
|
|
249
268
|
hooks?: WorktreeHook[];
|
|
269
|
+
/**
|
|
270
|
+
* Free-form reason string appended to the lifecycle audit log (T9805).
|
|
271
|
+
*
|
|
272
|
+
* Examples: `'pr-merged'`, `'manual'`, `'idle-timeout'`.
|
|
273
|
+
*
|
|
274
|
+
* @default 'manual'
|
|
275
|
+
*/
|
|
276
|
+
reason?: string;
|
|
250
277
|
}
|
|
251
278
|
|
|
252
279
|
/**
|
|
@@ -332,6 +359,16 @@ export interface PruneWorktreesOptions {
|
|
|
332
359
|
* @default true
|
|
333
360
|
*/
|
|
334
361
|
gitPrune?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Abandonment-timeout threshold in days (T9805 AC2).
|
|
364
|
+
*
|
|
365
|
+
* When set, worktrees whose branch has had no commits for at least this many
|
|
366
|
+
* days AND which have no open PR associated are eligible for pruning, even
|
|
367
|
+
* if their task ID is not in a known-stale set.
|
|
368
|
+
*
|
|
369
|
+
* @default undefined — disabled; no idle-age check is performed.
|
|
370
|
+
*/
|
|
371
|
+
idleDays?: number;
|
|
335
372
|
}
|
|
336
373
|
|
|
337
374
|
/**
|
|
@@ -375,6 +412,21 @@ export interface PruneWorktreesResult {
|
|
|
375
412
|
*/
|
|
376
413
|
export type WorktreeStatusCategory = 'active' | 'stale' | 'merged' | 'orphan' | 'locked';
|
|
377
414
|
|
|
415
|
+
/**
|
|
416
|
+
* Source classifier for a worktree entry.
|
|
417
|
+
*
|
|
418
|
+
* - `cleo-spawn` — Created by `cleo orchestrate spawn` via the canonical XDG path.
|
|
419
|
+
* - `claude-agent` — Created by Claude Code Agent `isolation:worktree` dispatch (T9804).
|
|
420
|
+
* - `manual` — Created directly via `git worktree add` without CLEO CLI involvement.
|
|
421
|
+
* - `adopted` — Registered via `cleo worktree adopt` from an unknown origin.
|
|
422
|
+
*
|
|
423
|
+
* The `source` field enables downstream consumers (prune, dashboard, sentient daemon)
|
|
424
|
+
* to apply different policies per origin without re-querying git.
|
|
425
|
+
*
|
|
426
|
+
* @task T9804
|
|
427
|
+
*/
|
|
428
|
+
export type WorktreeSource = 'cleo-spawn' | 'claude-agent' | 'manual' | 'adopted';
|
|
429
|
+
|
|
378
430
|
/**
|
|
379
431
|
* A single structured worktree entry with full status classification.
|
|
380
432
|
*
|
|
@@ -384,6 +436,7 @@ export type WorktreeStatusCategory = 'active' | 'stale' | 'merged' | 'orphan' |
|
|
|
384
436
|
* sentient daemon) can act on without re-querying git.
|
|
385
437
|
*
|
|
386
438
|
* @task T9546
|
|
439
|
+
* @task T9804 — added `source` field for multi-source listing
|
|
387
440
|
*/
|
|
388
441
|
export interface WorktreeInfo {
|
|
389
442
|
/** Absolute path to the worktree directory. */
|
|
@@ -406,6 +459,22 @@ export interface WorktreeInfo {
|
|
|
406
459
|
owningTaskStatus: string | null;
|
|
407
460
|
/** Mutually-exclusive status category — see {@link WorktreeStatusCategory}. */
|
|
408
461
|
statusCategory: WorktreeStatusCategory;
|
|
462
|
+
/**
|
|
463
|
+
* Origin of this worktree entry.
|
|
464
|
+
*
|
|
465
|
+
* - `cleo-spawn` — Canonical XDG worktree created by `cleo orchestrate spawn`.
|
|
466
|
+
* - `claude-agent` — Created by Claude Code Agent `isolation:worktree` (T9804).
|
|
467
|
+
* - `manual` — Created via direct `git worktree add`.
|
|
468
|
+
* - `adopted` — Registered via `cleo worktree adopt`.
|
|
469
|
+
*
|
|
470
|
+
* For backward-compatibility this field defaults to `cleo-spawn` for entries
|
|
471
|
+
* that originated from `git worktree list --porcelain` and are NOT present in
|
|
472
|
+
* the sentinel index.
|
|
473
|
+
*
|
|
474
|
+
* @task T9804
|
|
475
|
+
* @default 'cleo-spawn'
|
|
476
|
+
*/
|
|
477
|
+
source: WorktreeSource;
|
|
409
478
|
}
|
|
410
479
|
|
|
411
480
|
/**
|
|
@@ -451,6 +520,9 @@ export interface ListWorktreesResult {
|
|
|
451
520
|
/**
|
|
452
521
|
* Canonical action recorded in `.cleo/audit/worktree-lifecycle.jsonl`.
|
|
453
522
|
*
|
|
523
|
+
* - `create` — worktree was created via `cleo orchestrate spawn` (T9805).
|
|
524
|
+
* - `destroy` — worktree was explicitly destroyed (PR-merged cleanup or manual) (T9805).
|
|
525
|
+
* - `adopt` — an existing worktree directory was attached to a new task ID (T9805).
|
|
454
526
|
* - `prune` — orphaned/merged worktree was removed.
|
|
455
527
|
* - `prune-skip` — orphan was detected but skipped (user said N, or had uncommitted changes).
|
|
456
528
|
* - `force-unlock` — git index.lock removed + `git worktree unlock` ran.
|
|
@@ -460,18 +532,26 @@ export interface ListWorktreesResult {
|
|
|
460
532
|
* `--resolve manual`; no automatic merge attempted (T9548).
|
|
461
533
|
* - `complete-conflict` — auto-merge attempted but failed (e.g. rebase/merge conflict);
|
|
462
534
|
* worktree was preserved for manual resolution (T9548).
|
|
535
|
+
* - `adopt` — externally-created worktree (e.g. Claude Code Agent `isolation:worktree`)
|
|
536
|
+
* registered in the CLEO SSoT via `cleo worktree adopt` (T9804).
|
|
463
537
|
*
|
|
464
538
|
* @task T9547
|
|
465
539
|
* @task T9548
|
|
540
|
+
* @task T9804
|
|
541
|
+
* @task T9805
|
|
466
542
|
*/
|
|
467
543
|
export type WorktreeLifecycleAction =
|
|
544
|
+
| 'create'
|
|
545
|
+
| 'destroy'
|
|
546
|
+
| 'adopt'
|
|
468
547
|
| 'prune'
|
|
469
548
|
| 'prune-skip'
|
|
470
549
|
| 'force-unlock'
|
|
471
550
|
| 'complete'
|
|
472
551
|
| 'complete-skip'
|
|
473
552
|
| 'complete-manual'
|
|
474
|
-
| 'complete-conflict'
|
|
553
|
+
| 'complete-conflict'
|
|
554
|
+
| 'adopt';
|
|
475
555
|
|
|
476
556
|
/**
|
|
477
557
|
* One append-only entry written to `.cleo/audit/worktree-lifecycle.jsonl` by
|
|
@@ -629,3 +709,71 @@ export interface ForceUnlockWorktreeResult {
|
|
|
629
709
|
/** Error message when no worktree could be located or all actions failed. */
|
|
630
710
|
error?: string;
|
|
631
711
|
}
|
|
712
|
+
|
|
713
|
+
// ---------------------------------------------------------------------------
|
|
714
|
+
// Adopt operation (T9804 — Claude Code Agent isolation:worktree bridge)
|
|
715
|
+
// ---------------------------------------------------------------------------
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Options for {@link adoptWorktree} — the SDK primitive behind
|
|
719
|
+
* `cleo worktree adopt <path>`.
|
|
720
|
+
*
|
|
721
|
+
* @task T9804
|
|
722
|
+
*/
|
|
723
|
+
export interface AdoptWorktreeOpts {
|
|
724
|
+
/**
|
|
725
|
+
* Absolute path to the worktree directory to adopt.
|
|
726
|
+
*
|
|
727
|
+
* Typically a path under `.claude/worktrees/<sessionId>/` for Claude Code
|
|
728
|
+
* Agent `isolation:worktree` spawns, but any valid worktree path is accepted.
|
|
729
|
+
*/
|
|
730
|
+
worktreePath: string;
|
|
731
|
+
/**
|
|
732
|
+
* Absolute path to the project root. Used to resolve the sentinel index
|
|
733
|
+
* and the audit-log file.
|
|
734
|
+
*
|
|
735
|
+
* @default process.cwd()
|
|
736
|
+
*/
|
|
737
|
+
projectRoot?: string;
|
|
738
|
+
/**
|
|
739
|
+
* Source classification for this worktree.
|
|
740
|
+
*
|
|
741
|
+
* @default 'claude-agent'
|
|
742
|
+
*/
|
|
743
|
+
source?: WorktreeSource;
|
|
744
|
+
/**
|
|
745
|
+
* Task ID to associate with this worktree. When not supplied the function
|
|
746
|
+
* attempts to extract it from the branch name following the `task/T####`
|
|
747
|
+
* convention, then falls back to null.
|
|
748
|
+
*/
|
|
749
|
+
taskId?: string | null;
|
|
750
|
+
/** Override actor name written to the audit log and sentinel index. */
|
|
751
|
+
actor?: string;
|
|
752
|
+
/** Optional override for the audit-log file path (testing). */
|
|
753
|
+
auditLogPath?: string;
|
|
754
|
+
/** Optional override for the sentinel index path (testing). */
|
|
755
|
+
sentinelIndexPath?: string;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Result of a successful `cleo worktree adopt` operation.
|
|
760
|
+
*
|
|
761
|
+
* @task T9804
|
|
762
|
+
*/
|
|
763
|
+
export interface AdoptWorktreeResult {
|
|
764
|
+
/** Absolute path of the adopted worktree. */
|
|
765
|
+
path: string;
|
|
766
|
+
/** Branch name extracted from the worktree `.git` gitlink. */
|
|
767
|
+
branch: string;
|
|
768
|
+
/** Task ID associated with the worktree (null if not determinable). */
|
|
769
|
+
taskId: string | null;
|
|
770
|
+
/** Source classification applied to this entry. */
|
|
771
|
+
source: WorktreeSource;
|
|
772
|
+
/**
|
|
773
|
+
* Whether this was a new adoption (`true`) or an idempotent re-adopt
|
|
774
|
+
* of an already-registered worktree (`false`).
|
|
775
|
+
*/
|
|
776
|
+
isNew: boolean;
|
|
777
|
+
/** ISO-8601 timestamp when the sentinel entry was written. */
|
|
778
|
+
adoptedAt: string;
|
|
779
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance graph union types.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the 16 string-literal union types that describe edges
|
|
5
|
+
* and FSM states in the CLEO provenance graph (commits, pull requests,
|
|
6
|
+
* releases, release artifacts, and BRAIN↔release links). Promoted from
|
|
7
|
+
* `packages/core/src/store/tasks-schema.ts` in Phase 0c of the
|
|
8
|
+
* SG-ARCH-SOLID Saga so that downstream packages can import these unions
|
|
9
|
+
* without pulling in the Drizzle schema runtime.
|
|
10
|
+
*
|
|
11
|
+
* The const arrays that back each union (`PR_STATES`, `COMMIT_LINK_KINDS`,
|
|
12
|
+
* `RELEASE_STATUSES`, …) remain in `tasks-schema.ts` because Drizzle's
|
|
13
|
+
* `text({ enum: ... })` column declaration narrows the runtime row type
|
|
14
|
+
* directly from those `as const` literals. `tasks-schema.ts` re-exports
|
|
15
|
+
* each union from this module to preserve the existing public surface for
|
|
16
|
+
* every `import * as schema from '../store/tasks-schema.js'` consumer.
|
|
17
|
+
*
|
|
18
|
+
* @see SPEC-T9345 §3 — provenance graph table definitions
|
|
19
|
+
* @see ADR-073 — task hierarchy charter (release provenance scope)
|
|
20
|
+
*
|
|
21
|
+
* Consolidated unions:
|
|
22
|
+
* - {@link PrState} — pull-request lifecycle state
|
|
23
|
+
* - {@link PrLinkSource} — how a PR↔task link was discovered
|
|
24
|
+
* - {@link PrLinkKind} — semantic PR↔task relationship
|
|
25
|
+
* - {@link CommitConventionalType} — Conventional Commits prefix
|
|
26
|
+
* - {@link CommitLinkKind} — semantic commit↔task relationship
|
|
27
|
+
* - {@link CommitLinkSource} — how a commit↔task link was discovered
|
|
28
|
+
* - {@link CommitFileChangeType} — git status letter (A/M/D/R/C)
|
|
29
|
+
* - {@link ReleaseScheme} — versioning scheme
|
|
30
|
+
* - {@link ReleaseChannel} — npm dist-tag channel
|
|
31
|
+
* - {@link ReleaseKind} — release packaging type
|
|
32
|
+
* - {@link ReleaseStatus} — unified release FSM state
|
|
33
|
+
* - {@link ReleaseChangeType} — 12-value change taxonomy
|
|
34
|
+
* - {@link ReleaseImpact} — semver impact level
|
|
35
|
+
* - {@link ReleaseClassifiedBy} — change-classification provenance
|
|
36
|
+
* - {@link ReleaseArtifactType} — artifact archetype
|
|
37
|
+
* - {@link BrainReleaseLinkType} — BRAIN↔release link semantics
|
|
38
|
+
*
|
|
39
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// ── Pull-request unions (T9507) ─────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* State of a pull request.
|
|
46
|
+
*
|
|
47
|
+
* Mirrors the GitHub PR state machine:
|
|
48
|
+
* - `open` — PR is open and not yet merged
|
|
49
|
+
* - `closed` — PR was closed without merging
|
|
50
|
+
* - `merged` — PR was merged into the target branch
|
|
51
|
+
*
|
|
52
|
+
* @task T9507
|
|
53
|
+
*/
|
|
54
|
+
export type PrState = 'open' | 'closed' | 'merged';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* How a PR↔task link was discovered.
|
|
58
|
+
*
|
|
59
|
+
* - `pr-title` — task ID matched in the PR title
|
|
60
|
+
* - `pr-body` — task ID matched in the PR body markdown
|
|
61
|
+
* - `branch-name` — parsed from the branch name (e.g. `feat/T9507-...`)
|
|
62
|
+
* - `commit-trailer` — extracted from a git trailer in a PR commit
|
|
63
|
+
* - `manual` — explicitly linked via `cleo provenance link`
|
|
64
|
+
*
|
|
65
|
+
* @task T9507
|
|
66
|
+
*/
|
|
67
|
+
export type PrLinkSource = 'pr-title' | 'pr-body' | 'branch-name' | 'commit-trailer' | 'manual';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Semantic classification of a PR↔task relationship.
|
|
71
|
+
*
|
|
72
|
+
* Extends {@link CommitLinkKind} with `'tracks'` for PRs that observe a
|
|
73
|
+
* task without directly implementing, fixing, or documenting it.
|
|
74
|
+
*
|
|
75
|
+
* - `implements` — the PR directly implements the task's acceptance criteria
|
|
76
|
+
* - `fixes` — the PR fixes a bug or regression in the task's work
|
|
77
|
+
* - `refactors` — the PR restructures code introduced by the task
|
|
78
|
+
* - `tests` — the PR adds or updates tests for the task
|
|
79
|
+
* - `docs` — the PR updates documentation for the task
|
|
80
|
+
* - `reverts` — the PR reverts work introduced by the task
|
|
81
|
+
* - `tracks` — the PR is related to but does not directly implement the task
|
|
82
|
+
*
|
|
83
|
+
* @task T9507
|
|
84
|
+
*/
|
|
85
|
+
export type PrLinkKind =
|
|
86
|
+
| 'implements'
|
|
87
|
+
| 'fixes'
|
|
88
|
+
| 'refactors'
|
|
89
|
+
| 'tests'
|
|
90
|
+
| 'docs'
|
|
91
|
+
| 'reverts'
|
|
92
|
+
| 'tracks';
|
|
93
|
+
|
|
94
|
+
// ── Commit unions (T9506) ───────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Conventional Commits prefix parsed from a commit subject.
|
|
98
|
+
*
|
|
99
|
+
* Adds `'breaking'` to the canonical CC set to flag BREAKING CHANGE
|
|
100
|
+
* footers. The DB column is nullable — a commit that does not follow
|
|
101
|
+
* Conventional Commits format stores NULL rather than one of these values.
|
|
102
|
+
*
|
|
103
|
+
* @task T9506
|
|
104
|
+
*/
|
|
105
|
+
export type CommitConventionalType =
|
|
106
|
+
| 'feat'
|
|
107
|
+
| 'fix'
|
|
108
|
+
| 'chore'
|
|
109
|
+
| 'docs'
|
|
110
|
+
| 'refactor'
|
|
111
|
+
| 'test'
|
|
112
|
+
| 'build'
|
|
113
|
+
| 'ci'
|
|
114
|
+
| 'perf'
|
|
115
|
+
| 'revert'
|
|
116
|
+
| 'breaking';
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Semantic classification of a commit↔task relationship.
|
|
120
|
+
*
|
|
121
|
+
* - `implements` — the commit directly implements the task's acceptance criteria
|
|
122
|
+
* - `fixes` — the commit fixes a bug or regression in the task's work
|
|
123
|
+
* - `refactors` — the commit restructures code introduced by the task
|
|
124
|
+
* - `tests` — the commit adds or updates tests for the task
|
|
125
|
+
* - `docs` — the commit updates documentation for the task
|
|
126
|
+
* - `reverts` — the commit reverts work introduced by the task
|
|
127
|
+
*
|
|
128
|
+
* @task T9506
|
|
129
|
+
*/
|
|
130
|
+
export type CommitLinkKind = 'implements' | 'fixes' | 'refactors' | 'tests' | 'docs' | 'reverts';
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* How a commit↔task link was discovered.
|
|
134
|
+
*
|
|
135
|
+
* - `commit-trailer` — extracted from a `T####:` or `Task-Id:` git trailer
|
|
136
|
+
* - `commit-subject` — matched `T####` regex in the commit subject line
|
|
137
|
+
* - `pr-title` — matched task ID in the PR title
|
|
138
|
+
* - `pr-body` — matched task ID in the PR body markdown
|
|
139
|
+
* - `branch-name` — parsed from the branch name (e.g., `feat/T9506-...`)
|
|
140
|
+
* - `manual` — explicitly linked via `cleo provenance link`
|
|
141
|
+
*
|
|
142
|
+
* @task T9506
|
|
143
|
+
*/
|
|
144
|
+
export type CommitLinkSource =
|
|
145
|
+
| 'commit-trailer'
|
|
146
|
+
| 'commit-subject'
|
|
147
|
+
| 'pr-title'
|
|
148
|
+
| 'pr-body'
|
|
149
|
+
| 'branch-name'
|
|
150
|
+
| 'manual';
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Per-file change type from a git diff (status letter codes).
|
|
154
|
+
*
|
|
155
|
+
* - `A` — added
|
|
156
|
+
* - `M` — modified
|
|
157
|
+
* - `D` — deleted
|
|
158
|
+
* - `R` — renamed
|
|
159
|
+
* - `C` — copied
|
|
160
|
+
*
|
|
161
|
+
* @task T9506
|
|
162
|
+
*/
|
|
163
|
+
export type CommitFileChangeType = 'A' | 'M' | 'D' | 'R' | 'C';
|
|
164
|
+
|
|
165
|
+
// ── Release unions (T9508) ──────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Versioning scheme for a release.
|
|
169
|
+
*
|
|
170
|
+
* - `calver` — YYYY.MM.patch (e.g. 2026.5.74) — CLEO default
|
|
171
|
+
* - `semver` — MAJOR.MINOR.PATCH (e.g. 1.2.3)
|
|
172
|
+
* - `calver-suffix` — YYYY.MM.patch.N suffix hotfix (e.g. 2026.5.74.2)
|
|
173
|
+
*
|
|
174
|
+
* @task T9508
|
|
175
|
+
* @remarks
|
|
176
|
+
* The values here MUST stay aligned with `RELEASE_SCHEMES` in
|
|
177
|
+
* `tasks-schema.ts`; that const array drives the Drizzle row type. A
|
|
178
|
+
* compile-time structural assertion in
|
|
179
|
+
* `packages/contracts/src/__tests__/provenance.test.ts` pins both sides.
|
|
180
|
+
*/
|
|
181
|
+
export type ReleaseScheme = 'calver' | 'semver' | 'calver-suffix';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Release channel — controls which npm dist-tag (or equivalent) the
|
|
185
|
+
* artifact is published under.
|
|
186
|
+
*
|
|
187
|
+
* - `latest` — current stable
|
|
188
|
+
* - `beta` — pre-release tested in production-adjacent environments
|
|
189
|
+
* - `dev` — internal development snapshots
|
|
190
|
+
* - `hotfix` — emergency patch outside the regular cadence
|
|
191
|
+
*
|
|
192
|
+
* @task T9508
|
|
193
|
+
* @remarks
|
|
194
|
+
* Distinct from the `ReleaseChannel` exported by
|
|
195
|
+
* `@cleocode/contracts/release/channel` (which carries the npm-level
|
|
196
|
+
* `latest|beta|alpha` set) and from the `ReleaseChannel` in
|
|
197
|
+
* `@cleocode/contracts/release/plan` (which carries the release-plan
|
|
198
|
+
* `latest|beta|alpha|rc` set). Top-level `@cleocode/contracts` re-exports
|
|
199
|
+
* this union under a disambiguating alias.
|
|
200
|
+
*/
|
|
201
|
+
export type ReleaseChannel = 'latest' | 'beta' | 'dev' | 'hotfix';
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Release packaging kind, orthogonal to individual change types within
|
|
205
|
+
* the release.
|
|
206
|
+
*
|
|
207
|
+
* - `regular` — standard scheduled release
|
|
208
|
+
* - `hotfix` — emergency patch outside regular cadence
|
|
209
|
+
* - `prerelease` — alpha/beta/rc release for early adopters
|
|
210
|
+
*
|
|
211
|
+
* @task T9508
|
|
212
|
+
*/
|
|
213
|
+
export type ReleaseKind = 'regular' | 'hotfix' | 'prerelease';
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Unified release FSM state (admits values from BOTH the new T9492
|
|
217
|
+
* pipeline and the legacy T5580 pipeline; the status value itself
|
|
218
|
+
* discriminates which pipeline owns the row).
|
|
219
|
+
*
|
|
220
|
+
* **New T9492 pipeline** — SPEC-T9345 §10.1 FSM:
|
|
221
|
+
* `planned → pr-opened → pr-merged → published → reconciled`
|
|
222
|
+
*
|
|
223
|
+
* **Legacy T5580 pipeline** — pre-T9492 12-step flow:
|
|
224
|
+
* `prepared → committed → tagged → pushed`
|
|
225
|
+
*
|
|
226
|
+
* **Shared terminal states**:
|
|
227
|
+
* `rolled_back | failed | cancelled`
|
|
228
|
+
*
|
|
229
|
+
* State transitions per R-302 MUST be monotonic within each lifecycle;
|
|
230
|
+
* illegal transitions return `E_INVALID_STATE` and MUST NOT mutate any row.
|
|
231
|
+
*
|
|
232
|
+
* @task T9508
|
|
233
|
+
* @task T9686 (unification — legacy + new statuses on one column)
|
|
234
|
+
* @see SPEC-T9345 §10.1
|
|
235
|
+
*/
|
|
236
|
+
export type ReleaseStatus =
|
|
237
|
+
| 'planned'
|
|
238
|
+
| 'pr-opened'
|
|
239
|
+
| 'pr-merged'
|
|
240
|
+
| 'published'
|
|
241
|
+
| 'reconciled'
|
|
242
|
+
| 'prepared'
|
|
243
|
+
| 'committed'
|
|
244
|
+
| 'tagged'
|
|
245
|
+
| 'pushed'
|
|
246
|
+
| 'rolled_back'
|
|
247
|
+
| 'failed'
|
|
248
|
+
| 'cancelled';
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 12-value CLEO release change taxonomy (Option B from
|
|
252
|
+
* provenance-graph-design.md §2.2).
|
|
253
|
+
*
|
|
254
|
+
* Lives at the release-changes level (not on `tasks.kind`) so that:
|
|
255
|
+
* - A single task can produce multiple change rows across releases.
|
|
256
|
+
* - Hotfix classification is a release-packaging decision, not a task property.
|
|
257
|
+
* - Auto-classification is agent-writable without touching OWNER-WRITE-ONLY fields.
|
|
258
|
+
*
|
|
259
|
+
* @task T9508
|
|
260
|
+
* @see SPEC-T9345 §2.2
|
|
261
|
+
*/
|
|
262
|
+
export type ReleaseChangeType =
|
|
263
|
+
| 'feature'
|
|
264
|
+
| 'enhancement'
|
|
265
|
+
| 'bug'
|
|
266
|
+
| 'hotfix'
|
|
267
|
+
| 'security'
|
|
268
|
+
| 'breaking'
|
|
269
|
+
| 'refactor'
|
|
270
|
+
| 'docs'
|
|
271
|
+
| 'chore'
|
|
272
|
+
| 'revert'
|
|
273
|
+
| 'deprecation'
|
|
274
|
+
| 'infrastructure';
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Impact level for a release change, mapped to semver bump assessment.
|
|
278
|
+
*
|
|
279
|
+
* - `major` — breaking change (MAJOR bump)
|
|
280
|
+
* - `minor` — new feature (MINOR bump)
|
|
281
|
+
* - `patch` — bug fix / chore (PATCH bump)
|
|
282
|
+
* - `none` — cosmetic / docs / trivial (no version bump warranted alone)
|
|
283
|
+
*
|
|
284
|
+
* @task T9508
|
|
285
|
+
*/
|
|
286
|
+
export type ReleaseImpact = 'major' | 'minor' | 'patch' | 'none';
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Provenance of a release-change classification.
|
|
290
|
+
*
|
|
291
|
+
* - `auto` — derived by the classification engine from CC prefix + heuristics
|
|
292
|
+
* - `manual` — owner overrode the auto classification via `cleo release classify`
|
|
293
|
+
* - `approved` — owner approved an agent-proposed classification
|
|
294
|
+
*
|
|
295
|
+
* @task T9508
|
|
296
|
+
*/
|
|
297
|
+
export type ReleaseClassifiedBy = 'auto' | 'manual' | 'approved';
|
|
298
|
+
|
|
299
|
+
// ── Release artifact + BRAIN-link unions (T9509) ─────────────────────────
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Release artifact archetype.
|
|
303
|
+
*
|
|
304
|
+
* - `npm` — npm package published to a registry
|
|
305
|
+
* - `cargo` — Rust crate published to crates.io
|
|
306
|
+
* - `docker` — Container image pushed to an OCI registry
|
|
307
|
+
* - `pypi` — Python package published to pypi.org
|
|
308
|
+
* - `github-release` — GitHub Releases asset attached to a git tag
|
|
309
|
+
* - `binary` — Generic compiled binary distributed via direct URL
|
|
310
|
+
* - `github-tag` — Lightweight git tag (no attached assets)
|
|
311
|
+
*
|
|
312
|
+
* @task T9509
|
|
313
|
+
* @see SPEC-T9345 §3.9
|
|
314
|
+
*/
|
|
315
|
+
export type ReleaseArtifactType =
|
|
316
|
+
| 'npm'
|
|
317
|
+
| 'cargo'
|
|
318
|
+
| 'docker'
|
|
319
|
+
| 'pypi'
|
|
320
|
+
| 'github-release'
|
|
321
|
+
| 'binary'
|
|
322
|
+
| 'github-tag';
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Semantic relationship between a BRAIN entry and a release.
|
|
326
|
+
*
|
|
327
|
+
* - `approved-by` — A BRAIN decision approved a change that shipped in this release.
|
|
328
|
+
* - `documented-in` — This release is where the BRAIN entry was first formally documented.
|
|
329
|
+
* - `derived-from` — The release's failure or outcome produced this BRAIN learning/pattern.
|
|
330
|
+
* - `observed-in` — A BRAIN observation was made about this release (e.g. performance note).
|
|
331
|
+
*
|
|
332
|
+
* @task T9509
|
|
333
|
+
* @see SPEC-T9345 §8.1
|
|
334
|
+
*/
|
|
335
|
+
export type BrainReleaseLinkType = 'approved-by' | 'documented-in' | 'derived-from' | 'observed-in';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaffold + diagnostic result contracts.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the result shapes produced by CLEO's directory/file
|
|
5
|
+
* scaffolding utilities (`ensure*`) and read-only health-check utilities
|
|
6
|
+
* (`check*`). Promoted to `@cleocode/contracts` in Phase 0a of the
|
|
7
|
+
* SG-ARCH-SOLID Saga to eliminate duplicate definitions that previously
|
|
8
|
+
* lived in `packages/core/src/scaffold.ts`, `injection.ts`, `hooks.ts`,
|
|
9
|
+
* `schema-management.ts`, and `validation/doctor/checks.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Consolidated types:
|
|
12
|
+
* - {@link ScaffoldResult} — was defined 3× in core (scaffold/injection/hooks)
|
|
13
|
+
* - {@link CheckStatus} — was defined 2× in core (scaffold/doctor checks)
|
|
14
|
+
* - {@link CheckResult} — was defined 2× in core (scaffold/doctor checks)
|
|
15
|
+
* - {@link HookCheckResult} — single canonical definition (no prior duplication;
|
|
16
|
+
* promoted here to keep all scaffold-diagnostic shapes co-located)
|
|
17
|
+
*
|
|
18
|
+
* NOT consolidated (intentional — different domain shape):
|
|
19
|
+
* - `CheckResult` in `packages/core/src/schema-management.ts` is a
|
|
20
|
+
* `{ ok, installed, bundled, missing, stale }` schema-install report,
|
|
21
|
+
* unrelated to diagnostic checks. It retains its local definition and
|
|
22
|
+
* will be renamed in a follow-up slice if/when its naming collision
|
|
23
|
+
* warrants a separate cleanup task.
|
|
24
|
+
*
|
|
25
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// ── ScaffoldResult ────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Result of an `ensure*` scaffolding operation.
|
|
32
|
+
*
|
|
33
|
+
* All ensure functions in `@cleocode/core` are idempotent — they may
|
|
34
|
+
* create, repair, or skip the requested resource and report which
|
|
35
|
+
* action they took.
|
|
36
|
+
*
|
|
37
|
+
* Originally defined in:
|
|
38
|
+
* - `packages/core/src/scaffold.ts`
|
|
39
|
+
* - `packages/core/src/injection.ts`
|
|
40
|
+
* - `packages/core/src/hooks.ts`
|
|
41
|
+
*
|
|
42
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
43
|
+
*/
|
|
44
|
+
export interface ScaffoldResult {
|
|
45
|
+
/** What action was taken: created, repaired, or skipped. */
|
|
46
|
+
action: 'created' | 'repaired' | 'skipped';
|
|
47
|
+
/** Filesystem path that was operated on. */
|
|
48
|
+
path: string;
|
|
49
|
+
/** Human-readable explanation of the result. */
|
|
50
|
+
details?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── CheckStatus + CheckResult ─────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Status of a `check*` diagnostic.
|
|
57
|
+
*
|
|
58
|
+
* Originally defined in:
|
|
59
|
+
* - `packages/core/src/scaffold.ts`
|
|
60
|
+
* - `packages/core/src/validation/doctor/checks.ts`
|
|
61
|
+
*
|
|
62
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
63
|
+
*/
|
|
64
|
+
export type CheckStatus = 'passed' | 'failed' | 'warning' | 'info';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Result of a `check*` diagnostic (used by `cleo doctor` and scaffold
|
|
68
|
+
* health checks).
|
|
69
|
+
*
|
|
70
|
+
* Originally defined in:
|
|
71
|
+
* - `packages/core/src/scaffold.ts`
|
|
72
|
+
* - `packages/core/src/validation/doctor/checks.ts`
|
|
73
|
+
*
|
|
74
|
+
* The scaffold.ts and doctor/checks.ts definitions were structurally
|
|
75
|
+
* identical; this is the consolidated shape with TSDoc preserved.
|
|
76
|
+
*
|
|
77
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
78
|
+
*/
|
|
79
|
+
export interface CheckResult {
|
|
80
|
+
/** Unique check identifier (e.g. "cleo_structure", "sqlite_db"). */
|
|
81
|
+
id: string;
|
|
82
|
+
/** Category grouping (e.g. "scaffold", "global"). */
|
|
83
|
+
category: string;
|
|
84
|
+
/** Diagnostic outcome: passed, failed, warning, or info. */
|
|
85
|
+
status: CheckStatus;
|
|
86
|
+
/** Human-readable description of the check result. */
|
|
87
|
+
message: string;
|
|
88
|
+
/** Structured metadata about the check (paths, sizes, missing items). */
|
|
89
|
+
details: Record<string, unknown>;
|
|
90
|
+
/** Suggested CLI command to fix the issue, or null if passed. */
|
|
91
|
+
fix: string | null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── HookCheckResult ───────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Result of a git-hook installation check.
|
|
98
|
+
*
|
|
99
|
+
* Reports whether a managed hook (commit-msg, pre-commit, pre-push) is
|
|
100
|
+
* installed in `.git/hooks/` and whether the installed copy matches the
|
|
101
|
+
* source template under `packages/core/templates/git-hooks/`.
|
|
102
|
+
*
|
|
103
|
+
* Originally defined in `packages/core/src/hooks.ts`. Promoted here to
|
|
104
|
+
* co-locate all scaffold-diagnostic shapes.
|
|
105
|
+
*
|
|
106
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
107
|
+
*/
|
|
108
|
+
export interface HookCheckResult {
|
|
109
|
+
/** Hook name (commit-msg, pre-commit, pre-push). */
|
|
110
|
+
hook: string;
|
|
111
|
+
/** Whether the hook is installed at `.git/hooks/<hook>`. */
|
|
112
|
+
installed: boolean;
|
|
113
|
+
/** Whether the installed hook bytes match the source template. */
|
|
114
|
+
current: boolean;
|
|
115
|
+
/** Absolute path of the source template that should be installed. */
|
|
116
|
+
sourcePath: string;
|
|
117
|
+
/** Absolute path where the hook is (or would be) installed. */
|
|
118
|
+
installedPath: string;
|
|
119
|
+
}
|