Skip to content

test: keep one system lifecycle per drift kind - #12906

Merged
cv merged 2 commits into
test/layer-budgetsfrom
test/export-round-trip
Oct 9, 2026
Merged

cv merged 2 commits into
test/layer-budgetsfrom
test/export-round-trip

Conversation

@cv

@cv cv commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #12885. Part of #12876 (finding 1 in the overlap map).

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 Contract tests for the openshell and fabric providers #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 added 2 commits October 9, 2026 04:25
Export's consistency check ran only inside end-to-end lifecycles, about
30 s each on CI, so whether a configuration exports unchanged was proven
one deployment at a time. The check itself is pure: it compares the
saved document's compiled provider and sandbox targets with refreshed
observations.

Export now passes those observations to a pure function, exported. A
unit test compiles every example, echoes its targets as observations,
and checks that the saved document exports unchanged, and that a
drifted sandbox image, a drifted provider endpoint, or a missing
observation stops the export. It runs in 0.3 s.

Part of #12882.
About 35 system tests repeated the generic lifecycle (export reproduces
the document, an unchanged reapply is a no-op, destroy cleans up) for one
configuration variant each, about 30 s apiece on CI.

- Export round trips for every example now run in the SDK's unit tests.
- Drift detection keeps one lifecycle per kind: web search registrations
  (Tavily only; Brave is the same code path), sandbox policy across
  sandboxes, and harness native settings (tool_disclosure).
- Removed from deployment: explicit_network, inference_settings,
  execution_settings, observability, openclaw_interfaces,
  hermes_interfaces, and provider_definitions lifecycles.
- Removed from fabric_deployment: eight harnesses' apply, reapply, and
  export checks; OpenClaw and Pi remain. Every harness example compiles,
  passes the Fabric planner, and exports in the SDK's tests.
- The unsupported ownership annotation check moves to nemoclaw-cli: the
  schema rejects it, naming the field, before the saved intent or state
  is read, so it needs no deployment.

Whether the fake gateway accepts and reads back each variant unchanged
is left to the openshell and fabric contract tests in #12880.

Part of #12882.
@cv cv added area: e2e End-to-end tests, nightly failures, or validation infrastructure v1 NemoClaw v1 branch labels Oct 9, 2026
@cv
cv merged commit 2577138 into test/layer-budgets Oct 9, 2026
4 checks passed
@cv
cv deleted the test/export-round-trip branch October 9, 2026 11:45
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 9, 2026
…t tests (#12908)

Part of #12880; #12913 is stacked on it.

## Failure

#12906 removed system lifecycles that were the only check that the fake
gateway accepts each configuration variant's OpenShell resources and
reads them back unchanged. Those checks belong to the `openshell`
provider's contract tests, which did not exist. Its types were tested
only from `nemoclaw-e2e`, and the provider crate could not use the fake
gateway, because `nemoclaw-e2e` depends on the providers.

## Decision

- **New fixtures crate:** `nemoclaw-test-fixtures` holds the fake
OpenShell gateway and the owned OpenTofu workspace, so provider crates
can use them as development dependencies. `nemoclaw-e2e` re-exports
both, so existing tests are unchanged.
- **Contract binary:** `openshell-provider`'s `contract` binary applies
one fixture per example that uses an external gateway (22 fixtures)
through pinned OpenTofu, against the fake gateway running the compute
driver the fixture requires. For each fixture:
- The next plan must change no managed resource. Data sources re-read on
purpose.
- Teardown runs as the SDK's does: every sandbox, registration, and
profile is removed, and the workspace is kept.
- **Coverage test:** every fixture file must have a test, and every
`openshell` type must have a fixture.
- **Generated fixtures:** the fixtures are the OpenShell resources the
SDK compiles for each example. Fabric capability references are replaced
with the runtime bindings the fake images declare, and the protection
against accidental destroy is dropped for teardown. `nemoclaw-e2e`'s
deterministic `openshell_contract_fixtures` test fails when the fixtures
differ from what the SDK compiles, and `NEMOCLAW_REGENERATE_FIXTURES=1`
rewrites them. Examples whose credentials are read from a managed
service's container are excluded, because that needs Docker.
- **CI:** the lifecycle profile selects the contract binary, and the
OpenShell provider's provider binary is already in the lifecycle
archive.
- **Docs:** `docs/contributing/integration-tests.md` describes the
contract tests and how to regenerate fixtures.

- **Moved tests:** `opentofu_openshell` and `standalone_openshell` move
into the contract binary.
- The standalone tests apply a static authored configuration from
`tests/contract/standalone`.
- The gateway capability tests use the local example's fixture instead
of compiling the reference graph. They check that an incompatible
gateway and a failed read stop planning, that a failed object read stops
the next plan, and that a saved plan observes the gateway again, all
without changing the gateway or managed state.
- The Pi configuration test also needs the `fabric` provider, so it
stays in `nemoclaw-e2e` as `standalone_pi` until that provider has
contract tests.

## Validation

- **Contract binary:** through the lifecycle profile, the contract
binary's 46 tests and `standalone_pi` pass locally in 38 s wall. The
contract tests are 22 fixtures, the coverage test, 3 capability tests,
and 20 standalone tests.
- **Fixture freshness:** the `openshell_contract_fixtures` test passes
in 0.1 s.
- **Lint and format:** workspace clippy at `-D warnings`, fmt, and the
`nemoclaw-build` docs tests are clean.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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