Skip to main content

core_api/repograph/
mod.rs

1//! Reading a code graph back as answers.
2//!
3//! `ingest-git` writes a repository into the graph; this module reads it out
4//! again, in the shapes a person or an assistant asks for. Each tool computes
5//! a plain data structure and a renderer turns it into a short digest, so the
6//! same answer serves a CLI, an HTTP response and an MCP tool without being
7//! computed three ways.
8//!
9//! | Tool | Answers |
10//! |---|---|
11//! | [`explore`] | one target from as many sides as asked for: the three below in one call |
12//! | [`repo_map`] | what is this repository, in one screen |
13//! | [`brief`] | the same, for the start of a session, in a fixed byte budget |
14//! | [`context`] | everything known about one file or symbol |
15//! | [`impact`] | what else the files in a diff reach |
16//! | [`owners`] | who has written a file, and when |
17//! | [`why`] | what links two things, with the evidence |
18//! | [`recall::recall_digest`] | which nodes a topic is closest to |
19//! | [`remember::remember`] | write a note the graph can later recall |
20//! | [`stale_concepts`] | which learned concepts have drifted from their sources |
21//!
22//! [`rules`] holds the `about_<label>` and `concept_sources` rule
23//! definitions both `structure::ensure_rules_and_fulltext` (CLI) and
24//! [`remember::remember`] need, so the two cannot declare them differently.
25//!
26//! Two rules hold across every tool here. The output is **deterministic** for
27//! the same store state and the same caller-supplied "now": collections are
28//! sorted, ties break on the key, floats print at a fixed precision, and every
29//! answer is decided by the graph. The one value that is not is how long ago
30//! the store was synced, which is measured against the system clock unless the
31//! caller pins the time — see [`MapOptions::now_ts`]. And every string that
32//! came out of the graph passes through [`sanitize`](render::sanitize) before
33//! it reaches a rendered line, so repository content cannot forge a header or a
34//! line break in an assistant's context.
35//!
36//! [`context`] is the one tool that reads anything outside the graph: the
37//! source it quotes comes from the working tree, so what it shows is what is on
38//! disk now. It quotes it only when asked — [`context_with`] with
39//! [`ContextOptions::source`] — and otherwise answers with a pointer to it.
40
41mod brief;
42mod concepts;
43mod context;
44mod explore;
45mod facts;
46mod impact;
47mod map;
48mod owners;
49mod path;
50pub mod recall;
51pub mod remember;
52pub mod render;
53pub mod rules;
54mod why;
55
56pub use brief::{brief, BriefOptions, BriefReport, EdgeTypeBrief, LabelBrief, Recipe, SchemaBrief};
57pub use concepts::stale_concepts;
58pub use context::{
59    context, context_with, named_symbols, CallSites, ContextOptions, ContextReport, Target,
60    MAX_SOURCE_LINES,
61};
62pub use explore::{explore, Depth, ExploreReport};
63pub use impact::{
64    impact, path_excluded, FileImpact, ImpactOptions, ImpactReport, Partner, DEFAULT_EXCLUDES,
65    MIN_SHARED_COMMITS,
66};
67pub use map::{repo_map, MapCommunity, MapOptions, RepoMap, SyncInfo};
68pub use owners::{owners, OwnersReport, QUARTERS};
69pub use path::{shortest_path, MAX_HOPS, PATH_EDGES};
70pub use recall::{
71    identifier_terms, or_query, recall_digest, HINT, MAX_HITS, MAX_OUTPUT_BYTES, MAX_QUERY_TERMS,
72    MIN_HIT_SCORE, UNTRUSTED_FRAMING,
73};
74pub use remember::{remember, RememberInput, NOTE_KINDS};
75pub use render::{
76    cap_lines, render_brief, render_context, render_explore, render_impact, render_map,
77    render_owners, render_why, sanitize, DEFAULT_EXPLORE_BYTES, EMPTY_BRIEF, MAX_BRIEF_BYTES,
78    MAX_CONTEXT_LINES, MAX_MAP_LINES, MAX_TOOL_LINES,
79};
80pub use why::{why, SharedCommits, WhyLink, WhyReport};