Skip to main content

Crate knowledge

Crate knowledge 

Source
Expand description

The knowledge graph behind review and self-improvement: one SQLite store for every repository Ultron works in.

The code layer records what each file is made of, keyed by git blob: constructs (a BEFORE UPDATE trigger, a @Controller decorator, a call to runWithBypass), the symbols it defines, its calls and its imports, the graph an investigator queries in SQL. A blob’s constructs never change, so indexing a new revision only reads the blobs the store has not seen, and reviews of different revisions of one repository never disturb each other: each revision’s tree is its own path-to-blob table.

The relation layer (relations) is read on demand: a task asks for the relations among some files (which code reads which configuration key, which handler serves which route, which code touches which table, which test exercises which file); plain code proposes and prunes them, the judge settles what plain code cannot, and both are cached by blob.

This crate only writes. The kernel reads the same file with Python’s sqlite3 (rlm/knowledge_api.py), read-only, and refuses a schema version it does not know.

Modules§

relations
Relations across files, read on demand for a task: which code reads which configuration key, which handler serves which route, which code touches which table, which test exercises which file.

Structs§

IndexStats
Note
A review comment, as Store::record_notes keeps it.
Relations
The relations a task asked for at one revision (relations).
RuleCredit
A rule (a person’s addressed review comment) with the fates of the findings that cited it.
Settlement
Store::settle_relations: one relation’s verdict and who gave it.
Store

Enums§

Settled
The judge’s verdict on a relation.

Constants§

MAX_RELATION_FILES
Files read for relations in one call, at most: a bound on a monorepo asked about as a whole.
SCHEMA_VERSION
The schema the kernel reader (rlm/knowledge_api.py) is written against. Bump it with every change to a table the reader uses, and teach the reader the new version in the same change.

Functions§

default_path
The store under the agent directory, shared by reviews and the REPL’s knowledge API.
index_tree
Indexes repo (a stable name such as github.com/owner/name) at rev of the git checkout repo_dir into the store at db. Indexing the same revision again only refreshes its tree.
relations
The relations of kinds (all when empty) among the files under scope of repo at rev of the git checkout repo_dir: the revision is indexed first (only blobs the store has not seen are read), the proposer reads only blobs it has not read at RELATIONS_VERSION, and the result is pruned for the task. Verdicts the judge gave earlier come back with their relations.