cargo.build: a persistent build cache shared by all worlds

- The cargo target folder is <cache>/cargo-target, next to Wasmtime's
  cache, which moves to <cache>/wasmtime: Wasmtime's cleanup worker
  deletes unknown entries in its folder, also Cargo's artifacts.
- Builds use the SDK at <cache>/sdk/<content hash>/, so cargo reuses
  the compiled SDK in every world. /plugins/cargo/sdk/ stays for agents.
- Tests run in the release profile and share compiled crates with the
  release build.
- The cargo and cli tests use a persistent cache in CARGO_TARGET_TMPDIR:
  warm, the cargo suite takes 11 s (was 235 s) and the cli suite 6 s
  (was 149 s).
- nix flake check runs ignored stress tests. AGENTS.md: rules for fast
  tests.
This commit is contained in:
2026-10-23 08:05:15 +01:00
parent a090e1fd57
commit 93f092e02b
11 changed files with 155 additions and 48 deletions
+8 -2
View File
@@ -35,11 +35,17 @@ Keep it that way.
## Checks
```sh
nix flake check -L # all tests below; CI runs this on every push
nix develop -c cargo test --workspace
nix flake check -L # everything below, plus the stress tests; CI runs this on every push
nix develop -c cargo test --workspace # fast with a warm cache: run it during development
nix develop -c cargo build --release -p agent --target wasm32-wasip2
nix develop -c cargo clippy --workspace
```
`nix run -- init` and `nix run -- run` must keep working without other
setup.
Tests must stay fast. Only a few tests may wait for a timing (grace periods,
deadlines). Poll for a condition with a deadline, do not sleep. `#[ignore]` is
only for stress tests: `nix flake check` runs them with `--include-ignored`.
Tests that build plugins use the persistent cache in
`env!("CARGO_TARGET_TMPDIR")`.