/** * CrossPassEdgeMerger — Phase 2 of slice-topology-multipass (W2 T7). * * Produces `CrossPassEdge`s that span two adjacent decomposition passes by * combining fast structural detectors with the `LLMArbitrator` fallback. * * Pipeline (per adjacent pass pair `(upper, lower)`): * 1. Build a `path → upperSliceId` index of every file owned by `upper`. * 2. For each lower slice, for each file in that slice: * a. type-shares — `import type { ... } from '...'` resolves to an upper file. * b. import-re-export — `export ... from '...'` resolves to an upper file. * c. fixture-shares — file is a test file AND `from '...'` resolves to an upper file. * Each match emits one `CrossPassEdge` with `confidence: 'structural'` and * `arbitratedBy: null`. * 3. If a lower slice emitted NO static edges AND `opts.llmRunner` is provided AND * `llmCalls.length < opts.maxLlmCalls`, invoke `arbitrate(...)` once. On a * successful `{"depends": true}` response, emit one edge with * `kind: 'llm-arbitrated'`, `confidence: 'llm'`, and `arbitratedBy: `. * 4. The budget is `opts.maxLlmCalls ?? 2`; once exhausted the merger returns * what it has accumulated and never crashes. * * Pass 3 is reserved for future use; the type allows `passNumber: 3` but v1 input * never contains it. Pairs are processed left-to-right so edges are deterministic. */ import type { CrossPassEdge, LlmConfidence, PassResult } from './slice-topology-types.js'; import type { LlmRunner } from '../audit/audit-goal-service.js'; export interface MergeResult { readonly edges: readonly CrossPassEdge[]; readonly llmCalls: readonly LlmCallTrace[]; } export interface MergeOptions { readonly projectRoot: string; readonly llmRunner?: LlmRunner; readonly cacheDir?: string; readonly maxLlmCalls?: number; } /** * Full LLM-call trace captured by `runLlmFallback` for every arbitrator call. * Mirrors v2 `LlmArbitration` minus the non-null `tokens` contract; the * orchestrator coalesces a possible `null` `tokens` to a zeroed pair. */ export interface LlmCallTrace { readonly callId: string; readonly promptHash: string; readonly input: string; readonly output: string; readonly confidence: LlmConfidence; readonly tokens: { readonly input: number; readonly output: number; } | null; } export declare function merge(passes: readonly PassResult[], opts: MergeOptions): Promise;