@cleocode/contracts 2026.11.8 → 2026.11.9-rc.ci.726

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/src/adapter.ts CHANGED
@@ -30,7 +30,7 @@
30
30
  * `~/.config/opencode/agents/`).
31
31
  *
32
32
  * Full rationale + provider-swap invariant probe design:
33
- * `.cleo/adrs/ADR-049-harness-sovereignty.md`.
33
+ * `docs/adr/adr-049-harness-sovereignty.md`.
34
34
  */
35
35
 
36
36
  import type { AdapterCapabilities } from './capabilities.js';
@@ -12,7 +12,7 @@
12
12
  * @what BackupManifest describes metadata, databases, json files,
13
13
  * global files, and integrity block for a portable CLEO backup.
14
14
  * @see .cleo/rcasd/T311/specification/T311-specification.md §3
15
- * @see .cleo/adrs/ADR-038-backup-portability.md §3
15
+ * @see docs/adr/adr-038-backup-portability.md §3
16
16
  * @module backup-manifest
17
17
  */
18
18
 
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * Adding a new entry to the inventory is a charter amendment — update
32
32
  * `packages/contracts/src/db-inventory.json` AND
33
- * `.cleo/adrs/ADR-068-cleo-database-charter.md` in the same PR (gated by
33
+ * `docs/adr/adr-068-cleo-database-charter.md` in the same PR (gated by
34
34
  * `cleo check arch` Gate-4 SSoT-EXEMPT lint once T10282 ships its drift
35
35
  * check).
36
36
  *
@@ -28,12 +28,42 @@
28
28
 
29
29
  import type { DbRole } from './db-inventory.js';
30
30
 
31
- /** Read-only integrity assessment performed on a disposable copy. */
31
+ /** High-water marks from a key table in a disposable store image. */
32
+ export interface StoreTableHighWater {
33
+ /** Physical table name. */
34
+ table: string;
35
+ /** Number of readable rows. */
36
+ rows: number;
37
+ /** Largest rowid, encoded without losing 64-bit precision. */
38
+ maxRowid: string | null;
39
+ /** Latest created, updated, session or audit timestamp in Unix seconds. */
40
+ latestAt: number | null;
41
+ }
42
+
43
+ /** Evidence of newer snapshot history or WAL commits that SQLite cannot apply. */
44
+ export interface StoreFreshnessFinding {
45
+ /** Snapshot or original WAL path. */
46
+ source: string;
47
+ /** Recovery source whose contents advanced beyond the visible store. */
48
+ kind: 'snapshot' | 'wal';
49
+ /** Compared high-water marks naming the affected tables. */
50
+ evidence: string[];
51
+ /** SQLite rejected apparent commits; the quarantine remains necessary for investigation. */
52
+ unreadable?: boolean;
53
+ /** False for a retained backup excluded by an explicit rollback. */
54
+ authoritative?: boolean;
55
+ /** Whether assessed history has live-only keys; omitted when not assessed. */
56
+ divergent?: boolean;
57
+ }
58
+
59
+ /** Read-only integrity and freshness assessment performed on disposable copies. */
32
60
  export interface StoreIntegrityInspection {
33
- /** True when integrity_check returns exactly one ok row, or the store is absent. */
61
+ /** True when integrity and freshness checks pass, or the store is absent. */
34
62
  healthy: boolean;
35
63
  /** Integrity findings, a read failure, or absent. */
36
64
  detail: string;
65
+ /** Newer recoverable history, when physical integrity alone would pass. */
66
+ freshness?: StoreFreshnessFinding[];
37
67
  }
38
68
 
39
69
  /** Restartable phases of a whole-store repair; the commit is one atomic rename. */
@@ -100,6 +130,40 @@ export interface StoreRepairFile {
100
130
  bytes: number;
101
131
  }
102
132
 
133
+ /** Explicit rollback intent retained with the repair receipt and the store marker. */
134
+ export interface StoreRestoreIntent {
135
+ /** Explicitly selected snapshot. */
136
+ snapshot: string;
137
+ /** SHA-256 of the selected snapshot's original main file. */
138
+ snapshotSha256: string;
139
+ /** Time the deliberate rollback began. */
140
+ restoredAt: string;
141
+ /** Pre-existing backup images excluded from subsequent automatic recovery. */
142
+ ignoredSnapshots: StoreRepairFile[];
143
+ }
144
+
145
+ /** A rollback marker prepared before publication and finalized before releasing restore exclusion. */
146
+ export interface StoreRestoreIntentMarker {
147
+ /** Marker format. */
148
+ version: 1;
149
+ /** Canonical store to which the intent applies. */
150
+ target: string;
151
+ /** Prepared markers need image proof; committed intent survives later writes. */
152
+ state: 'prepared' | 'committed';
153
+ /** New intent, or an explicit clear. */
154
+ intent: StoreRestoreIntent | null;
155
+ /** Earlier intent remains applicable while the old image is still present. */
156
+ previous: StoreRestoreIntent | null;
157
+ /** Main image installed by this restore. */
158
+ mainSha256: string;
159
+ /** Full-image WAL installed by repair, when applicable. */
160
+ walSha256?: string;
161
+ /** Original main image before publication. */
162
+ previousMainSha256?: string;
163
+ /** Original WAL before publication, when present. */
164
+ previousWalSha256?: string;
165
+ }
166
+
103
167
  /** Recovery file reference and its losslessly encoded records. */
104
168
  export interface StoreRepairRecovery {
105
169
  /** Quarantine JSON path, or null for a dry run. */
@@ -139,6 +203,8 @@ export interface StoreRepairReceipt {
139
203
  commitMainSha256?: string;
140
204
  /** Whether readable live rows were merged. */
141
205
  delta: boolean;
206
+ /** Rollback intent; null explicitly clears an earlier deliberate rollback. */
207
+ restoreIntent?: StoreRestoreIntent | null;
142
208
  /** Preserved original file hashes. */
143
209
  files: StoreRepairFile[];
144
210
  /** Per-table accounting. */
@@ -147,6 +213,8 @@ export interface StoreRepairReceipt {
147
213
  missingTaskIds: string[];
148
214
  /** Extraction failures and unavailable optional tools. */
149
215
  diagnostics: string[];
216
+ /** Freshness evidence that triggered a lossless union instead of deletion inference. */
217
+ freshness?: StoreFreshnessFinding[];
150
218
  /** Excluded data and deletion accounting; also persisted beside the immutable originals. */
151
219
  recovery?: StoreRepairRecovery;
152
220
  /** True only after integrity, foreign-key, and base-count verification. */
@@ -5726,7 +5726,7 @@ export const OPERATIONS: OperationDef[] = [
5726
5726
  domain: 'admin',
5727
5727
  operation: 'adr.sync',
5728
5728
  description:
5729
- 'admin.adr.sync (mutate) — sync .cleo/adrs/ markdown files into architecture_decisions DB table; absorbs adr.validate via validate flag',
5729
+ 'admin.adr.sync (mutate) — sync docs/adr/ markdown files into architecture_decisions DB table; absorbs adr.validate via validate flag',
5730
5730
  tier: 2,
5731
5731
  idempotent: true,
5732
5732
  sessionRequired: false,
package/src/index.ts CHANGED
@@ -410,6 +410,7 @@ export type {
410
410
  DbRecoveryResult,
411
411
  DoctorRepairResult,
412
412
  DoctorRepairRoleResult,
413
+ StoreFreshnessFinding,
413
414
  StoreIntegrityInspection,
414
415
  StoreRepairFile,
415
416
  StoreRepairOptions,
@@ -419,6 +420,9 @@ export type {
419
420
  StoreRepairRecoveryRow,
420
421
  StoreRepairTable,
421
422
  StoreRepairValue,
423
+ StoreRestoreIntent,
424
+ StoreRestoreIntentMarker,
425
+ StoreTableHighWater,
422
426
  } from './db-recovery.js';
423
427
  // === Dependency Registry Contracts ===
424
428
  export type {
@@ -2160,6 +2164,7 @@ export type {
2160
2164
  PruneWorktreesOptions,
2161
2165
  PruneWorktreesResult,
2162
2166
  WorktreeArchiveReceipt,
2167
+ WorktreeDependentsScan,
2163
2168
  WorktreeDisposalBlockers,
2164
2169
  WorktreeHook,
2165
2170
  WorktreeHookResult,
@@ -2176,6 +2181,7 @@ export type {
2176
2181
  WorktreeLockRecord,
2177
2182
  WorktreeLockSessionProbe,
2178
2183
  WorktreeLockSessionState,
2184
+ WorktreeScannedCheckout,
2179
2185
  WorktreeSource,
2180
2186
  WorktreeStatusCategory,
2181
2187
  } from './operations/worktree.js';
@@ -2437,6 +2443,7 @@ export type {
2437
2443
  MemoryConsumer,
2438
2444
  MemoryConsumers,
2439
2445
  MemoryPressureReading,
2446
+ PreparedGitPushHook,
2440
2447
  ProjectSettingOverride,
2441
2448
  ResourceClass,
2442
2449
  ResourceDeferral,
@@ -509,6 +509,38 @@ export interface DestroyWorktreeOptions {
509
509
  evidence?: readonly EvidenceAtom[];
510
510
  }
511
511
 
512
+ /**
513
+ * One checkout read by the dependents scan (T14554): its real path, and each
514
+ * symlink it could link into another worktree through with the link's
515
+ * resolved target (`null` when the target does not resolve). `links` stays
516
+ * unset until a disposal needs it.
517
+ *
518
+ * @task T14554
519
+ */
520
+ export interface WorktreeScannedCheckout {
521
+ /** The checkout's real path, or `null` when it does not resolve. */
522
+ real: string | null;
523
+ /** Its candidate symlinks, read at most once per scan. */
524
+ links?: ReadonlyArray<{ path: string; target: string | null }>;
525
+ }
526
+
527
+ /**
528
+ * A memo shared by the dry-run disposal proofs of one listing (T14554), so
529
+ * finding a worktree's dependents reads every other checkout once per listing
530
+ * instead of once per proven worktree. Honoured only by dry runs: a removal
531
+ * always rescans the disk.
532
+ *
533
+ * @task T14554
534
+ */
535
+ export interface WorktreeDependentsScan {
536
+ /** The other checkouts per scanned directory and git root. */
537
+ checkouts: Map<string, readonly string[]>;
538
+ /** Each checkout read so far, by path. */
539
+ scanned: Map<string, WorktreeScannedCheckout>;
540
+ /** How many checkouts had their links read (bounded by the checkout count). */
541
+ linkScans: number;
542
+ }
543
+
512
544
  /**
513
545
  * Why a worktree disposal was refused (T13696). Disposal deletes the whole
514
546
  * directory, so it is skipped while anything outside it still needs a file in it.
@@ -664,6 +696,11 @@ export interface DisposeWorktreeOptions {
664
696
  * a reason when it does, `null` when not. A probe that throws counts as in use.
665
697
  */
666
698
  inUse?: () => string | null;
699
+ /**
700
+ * A dependents scan shared across one listing's proofs (T14554). Used only
701
+ * with `dryRun`; any other disposal scans afresh.
702
+ */
703
+ dependentsScan?: WorktreeDependentsScan;
667
704
  }
668
705
 
669
706
  /**
@@ -18,6 +18,14 @@
18
18
 
19
19
  import type { OperationExecutionContext } from './jobs.js';
20
20
 
21
+ /** A push whose pre-push hook takes its own admission, plus temporary-hook cleanup. */
22
+ export interface PreparedGitPushHook {
23
+ /** Git argv with a temporary hooks directory; the original command is otherwise preserved. */
24
+ readonly argv: readonly string[];
25
+ /** Remove the temporary directory after Git exits or fails to start. */
26
+ readonly release: () => void;
27
+ }
28
+
21
29
  /**
22
30
  * Governor arbitration mode. Mirrors the writer-lease mode shape
23
31
  * (`writer-lease.ts` {@link LeaseMode}).