import { type GitRepository } from "../utils/git"; export declare const REPOSITORY_BINDING_SCHEMA: "gjc.repository_binding.v1"; export interface RepositoryBinding { schema: typeof REPOSITORY_BINDING_SCHEMA; /** Canonical realpath of the git worktree root (or resolved cwd root). */ worktreeRoot: string; /** Git common dir realpath when available; null outside a git checkout. */ commonDir: string | null; /** Optional repo-relative subdirectory the lane should operate under. */ relativeSubdir?: string; /** Optional display path (may be non-canonical); never used for authority. */ displayPath?: string; /** Optional baseline HEAD at capture time. */ head?: string; /** Optional branch name at capture time (when not detached). */ branch?: string; } export type RepositoryBindingErrorCode = "not_a_repository" | "identity_mismatch" | "path_outside_root" | "invalid_binding"; export declare class RepositoryBindingError extends Error { readonly code: RepositoryBindingErrorCode; constructor(code: RepositoryBindingErrorCode, message: string); } /** Capture a durable binding from the active cwd/worktree. */ export declare function captureRepositoryBinding(cwd: string, options?: { relativeSubdir?: string; displayPath?: string; }): Promise; /** Parse a binding from JSON/plan payload; fail closed on malformed shapes. */ export declare function parseRepositoryBinding(value: unknown): RepositoryBinding; /** True when two bindings refer to the same repository identity (linked worktrees ok). */ export declare function repositoryBindingsMatch(left: RepositoryBinding, right: RepositoryBinding): boolean; /** * Ensure `cwd` is inside the bound repository (or the same linked worktree family). * Fails closed on sibling-repo drift. */ export declare function assertCwdMatchesRepositoryBinding(cwd: string, binding: RepositoryBinding): Promise; /** Ensure a declared target path resolves under the bound worktree root. */ export declare function assertPathUnderRepositoryBinding(binding: RepositoryBinding, targetPath: string): string; /** * Public identity snapshot for receipts/handoffs (no display-only fields required). * Always includes the schema + durable roots so downstream lanes can re-verify. */ export declare function publicRepositoryBinding(binding: RepositoryBinding): RepositoryBinding; /** * Resolve the authoritative binding for a delegated task before discovery/spawn. * * - Missing declaration → stamp from session cwd (never leave authority implicit). * - Declared binding → parse + fail closed unless it matches the active session worktree. * - relativeSubdir (when present) must resolve under the bound root. */ export declare function resolveTaskRepositoryBinding(sessionCwd: string, declared: unknown | undefined): Promise; /** * Ensure an execution/isolation root (cwd or worktree) still matches the bound identity. * Used after isolation workspace creation so linked worktrees keep the source repository. */ export declare function assertExecutionRootMatchesRepositoryBinding(executionRoot: string, binding: RepositoryBinding): Promise; /** Optional helper for tests and diagnostics. */ export declare function bindingFromGitRepository(repository: GitRepository, options?: { relativeSubdir?: string; displayPath?: string; head?: string; branch?: string; }): RepositoryBinding;