@cleocode/contracts 2026.10.3 → 2026.10.5-rc.ci.672

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 (103) hide show
  1. package/dist/__tests__/cloud-replica-retirement.test.d.ts +10 -0
  2. package/dist/__tests__/cloud-replica-retirement.test.d.ts.map +1 -0
  3. package/dist/__tests__/cloud-replica-retirement.test.js +111 -0
  4. package/dist/__tests__/cloud-replica-retirement.test.js.map +1 -0
  5. package/dist/__tests__/cloud-status-checkpoint-reads.test.d.ts +10 -0
  6. package/dist/__tests__/cloud-status-checkpoint-reads.test.d.ts.map +1 -0
  7. package/dist/__tests__/cloud-status-checkpoint-reads.test.js +49 -0
  8. package/dist/__tests__/cloud-status-checkpoint-reads.test.js.map +1 -0
  9. package/dist/agent-registry.d.ts +5 -1
  10. package/dist/agent-registry.d.ts.map +1 -1
  11. package/dist/cloud/api.d.ts +156 -0
  12. package/dist/cloud/api.d.ts.map +1 -1
  13. package/dist/cloud/api.js +99 -1
  14. package/dist/cloud/api.js.map +1 -1
  15. package/dist/cloud/envelope.d.ts +3 -3
  16. package/dist/dispatch/operations-registry.js +1 -1
  17. package/dist/dispatch/operations-registry.js.map +1 -1
  18. package/dist/doctor.d.ts +79 -7
  19. package/dist/doctor.d.ts.map +1 -1
  20. package/dist/heavy-command-hook.d.ts +134 -5
  21. package/dist/heavy-command-hook.d.ts.map +1 -1
  22. package/dist/index.d.ts +10 -8
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/invariants/sync-write-invariants.d.ts.map +1 -1
  27. package/dist/invariants/sync-write-invariants.js +31 -6
  28. package/dist/invariants/sync-write-invariants.js.map +1 -1
  29. package/dist/ledger/index.d.ts +211 -0
  30. package/dist/ledger/index.d.ts.map +1 -0
  31. package/dist/ledger/index.js +122 -0
  32. package/dist/ledger/index.js.map +1 -0
  33. package/dist/nexus-account.d.ts +72 -1
  34. package/dist/nexus-account.d.ts.map +1 -1
  35. package/dist/nexus-account.js +5 -0
  36. package/dist/nexus-account.js.map +1 -1
  37. package/dist/nexus-cloud.d.ts +175 -0
  38. package/dist/nexus-cloud.d.ts.map +1 -1
  39. package/dist/nexus-cloud.js +17 -0
  40. package/dist/nexus-cloud.js.map +1 -1
  41. package/dist/nexus-first-run.d.ts +145 -0
  42. package/dist/nexus-first-run.d.ts.map +1 -0
  43. package/dist/nexus-first-run.js +54 -0
  44. package/dist/nexus-first-run.js.map +1 -0
  45. package/dist/nexus-vault.d.ts +113 -1
  46. package/dist/nexus-vault.d.ts.map +1 -1
  47. package/dist/nexus-vault.js +27 -0
  48. package/dist/nexus-vault.js.map +1 -1
  49. package/dist/operations/admin.d.ts +14 -1
  50. package/dist/operations/admin.d.ts.map +1 -1
  51. package/dist/operations/docs-lifecycle.d.ts +23 -0
  52. package/dist/operations/docs-lifecycle.d.ts.map +1 -0
  53. package/dist/operations/docs-lifecycle.js +29 -0
  54. package/dist/operations/docs-lifecycle.js.map +1 -0
  55. package/dist/operations/docs.d.ts +2 -11
  56. package/dist/operations/docs.d.ts.map +1 -1
  57. package/dist/operations/docs.js +3 -17
  58. package/dist/operations/docs.js.map +1 -1
  59. package/dist/project-context.d.ts +17 -2
  60. package/dist/project-context.d.ts.map +1 -1
  61. package/dist/release/evidence-atoms.d.ts +15 -7
  62. package/dist/release/evidence-atoms.d.ts.map +1 -1
  63. package/dist/release/evidence-atoms.js +16 -12
  64. package/dist/release/evidence-atoms.js.map +1 -1
  65. package/dist/resource-governor.d.ts +96 -0
  66. package/dist/resource-governor.d.ts.map +1 -1
  67. package/dist/resource-governor.js.map +1 -1
  68. package/dist/row-identity.d.ts +81 -0
  69. package/dist/row-identity.d.ts.map +1 -1
  70. package/dist/store-restore.d.ts +66 -0
  71. package/dist/store-restore.d.ts.map +1 -0
  72. package/dist/store-restore.js +9 -0
  73. package/dist/store-restore.js.map +1 -0
  74. package/dist/task.d.ts +14 -0
  75. package/dist/task.d.ts.map +1 -1
  76. package/dist/task.js.map +1 -1
  77. package/dist/tasks.d.ts +17 -17
  78. package/dist/workgraph.d.ts +28 -28
  79. package/package.json +6 -2
  80. package/src/__tests__/cloud-replica-retirement.test.ts +135 -0
  81. package/src/__tests__/cloud-status-checkpoint-reads.test.ts +60 -0
  82. package/src/agent-registry.ts +5 -1
  83. package/src/cloud/api.ts +125 -1
  84. package/src/dispatch/operations-registry.ts +1 -1
  85. package/src/doctor.ts +85 -7
  86. package/src/heavy-command-hook.ts +175 -5
  87. package/src/index.ts +58 -0
  88. package/src/invariants/sync-write-invariants.ts +81 -42
  89. package/src/ledger/index.ts +141 -0
  90. package/src/nexus-account.ts +82 -0
  91. package/src/nexus-cloud.ts +193 -0
  92. package/src/nexus-first-run.ts +165 -0
  93. package/src/nexus-vault.ts +124 -1
  94. package/src/operations/admin.ts +14 -1
  95. package/src/operations/conduit.ts +1 -1
  96. package/src/operations/docs-lifecycle.ts +31 -0
  97. package/src/operations/docs.ts +4 -19
  98. package/src/project-context.ts +17 -2
  99. package/src/release/evidence-atoms.ts +16 -12
  100. package/src/resource-governor.ts +100 -0
  101. package/src/row-identity.ts +98 -0
  102. package/src/store-restore.ts +70 -0
  103. package/src/task.ts +14 -0
@@ -130,3 +130,101 @@ export interface RowIdentitySpec {
130
130
  /** Task that declared the table. */
131
131
  readonly task: string;
132
132
  }
133
+
134
+ /**
135
+ * One signal behind a store's row-identity share state (T13231).
136
+ *
137
+ * - `synced-marker`: `row_identity_synced` is set (a receive or a send happened);
138
+ * - `sync-flag`: `sync.seal`, `sync.push` or `sync.pull` is on;
139
+ * - `journal-rows`: a change-journal table holds rows (every `_sync_*` table
140
+ * except `_sync_meta`, `_sync_replica` and `_sync_clock`; they key rows by uid);
141
+ * - `journal-meta`: `_sync_meta` holds `suspect:` or `baseline:` keys;
142
+ * - `identity-aliases`: an alias table holds rows (uids were re-keyed);
143
+ * - `rebound`: the store was copied, moved or restored (`_sync_replica`);
144
+ * - `vault-pushed`: a vault push or restore of this root is recorded locally;
145
+ * - `nexus-linked-no-vault`: linked to Cleo Nexus with no local vault record;
146
+ * - `nexus-checkpoint`: Cleo Nexus holds a checkpoint or journal segment of the project;
147
+ * - `nexus-unreachable`: Cleo Nexus could not be asked;
148
+ * - `unreadable`: a record needed for the verdict could not be read.
149
+ */
150
+ export type RowIdentityShareSignalCode =
151
+ | 'synced-marker'
152
+ | 'sync-flag'
153
+ | 'journal-rows'
154
+ | 'journal-meta'
155
+ | 'identity-aliases'
156
+ | 'rebound'
157
+ | 'vault-pushed'
158
+ | 'nexus-linked-no-vault'
159
+ | 'nexus-checkpoint'
160
+ | 'nexus-unreachable'
161
+ | 'unreadable';
162
+
163
+ /** One signal behind a share verdict (T13231). */
164
+ export interface RowIdentityShareSignal {
165
+ readonly code: RowIdentityShareSignalCode;
166
+ /** `shared`: the uids may have left the store; `unknown`: that cannot be ruled out. */
167
+ readonly kind: 'shared' | 'unknown';
168
+ readonly detail: string;
169
+ }
170
+
171
+ /**
172
+ * Whether a store's row identity may have left it (T13231).
173
+ *
174
+ * - `shared`: its uids have, or may have, reached another store;
175
+ * - `unknown`: that cannot be ruled out;
176
+ * - `unshared`: provably local, so a from-scratch refill changes nothing any
177
+ * other store holds.
178
+ */
179
+ export interface RowIdentityShareState {
180
+ readonly state: 'shared' | 'unknown' | 'unshared';
181
+ /** Every signal that decided it (empty when unshared). */
182
+ readonly signals: readonly RowIdentityShareSignal[];
183
+ /** The signals' details, one line each (empty when unshared). */
184
+ readonly reasons: readonly string[];
185
+ }
186
+
187
+ /** What Cleo Nexus answered for one linked origin (`cleo doctor row-identity`, T13231). */
188
+ export interface RowIdentityNexusAnswer {
189
+ readonly apiUrl: string;
190
+ readonly remoteProjectId: string;
191
+ readonly streamId: string;
192
+ /** `none`: no checkpoint and no journal segment; `present`: some; `error`: not answered. */
193
+ readonly answer: 'none' | 'present' | 'error';
194
+ readonly checkpoints: number;
195
+ readonly headSeq: number;
196
+ /** Why it was not answered (`error` only). */
197
+ readonly error?: string;
198
+ }
199
+
200
+ /** Rows whose identity a full refill re-derives, per table. */
201
+ export type RowIdentityRefillCounts = Readonly<Record<string, number>>;
202
+
203
+ /**
204
+ * `cleo doctor row-identity --refill`: the verdict, its evidence and the plan
205
+ * (T13231). `applied` is false on a dry run and on a refusal.
206
+ */
207
+ export interface RowIdentityRefillReport {
208
+ readonly projectRoot: string;
209
+ /** Whether the store's recipe marker is current (no refill is due). */
210
+ readonly recipeCurrent: boolean;
211
+ /** Whether `CLEO_ROW_UID_FILL` is on in this process (`--apply` needs it). */
212
+ readonly fillEnabled: boolean;
213
+ /** The local verdict (link, vault state, journal state). */
214
+ readonly local: RowIdentityShareState;
215
+ /** Cleo Nexus, one answer per linked origin (empty when unlinked). */
216
+ readonly nexus: readonly RowIdentityNexusAnswer[];
217
+ /** The verdict with the Nexus answers folded in. */
218
+ readonly verdict: RowIdentityShareState;
219
+ /** Rows per declared table that carry an identity value the refill clears. */
220
+ readonly planned: RowIdentityRefillCounts;
221
+ /** `refill`: due and allowed; `none`: nothing to do; `refuse`: shared or unknown. */
222
+ readonly action: 'refill' | 'none' | 'refuse';
223
+ /** What to do next, one line each. */
224
+ readonly remedy: readonly string[];
225
+ readonly applied: boolean;
226
+ /** `--apply`: the pre-refill snapshot. */
227
+ readonly snapshot: string | null;
228
+ /** `--apply`: how to undo the refill. */
229
+ readonly undo: string | null;
230
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * `cleo restore backup --snapshot <file> | --id <backupId>`: restore the live
3
+ * project `cleo.db` (which holds the tasks AND brain tables) from a named
4
+ * snapshot or a backup id, safely (T13240).
5
+ *
6
+ * @task T13240
7
+ */
8
+
9
+ /** Where the snapshot came from. */
10
+ export interface StoreRestoreSource {
11
+ /** `snapshot`: a file named on the command line; `backup`: a backup id from `cleo backup list`. */
12
+ readonly kind: 'snapshot' | 'backup';
13
+ /** The file restored from (resolved, absolute). */
14
+ readonly path: string;
15
+ /** The backup id (`backup` only). */
16
+ readonly backupId: string | null;
17
+ }
18
+
19
+ /** What the snapshot verification found. */
20
+ export interface StoreRestoreVerification {
21
+ /** `PRAGMA integrity_check` on a private copy of the snapshot: `ok`, or the first problems. */
22
+ readonly integrity: string;
23
+ /** Tasks in the snapshot (`tasks_tasks`). */
24
+ readonly tasks: number;
25
+ readonly sizeBytes: number;
26
+ }
27
+
28
+ /** The live store file that was replaced, kept so the restore can be undone. */
29
+ export interface StoreRestoreKept {
30
+ /** Backup id the kept file is listed under (`cleo backup list`), restorable with `--id`. */
31
+ readonly backupId: string;
32
+ /** The kept store file. */
33
+ readonly path: string;
34
+ /** Whether the live WAL was folded into the kept file (otherwise its raw sidecars are kept beside it). */
35
+ readonly checkpointed: boolean;
36
+ /** Raw sidecar copies kept beside it (`-wal`, `-shm`, `-journal`), when not checkpointed. */
37
+ readonly sidecars: readonly string[];
38
+ }
39
+
40
+ /** Result of a store restore (or its dry run). */
41
+ export interface StoreRestoreResult {
42
+ readonly dryRun: boolean;
43
+ /** `project` (`.cleo/cleo.db`) or `global` (`<CLEO_HOME>/cleo.db`, T13245). */
44
+ readonly scope: 'project' | 'global';
45
+ readonly restored: boolean;
46
+ /** The live store file. */
47
+ readonly target: string;
48
+ readonly source: StoreRestoreSource;
49
+ readonly verification: StoreRestoreVerification;
50
+ /** The replaced store, kept (`null` on a dry run, or when there was no live store). */
51
+ readonly kept: StoreRestoreKept | null;
52
+ /** Live-file sidecars removed so the restored file is not read with the old journal. */
53
+ readonly removedSidecars: readonly string[];
54
+ /** How to undo the restore (`null` on a dry run, or when nothing was replaced). */
55
+ readonly undo: string | null;
56
+ }
57
+
58
+ /**
59
+ * `cleo backup recover tasks|brain|conduit`: the freshest valid snapshot of the
60
+ * project store, restored through the same safe path as `cleo restore backup`
61
+ * (T13245). All three roles name the one live file, `.cleo/cleo.db`.
62
+ */
63
+ export interface StoreRecoverResult extends StoreRestoreResult {
64
+ /** The role asked for (`tasks`, `brain` or `conduit`); the store restored is `cleo.db` either way. */
65
+ readonly role: string;
66
+ /** Snapshots that failed `PRAGMA quick_check` before one passed (newest first). */
67
+ readonly rejected: readonly string[];
68
+ /** Hours between the chosen snapshot and now, or `null` when its time is unknown. */
69
+ readonly dataLossWindowHours: number | null;
70
+ }
package/src/task.ts CHANGED
@@ -23,6 +23,7 @@
23
23
 
24
24
  import type { AcceptanceGate, AcceptanceGateResult } from './acceptance-gate.js';
25
25
  import type { AcRow } from './data-accessor.js';
26
+ import type { HeavyToolResourcePlan } from './resource-governor.js';
26
27
  import type { TaskStatus } from './status-registry.js';
27
28
 
28
29
  export type { TaskStatus };
@@ -365,6 +366,13 @@ export type EvidenceAtom =
365
366
  treeHash?: string;
366
367
  /** `true` when the result was served from the tool cache (no spawn). */
367
368
  cacheHit?: boolean;
369
+ /**
370
+ * The heap, worker count and workspace concurrency a memory-bound tool
371
+ * (`test`, `build`, `typecheck`, `lint`) was spawned with, and why
372
+ * (T13122, T13123) — including any inherited `NODE_OPTIONS` heap or
373
+ * worker count that was clamped to the budget. Absent for other tools.
374
+ */
375
+ resources?: HeavyToolResourcePlan;
368
376
  }
369
377
  | { kind: 'url'; url: string }
370
378
  | { kind: 'note'; note: string }
@@ -532,6 +540,12 @@ export type EvidenceAtom =
532
540
  * vouches for a PR that was not itself green.
533
541
  */
534
542
  descendantPrHeadSha?: string;
543
+ /**
544
+ * The PR edited a pinned workflow, so only default-branch `push` runs
545
+ * attested it; its own `pull_request` runs (which ran the edited
546
+ * workflow) were never consulted, and none is re-checked (T13174).
547
+ */
548
+ mainOnly?: boolean;
535
549
  /** Task the PR was verified to be linked to (T12634). */
536
550
  taskId?: string;
537
551
  /** Component PR the task is linked through; its CI ran as this integration PR's (T12671). */