Skip to main content

Module discovery

Module discovery 

Source
Expand description

Workspace discovery — the first cross-trust-boundary phase.

Given a workspace root, walk the filesystem with the ignore crate (the same engine ripgrep uses), classify each directory as a component, module, or environment, and emit an ordered, deterministic Discovered structure for the loader and Terragrunt resolver to consume.

No HCL parsing happens here — only a regex-grade shallow probe of file bytes (per 11-discovery.md § 3.3) that the loader will redo definitively.

This module is the first slice of code that touches user-controlled filesystem state. Every byte off disk is treated as hostile per 70-security.md § 1: paths are NUL-rejected, canonicalised, and verified to remain underneath the workspace root before any open.

Structs§

Discovered
Output of crate::discovery::Discoverer::discover.
DiscoveredDir
A single discovered directory.
DiscoveredFile
A single source file discovered inside a DiscoveredDir.
DiscoveryOptions
Discovery configuration (caps, excludes, classification hints).
FsDiscoverer
Default Discoverer implementation.

Enums§

ClassificationReason
Why the classifier picked the kind it did. Surfaced in Discovered.diagnostics and in CLI verbose output for auditability.
DirKind
What kind of directory the walker thinks it is.
GlobConfigError
Errors raised while compiling user-supplied glob patterns.

Constants§

MAX_DISCOVERY_THREADS
Cap on walker thread count. Per [11-discovery.md § 3.5], beyond 8 the fs metadata calls saturate on macOS APFS / Linux ext4. The current sequential walker uses one thread; the cap is reserved for the parallel implementation that lands in Phase 9.
MAX_GLOB_PATTERN_BYTES
Hard cap on the byte length of any user-supplied glob pattern, per 70-security.md § 3.4. Beyond this length regex compilation is rejected before reaching globset.

Traits§

Discoverer
Trait every discoverer implements. The default impl is FsDiscoverer; downstream tests / embedders may supply an in-memory variant by implementing this trait directly.

Functions§

compile_glob_set
Compile a user-supplied glob list into a GlobSet, applying the length cap from 70-security.md § 3.4.