When to Use
When any CLI command or tool needs to work with the full set of units on disk — validation (import resolution), run (dependency tree), publish (import checking). The registry is the bridge between the filesystem and the graph library.The Interface
FileSystemRegistry
How It Works
-
create(dir)— async factory:- Glob scans
dir/**/*.yaml - Parses each file with pinned YAML options (schema: core, version: 1.2)
- Runs
validateUnit()on each — only valid units enter the registry - Stores
Map<string, Unit>(URI → unit) andMap<string, string>(URI → filepath) - Invalid files are silently skipped (malformed YAML, schema failures)
- Glob scans
-
get()/all()/has()— synchronous Map lookups
Why This Pattern
The @stratt/graph library (resolveImports, buildDag, topologicalSort, computeBlastRadius) requires synchronous UnitRegistry access. Making the interface async would cascade Promises through every graph function. The eager-load pattern keeps the library clean and pushes the async boundary to the consumer.