/** * Personalized PageRank (random-walk-with-restart) over the in-memory call graph. * Change: add-personalized-pagerank-context-ranking. * * "Of the functions connected to this task, which are most relevant?" — answered as * a QUERY-CONDITIONED retrieval ranking, seeded by the task's matched symbols. It is * NOT a global, task-independent salience score (the `add-structural-landmark-salience` * decision still governs that; this adds no score to landmark/structural outputs). * * Why PageRank and not shortest-path distance: distance ranks a candidate by its single * cheapest path to the seeds; personalized PageRank ranks by how many ways, and how * densely, a candidate is connected to the seed set — a node reachable by many * independent paths outranks one reachable by a single long path. For "pull the most * task-relevant functions into a fixed token budget," connectivity-weighted relevance is * the better objective (the Aider repo-map result). * * Determinism mirrors the in-tree label-propagation discipline (call-graph.ts): nodes are * iterated in a fixed sorted-id order each pass and incoming contributions are summed in a * fixed order, so floating-point results are bit-identical across runs. The caller breaks * ties on equal relevance by node id. * * No new tuning constant: the damping factor and convergence tolerance are the SAME values * the system's existing file-level PageRank uses (`constants.ts`), and edge costs are used * only by the caller's neighbourhood bounding (`weightedBfs`) — the walk itself is uniform * over out-neighbours (textbook PPR), so no edge-weight knob is introduced. */ /** An edge list keyed by source node, as produced by `buildWeightedAdjacency`. */ export type WeightedAdjacency = Map>; /** * Compute personalized PageRank over `universe`, restarting to `seeds`. * * @param adjacency directed weighted adjacency (source → out-neighbours). Pick the * direction the ranking should flow: forward (caller→callee) ranks * downstream relevance, backward ranks upstream, or an undirected merge * ranks proximity in either direction. * @param seeds the task seed node ids — the restart distribution is uniform over the * seeds that fall inside `universe`. Required: with no seed inside the * universe the function returns an empty map (it is never run as a global, * seedless importance ranking — the caller falls back to its default order). * @param universe the bounded set of node ids to rank over (e.g. the distance-limited * neighbourhood `weightedBfs` already explored), so cost stays proportional * to the task neighbourhood rather than the whole repository. * @returns a map from node id to its stationary relevance (a probability distribution over * `universe` summing to ~1); empty when no seed lies in the universe. */ export declare function personalizedPageRank(adjacency: WeightedAdjacency, seeds: Iterable, universe: Iterable): Map; /** * Merge a forward and backward weighted adjacency into one undirected adjacency, so a * nearby caller OR callee counts as "connected". Mirrors the merge `orient` already does * for its distance ranker; factored here for reuse by the PageRank ranking mode. */ export declare function mergeUndirected(forward: WeightedAdjacency, backward: WeightedAdjacency): WeightedAdjacency; /** * Rank the candidate ids that lie in `scores` by descending relevance, breaking ties on * node id (the determinism tie-break). Candidates absent from `scores` (outside the bounded * universe / unreachable from the seeds) are dropped. Returns `{ id, relevance }` pairs. */ export declare function rankByRelevance(candidates: Iterable, scores: Map): Array<{ id: string; relevance: number; }>; //# sourceMappingURL=personalized-pagerank.d.ts.map