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;
47pub mod layering;
48mod links;
49mod markers;
50// Generated media content (ADR-0015): ASR transcripts and VLM descriptions. Like
51// findings, a *separate* artifact store — generated text is not a deterministic
52// function of the bytes, so it is not a `derived` fact and never enters
53// `nodes`/`edges`.
54pub mod media;
55// Episodic agent memory (ADR-0013): what a session learned, which has no
56// generating function at all — so it is neither `derived` nor `authored`, and it
57// gets a *separate* artifact store on the same terms as findings and media.
58mod memory;
59mod migrations;
60mod model;
61// Which model serves which task, and **why** (Stage 33). Deliberately in *this*
62// crate: `gix` is pinned here without transports, so a resolver that decides
63// which model runs structurally cannot grow a "check for a newer one" call.
64#[cfg(feature = "models")]
65pub mod model_choice;
66#[cfg(feature = "models")]
67mod models;
68mod provenance;
69mod query;
70// A citable external work (issue #801). In *this* crate for the reason
71// `model_choice` and `review_corpus` are, and with more at stake: `gix` is
72// pinned here without transports, so a record whose every field — author, year,
73// publisher, DOI — invites a lookup structurally cannot grow one. It is also the
74// crate the eventual extraction layer lives in, and the one `rto-render` depends
75// on, so both ends can name the type. What a *citation style* requires of such a
76// record is a different question and lives with the renderer.
77pub mod reference;
78// Stage 35 — the adjudicated review corpus, and the two pure decisions made over
79// it. In *this* crate for the same reason `model_choice` is: `gix` is pinned here
80// without transports, and both a historical record that must not be "refreshed
81// from the GitHub API" and a suppression rule that must not "just ask CI" are
82// precisely the code that would otherwise acquire such a call.
83pub mod compile_claim;
84pub mod review_corpus;
85pub mod review_score;
86// Stage 35b — the reviewer's judgement, which is likewise pure: prompt assembly,
87// response parsing and the compile-claim site derivation are functions of bytes,
88// so what the reviewer *decides* is testable with no model and no network. The
89// loop that calls an engine is in the binary, where the engine already is.
90pub mod okf_consent;
91pub mod reviewer;
92pub mod screen;
93mod store;
94mod sync;
95mod text;
96pub mod topology;
97// Whether a producer's identity is measured or asserted (ADR-0019 §5). In *this*
98// crate rather than in `rto-remote` because `rto-remote` depends on this one, so
99// `ModelSource::Remote` cannot name a type that lives there — and because the
100// grade qualifies `Producer`, which is here. Two variants and a sentence: it
101// brings no transport with it.
102pub mod trust;
103mod workspace;
104
105pub use artifact::{ARTIFACT_SCHEMA, GraphArtifact};
106#[cfg(feature = "audio-metadata")]
107pub use audio::{AUDIO_STREAM_KIND, AudioDuration, AudioFacts, AudioTag, Exactness};
108pub use cache::{CacheError, ObjectCache, ObjectSweep};
109pub use clock::{age_in_days, rfc3339_from_unix, rfc3339_utc, unix_from_rfc3339};
110pub use codegraph::{ORACLE_SCHEMA, OracleError, OracleReport, compare as compare_codegraph};
111pub use config_keys::{
112    ConfigKey, canonicalize as canonicalize_config_key, flatten as flatten_config, is_config_path,
113    is_secret_key, is_tooling_config_path, normalize as normalize_config_key,
114};
115pub use context::{
116    BoundedEdges, ContextEdge, ContextNode, ContextRefresh, NodeContext, OmittedEdges,
117    TOOL_CONTEXT_EDGE_CAP, ToolContext, build_context, context, dependents, refresh_contexts,
118    tool_context,
119};
120pub use extract::{
121    Extractor, FileNodeExtractor, IngestConfig, MediaEngineGuard, Registry, RustExtractor,
122    cap_content, is_prose, release_media_engines,
123};
124pub use findings::{
125    AdvisoryDb, AnalysisRun, CommandPolicy, EnvironmentPolicy, FINDING_KEY_PREFIX, Finding,
126    FindingKey, FindingsApplied, FindingsError, FindingsLayer, Isolation, MAX_ANALYZER_ID,
127    MAX_IDENTITY_PART, NetworkPolicy, RunnerKind, SECURITY_LAYER_PREFIX, Severity, SourceIdentity,
128    WorktreeAccess, WorktreeId, analyzer_id_error, is_valid_analyzer_id, layer_key,
129};
130pub use git::{
131    BaseResolution, BlobRef, ChangeStatus, ChangedFile, GitError, GraphSource, PathAuthor, Repo,
132    Submodule, Upstream,
133};
134#[cfg(feature = "inference")]
135pub use infer::{
136    DuplicateConfig, DuplicatePair, DuplicateReport, EMBED_REF, Embedder, HashEmbedder,
137    InferenceConfig, duplicates, duplicates_with, embed, infer_edges, infer_edges_with, similarity,
138};
139pub use links::{
140    EXTERNAL_REF_KIND, LINKS_AUTHORED_REF, LINKS_REF, external_ref_key, external_ref_node,
141    external_ref_node_with, external_ref_target,
142};
143/// The whole-file scan opt-out (`roteiro:ignore-file`), so every scanner that
144/// reads sources honours one directive rather than each defining its own.
145pub use markers::is_scan_exempt;
146pub use media::{
147    CandidateCount, GateReason, GateThresholds, GeneratedContent, MAX_MODEL_ID, MAX_PROMPT,
148    MEDIA_PRODUCER_PREFIX, MEDIA_SCHEMA, MediaBlob, MediaBuildOptions, MediaBuildReport,
149    MediaError, MediaFilter, MediaKind, MediaOutcome, MediaProducer, MediaRecord, MediaSkip,
150    MediaStatus, MediaWrite, Producer, ProducerId, ProducerSummary, ProducerSummaryAvailable,
151    SkipEntry, build_media, is_valid_model_id, media_blobs, status as media_status,
152};
153pub use memory::{
154    AnchorState, CACHE_BUDGET_ENV, CACHE_SCHEMA, CacheEntry, CacheStats, CacheSweep, CacheWrite,
155    DEFAULT_BASE_CONFIDENCE, DEFAULT_CACHE_BUDGET_BYTES, DEFAULT_DECAY_SPAN, DEFAULT_HALF_LIFE,
156    DEFAULT_MEMORY_SCOPE, Decay, MAX_MEMORY_BODY, MAX_MEMORY_SCOPE, MEMORY_SCHEMA, MemoryAnchor,
157    MemoryError, MemoryFilter, MemoryForgotten, MemoryKind, MemoryListing, MemoryRecord,
158    MemoryWrite, RECALL_SCHEMA, Recall, RecallOptions, Recalled, anchor_penalty,
159    cache_budget_bytes,
160};
161pub use model::{Direction, Edge, EdgeKind, FactSet, Node, NodeKind, Span};
162#[cfg(feature = "models")]
163pub use model_choice::{
164    DEFAULT_GENERATIVE, DEFAULT_OCR, ModelChoice, ModelChoiceError, ModelPins, ModelSource,
165    ModelTask, RemoteTier, TASKS as MODEL_TASKS, resolve as resolve_model,
166    resolve_all_with as resolve_models, resolve_with as resolve_model_with,
167    resolve_with_remote as resolve_model_with_remote, set_model_pins,
168};
169#[cfg(feature = "models")]
170pub use models::{
171    DownloadError, DownloadEvent, ModelFile, ModelKind, ModelRole, ModelSpec, ModelVariant,
172    Platform, REGISTRY, RangeKind, RangeReply, Removal, ResourceTier, discard_partial,
173    download_resumable, download_verified, ensure_model_dir, find as find_model, installed_size,
174    interpret_range_response, is_installed, model_dir, partial_meta_path, partial_path,
175    remove_model, set_model_store, sha256_hex, store_root, verify_sha256,
176};
177pub use okf_consent::{
178    ConsentState, OkfConsent, OkfDecision, screen_fingerprint, screen_regressed,
179};
180pub use provenance::Provenance;
181pub use query::{
182    ConfigSecretItem, ConfigSecretReport, CouplingItem, CouplingOrder, CouplingReport,
183    DEFAULT_MIN_LINES, DebtDensityReport, DebtItem, DebtReport, DensityItem, DensityOrder, EdgeRef,
184    Explanation, GeneratedHit, Listing, MemoryHit, NodeSummary, Path, PathHop, RedactionState,
185    SCHEMA, SearchHit, SearchOptions, SearchResults, config_secrets, coupling, debt, debt_density,
186    explain, list_kind, path, search, search_channels, window,
187};
188pub use reference::{
189    AccessDate, Attested, Author, Day, Doi, GivenName, Locator, Month, NotADay, NotADoi,
190    NotAGivenName, NotAYear, PublicationDate, Reference, Stability, WorkKind, Year,
191    is_printable_identifier,
192};
193pub use store::{ImportApplied, SchemaAhead, Store, StoreError};
194pub use sync::{
195    DEFAULT_KEEP_GENERATIONS, ReclaimReport, SyncError, SyncReport, sweep_superseded, sync,
196    sync_index, sync_tree, sync_worktree,
197};
198pub use text::{
199    Heading, LinkKind, LinkScope, MarkdownLink, code_spans, first_h1, heading_id, heading_id_from,
200    heading_text, headings, is_code_fence, link_scope, markdown_dialect, markdown_links, slugify,
201    strip_code_spans, wiki_link_targets,
202};
203pub use trust::ProducerTrust;
204pub use workspace::{
205    Follow, OKF_BUNDLE_DIR, OkfBundle, ReloadPlan, ResolvedWorkspace, RootScan, SetReloadPlan,
206    Workspace, WorkspaceError, WorkspaceSet, discover_okf_bundles, discover_repos_under,
207    okf_bundle_in, parse_qualified, scan_root,
208};