Expand description
Structure ingest: the working tree, read as graph.
ingest_git builds the history half of a codebase
graph — who touched what, when. This module builds the present half from
the files on disk: what each file defines, what it imports, what its
definitions call, and what the prose says about it.
It never writes an edge itself. Every relationship is stored as a list
property and left to a rule, so the engine owns retraction: rewrite a
file’s imports and the stale IMPORTS edges retract in the same commit.
| Written on | Prop | Derives |
|---|---|---|
File | imports: [File key] | IMPORTS File → File |
File | mentions: [File key] | MENTIONS File → File |
Symbol | calls_to: [Symbol key] | CALLS Symbol → Symbol |
Symbol | file_id: File key | DEFINES Symbol → File |
Beside each list sits its evidence: import_lines and call_lines hold
"<key>\t<line>" strings, so a tool can quote the line a link came from.
One entry per call site, not one per callee: a symbol that calls another
twelve times contributes twelve entries and one calls_to element, which is
what lets context name every line a change would have to visit.
§Resolving a call
A file’s imports are resolved before its calls, and the resolved list is fed
to resolve_call: a definition living in a file this one imports beats a
same-named definition anywhere else in the tree. Without that a call could
only cross a crate boundary when the callee’s name happened to be unique
across the whole repository.
That repository-wide tier is also the only one a call written on a receiver
never reaches. .collect() and .ok() name methods on types from outside
the tree, and uniqueness would bind them to any single same-named function
it found. A method call resolves through the local and imported tiers or not
at all — and it reaches a method there through the bare name the index files
every Type.method under, gated on a receiver that says which type it is.
§What is read
Only the working tree. The candidates are the File nodes git already put
in the graph — so exclusion patterns have been applied — narrowed to those
that exist on disk right now. A path that lives only in history keeps
whatever git recorded about it and is skipped here.
§What is written
Only differences. Each file’s stored props are compared field by field
against the freshly extracted ones, and its Symbol nodes against the
symbols just found in it. A file whose bytes have not changed produces no
write at all, which is what makes a re-run byte-identical.
Structs§
- Structure
Report - What one refresh saw. Counts cover every file scanned, including those that needed no write, so the numbers are stable across re-runs.
Constants§
- DEFINES_
RULE - Name of the
Symbol.file_idforeign-key rule. Identical to the name zero-config FK inference would choose, so the two never both create it — and declaring it here is what makes the edgeDEFINESrather than theFILEthat inference would derive from the field name. - FULLTEXT
(label, field)pairs this module indexes for full-text search.- MAX_
SYMBOLS_ PER_ FILE - Most
Symbolnodes kept for one file. A generated or vendored file can define tens of thousands; past this the file is still hashed and its imports still resolve, it just stops contributing definitions.
Functions§
- ensure_
rules_ and_ fulltext - Declare the structure rules and full-text fields that are missing, and return the names of the rules created.
- importers_
of - The
Filekeys whoseimportsormentionslist still names one ofkeys. - refresh_
all - Refresh every working-tree file under
prefix. - refresh_
files - Refresh exactly
paths— those of them that are still files on disk. - rules
- Every rule this module declares, in creation order.
Type Aliases§
- Db
GraphDbover the real filesystem, named without spelling outRealFs— whichcore-apidoes not re-export. Both an opencore_api::GraphDband acore_api::WriteGuard(through itsDeref) are one of these.