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