Skip to main content

Module relations

Module relations 

Source
Expand description

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.

The schema is small and closed (Kind), versioned by RELATIONS_VERSION, and grows only when a recorded failure needs a distinction (a just-in-time ontology: built when a task asks, kept with its evidence, reused). Each relation passes three rungs, cheapest first:

  1. The proposer (propose): plain code over one blob’s text. A pattern that cannot mean anything else (std::env::var("HOME"), @app.get("/users"), SQL in a .sql file) is settled here (certain); a pattern that only looks like one (config.get("x.y"), a lowercase from users in a string) is proposed.
  2. Pruning (prune): only the kinds the task asked for; a test import must name a file of the same tree; duplicates and relations the judge refused are dropped. No model is asked about what plain code can drop.
  3. The judge (judge.decide, asked by the REPL client): one yes/no per proposed relation, over its lines.

What the proposer reads depends on the blob alone, so proposals and verdicts are cached by blob and RELATIONS_VERSION: the next task over the same files asks nothing again.

Structs§

Proposed
A relation the proposer read from one blob. It depends on the blob’s text only: the file’s path is joined in when it is read back (Relation).
Pruned
What a task keeps of a revision’s relations, and how many were dropped, by reason.
Relation
A relation of one file at one revision, as the store keeps it.

Enums§

Kind

Constants§

MAX_PER_BLOB
Proposals kept per blob, in order: a bound on generated files.
RELATIONS_VERSION
The version of the proposer’s rules and of the schema of kinds. Bump it whenever what is proposed changes: every blob is then read again, and its earlier proposals and verdicts are dropped.

Functions§

propose
Everything the proposer reads in text (the file at path), in line order, at most MAX_PER_BLOB.
prune
The relations a task asked for (kinds, all when empty), pruned with plain code: another kind (kind), a test’s import that names no file of the tree (unresolved; a resolved one names the file), one the judge refused (rejected), and the same (kind, subject, object) again (duplicate). paths is every file of the tree.
resolve_import
The repository file a test’s import names, when it is one: Rust use paths (crate::, a workspace crate’s name), Python modules (dotted, relative), relative TypeScript and JavaScript specifiers.
scanned
Whether the proposer reads path: source and SQL outside vendored and built trees.