Expand description
Persisted graph and fragment data structures.
Structs§
- Admission
Expectations - What one admission call checks a candidate against.
- Admitted
Facts - A candidate that passed every admission check, still carrying its original bytes unchanged – the one field publication ever writes.
- AlsoIn
- Represents
AlsoIn. - Candidate
- Represents
Candidate. - Def
- Represents
Def. - EdgeEnd
- One end of an imported edge.
- Edges
ByKind - Represents
EdgesByKind. - FragDef
- Field order is significant: id, name, namespace, kind, line, methods, then the member-fact additions in that exact order – properties, fields, methodReturns – and after those extensionMethods, appended LAST. Each is omitted entirely when empty, so a type declaring none of them serializes exactly as it did before those additions.
- Frag
Extension Method - One
extensionMethodsentry. Serialized field order (name,thisType,arityMin,arityMax,thisArgs) is significant, and serde emits struct fields in declaration order. The two arity halves are NOT optional: they joined the schema with the v6 cache rename, so no fragment this reader can meet is missing them.arity_maxis signed because -1 is the unbounded-paramssentinel. - Frag
Fact - One declared type fact: the type NAME, plus its top-level
type-argument descriptors when the declaration carried any. Field order
(
type,args) is significant, andargsis omitted when absent. - Frag
Lambda Slot - One untyped lambda parameter’s callee slot (see extract.rs’s
LambdaSlot). - Frag
Name - One declared member, with the line its own NAME token sits on.
Field order (
name,kind,line,owner) is significant, andowneris omitted when empty – which is how a markup or resource key, owned by no C# type, serializes with three fields. - FragRef
- Represents
FragRef. - Frag
Registration - One two-type-argument DI service registration a file’s invocations
record – see
extract::RegistrationRecord. - Fragment
- Represents
Fragment. - Fragment
Cache Entry - Represents
FragmentCacheEntry. - Graph
- Represents
Graph. - Graph
File - One file that contributes a graph fragment: C# (defs, refs, member names),
markup (
x:Class/x:Name,.reswkeys – names only) or TS/JS (imports, exported declarations, call/JSX/dispatch references). - Graph
Name - One row of the full name index. Field order (
name,kind,file,line,owner) is significant;ownercarries the declaring type’s def id for a member and is omitted for a type, an enum member, and every markup or resource key. - Graph
Unit - One
.csprojproject as graph.json persists it. - Heuristic
ByTier heuristic_edge_countsplit by the tier that emitted each edge, in the fixed key order every tier-keyed output uses (ext, then guess).- Import
Record - One joined edge from the export.
- Imported
Edges - The validated artifact
import-edgeswrites andimpactreads. - Incomplete
Unit - One unit a structurally valid but declared-incomplete artifact could not fully process, with the compiler’s own per-unit reason.
- Ordered
Map - Represents
OrderedMap. - Percent1
- Represents
Percent1. - Profile
- The requested compilation profile: target, configuration and platform.
- Provenance
- The export’s provenance: who produced it, in which format version, and the digest an importer keys equality on. Carried once in the envelope, never per record.
- Stats
- Represents
Stats.
Enums§
- AnyFragment
- The two shapes a cached fragment can have. Each rel is keyed to whichever
shape the file’s grammar produced; the
ts: 1tag is what tells them apart, on disk and at the resolver’s door. Untagged, and TS FIRST: a C#/markup fragment carries notskey (so the TS arm always fails on it) and a TS fragment carries nousings(so the C# arm always fails on it) – the discrimination is total in both directions, never a first-match-wins guess. - Coverage
- Whether an admitted artifact reports clean, complete coverage or a
qualified partial one. Never conflated with a
RefusalReason: a structurally valid, declared-incomplete artifact is admitted, not refused. - Edge
- The guess tag, appended LAST on every edge kind that can
carry it.
heuristic: trueis set only on an edge a heuristic tier emitted and never writesheuristic: false, so this side pairsskip_serializing_ifwithdefault: absent == precise, and a precise edge’s bytes are exactly what they were before the tag existed. Only the resolver’s heuristic tiers set it today (bothuses-member), but the flag lives on all three targeted kinds because the query layer’s heuristic adjacency is kind-keyed, so a future tier tagging auses-typeedge needs no schema change. - Frag
Using - Represents
FragUsing. - Heuristic
Tier - Which heuristic tier emitted a guess.
- Publish
Error - Why
admit_and_publishdid not produce an admitted, published artifact: either the candidate itself was refused, or admission’s own atomic write failed. The two are kept apart because only the first is aRefusalReasona caller might match on by token; the second is an ordinary filesystem failure. - Rebuild
Outcome - Represents
RebuildOutcome. - Refusal
Reason - Why a candidate compiler-facts artifact was refused.
Constants§
- COMPILER_
FACTS_ ARTIFACT_ SCHEMA_ VERSION - This artifact’s own schema version (distinct from
contractVersion, the producer’s own wire-shape version, the same splitgraph::imports::IMPORTED_EDGES_SCHEMA_VERSION/IMPORTED_EDGES_ARTIFACT_SCHEMA_VERSIONalready draws). The shipped engine now writes2(per-reference occurrence facts, an additive top- leveloccurrenceskey). Nothing in this admission path branches on the literal for equality –parse_headerreadsartifactSchemaVersionfor presence/shape only – but the constant’s name promises the artifact’s schema version, so it is kept equal to what the shipped engine actually writes rather than left to name a version nothing emits. - COMPILER_
FACTS_ CONTRACT_ VERSION - The wire-contract version this admission path was built for. Also the
literal that names the artifact file (
compiler-facts-v<N>.json). - COMPILER_
FACTS_ FORMAT - The export format
compiler-factsadmission accepts. - DEFAULT_
OUTPUT_ CAP - The default stdout byte cap a local engine run is held to before it is
killed and refused as
output-bounded. 256 MiB comfortably exceeds any fixture this crate ships while still bounding an adversarial or corrupted engine’s memory cost. - DEFAULT_
TIMEOUT - The default wall-clock budget a local engine run is given before it is
killed and refused as
engine-timeout. Generous because a Roslyn/MSBuild load is the dominant cost this crate has never measured before; tighten once real cold/warm figures exist. - EXPECTED_
CONTEXT_ SCHEMA_ VERSION - The compilation-context envelope version this admission path recognises. A candidate embedding any other version is refused without this module ever parsing the envelope’s internal shape.
- EXPECTED_
DEPENDENCY_ FINGERPRINT - The sha256 digest of
tools/scout-semantic/packages.lock.jsonas of the engine build this admission path expects. Recompute (shasum -a 256 tools/scout-semantic/packages.lock.json) and update this constant whenever that lock file changes. - EXPECTED_
ENGINE_ REVISION - The engine-protocol revision this admission path expects. Distinct from
super::artifact::COMPILER_FACTS_CONTRACT_VERSION: this names the engine’s own analysis behaviour, the contract names the wire shape. Bump together with a corresponding change on the engine side. “2” means the engine this admission path expects can emit occurrence facts. - EXPECTED_
PRODUCER_ NAME - The producer name this admission path accepts. Keeps the contract additive and producer-tagged: a later outcome that adds or substitutes a producer format changes this constant (and the token it is compared under), never the admission path itself.
- GRAPH_
SCHEMA_ VERSION - The version stamped into every graph.json this build writes, and the one
rebuild_graphdemands before it reuses an artifact it did not just produce. - IMPORTED_
EDGES_ FORMAT - The export format
import-edgesaccepts. - IMPORTED_
EDGES_ SCHEMA_ VERSION - The export schema version
import-edgesaccepts. - IMPORTED_
EDGE_ KINDS - The closed set of edge kinds a record may carry. Fixed by the producer’s own contract – adding a kind here is out of scope for the importer.
- SCOUT_
COMPILER_ ENGINE - The engine locator environment variable: the path to the engine
executable
compiler-facts runspawns. Read only from this module, with no default and no download – a missing engine exits non-zero with one line and leaves any already-admitted artifact untouched. Named distinctly from the unrelated, unshippedSCOUT_SEMANTIC_TOOLlocator a different design note proposes for a different, still-unbuilt cache, so the two invocation paths can never be confused once both exist.
Functions§
- admit
- Admits or refuses a candidate compiler-facts artifact.
- admit_
and_ publish - Admits
candidate_bytesand, on success, publishes it atomically as this checkout’s compiler-facts artifact – the one place bothrunandimportconverge, the concrete mechanism behind “one admission path for both producers.” On any refusal, no write occurs and whatever artifact already existed is untouched. - compiler_
facts_ json_ path - Path to the compiler-facts artifact for
root, besidegraph.json. The contract version is part of the filename, so a future contract bump writes a new file rather than overwriting this one – a v2-only reader is inert to a stale v1 file by construction. - expectations_
for - Builds the expectations a
compiler-facts run/importadmits against, for the checkout atrootand the profile the caller requested. - fragment_
from_ extraction - Build a graph fragment from this crate’s extractor output.
Extraction.purposehas no fragment counterpart – the fragment is graph-only. - graph_
json_ path - Path to the graph artifact (
graph.json) forroot. - imported_
edges_ json_ path - Path to the imported-edges artifact for
root, besidegraph.jsonunder the same graph directory. - index_
is_ stale - Whether the fragments index is stale for the given graph files (any mtime mismatch, or a differing file count).
- locate_
engine - Locates the engine executable from
SCOUT_COMPILER_ENGINE, orNonewhen the variable is unset or empty. - markup_
fragment - Markup and resource files never reach the extractor: a
line scan reads them instead (see markup.rs). They still get a fragment even
when they declare nothing, because the fragments index is what tells
mapwhether the graph’s input set changed, and a file missing from it reads as a permanent mismatch.usingsis always empty: XAML has no using-directive equivalent, and thexmlns:prefix declarations that stand in for one are already resolved into fully-qualified ref names by the scan. - parse_
imported_ edges - Parses and validates a cross-repo edge export.
- project_
units_ path - Path to the project-model staleness sidecar for
root. - read_
compiler_ facts - Reads this checkout’s admitted compiler-facts artifact, or
Nonewhen absent or unreadable – the same fail-open conventiongraph::read_graph/graph::read_imported_edgesalready follow, since this artifact is auxiliary and its absence is the ordinary “no engine ever ran here” state, not an error. - read_
fragments_ index - Read the fragments index (rel -> mtime). Used for the per-file reuse decision, independent of the graph rebuild.
- read_
graph - Reads and deserializes the repository graph, returning
Noneon failure. - read_
imported_ edges - Reads the imported-edges artifact for
root, orNonewhen absent or unreadable. - rebuild_
graph fresh_fragments: fragments this run’s extractor produced for files that needed reparsing (the same set that got a fresh purpose signature in the realdevscout mapflow –mapcmd::map_repoassembles it).changed: from the caller’s ownindexIsStale-equivalent check againstcsFiles, passed in rather than recomputed so the unchanged path never opens any graph file.model: the repo’s discovered.csprojprojects, orNonewhen it declares none – serialized intograph.unitsand mirrored into theproject_units_pathstaleness sidecar. The caller is expected to have already foldedproject::sidecar_differsintochanged; this function only writes the sidecar, it never decides on it.- run_
engine - Runs
commandto completion, capturing stdout underoutput_capbytes andtimeoutwall-clock time.command’s stdin is closed and stderr is discarded – only stdout carries the candidate artifact bytes. - write_
imported_ edges - Writes the imported-edges artifact for
root, atomically.