import type { ContextPackCoverage, ContextPackExecutionPhase, ContextPackExecutionSlice, ContextPackExpandableRef, ContextPackRuntimeGenerationAnswerContract, ContextPackTaskContract, ContextPackTaskKind } from '../../contracts/context-pack.js'; import type { RetrievalGateDecision, RetrievalLevel } from '../../contracts/retrieval-gate.js'; import type { TaskIntentKind } from '../../contracts/task-intent.js'; import { type PipelineStageDiagnostic, type PipelineStageObserver } from '../../core/pipeline/stage.js'; import { type QueryEvidenceCoverage, type QueryEvidenceNode } from './conceptual-fallback.js'; export type RetrievalPipelineStage = 'query_interpretation' | 'seed_generation' | 'structural_expansion' | 'candidate_ranking' | 'evidence_planning' | 'budgeted_packing' | 'recovery_answerability'; export type RetrievalStageDiagnostic = PipelineStageDiagnostic; export type RetrievalStageObserver = PipelineStageObserver; export declare const tokenizeQuestion: (question: string) => string[]; export declare const tokenizeLabel: (label: string) => string[]; export declare const tokenMatchCount: (questionToken: string, labelTokens: readonly string[]) => number; export interface RetrievalQueryStageInput { question: string; budget: number; taskKind?: ContextPackTaskKind; taskIntent?: TaskIntentKind; retrievalLevel?: RetrievalLevel; } export interface RetrievalQueryStageOutput { question_tokens: string[]; retrieval_gate: RetrievalGateDecision; effective_retrieval_level: RetrievalLevel; task_contract: ContextPackTaskContract; } export declare const interpretRetrievalQuery: (input: RetrievalQueryStageInput) => RetrievalQueryStageOutput; export declare const runRetrievalQueryStage: (input: RetrievalQueryStageInput, observer?: RetrievalStageObserver) => RetrievalQueryStageOutput; export interface RetrievalEvidencePlanInput { taskContract?: ContextPackTaskContract; coverage?: ContextPackCoverage; expandable?: readonly ContextPackExpandableRef[]; executionSlice?: ContextPackExecutionSlice; answerContract?: ContextPackRuntimeGenerationAnswerContract; missingPhases?: readonly ContextPackExecutionPhase[]; coveredWorkflowOwners?: readonly string[]; selectedNodeCount?: number; selectedRelationshipCount?: number; question?: string; matchedNodes?: readonly QueryEvidenceNode[]; } /** Explicit boundary consumed by answerability; it contains evidence facts, never ranking scores. */ export interface RetrievalEvidencePlan { version: 1; task_contract?: ContextPackTaskContract; coverage?: ContextPackCoverage; expandable: ContextPackExpandableRef[]; execution_slice?: ContextPackExecutionSlice; answer_contract?: ContextPackRuntimeGenerationAnswerContract; missing_phases: ContextPackExecutionPhase[]; covered_workflow_owners: string[]; selected_node_count: number; selected_relationship_count: number; query_evidence?: QueryEvidenceCoverage; } export type RetrievalCandidateStage = 'seed_generation' | 'structural_expansion' | 'candidate_ranking'; export interface RetrievalCandidateStageInput { candidate_count: number; } export interface RetrievalCandidateStageOutput { candidate_count: number; warning_count?: number; } export interface RetrievalCandidateStageBoundary { complete(output: RetrievalCandidateStageOutput): void; fail(warningCount?: number): void; } export declare const runRetrievalCandidateStage: (stage: RetrievalCandidateStage, input: RetrievalCandidateStageInput, execute: () => TOutput, observer?: RetrievalStageObserver) => TOutput; export declare const startRetrievalCandidateStage: (stage: RetrievalCandidateStage, input: RetrievalCandidateStageInput, observer?: RetrievalStageObserver) => RetrievalCandidateStageBoundary; export interface RetrievalPackingStageInput { candidate_count: number; } export interface RetrievalPackingStageOutput { nodes: readonly unknown[]; } export declare const runRetrievalPackingStage: (input: RetrievalPackingStageInput, execute: () => TOutput, observer?: RetrievalStageObserver) => TOutput; export interface RetrievalRecoveryStageInput { selected_node_count: number; } export interface RetrievalRecoveryStageOutput { selected_node_count: number; insufficient: boolean; } export interface RetrievalRecoveryStageBoundary { complete(output: RetrievalRecoveryStageOutput): void; fail(): void; } export declare const startRetrievalRecoveryStage: (input: RetrievalRecoveryStageInput, observer?: RetrievalStageObserver) => RetrievalRecoveryStageBoundary; export declare const buildRetrievalEvidencePlan: (input: RetrievalEvidencePlanInput) => RetrievalEvidencePlan; export interface RetrievalEvidenceResultLike { question?: string; task_contract?: ContextPackTaskContract; coverage?: ContextPackCoverage; expandable?: readonly ContextPackExpandableRef[]; execution_slice?: ContextPackExecutionSlice; answer_contract?: ContextPackRuntimeGenerationAnswerContract; matched_nodes: ReadonlyArray; relationships: readonly unknown[]; } export declare const buildRetrievalEvidencePlanFromResult: (result: RetrievalEvidenceResultLike) => RetrievalEvidencePlan; export declare const runRetrievalEvidencePlanningStage: (input: RetrievalEvidencePlanInput, observer?: RetrievalStageObserver) => RetrievalEvidencePlan;