export type TaskBaseSource = 'record' | 'project' | 'folder' | 'repo-default'; export interface TaskBaseRecord { taskId: string; /** The linked folder this record belongs to (a moved project gets a new one). */ folder: string; /** `/` — the branch the work is delivered on. */ branch: string; /** The branch this task STARTED from (the ref every run pulls). */ base: string; /** Which input produced `base` when it was recorded. */ source: TaskBaseSource; createdAt: string; updatedAt: string; /** How many runs have used this record. */ runs: number; } export interface TaskBasePlan { taskId: string; /** The branch the tree is put ON and the work is delivered on. */ branch: string; /** * The ref to merge into the branch before the agent starts, so the run works * against current state. Null when nothing could be resolved. */ pullFrom: string | null; baseSource: TaskBaseSource; /** `record` = this task already has a branch/base on this machine. */ branchSource: 'record' | 'derived'; /** True when at least one of the two refs already exists on this machine. */ branchExists: boolean; /** The recorded base, when the record's base no longer resolves. */ staleBase?: string; } /** Absolute path of a task's record file. */ export declare function taskBasePath(taskId: string): string; /** The record for a task ON THIS FOLDER, or null. Never throws. */ export declare function readTaskBase(taskId: string, folder: string): TaskBaseRecord | null; /** Every record on this machine, newest first. Never throws. */ export declare function listTaskBases(): TaskBaseRecord[]; /** Drop records whose task has not run in `TASK_BASE_TTL_MS`. Never throws. */ export declare function pruneTaskBases(now?: number): number; /** * Resolve a recorded base inside a SPECIFIC repo (a multi-repo mirror shares one * base NAME across repos that each have their own remotes). * * Accepts both `staging` and `origin/staging`, prefers the remote-tracking ref, * and returns null when neither exists HERE — in which case the repo is simply * not updated, rather than being merged with an unrelated branch. */ export declare function resolveBaseRefIn(repo: string, base: string): string | null; /** * Decide the branch, the start point and the pull for one task. * * Pure decision-making: it reads git refs and the record, writes nothing. Both * `createIsolationMirror` and the repair call it, which is the whole point — * there is no second opinion anywhere in the bridge. */ export declare function planTaskBase(opts: { folder: string; taskId: string; projectSlug?: string | null; taskTitle?: string | null; /** Hub-assigned branch name (orchestrator/chain); wins over the derivation. */ deliverableBranch?: string | null; /** * The branch this task already DELIVERED on, recorded by the hub after a * guarded rename to an agent-proposed name (2026-12). It outranks the local * record: the record was written before the rename and would send a retry * back to the pre-rename branch, which no longer holds the delivered work. */ deliveryBranch?: string | null; /** Project-wide base branch from TeamShare settings. */ configuredBase?: string | null; }): TaskBasePlan; /** * Persist the plan for this task. Called ONCE per successful tree creation. * * The BASE is written once and then kept: it is "the branch this task started * from", and a later project-setting change must not silently re-point an * in-flight task's updates at another branch. Only a base that no longer * resolves is replaced (self-heal), which `planTaskBase` reports as * `staleBase`. */ export declare function recordTaskBase(opts: { folder: string; plan: TaskBasePlan; /** The base the tree was ACTUALLY cut/synced from (per the mirror marker). */ actualBase?: string | null; }): TaskBaseRecord | null;