Unit artifact cache schema
Layout
Section titled “Layout”Unit artifacts live under {project}/obj/beskid/cache/salsa/:
| Path | Content |
|---|---|
manifest.json | grammar_rev, compiler_version, schema_version, persisted_units |
units/{content_fp}/meta.json | UnitArtifactMeta (logical name, source path, source length, imports) |
units/{content_fp}/ast.bin | Postcard Spanned<Program> snapshot |
units/{content_fp}/hir.bin | HIR cache marker (HIR rebuilt from AST on cold load) |
Legacy obj/beskid/cache/units/*.json records are retired; tooling ignores them.
Fingerprint rule
Section titled “Fingerprint rule”content_fp = hash(grammar_rev, source_bytes) — not absolute path. Path is metadata only. grammar_rev is the workspace constant shared by beskid_pipeline, beskid_artifacts, and beskid_queries.
Invalidation
Section titled “Invalidation”- File edit —
FileTextrevision bump clears fingerprints for old and new content;reverse_dependentspropagates to import closure. - Grammar bump —
GrammarRevisioninput invalidates all unit tracked queries globally. - Lockfile / manifest —
ProjectSession.lockfile_digestchange invalidatesprogram_assemblyfor that entry.
Hot path
Section titled “Hot path”Production assembly uses Salsa in-memory unit_cache (parse + HIR tokens). Disk artifacts are read on cold start; writes occur on direct-parse paths without the Salsa delegate. Manifest persisted_units is refreshed once per assembly batch, not per unit.