/** * discover-pipeline — pipeline orchestration and reporting helpers for the * discover command group (#434). * * Extracted from discover.ts: breadth assessment, semantic demand-relevance * filtering, and demand-relevant source selection. Pure helpers only — the * CLI dispatch stays in discover.ts. */ import type { getRuntimeConfig } from "./config/runtime.js"; import type { AssetCatalogEntry, DemandProfile, SelectionRegistry, SelectionReport, SourceDefinition, SourceIndex } from "./types.js"; /** * Harvests the catalog entries for one non-repo source. Repo sources run * through a separate bounded batch loop in discover.ts; every other * SourceKind member is dispatched here (exhaustiveness-checked). * * ard-registry sources are indexed (cursor-based) coverage: when sync has * not populated the index yet, there is nothing to harvest locally. This is * a live state (an enabled ard source before its first sync), not an * invariant violation — surface it instead of failing or skipping silently. */ export declare function harvestCatalogSourceEntries(source: SourceDefinition, sourceKind: Exclude, demandProfile: DemandProfile | null, selectionRegistry: SelectionRegistry, projectRoot: string): Promise; /** * Builds the stratified rejection sample: one representative per distinct * rejection reason (Pass 1), then tops up to `sampleSize` with the earliest * un-sampled entries (Pass 2). Membership checks use object references so * they stay O(1). * * The Pass-1 cap bounds the sample when the distinct-reason count exceeds * `sampleSize` — today the reason vocabulary is closed (3 kinds), but the * guard protects future rejection kinds and is exercised directly by tests * with >sampleSize distinct reasons. */ export declare function buildStratifiedRejectionSample(rejectionLog: T[], sampleSize: number): T[]; /** * Summarizes and assesses a breadth discovery pass: prints the demand-signal * count, indexed source count, operational source count, and the bottleneck * assessment with next steps. When `previousCatalogEntryCount` is provided * the catalog line also reports how the pool changed versus the prior pass. */ export declare function printDiscoveryBreadthSummary(input: { demandProfile: DemandProfile; sourceIndex: SourceIndex; enabledSources: SourceDefinition[]; catalogEntries: AssetCatalogEntry[]; selectionReport: SelectionReport; previousCatalogEntryCount?: number | null; }): void; declare function formatCatalogEntryDelta(current: number, previous: number): string; /** * Exposes breadth-summary helpers for focused tests (the accepted * internals-seam pattern; production behavior does not depend on it). */ export declare const discoverPipelineInternals: { formatCatalogEntryDelta: typeof formatCatalogEntryDelta; }; /** * Prints help for a specific discover subcommand. */ /** * Applies demand-relevance filtering to the catalog, using semantic similarity * scoring when enabled and available, falling back to keyword-overlap gating. * * All scorer branching lives here so `generateSelectionOutputs` stays clean. */ /** * Minimal shape the semantic relevance filter needs from a scorer, so tests * can inject a stub without loading the optional transformers pipeline. */ export interface RelevanceScorer { readonly available: boolean; tryInit(): Promise; filterAndRank(entries: AssetCatalogEntry[], demandProfile: DemandProfile | null): Promise<{ selected: AssetCatalogEntry[]; rejected: AssetCatalogEntry[]; } | null>; } /** * Applies the semantic relevance filter when enabled, falling back to the * keyword demand-relevance gate otherwise. All scorer branching lives here * so `generateSelectionOutputs` stays clean. */ export declare function applyRelevanceFilter(catalogEntries: AssetCatalogEntry[], demandProfile: DemandProfile | null, config: ReturnType, scorerFactory?: (minSimilarity: number) => RelevanceScorer): Promise<{ selectedEntries: AssetCatalogEntry[]; rejectedEntries: AssetCatalogEntry[]; }>; /** * Applies a per-source entry cap to a pre-sorted list of catalog entries. * * Entries are visited in the order provided; the first `maxPerSource` entries * for each `source.sourceId` are kept, and any excess are returned in the * `capped` array so callers can add rejection-log entries. * * @param entries - Pre-sorted selected entries (insertion order preserved). * @param maxPerSource - Maximum entries to retain per unique `source.sourceId`. * @returns `{ kept, capped }` — kept entries in original order; capped entries * as `{ assetId }` objects suitable for rejection logging. */ export declare function applyPerSourceCap(entries: AssetCatalogEntry[], maxPerSource: number): { kept: AssetCatalogEntry[]; capped: Array<{ assetId: string; }>; }; /** * Maximum number of sample rejected entries in SelectionReport.sampleRejected. * Guarantees at least one entry per distinct rejection reason. */ export declare const REJECTION_SAMPLE_SIZE = 20; /** * Returns a human-readable warning when any single source contributes more * than 20% of the provided (already-capped) selected entries. Returns * `undefined` when the set is well-diversified or empty. * * @param cappedEntries - Selected entries after the per-source cap. * @param maxPerSource - The cap value in effect, included in the message so * the operator knows which knob to turn. */ export declare function computeSourceDiversityWarning(cappedEntries: AssetCatalogEntry[], maxPerSource: number): string | undefined; /** * Computes the acceptance rate as a fraction 0–1. * Returns 0 when inputCount is 0 to avoid division by zero. * Rounded to 4 decimal places for diagnostic use. */ export declare function computeAcceptanceRate(inputCount: number, selectedCount: number): number; /** * Maps demand profile technology signals to source IDs that should be synced. * Sources not in the returned set are skipped during sync unless --sync-all is * passed (#419 — demand-based source filtering for faster first-run sync). */ export declare function computeDemandRelevantSourceIds(demandProfile: DemandProfile): ReadonlySet; /** * Returns the IDs of all enabled sources in the source registry. * Used to compute accurate filtered/skipped counts for the demand-based * filtering progress hint (#419). */ export declare function getEnabledSourceIds(projectRoot: string): Promise; export {};