Skip to content

refactor(provider)!: store provider profile metadata one field per annotation - #12941

Merged
cv merged 1 commit into
v1from
refactor/profile-annotations
Oct 9, 2026
Merged

cv merged 1 commit into
v1from
refactor/profile-annotations

Conversation

@cv

@cv cv commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Failure

NemoClaw packed each provider profile's ownership and definition fields into one JSON annotation, nemoclaw.nvidia.com/profile-v1. OpenShell v0.1.2 computed profile revisions from protobuf bytes that depend on map iteration order, so several annotations made a sandbox's provider environment revision change on every read (#12458). OpenShell v0.1.3 hashes profiles in a canonical order (ai-openshell/openshell#4122), so the workaround no longer serves a purpose.

Decision

Store one annotation per field. Owner and generation use the existing nemoclaw.nvidia.com/uid and nemoclaw.nvidia.com/generation keys. The other fields use nemoclaw.nvidia.com/binaries, endpoint, provider-type, and authenticated. One table maps fields to keys for both the writer and the reader.

There is no compatibility path for the old format.

Breaking: a deployment whose gateway still holds profiles written in the old single-annotation format fails profile observation, so plan, apply, and destroy report an error for those profiles. Recover by deleting the old profiles from the gateway, or by recreating the gateway, then applying again. Recreated profiles get new revisions, which reloads or restarts the affected sandboxes.

The test that required profiles to re-encode to identical protobuf bytes is removed; only v0.1.2's byte hashing needed that. The wire round-trip still checks that each decoded profile is observed correctly.

Validation

  • A new test, profile_metadata_is_one_annotation_per_field, checks that native profiles carry six annotations and search profiles three. The rejection test now covers each missing annotation, malformed binaries, an unexpected nemoclaw.nvidia.com/ annotation, and foreign owner or generation values. Both failed before the change and pass after it.
  • All 26 openshell-provider tests pass, and nothing references profile-v1 any more.
  • cargo ci passed: 1,319 workspace tests and all 96 lifecycle tests.
  • Live / Docker passed on linux_arm64 and linux_amd64 against the real v0.1.3 gateway (run 37995148463), including managed_gateway_live::profile_revision::imported_profile_revisions_survive_repeated_reads_and_gateway_restart.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@cv
cv merged commit ba03c3f into v1 Oct 9, 2026
@cv
cv deleted the refactor/profile-annotations branch October 9, 2026 22:29
@cv cv added the v1 NemoClaw v1 branch label Oct 12, 2026
cv pushed a commit that referenced this pull request Oct 13, 2026
…, and test fixtures (#13056)

Report the gateway's reason when OpenShell rejects a credential-free
mutation, and fix sandbox teardown, deployment-lock release,
test-fixture flakes and the images plan message, with matching docs.
Nothing here depends on Kubernetes.

## Why

The review of #12736 found these problems; each predates or is
independent of the cluster model services.

- **F2** (#12736 review): OpenShell rejection text was discarded.
`remote_error` maps every gateway status to a fixed category, so on kind
a CreateSandbox rejection for conflicting `allowed_ips` endpoint
metadata reached the user only as `observation query failed`. Finding
the cause took a rebuilt bundle that logged `status.message()`.
- **`transport.rs:220`** (#12736 review: open at 59ad198, fixed at
c3496ea): removing a ready sandbox read its active-policy status,
which teardown does not use, so a failing status read blocked removal.
#12736 changed this without a test.
- **T1** (#12736 review): the deployment lock is an `flock` on the open
file description. A child spawned concurrently holds a copy of the
descriptor until `exec`, so dropping `Store` could leave the deployment
locked and the next open failed with `another operation holds the
deployment lock`. Besides the flaky SDK suite, an SDK process that runs
`tofu` can hit this.
- **T1-tail** (#12736 review) and **N1** (#12736 review, nit): several
tests wrote a script and executed it at once, which fails with `Text
file busy` (ETXTBSY) when a concurrent spawn holds the write descriptor.
Running the staged provider through `/bin/sh` stopped the staging test
from checking the executable bit OpenTofu needs.
- **HM-4** (#12736 review, nit): `cargo images build --platform
linux/amd64 hermes` failed with Bake's `failed to find target hermes`.
- **N2** (#12736 review) and
[#12642](#12642): no documented
OpenClaw request format, and no recovery path when a malformed request
leaves the runtime `unknown`. The gateway profile-format break from
#12941 had no operator note.

## What changes

- **Rejection text.** `ObservationError` gains `Rejected { operation,
code, detail }`. `nemoclaw_openshell::remote_rejection` keeps the
gateway's detail only for CreateWorkspace, CreateSandbox, DeleteProvider
and DeleteProviderProfile, whose requests carry no credentials, and only
for `FailedPrecondition`, `InvalidArgument`, `AlreadyExists`,
`OutOfRange` and `ResourceExhausted`. Other codes and operations return
the same category as before.
- **Redaction.** `ObservationError::sanitized_detail` reduces text to
printable ASCII of at most 1024 characters and redacts bearer tokens,
key/value credentials (`authorization`, `api_key`, `token`, `password`,
`secret`) and runs of 32 or more token characters.
`sanitized_resource_detail` additionally keeps one known resource name.
Credential-bearing provider creation and update, reads and exec keep
category-only errors.
- **Teardown.** `openshell-provider` skips the active-policy status read
when it reads a ready sandbox for removal (`if ready && !removing`). The
owned identity checks still run.
- **Lock.** `impl Drop for Store` unlocks before the file closes, which
releases the `flock` for every copy of the descriptor.
- **Test fixtures.** Tests execute an existing interpreter or binary
(`/bin/sh`, `/bin/cat`) and pass the written script as data. The
provider staging test asserts the executable bit.
- **Images plan.** `images::plan` lists each platform's harnesses with
`buildx bake --print agents` and names the platforms that build a
requested harness. Groups and other targets keep Bake's resolution.
- **Docs.** `agents.md`: the headless OpenClaw request and the reported
malformed-request failure. `usage.md`: "Replace Workloads After an
Unusable OpenClaw Runtime". `troubleshooting.md`: which rejections keep
their detail, and table rows for both failures. `provider.md`: "Gateway
Profile Format Upgrade".

## Breaking or user-visible changes

- **Rust API:** `ObservationError` (from `nemoclaw-backend`, re-exported
as `nemoclaw_sdk::ObservationError`) is `Clone` but no longer `Copy`,
and has the new `Rejected` variant. Code that copies it must call
`.clone()`, and exhaustive matches need a `Rejected` arm. The crates are
`publish = false`; every use in this workspace is updated. An
application using the SDK through a path dependency must make the same
edits.
- **Error text:** a rejected CreateWorkspace, CreateSandbox,
DeleteProvider or DeleteProviderProfile now reports `OpenShell
<operation> rejected (<code>): <detail>` instead of `observation query
failed`. This applies to Docker, Podman and Kubernetes gateways.
- **Images:** an unsupported harness now fails with, for example,
`hermes is built only for linux/arm64; linux/amd64 builds deepagents,
openclaw (docs/build.md#build-agent-images)`.
- No configuration, schema, bundle or state format change.

## Test proof

### `cargo ci` (linux_arm64, this branch)

Run on the GB300 host (aarch64). The tree tested is the commit's tree.

```
ok tools in 0s
ok fmt in 1s
ok clippy in 35s
ok build in 76s
     Summary [  19.032s] 1387 tests run: 1387 passed, 174 skipped
ok test in 25s
ok schema in 0s
ok bundle in 178s
     Summary [ 364.941s] 127 tests run: 127 passed, 48 skipped
ok lifecycle in 371s
All selected CI steps passed in 690s
```

The test step's 4 doctests passed. The lifecycle timing report lists one
local overrun: 364.9 s wall against the 300 s budget that applies on the
Linux CI runners. This PR adds no lifecycle tests; the per-test (90 s)
and per-binary budgets were met. `cargo run --locked -p nemoclaw-build
-- docs --check` passed after `docs` generated the untracked output; no
tracked file changed.

### New tests: red without the production change, green with it

Each red run edited only the working tree and restored the PR tree
afterwards. Commands: `cargo test --locked -p <crate> <target> -- <test
names>`.

| Test | Red change | Red result | Green |
|---|---|---|---|
| `nemoclaw-openshell`
`connection::tests::live_endpoint_ambiguity_keeps_its_conflict_kind` |
`remote_rejection` returns `remote_error` (v1 behaviour) | FAILED:
message lacks `conflicting metadata: allowed_ips=[]` | ok |
|
`connection::tests::definitive_rejections_keep_bounded_gateway_text_and_other_statuses_stay_fixed`
| same | FAILED: `missing operation rejection` | ok |
| `openshell-provider`
`fake_gateway_tests::gateway_validation_rejections_preserve_details_for_credential_free_mutations`
| `connected.rs` restored to v1 | FAILED: `missing CreateWorkspace
rejection detail: observation query failed` | ok |
|
`fake_gateway_tests::credential_requests_reads_and_exec_keep_backend_rejection_text_private`
| guard: passes on v1 by design; mutant opts CreateProvider into
`remote_rejection` | FAILED under the mutant: `Rejected { operation:
"CreateProvider", …, detail: "PRIVATE_SENTINEL" }` ≠ `Query` | ok |
|
`fake_gateway_tests::ready_sandbox_teardown_needs_owned_identity_but_not_active_policy_status`
| `transport.rs` restored to v1 (`if ready {`) | FAILED: removal read
returned `Err(Transport)` | ok |
| `nemoclaw-sdk`
`error::workload_details_redact_short_bearer_and_quoted_credentials` |
`sanitize_detail` returns its input | FAILED: secret kept | ok |
|
`error::workload_details_are_single_line_bounded_and_redact_token_like_runs`
| same | FAILED: `safe.len() <= 1024` | ok |
|
`error::resource_details_preserve_only_the_exact_known_name_outside_credentials`
| same | FAILED: name appears 5 times, expected 1 | ok |
| the three `error::` tests | `observation.rs` restored to v1 | does not
compile: no `sanitized_detail`, no `Rejected` (E0599) | ok |
| `nemoclaw-sdk`
`state::tests::dropping_store_releases_lock_while_a_duplicate_descriptor_remains_open`
| `state/mod.rs` restored to v1 (no `Drop for Store`) | FAILED:
`Conflict("another operation holds the deployment lock or locking
failed")` | ok |
| `nemoclaw-build`
`images::harnesses_missing_from_the_selected_platform_name_the_platforms_that_build_them`
(needs `docker buildx`; v0.37.1 here) | `images.rs` restored to v1 |
FAILED: got `docker failed to plan the image build` | ok |
| `nemoclaw-test-fixtures`
`tofu::tests::stages_only_the_selected_provider_and_cleans_only_its_workspace`
(changed test) | mutant: staging sets mode 0644 | FAILED: executable-bit
assertion | ok |

### Repeated runs of the touched suites

In-process `cargo test` runs on this host, which is where the descriptor
races occur (nextest isolates each test). Branch and v1 (29bb057) ran
under the same load.

| Suite | This branch | v1 |
|---|---|---|
| `cargo test -p nemoclaw-sdk --lib` | 22/22 runs passed (192 tests) |
7/22; failures in
`state::tests::lock_excludes_other_operations_and_atomic_intent_survives_reopen`
(`Conflict("another operation holds the deployment lock…")`),
`deployment::tests::changing_gateway_management_at_the_same_endpoint_preserves_saved_state`,
`deployment::export::tests::export_reports_recovery_for_each_saved_operation_state_without_changing_files`
|
| `cargo test -p nemoclaw-test-fixtures --lib` | 50/50 | 46/50; kept
logs show `Text file busy` in the staging test |
| `cargo test -p nemoclaw-runtime --lib vllm::runtime` | 10/10 | 10/10 |
| `cargo test -p nemoclaw-provider --lib hardware::ssh` | 10/10 | 10/10
|
| `cargo test -p nemoclaw-sdk --test integration kubernetes_connection`
| 10/10 | 10/10 |

### Lifecycle tests

This PR adds no lifecycle-only tests. All 127 selected by the
`lifecycle` profile passed. The ones that drive the changed OpenShell
code through OpenTofu:

- `openshell-provider::contract`: all 44 passed, including
`standalone::standalone_hcl_rejects_replacement_and_unauthorized_removal_during_plan`,
`standalone::standalone_hcl_recovers_lost_delete_response_without_repeating_the_mutation`,
`standalone::standalone_registrations_replace_and_remove_without_destroy_mode`
and the 22 example-configuration tests.
- `nemoclaw-e2e::integration` teardown paths, all passed:
`deployment::failed_first_apply_can_destroy_bound_resources_without_successful_reapply`,
`deployment::destroy_waits_for_graceful_sandbox_stop_without_retrying`,
`deployment::rejected_policy_fails_promptly_with_context_and_allows_recovery_or_destroy`,
`deployment::sandbox_startup_failure_names_reason_and_guidance_and_allows_destroy`,
`deployment::pi_start_failure_names_the_sandbox_in_cli_text_and_json_and_allows_destroy`,
`deployment::mixed_sandboxes_reorder_add_recover_export_and_destroy_independently`.

<details><summary>All 127 lifecycle tests (passed)</summary>

- `fabric-provider::contract` (3):
`capabilities::capabilities_judge_the_image_for_the_configuration`,
`pi_configuration_updates_without_replacing_the_sandbox`,
`readiness::readiness_reports_the_configured_agent_and_its_failed_health`
- `nemoclaw-e2e::integration` (49): `deployment::` (24),
`export_observations::` (4), `fabric_deployment::` (4),
`helm_recovery::` (5),
`inference_discovery::optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_uncertainty`,
`multiple_providers::provider_union_export_reapply_drift_and_destroy_remain_scoped_to_each_sandbox`,
`remote_service::` (9),
`sandbox_readiness::standalone_sandbox_completion_rejects_unknown_health_and_retains_bindings`
- `nemoclaw-provider::contract` (29): `discovery::` (3),
`gateway_readiness::` (1), `gateway_storage::` (1),
`inference_capabilities::` (3), `kubernetes_hcl::` (1),
`kubernetes_lifecycle::` (2), `provider_protocol::` (4),
`runtime_image::` (1), `service_capacity::` (1), `service_readiness::`
(2), `service_storage::` (6), `vllm_runtime::` (4)
- `openshell-provider::contract` (44): `capabilities::` (2),
`standalone::` (20), and the example configurations `explicit_policy`,
`fabric`, `fabric_claude`, `fabric_codex`, `fabric_hermes`,
`fabric_mini_swe_agent`, `fabric_nooa`, `fabric_nooa_bench`,
`fabric_openclaw`, `fabric_pi`, `fabric_remote_agent`, `hermes_auth`,
`hermes_interfaces`, `inference_tuning`, `inline_inference`, `local`,
`multiple_models`, `multiple_providers`, `multiple_sandboxes`,
`openclaw_dashboard`, `openclaw_web_search`, `tavily_web_search`
- `nemoclaw-fixture-provider::archive`
`the_fixture_provider_is_found_beside_the_test_executables`,
`nemoclaw-test-fixtures::ssh_relay`
`the_relay_is_found_beside_the_test_executables`

</details>

### Live evidence (not qualification; #12732 stays open)

This branch merged with `v1` 025b95a (local merge ba8499b, GB300
host, aarch64, 2026-10-13):

- `cargo ci live-docker`: **11/11 passed** in 352 s, and the Docker
inventory was the same before and after.
- The suite includes `v1`'s new
`dummy_agent::the_dummy_agent_completes_a_managed_docker_lifecycle`
(48.1 s). It destroys a ready sandbox through the bundled OpenShell
provider and checks that no sandbox containers or volumes remain, which
is the live path of the teardown change (`if ready && !removing`).
- Full `cargo ci` on the merged tree: 1394 tests + 127 lifecycle, all
passed, 727 s. The branch needs no change for the new `v1`; "Update
branch" produces the tested tree.

No kind or GPU run: nothing in this PR depends on them.


## Depends on / merge order

- Base: `v1` at 29bb057. No dependencies; it merges in parallel with
#13057, #13058 and #13059, and the four branches merge into each other
without conflicts.
- #13060 is opened on this branch and retargets to `v1` when this branch
is deleted after merge.
- #13061 needs this PR and #13058 in `v1`.
- Lines of #12736 in these files that this PR leaves out, for the later
PRs to carry: the `ModelRuntimeStopped` doc comment in `observation.rs`
(#13061); in `provider.md`, the cluster `owner`/`generation` paragraph
and the "cluster resource identity refresh" clause of the profile-format
note (#13062); in `usage.md`, "including the cluster model and
credential PVCs" (#13062).

Split from #12736.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
@wscurran wscurran added area: architecture Architecture, design debt, major refactors, or maintainability refactor PR restructures code without intended behavior change security area: security Security controls, permissions, secrets, or hardening and removed security labels 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: architecture Architecture, design debt, major refactors, or maintainability area: security Security controls, permissions, secrets, or hardening refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants