import { type WorktreeIdentityFields } from "./dispatch-identity.js"; import { type RolePolicyConfig } from "../domain/role-policy.js"; import type { Clock, KernelPaths } from "./types.js"; export interface WorktreeVerifyResult { readonly ok: true; readonly worktree_id: string; readonly worktree_path: string; readonly base_commit: string; readonly git_dir: string; readonly common_git_dir: string; readonly repository: string | null; /** Factory-bound attempt branch — never null on a writable verified worktree. */ readonly branch: string; readonly clean: true; } export type WorktreeFail = { readonly ok: false; readonly reason: string; }; export interface WorktreeAdapter { /** Resolve base commit for this task attempt (factory-bound; not conductor input). */ readonly resolveBaseCommit: (input: { readonly task_id: string; readonly target_attempt: number; readonly source_digest: string | null; }) => string; /** * First-create ensure: inspect exact path; adopt if match; create once if absent. * Must refuse dirty/symlink/wrong HEAD/branch/repo/common-dir. */ readonly ensureExact: (input: { readonly operation_id: string; readonly identity_digest: string; readonly path: string; readonly base_commit: string; readonly task_id: string; readonly target_attempt: number; readonly expected_repository: string | null; readonly expected_branch: string; }) => WorktreeVerifyResult | WorktreeFail; /** * Non-creating live readback for existing effect/completion replay. * Must never create a worktree. Absent/dirty/moved/wrong state fails closed. */ readonly inspectExact: (input: { readonly path: string; readonly base_commit: string; readonly task_id: string; readonly target_attempt: number; readonly expected_repository: string | null; readonly expected_branch: string; /** * Only an already-authoritative task worktree_id may be supplied. * Never pass completion/effect row IDs as expectations (7A.3B.4 §3). */ readonly expected_worktree_id?: string; }) => WorktreeVerifyResult | WorktreeFail; } export declare function attemptWorktreePath(paths: KernelPaths, taskId: string, attempt: number): string; /** Stable factory-bound attempt branch — never caller/model input. */ export declare function attemptWorktreeBranch(taskId: string, attempt: number): string; import { worktreeIntentOpId, worktreeEffectOpId, worktreeCompleteOpId } from "./result-op-ids.js"; export { worktreeIntentOpId, worktreeEffectOpId, worktreeCompleteOpId, }; /** Canonical request identity — sole production form. */ export declare function worktreeRequestIdentity(input: WorktreeIdentityFields): string; /** * Prepare one verified worktree for target attempt after successful advice. * Module-internal / service-bound — not a conductor-facing tool. */ export declare function prepareAttemptWorktree(input: { readonly paths: KernelPaths; readonly clock: Clock; readonly taskId: string; readonly expectedVersion: number; readonly expectedSourceDigest: string; readonly targetAttempt: number; readonly adapter: WorktreeAdapter; readonly policyDigest: string; /** Factory role policy — required for advice revalidation (no default fallback). */ readonly rolePolicy: RolePolicyConfig; }): WorktreeVerifyResult;