pub fn render_json_budgeted(
graph: &RepoGraph,
token_budget: usize,
focus: Option<usize>,
include_metadata: bool,
) -> GetRepoMapResponseExpand description
Render a PageRank-weighted JSON map with token-budget allocation (4.0.1).
§Algorithm
Step 1 — File-share allocation. Each eligible file receives a byte
budget proportional to its base_rank. The share is capped at 40% of
budget_total_bytes and floored at [FILE_ENVELOPE_MIN_BYTES] (200 B).
Files are included in rank order until the cumulative allocation would
exceed the total budget.
Step 2 — Per-file symbol fill. For each included file, symbols are
walked in def-rank descending order. Inclusion continues until either (a)
the file’s budget share is exhausted (with carry-over of leftover bytes to
the next file) or (b) a logarithmic attenuation cutoff fires: symbol at
position i (0-based) is included only if its rank ≥ top_rank / (1 + ln(i + 1)). calls[] is filled in target-file base-rank order
subject to a hard [MAX_FILE_CALLS] render cap (no attenuation — I#68,
4.1.4) and per-file byte budget. truncated_symbols and truncated_calls
track the count of omitted entries.
Step 3 — Response telemetry. The response includes estimated_bytes
(actual returned content size), budget_bytes (token_budget * 4),
and budget_exhausted (total_files > files.len()).
§Arguments
graph— the built dependency graph.token_budget— caller-specified token budget (× 4 = byte budget).focus— optional file index for topic-sensitivePageRank.include_metadata— whenfalse(default), Meta-classified files are excluded before ranking.