Skip to content

fix(onboard): replace rebuild recovery flag with authorization receipt - #6675

Merged
cv merged 8 commits into
mainfrom
fix/6666-rebuild-recovery-receipt
Jul 12, 2026
Merged

fix(onboard): replace rebuild recovery flag with authorization receipt#6675
cv merged 8 commits into
mainfrom
fix/6666-rebuild-recovery-receipt

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the authoritative-rebuild incomplete-session boolean bypass with a one-shot, target-bound provider-recovery authorization receipt. The receipt is minted after locked rebuild preflight, activated against the onboard session at provider selection, and rechecked inside the gateway and sandbox mutation locks, so recovering a recorded provider is bound to the exact rebuild target and to the reservation owner.

Related Issue

Resolves #6666

Changes

  • Add ProviderRecoveryReceipt with mintProviderRecoveryReceipt and a single-use createProviderRecoveryReceiptLedger (activate binds one session and refuses replay, cross-sandbox, expired, malformed, or route-mismatched receipts; validateInLock re-binds to the live reservation owner) in rebuild-route-handoff.ts.
  • Mint the receipt after preflight validates the target in rebuild-preflight-target-phase.ts; carry it on OnboardOptions and the rebuild recreate options.
  • Activate the receipt against the live session and target in rebuildProviderFlowOptions, threading it through the core flow phases into the provider-inference handler.
  • Drop the authoritativeResumeConfig incomplete-session bypass and its temporary comment in the recovery gate; the gate now keys on the activated receipt and the in-lock recheck also runs validateInLock.
  • Add unit coverage for the receipt primitive and two behavioural tests: only the reservation owner recovers the same sandbox concurrently, and a foreign reservation introduced after selection is rejected inside the mutation lock.

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:
  • 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:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification:
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • 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: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added one-time provider recovery receipts with an associated receipt ledger to authorize recorded-provider recovery during rebuilds.
    • Receipts are minted during rebuild preflight and carried through the onboarding/rebuild flow to enable secure resumption.
  • Bug Fixes

    • Strengthened recovery gating to block unauthorized concurrent and lock-time recovery attempts.
    • Added stricter validation for receipt expiry, one-shot replay, session/sandbox/gateway matching, and reservation ownership.
  • Tests

    • Expanded coverage for receipt minting, ledger activation, replay/session binding, and recovery recheck behavior under concurrent/foreign reservations.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change replaces the authoritative rebuild recovery flag with a target-bound, time-limited provider recovery receipt. Receipts are minted after preflight, activated for matching sessions, propagated through onboarding, and validated against reservations inside provider recovery locks.

Changes

Provider recovery authorization

Layer / File(s) Summary
Receipt contract and one-shot ledger
src/lib/onboard/rebuild-route-handoff.ts, src/lib/onboard/rebuild-route-handoff.test.ts
Adds target-bound receipt types, minting and validation, one-shot activation, expiration checks, route matching, and reservation-aware in-lock validation.
Rebuild preflight and handoff activation
src/lib/actions/sandbox/*, src/lib/onboard/authoritative-rebuild-target*
Mints receipts from registry recovery routes during preflight, carries them through recreate options, and activates them for matching rebuild sessions.
Provider inference recovery enforcement
src/lib/onboard/machine/core-flow-phases.ts, src/lib/onboard/machine/handlers/*, src/lib/onboard/types.ts
Propagates receipt artifacts into recovery handling and validates receipt, session, sandbox, gateway, expiration, and reservation ownership inside recovery locks, including concurrency and mutation-race tests.

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

Sequence Diagram(s)

sequenceDiagram
  participant RebuildPreflight
  participant RebuildProviderFlowOptions
  participant HandleProviderInferenceState
  participant ProviderRecoveryReceiptLedger
  participant ProviderInferenceRecovery
  RebuildPreflight->>RebuildProviderFlowOptions: mint and attach target-bound receipt
  RebuildProviderFlowOptions->>ProviderRecoveryReceiptLedger: activate receipt for session
  ProviderRecoveryReceiptLedger-->>HandleProviderInferenceState: activated receipt and ledger
  HandleProviderInferenceState->>ProviderInferenceRecovery: pass recovery authorization artifacts
  ProviderInferenceRecovery->>ProviderRecoveryReceiptLedger: validate receipt in mutation lock
  ProviderRecoveryReceiptLedger-->>ProviderInferenceRecovery: allow or reject recovery
Loading

Suggested labels: area: sandbox

Suggested reviewers: ericksoa, cv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: replacing the rebuild recovery flag with an authorization receipt.
Linked Issues check ✅ Passed The PR mints, carries, and validates one-shot receipts across preflight, provider selection, and mutation-lock paths, with replay and reservation-race tests.
Out of Scope Changes check ✅ Passed The changes stay focused on the rebuild recovery authorization flow and its supporting tests, with no unrelated feature work apparent.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/6666-rebuild-recovery-receipt

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

@github-code-quality

github-code-quality Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the fix/6666-rebuild-rec... branch remains at 79%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main b9b8d2a fix/6666-rebuild-rec... e3f5d23 +/-
src/lib/inferen...del-registry.ts 100% 66% -34%
src/lib/onboard...tup-nim-flow.ts 94% 80% -14%
src/lib/state/sandbox.ts 86% 76% -10%
src/lib/agent/onboard.ts 80% 70% -10%
src/lib/onboard...cy-selection.ts 91% 82% -9%
src/lib/messagi...agent-config.ts 71% 64% -7%
src/lib/onboard.ts 29% 30% +1%
src/lib/onboard...er-gpu-patch.ts 78% 80% +2%
src/lib/actions...-monkeypatch.ts 72% 81% +9%
src/lib/cli/public-dispatch.ts 69% 85% +16%

Updated July 12, 2026 00:39 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: cloud-onboard, inference-routing, network-policy, onboard-repair, onboard-resume, state-backup-restore, upgrade-stale-sandbox
Optional E2E: None

Dispatch hint: cloud-onboard,inference-routing,network-policy,onboard-repair,onboard-resume,state-backup-restore,upgrade-stale-sandbox

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • cloud-onboard: Required validation floor for hosted clean onboarding after changes to the core onboarding provider-inference flow.
  • inference-routing: Required to validate selected provider reachability and gateway route setup across the real host-to-sandbox boundary.
  • network-policy: Required to validate that recovered inference routing remains usable within intended sandbox network-policy boundaries.
  • onboard-repair: Required by the onboarding resume rule and deterministic lifecycle-state plan; authoritative rebuild recovery changes can affect repair after missing or stale runtime state.
  • onboard-resume: Required by the onboarding resume rule and deterministic lifecycle-state plan; this PR changes live provider recovery and onboarding state transitions during resume.
  • state-backup-restore: Required validation floor for rebuild mutation paths that must retain intended user state and remain retryable.
  • upgrade-stale-sandbox: Required validation floor for destructive rebuild/recreate behavior with stale runtime state.

Optional E2E

  • None.

New E2E recommendations

  • lifecycle-state (high): Current live resume and repair coverage validates interrupted onboarding and sandbox recreation, but this change introduces one-shot, expiring receipt activation plus an in-lock reservation-owner recheck that is only unit-covered in this PR.
    • Suggested test: Add a live authoritative compatible-endpoint rebuild scenario that interrupts after receipt staging, resumes with the intended session, verifies recovered inference succeeds, and verifies a competing or stale reservation cannot reuse the gateway credential.

Dispatch hint

  • Workflow: .github/workflows/e2e.yaml
  • jobs input: cloud-onboard,inference-routing,network-policy,onboard-repair,onboard-resume,state-backup-restore,upgrade-stale-sandbox

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

E2E Target Recommendation

Required E2E targets: cloud-onboard, inference-routing, network-policy, onboard-repair, onboard-resume, state-backup-restore, upgrade-stale-sandbox
Optional E2E targets: None

Dispatch required E2E targets:

  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=cloud-onboard
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=inference-routing
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=network-policy
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=onboard-repair
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=onboard-resume
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=state-backup-restore
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=upgrade-stale-sandbox

Workflow run

Full E2E target advisor summary

E2E Target Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E targets

  • cloud-onboard: Installer and platform changes must work on a clean supported host with the pinned runtime dependencies.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=cloud-onboard
  • inference-routing: Inference selection, reachability, and network policy must agree at the real host-to-sandbox boundary.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=inference-routing
  • network-policy: Inference selection, reachability, and network policy must agree at the real host-to-sandbox boundary.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=network-policy
  • onboard-repair: Onboarding and sandbox state must converge across persisted metadata, reported status, and the live runtime.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=onboard-repair
  • onboard-resume: Onboarding and sandbox state must converge across persisted metadata, reported status, and the live runtime.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=onboard-resume
  • state-backup-restore: Upgrade, rebuild, snapshot, and restore operations must preserve user state while replacing stale runtime state.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=state-backup-restore
  • upgrade-stale-sandbox: Upgrade, rebuild, snapshot, and restore operations must preserve user state while replacing stale runtime state.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=upgrade-stale-sandbox

Optional E2E targets

  • None.

Relevant changed files

  • src/lib/actions/sandbox/rebuild-gpu-opt-out.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.ts
  • src/lib/onboard/authoritative-rebuild-target.ts
  • src/lib/onboard/machine/core-flow-phases.ts
  • src/lib/onboard/machine/handlers/provider-inference-recovery.ts
  • src/lib/onboard/machine/handlers/provider-inference.ts
  • src/lib/onboard/rebuild-route-handoff.ts
  • src/lib/onboard/types.ts
  • src/lib/onboard/machine/handlers/provider-inference.test-support.ts

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor (Nemotron Ultra) — Changes requested

Merge posture: Do not merge yet
Primary next action: Resolve or justify PRA-1: Test file monolith growth exceeds threshold without extraction.
Open items: 0 required · 3 warnings · 1 suggestion · 5 test follow-ups
Top item: Test file monolith growth exceeds threshold without extraction

Action checklist

  • PRA-1 Resolve or justify: Test file monolith growth exceeds threshold without extraction in src/lib/onboard/machine/handlers/provider-inference-recovery-gating.test.ts:1
  • PRA-2 Resolve or justify: Source-of-truth workaround: receipt system papers over incomplete-session FSM timing with circular reference in src/lib/onboard/machine/handlers/provider-inference-recovery.ts:25
  • PRA-3 Resolve or justify: Monolith growth on current hotspot file in src/lib/onboard/machine/handlers/provider-inference.ts:1
  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Runtime validation
  • PRA-T4 Add or justify test follow-up: Runtime validation
  • PRA-T5 Add or justify test follow-up: Runtime validation
  • PRA-4 In-scope improvement: New test file at 196 lines could benefit from organization by concern in src/lib/onboard/rebuild-route-handoff.test.ts:1

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify architecture src/lib/onboard/machine/handlers/provider-inference-recovery-gating.test.ts:1 Extract the new receipt-specific tests (concurrent recovery, foreign reservation recheck) into a dedicated test file (e.g., provider-inference-recovery-receipt.test.ts) or split the existing file by concern. At minimum, add a follow-up task to refactor before the next feature lands on this file.
PRA-2 Resolve/justify architecture src/lib/onboard/machine/handlers/provider-inference-recovery.ts:25 Track the FSM restructuring as a follow-up issue. Add a code comment with a concrete removal condition (e.g., 'Remove when FSM supports atomic provider+sandbox authority or a dedicated recovery phase exists'). Ensure any FSM/refactor work verifies the receipt system can be removed without regressing the concurrent/race test coverage.
PRA-3 Resolve/justify architecture src/lib/onboard/machine/handlers/provider-inference.ts:1 Review whether the receipt plumbing can be extracted into a separate module or helper, or whether the provider-inference.ts file should be split by concern (selection, setup, recovery).
PRA-4 Improvement architecture src/lib/onboard/rebuild-route-handoff.test.ts:1 Consider splitting into: rebuild-route-handoff-minting.test.ts, rebuild-route-handoff-ledger.test.ts, rebuild-route-handoff-recheck.test.ts, or similar organization by concern.
Review findings by urgency: 0 required fixes, 3 items to resolve/justify, 1 in-scope improvement

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-1 Resolve/justify — Test file monolith growth exceeds threshold without extraction

  • Location: src/lib/onboard/machine/handlers/provider-inference-recovery-gating.test.ts:1
  • Category: architecture
  • Problem: provider-inference-recovery-gating.test.ts grew from 409 to 514 lines (+105) in this PR, exceeding the 20-line growth threshold for current large-file hotspots. The growth adds security-critical negative tests for the new Provider Recovery Receipt system (concurrent recovery, foreign reservation recheck), but the test file is now a 514-line monolith that should be split or offset.
  • Impact: Large test files reduce maintainability, slow test collection, and make it harder to isolate regression coverage. This file covers provider inference recovery gating across multiple scenarios and should be factored into focused test modules.
  • Recommended action: Extract the new receipt-specific tests (concurrent recovery, foreign reservation recheck) into a dedicated test file (e.g., provider-inference-recovery-receipt.test.ts) or split the existing file by concern. At minimum, add a follow-up task to refactor before the next feature lands on this file.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Run `wc -l src/lib/onboard/machine/handlers/provider-inference-recovery-gating.test.ts` and confirm line count > 500. Check if tests can be logically grouped into separate files.
  • Missing regression test: No test file organization regression test exists; consider adding a lint rule or CI check for test file line limits.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Run `wc -l src/lib/onboard/machine/handlers/provider-inference-recovery-gating.test.ts` and confirm line count > 500. Check if tests can be logically grouped into separate files.
  • Evidence: riskContext.monolithDeltas[0] shows delta: 105, severity: blocker, rationale: 'Current monolith grew by 20 or more lines; extract or offset the growth before merge.' diff shows +107 lines in provider-inference-recovery-gating.test.ts

PRA-2 Resolve/justify — Source-of-truth workaround: receipt system papers over incomplete-session FSM timing with circular reference

  • Location: src/lib/onboard/machine/handlers/provider-inference-recovery.ts:25
  • Category: architecture
  • Problem: The ProviderRecoveryReceipt system is a localized workaround for the FSM step-completion timing problem: rebuild deletes the sandbox before creating a new one, so the sandbox step marker remains incomplete during provider recovery. The receipt authorizes recovery despite the incomplete step. The comment at line 25 references security(onboard): replace rebuild recovery flag with authorization receipt #6666 as the future fix, but security(onboard): replace rebuild recovery flag with authorization receipt #6666 is the tracking issue for this very receipt system — the actual root fix (FSM restructuring to allow provisional step completion or a dedicated recovery phase) is not scheduled.
  • Impact: The workaround is security-critical and correctly implemented with one-shot receipts, mutation-lock rechecks, and TOCTOU tests. However, it adds complexity to the authorization path and the root cause (FSM step timing) remains unfixed. Future changes to FSM or rebuild flow must account for this workaround.
  • Recommended action: Track the FSM restructuring as a follow-up issue. Add a code comment with a concrete removal condition (e.g., 'Remove when FSM supports atomic provider+sandbox authority or a dedicated recovery phase exists'). Ensure any FSM/refactor work verifies the receipt system can be removed without regressing the concurrent/race test coverage.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the comment at provider-inference-recovery.ts:25-32 and verify it references security(onboard): replace rebuild recovery flag with authorization receipt #6666 circularly. Check that provider-inference-recovery-gating.test.ts concurrent/race tests would still pass if the receipt system were removed and FSM step timing fixed.
  • Missing regression test: No test asserts the workaround can be removed; add a TODO-tracking test or lint rule that flags the receipt system for removal when FSM timing is fixed.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the comment at provider-inference-recovery.ts:25-32 and verify it references security(onboard): replace rebuild recovery flag with authorization receipt #6666 circularly. Check that provider-inference-recovery-gating.test.ts concurrent/race tests would still pass if the receipt system were removed and FSM step timing fixed.
  • Evidence: provider-inference-recovery.ts:25-32 comment references security(onboard): replace rebuild recovery flag with authorization receipt #6666 as future fix but security(onboard): replace rebuild recovery flag with authorization receipt #6666 is this PR's issue rebuild-route-handoff.ts:184-194 docstring describes receipt as 'one-shot authority' for the incomplete-session gap provider-inference-recovery-gating.test.ts:431-514 tests prove workaround handles TOCTOU but don't test removal

PRA-3 Resolve/justify — Monolith growth on current hotspot file

  • Location: src/lib/onboard/machine/handlers/provider-inference.ts:1
  • Category: architecture
  • Problem: provider-inference.ts grew from 840 to 851 lines (+11) in this PR. The file is already a current large-file hotspot (warning severity in risk context). The growth adds providerRecoveryReceipt plumbing through the provider inference handler.
  • Impact: Continued growth on an already-large handler file reduces maintainability and makes it harder to isolate provider inference logic from recovery authorization logic.
  • Recommended action: Review whether the receipt plumbing can be extracted into a separate module or helper, or whether the provider-inference.ts file should be split by concern (selection, setup, recovery).
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Run `wc -l src/lib/onboard/machine/handlers/provider-inference.ts` and confirm line count > 850. Check if receipt-related logic can be factored out.
  • Missing regression test: No test file organization regression test exists for handler file size.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Run `wc -l src/lib/onboard/machine/handlers/provider-inference.ts` and confirm line count > 850. Check if receipt-related logic can be factored out.
  • Evidence: riskContext.monolithDeltas[1] shows delta: 11, severity: warning, rationale: 'Current monolith grew by 1-19 lines; review whether extraction is feasible.' diff shows +13 lines in provider-inference.ts

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

PRA-4 Improvement — New test file at 196 lines could benefit from organization by concern

  • Location: src/lib/onboard/rebuild-route-handoff.test.ts:1
  • Category: architecture
  • Problem: rebuild-route-handoff.test.ts grew from 43 to 196 lines (+153) in this PR. While not a current hotspot, the new tests cover minting, ledger activation, one-shot semantics, in-lock rechecks, and rejection cases — distinct concerns that could be split into focused test files for maintainability.
  • Impact: As the receipt system evolves, a single test file mixing minting, activation, and validation tests will become harder to navigate and maintain.
  • Suggested action: Consider splitting into: rebuild-route-handoff-minting.test.ts, rebuild-route-handoff-ledger.test.ts, rebuild-route-handoff-recheck.test.ts, or similar organization by concern.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Run `wc -l src/lib/onboard/rebuild-route-handoff.test.ts` and review test describe blocks for logical grouping.
  • Missing regression test: No test organization regression test exists.
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: riskContext.monolithDeltas[4] shows delta: 153, severity: none, rationale: 'Changed TypeScript file is not a current large-file hotspot.' diff shows +155 lines in rebuild-route-handoff.test.ts with 5 describe blocks covering distinct concerns
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Run the `cloud-onboard` E2E job for Installer and platform changes must work on a clean supported host with the pinned runtime dependencies. Matched files: `src/lib/onboard/machine/core-flow-phases.ts`, `src/lib/onboard/machine/handlers/provider-inference-recovery.ts`, `src/lib/onboard/machine/handlers/provider-inference.test-support.ts`, `src/lib/onboard/machine/handlers/provider-inference.ts`.. Deterministic regression risks require live validation: lifecycle-state, upgrade-rebuild, inference-policy, platform-install.
  • PRA-T2 Runtime validation — Run the `inference-routing` E2E job for Inference selection, reachability, and network policy must agree at the real host-to-sandbox boundary. Matched files: `src/lib/onboard/machine/handlers/provider-inference-recovery.ts`, `src/lib/onboard/machine/handlers/provider-inference.test-support.ts`, `src/lib/onboard/machine/handlers/provider-inference.ts`.. Deterministic regression risks require live validation: lifecycle-state, upgrade-rebuild, inference-policy, platform-install.
  • PRA-T3 Runtime validation — Run the `network-policy` E2E job for Inference selection, reachability, and network policy must agree at the real host-to-sandbox boundary. Matched files: `src/lib/onboard/machine/handlers/provider-inference-recovery.ts`, `src/lib/onboard/machine/handlers/provider-inference.test-support.ts`, `src/lib/onboard/machine/handlers/provider-inference.ts`.. Deterministic regression risks require live validation: lifecycle-state, upgrade-rebuild, inference-policy, platform-install.
  • PRA-T4 Runtime validation — Run the `onboard-repair` E2E job for Onboarding and sandbox state must converge across persisted metadata, reported status, and the live runtime. Matched files: `src/lib/actions/sandbox/rebuild-gpu-opt-out.ts`, `src/lib/actions/sandbox/rebuild-preflight-target-phase.ts`, `src/lib/onboard/authoritative-rebuild-target.ts`, `src/lib/onboard/machine/core-flow-phases.ts`, `src/lib/onboard/machine/handlers/provider-inference-recovery.ts`.. Deterministic regression risks require live validation: lifecycle-state, upgrade-rebuild, inference-policy, platform-install.
  • PRA-T5 Runtime validation — Run the `onboard-resume` E2E job for Onboarding and sandbox state must converge across persisted metadata, reported status, and the live runtime. Matched files: `src/lib/actions/sandbox/rebuild-gpu-opt-out.ts`, `src/lib/actions/sandbox/rebuild-preflight-target-phase.ts`, `src/lib/onboard/authoritative-rebuild-target.ts`, `src/lib/onboard/machine/core-flow-phases.ts`, `src/lib/onboard/machine/handlers/provider-inference-recovery.ts`.. Deterministic regression risks require live validation: lifecycle-state, upgrade-rebuild, inference-policy, platform-install.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: No advisor follow-up required beyond maintainer review.
Findings: 0 required · 0 warnings · 0 optional suggestions

Workflow run details

This is an automated review. Required findings need action before merge. Warnings and optional suggestions do not require a response or follow-up. A human maintainer makes the final merge decision.

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/lib/onboard/rebuild-route-handoff.ts`:
- Around line 120-126: Update routesMatch to also compare
left.preferredInferenceApi with right.preferredInferenceApi, while preserving
the existing provider, model, and endpointUrl comparisons.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c1db93c8-1866-4b38-af03-db60d14b643a

📥 Commits

Reviewing files that changed from the base of the PR and between e4d2e91 and 3df40dd.

📒 Files selected for processing (13)
  • src/lib/actions/sandbox/rebuild-gpu-opt-out.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.ts
  • src/lib/onboard/authoritative-rebuild-target.test.ts
  • src/lib/onboard/authoritative-rebuild-target.ts
  • src/lib/onboard/machine/core-flow-phases.ts
  • src/lib/onboard/machine/handlers/provider-inference-authoritative-recovery.test.ts
  • src/lib/onboard/machine/handlers/provider-inference-recovery-gating.test.ts
  • src/lib/onboard/machine/handlers/provider-inference-recovery.ts
  • src/lib/onboard/machine/handlers/provider-inference.test-support.ts
  • src/lib/onboard/machine/handlers/provider-inference.ts
  • src/lib/onboard/rebuild-route-handoff.test.ts
  • src/lib/onboard/rebuild-route-handoff.ts
  • src/lib/onboard/types.ts

Comment thread src/lib/onboard/rebuild-route-handoff.ts
@laitingsheng laitingsheng added security bug-fix PR fixes a bug or regression labels Jul 11, 2026
…InferenceApi

routesMatch compared provider, model, and endpointUrl but not
preferredInferenceApi, so a receipt could activate against a target on a
different inference API family sharing the same provider/model/endpoint.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@cv cv added the v0.0.81 label Jul 11, 2026

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/lib/onboard/machine/handlers/provider-inference.test.ts`:
- Around line 824-839: Update the recovery test around
handleProviderInferenceState to remove or disable authoritativeResumeConfig and
keep provider_selection incomplete, ensuring the activated
providerRecoveryReceipt and providerRecoveryReceiptLedger are the only
authorization path. Assert the public handler succeeds through receipt
validation and verify the legacy resume shortcut cannot execute.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a24b7b61-7458-4174-b325-921446644cb9

📥 Commits

Reviewing files that changed from the base of the PR and between f5429dd and e5e86f7.

📒 Files selected for processing (3)
  • src/lib/onboard/machine/handlers/provider-inference.test.ts
  • src/lib/onboard/rebuild-route-handoff.test.ts
  • src/lib/onboard/rebuild-route-handoff.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/onboard/rebuild-route-handoff.test.ts
  • src/lib/onboard/rebuild-route-handoff.ts

Comment thread src/lib/onboard/machine/handlers/provider-inference.test.ts

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed current PR commit e3f5d23. All 50 checks are green, including the seven selected live E2E scenarios (cloud-onboard, inference-routing, network-policy, onboard-repair, onboard-resume, state-backup-restore, and upgrade-stale-sandbox). The focused receipt/recovery suite passes 76 tests locally, CLI type-check and normal hooks passed, replay and fabricated-provenance paths are covered, all eight commits are GitHub Verified with DCO present, no review threads remain unresolved, CodeRabbit has no blocking findings, and the provenance-valid primary advisor recommends merge_as_is.

@cv
cv merged commit 6896cc7 into main Jul 12, 2026
53 of 54 checks passed
@cv
cv deleted the fix/6666-rebuild-recovery-receipt branch July 12, 2026 01:11
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
NVIDIA#6675)

<!-- markdownlint-disable MD041 -->
## Summary
Replace the authoritative-rebuild incomplete-session boolean bypass with
a one-shot, target-bound provider-recovery authorization receipt. The
receipt is minted after locked rebuild preflight, activated against the
onboard session at provider selection, and rechecked inside the gateway
and sandbox mutation locks, so recovering a recorded provider is bound
to the exact rebuild target and to the reservation owner.

## Related Issue
Resolves NVIDIA#6666

## Changes
- Add `ProviderRecoveryReceipt` with `mintProviderRecoveryReceipt` and a
single-use `createProviderRecoveryReceiptLedger` (`activate` binds one
session and refuses replay, cross-sandbox, expired, malformed, or
route-mismatched receipts; `validateInLock` re-binds to the live
reservation owner) in `rebuild-route-handoff.ts`.
- Mint the receipt after preflight validates the target in
`rebuild-preflight-target-phase.ts`; carry it on `OnboardOptions` and
the rebuild recreate options.
- Activate the receipt against the live session and target in
`rebuildProviderFlowOptions`, threading it through the core flow phases
into the provider-inference handler.
- Drop the `authoritativeResumeConfig` incomplete-session bypass and its
temporary comment in the recovery gate; the gate now keys on the
activated receipt and the in-lock recheck also runs `validateInLock`.
- Add unit coverage for the receipt primitive and two behavioural tests:
only the reservation owner recovers the same sandbox concurrently, and a
foreign reservation introduced after selection is rejected inside the
mutation lock.

## Type of Change

- [x] 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
- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification:
- [x] 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:
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification
- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [ ] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — command/result or justification:
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result:
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added one-time provider recovery receipts with an associated receipt
ledger to authorize recorded-provider recovery during rebuilds.
* Receipts are minted during rebuild preflight and carried through the
onboarding/rebuild flow to enable secure resumption.

* **Bug Fixes**
* Strengthened recovery gating to block unauthorized concurrent and
lock-time recovery attempts.
* Added stricter validation for receipt expiry, one-shot replay,
session/sandbox/gateway matching, and reservation ownership.

* **Tests**
* Expanded coverage for receipt minting, ledger activation,
replay/session binding, and recovery recheck behavior under
concurrent/foreign reservations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(onboard): replace rebuild recovery flag with authorization receipt

3 participants