@cleocode/contracts 2026.11.22 → 2026.11.23

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.
@@ -10159,6 +10159,26 @@ export const OPERATIONS: OperationDef[] = [
10159
10159
  },
10160
10160
  ] satisfies ParamDef[],
10161
10161
  },
10162
+ // T14694 — preserve stray worker reports so report-only worktrees become disposable
10163
+ {
10164
+ gateway: 'mutate',
10165
+ domain: 'worktree',
10166
+ operation: 'preserveReports',
10167
+ description:
10168
+ 'worktree.preserveReports (mutate) — store every worktree temp/cleo-worker-report.txt as a content-addressed blob attachment on its task, idempotently, so the disposal proof treats an unchanged report as preserved. Never deletes (T14694).',
10169
+ tier: 1,
10170
+ idempotent: true,
10171
+ sessionRequired: false,
10172
+ requiredParams: [],
10173
+ params: [
10174
+ {
10175
+ name: 'dryRun',
10176
+ type: 'boolean',
10177
+ required: false,
10178
+ description: 'Report what would be preserved without writing',
10179
+ },
10180
+ ] satisfies ParamDef[],
10181
+ },
10162
10182
  // T9804 — Claude Code Agent isolation:worktree bridge (adopt)
10163
10183
  {
10164
10184
  gateway: 'mutate',
package/src/index.ts CHANGED
@@ -2161,6 +2161,10 @@ export type {
2161
2161
  MergedCleanupItem,
2162
2162
  MergedCleanupOpts,
2163
2163
  MergedCleanupResult,
2164
+ PreservedWorkerReport,
2165
+ PreservedWorkerReportStatus,
2166
+ PreserveWorkerReportsOpts,
2167
+ PreserveWorkerReportsResult,
2164
2168
  PrunedWorktreeOutcome,
2165
2169
  PruneOrphanedWorktreesOpts,
2166
2170
  PruneOrphanedWorktreesResult,
@@ -1220,6 +1220,83 @@ export interface ForceUnlockWorktreeResult {
1220
1220
  error?: string;
1221
1221
  }
1222
1222
 
1223
+ // ---------------------------------------------------------------------------
1224
+ // Preserve worker reports (T14694)
1225
+ // ---------------------------------------------------------------------------
1226
+
1227
+ /**
1228
+ * Options for `preserveWorkerReports` — the SDK primitive behind
1229
+ * `cleo worktree preserve-reports`.
1230
+ *
1231
+ * @task T14694
1232
+ */
1233
+ export interface PreserveWorkerReportsOpts {
1234
+ /** Absolute path to the project root whose worktrees are scanned. */
1235
+ projectRoot: string;
1236
+ /** Report what would be preserved; write nothing. */
1237
+ dryRun?: boolean;
1238
+ /** Agent identity recorded on each attachment ref. */
1239
+ actor?: string;
1240
+ }
1241
+
1242
+ /**
1243
+ * What happened to one worktree's `temp/cleo-worker-report.txt`.
1244
+ *
1245
+ * - `preserved` — stored as a blob attachment on its task (or would be, on a dry run).
1246
+ * - `already-preserved` — CLEO already held these exact bytes for the task.
1247
+ * - `skipped` — not stored; {@link PreservedWorkerReport.reason} says why.
1248
+ *
1249
+ * @task T14694
1250
+ */
1251
+ export type PreservedWorkerReportStatus = 'preserved' | 'already-preserved' | 'skipped';
1252
+
1253
+ /**
1254
+ * One worktree's report outcome from `preserveWorkerReports`.
1255
+ *
1256
+ * @task T14694
1257
+ */
1258
+ export interface PreservedWorkerReport {
1259
+ /** Absolute worktree path. */
1260
+ worktreePath: string;
1261
+ /** Owning task, from the worktree directory name; `null` when it names none. */
1262
+ taskId: string | null;
1263
+ /** Outcome. */
1264
+ status: PreservedWorkerReportStatus;
1265
+ /** sha256 of the report bytes. */
1266
+ sha256: string;
1267
+ /** Report size in bytes. */
1268
+ size: number;
1269
+ /** Attachment holding the bytes, once stored. */
1270
+ attachmentId?: string;
1271
+ /** Why the report was skipped (`unknown task` when the task store lacks the task). */
1272
+ reason?: string;
1273
+ /**
1274
+ * Set when identical bytes were already stored from another worktree: the
1275
+ * shared, content-addressed row keeps that worktree in its description, so
1276
+ * this worktree is recorded only by this entry and its task ref.
1277
+ */
1278
+ note?: string;
1279
+ }
1280
+
1281
+ /**
1282
+ * Result of `preserveWorkerReports`. Nothing is ever deleted: disposal stays
1283
+ * with `cleo worktree prune`.
1284
+ *
1285
+ * @task T14694
1286
+ */
1287
+ export interface PreserveWorkerReportsResult {
1288
+ /** One entry per worktree holding a worker report. */
1289
+ reports: PreservedWorkerReport[];
1290
+ /** Reports stored by this run (or that a dry run would store). */
1291
+ preservedCount: number;
1292
+ /** Reports CLEO already held. */
1293
+ alreadyPreservedCount: number;
1294
+ /** Reports not stored. */
1295
+ skippedCount: number;
1296
+ /** Whether {@link PreserveWorkerReportsOpts.dryRun} was set. */
1297
+ dryRun: boolean;
1298
+ }
1299
+
1223
1300
  // ---------------------------------------------------------------------------
1224
1301
  // Adopt operation (T9804 — Claude Code Agent isolation:worktree bridge)
1225
1302
  // ---------------------------------------------------------------------------