knowledge/lib.rs
1//! The knowledge graph behind review and self-improvement: one SQLite store for every repository Ultron works in.
2//!
3//! The code layer records what each file is made of, keyed by git blob: constructs (a `BEFORE UPDATE` trigger, a
4//! `@Controller` decorator, a call to `runWithBypass`), the symbols it defines, its calls and its imports, the graph
5//! an investigator queries in SQL. A blob's constructs never change,
6//! so indexing a new revision only reads the blobs the store has not seen, and reviews of different revisions of
7//! one repository never disturb each other: each revision's tree is its own path-to-blob table.
8//!
9//! The relation layer (`relations`) is read on demand: a task asks for the relations among some files (which code
10//! reads which configuration key, which handler serves which route, which code touches which table, which test
11//! exercises which file); plain code proposes and prunes them, the judge settles what plain code cannot, and both
12//! are cached by blob.
13//!
14//! This crate only writes. The kernel reads the same file with Python's `sqlite3` (`rlm/knowledge_api.py`), read-only,
15//! and refuses a schema version it does not know.
16
17mod extract;
18mod index;
19pub mod relations;
20mod store;
21
22pub use index::{IndexStats, MAX_RELATION_FILES, Relations, index_tree, relations};
23pub use store::{Note, RuleCredit, SCHEMA_VERSION, Settled, Settlement, Store};
24
25/// The store under the agent directory, shared by reviews and the REPL's `knowledge` API.
26pub fn default_path(agent_dir: &std::path::Path) -> std::path::PathBuf {
27 agent_dir.join("knowledge").join("graph.db")
28}