/**
 * pipeline/mirror-repo-tasks.ts
 *
 * Mirrors repo-based TaskDefinitions into the Sanity Content Lake as
 * ailf.task documents with origin provenance. This makes the Content Lake
 * the universal registry — every task (native or repo-sourced) is visible
 * in Studio.
 *
 * The mirror is idempotent: deterministic document IDs + content hashing
 * means unchanged tasks are skipped. Changed tasks are upserted via
 * createOrReplace.
 *
 * @see docs/archive/exec-plans/tasks-as-content/phase-5-content-lake-mirroring.md
 */
import type { SanityClient } from "@sanity/client";
import { type LiteracyTaskDefinition, type Logger } from "../_vendor/ailf-core/index.d.ts";
export interface MirrorOptions {
    /**
     * Sanity client targeting the AILF private dataset — used to write
     * `ailf.task` and `ailf.featureArea` documents and to read existing
     * mirror state. Per D0043, AILF docs live in `ailf-prod-private`.
     */
    client: SanityClient;
    /**
     * Sanity client targeting the editorial dataset — used to resolve
     * `article` slugs to document IDs for canonical-doc references. After
     * the dataset split, the AILF client cannot see editorial documents,
     * so this must be a separate client (or omitted to skip slug resolution).
     */
    editorialClient?: SanityClient;
    /** Tasks to mirror (already loaded from repo) */
    tasks: LiteracyTaskDefinition[];
    /** Git context for origin provenance */
    git: GitContext;
    /** If true, log what would be done without writing */
    dryRun?: boolean;
    /** Logger instance (defaults to ConsoleLogger) */
    logger?: Logger;
}
/** Authorship info extracted from git context or GitHub Actions environment. */
export interface GitAuthor {
    /** Git commit author name (e.g., "Jordan Smith") */
    gitName?: string;
    /** Git commit author email (e.g., "jordan@example.com") */
    gitEmail?: string;
    /** GitHub username (from GITHUB_ACTOR or event payload) */
    githubUsername?: string;
}
export interface GitContext {
    /** Full repo identifier (e.g., "sanity-io/visual-editing") */
    repo: string;
    /** Repo owner (e.g., "sanity-io") */
    owner: string;
    /** Repo name (e.g., "visual-editing") */
    name: string;
    /** Current branch */
    branch: string;
    /** HEAD commit SHA */
    commitSha: string;
    /** Author of the current commit/trigger */
    author: GitAuthor;
}
export interface MirrorResult {
    /** Total tasks processed */
    total: number;
    /** Tasks created or updated */
    upserted: number;
    /** Tasks skipped (unchanged) */
    skipped: number;
    /** Feature areas auto-created */
    areasCreated: string[];
    /** Context doc slugs that failed to resolve */
    unresolvedSlugs: string[];
    /** Errors (non-fatal — mirror continues) */
    errors: string[];
}
/**
 * Mirror repo tasks to the Content Lake.
 *
 * For each task:
 * 1. Compute deterministic document ID
 * 2. Compute content hash of the task definition
 * 3. Check if mirror document exists with same hash → skip if unchanged
 * 4. Resolve context doc slugs → Sanity references
 * 5. Auto-create feature areas if needed
 * 6. Upsert the ailf.task document with origin block
 */
export declare function mirrorRepoTasks(options: MirrorOptions): Promise<MirrorResult>;
/**
 * Detect git context from GitHub Actions environment variables,
 * falling back to git CLI commands.
 */
export declare function detectGitContext(repoTasksPath: string): Promise<GitContext>;
/**
 * Deterministic mirror document ID.
 *
 * Format: ailf.task.mirror.<owner>.<repo>.<taskId>
 *
 * Dots in owner/repo/taskId are replaced with hyphens to avoid
 * Sanity document ID issues.
 */
export declare function mirrorDocId(owner: string, repo: string, taskId: string): string;
/**
 * Compute a content hash of a LiteracyTaskDefinition for change detection.
 *
 * Includes all fields that affect the mirror document. Excludes
 * runtime metadata like referenceSolution (filesystem path) since
 * that's not mirrored.
 */
export declare function computeTaskHash(task: LiteracyTaskDefinition): string;
/** @internal Exported for testing — not part of the public API. */
export declare function buildMirrorDocument(task: LiteracyTaskDefinition, opts: {
    contentHash: string;
    docId: string;
    /** Existing author from the current mirror document (write-once preservation) */
    existingAuthor?: GitAuthor;
    git: GitContext;
    slugToDocId: Map<string, string>;
}): {
    baseline?: {
        rubric?: "full" | "abbreviated" | "none" | undefined;
        enabled?: boolean | undefined;
    } | undefined;
    _id: string;
    _type: string;
    ownership: string;
    status: import("@sanity/ailf-core").TaskStatus;
    assertions: Record<string, unknown>[];
    contextDocs: ({
        _key: string;
        reason: string;
    } | {
        refType: string;
        path: string;
        _key: string;
        reason: string;
    } | {
        doc?: import("@sanity/ailf-shared").EditorialReference | undefined;
        docId?: string | undefined;
        refType: string;
        _key: string;
        reason: string;
    } | {
        refType: string;
        perspective: string;
        _key: string;
        reason: string;
    })[];
    title: string;
    docCoverage: boolean;
    area: {
        _ref: string;
        _type: string;
    };
    id: {
        _type: string;
        current: string;
    };
    origin: {
        branch: string;
        commitSha: string;
        contentHash: string;
        lastSyncedAt: string;
        path: string;
        repo: string;
        repoName: string;
        repoOwner: string;
        type: string;
        author: GitAuthor;
        lastEditor: GitAuthor;
    };
    promptText: string;
};
