@cleocode/contracts 2026.5.108 → 2026.5.110

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 (51) hide show
  1. package/dist/__tests__/db-inventory.test.d.ts +25 -0
  2. package/dist/__tests__/db-inventory.test.d.ts.map +1 -0
  3. package/dist/__tests__/db-inventory.test.js +148 -0
  4. package/dist/__tests__/db-inventory.test.js.map +1 -0
  5. package/dist/__tests__/memory-wire-shapes.test.js.map +1 -1
  6. package/dist/__tests__/task-type-narrowing.test.d.ts +14 -0
  7. package/dist/__tests__/task-type-narrowing.test.d.ts.map +1 -0
  8. package/dist/__tests__/task-type-narrowing.test.js +51 -0
  9. package/dist/__tests__/task-type-narrowing.test.js.map +1 -0
  10. package/dist/backup-verify.d.ts +136 -0
  11. package/dist/backup-verify.d.ts.map +1 -0
  12. package/dist/backup-verify.js +29 -0
  13. package/dist/backup-verify.js.map +1 -0
  14. package/dist/brain.d.ts +103 -0
  15. package/dist/brain.d.ts.map +1 -1
  16. package/dist/db-inventory.d.ts +200 -0
  17. package/dist/db-inventory.d.ts.map +1 -0
  18. package/dist/db-inventory.js +76 -0
  19. package/dist/db-inventory.js.map +1 -0
  20. package/dist/db-inventory.json +165 -0
  21. package/dist/db-recovery.d.ts +141 -0
  22. package/dist/db-recovery.d.ts.map +1 -0
  23. package/dist/db-recovery.js +29 -0
  24. package/dist/db-recovery.js.map +1 -0
  25. package/dist/doctor.d.ts +605 -0
  26. package/dist/doctor.d.ts.map +1 -1
  27. package/dist/index.d.ts +6 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/memory/observe.d.ts +8 -0
  32. package/dist/memory/observe.d.ts.map +1 -1
  33. package/dist/operations/tasks.d.ts +4 -4
  34. package/dist/operations/tasks.d.ts.map +1 -1
  35. package/dist/task.d.ts +13 -2
  36. package/dist/task.d.ts.map +1 -1
  37. package/dist/task.js.map +1 -1
  38. package/package.json +5 -4
  39. package/src/__tests__/db-inventory.test.ts +184 -0
  40. package/src/__tests__/memory-wire-shapes.test.ts +1 -0
  41. package/src/__tests__/task-type-narrowing.test.ts +56 -0
  42. package/src/backup-verify.ts +140 -0
  43. package/src/brain.ts +114 -0
  44. package/src/db-inventory.json +165 -0
  45. package/src/db-inventory.ts +234 -0
  46. package/src/db-recovery.ts +144 -0
  47. package/src/doctor.ts +634 -0
  48. package/src/index.ts +46 -0
  49. package/src/memory/observe.ts +8 -0
  50. package/src/operations/tasks.ts +4 -4
  51. package/src/task.ts +13 -2
package/dist/doctor.d.ts CHANGED
@@ -256,6 +256,474 @@ export interface SagaAuditResult {
256
256
  /** Total auto-close-drift warnings across all sagas. */
257
257
  driftCount: number;
258
258
  }
259
+ /**
260
+ * Per-database substrate-audit findings.
261
+ *
262
+ * Produced by `surveyProjectDbSubstrate` for every entry in the
263
+ * `DB_INVENTORY` SSoT. Fields that depend on the file existing on disk
264
+ * (`integrityOK`, `rowCounts`, `lastWriteMs`, `sizeBytes`) are `null` when
265
+ * the file is missing. `error` is non-null when integrity_check or the
266
+ * open / row-count round-trip threw — corrupt DBs surface here so the
267
+ * envelope's `summary.corrupt` counter increments.
268
+ *
269
+ * `suggestedFix` is a stable, machine-readable repair command (typically
270
+ * `cleo backup recover <role>` — the verb introduced by T10304). Always
271
+ * populated when `integrityOK === false` so the operator has a one-line
272
+ * remediation path.
273
+ *
274
+ * @task T10307
275
+ * @task T10312 — added `quarantinedTo`, `integrityCheckMs`, `timedOut`
276
+ * for auto-quarantine + bounded-timeout behaviour.
277
+ * @epic T10282
278
+ * @saga T10281
279
+ */
280
+ export interface DbSubstrateEntry {
281
+ /** Absolute on-disk path the inventory template resolved to. */
282
+ filePath: string;
283
+ /** `true` iff the file currently exists on disk. */
284
+ exists: boolean;
285
+ /**
286
+ * Result of `PRAGMA integrity_check`. `true` when the pragma returned
287
+ * exactly one `'ok'` row; `false` when it returned anything else or
288
+ * the call threw; `null` when the file did not exist (no integrity
289
+ * check attempted).
290
+ */
291
+ integrityOK: boolean | null;
292
+ /**
293
+ * Row counts for up to 3 representative tables (alphabetically first
294
+ * non-meta tables). `null` when the file is missing or the count
295
+ * round-trip threw.
296
+ */
297
+ rowCounts: Readonly<Record<string, number>> | null;
298
+ /** `fs.statSync(filePath).mtimeMs`, or `null` when the file is missing. */
299
+ lastWriteMs: number | null;
300
+ /** `fs.statSync(filePath).size`, or `null` when the file is missing. */
301
+ sizeBytes: number | null;
302
+ /**
303
+ * Stable error string surfaced from a failed integrity_check or open.
304
+ * `null` when the survey succeeded (including when the file simply
305
+ * does not exist — that is `exists: false`, not an error).
306
+ */
307
+ error: string | null;
308
+ /**
309
+ * Suggested repair command when `integrityOK === false`. `null`
310
+ * otherwise. Typically `cleo backup recover <role>` per T10304.
311
+ *
312
+ * When auto-quarantine fires (T10312) the suggestedFix is augmented
313
+ * with the quarantine path in the same string for human readability,
314
+ * while the machine-readable path lives in {@link quarantinedTo}.
315
+ */
316
+ suggestedFix: string | null;
317
+ /**
318
+ * Drizzle migration coverage cross-check (T10311). `null` when:
319
+ * - the inventory entry has `migrationsDir === null` (derived or
320
+ * reserved roles); OR
321
+ * - the DB file does not exist; OR
322
+ * - the DB exists but has no `__drizzle_migrations` table yet (e.g.
323
+ * reserved opener that never ran migrations).
324
+ *
325
+ * Otherwise carries a populated {@link DbSubstrateMigrationCoverage}
326
+ * with the orphan-row / missing-file diffs.
327
+ *
328
+ * @task T10311
329
+ */
330
+ migrationCoverage: DbSubstrateMigrationCoverage | null;
331
+ /**
332
+ * Pragma drift entries — one per pragma whose actual value (read from
333
+ * a raw read-only snapshot of this DB, no pragma application) differs
334
+ * from the SSoT expectation in `specs/sqlite-pragmas.json`.
335
+ *
336
+ * @remarks
337
+ * `null` when the DB does not exist on disk (no snapshot to query) OR
338
+ * the integrity_check failed (a corrupt DB cannot be reliably queried
339
+ * for pragmas). Empty array `[]` means the DB matches the canonical
340
+ * pragma SSoT exactly.
341
+ *
342
+ * @task T10310
343
+ */
344
+ pragmaDrift: PragmaDriftItem[] | null;
345
+ /**
346
+ * Absolute path to the quarantine directory when `inspectDbFile`
347
+ * auto-quarantined a corrupt DB. `null` when the entry is healthy OR
348
+ * when auto-quarantine was disabled by the caller.
349
+ *
350
+ * Quarantine naming: `<projectRoot>/.cleo/quarantine/<role>-malformed-<iso>/`.
351
+ * The corrupt DB lands at `<quarantineDir>/<basename>.malformed`, and
352
+ * any sidecar `-wal` / `-shm` files are preserved alongside it.
353
+ *
354
+ * @task T10312
355
+ */
356
+ quarantinedTo: string | null;
357
+ /**
358
+ * Wall-clock duration of the `PRAGMA integrity_check` call in
359
+ * milliseconds, or `null` when the file did not exist OR the open
360
+ * itself threw before the pragma could run.
361
+ *
362
+ * @task T10312
363
+ */
364
+ integrityCheckMs: number | null;
365
+ /**
366
+ * `true` when the integrity_check wall-clock duration exceeded the
367
+ * configured `integrityCheckTimeoutMs`. Because `node:sqlite` is fully
368
+ * synchronous and offers no interrupt(), the check itself runs to
369
+ * completion — `timedOut: true` flags the DB as slow and is treated
370
+ * as an integrity failure for downstream gating (the entry's
371
+ * `integrityOK` is forced to `false` and `summary.corrupt` increments).
372
+ *
373
+ * @task T10312
374
+ */
375
+ timedOut: boolean;
376
+ }
377
+ /**
378
+ * One pragma drift item surfaced in {@link DbSubstrateEntry.pragmaDrift}.
379
+ *
380
+ * @remarks
381
+ * Compared values are normalised to lower-case strings before equality
382
+ * is asserted, matching SQLite's pragma-output conventions
383
+ * (`journal_mode` returns `wal` not `WAL`, `synchronous` returns
384
+ * `2` for `NORMAL`, etc. — see {@link PRAGMA_VALUE_NORMALISERS}).
385
+ *
386
+ * The triple `(pragma, expected, actual)` is stable across runs so
387
+ * downstream consumers can deduplicate / aggregate drift reports.
388
+ *
389
+ * @task T10310
390
+ * @epic T10283
391
+ * @saga T10281
392
+ */
393
+ export interface PragmaDriftItem {
394
+ /** Name of the pragma (e.g. `journal_mode`, `busy_timeout`). */
395
+ pragma: string;
396
+ /**
397
+ * Expected value as declared in `specs/sqlite-pragmas.json`. Always a
398
+ * string — values are stored as strings in the SSoT so a future
399
+ * `0x12345` application_id literal does not lose its hex form to a
400
+ * number cast.
401
+ */
402
+ expected: string;
403
+ /**
404
+ * Actual value as returned by `PRAGMA <name>` on a raw read-only
405
+ * snapshot. `null` when the pragma query threw (e.g. an exotic pragma
406
+ * name not implemented by this SQLite build).
407
+ */
408
+ actual: string | null;
409
+ }
410
+ /**
411
+ * One orphan row in `__drizzle_migrations` — a journal entry whose hash
412
+ * does not match any migration file currently on disk for this role.
413
+ *
414
+ * @remarks
415
+ * Orphans indicate one of:
416
+ * - The DB was last written by a newer CLEO version whose migrations
417
+ * have since been deleted/renamed; OR
418
+ * - A hand-edited journal entry (manual SQL bootstrap that bypassed
419
+ * Drizzle); OR
420
+ * - A migration file was deleted from disk while its journal row
421
+ * remained — a charter violation that breaks T9686-class
422
+ * reconciliation.
423
+ *
424
+ * @task T10311
425
+ */
426
+ export interface DbSubstrateMigrationOrphan {
427
+ /** SHA-256 hash recorded in `__drizzle_migrations.hash`. */
428
+ hash: string;
429
+ /**
430
+ * `__drizzle_migrations.created_at` (Drizzle convention: ms-since-epoch
431
+ * derived from the folder timestamp prefix). `null` when the column was
432
+ * present but `NULL`, or the column did not exist on this DB.
433
+ */
434
+ createdAt: number | null;
435
+ }
436
+ /**
437
+ * One missing-file entry — a migration file present in `migrationsDir`
438
+ * whose hash is NOT recorded in `__drizzle_migrations`.
439
+ *
440
+ * @remarks
441
+ * Missing-file entries indicate the migration has not been applied yet
442
+ * (which is benign for a fresh DB) OR was applied without a journal write
443
+ * (the bug class `reconcileJournal` Scenario 3 was designed to catch).
444
+ *
445
+ * @task T10311
446
+ */
447
+ export interface DbSubstrateMigrationMissing {
448
+ /** Migration directory name (e.g. `20260318205539_initial`). */
449
+ name: string;
450
+ /** SHA-256 hash of the migration's `migration.sql` (Drizzle convention). */
451
+ hash: string;
452
+ }
453
+ /**
454
+ * Per-DB Drizzle migration coverage diff produced by
455
+ * `cleo doctor db-substrate`.
456
+ *
457
+ * @remarks
458
+ * The substrate audit cross-references `__drizzle_migrations` rows (the
459
+ * applied set) with files in `migrationsDir` (the expected set). Both
460
+ * directions are surfaced so operators can distinguish:
461
+ *
462
+ * - **Orphan rows** (`orphanRows.length > 0`): the DB has applied
463
+ * migrations that the local checkout does not provide. Risky — a
464
+ * `reconcileJournal` Scenario 2A signal.
465
+ * - **Missing files** (`missingFiles.length > 0`): the local checkout
466
+ * has migrations the DB has not applied. Drizzle's `migrate()` will
467
+ * pick these up on next open; benign for a fresh DB, suspicious for
468
+ * a live one.
469
+ *
470
+ * Healthy coverage: `orphanRows.length === 0 && missingFiles.length === 0`
471
+ * AND `applied === expected`.
472
+ *
473
+ * @task T10311
474
+ */
475
+ export interface DbSubstrateMigrationCoverage {
476
+ /** Number of rows in `__drizzle_migrations`. */
477
+ applied: number;
478
+ /** Number of migration directories in `migrationsDir`. */
479
+ expected: number;
480
+ /**
481
+ * Rows in `__drizzle_migrations` whose hash does not match any
482
+ * migration file on disk. Always present (may be empty).
483
+ */
484
+ orphanRows: DbSubstrateMigrationOrphan[];
485
+ /**
486
+ * Migration files whose hash is not recorded in
487
+ * `__drizzle_migrations`. Always present (may be empty).
488
+ */
489
+ missingFiles: DbSubstrateMigrationMissing[];
490
+ }
491
+ /**
492
+ * Warning kinds surfaced by `surveyDbSubstrate` via `envelope.meta.warnings`.
493
+ *
494
+ * @remarks
495
+ * Surfacing as warnings (not violations) means they do NOT drive a
496
+ * non-zero exit code on their own — operators should review and remediate,
497
+ * but the substrate is otherwise healthy.
498
+ *
499
+ * - `orphan-project-root` — a `.cleo/` directory found at a project-PARENT
500
+ * path (e.g. `/mnt/projects/.cleo/`). Regression class T9550.
501
+ * - `nested-nexus-duplicate` — `~/.local/share/cleo/nexus/{nexus,signaldock}.db`
502
+ * exists alongside the canonical flat `nexus.db` / `signaldock.db` files,
503
+ * indicating a structural duplicate from an older XDG-path resolution.
504
+ *
505
+ * @task T10307
506
+ */
507
+ export type DbSubstrateWarningKind = 'orphan-project-root' | 'nested-nexus-duplicate';
508
+ /**
509
+ * One warning entry surfaced in the envelope's `meta.warnings` list.
510
+ *
511
+ * @task T10307
512
+ * @task T10308 — added `parentWorkspace` for orphan-project-root attribution.
513
+ */
514
+ export interface DbSubstrateWarning {
515
+ /** Machine-readable warning class. */
516
+ kind: DbSubstrateWarningKind;
517
+ /** Absolute path of the offending file or directory. */
518
+ path: string;
519
+ /**
520
+ * `fs.statSync(path).mtimeMs` for the offending file/directory.
521
+ * `null` when stat() threw (e.g. ephemeral race during scan).
522
+ */
523
+ lastWriteMs: number | null;
524
+ /**
525
+ * For `orphan-project-root` warnings only: the `workspace` field read
526
+ * from `<path>/.context-state.json` when present. Identifies which
527
+ * outside workspace last wrote into this orphan `.cleo/` directory
528
+ * (audit trail for the T9550 regression class). `null` when the
529
+ * file is absent, unreadable, or carries no `workspace` field.
530
+ *
531
+ * @task T10308
532
+ */
533
+ parentWorkspace?: string | null;
534
+ }
535
+ /**
536
+ * Survey result for one CLEO project (i.e. one `.cleo/` directory) plus
537
+ * the global tier of databases owned by it.
538
+ *
539
+ * @remarks
540
+ * `dbs` is keyed by the canonical role names from `DB_INVENTORY`. Every
541
+ * entry is populated regardless of whether the file exists — the caller
542
+ * can iterate every role and decide how to surface absent rows.
543
+ *
544
+ * @task T10307
545
+ */
546
+ export interface DbSubstrateProjectSurvey {
547
+ /** Absolute path to the project root that was surveyed. */
548
+ projectRoot: string;
549
+ /**
550
+ * Stable identifier for the project — currently the `base64url(path)`
551
+ * truncated to 32 chars, matching the convention used by `cleo nexus`
552
+ * project resolution.
553
+ */
554
+ projectId: string;
555
+ /** Per-role survey result, keyed by canonical role name. */
556
+ dbs: Readonly<Record<string, DbSubstrateEntry>>;
557
+ }
558
+ /**
559
+ * Aggregate counters surfaced in `envelope.data.summary`.
560
+ *
561
+ * @task T10307
562
+ */
563
+ export interface DbSubstrateSummary {
564
+ /** Total inventory entries surveyed across all projects + global tier. */
565
+ totalDbs: number;
566
+ /** Entries where `exists && integrityOK === true`. */
567
+ healthy: number;
568
+ /** Entries where `!exists`. */
569
+ missing: number;
570
+ /** Entries where `exists && integrityOK === false`. */
571
+ corrupt: number;
572
+ }
573
+ /**
574
+ * Top-level result payload returned by `surveyDbSubstrate`.
575
+ *
576
+ * @remarks
577
+ * `scope === 'project'` means the survey covered exactly one project plus
578
+ * the global tier. `scope === 'fleet'` means the survey walked every
579
+ * `.cleo/` directory discoverable from a fleet-root search path.
580
+ *
581
+ * Carried as the `data` field of the LAFS envelope; the corresponding
582
+ * `meta` field carries `meta.warnings` per `DbSubstrateWarning` and the
583
+ * canonical `operation: 'doctor.db-substrate.run'` identifier.
584
+ *
585
+ * @task T10307
586
+ */
587
+ export interface DbSubstrateAuditResult {
588
+ /** Survey scope. `'project'` = current project; `'fleet'` = many projects. */
589
+ scope: 'project' | 'fleet';
590
+ /** Per-project surveys. One entry for `scope='project'`; ≥1 for `scope='fleet'`. */
591
+ projects: DbSubstrateProjectSurvey[];
592
+ /** Aggregate counters across all surveyed entries. */
593
+ summary: DbSubstrateSummary;
594
+ /**
595
+ * Structural warnings the survey detected outside of any inventory
596
+ * entry — orphan project-root `.cleo/` directories, nested-nexus
597
+ * duplicates, etc. ALWAYS present (may be empty).
598
+ */
599
+ warnings: DbSubstrateWarning[];
600
+ /**
601
+ * Cross-DB orphan-row reports — one entry per invariant the survey
602
+ * was able to check. ALWAYS present (may be empty when no DBs exist,
603
+ * or when every invariant returned zero orphans).
604
+ *
605
+ * Surfaced to the envelope's `meta.crossDbOrphans` array by the
606
+ * `cleo doctor db-substrate` command via `pushWarning`. Per-invariant
607
+ * sample row IDs are capped at the first 5 to keep envelopes small.
608
+ *
609
+ * @task T10323
610
+ */
611
+ crossDbOrphans: DbCrossDbOrphanReport[];
612
+ }
613
+ /**
614
+ * Canonical identifiers for the cross-DB referential invariants surfaced by
615
+ * `cleo doctor db-substrate` (T10323). The catalogue is owned by the T10320
616
+ * ADR draft — every ID here MUST round-trip with the ADR enumeration.
617
+ *
618
+ * | ID | Source | Target |
619
+ * |----|---------------------------------------|---------------------------------------------|
620
+ * | I1 | `brain_memory_links.task_id` | `tasks.id` (tasks.db) |
621
+ * | I2 | `manifest.db blob_attachments.doc_slug` | `tasks.id` (tasks.db) |
622
+ * | I3 | `nexus.db project_registry.project_id`| `.cleo/project-context.json` (or computed) |
623
+ * | I4 | `llmtxt.db documents.doc_slug` (or any `session_id` column) | `tasks.id` / `sessions.id` |
624
+ * | I5 | `conduit.db dead_letters.job_id` | `tasks.id` / `brain_*.id` |
625
+ *
626
+ * Invariants I1 / I2 / I3 / I5 always run when both source + target DBs
627
+ * exist; I4 runs only when the source schema actually declares a candidate
628
+ * column (the live llmtxt schema has not yet introduced `session_id` — the
629
+ * check stays schema-aware to avoid false positives).
630
+ *
631
+ * @task T10323
632
+ * @epic T10285
633
+ * @saga T10281
634
+ */
635
+ export type DbCrossDbInvariantId = 'I1' | 'I2' | 'I3' | 'I4' | 'I5';
636
+ /**
637
+ * One cross-DB orphan-row finding produced by `walkCrossDbInvariants`.
638
+ *
639
+ * @remarks
640
+ * Every reported invariant carries a bounded sample (first 5 orphan keys)
641
+ * so operators can immediately see WHICH rows triggered the finding. The
642
+ * underlying SQL queries are capped at LIMIT 100 — a sample of 5 is
643
+ * sufficient for triage, and the full count is reported via `orphanCount`.
644
+ *
645
+ * `suggestedFix` is the canonical repair command (or hint) for the
646
+ * invariant class. When the invariant has no programmatic fix it carries
647
+ * a human-readable instruction.
648
+ *
649
+ * `skipped` indicates the invariant could not be checked (e.g. the source
650
+ * DB is missing, the column has not yet been added to the schema, or the
651
+ * snapshot opener threw). When `skipped === true`, `orphanCount === 0`
652
+ * and `sample === []`.
653
+ *
654
+ * @task T10323
655
+ */
656
+ export interface DbCrossDbOrphanReport {
657
+ /** Canonical invariant identifier — see {@link DbCrossDbInvariantId}. */
658
+ invariant: DbCrossDbInvariantId;
659
+ /**
660
+ * Human-readable description of which (source → target) reference class
661
+ * this invariant tracks. Stable text — operators should be able to grep
662
+ * this in audit logs.
663
+ */
664
+ description: string;
665
+ /**
666
+ * Total number of orphan rows detected by the bounded query. When the
667
+ * query hit its `LIMIT 100` cap, this value is the cap; the actual
668
+ * orphan population may be larger.
669
+ */
670
+ orphanCount: number;
671
+ /**
672
+ * First N (≤ 5) orphan identifiers — usually the foreign-key column
673
+ * value. Order matches the source DB's natural read order (no ORDER BY).
674
+ * `[]` when `orphanCount === 0` OR `skipped === true`.
675
+ */
676
+ sample: string[];
677
+ /**
678
+ * Canonical repair command or hint. Stable text — wired into release
679
+ * notes and ADR-068 evidence atoms.
680
+ */
681
+ suggestedFix: string;
682
+ /**
683
+ * `true` when the invariant could not be checked (missing DB, missing
684
+ * column, opener threw). `orphanCount === 0` and `sample === []` when
685
+ * skipped. Carries the skip reason for triage.
686
+ */
687
+ skipped: boolean;
688
+ /**
689
+ * Free-form reason populated when `skipped === true`. Empty string
690
+ * otherwise. Stable text — operators rely on this for diagnostics.
691
+ */
692
+ skipReason: string;
693
+ }
694
+ /**
695
+ * Caller-supplied tuning knobs for a substrate survey.
696
+ *
697
+ * @remarks
698
+ * - `integrityCheckTimeoutMs` bounds the wall-clock duration the survey
699
+ * will wait for `PRAGMA integrity_check` on a single DB. Because
700
+ * `node:sqlite` is fully synchronous, the check cannot be aborted
701
+ * mid-flight — the timer is consulted AFTER the call returns, and a
702
+ * DB that exceeded the budget is flagged via {@link DbSubstrateEntry.timedOut}.
703
+ * - `autoQuarantine` (default `true`) controls whether
704
+ * `inspectDbFile` moves a corrupt DB and its `-wal`/`-shm` sidecars
705
+ * into `<projectRoot>/.cleo/quarantine/<role>-malformed-<iso>/`. Set
706
+ * to `false` for read-only diagnostic surveys.
707
+ *
708
+ * @task T10312
709
+ * @epic T10283
710
+ * @saga T10281
711
+ */
712
+ export interface DbSubstrateSurveyOptions {
713
+ /**
714
+ * Wall-clock budget for the `PRAGMA integrity_check` call on each
715
+ * DB, in milliseconds. Default: 60000 (60 s).
716
+ *
717
+ * Pass `0` to disable the timeout (the survey waits indefinitely).
718
+ */
719
+ integrityCheckTimeoutMs?: number;
720
+ /**
721
+ * `true` (default) → auto-quarantine corrupt DBs into
722
+ * `<projectRoot>/.cleo/quarantine/<role>-malformed-<iso>/`.
723
+ * `false` → leave the corrupt DB in place; only report it.
724
+ */
725
+ autoQuarantine?: boolean;
726
+ }
259
727
  /**
260
728
  * One line appended to `.cleo/audit/worktree-prune.jsonl` per prune
261
729
  * operation. Extends the existing audit-log schema (timestamp +
@@ -288,4 +756,141 @@ export interface PruneAuditEntry {
288
756
  /** Whether this entry represents a dry-run plan (no actual removal). */
289
757
  dryRun: boolean;
290
758
  }
759
+ /**
760
+ * Origin hint inferred from a legacy backup file's name.
761
+ *
762
+ * Identifies which legacy migration produced the file. Used by the operator
763
+ * to decide whether the artefact is safe to delete. Derived purely from the
764
+ * filename (and parent-directory name) — no DB inspection is performed.
765
+ *
766
+ * Codes:
767
+ * - `pre-cleo-migration` — `*-pre-cleo.db.bak` files written by the
768
+ * pre-cleo→cleo migration when the SDK still used legacy file shapes.
769
+ * - `brain-dup-fix` — `brain.db.PRE-DUP-FIX-*` written by the BRAIN
770
+ * dedup repair (T7xxx series).
771
+ * - `pre-untrack` — `*.pre-untrack-*` written by T5158 when the four
772
+ * runtime files were `git rm --cached`-ed in 2026-04-07.
773
+ * - `quarantine-snapshot` — files captured under
774
+ * `<projectRoot>/.cleo/quarantine/` by historical quarantine sweeps
775
+ * (lafs-, studio-, adapters-, core-, runtime-, cleo-os- timestamped
776
+ * directories). NEVER auto-pruned (may be active forensic artefacts).
777
+ * - `brain-malformed` — files under `.cleo/quarantine/brain-malformed-*`
778
+ * (2026-05-23 P0 brain.db malformation incident). Treated as
779
+ * `quarantine-snapshot` for retention.
780
+ * - `db-backup-rotation` — files under `.cleo/backups/sqlite/` older
781
+ * than the 10-snapshot rotation cap (overflow candidates).
782
+ * - `unknown` — file matches the suffix pattern but no specific origin
783
+ * could be inferred from the path. Defaults to safe retention.
784
+ *
785
+ * @task T10309
786
+ */
787
+ export type LegacyBackupOriginHint = 'pre-cleo-migration' | 'brain-dup-fix' | 'pre-untrack' | 'quarantine-snapshot' | 'brain-malformed' | 'db-backup-rotation' | 'unknown';
788
+ /**
789
+ * Retention recommendation for one legacy backup file.
790
+ *
791
+ * `keep` — file is younger than the soft retention window (default 30
792
+ * days), OR the file lives under a path that is unconditionally
793
+ * preserved (quarantine artefacts).
794
+ *
795
+ * `compress` — file is 30-90 days old and large enough that gzip-ing it
796
+ * reduces disk pressure. The current implementation surfaces this
797
+ * recommendation but the `--prune` flag does NOT compress (it only
798
+ * deletes); a future T10311+ task will wire the compressor.
799
+ *
800
+ * `delete` — file is older than the hard retention window (default 90
801
+ * days) AND does NOT live under `.cleo/quarantine/`. The `--prune`
802
+ * verb removes these (or simulates removal in dry-run mode).
803
+ *
804
+ * @task T10309
805
+ */
806
+ export type LegacyBackupRecommendation = 'keep' | 'compress' | 'delete';
807
+ /**
808
+ * One legacy backup artefact discovered by the walker.
809
+ *
810
+ * Carries enough provenance for the operator to act without re-reading
811
+ * the file from disk. `ageDays` is rounded DOWN to match the retention
812
+ * window semantics (a file exactly 30.5 days old is `30` days, still
813
+ * inside the keep window).
814
+ *
815
+ * @task T10309
816
+ */
817
+ export interface LegacyBackupEntry {
818
+ /** Absolute path to the legacy backup file. */
819
+ path: string;
820
+ /** `fs.statSync(path).size`. */
821
+ sizeBytes: number;
822
+ /** `fs.statSync(path).mtimeMs`. */
823
+ mtimeMs: number;
824
+ /** Whole-day age of the file at scan time (`floor((now - mtimeMs) / 86_400_000)`). */
825
+ ageDays: number;
826
+ /** Inferred origin (which legacy migration created this artefact). */
827
+ originHint: LegacyBackupOriginHint;
828
+ /** Retention verdict for this file. */
829
+ recommendation: LegacyBackupRecommendation;
830
+ /**
831
+ * Free-form reason explaining the recommendation. Stable enough to
832
+ * surface to operators; do NOT machine-parse — switch on
833
+ * `originHint` + `recommendation` instead.
834
+ */
835
+ reason: string;
836
+ }
837
+ /**
838
+ * Result returned by the legacy-backup walker (T10309).
839
+ *
840
+ * Lists every discovered artefact plus aggregate counters. When
841
+ * `--prune` was requested the `pruned` and `kept` arrays partition the
842
+ * total set; otherwise both arrays are empty and `entries` is the only
843
+ * populated list.
844
+ *
845
+ * @remarks
846
+ * `softRetentionDays` and `hardRetentionDays` echo the configured
847
+ * retention thresholds back to the operator so the envelope is
848
+ * self-documenting.
849
+ *
850
+ * @task T10309
851
+ */
852
+ export interface LegacyBackupScanResult {
853
+ /** Absolute path to the project root that was scanned. */
854
+ projectRoot: string;
855
+ /** Absolute path to the CLEO home (`<projectRoot>/../.local/share/cleo` style) that was scanned. */
856
+ cleoHome: string;
857
+ /** All artefacts discovered, sorted by `path` ascending. */
858
+ entries: LegacyBackupEntry[];
859
+ /** Total bytes across `entries`. */
860
+ totalBytes: number;
861
+ /** Soft retention window in days (files younger than this are always `keep`). */
862
+ softRetentionDays: number;
863
+ /** Hard retention window in days (files older than this are `delete`). */
864
+ hardRetentionDays: number;
865
+ /**
866
+ * `true` when this result represents a `--prune` invocation; `false`
867
+ * when it is a pure scan. Drives whether `pruned`/`kept` are
868
+ * populated.
869
+ */
870
+ prune: boolean;
871
+ /**
872
+ * `true` when `--prune` was requested but `--dry-run` was active
873
+ * (the implementation defaults `--prune` to dry-run). `false` for
874
+ * actual deletions or when `prune === false`.
875
+ */
876
+ dryRun: boolean;
877
+ /**
878
+ * Entries that were (or would be) deleted. Always empty when
879
+ * `prune === false`.
880
+ */
881
+ pruned: LegacyBackupEntry[];
882
+ /**
883
+ * Entries the prune operation skipped (recommendation !== 'delete'
884
+ * or path under quarantine). Always empty when `prune === false`.
885
+ */
886
+ kept: LegacyBackupEntry[];
887
+ /**
888
+ * Errors encountered while removing pruneable files. Empty in
889
+ * dry-run mode and on pure scans.
890
+ */
891
+ errors: Array<{
892
+ path: string;
893
+ error: string;
894
+ }>;
895
+ }
291
896
  //# sourceMappingURL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AC1B;;;OAGG;IACH,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD"}
package/dist/index.d.ts CHANGED
@@ -17,9 +17,10 @@ export type { AttachmentMetadataSchemaInput, AttachmentRefSchemaInput, Attachmen
17
17
  export { attachmentMetadataSchema, attachmentRefSchema, attachmentSchema, blobAttachmentSchema, llmsTxtAttachmentSchema, llmtxtDocAttachmentSchema, localFileAttachmentSchema, urlAttachmentSchema, } from './attachment-schema.js';
18
18
  export type { CommitEntry, ReconstructResult, ReleaseTagEntry, } from './audit.js';
19
19
  export type { BackupDatabaseEntry, BackupGlobalFileEntry, BackupIntegrity, BackupJsonEntry, BackupManifest, BackupMetadata, BackupScope, } from './backup-manifest.js';
20
+ export type { BackupVerifyDbReport, BackupVerifyResult, BackupVerifySnapshot, BackupVerifySummary, BackupVerifyVerdict, } from './backup-verify.js';
20
21
  export type { BoundaryEntry, CanonicalHome, PerfBudget, SafetyBudget, ThroughputThreshold, WorkloadIntent, } from './boundary.js';
21
22
  export { BOUNDARY_REGISTRY } from './boundary.js';
22
- export type { BrainCognitiveType, BrainEntryRef, BrainEntrySummary, BrainMemoryTier, BrainSourceConfidence, ContradictionDetail, SupersededEntry, } from './brain.js';
23
+ export type { BackupRecoverBrainResult, BrainCognitiveType, BrainEntryRef, BrainEntrySummary, BrainMemoryTier, BrainRecoveredRowCounts, BrainRecoveryResult, BrainSourceConfidence, ContradictionDetail, SupersededEntry, } from './brain.js';
23
24
  export type { BrainConnectionStatus, BrainEdge, BrainGraph, BrainNode, BrainNodeKind, BrainProjectContext, BrainQueryOptions, BrainStreamEvent, BrainSubstrate, } from './brain-graph.js';
24
25
  export type { AbsolutePathRules, AbsolutePathValidationResult, AgentWorktreeState, BoundaryContract, BranchLockErrorCode, DeniedGitOp, FsHardenCapabilities, FsHardenState, GitShimEnv, IsolationEnvKey, IsolationOptions, IsolationResult, OwnerOverrideAuditRecord, OwnerOverrideConfig, WorktreeCleanupResult, WorktreeMergeResult, WorktreeSpawnResult, } from './branch-lock.js';
25
26
  export { BRANCH_LOCK_ERROR_CODES, ISOLATION_ENV_KEYS, provisionIsolatedShell, validateAbsolutePath, } from './branch-lock.js';
@@ -35,6 +36,9 @@ export type { AdapterContextMonitorProvider } from './context-monitor.js';
35
36
  export type { ClaudeCodeOAuthBlock, ParsedClaudeCodeCredential, } from './credentials.js';
36
37
  export { parseClaudeCodeCredentials } from './credentials.js';
37
38
  export type { ArchiveFields, ArchiveFile, DataAccessor, DataAccessorAgentInstance, QueryTasksResult, TaskFieldUpdates, TaskQueryFilters, TransactionAccessor, } from './data-accessor.js';
39
+ export type { DbConcurrency, DbInventoryEntry, DbPrivacy, DbRole, DbTier, } from './db-inventory.js';
40
+ export { DB_INVENTORY } from './db-inventory.js';
41
+ export type { BackupRecoverResult, DbRecoveredRowCounts, DbRecoveryResult, } from './db-recovery.js';
38
42
  export type { DependencyCategory, DependencyCheckResult, DependencyReport, DependencySpec, } from './dependency.js';
39
43
  export type { AdapterManifest, DetectionPattern } from './discovery.js';
40
44
  export type { CanonicalDomain, Gateway, Tier } from './dispatch/identity.js';
@@ -44,7 +48,7 @@ export { defineDomain, defineOp, OPERATIONS } from './dispatch/operations-regist
44
48
  export type { DocExportFormat, DocKind, DocRecord, DocSearchHit, DocsAccessor, ListDocsFilters, StoreDocParams, StoreDocResult, } from './docs-accessor.js';
45
49
  export type { BuiltinDocKind, DocKindConfigFile, DocKindExtensionConfig, DocKindMetadata, SlugValidationResult, } from './docs-taxonomy.js';
46
50
  export { BUILTIN_DOC_KIND_VALUES, BUILTIN_DOC_KINDS, DocKindConfigError, DocKindRegistry, } from './docs-taxonomy.js';
47
- export type { ComprehensiveAuditResult, OrphanEntry, OrphanScanResult, PruneAuditEntry, PruneResult, SagaAuditEntry, SagaAuditResult, SagaAuditViolation, SagaAuditViolationKind, WorktreeAnomaly, WorktreeAnomalyKind, } from './doctor.js';
51
+ export type { ComprehensiveAuditResult, DbCrossDbInvariantId, DbCrossDbOrphanReport, DbSubstrateAuditResult, DbSubstrateEntry, DbSubstrateMigrationCoverage, DbSubstrateMigrationMissing, DbSubstrateMigrationOrphan, DbSubstrateProjectSurvey, DbSubstrateSummary, DbSubstrateSurveyOptions, DbSubstrateWarning, DbSubstrateWarningKind, LegacyBackupEntry, LegacyBackupOriginHint, LegacyBackupRecommendation, LegacyBackupScanResult, OrphanEntry, OrphanScanResult, PragmaDriftItem, PruneAuditEntry, PruneResult, SagaAuditEntry, SagaAuditResult, SagaAuditViolation, SagaAuditViolationKind, WorktreeAnomaly, WorktreeAnomalyKind, } from './doctor.js';
48
52
  export type { EngineErrorPayload, EngineFailure, EngineResult, EngineSuccess, ProblemDetails, } from './engine-result.js';
49
53
  export { EngineResultError, engineError, engineSuccess, unwrap, } from './engine-result.js';
50
54
  export { ARCHIVE_REASONS, TASK_KINDS, TASK_RELATION_TYPES, TASK_SCOPES, TASK_SEVERITIES, TASK_SIZES, } from './enums.js';