feat(features): additive C++ feature flags (G2)
VoidBuildSystem CI / 1 · Requirements (push) Successful in 8s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m47s
VoidBuildSystem CI / 2A · Linux build (coverage) (push) Successful in 2m53s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 3m36s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m57s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m23s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 25s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 24s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 6m1s
VoidBuildSystem CI / 3A · Linux test (coverage) (push) Failing after 2m2s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 2m2s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 6m54s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 7m4s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped

- Project::feature(name, default_on) / FeatureDescription, Target's
  require_feature() (the `.requires` spelling is a C++20 keyword), and
  Dependency::when(feature) for optional dependencies.
- --features a,b / --no-default-features on build, test, run, explain and
  deps resolve/update. Unification is additive: defaults (unless
  disabled) + features required by targets + requested features.
- Enabled features add VBS_FEATURE_<NAME> compile definitions to every
  target, so action keys and the cache are feature-aware; switching the
  set invalidates cached actions.
- Optional dependencies are filtered before resolution, so vbs.lock
  contains only active ones.
- vbs explain --show-features prints the unified set with reasons
  (default/requested/required by target); vbs metadata lists declared
  features with their enabled state; the descriptor JSON carries features
  and target requirements.

API note: features provide preprocessor-level configuration (defines), not
ABI/layout changes across a feature boundary.

Verified: features_unify_defines_and_invalidate_action_keys and
optional_dependencies_follow_feature_selection pass; vbs_core_tests 8/8;
CLI contracts pass; clang-format clean.
This commit is contained in:
faumaray committed 2026-12-06 20:01:29 +03:00
1 parent 8b21583eeb
commit f03524628b
10 files changed
+512 -3

No files matched your search

+2
View File
@@ -401,6 +401,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
## Remaining future scope
- **Wave 150 (Real feature flags, G2)**: `Project::feature(name, default_on)` (or `FeatureDescription`), `Target::require_feature(name)` (renamed because `requires` is a C++20 keyword), and `Dependency::when(feature)` for optional dependencies. `--features a,b` / `--no-default-features` on build/test/run/explain/deps (or `VBS_FEATURE`-style CLI only) perform additive unification: defaults (unless disabled) + features required by targets + requested features; enabled features add `VBS_FEATURE_<NAME>` compile definitions to every target (so action keys and the cache are feature-aware) and the descriptor JSON/`vbs metadata` expose declared features with their enabled state. Optional dependencies are filtered before resolution, so the lock contains only active ones; `vbs explain --show-features` prints the unified set with reasons (default/requested/required by target). Verified by `FullV1Tests.features_unify_defines_and_invalidate_action_keys` and `FullV1Tests.optional_dependencies_follow_feature_selection`.
- **Wave 149 (Trust layer, G5 start)**: `vbs attest create|verify` produces and verifies DSSE-wrapped in-toto Statement v1 / SLSA provenance v1 attestations (subjects, build definition with project/profile/targets/lock revision, internal parameters, run details) signed with the existing Ed25519 primitives; verification requires a trusted key, checks the DSSE PAE signature and requires every supplied artifact digest to be covered. `vbs audit --advisories OSV.json` matches OSV records (introduced/fixed/last_affected/limit ranges and exact versions) against `vbs.lock` packages with a severity threshold and JSON output; `vbs doctor` reports the signing backend. Unsignable hosts fail closed. Verified by `FullV1Tests.attest_create_and_verify_detects_tampering` (valid, wrong artifact, tampered payload, untrusted key, missing keys) and `FullV1Tests.audit_matches_osv_advisories_against_lock` (affected/fixed versions, severity thresholds, JSON).
- **Wave 148 (Hermetic sandboxing, F1)**: `Sandbox::sandbox_supported()` probes unprivileged user namespaces; `vbs build|test|run --sandbox=off|warn|strict` (or `VBS_SANDBOX`) wraps every action in the hidden `vbs __sandbox-exec` mode, which unshares user/mount/network namespaces, maps the caller to root, binds the project read-only, the build root (snapshots included) read-write, and `/usr`, `/lib`, `/bin`, `/etc` and the Nix store read-only before `pivot_root` and exec. `/proc`, `/sys` and `/dev` are bound read-write (their mounts cannot be remounted read-only from a user namespace), `/tmp` is an empty directory, and system read-only remounts that the kernel refuses degrade to writable binds (the project itself is required to be read-only). `vbs doctor` reports availability, CI runs a strict smoke build when the runner allows user namespaces, and `FullV1Tests.sandbox_strict_allows_project_builds_and_hides_outside_files` proves a strict build succeeds while an action that reads an outside file fails.
+1
View File
@@ -149,4 +149,5 @@ Base HEAD: `fe0d1a6`
| Wave 147 (Lifecycle CLI + native caching + BEP) | `vbs run` (Void::Process inherited stdio, exit-code passthrough, Wine), `vbs metadata` (StrictJson schema v1), `vbs why`, `vbs tree`, `vbs fmt`/`vbs lint`, `vbs install-binary`, `vbs add`/`vbs remove` (Semver-validated manifest editing + lock refresh), `vbs new`, `--frozen`, `--bep` event stream, `--native-cache off/auto/ccache/sccache` with doctor reporting | COMPLETE & VERIFIED for the implemented commands (GCC 16.2; lifecycle, tree, fmt, BEP and native-cache tests pass; CLI contracts pass) | `src/Main.cpp`, `src/Toolchain/Driver.{hpp,cpp}`, `src/Package/Manifest.{hpp,cpp}`, `include/Void/Build/Package/Manifest.hpp`, `tests/{FullV1Tests,CliContracts}`, docs |
| Wave 148 (Hermetic sandboxing) | `Sandbox::sandbox_supported`, `Sandbox::apply_sandbox`, hidden `vbs __sandbox-exec` wrapper, `--sandbox=off|warn|strict`/`VBS_SANDBOX`, project read-only + build root writable + system/toolchain roots read-only, doctor reporting, CI strict smoke step | COMPLETE & VERIFIED (GCC 16.2; `sandbox_strict_allows_project_builds_and_hides_outside_files` passes: strict build succeeds and an action reading an outside file fails; CLI contracts pass) | `include/Void/Build/Sandbox/Sandbox.hpp`, `src/Sandbox/Linux/NamespaceSandbox.cpp`, `include/Void/Build/Execution/Scheduler.hpp`, `src/Execution/Scheduler.cpp`, `src/Main.cpp`, `.gitea/workflows/ci.yml`, `tests/{FullV1Tests,CliContracts}`, docs |
| Wave 149 (Trust layer) | `vbs attest create\|verify` (DSSE + in-toto Statement v1 + SLSA provenance v1, Ed25519 over the PAE, trusted-key and subject-digest enforcement), `vbs audit --advisories OSV.json` (introduced/fixed/last_affected/limit ranges, severity threshold, JSON), signing availability in `vbs doctor` | COMPLETE & VERIFIED (GCC 16.2; `attest_create_and_verify_detects_tampering` and `audit_matches_osv_advisories_against_lock` pass; CLI contracts pass) | `include/Void/Build/Provenance/Attestation.hpp`, `src/Provenance/Attestation.cpp`, `include/Void/Build/Package/Audit.hpp`, `src/Package/Audit.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}`, docs |
| Wave 150 (Feature flags) | `Project::feature`, `Target::require_feature`, `Dependency::when`, additive unification, `--features`/`--no-default-features`, `VBS_FEATURE_*` defines, feature-aware action keys, optional dependency filtering, `explain --show-features`, metadata feature list | COMPLETE & VERIFIED (GCC 16.2; `features_unify_defines_and_invalidate_action_keys` and `optional_dependencies_follow_feature_selection` pass; CLI contracts pass) | `include/Void/Build.hpp`, `sdk/Build.cpp`, `include/Void/Build/Graph/Graph.hpp`, `src/Graph/Graph.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}`, docs |
| Future (Plans 23–24) | Gap closure and superiority tracks | PLANNED (see the plans for per-track acceptance gates) | [23-remaining-upgrade-plan.md](../roadmap/23-remaining-upgrade-plan.md), [24-superiority-tracks.md](../roadmap/24-superiority-tracks.md) |
+11
View File
@@ -157,6 +157,17 @@ the registry offline; `install-binary` installs and runs the registry artifact.
### G2 — Feature flags that actually work *(M–L)*
**Status: implemented (Wave 150).** `Project::feature(name, default_on)` (or
`FeatureDescription`), `Target::require_feature(name)` (the plan's `.requires` spelling collides
with the C++20 keyword) and `Dependency::when(feature)`; `--features a,b` /
`--no-default-features` on build/test/run/explain/deps; additive unification (defaults + target
requirements + requests); `VBS_FEATURE_<NAME>` defines on every target so action keys and the
cache follow the feature set; optional dependencies filtered before resolution; `vbs explain
--show-features` and `vbs metadata` report the unified set and its reasons. Verified by
`FullV1Tests.features_unify_defines_and_invalidate_action_keys` and
`optional_dependencies_follow_feature_selection`. The ABI rule (features may add definition
macros, never layout) is documented.
**Beats:** Cargo's best idea, applied to C++ — no C++ build system has additive, unified features.
Current state: `Dependency::feature(name)` is recorded and serialized into the lockfile but **is