/** * Next-task selection logic — coreTaskNext. * @task T10064 * @epic T9834 */ import type { ScoreTaskContext, Task } from '@cleocode/contracts'; import type { DataAccessor } from '../store/data-accessor.js'; import { type RankedTask } from '../task-tools/score-task-priority.js'; /** * Suggest next task to work on based on priority, phase, age, and deps. * * @param projectRoot - Absolute path to the CLEO project root directory * @param params - Optional scoring configuration * @param params.count - Number of suggestions to return (default: 1) * @param params.explain - When true, include scoring reasons in each suggestion * @param params.brain - Brain pattern scoring (default true). A one-line * "next ready task" hint (stale `cleo current`, a completion's * `nextSuggested`) passes false: no brain store is opened (T12689). * @returns Ranked suggestions with scores and the total number of eligible candidates * * @remarks * Ranks through the shared {@link scoreTask} (via {@link rankReadyTasks}): * the lexicographic D11161 key — priority band, then attested severity (an * unset severity is unknown; nothing is imputed from `kind`), then a bounded * tiebreak (dependency readiness, phase alignment, leverage, age), then * `createdAt`, then id. BRAIN patterns are informational factors only. * `explain` returns every factor. The briefing's `nextTasks` uses the same ranking (T12661). * Candidates retain the active query population; a separate canonical lookup * resolves explicit dependencies, including archived records. Missing/cancelled * prerequisites block selection, and required dependency-read failures propagate. * * @throws Error when required task or dependency evidence cannot be read. * * @example * ```typescript * const { suggestions } = await coreTaskNext('/project', { count: 3, explain: true }); * console.log(suggestions[0].id, suggestions[0].score); * ``` * * @task T4790 */ export declare function coreTaskNext(projectRoot: string, params?: { count?: number; explain?: boolean; brain?: boolean; }): Promise<{ suggestions: Array<{ id: string; title: string; priority: string; phase: string | null; score: number; reasons?: string[]; }>; totalCandidates: number; }>; /** * The phase that earns the phase-alignment bonus: the caller's session focus * phase, else the project's current phase. `cleo next` and the briefing both * resolve it here so they rank identically (T12661). * * @param accessor - Task data accessor. * @returns The phase slug, or null. * @task T12661 */ export declare function resolveRankingPhase(accessor: DataAccessor, cwd?: string): Promise; /** * Rank every READY task — pending, not cancelled, all dependencies satisfied * under the canonical lookup (archived dependencies included) — through the * shared {@link scoreTask}. The single ranking behind `cleo next` and the * briefing's `nextTasks` (T12661). * * @param accessor - Task data accessor (for dependency records outside `allTasks`). * @param allTasks - The active task population. * @param opts - Current phase, optional id scope, `nowMs`, and `projectRoot` * to attach BRAIN success/failure patterns as informational factors * (best-effort; they are not part of the order). * @returns Ranked candidates, how many there were, and the leverage map used. * @task T12661 */ export declare function rankReadyTasks(accessor: DataAccessor, allTasks: readonly Task[], opts: { currentPhase: string | null; scopeTaskIds?: ReadonlySet; projectRoot?: string; /** Clock for the age tiebreak; one instant for the whole ranking. */ nowMs?: number; }): Promise<{ ranked: RankedTask[]; totalCandidates: number; leverage: ReadonlyMap; }>; /** * The ranking context of the live project (T12692): the SAME context * {@link rankReadyTasks} ranks `cleo next` with — dependency statuses from the * canonical lookup, leverage over the active population and the ranking phase * from {@link resolveRankingPhase}. `cleo orchestrate ready` (and so the focus * ready wave), `cleo orchestrate next`, the wave listing, the bootstrap * suggestion, `cleo plan` and the handoff build theirs here, so one fixture * ranks identically on every surface. * * @param accessor - Task data accessor. * @param population - The active task population (`queryTasks({})`); loaded when omitted. * @param opts - Optional phase override, clock, and the project root whose * caller's focus phase ranks (T12501: always pass it — without it the focus * session is resolved from the process cwd, which in a git worktree is the * main checkout). * @returns The scoring context and the dependency lookup it was built from. * @task T12692 */ export declare function loadRankingContext(accessor: DataAccessor, population?: readonly Task[], opts?: { currentPhase?: string | null; nowMs?: number; cwd?: string; }): Promise<{ ctx: ScoreTaskContext; dependencyLookup: Map; population: readonly Task[]; }>; //# sourceMappingURL=task-next.d.ts.map