feat(features): Stage 2a — feature-activated optional dependencies (v0.0.71)#183
Merged
Conversation
A dependency declared under a feature is pulled into resolution ONLY when that
feature is active; declared optionality (no `optional=true` flag needed).
- Manifest.featureDeps: map<feature, map<depKey, DependencySpec>>.
- Parsed from TOML [feature-deps.<name>] (reuses the dependency loader) and from
a Lua descriptor feature's nested `deps = { ["name"] = "ver" }`. Lua feature
`implies` is now parsed too (was TOML-only).
- prepare_build: local lambdas activateFeatures/mergeActiveFeatureDeps merge a
manifest's active feature-deps into its `dependencies` map — root before the
worklist seed, each dep right after its manifest loads — so the existing
worklist BFS resolves them and Stage-3 capability binding finds a
feature-pulled provider. Composes into a one-line `backend-openblas` feature
that pulls a provider AND turns on the consumer switch.
Note: the two helpers MUST be local lambdas, not file-scope inline functions —
as exported functions in this module-interface unit their std::map
instantiations leak into the BMI and trip a GCC-16 modules bug (another TU
importing std then fails: 'failed to load pendings for __normal_iterator').
Tests: e2e/82_feature_optional_deps.sh, Manifest.FeatureDepsTomlSection,
SynthesizeFromXpkgLua.FeatureDepsAndImplies.
Design: .agents/docs/2026-06-29-feature-optional-dependencies-s2-design.md
Bump to 0.0.71. CHANGELOG + docs/05-mcpp-toml.md (§2.8.2 [feature-deps.<name>]). Design doc Implementation Status updated (S2a done; S2b next).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A dependency declared under a feature is pulled into resolution only when that feature is active. Optionality is expressed by where you declare it — no
optional = trueflag.This composes with Stage 3 capabilities:
features = ["backend-openblas"]pulls the provider (compat.openblas, whichprovides = ["blas"]) and turns on the consumer switch (implies use_blas, whichrequires blas) → the capability binds automatically. One-line backend selection.How
Manifest.featureDeps : map<feature, map<depKey, DependencySpec>>. Parsed from TOML[feature-deps.<name>](reuses the dependency loader) and from a Lua descriptor feature's nesteddeps = { ["name"] = "ver" }. Lua featureimpliesis now parsed too (was TOML-only).prepare_build: two local lambdasactivateFeatures/mergeActiveFeatureDepsmerge a manifest's active feature-deps into itsdependenciesmap — root before the worklist seed, each dep right after its manifest loads. The existing worklist BFS then resolves them; no new resolution phase, no re-entrancy. Optional-by-default falls out for free.Deferred
S2b — feature unification (union feature requests per package identity across the graph; today first-requester wins) is the next stage — the one genuine resolver-semantics change.
Tests
82_feature_optional_deps.sh(off → dep not pulled; on → pulled + compiled).Manifest.FeatureDepsTomlSection,SynthesizeFromXpkgLua.FeatureDepsAndImplies.Design:
.agents/docs/2026-06-29-feature-optional-dependencies-s2-design.md.