# 08 — Modules, header units and compiler features Implementation status: IMPLEMENTED & VERIFIED (2026-11-26). See [STATE](../agent-workflow/STATE.md) and [VERIFICATION](../agent-workflow/VERIFICATION.md) for implemented files and observed checks. ## Requirements and ownership - Requirements: R-003, R-011, R-015. - Delivery phase: Full v1 compiler capability. - Intended configured role: astra_implementer at XHigh; fresh astra_reviewer acceptance. - Dependencies: 03 graph; 04 capability drivers; 05 snapshots; 06 dynamic scheduling; 07 cache identity. - Proposed exclusive implementation scope: src/toolchain/modules/, src/features/, tests/features/; common toolchain contracts root-owned. Before dispatch, reconcile these paths with the real HEAD, write a full task spec, lint it, and transfer shared-file ownership explicitly. Paths that do not yet exist are NEW. Source-disjoint work still coordinates shared state, ports and build directories. ## Design and interfaces - Use compiler-supported dependency scans (P1689 for named modules) to establish providers/imports before compilation. Scan generated sources only after their producer completes. Detect duplicate providers, missing imports and module cycles with context. - Map named modules, partitions and explicit header-unit declarations to typed artifacts/actions. Clang's named-module scanner must not be assumed to discover header units; provide explicit header-unit sources and import mappings. - Keep BMI/CMI/PCH products isolated by compiler/stdlib, profile, macros/options, input identity and required physical path context. Do not assume such binaries can be moved or shared across compilers. - Implement PCH, unity batching, LTO and sanitizer options through capability-checked drivers. Exclude module translation units from unity. Validate incompatible combinations and preserve per-file overrides. - Cover standard-library module use through actual compiler/stdlib probes. A requested capability is either tested/supported or explicitly rejected; do not silently turn it off. - Make scan, BMI, PCH and generated unity actions visible to state/scheduler/diagnostics. Editor projection must distinguish real supported commands from missing prerequisite readiness. ## Implementation sequence 1. Implement named-module scanning/collation and dynamic graph integration. 2. Add module partition/standard-library cases and per-context artifact naming. 3. Add explicitly declared header units with driver-specific mappings. 4. Implement PCH/unity/LTO/sanitizers incrementally with separate capability and invalidation fixtures. ## Failure behavior and boundaries - Invalid scans or unsupported format/version fail clearly. - No importer runs before a required BMI; stale module artifacts cannot survive changed provider/options. - ASan/TSan and other unsupported combinations fail configuration. - A successful compilation database export does not prove clangd supports the compiler's extensions. ## Acceptance scenarios 1. Provider edits/additions/deletions, partitions, transitive imports and missing/duplicate/cyclic modules. 2. Header units, macros, profile changes and generated module sources. 3. Cross-profile/compiler BMI/PCH isolation; no reuse of incompatible artifacts. 4. Unity exclusion, per-file flags, LTO linker matching and sanitizer runtime tests. 5. Cold parallel versus sequential builds produce equivalent observable programs. ## Verification and integration gate NEW real compile/link/run fixtures in GCC16.2 and Clang23.1.3 environments, recording compiler+stdlib versions and capability matrix. Test supported combinations; distinguish explicit unsupported cases from regressions. Acceptance requires observed results for these scenarios, the affected regression suite, reviewed cross-component contracts, and a fresh independent review. Record unrun checks and environment limitations; tests passing alone do not waive an invariant. No merge, push or deployment is authorized by a review verdict. ## VoidLibrary reuse and upstream candidates Reuse graph/scheduler/state primitives, not an independent module executor. Compiler-specific scanning belongs in VBS; generic graph facilities may use VoidLibrary. Shared invariants and input/publication policies are defined in [ARCHITECTURE](ARCHITECTURE.md); requirement authority is [REQUIREMENTS](REQUIREMENTS.md). Return implementation evidence to [VERIFICATION](../agent-workflow/VERIFICATION.md).