import { type ClassificationLabel, type LedgerEntry } from "./ledger.js"; /** * v0.5 §6.5 — applier. Backup → apply → verify → rollback chain. Reuses * the v0.2.3 backup framework conceptually (snapshot a directory tree, * restore on failure) but parameterized for *repo-level* onboarding rather * than workspace-level migration. The snapshot root is * `~/.solosquad-backups/-repo-onboard/` per spec. * * Verification calls the injected `verify` hook (the CLI wires it to * `rebuildRoutes()` from agent-router.js). On any failure during apply, * the backup is restored and the original ledger left intact. */ export type MergePolicy = "append" | "override" | "replace"; export interface ApplyOpts { repo_root: string; org_slug: string; workspace_root: string; /** Optional override of the user-global agents dir (testing). */ user_global_dir?: string; /** Optional override of the backup root (testing). */ backup_root?: string; /** Merge policy for role-label files landing in user-global agents (§6.5). */ merge_policy?: MergePolicy; /** * Injected verifier. Called after applying. If it throws or returns * `{ ok: false }`, the applier rolls back automatically. */ verify?: () => { ok: boolean; error?: string; }; /** Override now() for deterministic backup folder names in tests. */ now?: () => Date; } export interface ApplyResult { applied_count: number; skipped_count: number; backup_dir: string; destinations: { path: string; destination: string; label: ClassificationLabel; }[]; rolled_back: boolean; error?: string; } export declare function inferTeam(filename: string): string; export declare function inferAgentSlug(filename: string): string; /** * Compute the destination path for one ledger entry per §6.5 / §6.2 v0.5 * temporary column. Note: codebase-fact returns `null` because the file * stays in the repo and no move is needed. */ export declare function destinationFor(entry: LedgerEntry, ctx: { workspace_root: string; org_slug: string; user_global_dir: string; }): string | null; export declare function applyReport(opts: ApplyOpts): Promise; export declare function rollbackBackup(backupDir: string): void;