/** * Rogue `.cleo/` directory forensic scanner and quarantine tool. * * Detects `.cleo/` directories that exist inside package sub-directories * (e.g. `packages/core/.cleo/`) — these are artefacts of agent misrouting * where CLEO initialised a project context inside a sub-package instead of * the monorepo root. * * Each rogue directory is fingerprinted with: * - SHA-256 hashes for every contained file * - Row counts from `tasks.db` and `brain.db` * - The `__drizzle_migrations` snapshot from any SQLite database found * * Quarantine moves (never deletes) the directory to * `.cleo/quarantine/-/` under the project root. * * @task T1868 */ /** SHA-256 fingerprint of a single file inside the rogue directory. */ export interface RogueFileEntry { /** Path relative to the rogue `.cleo/` directory root. */ path: string; /** Hex-encoded SHA-256 digest. */ sha256: string; /** File size in bytes. */ size: number; } /** A single row from `__drizzle_migrations` in a rogue database. */ export interface DrizzleMigrationEntry { /** Auto-increment primary key. */ id: number; /** Migration content hash recorded by Drizzle. */ hash: string; /** Human-readable migration name (may be null in older schemas). */ name: string | null; } /** Row counts extracted from SQLite databases found inside the rogue directory. */ export interface RogueDbRowCounts { /** Number of rows in `tasks.db → tasks` (undefined if DB absent or unreadable). */ tasks?: number; /** Number of rows in `brain.db → brain_observations` (undefined if DB absent or unreadable). */ brain_observations?: number; /** Number of rows in `brain.db → brain_decisions` (undefined if DB absent or unreadable). */ brain_decisions?: number; } /** * Full forensic report for a single rogue `.cleo/` directory. * * Generated by {@link scanRogueCleoDirs} and consumed by * {@link quarantineRogueCleoDir}. */ export interface RogueDirReport { /** Absolute path to the rogue `.cleo/` directory. */ path: string; /** Package directory name (e.g. `"core"` for `packages/core/.cleo/`). */ packageName: string; /** SHA-256 manifest of every file inside the rogue directory. */ fileManifest: RogueFileEntry[]; /** Row counts from SQLite databases found in the directory. */ dbRowCounts: RogueDbRowCounts; /** Drizzle migration records found in `tasks.db` (empty if absent/unreadable). */ drizzleMigrations: DrizzleMigrationEntry[]; /** Total size of all files in bytes. */ totalSize: number; /** * `true` when `project-info.json` exists inside the `.cleo/` dir, which is * the canonical marker of a legitimately-initialised project root. * `false` means this is definitely a rogue directory. */ hasProjectInfoMarker: boolean; } /** * Scan for rogue `.cleo/` directories inside sub-packages of a monorepo. * * A directory is considered rogue when it: * 1. Exists as `.cleo/` directly inside a `packages//` directory. * 2. Does NOT contain `project-info.json` (the canonical legitimacy marker), * OR it does contain one (recorded, but still quarantine-worthy when * inside a sub-package). * * The function inspects the `packages/` directory under `projectRoot`. Any * `.cleo/` found at depth-1 under any package is returned as a report. * * @param projectRoot - Absolute path to the monorepo root (where the canonical * `.cleo/` directory lives). * @returns Array of forensic reports — one per rogue directory found. */ export declare function scanRogueCleoDirs(projectRoot: string): RogueDirReport[]; /** * Quarantine a single rogue `.cleo/` directory by moving it atomically to * `.cleo/quarantine/-/` under the project root. * * The move is a single `fs.renameSync` which is atomic on POSIX when source * and destination are on the same filesystem. This is NEVER a deletion — the * directory and all its contents are preserved verbatim. * * @param rogue - Report produced by {@link scanRogueCleoDirs}. * @param projectRoot - Absolute path to the monorepo root. * @returns Object containing the absolute `quarantinePath` where the directory * was moved. * @throws If the quarantine directory cannot be created or the rename fails. */ export declare function quarantineRogueCleoDir(rogue: RogueDirReport, projectRoot: string): { quarantinePath: string; }; //# sourceMappingURL=rogue-cleo-detector.d.ts.map