Skip to content

feat(onboard): define native artifact workload contract - #8243

Merged
cv merged 11 commits into
mainfrom
codex/windows-native-workload-contract
Aug 4, 2026
Merged

feat(onboard): define native artifact workload contract#8243
cv merged 11 commits into
mainfrom
codex/windows-native-workload-contract

Conversation

@senthilr-nv

@senthilr-nv senthilr-nv commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Defines an inactive, versioned receipt for staging the pinned OpenClaw Windows workload without an OCI image. The parser rejects mutable identity, non-canonical paths, literal environment assignments, and mismatched startup intent; it does not register or activate an MXC provider.

Related Issue

Related to #8178.

Changes

  • Add the native artifact workload receipt required by the future OpenShell+MXC OpenClaw provider. An OCI receipt is not sufficient because this path identifies a staged Windows executable and its launch intent rather than a container image.
  • Bind artifact, executable, source revision, and managed startup-profile identity while restricting environment metadata to variable names. The future staging authority remains responsible for verifying the recorded digests before provider use.
  • Add focused tests for the valid receipt and fail-closed handling of mutable or malformed identity, path traversal, environment assignments, duplicate names, startup-profile mismatch, OCI fields, and disabled ownership or credential-replay requirements.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: the contract is inactive and unregistered, with no change to a CLI, configuration, workflow, default, error output, or supported behavior.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: exact-head maintainer review passed all nine security categories. The schema uses exact keys and bounded inputs, rejects traversal and literal credential assignments, verifies startup-profile identity, adds no dependency or execution path, and remains inactive.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: Exact-head review confirmed that the inactive native-artifact receipt parser has no production consumer and adds no provider registration, CLI, configuration, runtime activation, supported workflow, or documentation surface. The final comments and test titles make field-level claims only; the focused source test passed 29 tests.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable; scripts/prepare-dgx-station-host.sh is unchanged.
  • Station profile/scenario: Not applicable.
  • Result: Not applicable.
  • Supporting evidence: Not applicable.

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — npx vitest run --project cli src/lib/onboard/workload/native-artifact.test.ts passed 29/29; npm run typecheck:cli, npm run build:cli, npm --prefix nemoclaw run build, npm exec -- biome check for both changed files, and npm run checks:repository passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — not applicable because this isolated parser is not imported by production code or the runtime registry.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Senthil Ravichandran senthilr@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added support for validating Windows/x64 native artifact workload receipts.
    • Validates artifact integrity, launch metadata, executable paths, environment variables, startup profiles, and credential-proxy settings.
    • Rejects unsupported OCI images, mutable downloads, malformed data, and invalid ownership details.
    • Returns normalized receipt information with clear validation errors.
  • Tests

    • Added comprehensive coverage for valid receipts and invalid or unsupported configurations.

Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
@senthilr-nv senthilr-nv added integration: openclaw OpenClaw integration behavior area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow platform: windows Affects native Windows environments labels Aug 4, 2026
@senthilr-nv senthilr-nv self-assigned this Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds a native Windows/x64 OpenClaw workload receipt contract. It defines public types and constants, validates artifact and launch metadata, verifies startup-profile integrity, returns normalized receipts, and adds rejection tests.

Changes

Native artifact receipt validation

Layer / File(s) Summary
Contract and validation primitives
src/lib/onboard/workload/native-artifact.ts
Defines receipt types, contract constants, a dedicated error, and strict checks for shapes, literals, digests, paths, arguments, and environment names.
Receipt parsing and normalization
src/lib/onboard/workload/native-artifact.ts
Validates artifact identity, provenance, launch configuration, startup-profile integrity, agent ownership, credential-proxy settings, and shared ownership flags before returning a normalized receipt.
Contract test coverage
src/lib/onboard/workload/native-artifact.test.ts
Covers valid immutable receipts and rejects invalid formats, paths, environment declarations, startup profiles, mutable fields, and missing required flags.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#8032: Validates and consumes immutable workload receipts during workload-clone handoff.

Suggested labels: feature

Suggested reviewers: apurvvkumaria, ericksoa

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding the native artifact workload contract.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/windows-native-workload-contract

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
src/lib/onboard/workload/native-artifact.test.ts (2)

70-86: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the complete normalized receipt.

toMatchObject does not verify kind, artifact digest and version, source revision, startup-profile fields, or the required ownership flags. A return-path regression can alter or omit these fields while this test passes. parseNativeArtifactWorkloadReceiptV1 returns all of them as public contract data in src/lib/onboard/workload/native-artifact.ts lines 178-337.

Compare the parsed result with the complete expected receipt. As per path instructions, prefer observable outcomes through the public boundary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/workload/native-artifact.test.ts` around lines 70 - 86,
Update the test around parseNativeArtifactWorkloadReceiptV1 to compare parsed
against the complete expected normalized receipt using a full equality assertion
instead of toMatchObject. Include kind, artifact digest and version, source
revision, startup-profile fields, ownership flags, and all existing receipt
fields, while asserting only through the public parser result.

Source: Path instructions


108-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover workingDirectory path validation.

This table only mutates launch.executable.relativePath. The parser also validates launch.workingDirectory with requireRelativePath, so a regression that accepts ../agent, agent/../work, or repeated separators in the working directory will pass this suite.

Add equivalent rejection cases that mutate launch(value).workingDirectory. As per path instructions, tests must provide behavioral confidence at the public boundary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/workload/native-artifact.test.ts` around lines 108 - 118,
Extend the canonical-path rejection coverage in the parameterized test around
parseNativeArtifactWorkloadReceiptV1 by adding equivalent cases that assign each
invalid path to launch(value).workingDirectory. Keep the assertions at the
public parser boundary and verify every non-canonical working-directory value
throws the canonical relative path error.

Source: Path instructions

src/lib/onboard/workload/native-artifact.ts (2)

289-302: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Narrow the try block to the decode call.

decodeManagedStartupProfile is the only realistic throwing path here. The agent-ownership check sits inside the same try, so the code then needs the instanceof re-throw at Line 297 to escape its own catch. Move the check after the try to remove that round trip.

♻️ Proposed restructure
-  try {
-    const profile = decodeManagedStartupProfile(contract.encodedProfile);
-    if (profile.agent !== agent) {
-      throw new NativeArtifactWorkloadContractError(
-        `contract.encodedProfile belongs to '${profile.agent}', not '${agent}'`,
-      );
-    }
-  } catch (error) {
-    if (error instanceof NativeArtifactWorkloadContractError) throw error;
-    throw new NativeArtifactWorkloadContractError(
-      "contract.encodedProfile failed closed validation",
-      { cause: error },
-    );
-  }
+  let profile;
+  try {
+    profile = decodeManagedStartupProfile(contract.encodedProfile);
+  } catch (error) {
+    throw new NativeArtifactWorkloadContractError(
+      "contract.encodedProfile failed closed validation",
+      { cause: error },
+    );
+  }
+  if (profile.agent !== agent) {
+    throw new NativeArtifactWorkloadContractError(
+      `contract.encodedProfile belongs to '${profile.agent}', not '${agent}'`,
+    );
+  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/workload/native-artifact.ts` around lines 289 - 302, In the
validation flow around decodeManagedStartupProfile, narrow the try/catch to only
the decode call, preserving the existing wrapped error behavior for decode
failures. Move the profile.agent ownership check after the catch so
NativeArtifactWorkloadContractError is no longer re-thrown from its own catch.

119-139: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Path Traversal (CWE-41)

Reachability: Unreachable · Exploitability: Theoretical

Reject Windows-normalizing path segments in requireRelativePath.

The current check already rejects backslashes. Use bin/claw.exe. as the forward-slash example. Reject trailing dots, trailing spaces, and Windows reserved device names with extensions. Add focused tests. Existing fixtures runtime/node.exe and . remain valid. This is contract hardening for the future staging authority, not a current traversal path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/workload/native-artifact.ts` around lines 119 - 139, The
requireRelativePath validation must also reject Windows-normalizing segments:
trailing dots, trailing spaces, and Windows reserved device names even when
followed by extensions, while continuing to accept runtime/node.exe and "." when
allowDot is true. Update the segment validation in requireRelativePath using the
bin/claw.exe. example and add focused tests covering each rejected form and the
preserved valid fixtures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/lib/onboard/workload/native-artifact.test.ts`:
- Around line 70-86: Update the test around parseNativeArtifactWorkloadReceiptV1
to compare parsed against the complete expected normalized receipt using a full
equality assertion instead of toMatchObject. Include kind, artifact digest and
version, source revision, startup-profile fields, ownership flags, and all
existing receipt fields, while asserting only through the public parser result.
- Around line 108-118: Extend the canonical-path rejection coverage in the
parameterized test around parseNativeArtifactWorkloadReceiptV1 by adding
equivalent cases that assign each invalid path to
launch(value).workingDirectory. Keep the assertions at the public parser
boundary and verify every non-canonical working-directory value throws the
canonical relative path error.

In `@src/lib/onboard/workload/native-artifact.ts`:
- Around line 289-302: In the validation flow around
decodeManagedStartupProfile, narrow the try/catch to only the decode call,
preserving the existing wrapped error behavior for decode failures. Move the
profile.agent ownership check after the catch so
NativeArtifactWorkloadContractError is no longer re-thrown from its own catch.
- Around line 119-139: The requireRelativePath validation must also reject
Windows-normalizing segments: trailing dots, trailing spaces, and Windows
reserved device names even when followed by extensions, while continuing to
accept runtime/node.exe and "." when allowDot is true. Update the segment
validation in requireRelativePath using the bin/claw.exe. example and add
focused tests covering each rejected form and the preserved valid fixtures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f92ff21b-4239-48ad-904b-2d18a08e1dc4

📥 Commits

Reviewing files that changed from the base of the PR and between 8683777 and f8be0da.

📒 Files selected for processing (2)
  • src/lib/onboard/workload/native-artifact.test.ts
  • src/lib/onboard/workload/native-artifact.ts

Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
@github-code-quality

github-code-quality Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit e7bde8d in the codex/windows-native... branch remains at 96%, unchanged from commit 87fcfe4 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit e7bde8d in the codex/windows-native... branch remains at 81%, unchanged from commit 87fcfe4 in the main branch.

Show a code coverage summary of the most impacted files.
File main 87fcfe4 codex/windows-native... e7bde8d +/-
src/lib/inferen...ompatibility.ts 94% 94% 0%
src/lib/sandbox...rce-identity.ts 87% 87% 0%
src/lib/shields/index.ts 70% 71% +1%
src/lib/credentials/store.ts 55% 56% +1%
src/lib/onboard...e-patch-flow.ts 71% 76% +5%
src/lib/domain/.../connect-env.ts 89% 97% +8%
src/lib/onboard...ive-artifact.ts 0% 93% +93%

Updated August 04, 2026 23:21 UTC

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed after a partial review · low confidence · 0 blockers · 0 warnings · 0 suggestions

Second-opinion terminology and E2E selections are advisory. They do not change the primary assessment or E2E / PR Gate.

1 semantic terminology decision

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • define — launch intent at src/lib/onboard/workload/native-artifact.ts:23: Keep the term with the schema comment that distinguishes it from immutable artifact identity.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: onboard-repair, onboard-resume, cloud-onboard

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@senthilr-nv

Copy link
Copy Markdown
Collaborator Author

Maintainer decision on PRA-1: retain this inactive contract as the independently reviewable artifact/workload boundary in the accepted #8178 delivery sequence. Wiring a production consumer in this PR would cross the stated inactive boundary and overlap the evolving #7744 provider work. The named next consumer is the inactive MXC provider; that PR must add the consumer-boundary test. No runtime registration or support claim is added here, and activation remains gated on protected exact-version E2E.

@senthilr-nv senthilr-nv added the v0.0.103 Release target label Aug 4, 2026
@senthilr-nv
senthilr-nv requested a review from cv August 4, 2026 22:42
@senthilr-nv
senthilr-nv enabled auto-merge (squash) August 4, 2026 22:52
@cv
cv disabled auto-merge August 4, 2026 23:23
@cv
cv merged commit e7f58e9 into main Aug 4, 2026
89 of 90 checks passed
@cv
cv deleted the codex/windows-native-workload-contract branch August 4, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow integration: openclaw OpenClaw integration behavior platform: windows Affects native Windows environments v0.0.103 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants