/**
 * Priority Service - Dependency-based priority calculation and complexity inheritance
 *
 * Provides:
 * - Effective Priority: Computes a task's priority based on what depends on it
 *   (tasks blocking high-priority work inherit that urgency)
 * - Aggregate Complexity: Computes total effort including dependent task complexity
 */
import type { StorageBackend } from '@stoneforge/storage';
import type { ElementId, Task, Priority, Complexity } from '@stoneforge/core';
/**
 * Result of effective priority calculation
 */
export interface EffectivePriorityResult {
    /** The task's own/explicit priority */
    basePriority: Priority;
    /** The computed effective priority (may be higher due to dependents) */
    effectivePriority: Priority;
    /** IDs of high-priority tasks that depend on this task */
    dependentInfluencers: ElementId[];
    /** Whether the effective priority differs from base priority */
    isInfluenced: boolean;
}
/**
 * Result of aggregate complexity calculation
 */
export interface AggregateComplexityResult {
    /** The task's own complexity */
    baseComplexity: Complexity;
    /** Total complexity including blocked dependencies */
    aggregateComplexity: number;
    /** Number of dependent tasks included in calculation */
    dependentCount: number;
    /** Breakdown by dependency */
    dependentComplexities: Array<{
        id: ElementId;
        complexity: Complexity;
    }>;
}
/**
 * Task with calculated priority and complexity
 */
export interface TaskWithEffectivePriority extends Task {
    /** Computed effective priority based on dependents */
    effectivePriority: Priority;
    /** Whether this task's priority was influenced by dependents */
    priorityInfluenced: boolean;
    /** Aggregate complexity including dependent tasks */
    aggregateComplexity?: number;
}
/**
 * Configuration for priority calculation
 */
export interface PriorityCalculationConfig {
    /** Maximum depth for traversing dependency chain (default: 10) */
    maxDepth: number;
    /** Whether to include complexity aggregation (default: false) */
    includeComplexity: boolean;
}
/**
 * Default priority calculation configuration
 */
export declare const DEFAULT_PRIORITY_CONFIG: PriorityCalculationConfig;
/**
 * Service for computing dependency-based priority and complexity
 */
export declare class PriorityService {
    private readonly db;
    constructor(db: StorageBackend);
    /**
     * Calculate the effective priority of a task based on its dependents.
     *
     * A task that blocks high-priority tasks should inherit that urgency.
     * The effective priority is the minimum (highest urgency) of:
     * - The task's own priority
     * - The priorities of all tasks that directly or transitively depend on it
     *
     * @param taskId - The task to calculate effective priority for
     * @param config - Optional configuration
     * @returns EffectivePriorityResult with calculation details
     */
    calculateEffectivePriority(taskId: ElementId, config?: PriorityCalculationConfig): EffectivePriorityResult;
    /**
     * Calculate effective priorities for multiple tasks efficiently
     *
     * @param taskIds - Array of task IDs to calculate priorities for
     * @param config - Optional configuration
     * @returns Map of taskId to EffectivePriorityResult
     */
    calculateEffectivePriorities(taskIds: ElementId[], config?: PriorityCalculationConfig): Map<ElementId, EffectivePriorityResult>;
    /**
     * Calculate the aggregate complexity of a task including its blockers.
     *
     * This represents the total effort needed before this task can be considered
     * truly "done" - including all tasks it's waiting on.
     *
     * Note: This calculates complexity of tasks that THIS task depends on (blockers),
     * not tasks that depend on it.
     *
     * @param taskId - The task to calculate aggregate complexity for
     * @param config - Optional configuration
     * @returns AggregateComplexityResult with calculation details
     */
    calculateAggregateComplexity(taskId: ElementId, config?: PriorityCalculationConfig): AggregateComplexityResult;
    /**
     * Enhance an array of tasks with effective priority (for sorting)
     *
     * @param tasks - Array of tasks to enhance
     * @param config - Optional configuration
     * @returns Array of tasks with effectivePriority field
     */
    enhanceTasksWithEffectivePriority(tasks: Task[], config?: PriorityCalculationConfig): TaskWithEffectivePriority[];
    /**
     * Sort tasks by effective priority (highest priority first)
     *
     * @param tasks - Array of tasks with effective priority
     * @returns Sorted array (mutates in place and returns reference)
     */
    sortByEffectivePriority(tasks: TaskWithEffectivePriority[]): TaskWithEffectivePriority[];
    /**
     * Get a task's priority and complexity from the database
     */
    private getTaskPriority;
    /**
     * Collect priorities of all tasks that depend on a given task (transitively).
     *
     * blockedId = the element waiting, blockerId = the element doing the blocking.
     * To find tasks blocked by current.id, query WHERE blocker_id = current.id,
     * then read blocked_id to get the dependent tasks.
     */
    private collectDependentPriorities;
    /**
     * Collect complexities of all tasks that this task depends on (blockers, transitively).
     *
     * blockedId = the element waiting, blockerId = the element doing the blocking.
     * To find tasks that block current.id, query WHERE blocked_id = current.id,
     * then read blocker_id to get the blocking tasks.
     */
    private collectBlockerComplexities;
}
/**
 * Create a new PriorityService instance
 */
export declare function createPriorityService(db: StorageBackend): PriorityService;
//# sourceMappingURL=priority-service.d.ts.map