Skip to main content

rto_graph/
lib.rs

1//! Provenance-tagged knowledge graph store.
2//!
3//! Every edge in a Roteiro graph carries a [`Provenance`] tag recording how it
4//! was produced: deterministically derived from source ASTs, authored by a
5//! human or agent in an ADR/blueprint, or inferred heuristically from docs and
6//! other artifacts. See ADR-0001.
7//!
8//! The graph is a set of [`Node`]s addressed by a deterministic natural
9//! [`Node::key`], connected by [`Edge`]s. Facts extracted from one source blob
10//! are grouped into a [`FactSet`] and applied atomically to a [`Store`].
11//!
12//! @rto:0001
13
14mod artifact;
15// Audio metadata (ADR-0016): codec, rate, bit depth, channels, duration and tags,
16// read from the container without decoding and without a model. Unlike the media
17// module below, these *are* `derived` facts and do live in `nodes`/`edges` — the
18// complement of ADR-0015 rather than an exception to it.
19#[cfg(feature = "audio-metadata")]
20pub mod audio;
21mod cache;
22mod codegraph;
23mod config_keys;
24mod context;
25// The holder for the media extractors' process-wide native engines — and the
26// deterministic release that keeps a Metal build from aborting at exit (#291) —
27// now lives one level down, next to the llama.cpp backend that shares the same
28// mechanism: `rto_llama::EngineSlot` (#296).
29mod extract;
30// Analyzer findings (ADR-0012): a *separate* artifact store, deliberately not a
31// provenance class and deliberately not in `nodes`/`edges`.
32mod findings;
33mod git;
34#[cfg(feature = "inference")]
35mod infer;
36mod links;
37mod markers;
38// Generated media content (ADR-0015): ASR transcripts and VLM descriptions. Like
39// findings, a *separate* artifact store — generated text is not a deterministic
40// function of the bytes, so it is not a `derived` fact and never enters
41// `nodes`/`edges`.
42pub mod media;
43// Episodic agent memory (ADR-0013): what a session learned, which has no
44// generating function at all — so it is neither `derived` nor `authored`, and it
45// gets a *separate* artifact store on the same terms as findings and media.
46mod memory;
47mod migrations;
48mod model;
49// Which model serves which task, and **why** (Stage 33). Deliberately in *this*
50// crate: `gix` is pinned here without transports, so a resolver that decides
51// which model runs structurally cannot grow a "check for a newer one" call.
52#[cfg(feature = "models")]
53pub mod model_choice;
54#[cfg(feature = "models")]
55mod models;
56mod provenance;
57mod query;
58// Stage 35 — the adjudicated review corpus, and the two pure decisions made over
59// it. In *this* crate for the same reason `model_choice` is: `gix` is pinned here
60// without transports, and both a historical record that must not be "refreshed
61// from the GitHub API" and a suppression rule that must not "just ask CI" are
62// precisely the code that would otherwise acquire such a call.
63pub mod compile_claim;
64pub mod review_corpus;
65pub mod review_score;
66// Stage 35b — the reviewer's judgement, which is likewise pure: prompt assembly,
67// response parsing and the compile-claim site derivation are functions of bytes,
68// so what the reviewer *decides* is testable with no model and no network. The
69// loop that calls an engine is in the binary, where the engine already is.
70pub mod reviewer;
71mod store;
72mod sync;
73mod text;
74/// The project-level dependency shape of a workspace: roles, parents, and the
75/// config-key baseline the cross-repo views pivot on (#623).
76pub mod topology;
77// Whether a producer's identity is measured or asserted (ADR-0019 §5). In *this*
78// crate rather than in `rto-remote` because `rto-remote` depends on this one, so
79// `ModelSource::Remote` cannot name a type that lives there — and because the
80// grade qualifies `Producer`, which is here. Two variants and a sentence: it
81// brings no transport with it.
82pub mod trust;
83mod workspace;
84
85pub use artifact::{ARTIFACT_SCHEMA, GraphArtifact};
86#[cfg(feature = "audio-metadata")]
87pub use audio::{AUDIO_STREAM_KIND, AudioDuration, AudioFacts, AudioTag, Exactness};
88pub use cache::{CacheError, ObjectCache, ObjectSweep};
89pub use codegraph::{ORACLE_SCHEMA, OracleError, OracleReport, compare as compare_codegraph};
90pub use config_keys::{
91    ConfigKey, canonicalize as canonicalize_config_key, flatten as flatten_config, is_config_path,
92    is_secret_key, is_tooling_config_path, normalize as normalize_config_key,
93};
94pub use context::{
95    BoundedEdges, ContextEdge, ContextNode, ContextRefresh, NodeContext, OmittedEdges,
96    TOOL_CONTEXT_EDGE_CAP, ToolContext, build_context, context, dependents, refresh_contexts,
97    tool_context,
98};
99pub use extract::{
100    Extractor, FileNodeExtractor, IngestConfig, MediaEngineGuard, Registry, RustExtractor,
101    cap_content, is_prose, release_media_engines,
102};
103pub use findings::{
104    AdvisoryDb, AnalysisRun, CommandPolicy, EnvironmentPolicy, FINDING_KEY_PREFIX, Finding,
105    FindingKey, FindingsApplied, FindingsError, FindingsLayer, Isolation, MAX_ANALYZER_ID,
106    MAX_IDENTITY_PART, NetworkPolicy, RunnerKind, SECURITY_LAYER_PREFIX, Severity, SourceIdentity,
107    WorktreeAccess, WorktreeId, analyzer_id_error, is_valid_analyzer_id, layer_key,
108};
109pub use git::{BlobRef, ChangeStatus, ChangedFile, GitError, GraphSource, Repo, Submodule};
110#[cfg(feature = "inference")]
111pub use infer::{
112    DuplicateConfig, DuplicatePair, DuplicateReport, EMBED_REF, Embedder, HashEmbedder,
113    InferenceConfig, duplicates, duplicates_with, embed, infer_edges, infer_edges_with, similarity,
114};
115pub use links::{
116    EXTERNAL_REF_KIND, LINKS_AUTHORED_REF, LINKS_REF, external_ref_key, external_ref_node,
117    external_ref_node_with, external_ref_target,
118};
119/// The whole-file scan opt-out (`roteiro:ignore-file`), so every scanner that
120/// reads sources honours one directive rather than each defining its own.
121pub use markers::is_scan_exempt;
122pub use media::{
123    CandidateCount, GateReason, GateThresholds, GeneratedContent, MAX_MODEL_ID, MAX_PROMPT,
124    MEDIA_PRODUCER_PREFIX, MEDIA_SCHEMA, MediaBlob, MediaBuildOptions, MediaBuildReport,
125    MediaError, MediaFilter, MediaKind, MediaOutcome, MediaProducer, MediaRecord, MediaSkip,
126    MediaStatus, MediaWrite, Producer, ProducerId, ProducerSummary, ProducerSummaryAvailable,
127    SkipEntry, build_media, is_valid_model_id, media_blobs, status as media_status,
128};
129pub use memory::{
130    AnchorState, CACHE_BUDGET_ENV, CACHE_SCHEMA, CacheEntry, CacheStats, CacheSweep, CacheWrite,
131    DEFAULT_BASE_CONFIDENCE, DEFAULT_CACHE_BUDGET_BYTES, DEFAULT_DECAY_SPAN, DEFAULT_HALF_LIFE,
132    DEFAULT_MEMORY_SCOPE, Decay, MAX_MEMORY_BODY, MAX_MEMORY_SCOPE, MEMORY_SCHEMA, MemoryAnchor,
133    MemoryError, MemoryFilter, MemoryForgotten, MemoryKind, MemoryListing, MemoryRecord,
134    MemoryWrite, RECALL_SCHEMA, Recall, RecallOptions, Recalled, anchor_penalty,
135    cache_budget_bytes,
136};
137pub use model::{Direction, Edge, EdgeKind, FactSet, Node, NodeKind, Span};
138#[cfg(feature = "models")]
139pub use model_choice::{
140    DEFAULT_GENERATIVE, DEFAULT_OCR, ModelChoice, ModelChoiceError, ModelPins, ModelSource,
141    ModelTask, RemoteTier, TASKS as MODEL_TASKS, resolve as resolve_model,
142    resolve_all_with as resolve_models, resolve_with as resolve_model_with,
143    resolve_with_remote as resolve_model_with_remote, set_model_pins,
144};
145#[cfg(feature = "models")]
146pub use models::{
147    DownloadError, DownloadEvent, ModelFile, ModelKind, ModelRole, ModelSpec, ModelVariant,
148    Platform, REGISTRY, RangeKind, RangeReply, Removal, ResourceTier, discard_partial,
149    download_resumable, download_verified, ensure_model_dir, find as find_model, installed_size,
150    interpret_range_response, is_installed, model_dir, partial_meta_path, partial_path,
151    remove_model, set_model_store, sha256_hex, store_root, verify_sha256,
152};
153pub use provenance::Provenance;
154pub use query::{
155    ConfigSecretItem, ConfigSecretReport, CouplingItem, CouplingOrder, CouplingReport,
156    DEFAULT_MIN_LINES, DebtDensityReport, DebtItem, DebtReport, DensityItem, DensityOrder, EdgeRef,
157    Explanation, GeneratedHit, Listing, MemoryHit, NodeSummary, Path, PathHop, RedactionState,
158    SCHEMA, SearchHit, SearchOptions, SearchResults, config_secrets, coupling, debt, debt_density,
159    explain, list_kind, path, search, search_channels, window,
160};
161pub use store::{ImportApplied, SchemaAhead, Store, StoreError};
162pub use sync::{
163    DEFAULT_KEEP_GENERATIONS, ReclaimReport, SyncError, SyncReport, sweep_superseded, sync,
164    sync_index, sync_tree, sync_worktree,
165};
166pub use text::{
167    Heading, first_h1, heading_id, heading_id_from, heading_text, headings, markdown_dialect,
168    slugify,
169};
170pub use trust::ProducerTrust;
171pub use workspace::{
172    Follow, ResolvedWorkspace, RootScan, Workspace, WorkspaceError, WorkspaceSet,
173    discover_repos_under, parse_qualified, scan_root,
174};