/** * NEXUS project registry bulk-clean. * * Purges project_registry rows matching configurable path/status criteria. * Supports dry-run mode and returns a summary result. * * T12324: every run classifies the whole registry (missing path, temp path, * test path), and an applied run removes the matched rows together with their * `nexus_project_id_aliases` rows and a `nexus_audit_log` receipt in ONE * transaction on the GLOBAL registry store โ€” the store `--vacuum` compacts. * * T12471: a matched row whose path is gone but whose id is found at another * path on this device is a MOVED project, not an orphan. It is never removed * (whatever criterion matched it); it is reported under `relocated` with the * `cleo doctor projects` remedy that rebinds it by id. A path is gone only * when the tri-state probe answers `no`; an unreadable one (EACCES, EPERM, * timeout) is never removed and is reported under `unreadable`. * * T12336: a row whose `project_path` is a cloud vault placeholder (a project * that lives only on another machine) is neither probed nor removed. * * @task T1473 * @task T12324 * @task T12471 */ import type { NexusProjectsCleanResult } from '@cleocode/contracts'; import { type EngineResult } from '../engine-result.js'; /** Thrown when no filter criteria are provided to cleanProjects. */ export declare class NoCriteriaError extends Error { /** @override */ readonly name = "NoCriteriaError"; constructor(); } /** Thrown when --pattern is not a valid JS regex. */ export declare class InvalidPatternError extends Error { /** @override */ readonly name = "InvalidPatternError"; constructor(pattern: string, cause: unknown); } /** Options for {@link cleanProjects}. */ export interface CleanProjectsOptions { /** When true, perform a dry-run scan only โ€” no deletions. */ dryRun: boolean; /** JS regex pattern matched against project_path. */ pattern?: string; /** Match paths containing a .temp/ segment or under the OS temp directory (T12324). */ includeTemp?: boolean; /** Match paths containing tmp/test(s)/__tests__/fixture(s)/scratch/sandbox segments. */ includeTests?: boolean; /** Match rows where health_status is 'unhealthy'. */ matchUnhealthy?: boolean; /** Match rows where last_indexed IS NULL. */ matchNeverIndexed?: boolean; /** Match rows whose project_path no longer exists on disk (T9117). */ matchOrphaned?: boolean; /** * Match rows that are path-divergent duplicates of the same canonical * project (T9149 W5 pollution cleanup). Groups rows by canonicalProjectId * and flags all but the most-recently-indexed one as polluted. */ matchPolluted?: boolean; /** After DB delete, `rm -rf` each matched path that still exists on disk (T9117). */ removeFs?: boolean; /** After delete, VACUUM the GLOBAL registry store to reclaim space (T9117 ยท T12324). */ vacuum?: boolean; /** * When matchPolluted is set and dryRun is false, write an audit JSONL to * /nexus-cleanup-.jsonl before deletion (T9149). */ auditLog?: boolean; } /** Result envelope for {@link cleanProjects} (contract: `NexusProjectsCleanResult`). */ export type CleanProjectsResult = NexusProjectsCleanResult; /** * Bulk-purge project registry rows matching configurable criteria. * * At least one of `pattern`, `includeTemp`, `includeTests`, `matchUnhealthy`, * `matchNeverIndexed`, `matchOrphaned` or `matchPolluted` must be set โ€” * otherwise throws {@link NoCriteriaError}. If `pattern` is set but invalid, * throws {@link InvalidPatternError}. When `dryRun` is true, performs only a * preview scan with no deletions; the classification is reported either way. * * An applied run opens the GLOBAL registry store directly and, in one * transaction, deletes the matched rows, every alias pointing at them, any * pre-existing orphan alias, and writes the audit receipt. * * @param opts - Clean options. * @returns Clean result with match count, classification, and receipt. * @throws {NoCriteriaError} When no filter criteria are provided. * @throws {InvalidPatternError} When `opts.pattern` is not a valid regex. * * @example * const preview = await cleanProjects({ dryRun: true, includeTemp: true }); * console.log(preview.matched, 'projects would be purged'); */ export declare function cleanProjects(opts: CleanProjectsOptions): Promise; export declare function nexusProjectsClean(opts: { dryRun?: boolean; pattern?: string; includeTemp?: boolean; includeTests?: boolean; matchUnhealthy?: boolean; matchNeverIndexed?: boolean; matchOrphaned?: boolean; removeFs?: boolean; vacuum?: boolean; }): Promise>; //# sourceMappingURL=projects-clean.d.ts.map