Skip to content

fix(scripts,#1257): cargo-test.sh wrapper for platform GPU features#1285

Merged
joelteply merged 1 commit into
canaryfrom
fix/cargo-test-rust-wrapper-1257
May 15, 2026
Merged

fix(scripts,#1257): cargo-test.sh wrapper for platform GPU features#1285
joelteply merged 1 commit into
canaryfrom
fix/cargo-test-rust-wrapper-1257

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Summary

Make `cargo test` Just Work on every platform without forcing the dev to memorize the platform-correct Cargo feature incantation.

Before (the friction this card was filed for):
```bash
cd workers/continuum-core && cargo test tick_db_handle --lib

→ fails in vendored llama crate; "metal" or "cuda" feature required

```

After:
```bash
./scripts/cargo-test.sh tick_db_handle --lib # from src/
npm run test:rust -- tick_db_handle --lib
```

The wrapper sources the existing `scripts/shared/cargo-features.sh` detector — same single source of truth that `build-with-loud-failure.sh` and `git-prepush.sh` already use — and forwards arbitrary args to `cargo test` with platform-correct features appended.

Acceptance criteria check (from #1257)

  • Focused `continuum-core` Rust test command is documented and/or wrapped so macOS uses `metal,accelerate` by default. ← `scripts/cargo-test.sh` + `npm run test:rust` + `TESTING.md`.
  • The fix does not weaken or remove the CPU-only compile guard. ← Wrapper just appends features; the no-CPU-fallback contract (`tests/no_cpu_fallback_contract.rs`, perf(inference): silent CPU model fallbacks violate the no-CPU-fallback alpha rule #1262) still fires when invoked directly. `CARGO_TEST_NO_FEATURES=1` escape hatch lets you reproduce the bare-command failure to verify the guard.
  • Local docs distinguish intentional CPU-only test mode from normal Metal-backed local development. ← `TESTING.md` "CPU-only debug mode" section.
  • Fresh-install validation includes this path — left for a follow-on if Carl/install adds a smoke step. The wrapper itself is platform-agnostic and discoverable; the install path doesn't currently run cargo test.

Files

  • `scripts/cargo-test.sh` — wrapper script (new, +90 LOC)
  • `package.json` — adds `test:rust` npm alias next to `test:precommit`/`test:prepush`
  • `workers/continuum-core/TESTING.md` — documents the friction, the wrapper, and the per-platform feature mapping (new)

Test plan

  • `./src/scripts/cargo-test.sh --test generated_barrel_sync` → 8 passed, 0 failed (auto-applied `--features metal,accelerate` on this M5 Pro).
  • Precommit (TypeScript + browser ping): PASSED

🤖 Generated with Claude Code

…orm GPU features

Make the obvious developer command work on every platform without
requiring contributors to memorize the per-platform Cargo feature
incantation.

Before:
  cd workers/continuum-core && cargo test tick_db_handle --lib
  → fails in vendored llama crate; "metal" or "cuda" feature required

After:
  ./scripts/cargo-test.sh tick_db_handle --lib    (anywhere from src/)
  npm run test:rust -- tick_db_handle --lib
  → auto-detects platform, appends --features metal,accelerate (Mac) /
    --features cuda,load-dynamic-ort (Linux+Nvidia) / etc.

Implementation:
- `scripts/cargo-test.sh` sources the existing
  `scripts/shared/cargo-features.sh` detector (single source of truth
  for platform→features, also used by build-with-loud-failure.sh and
  git-prepush.sh) and forwards arbitrary args to `cargo test`.
- `npm run test:rust` alias added next to `test:precommit` /
  `test:prepush` for discoverability.
- `workers/continuum-core/TESTING.md` documents the friction, the
  wrapper, the CARGO_TEST_NO_FEATURES escape hatch (for verifying the
  loud-fail guard itself), and the relationship to the other test
  entry points.

The wrapper does NOT weaken the no-CPU-fallback compile guard — it
just spares the dev from typing the platform-correct features every
time. The guard still fires in CARGO_TEST_NO_FEATURES=1 mode.

Verified:
- ./src/scripts/cargo-test.sh --test generated_barrel_sync → 8 passed,
  0 failed (8.5s, used --features metal,accelerate on this Mac).

Closes #1257.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelteply joelteply merged commit 223bc8d into canary May 15, 2026
4 checks passed
@joelteply joelteply deleted the fix/cargo-test-rust-wrapper-1257 branch May 15, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant