/** * Shared resolver helpers usable by any GraphLanguageAdapter. * * These tiny utilities used to live duplicated under each lang-* * adapter (`appendEdge`, `pushCreationEdge`, the `MutableStats` * counter shape). The duplicated-function-body rule flagged the * duplication, which is correct — the bodies really are identical * and the rule has no false-positive heuristic that would skip them. * * Putting these in lang-adapter/ keeps them on the contract layer: * adapters already import types from `./types.js`, so importing one * more helper is structurally consistent. The layering rules forbid * lang-* adapters from importing each other but say nothing about * lang-adapter/. */ import type { CallEdge } from '../types.js'; /** Maximum length of a `CallEdge.text` field. Per types.ts contract. */ export declare const CALL_EDGE_TEXT_MAX = 80; /** Prefix prepended to creation-edge text (`[creates] `). */ export declare const CREATION_EDGE_PREFIX = "[creates] "; /** * Maximum length of the inner source-text slice that gets prefixed * with `[creates] ` to form a creation edge. The total edge text * after prefixing is bounded by `CALL_EDGE_TEXT_MAX`. */ export declare const CREATION_EDGE_TEXT_MAX: number; /** * Truncate raw call-site source text to fit within `CallEdge.text`'s * 80-char contract. Long strings get sliced and ellipsized; short * strings pass through unchanged. Single source of truth for the * truncation contract — adapters call this instead of inlining the * length math. */ export declare function truncateForCallEdge(text: string): string; /** * Append a CallEdge to the per-owner edge list, creating the list on * first append. Trivial — but small functions deserve a single home. */ export declare function appendEdge(edgesByOwner: Map, ownerHash: string, edge: CallEdge): void; /** * Per-confidence stat counters mutated as edges are appended. Same * shape every adapter resolver assembles inline; consolidated here * with an `apply(edge)` method that classifies and bumps the right * counter so resolvers don't repeat the if-ladder. * * Use {@link createMutableStats} for a fresh zeroed instance. */ export interface MutableStats { totalCallSites: number; resolvedHigh: number; resolvedMedium: number; resolvedLow: number; unresolved: number; /** * Classify `edge` by its `to.length` and `confidence` and bump the * matching counter. Does NOT touch `totalCallSites` — call sites * include unresolved-by-shape decisions that don't always produce * an edge, so call-site counting stays the resolver's job. */ apply(edge: CallEdge): void; } /** * The two output accumulators a resolver threads through edge emission: * the per-owner edge map and the running confidence stats. Grouping them * names the "resolution output" a resolver allocates once per pass and * keeps the edge-push helpers (and the adapter `pushCallEdge` functions) * under the wide-function parameter budget. */ export interface EdgeSink { /** Per-owner-hash edge list, appended via {@link appendEdge}. */ readonly edgesByOwner: Map; /** Running per-confidence counters, bumped as edges are appended. */ readonly stats: MutableStats; } /** Constructs a fresh {@link MutableStats} accumulator for edge resolver bookkeeping. */ export declare function createMutableStats(): MutableStats; /** * Position info every adapter must derive from its node/file pair to * build a CallEdge. Adapters supply this via the `position` callback * to {@link pushCreationEdge}, keeping the helper agnostic to the * underlying parser shape (TS Node + SourceFile, tree-sitter Node + * source string, etc.). */ export interface EdgePosition { /** 1-based line number. */ readonly line: number; /** 0-based column. */ readonly column: number; /** Source text of the call site, untruncated. */ readonly text: string; } /** * Append a synthetic creation edge — the parent owner contains an * inline-callable child, so its enclosing scope's reachability flows * to the child unconditionally. Static, high-confidence by * construction. * * Parser-agnostic: the caller resolves the call site's {@link EdgePosition} * (the only thing the helper needs from the adapter's node/file pair) and * passes it in, so this helper never touches a parser-specific node shape. * Bumps `totalCallSites` and `resolvedHigh` on the sink's stats. */ export declare function pushCreationEdge(pos: EdgePosition, ownerHash: string, childHash: string, sink: EdgeSink): void; //# sourceMappingURL=edge-helpers.d.ts.map