/**
 * studiograph admin migrate-asset-owners — one-time owner rewrite for the
 * assets-referenced-not-owned model (P1).
 *
 * Rewrites every `assets.db` row whose owner is an ENTITY (owner_type outside
 * {folder, workspace}) to a folder asset of its current repo:
 * owner_type='folder', owner_id=<repo>. After this, assets are uniformly
 * library citizens — entries only ever REFERENCE them (via the immutable
 * /api/assets/{assetId}/{filename} URL), never own them.
 *
 * Safety:
 *   - `--dry-run`: reports the per-repo breakdown + counts, writes nothing.
 *   - Idempotent: the rewrite matches only entity-owned rows, so a second run
 *     is a no-op (0 rows).
 *   - Blobs untouched: immutable keys are repo-independent; this is an
 *     index-row-only UPDATE. Fully reversible, no blob moves.
 *   - Orphan-owner rows (owner entity already deleted) home to the repo like
 *     any other row — they surface as library assets, never deleted.
 *   - Verification: COUNT(*) of remaining entity-owned rows must be 0 after a
 *     real run; a non-zero count exits 1. The same query (run per workspace)
 *     gates the P1.5 dead-code delete (cleanupOwnedAssets, keepAssets, the
 *     free-standing route guards).
 *
 * Per-workspace: run on each serving instance (assets.db is volume-local),
 * like `admin migrate-assets`.
 */
import { Command } from 'commander';
import type { AssetIndexService } from '../../../services/assets/asset-index-service.js';
export interface OwnerMigrationReport {
    /** Entity-owned rows found before the rewrite (sum of the breakdown). */
    entityOwned: number;
    /** Rows actually rewritten (0 in dry-run). */
    rewritten: number;
    /** Entity-owned rows remaining after the run — the verification count.
     *  Must be 0 after a real run; equals `entityOwned` in dry-run. */
    remaining: number;
    /** Per-(repo, owner_type) breakdown of the rows found. */
    breakdown: Array<{
        repo: string;
        ownerType: string;
        count: number;
    }>;
    /** Repos referenced by entity-owned rows but absent from workspace config.
     *  Their rows still rewrite (to a folder that no listing iterates) — they
     *  were already unreachable pre-migration; this surfaces them for ops at
     *  the one moment they're all enumerated. */
    unknownRepos: string[];
}
/**
 * Core migration — decoupled from clack/Workspace so it's unit-testable with
 * a real AssetIndexService over a temp workspace. Index-only; never touches
 * blobs or markdown.
 */
export declare function runAssetOwnerMigration(assetIndex: AssetIndexService, dryRun: boolean, knownRepos?: Set<string>): OwnerMigrationReport;
export declare const adminMigrateAssetOwnersCommand: Command;
