# Plan C++ module builds from versioned compiler scan evidence Task ID: T-MODULE-GRAPH-011 Role: astra_implementer Status: READY ## 1. Context and baseline Shared feat/implement-roadmap ca04975. Actual GCC 16.2 corpus in tests/corpus/modules/verify.py reads P1689R5 v0/rev0 single rules, changes named partition requirements with macros and exposes a cold header-unit scan missing a later import. Warm validated builds obtain 17/41/48; old reader remains 17. T-PLAN-SEMANTICS-010 provided the module package. Existing BuildGeneration/ContextKey and immutable AnalysisInputs hold authority/input identity. Core graph currently absent. ## 2. Objective and deliverables Implement the compiler-independent module scan decoder and dependency planner used by the semantic worker. Expose deterministic prerequisite order for a requested owning TU, reverse consumers for invalidation, and structured blockers with truthful completeness. Supply focused C++ tests. Root integrates both build systems and runs the real GCC fixture through this new C++ path. ## 3. Scope and non-goals Graph construction and immutable evidence only inside VLS. No compiler/descriptor spawning, file reads through graph data, module file format assumptions, public LSP advertisement, frontend choice, shared build wiring, new source parser or edits outside ownership. ## 4. Files to inspect Read docs/roadmap/11-cpp-modules.md, tests/corpus/modules/verify.py and fixtures, build/gcc-gate/private-modules.log, include/Void/LanguageServer/Build/Model.hpp, include/Void/LanguageServer/Protocol/Json.hpp (bounded parser and type accessors), tests/providers/ModelTests.cpp for actual runner idiom. Consult P1689R5 directly (open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html); GCC output supplies fewer fields than the general format. ## 5. Write ownership and coordination Write scope: include/vls/modules/ModuleGraph.hpp; src/modules/ModuleGraph.cpp; tests/modules/ModuleGraphTests.cpp Shared files marked above are yours only after root explicitly dispatches this task following preflight. Root owns real compiler harness, build manifests, docs and all integration. Use isolated build/module-graph-011 for temporary checks. No staging, commits, branch changes, other workers, or user communication. ## 6. Implementation or investigation approach Decode one expected primary output per compiler invocation with Protocol::parse_json and its helpers; validate types, GCC envelope and optional authority-bearing fields before producing owned data. Bind it externally to its real exit status, scan method/completeness, file/command/provider revision, immutable source and lookup inputs. Allow explicit authoritative header-unit identities, path/spelling ambiguity must degrade. Never infer unit semantics from filename. Missing source, failed pass even with viable-looking rule, cold incomplete header/macros, duplicate providers, missing provider, cycle, mismatched domain and oversize need typed outcomes. ## 7. Interfaces and data contracts Bind each consumed header-unit CMI to its immutable staged artifact generation and matched current header/transitive contents, compiler/domain and lookup identities; a successful warm scan with an old CMI misses a macro-conditioned import. A bare warm flag or a depfile containing just a CMI cannot provide completeness. A -MMD scan needs independent immutable system-include coverage; -MD textual dependencies or equivalent evidence cover relevant inputs. -M -MG can be used warm as well as cold, so the scan mode alone never upgrades completeness. GCC can emit identical import-only rules for a module implementation and an ordinary importer with identical expected output. Keep that unit kind unknown unless independently evidenced. The input owner supplies a closed, revisioned census of eligible per-TU ContextKeys for the requested linked target/domain, or a compatible per-importer census when visibility differs. Explicit membership is distinct from ABI compatibility. Reject ambiguous/missing censuses and unknown claims from failed or omitted eligible scans before claiming ready. Cover membership/lookup changes and missing or duplicate claims in invalidation evidence so adding a previously unknown provider invalidates old observations. Prove unrelated complete cycles do not block a requested acyclic component. This decoder accepts the observed GCC 16.2 single-rule version 0 revision 0 variant of P1689R5; the published paper describes version 1 revision 0. Refuse unsupported versions with a typed result. Bind expected primary-output to the admitted invocation working directory and its exact expected spelling or a proven matching identity. NEW API in namespace vls::modules, exposed through ModuleGraph.hpp. Provide read/decode_scan(p1689_bytes, expected_primary_output) -> expected and build_module_plan(graph inputs, requested TU/context) -> owned plan with order, reverse invalidation and typed blockers. Freeze exact names to root early. Scans carry Build::ContextKey or equivalent unambiguous owning TU/context identity, full generation scope, source/dependency observations and verified compatible module-domain identity. Distinguish TU command identities from module compatibility: legal per-TU -D or -o variations cannot prevent deliberately admitted compatible providers. ABI-affecting configuration and lookup scopes cannot mix on name. Preserve is-interface false, header lookup identity (where emitted), primary-output equality and source convergence. Epoch/current checks belong to revision owner. ## 8. Dependencies and integration T-PLAN-SEMANTICS-010 early plan accepted for preflight. This is the pure graph used by a future real worker/scheduler. Root verifies current stock GCC via full module corpus and an integration bridge consuming actual P1689 scan output; return interface early to allow this. No production backend selection required to model observations. ## 9. Edge cases security and performance Bound JSON bytes/depth and per-rule/collection/string/aggregate sizes before expensive work; cap graph nodes/edges/traversal. Avoid process-stack overflow on deep chains, arbitrary path normalization, global name-only matches, unsafe cross-context reuse, repeated O(N²) scans or exponential walking. For blockers outside a requested independent component distinguish global collection incompleteness from a proven conflict unrelated to that component. Definition of input coverage must account for unknown provider claims and duplicate records, including failed scans. ## 10. Acceptance criteria READY from the independent reviewer. Include a new file changing __has_include and attaching a new edge, and a renamed provider introducing a duplicate while the eligible membership stays fixed. Equal private output labels in distinct invocations are legal and differ from a writer collision of actual output identity. Assert ordered transitive partition/primary/importer, implementation and internal partition, same-name compatible duplicates vs incompatible contexts, unprovided std/header, self+multi-node cycles, retained previous context after source edit, reverse invalidation, context switch, header shadowing and cold/warm conditional import. Document what cannot be inferred from GCC scan. Test malformed/unknown wire semantics, successful rule with failed compiler exit, deep/legal bounds, semantic distinction of absent vs malformed scanner evidence and explicit incompleteness. ## 11. Verification commands and evidence Use dev cpp-gcc -c g++ -std=c++26 -freflection -Iinclude -Ibuild/voidlibrary/current/include -fsyntax-only src/modules/ModuleGraph.cpp tests/modules/ModuleGraphTests.cpp. Use Void::Testing runner and actual resulting nonzero registered suites via root build or temporary separate link with existing build/bootstrap artifacts. Do not configure shared build dirs. Root provides integrated target and binaries. Record exact observed results and distinguishing failure inputs. ## 12. Constraints and stop conditions Stop for data/authority the graph cannot establish, expose typed pending status, send root the exact missing evidence and complete independent cases. No guesses about real loaded imports, generated code, artifact compatibility or private fragment support. Do not choose backend/distribution or expand code ownership. ## 13. Authorization and decisions User authorized full implementation, separate branch, VBS primary, GPT-6.2 Max (D-022/025/027); local compiler experiments only D-030. Modules are first-class user requirement. No out-of-repo writes except owned temporary compiler outputs under this checkout. ## 14. Return format T-MODULE-GRAPH-011 DONE/PARTIAL with public API, invariants, touched files and exact commands/results; send root stable headers early, concrete limits/open obligations at handoff.