Skip to content

test: split tests into layers with wall-clock budgets - #12885

Merged
cv merged 17 commits into
v1from
test/layer-budgets
Oct 9, 2026
Merged

cv merged 17 commits into
v1from
test/layer-budgets

Conversation

@cv

@cv cv commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #12876.

Failure

Tests overlapped across layers, and nothing measured or limited how long they ran. On v1 before this PR:

  • On linux_amd64 the test step took 78 s wall for 620 s of tests.
  • The lifecycle step took 744 s wall for 2,948 s of tests.
  • Three end-to-end modules accounted for 82% of the lifecycle time.
  • Many end-to-end tests repeated full deployments to cover variants that the SDK already proves equivalent.

Decision

Make test time visible first. Then move each group of tests to the layer that owns its behavior, keeping one end-to-end check per behavior.

  • Timing report (Enforce wall-clock budgets per test layer #12877): after the test, lifecycle, and live steps, cargo ci prints where the time went: wall and summed time, time per binary and module, and the slowest tests. It also writes the report to the GitHub job summary. Each lifecycle partition reports its own tests. The report reads nextest's JUnit output with quick-junit, and the test step's JUnit report is now uploaded.
  • deployment:
    • Each configuration variant deploys once: web_search, execution_settings, tool_disclosure, and provider_definitions ran 15 lifecycles and now run 6.
    • cli_redaction checks each redaction rule once through the CLI.
    • The SDK tests that own each dropped variant are named in the commits.
  • remote_service:
    • The Hermes lifecycle without authentication repeated the OpenClaw one, so it is removed.
    • Pi stops after admission and refused sandbox changes.
    • Refused changes export once instead of eight times.
  • opentofu_openshell: the reference graph surfaces each gateway capability failure kind once through OpenTofu, in 14 runs instead of 23. nemoclaw-openshell observation tests own the reasons.
  • fabric_deployment: every harness applies, reapplies, exports, and destroys. Only OpenClaw and Pi also run the harness-independent model change and refusals.
  • inference_discovery: each catalog response is planned once. nemoclaw-discovery owns the classification.
  • Optimized dependencies: dependencies build at opt-level 2 in development and test builds, and workspace crates stay unoptimized. Unoptimized JSON Schema validation dominated the onboarding journeys.
  • Onboarding wizard (perf(onboarding): resolve an unchanged journey once #12901, merged into this branch): the wizard resolves an unchanged journey once.

Validation

Measured in CI run 37916518035, with cold dependency caches:

linux_amd64 Before After
test step 78 s wall, 620 s summed 24 s wall, 189 s summed
Lifecycle, summed 2,948 s 1,898 s
Lifecycle shards, wall 744 s unsharded 309 s and 262 s
deployment 1,331 s 922 s
remote_service 697 s 433 s
fabric_deployment 379 s 164 s
opentofu_openshell 230 s 155 s

linux_arm64 follows the same pattern: the test step went from 44 s to 19 s wall, and lifecycle from 2,642 s to 1,845 s summed.

  • Cost: optimizing dependencies lengthens a cold build. "Build test executables" took 315 s instead of 118–155 s on the previous cold run. Only v1 pushes save the dependency cache, and .cargo/config.toml is part of its key, so pull request runs build cold until this merges.
  • Local checks for each commit: each changed test passes against a rebuilt bundle. Workspace clippy at -D warnings and fmt are clean. A new nemoclaw-build test covers the timing report.

Follow-ups

Test time had no visible budget: the lifecycle step reached 684 s on
linux_arm64 for 2,673 s of tests, and finding the slow tests meant
downloading an artifact and reading JUnit XML.

After the test, lifecycle, and live steps, cargo ci reads the step's
nextest JUnit report and prints its test count, wall and summed time,
the time per test binary and module, and the slowest tests. In GitHub
Actions the report goes to the job summary. The deterministic step now
writes and uploads a JUnit report too.

Part of #12877.
@cv cv added area: ci CI workflows, checks, release automation, or GitHub Actions area: e2e End-to-end tests, nightly failures, or validation infrastructure v1 NemoClaw v1 branch labels Oct 9, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

cv added 9 commits October 9, 2026 00:04
The timing report parsed JUnit XML by hand. quick-junit, the library
nextest writes these reports with, deserializes them. The report also
limits its module table to the slowest rows and sums the rest, since
the deterministic step has over a hundred modules.
#12884 moved the native test steps into native-platform.yml and runs the
Unix lifecycle in two partitions. The timing report now names the
partition it covers, and the deterministic step's JUnit report is
uploaded from the new workflow.
The deployment module took 1,331 s of the 2,948 s summed lifecycle time
on linux_amd64. Profiling one lifecycle() locally showed where it goes:
about 11-18 s per full plan, apply, CLI export, reapply, drift checks,
and CLI destroy, of which five OpenTofu plans take a third. On CI each
lifecycle takes about 33 s, and 12 tests ran 24 of them to cover
configuration variants that the SDK already proves equivalent.

Each variant group now deploys once per behavior the deployment owns:

- web_search: 6 -> 2 lifecycles. One per provider, in different scopes;
  web_search::agent_inline_and_enclosing_definitions_compile_to_the_same_search_grants
  owns scope equivalence.
- execution_settings: 3 -> 1. Heartbeats are opaque native settings;
  execution_settings owns the timeout projection.
- tool_disclosure: 2 -> 1. agent_tools::disclosure_belongs_to_opaque_native_settings
  owns both modes.
- provider_definitions: 4 -> 2. One scope per harness;
  inference_references owns that both scopes compile and export unchanged.

Locally the four tests take 34 s at four threads instead of over 109 s
for web_search alone.

Part of #12882.
cli_redaction ran 13 CLI applies, about 30 s locally: four credentials in
both output formats. nemoclaw-sdk's process tests own the redaction rules
for short, colliding, overlapping, and Unicode credentials. The CLI test
now checks that each rule reaches a failed apply's output, one credential
per rule across both formats, in 18 s.

Part of #12882.
remote_service took 697 s summed on linux_amd64. Locally each of its
five full lifecycles runs about 30 CLI commands in 80-136 s, and only two
steps depend on the harness: image pull checks for OpenClaw and refused
sandbox changes for Pi.

- The non-authenticated Hermes lifecycle repeated the OpenClaw vLLM
  lifecycle step for step. Hermes with remote vLLM stays covered by the
  bearer lifecycle, and fabric_deployment covers each harness.
- Pi stops after admission without generation, its refused sandbox
  changes, and destroy; the service recovery that followed did not
  depend on the harness.
- Refused sandbox changes exported after each of eight refusals, about
  4 s each, while byte comparisons of the saved intent and state already
  prove nothing changed. One export after the refusals checks that the
  intent still reproduces the accepted document.

Locally the module sums 400 s instead of 562 s across its tests.

Part of #12882.
…OpenTofu

production_provider_applies_refreshes_and_destroys_the_reference_graph
was the slowest test in opentofu_openshell, 113 s on linux_amd64, with 23
OpenTofu runs locally. It planned once per incompatibility reason, five
times, and re-applied a saved plan for both failure kinds in both the
unchanged and creating cases.

nemoclaw-openshell's observation tests own every incompatibility reason
and its message. Through OpenTofu, one precondition failure and one
failed read now show both diagnostics reach the user, and the saved-plan
check runs each failure kind once: the driver change for an unchanged
plan and the failed read while creating. The test runs 14 OpenTofu
commands in 19 s locally instead of 30 s.

Part of #12882.
# Conflicts:
#	crates/nemoclaw-e2e/tests/remote_service.rs
fabric_deployment took 328 s summed on linux_amd64, about 30 s for each
of ten harnesses. Locally each harness took 26 s: 3 s to apply, 16 s
for a model change and its export, and 7 s refusing adapter, image, and
observed sandbox changes and destroying. Only the first part depends on
the harness; the rest exercises the Fabric provider and the SDK's
sandbox protections the same way every time.

Every harness still applies, reapplies without rewriting its runtime
configuration, exports unchanged, and destroys. OpenClaw also runs the
model change and the refusals, and Pi its route-role model change.

Locally the module sums about 146 s instead of 280 s; eight harnesses
take 9 s each instead of 26 s.

Part of #12882.
The onboarding TUI journeys took 168 s summed in the deterministic step on
linux_amd64, up to 15 s per journey. Each answer resolves the journey
several times, and each resolution validates the partial document against
the SDK's JSON Schema and parses it; unoptimized, jsonschema and its
regex and JSON dependencies made one resolution take about 8 ms.

Dependencies now build at opt-level 2 in the dev and test profiles;
workspace crates stay unoptimized. Locally the slowest journey takes
1.0 s instead of 2.5 s, and the nemoclaw-onboarding, nemoclaw-authoring,
and nemoclaw-sdk tests finish in 8.0 s instead of 13.4 s at eight
threads. A cold workspace build takes 82 s instead of 46 s locally; CI
restores dependencies from its cache, and this file is part of the cache
key, so the first run after this change builds cold.

Part of #12882.
cv added 2 commits October 9, 2026 03:13
Stacked on #12885. Part of #12882.

## Failure

The onboarding wizard resolved its journey again for each of these: the
next question, each step, the review document, and every view redraw. A
resolution validates the partial document against the SDK schema and
parses it. Instrumenting the slowest example journey,
`spark_spark_inline`, showed 196 resolutions across 36 answers, about 8
ms each in a debug build. This made the TUI journey tests the largest
cost in the deterministic test step: 168 s summed on `linux_amd64`.
Every redraw of the running TUI paid the same cost.

## Decision

- `JourneyWizard` keeps its last resolution, including a failed one, and
reuses it until the state or observations change.
- `state` and `observations` are private. Every change goes through
`submit`, `delegate`, `back`, or `remember`, which clear the kept
resolution. The view and terminal read them through accessors. Tests
record observations through a test-only `record` method that also clears
it.
- The view's information notes and review document use the kept
resolution.
- `JourneyState::answer` still resolves internally. That code is in
`nemoclaw-authoring` and unchanged here.

## Validation

- **New test:** asking for the next question and the document repeatedly
resolves once. An answer, an undo, and a new observation each cause
exactly one new resolution. The test was written first and failed to
compile without the counter.
- **Timings:** on top of #12885's optimized dependencies,
`spark_spark_inline` takes 0.74 s locally instead of 1.06 s. The
`nemoclaw-onboarding` library tests take 0.92 s instead of 1.28 s.
- **Checks:** all 79 library tests pass, and clippy at `-D warnings` and
fmt are clean.
optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_uncertainty
took 50 s on linux_amd64. For both provider protocols it planned four
catalog responses twice, through the CLI and the SDK: 16 plans.

nemoclaw-discovery's inference tests own how each catalog response is
classified. The deployment test now plans each response once through
the CLI, split across the Anthropic and OpenAI protocols so both still
read their catalog and the Anthropic version header is still sent. The
CLI's JSON already shows the plan is complete and unchanged, which the
SDK preview repeated. The test takes 22 s locally.

Part of #12882.
@cv
cv marked this pull request as ready for review October 9, 2026 10:53
# Conflicts:
#	.cargo/config.toml
#	Cargo.lock
#	crates/nemoclaw-build/Cargo.toml
Stacked on #12885. Part of #12876 (finding 1 in [the overlap
map](#12876 (comment))).

## Failure

About 35 system tests repeated the generic lifecycle for one
configuration variant each, about 30 s apiece on CI. The lifecycle
checks that export reproduces the document, an unchanged reapply is a
no-op, and destroy cleans up. Most variants differ only in what they
compile to, which unit tests already cover. Export's consistency check
could not run without OpenTofu.

## Decision

- **Pure export check:** export's consistency check is now a pure
function, `exported`. A new unit test compiles every example, echoes its
targets back as provider observations, and checks three things: the
saved document exports unchanged, a drifted sandbox image or provider
endpoint stops the export, and a missing observation stops it too.
- **One system lifecycle per drift kind:**
- Web search registrations: Tavily only, since Brave uses the same code
path.
  - Sandbox policy across sandboxes: `separate_agent_sandboxes`.
  - Harness native settings: `tool_disclosure`.
- The external-gateway lifecycle (`sdk_apply_cli_export…`) and the
remote Podman lifecycles remain.
- **Removed system tests:**
- From `deployment`: `explicit_network`, `inference_settings`,
`execution_settings`, `observability`, `openclaw_interfaces`,
`hermes_interfaces`, and `provider_definitions`.
- From `fabric_deployment`: the apply, reapply, and export checks for
eight harnesses. OpenClaw and Pi remain, and every harness's example
compiles, passes the Fabric planner, and exports in the SDK's tests.
- **Moved:** the unsupported ownership annotation check now lives in
`nemoclaw-cli`. The schema rejects the annotation, naming its field,
before the CLI reads saved intent or state, so the check needs no
deployment.
- **Known gap until #12880:** nothing at the system layer now checks
that the fake gateway accepts and reads back each removed variant
unchanged. The `openshell` and `fabric` contract tests will own that.

## Validation

- **New tests:** the export test covers more than 20 examples in 0.3 s.
The CLI annotation test passes in 0.05 s.
- **Remaining lifecycles:** locally against a rebuilt bundle, the
remaining `deployment` lifecycles and all `fabric_deployment` tests
pass, 8 tests in 39 s.
- **Checks:** `nemoclaw-sdk`, `nemoclaw-cli`, and `nemoclaw-e2e` clippy
at `-D warnings` and fmt are clean.
@cv
cv enabled auto-merge (squash) October 9, 2026 12:12
@cv
cv merged commit e2acbd9 into v1 Oct 9, 2026
@cv
cv deleted the test/layer-budgets branch October 9, 2026 13:20
cv added a commit that referenced this pull request Oct 9, 2026
Part of #12877 and #12876.

## Failure

The timing report from #12885 showed where test time went, but nothing
stopped it growing. A slower test passed CI as long as it passed.

## Decision

- **Budgets file:** `.config/test-budgets.yaml` records a wall-clock
budget for the `test` step and for each `lifecycle` partition, and a
limit for any one test in them.
- **Comparison:** after each step, `cargo ci` compares the step's JUnit
report with its budget. The budget and any offenders are added to the
timing report, which is printed and goes to the job summary.
- **Enforcement:** on the Linux GitHub runners the budgets were measured
on, a step over budget fails. It names its wall time and every test over
the limit. Other platforms and local runs report the budget without
failing.
- **First budgets:** these pass today with headroom. They come from the
latest `v1` run on `linux_amd64`, which already includes #12885 and
#12906.

| Step | Measured | Budget |
|---|---|---|
| `test` | 27 s wall, slowest test 5.1 s | 45 s wall, 8 s per test |
| `lifecycle`, each partition | up to 270 s wall, slowest test 149 s |
360 s wall, 180 s per test |

- **Live suites:** the live suites have no budget yet; they report as
before.
- **Docs:** `docs/contributing/testing.md` says to lower a budget when a
step gets faster, and to explain any increase in the pull request.

#12876 proposed 120 s per system scenario.
`remote_service::managed_bearer_credentials_survive_export_reapply_and_destroy`
takes 149 s, so the lifecycle limit can drop to 120 s once that test is
split or shortened.

## Validation

- **New test:** parses budgets, lists a run's wall time and each test
over the limit, rejects invalid budgets, and checks that the
repository's budgets cover both steps. It failed before `Budgets`
existed.
- **Local run:** `cargo ci test` reports `Budget: 45 s wall, 8 s per
test (reported only; …)` and `Within budget.`.
- **Checks:** `nemoclaw-build` integration tests pass. clippy at `-D
warnings` passes with and without default features, and fmt is clean.
- **Pending:** this PR's CI shows the enforced budget on the Linux
runners.
cv added a commit that referenced this pull request Oct 10, 2026
## Failure

The Rust dependency caches have grown from 1.3–1.5 GB to about 2.9 GB
per platform in a day. Before saving, rust-cache keeps target artifacts
by crate name only, not by version or build hash
([`cleanProfileTarget`](https://github.com/Swatinem/rust-cache/blob/6323deb102c322ba6fcbdcafc7e3dddab59af2b6/src/cleanup.ts)
at the pinned revision). When a key change restores an older cache, the
new cache therefore keeps every earlier build of each crate. The two
profile changes in #12905 and #12885 each rebuilt every dependency with
new hashes.

The larger caches slow both ends of each run. Windows setup restores for
123–210 s. When `v1` saves a changed key, the Windows `Build and test`
save takes 298–433 s, and lifecycle tests wait for it. Those saves made
warm runs take 850–1,095 s instead of about 600 s.

## Decision

Add two parts to the rust-cache prefix:

- **The hash of `.cargo/config.toml`:** a profile change starts a fresh
cache instead of extending the old one.
- **The current UTC month:** this bounds the slower growth from lockfile
updates, at the cost of one cold build per platform each month.

Within a generation, manifest, lockfile, and toolchain-file changes
still restore the previous cache and rebuild only what changed. Deleting
unused artifacts before saving isn't reliable, because Cargo doesn't
touch an artifact that's already fresh, so a job can't tell which files
it used.

The new prefix also resets the current oversized caches: the first `v1`
push after merge builds each platform cold. The old entries expire
unused.

## Validation

- `actionlint` passes on the workflows, and the composite action parses
as YAML with the new step.
- `cargo ci` passed: 1,324 workspace tests and all 120 lifecycle tests.
- `fern check` passes.
- After merge, the `v1` cache entries should return to about 1.3–1.5 GB
per platform and stay there within the month.
cv added a commit that referenced this pull request Oct 12, 2026
#13042)

Fixes #12530.

## Failure

`lifecycle()` in `crates/nemoclaw-e2e/tests/deployment.rs` set up a
deployment, ran the plan, apply, export, reapply, and destroy checks,
and chose drift checks by inspecting each test's document: web search
registrations when a search integration was bound, tool policies with
more than one sandbox, native settings when the inference API, agent
authentication, harness execution, or harness settings were set, and
network policy drift, with its own setup change, when the policy was
explicit. A test's body did not show which of these it ran.

## Decision

`Lifecycle::start` owns the setup: the fixture gateway, image engine,
secrets, progress recording, and deployment. The checks are named
methods: `apply`, `export_and_reapply_unchanged`,
`assert_search_registration_drift`, `assert_tool_policy_drift`,
`assert_native_settings_drift`, and `destroy`. Each test calls the
checks it exercises and asserts its own effect count, and each fault
injection is still undone inside the check that makes it.

Since #12885 kept one system lifecycle per drift kind (#12906), no test
has an explicit network policy, so the policy setup change and drift
check are removed rather than kept unreachable. Lower layers cover
explicit policies: the `openshell` contract tests apply the resources
compiled from `explicit-policy.yaml` and read them back unchanged
(#12908), `explicit_policy_reaches_the_gateway_and_detects_drift` checks
policy drift in the provider, and
`policy_template_markers_remain_literal_in_opentofu_configuration`
checks the templated path the setup change wrote.

`web_search_cli_export_reapply_and_destroy` and
`tool_disclosure_cli_export_reapply_and_drift` are renamed for the drift
they check, and `docs/contributing/integration-tests.md` follows. All 24
tests keep their test and ignore attributes, and `Lifecycle` owns the
same resources and drops them in the same order.

## Validation

- **Each test runs the checks it ran before.** With a marker in each
branch of `lifecycle()` on `v1` at 29bb057, `sdk_apply_cli_export…`
reached no drift check, `separate_agent_sandboxes…` only tool policies,
`tool_disclosure…` only native settings, and `web_search…` only search
registrations, with 4, 7, 4, and 6 gateway effects. No test reached the
explicit-policy setup or check. The new tests call the same checks and
assert the same counts.
- **The other assertions moved unchanged.** With `self.` and whitespace
removed, the old and new code have the same 39 assertions and 8 fault
injections and restores outside the explicit-policy check. The
conditional effect count became one assertion per test.
- **The deployment suite passes before and after against one bundle.** A
single `cargo ci bundle` at 29bb057 served both runs on Linux ARM64: all
24 `deployment::` tests passed before (168 s) and after (174 s).
- **`cargo ci` passes on Linux ARM64** (1,377 tests, 127 lifecycle
tests).
- **CI passes on a fork run.** CI / Bundle passes on Linux ARM64 and
AMD64 with both live suites, macOS, and Windows, and every platform's
lifecycle shards ran and passed all 24 `deployment::` tests.

---
Signed-off-by: Bowen Zhu <[email protected]>

Signed-off-by: Bowen Zhu <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
@wscurran wscurran added the chore Build, CI, dependency, or tooling maintenance label Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants