/**
 * Hierarchy Reporting Service
 *
 * Handles the hierarchical reporting chain: Workers report to Team Leaders,
 * Team Leaders aggregate and report up to the Orchestrator.
 *
 * Key responsibilities:
 * - Receive worker status reports and route them to the Team Leader
 * - Aggregate multiple worker reports into a single TL report
 * - Generate AggregatedReport format for Orchestrator consumption
 * - Emit hierarchy:report_up events when reports flow upward
 *
 * @module services/hierarchy/hierarchy-reporting
 */
import type { InProgressTask, TaskArtifact, InProgressTaskStatus } from '../../types/task-tracking.types.js';
import type { StatusReport } from '../../types/hierarchy-message.types.js';
import type { EventBusService } from '../event-bus/event-bus.service.js';
/**
 * Aggregated report from Team Leader to Orchestrator.
 * Summarizes the status of all subtasks under a parent goal.
 */
export interface AggregatedReport {
    /** Message type identifier */
    type: 'aggregated_report';
    /** The goal/task that Orchestrator originally delegated */
    parentTaskId: string;
    /** Overall status of the aggregated work */
    overallState: InProgressTaskStatus;
    /** Summary written by Team Leader */
    summary: string;
    /** Per-worker task breakdown */
    subtaskSummary: {
        total: number;
        completed: number;
        failed: number;
        inProgress: number;
        blocked: number;
    };
    /** Key artifacts curated by Team Leader */
    keyArtifacts?: TaskArtifact[];
    /** Issues requiring Orchestrator attention */
    escalations?: string[];
    /** Team Leader's assessment of quality */
    qualityAssessment?: 'pass' | 'partial' | 'fail';
    /** Session name of the reporting Team Leader */
    reportedBy: string;
    /** ISO timestamp of the report */
    timestamp: string;
}
/**
 * A stored worker report awaiting aggregation.
 */
export interface StoredWorkerReport {
    /** The original status report */
    report: StatusReport;
    /** ISO timestamp when received */
    receivedAt: string;
    /** Session name of the worker */
    workerSession: string;
}
/**
 * HierarchyReportingService manages the upward reporting chain.
 * Singleton pattern matching other Crewly services.
 */
export declare class HierarchyReportingService {
    private static instance;
    /** Stored worker reports indexed by parentTaskId */
    private workerReports;
    /** Event bus reference for emitting hierarchy events */
    private eventBus;
    private constructor();
    /**
     * Get the singleton instance of HierarchyReportingService.
     *
     * @returns The singleton instance
     */
    static getInstance(): HierarchyReportingService;
    /**
     * Clear the singleton instance (for testing).
     */
    static clearInstance(): void;
    /**
     * Set the EventBusService reference for emitting events.
     *
     * @param eventBus - The EventBusService instance
     */
    setEventBus(eventBus: EventBusService): void;
    /**
     * Receive a worker's status report and store it for aggregation.
     * Called when a Worker sends a StatusReport to their Team Leader.
     *
     * @param report - The worker's status report
     * @param workerSession - Session name of the reporting worker
     * @param parentTaskId - The parent task ID this report belongs to
     * @returns The stored report entry
     */
    receiveWorkerReport(report: StatusReport, workerSession: string, parentTaskId: string): StoredWorkerReport;
    /**
     * Aggregate all stored worker reports for a parent task and generate
     * an AggregatedReport for the Orchestrator.
     *
     * @param parentTaskId - The parent task to aggregate reports for
     * @param subtasks - All subtasks under this parent task
     * @param tlSummary - Team Leader's summary of the aggregated work
     * @param tlSession - Team Leader's session name
     * @param teamInfo - Team and member info for event emission
     * @returns The aggregated report, or null if no reports exist
     */
    aggregateAndReportUp(parentTaskId: string, subtasks: InProgressTask[], tlSummary: string, tlSession: string, teamInfo?: {
        teamId: string;
        teamName: string;
        memberId: string;
        memberName: string;
    }): AggregatedReport | null;
    /**
     * Generate an AggregatedReport from subtask data.
     * Computes the overall state, subtask summary, and collects key artifacts.
     *
     * @param parentTaskId - The parent task ID
     * @param subtasks - All subtasks under this parent task
     * @param tlSummary - Team Leader's written summary
     * @param tlSession - Team Leader's session name
     * @returns The aggregated report, or null if no subtasks
     */
    generateAggregatedReport(parentTaskId: string, subtasks: InProgressTask[], tlSummary: string, tlSession: string): AggregatedReport | null;
    /**
     * Get stored worker reports for a parent task.
     *
     * @param parentTaskId - The parent task ID
     * @returns Array of stored worker reports
     */
    getWorkerReports(parentTaskId: string): StoredWorkerReport[];
    /**
     * Clear all stored reports (for cleanup/testing).
     */
    clearReports(): void;
    /**
     * Serialize an AggregatedReport to markdown for PTY delivery.
     *
     * @param report - The aggregated report to serialize
     * @returns Markdown-formatted string with [AGGREGATED REPORT] header
     */
    serializeAggregatedReport(report: AggregatedReport): string;
    /**
     * Compute the subtask summary counts from task list.
     */
    private computeSubtaskSummary;
    /**
     * Determine the overall state from subtask summary.
     */
    private computeOverallState;
    /**
     * Collect key artifacts from completed subtasks.
     */
    private collectKeyArtifacts;
    /**
     * Assess overall quality from subtask completion rates.
     */
    private assessQuality;
}
//# sourceMappingURL=hierarchy-reporting.service.d.ts.map