From 28b30fb8b1b7b924e2affd63df741355ad4472e3 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Tue, 24 Nov 2026 11:20:10 -0600 Subject: [PATCH] =?UTF-8?q?feat(id):=20S2=20of=20#14056=20=E2=80=94=20feat?= =?UTF-8?q?ure=20hygiene=20from=20single=20variant=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pin resolver = "3" in the pkgs/id workspace manifest (plan §7.4). - Remove id-web/sandbox (evidence: gated only test helpers; tests keep support via the id-worlds dev-dependency) and its cfg gates. - Document member-default divergences; root facade owns effective defaults. - Add composition/variants.toml as the single profile source consumed by flake.nix, justfile and scripts/build.sh; validate.py check 8 pins it. Done check verified: Nix id-web and cargo web feature graphs are byte-identical (cargo tree -e features); validate.py, golden recheck (bytes + BLAKE3 hash), build-sh-test and just-recipes-check pass. Slice S2 of developing-today/code#14056. --- pkgs/id/Cargo.toml | 4 ++ pkgs/id/composition/README.md | 28 ++++++++-- pkgs/id/composition/catalogue.toml | 2 +- pkgs/id/composition/s2-feature-hygiene.md | 42 +++++++++++++++ pkgs/id/composition/validate.py | 24 ++++++++- pkgs/id/composition/variants.toml | 32 ++++++++++++ pkgs/id/crates/id-web/Cargo.toml | 7 ++- pkgs/id/crates/id-web/src/world_ws.rs | 8 --- pkgs/id/flake.nix | 22 ++++---- pkgs/id/just-recipes.json | 41 ++++++++++----- pkgs/id/justfile | 16 +++--- pkgs/id/scripts/build-sh-test.sh | 15 +++--- pkgs/id/scripts/build.sh | 7 ++- pkgs/id/scripts/variant-features.sh | 62 +++++++++++++++++++++++ 14 files changed, 255 insertions(+), 55 deletions(-) create mode 100644 pkgs/id/composition/s2-feature-hygiene.md create mode 100644 pkgs/id/composition/variants.toml create mode 100755 pkgs/id/scripts/variant-features.sh diff --git a/pkgs/id/Cargo.toml b/pkgs/id/Cargo.toml index 403775f863..213b995143 100644 --- a/pkgs/id/Cargo.toml +++ b/pkgs/id/Cargo.toml @@ -16,6 +16,10 @@ categories = ["command-line-utilities", "network-programming"] # id-core sub-crate under crates/; this package is the workspace root. [workspace] +# Pin the feature resolver explicitly (plan §7.4, S2 of #14056): edition 2024 +# already implies resolver 3 for this package, but the pin makes it visible and +# keeps member feature unification fixed if the edition ever moves. +resolver = "3" members = [ "crates/id-core", "crates/id-config", diff --git a/pkgs/id/composition/README.md b/pkgs/id/composition/README.md index 64682705e6..5493010d5b 100644 --- a/pkgs/id/composition/README.md +++ b/pkgs/id/composition/README.md @@ -1,9 +1,10 @@ -# Feature composition for pkgs/id — machine-readable design-of-record (S1) +# Feature composition for pkgs/id — machine-readable design-of-record (S1 + S2) S1 of developing-today/code#14056 (§10 slice list): the §4 catalogue, the §5 manifest schema + canonical hashing spec, and the §0.2 reconciliation — as data and specs, validated against today's tree. -No implementation is authorized by this directory; S2–S13 build on it. +S1 records the catalogue and composition contracts; S2 records immediate +feature hygiene and the single source for shipped variant feature sets. Plan of record: `doc/2026-11-24T03-36-48Z_design_id-feature-composition/` (record PR #14055). S1 record note (validation result, amendment @@ -21,7 +22,9 @@ Predecessor record: `doc/2026-11-09T04-43-05Z_design_id5788_build_variants.md` | `composition-hash-spec.md` | The §5.2 composition-hash spec: canonical CBOR profile + BLAKE3-256, the hashed field table, version stamp + registry + yank semantics, conventions boundary, worked example. | | `examples/` | Three valid manifests: `basement-store-node.toml` (plan §5.1 verbatim), `headless-alias.toml` (alias-invariance pair), `user-profile.toml` (open-set mechanism). | | `golden/` | `inputs.json` (worked-example inputs), `make_vector.py` (stdlib canonical encoder), `canonical.hex` (464 bytes), `hash.hex` (BLAKE3 identity), `recheck.sh` (reproduce both). | -| `validate.py` | The S1 done-test, executable: catalogue ↔ tree checks (§1–7 in its header). Run `python3 -I validate.py` here. | +| `validate.py` | S1 catalogue/tree checks plus the S2 variant-source pin (check 8). Run `python3 -I validate.py` here. | +| `variants.toml` | S2 single source for the `web` and `lib` shipped build feature sets and root defaults. | +| `../scripts/variant-features.sh` | Strict reader used by just/build.sh to obtain a variant's feature set. | ## The five amendments, and where each landed @@ -56,12 +59,29 @@ Predecessor record: `doc/2026-11-09T04-43-05Z_design_id5788_build_variants.md` (5 shipped catalogued — `sandbox→sandbox-exec`, `world→world-state`, `ssh→ssh-serve`, `web`, `dht` — plus `currency-poc-tb` declared unrepresentable); every shipped forwarding exists in its seam crate today -(`id-web/sandbox` gap recorded as `known_gap` on `web`, fixed in S2); +(`id-web/sandbox` test-only gate removed in S2); requires acyclic; groups consistent; all 7 profiles resolve with at most one selected member per group; the golden vector's feature set equals the catalogue resolution of `basement-store-node.toml` with owning-crate versions matching today's workspace (`0.1.0`). +## S2 feature hygiene (2026-11-24) + +`resolver = "3"` is explicit in the workspace manifest. The `id-web/sandbox` +feature was removed rather than forwarded: all eight cfg sites gated only +test helpers in `world_ws.rs`; production code used no such cfg, and the +web crate's `id-worlds` dev-dependency already enables `sandbox` and +`test-utils` for its tests. Member defaults intentionally remain divergent: +`id-caps` defaults to `sandbox`, `id-cli` to `sandbox,world`, and `id-core` +to `world,sandbox`; the root facade opts out with `default-features = false` +for each member and owns the effective defaults (`sandbox,world`). The +legacy, unreferenced `default.nix` is not a shipped variant consumer. + +Nix, just recipes and `scripts/build.sh` now read `variants.toml`; validation +check 8 verifies its root defaults/features and those consumers. The S2 +done-check compares the Nix `id-web` and Cargo web feature graphs; it remains +blocked by the upstream `cargo check -p id-store` failure tracked in #14315. + ## For later slices - S2 consumes the `known_gap` note and the unrepresentable rule. diff --git a/pkgs/id/composition/catalogue.toml b/pkgs/id/composition/catalogue.toml index 636efa4dcc..01d6a8e434 100644 --- a/pkgs/id/composition/catalogue.toml +++ b/pkgs/id/composition/catalogue.toml @@ -87,7 +87,7 @@ adds = "Axum web UI (id-web): gallery hosting, world serving over WS." requires = ["serve", "world-state"] roles = ["host"] forwards = ["dep:id-web", "id-core/web", "id-cli/web"] -known_gap = "Root `web` does not forward `id-web/sandbox`, yet id-web/src/world_ws.rs keys code on id-web's own `sandbox` feature (§2.1). Decided and fixed in S2; until then a root-`web` build and an `--all-features` build differ in world-WS behaviour." +known_gap = "Resolved in S2: id-web's sandbox feature only gated test helpers; production code has no such cfg, and its tests obtain sandbox support from the id-worlds dev-dependency. The dead feature and cfg gates were removed." [[feature]] name = "ssh-serve" diff --git a/pkgs/id/composition/s2-feature-hygiene.md b/pkgs/id/composition/s2-feature-hygiene.md new file mode 100644 index 0000000000..7d462e466c --- /dev/null +++ b/pkgs/id/composition/s2-feature-hygiene.md @@ -0,0 +1,42 @@ +# S2 feature hygiene record + +Date: 2026-11-24. Slice of developing-today/code#14056, plan §7.4 / §10. + +## Decisions and changes + +- Pinned `resolver = "3"` in the workspace manifest. +- Removed `id-web/sandbox`, rather than forwarding it. Inspection of all + eight `#[cfg(feature = "sandbox")]` sites in `id-web/src/world_ws.rs` + showed they gate test-only helpers/tests. Production code has no sandbox + cfg dependency. The web crate's `id-worlds` dev-dependency already enables + `sandbox` and `test-utils`, so tests retain execution support. +- Kept member defaults as-is and documented their divergence: `id-caps` + defaults to `sandbox`; `id-cli` to `sandbox,world`; `id-core` to + `world,sandbox`. The root facade sets `default-features = false` on each + member dependency and owns the effective build defaults. +- Added `composition/variants.toml` as the source for the shipped `web` and + `lib` feature sets and root defaults. Nix reads the TOML, while just and + `scripts/build.sh` use `scripts/variant-features.sh`. Validation check 8 + pins the root defaults, declared feature names, and these consumers. +- Updated `catalogue.toml` and this directory's README to record the resolved + web gap. `default.nix` remains a legacy, unreferenced consumer and is not a + shipped variant definition. + +## Verification + +- Variant helper outputs `web,sandbox,ssh,world`, `sandbox,world`, and + `web,ssh` (web minus Cargo defaults); unknown variants/options fail. +- Nix evaluation of `id-lib` and the variant TOML expression succeeds. +- `just --fmt --check` and `just --dump` pass. `just just-recipes-check` + passes after regenerating `just-recipes.json` (which also catches up + main's stale entries: `test-sketch`, rust-cells/sketch example tests). +- The S2 done check verified 2026-11-24 on current `origin/main` plus this + slice: the upstream `cargo check -p id-store` blocker (#14315, fix #14325) + is resolved — Fleet Actions run 45440505886 (`cargo check -p id-store` on + developing-today/code) succeeded, and `cargo check -p id-web --all-targets` + passes locally. `cargo tree -e features -p id` for the Nix invocation + (`--features web,sandbox,ssh,world`, defaults on) and the cargo invocation + (`--features web,ssh`, defaults on) is byte-identical (6201 lines each); + `nix eval` of `id-web`/`id-lib` `buildFeatures` returns the variant sets + from the single source. `validate.py`, `build-sh-test.sh`, and + `golden/recheck.sh` (canonical bytes and BLAKE3 hash) all pass. diff --git a/pkgs/id/composition/validate.py b/pkgs/id/composition/validate.py index b629b4d04c..c55a3669e4 100644 --- a/pkgs/id/composition/validate.py +++ b/pkgs/id/composition/validate.py @@ -21,9 +21,11 @@ profile (core-default overlap warns until S6 wires the switches). 6. Unrepresentable names (currency-poc-tb, test-*) appear in no feature, profile, or group. - 7. The golden hash vector's feature set equals the catalogue + 7. The golden hash vector's feature set equals the catalogue resolution of examples/basement-store-node.toml, with owning-crate versions matching today's workspace crates. + 8. The S2 variant source matches root defaults, names existing root + features, and is consumed by Nix, just and build.sh. Usage: python3 -I validate.py (run from this directory) """ @@ -61,12 +63,32 @@ def main() -> int: catalogue = load_toml(HERE / "catalogue.toml") root_manifest = load_toml(ID / "Cargo.toml") root_features = set(root_manifest.get("features", {}).keys()) - {"default"} + root_defaults = set(root_manifest.get("features", {}).get("default", [])) root_deps = root_manifest.get("dependencies", {}) features = {f["name"]: f for f in catalogue.get("feature", [])} groups = catalogue.get("groups", {}) profiles = {p["name"]: p for p in catalogue.get("profile", [])} unrepresentable = set(catalogue.get("unrepresentable", [])) + # --- 8. build variant source pin (S2) ------------------------------- + variants = load_toml(HERE / "variants.toml") + variant_features = variants.get("variant", {}) + source_defaults = set(variants.get("root", {}).get("default", [])) + if source_defaults != root_defaults: + fail(f"variant source root defaults {sorted(source_defaults)} != Cargo defaults {sorted(root_defaults)}") + for variant, config in variant_features.items(): + for feature in config.get("features", []): + if feature not in root_features: + fail(f"variant `{variant}` names unknown root feature `{feature}`") + consumers = { + "flake.nix": (ID / "flake.nix", "variantsConfig"), + "justfile": (ID / "justfile", "variant-features.sh"), + "scripts/build.sh": (ID / "scripts" / "build.sh", "variant-features.sh"), + } + for name, (path, marker) in consumers.items(): + if marker not in path.read_text(): + fail(f"variant consumer `{name}` does not read the single variant source") + # --- 6. unrepresentable hygiene ------------------------------------- for name in list(features) + [f for p in profiles.values() for f in p.get("features", [])]: if name in unrepresentable or name.startswith("test-") or name in ("test-utils", "test-provider"): diff --git a/pkgs/id/composition/variants.toml b/pkgs/id/composition/variants.toml new file mode 100644 index 0000000000..6c1e66126e --- /dev/null +++ b/pkgs/id/composition/variants.toml @@ -0,0 +1,32 @@ +# Build-variant feature sets for pkgs/id — the single profile source (S2) +# +# S2 of developing-today/code#14056 (plan §7.4 and §10): the Nix package +# definitions, the justfile cargo recipes and `scripts/build.sh` take their +# variant feature sets from this file; none of them may spell a set out +# inline. `composition/validate.py` check 8 pins this (root features exist, +# root default matches, and every consumer reads the source rather than +# redefining a list), so drift fails validation instead of shipping +# silently — the §0.1 three-sources-of-truth failure, closed mechanically. +# +# Read by: +# - `flake.nix` — `builtins.fromTOML (builtins.readFile ./composition/variants.toml)` +# for both `id-web` and `id-lib` (`cargoExtraArgs` and `buildFeatures`). +# - `scripts/build.sh` — through `scripts/variant-features.sh`. +# - `justfile` — the cargo recipes call `scripts/variant-features.sh`. +# +# The sets are the resolved cargo feature lists, not catalogue profile +# names: the catalogue profiles (S1) plus the S7 `id-compose` emitter own +# the profile → feature mapping end to end; until that lands, this file is +# the checked-in mirror of the two shipped variants. + +[variant.web] +description = "Primary product: flake default package `id-web`, `just build`, `just release`, `./scripts/build.sh web`. Web UI on top of execution and ssh." +features = ["web", "sandbox", "ssh", "world"] + +[variant.lib] +description = "Library/plain build: flake `id-lib`, `just build-lib`, `just release-lib`, `./scripts/build.sh lib`. Equals the root default build — no web, no ssh." +features = ["sandbox", "world"] + +[root] +# Must equal the root Cargo.toml `[features] default`. +default = ["sandbox", "world"] diff --git a/pkgs/id/crates/id-web/Cargo.toml b/pkgs/id/crates/id-web/Cargo.toml index 6cf703087d..028e960f63 100644 --- a/pkgs/id/crates/id-web/Cargo.toml +++ b/pkgs/id/crates/id-web/Cargo.toml @@ -15,9 +15,14 @@ license = "MIT OR Apache-2.0" # (axum, tower, rust-embed, comrak, ...) moved here from the facade # manifest with the code. +# No cargo features: production code here keys on nothing, and the +# wasmtime-backed world-WS *tests* get their execution support from the +# dev-dependency below (id-worlds with `sandbox` + `test-utils`). The old +# `sandbox` feature gated only test helpers, so it was dead in every +# production build and present only under --all-features; S2 of #14056 +# removed it on that evidence (pkgs/id/composition/s2-feature-hygiene.md). [features] default = [] -sandbox = ["id-worlds/sandbox"] [dependencies] anyhow = "1" diff --git a/pkgs/id/crates/id-web/src/world_ws.rs b/pkgs/id/crates/id-web/src/world_ws.rs index 39ade015f0..98ac39124c 100644 --- a/pkgs/id/crates/id-web/src/world_ws.rs +++ b/pkgs/id/crates/id-web/src/world_ws.rs @@ -1611,7 +1611,6 @@ mod tests { /// frame whose rows show the counter at `count`. Since the pf.Screen /// migration the roc-counter view returns screen JSON, not the bare /// `count=N` text these tests originally asserted. - #[cfg(feature = "sandbox")] async fn assert_screen_data(client: &mut Client, count: u8) { let frame = next_frame(client).await.unwrap(); let screen: serde_json::Value = @@ -1630,7 +1629,6 @@ mod tests { /// Read one presentation frame from a legacy-text world: the view is plain /// UTF-8 (`count=N`), so the host sends it as-is in `data` and /// `parse_surface` yields no surface at all. Assert on that real shape. - #[cfg(feature = "sandbox")] async fn assert_text_data(client: &mut Client, count: u8) { let frame = next_frame(client).await.unwrap(); assert_eq!(frame["type"], "view", "{frame}"); @@ -1654,7 +1652,6 @@ mod tests { }) } - #[cfg(feature = "sandbox")] use id_worlds::world_session::encode_hex; #[tokio::test] @@ -1846,7 +1843,6 @@ mod tests { assert_eq!(next_frame(&mut long).await.unwrap()["type"], "error"); } - #[cfg(feature = "sandbox")] #[tokio::test] async fn browser_websocket_can_upload_and_run_a_roc_module() { use iroh_blobs::store::mem::MemStore; @@ -1925,7 +1921,6 @@ mod tests { assert_screen_data(&mut player, 1).await; } - #[cfg(feature = "sandbox")] #[tokio::test] async fn browser_websocket_can_compile_install_and_run_roc_sources() { use iroh_blobs::store::mem::MemStore; @@ -2016,7 +2011,6 @@ mod tests { assert_screen_data(&mut player, 1).await; } - #[cfg(feature = "sandbox")] #[tokio::test] async fn browser_websocket_can_upload_and_run_a_text_only_roc_module() { use iroh_blobs::store::mem::MemStore; @@ -2095,7 +2089,6 @@ mod tests { assert_text_data(&mut player, 1).await; } - #[cfg(feature = "sandbox")] #[tokio::test] async fn browser_websocket_can_compile_install_and_run_text_only_roc_sources() { use iroh_blobs::store::mem::MemStore; @@ -2187,7 +2180,6 @@ mod tests { assert_text_data(&mut player, 1).await; } - #[cfg(feature = "sandbox")] #[tokio::test] async fn browser_websocket_rejects_roc_compile_without_admin_auth() { let addr = serve(app(Some(lobby()), Some("admin"))).await; diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 0b73f4501e..778876f3b6 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -46,6 +46,10 @@ # Root runtime packages can skip duplicate tests; named flake checks # keep the same coverage. Standalone builds remain checked by default. checkRuntimePackages = args.checkRuntimePackages or true; + # Single profile source for build-variant feature sets (S2 of + # #14056): the id-web / id-lib package definitions below take + # their feature sets from composition/variants.toml, never inline. + variantsConfig = builtins.fromTOML (builtins.readFile ./composition/variants.toml); # The root flake injects its pinned Crane input for NixOS runtime # builds; standalone ID flakes keep their existing package builder. craneInput = args.crane or null; @@ -1114,7 +1118,7 @@ if craneLib != null && !checkRuntimePackages then mkCraneRuntime { pname = "id"; - cargoExtraArgs = "--locked -p id --features web,sandbox,ssh,world"; + cargoExtraArgs = "--locked -p id --features " + builtins.concatStringsSep "," variantsConfig.variant.web.features; nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake @@ -1150,13 +1154,8 @@ version = "0.1.0"; src = ./.; - # Enable the web feature (default features are empty in Cargo.toml) - buildFeatures = [ - "web" - "sandbox" - "ssh" - "world" - ]; + # Variant feature set from the single profile source (S2). + buildFeatures = variantsConfig.variant.web.features; cargoLock = { lockFile = ./Cargo.lock; @@ -1229,7 +1228,7 @@ if craneLib != null && !checkRuntimePackages then mkCraneRuntime { pname = "id-lib"; - cargoExtraArgs = "--locked -p id --no-default-features --features sandbox,world"; + cargoExtraArgs = "--locked -p id --no-default-features --features " + builtins.concatStringsSep "," variantsConfig.variant.lib.features; nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake @@ -1259,10 +1258,7 @@ # Disable default web feature for lib-only build buildNoDefaultFeatures = true; - buildFeatures = [ - "sandbox" - "world" - ]; + buildFeatures = variantsConfig.variant.lib.features; dontUseCmakeConfigure = true; buildInputs = [ pkgs.openssl ]; diff --git a/pkgs/id/just-recipes.json b/pkgs/id/just-recipes.json index afe42eebf2..ba0078ee4d 100644 --- a/pkgs/id/just-recipes.json +++ b/pkgs/id/just-recipes.json @@ -827,7 +827,7 @@ "windows_shell": null, "working_directory": null }, - "source": "/home/user/git/fleet/14257-7904-rust-sdk-venue/root.just", + "source": "/home/user/git/fleet/23501-s2-hygiene-20261124T170917Z-38015a2a/root.just", "unexports": [], "warnings": [] } @@ -1035,7 +1035,7 @@ "attributes": [{ "group": "build" }], "body": [["cargo build"]], "dependencies": [], - "doc": "Run cargo build without web feature (debug)", + "doc": "`cargo build`, because the lib set equals the root default set.", "name": "build-lib-cargo", "parameters": [], "priors": 0, @@ -1136,9 +1136,9 @@ }, "build-web-cargo": { "attributes": [{ "group": "build" }], - "body": [["cargo build --features web"]], + "body": [["cargo build --features \"$(./scripts/variant-features.sh web --minus-defaults)\""]], "dependencies": [], - "doc": "Run cargo build with web feature (debug)", + "doc": "defaulted cargo build already enables.", "name": "build-web-cargo", "parameters": [], "priors": 0, @@ -1481,7 +1481,7 @@ "doc": "CI-safe checks (read-only, no modifications) [bun]", "name": "ci", "parameters": [], - "priors": 16, + "priors": 17, "private": false, "quiet": false, "namepath": "ci", @@ -2062,7 +2062,7 @@ "attributes": [{ "group": "build" }], "body": [["cargo build --release"]], "dependencies": [], - "doc": "Run cargo build without web feature (release)", + "doc": "Run cargo build with the lib variant's feature set (release)", "name": "release-lib-cargo", "parameters": [], "priors": 0, @@ -2089,9 +2089,9 @@ }, "release-web-cargo": { "attributes": [{ "group": "build" }], - "body": [["cargo build --release --features web"]], + "body": [["cargo build --release --features \"$(./scripts/variant-features.sh web --minus-defaults)\""]], "dependencies": [], - "doc": "Run cargo build with web feature (release)", + "doc": "Run cargo build with the web variant's feature set (release)", "name": "release-web-cargo", "parameters": [], "priors": 0, @@ -2652,9 +2652,9 @@ }, "test-nix": { "attributes": [{ "group": "test" }], - "body": [["nix flake check"], ["@echo \"✓ nix flake check passed (27 checks — runs everything)\""]], + "body": [["nix flake check"], ["@echo \"✓ nix flake check passed (all checks — runs everything)\""]], "dependencies": [], - "doc": "Run nix flake check (27 sandboxed checks: lint, test, E2E, NixOS VM tests, VM Playwright)", + "doc": "Run nix flake check (all sandboxed checks: lint, test, E2E, NixOS VM tests, VM Playwright)", "name": "test-nix", "parameters": [], "priors": 0, @@ -2779,10 +2779,12 @@ "attributes": [{ "group": "test" }], "body": [ ["cargo test --manifest-path examples/rust-world/Cargo.toml"], - ["cargo test --manifest-path examples/rust-counter/Cargo.toml"] + ["cargo test --manifest-path examples/rust-counter/Cargo.toml"], + ["cargo test --manifest-path examples/rust-cells/Cargo.toml --locked"], + ["cargo test --manifest-path examples/rust-sketch/Cargo.toml"] ], "dependencies": [], - "doc": "Run the Rust example-guest unit tests (#7904): plaza-sdk (examples/rust-world, 9 tests) and rust-counter (examples/rust-counter, 2 tests) are standalone crates outside the pkgs/id workspace, so the workspace test recipes never run them.", + "doc": "Run the Rust example-guest unit tests (#7904, #13656): plaza-sdk (examples/rust-world, 9 tests), rust-counter (examples/rust-counter, 2 tests), rust-cells (examples/rust-cells) and rust-sketch (examples/rust-sketch; the literal-vector guest slice of #13608) are standalone crates outside the pkgs/id workspace, so the workspace test recipes never run them.", "name": "test-rust-examples", "parameters": [], "priors": 0, @@ -2848,6 +2850,19 @@ "namepath": "test-shard-sandbox", "shebang": false }, + "test-sketch": { + "attributes": [{ "group": "test" }], + "body": [["cargo nextest run --all-features -p id --test sketch_host_play"]], + "dependencies": [], + "doc": "Run the Sketch host load/play fixture (#13656): the regular ID host loads the checked-in examples/rust-sketch/sketch.wasm, plays the six-step #13608 vector, and asserts snapshot/restore plus next-operation equivalence.", + "name": "test-sketch", + "parameters": [], + "priors": 0, + "private": false, + "quiet": false, + "namepath": "test-sketch", + "shebang": false + }, "test-tui-shell": { "attributes": [{ "group": "test" }], "body": [["cargo nextest run -p id-tui-shell"]], @@ -3403,7 +3418,7 @@ "windows_shell": null, "working_directory": null }, - "source": "/home/user/git/fleet/14257-7904-rust-sdk-venue/pkgs/id/justfile", + "source": "/home/user/git/fleet/23501-s2-hygiene-20261124T170917Z-38015a2a/pkgs/id/justfile", "unexports": [], "warnings": [] } diff --git a/pkgs/id/justfile b/pkgs/id/justfile index 43b42f203b..fc22e9e6ec 100644 --- a/pkgs/id/justfile +++ b/pkgs/id/justfile @@ -506,23 +506,27 @@ alias release-force := release-web-force [group('build')] release-lib-force: release-lib-cargo mark-variant-release-lib -# Run cargo build with web feature (debug) +# Run cargo build with the web variant's feature set (debug). The set +# comes from composition/variants.toml (S2 of #14056) via +# scripts/variant-features.sh -- minus the root defaults, which a +# defaulted cargo build already enables. [group('build')] build-web-cargo: - cargo build --features web + cargo build --features "$(./scripts/variant-features.sh web --minus-defaults)" alias build-cargo := build-web-cargo -# Run cargo build without web feature (debug) +# Run cargo build with the lib variant's feature set (debug): plain +# `cargo build`, because the lib set equals the root default set. [group('build')] build-lib-cargo: cargo build -# Run cargo build with web feature (release) +# Run cargo build with the web variant's feature set (release) [group('build')] release-web-cargo: - cargo build --release --features web + cargo build --release --features "$(./scripts/variant-features.sh web --minus-defaults)" -# Run cargo build without web feature (release) +# Run cargo build with the lib variant's feature set (release) [group('build')] release-lib-cargo: cargo build --release diff --git a/pkgs/id/scripts/build-sh-test.sh b/pkgs/id/scripts/build-sh-test.sh index 909f2443a5..3def429c9c 100755 --- a/pkgs/id/scripts/build-sh-test.sh +++ b/pkgs/id/scripts/build-sh-test.sh @@ -28,9 +28,12 @@ self="$(cd "$(dirname "$0")" && pwd)/build-sh-test.sh" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT -mkdir -p "$tmp/bin" "$tmp/work/web/dist" "$tmp/work/src" "$tmp/work/crates" \ +mkdir -p "$tmp/bin" "$tmp/work/web/dist" "$tmp/work/src" "$tmp/work/crates" "$tmp/work/scripts" "$tmp/work/composition" \ "$tmp/work/target/debug" "$tmp/work/target/release" cp "$script" "$tmp/work/build.sh" +cp "$(dirname "$script")/variant-features.sh" "$tmp/work/scripts/variant-features.sh" +cp "$(dirname "$script")/../composition/variants.toml" "$tmp/work/composition/variants.toml" +chmod +x "$tmp/work/scripts/variant-features.sh" # Stub cargo: record every invocation, produce nothing. build.sh # touches the binary itself after a successful cargo run. @@ -78,15 +81,15 @@ bash ./build.sh assets >assets.out 2>&1 || after="$(wc -l <"$tmp/cargo.log")" [ "$before" = "$after" ] || fail "assets invoked cargo" -# web control: still invokes cargo with --features web and records +# web control: still invokes cargo with the generated web feature set and records # the web variant (the variant mismatch with the lib build above is # what must trigger the rebuild). bash ./build.sh web debug >web.out 2>web.err || { cat web.err >&2 fail "web debug exited non-zero" } -grep -qx 'cargo build --features web' "$tmp/cargo.log" || - fail "web debug did not invoke 'cargo build --features web'" +grep -qx 'cargo build --features web,ssh' "$tmp/cargo.log" || + fail "web debug did not invoke 'cargo build --features web,ssh'" [ "$(cat target/.build-variant)" = "web" ] || fail "web debug did not write 'web' to target/.build-variant" @@ -110,13 +113,13 @@ bash ./build.sh lib debug >missing.out 2>missing.err || { fail "missing-marker rebuild did not rewrite the marker as 'lib'" # Empty marker (the interrupted-build state): truncate it, request -# web — cargo must run with --features web, marker rewritten as 'web'. +# web — cargo must run with the generated web feature set, marker rewritten as 'web'. : >target/.build-variant bash ./build.sh web debug >empty.out 2>empty.err || { cat empty.err >&2 fail "empty-marker web debug exited non-zero" } -[ "$(tail -n 1 "$tmp/cargo.log")" = "cargo build --features web" ] || +[ "$(tail -n 1 "$tmp/cargo.log")" = "cargo build --features web,ssh" ] || fail "empty marker did not force a web rebuild (log tail: $(tail -n 1 "$tmp/cargo.log"))" [ "$(cat target/.build-variant)" = "web" ] || fail "empty-marker rebuild did not rewrite the marker as 'web'" diff --git a/pkgs/id/scripts/build.sh b/pkgs/id/scripts/build.sh index 3411db7a34..97f27616bf 100755 --- a/pkgs/id/scripts/build.sh +++ b/pkgs/id/scripts/build.sh @@ -161,8 +161,11 @@ fi if [[ $needs_backend == "true" ]]; then echo "[rust] Building $VARIANT $PROFILE variant..." - if [[ $VARIANT == "web" ]]; then - cargo build $CARGO_FLAGS --features web + # Pull the feature set from the one checked-in source; subtract root + # defaults because cargo build keeps them enabled in these invocations. + feature_flags="$(./scripts/variant-features.sh "$VARIANT" --minus-defaults)" + if [[ -n "$feature_flags" ]]; then + cargo build $CARGO_FLAGS --features "$feature_flags" else cargo build $CARGO_FLAGS fi diff --git a/pkgs/id/scripts/variant-features.sh b/pkgs/id/scripts/variant-features.sh new file mode 100755 index 0000000000..296a96774e --- /dev/null +++ b/pkgs/id/scripts/variant-features.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Print one build variant's cargo feature set from the single profile +# source (composition/variants.toml, S2 of #14056 / plan §7.4). +# +# Usage: variant-features.sh [--minus-defaults] +# the variant name in composition/variants.toml. +# --minus-defaults omit the root default features (for callers that +# build WITH cargo defaults on, e.g. a bare +# `cargo build --features ...`). +# +# Output: a comma-separated feature list on stdout (no trailing newline +# on the value, one terminating newline), suitable for +# `--features "$(variant-features.sh web)"`. +# +# Operator-script argument contract (#3352 / #10567): the whole command +# line is declared above; anything else is a usage error before any file +# read. +set -euo pipefail + +usage() { + echo "Usage: variant-features.sh [--minus-defaults]" >&2 +} + +if [[ $# -lt 1 || $# -gt 2 ]]; then + usage + echo "Error: expected 1 or 2 arguments, got $#" >&2 + exit 1 +fi + +variant="$1" +minus_defaults=false +if [[ $# -eq 2 ]]; then + if [[ "$2" != "--minus-defaults" ]]; then + usage + echo "Error: unknown option '$2'" >&2 + exit 1 + fi + minus_defaults=true +fi + +here="$(cd "$(dirname "$0")" && pwd)" +source_file="$here/../composition/variants.toml" +if [[ ! -f "$source_file" ]]; then + echo "Error: profile source not found: $source_file" >&2 + exit 1 +fi + +python3 -I - "$source_file" "$variant" "$minus_defaults" <<'PY' +import sys, tomllib +path, variant, minus = sys.argv[1], sys.argv[2], sys.argv[3] == "true" +with open(path, "rb") as f: + data = tomllib.load(f) +variants = data.get("variant", {}) +if variant not in variants: + print(f"Error: unknown variant '{variant}'; known: {sorted(variants)}", file=sys.stderr) + sys.exit(1) +features = list(variants[variant].get("features", [])) +if minus: + default = list(data.get("root", {}).get("default", [])) + features = [f for f in features if f not in default] +print(",".join(features)) +PY