Skip to content

fix(rebuild): recover managed MCP after exec loss#7196

Merged
cv merged 25 commits into
mainfrom
codex/7062-force-mcp-recovery
Jul 26, 2026
Merged

fix(rebuild): recover managed MCP after exec loss#7196
cv merged 25 commits into
mainfrom
codex/7062-force-mcp-recovery

Conversation

@apurvvkumaria

@apurvvkumaria apurvvkumaria commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

An explicit rebuild --force can now preserve registered managed MCP intent when the old sandbox cannot execute a pre-mutation no-op. The recovery does not reinterpret arbitrary live MCP preparation failures as exec-relay loss, and it preserves the original contribution from @kagura-agent with co-author credit.

Related Issue

Closes #7062.

Supersedes #7195 because its published commit lacks the required DCO sign-off and cannot be repaired append-only.

Changes

  • Thread the normalized force choice through the rebuild destroy phase.
  • Probe sandbox execution before any MCP teardown mutation.
  • Use the existing host-side absent-sandbox recovery only when that probe fails under explicit force.
  • Keep policy drift, ambiguous ownership, invalid targets, provider failures, and errors after a successful probe fail-closed.
  • Require delete convergence to prove explicit absence for the named sandbox; reject other-resource, mixed, and signal-terminated diagnostics.
  • Document the data-loss and managed-MCP recovery boundary in the command reference and rebuild recovery guide.
  • Cover force propagation, unavailable execution, live-path safety failures, ambiguous host-side state, non-force behavior, and established stale recovery.

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: maintainer review narrowed recovery to a pre-mutation no-op failure and added fail-closed regressions.
  • 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: The writer reviewed the cumulative behavior through e92c7f060896fe3ea5fb84cc4876ddba26c8fcf9, then independently reviewed the exact follow-up delta through 768e87c20a6f676e51bf6890884d724d76565a3a. The follow-up changes only three integration-test diagnostics to name sandbox my-assistant, aligning intended success fixtures with the already-documented strict delete-convergence rule. No command, flag, output contract, recovery step, runtime behavior, or user action changed.
  • Agent: Codex Desktop

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 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 — exact head 768e87c20a6f676e51bf6890884d724d76565a3a: 12 remaining integration fixture tests, 26 owning destroy-phase tests, and 96 earlier affected fixture-consumer tests passed; Biome, the CLI build, CLI type-check, normal commit hooks, and normal push hooks passed. The earlier branch head retained its broader 90 owning rebuild-flow, 32 adjacent CLI, and 45 MCP lifecycle integration test evidence.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — not applicable to this narrow branch; exact-head PR CI will run the repository gates.
  • 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) — the prior head's documentation validation passed with 0 errors and 2 Fern warnings; the exact-head follow-up changes no documentation.
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Apurv Kumaria akumaria@nvidia.com

Summary by CodeRabbit

  • Documentation

    • Expanded the rebuild --force managed-MCP warning with clearer guidance on when recovery falls back to a host-side, fail-closed path, plus safer post-delete verification and reconciliation outcomes.
  • Bug Fixes

    • Improved forced managed-MCP rebuild safety by probing in-sandbox when enabled, using stricter read-only ownership/policy checks when exec is unavailable, handling ambiguous delete states correctly, and delaying local NIM stopping until after deletion is confirmed.
  • Tests

    • Added broader coverage for forced rebuild MCP prep, exec-unavailable recovery, policy/ownership drift detection, and correct force behavior through the rebuild destroy phase.

Use host-side MCP recovery only when an explicit forced rebuild cannot run a sandbox no-op.

Keep policy, ownership, target, provider, and transaction errors fail-closed.

Closes #7062

Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 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

Forced rebuilds now probe sandbox execution before MCP teardown and use read-only host-side MCP recovery when the probe is unavailable. Deletion outcomes are reconciled before cleanup, with force propagation, ambiguity handling, validation tests, and updated documentation.

Changes

Forced MCP rebuild recovery

Layer / File(s) Summary
Canonical MCP state validation
src/lib/actions/sandbox/gateway-state.ts, src/lib/actions/sandbox/mcp-bridge-policy.ts, src/lib/actions/sandbox/*test.ts
Canonical policy ownership and missing-sandbox output are validated consistently.
Exec-unavailable MCP preparation
src/lib/actions/sandbox/mcp-bridge-rebuild*.ts, src/lib/actions/sandbox/mcp-bridge.ts
Complete MCP entries are snapshotted with policy, provider, target, gateway, and adapter identity checks before deletion.
Destroy-phase reconciliation
src/lib/actions/sandbox/rebuild-*.ts, test/helpers/rebuild-flow-recovery-cases.ts
Force state is propagated, NIM stopping is deferred, and delete results are classified as deleted, intact, or ambiguous.
Recovery lifecycle validation
test/mcp-destroy-lifecycle.test.ts, src/lib/actions/sandbox/rebuild-destroy-phase.test.ts
Tests cover ownership drift, provider identity, DNS pins, delete-edge changes, partial probes, reattachment, and cleanup ordering.
Rebuild recovery documentation
docs/reference/commands.mdx, docs/manage-sandboxes/recover-rebuild-sandboxes.mdx
Documentation describes probing, host-side preservation, stop conditions, reconciliation, cleanup timing, and fail-closed behavior.

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

Sequence Diagram(s)

sequenceDiagram
  participant RebuildPipeline
  participant RebuildDestroyPhase
  participant MCPPreparation
  participant SandboxExec
  participant HostSideRecovery
  participant OpenShell
  participant NIM
  RebuildPipeline->>RebuildDestroyPhase: pass normalized force
  RebuildDestroyPhase->>MCPPreparation: prepare MCP for rebuild
  MCPPreparation->>SandboxExec: execute pre-mutation no-op
  SandboxExec-->>MCPPreparation: success or unavailable
  MCPPreparation->>HostSideRecovery: validate and preserve MCP intent
  RebuildDestroyPhase->>OpenShell: delete sandbox
  OpenShell-->>RebuildDestroyPhase: delete result and gateway state
  RebuildDestroyPhase->>NIM: stop after confirmed deletion
Loading

Possibly related issues

Possibly related PRs

Suggested labels: bug-fix, area: sandbox, area: security, v0.0.88

Suggested reviewers: ericksoa, laitingsheng, jyaunches

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 Implements the #7062 recovery path, force propagation, fail-closed drift checks, and restore/cleanup behavior described in the issue.
Out of Scope Changes check ✅ Passed Changes stay focused on rebuild recovery, MCP validation, docs, and tests with no clear unrelated feature work.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: rebuilding now recovers managed MCP when sandbox exec is lost.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/7062-force-mcp-recovery

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

@github-actions

Copy link
Copy Markdown
Contributor

@github-code-quality

github-code-quality Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 768e87c in the codex/7062-force-mcp... branch remains at 96%, unchanged from commit 029c7aa in the main branch.


Updated July 26, 2026 01:39 UTC

@github-actions

github-actions Bot commented Jul 19, 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 · medium confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 2 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 2 more warnings, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

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

Recommended E2E: inference-routing, network-policy, onboard-repair, onboard-resume, state-backup-restore, upgrade-stale-sandbox

2 optional E2E recommendations
  • mcp-bridge
  • sandbox-rebuild

Workflow run details

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

@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Exact-head maintainer audit: the implementation and fail-closed unit/integration coverage are clean, required CI and the selected protected E2E lanes pass, and there are no unresolved review threads.

The advisor's non-blocking request for a deterministic live exec-loss scenario is valid but separable from this fix. I filed #7198 with explicit credential-redaction and recovery acceptance criteria. Independent review is requested because this PR is authored by the current maintainer account.

apurvvkumaria and others added 3 commits July 19, 2026 12:14
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Pushed the reviewed #7062 recovery completion as two signed, GitHub-Verified, append-only commits with kagura-agent credited:

  • ad20e0e90ae8a914bff0d8b60685cfe632bfbbd1 — atomic implementation and tests;
  • dedfcce40739d6dcc1291c0178f212216fdae0d7 — user-facing recovery documentation.

The explicit rebuild --force fallback is read-only before deletion and now requires complete bridge entries, the adapter recorded for the sandbox agent, exact owner gateway, canonical live generated policy plus DNS pins, and exact provider identity. It revalidates those proofs at the delete edge. Duplicate same-name policy ownership, incomplete transitions, malformed state, target drift, provider drift, policy drift, gateway drift, and probe failures all stop fail closed.

Nonzero deletion now queries the exact recorded gateway with a bounded probe: explicit absence continues, confirmed Ready/Running attempts MCP and temporary-shields restoration, and timeout/partial/other ambiguous results preserve ownership and recovery metadata. Local NIM cleanup starts only after deletion is positively confirmed.

Validation on the final tree:

  • focused recovery CLI tests: 51/51;
  • MCP lifecycle: 36/36;
  • full rebuild-flow suite: 83/83;
  • CLI type-check passed;
  • strict docs build passed with the repository’s two existing warnings;
  • Biome, title/source-shape, diff, commit, DCO, and pre-push gates passed.

Fresh exact-head CI and advisor checks are now running on dedfcce40739d6dcc1291c0178f212216fdae0d7.

Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/actions/sandbox/mcp-bridge.ts (1)

94-102: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Consolidate the duplicated McpRebuildPreparation contract and its two export paths into one canonical source.

Both files independently declare the identical McpRebuildPreparation interface shape, and both expose prepareMcpBridgesForExecUnavailableRebuild under the same name through two different routes (a pass-through wrapper in mcp-bridge.ts vs. a direct re-export in mcp-bridge-rebuild.ts, both ultimately delegating to mcp-bridge-rebuild-exec-unavailable.ts). This PR had to hand-edit the same two optional hooks in two places to keep them in sync — exactly the "duplicate sources of truth" / "forwarding wrappers that add a new layer without retiring the old owner" pattern called out for src/lib/{actions,domain,adapters,state}/**.

  • src/lib/actions/sandbox/mcp-bridge.ts#L94-L102: import McpRebuildPreparation from a single canonical module (e.g., mcp-bridge-rebuild-exec-unavailable.ts or a shared contracts file) instead of redeclaring it here; drop the local interface.
  • src/lib/actions/sandbox/mcp-bridge.ts#L157-L161: remove this pass-through wrapper, or make it the sole canonical export and have mcp-bridge-rebuild.ts import from it instead of independently re-exporting the underlying implementation.
  • src/lib/actions/sandbox/mcp-bridge-rebuild.ts#L41-L52: drop the independently-declared McpRebuildPreparation interface (import the canonical one) and pick a single re-export path for prepareMcpBridgesForExecUnavailableRebuild shared with mcp-bridge.ts rather than maintaining a second parallel export.
🤖 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/actions/sandbox/mcp-bridge.ts` around lines 94 - 102, The
McpRebuildPreparation contract and prepareMcpBridgesForExecUnavailableRebuild
export are duplicated across two modules. In
src/lib/actions/sandbox/mcp-bridge.ts#L94-L102, remove the local interface and
import the canonical type; in
src/lib/actions/sandbox/mcp-bridge-rebuild.ts#L41-L52, remove its duplicate
interface and use the same import. Consolidate the two export paths so both
modules share one canonical prepareMcpBridgesForExecUnavailableRebuild route,
removing the unnecessary pass-through wrapper or independent re-export.

Source: Path instructions

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

Outside diff comments:
In `@src/lib/actions/sandbox/mcp-bridge.ts`:
- Around line 94-102: The McpRebuildPreparation contract and
prepareMcpBridgesForExecUnavailableRebuild export are duplicated across two
modules. In src/lib/actions/sandbox/mcp-bridge.ts#L94-L102, remove the local
interface and import the canonical type; in
src/lib/actions/sandbox/mcp-bridge-rebuild.ts#L41-L52, remove its duplicate
interface and use the same import. Consolidate the two export paths so both
modules share one canonical prepareMcpBridgesForExecUnavailableRebuild route,
removing the unnecessary pass-through wrapper or independent re-export.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ee87a128-bdd3-48c0-ab0e-57adeef0c435

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8dbcf and dedfcce.

📒 Files selected for processing (16)
  • docs/manage-sandboxes/recover-rebuild-sandboxes.mdx
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/gateway-state-owning-gateway.test.ts
  • src/lib/actions/sandbox/gateway-state.ts
  • src/lib/actions/sandbox/mcp-bridge-policy.test.ts
  • src/lib/actions/sandbox/mcp-bridge-policy.ts
  • src/lib/actions/sandbox/mcp-bridge-rebuild-exec-unavailable.ts
  • src/lib/actions/sandbox/mcp-bridge-rebuild.ts
  • src/lib/actions/sandbox/mcp-bridge.ts
  • src/lib/actions/sandbox/rebuild-destroy-phase.test.ts
  • src/lib/actions/sandbox/rebuild-destroy-phase.ts
  • src/lib/actions/sandbox/rebuild-mcp-phase.test.ts
  • src/lib/actions/sandbox/rebuild-mcp-phase.ts
  • src/lib/actions/sandbox/rebuild-pipeline.ts
  • test/helpers/rebuild-flow-recovery-cases.ts
  • test/mcp-destroy-lifecycle.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/actions/sandbox/rebuild-mcp-phase.test.ts

@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Pushed the narrow growth-guard follow-up in f1c564361.

  • Removed the only new test conditional while preserving a runtime adapter assertion before policy construction.
  • Independent review confirmed the shared AST counter remains 0 at both the base and current head.
  • Focused lifecycle validation: 36/36 passed.
  • Biome, CLI type-check, repository conditional scan, commit hooks, and pre-push hooks passed.
  • Commit is DCO-compliant, GitHub Verified, and preserves the original author's credit.

Fresh exact-head CI and automated review are now running.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Advisor follow-up on exact head f1c564361:

  • The one permitted failed-job retry is exhausted; no further retry will be issued on this revision.
  • Terra completed successfully and the published primary assessment remains informational with 0 blockers, 0 warnings, and 0 suggestions.
  • Nemotron reproduced an advisor-ledger validation error after completing its analysis: a status=satisfied entry retained a non-null finding ID. This is an advisor output/schema failure, not a repository test or product-code failure.
  • All repository checks, CodeRabbit, focused validation, and the growth guard are green.

No code change is justified by the exhausted advisor failure.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Blocking exact-head security review at f1c5643 found two pre-delete gaps. First, generic or gateway-level NotFound output, including signal-terminated partial output, can be treated as positive proof that the sandbox was deleted. Require a completed sandbox-specific absence response tied to the requested sandbox and reject gateway/provider/schema/transport ambiguity. Second, the host-recovery snapshot validates entries individually but not cross-entry credential, provider, and policy uniqueness, so collisions can surface only after destructive deletion. Re-establish those whole-snapshot invariants before delete and add negative tests for both boundaries. I am preparing the narrow fixes now.

apurvvkumaria and others added 3 commits July 19, 2026 19:40
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Maintainer remediation is now pushed at exact head 21695d1.

  • Destructive recovery now accepts only explicit, sandbox-scoped absence evidence and rejects bare or generic NotFound, gateway/provider errors, mixed output, wrong sandbox names, signals, null status, and incomplete probes.
  • MCP rebuild now rejects duplicate credential keys, provider names, provider IDs, and generated policy names before any inspection or mutation.
  • The rebuild preparation contract and implementation now have one canonical owner.

Validation: rebuild destroy phase 16/16, MCP lifecycle 40/40, CLI type-check, and diff whitespace check all pass. An independent security audit found no remaining blocker. All three commits are signed off, GitHub Verified, append-only, and retain kagura-agent as co-author.

Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Addressed the final transport-symmetry review finding in 5293739. Forced rebuild now proves both SSH-backed and OpenShell sandbox-exec MCP preparation paths before any live mutation; either mismatch selects the fail-closed host-side recovery path, with Docker fallback disabled. Comments now accurately scope gateway recovery/selection and the registry-only final edge check.

Validation: independent security re-audit PASS; 61 targeted tests PASS; CLI typecheck PASS; Biome and diff checks PASS. The commit is DCO-signed, original-author credited, and GitHub Verified. Monitoring exact-head CI/advisor feedback now.

Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

CI follow-up 6340766 linearizes the transport mock flagged by the codebase growth guard; behavior and coverage are unchanged. The 40-test lifecycle file, Biome, and diff checks pass, and the signed co-authored commit is GitHub Verified. Exact-head CI has restarted.

Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Addressed the exact-head advisor blocker in b83a56b. The destructive sandbox delete now resolves the persisted gateway before MCP preparation and passes it explicitly with -g at the delete boundary; recorded-gateway post-delete reconciliation remains unchanged. Added a regression with ambient OPENSHELL_GATEWAY=nemoclaw-29080 and persisted gateway nemoclaw-19080, proving deletion targets only nemoclaw-19080. Validation: 17/17 focused tests, CLI typecheck, Biome, git diff check, and an independent security audit all pass. Commit is signed, DCO-compliant, co-authored, and GitHub Verified.

Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression labels Jul 20, 2026
apurvvkumaria and others added 3 commits July 24, 2026 20:32
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Fixed the newly actionable CLI timeout cascade in signed commit 59bac28. The shared rebuild fixtures now model the exact recorded-gateway deletion probe instead of falling through to the full convergence wait. Exact-head local evidence: 66 shared-harness tests, 64 focused CLI tests, and 40 MCP lifecycle integration tests pass; source-shape, Biome, commit hooks, CLI typecheck, and pre-push checks pass. The replacement CI run is now authoritative; the prior failed jobs are superseded.

@apurvvkumaria apurvvkumaria added the v0.0.96 Release target label Jul 25, 2026
Co-authored-by: kagura-agent <kagura.agent.ai@gmail.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Addressed the exact-head shard-8 failure in signed commit 280c81e. Root cause: the safe default exact-gateway fixture response ran before explicit per-test OpenShell behavior, so the delete-failure regression could not model an intact sandbox. Explicit handled calls now take precedence, while unhandled calls fall through to the safe default. Exact-head local evidence: targeted regressions 3/3 and full rebuild-flow suite 86/86; Biome, source-shape, commit hooks, CLI typecheck, and pre-push gates pass. Prior CI is superseded by the replacement run.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Exact-head E2E retry follow-up for 280c81e08b606d5aab82556a91991cb31c8c9d85: upgrade-stale-sandbox, the lane directly exercising this PR, passed. The three failures all reached sandbox base-image creation and were terminated at the shared 15-minute live-test ceiling with context canceled / signal termination; runner health remained normal and the same timeout signature occurred across network-policy zero-presets, network-policy live-probes, and onboard-resume. This is shared cold-build infrastructure pressure rather than evidence of an MCP recovery regression, so I am not adding an unrelated code change. The next validation should reuse a compatible published base image or rerun after runner/base-image availability recovers.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Exact-head E2E follow-up for db6a752d2: every non-E2E check is terminal and passing, and the advisor reports no actionable findings. The coordination result failed in generate-matrix at Authenticate controller dispatch; none of this PR’s selected recovery lanes ran. This is the same controller authorization defect fixed by #7529, not evidence of a managed-MCP recovery regression. I am not rerunning the unchanged head; after #7529 lands, this PR needs fresh exact-head E2E and independent approval.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Addressed the exact-head PRA-1 delete-convergence blocker in signed commit 61834f2. The successful-delete convergence path now uses the same strict named-sandbox classifier as nonzero-delete reconciliation and rejects signal-terminated probes, other sandbox names, gateway/provider NotFound output, and mixed diagnostics. Five adversarial cases verify that NIM stop, registry removal, and recreation signaling do not occur; all 26 destroy-phase tests, Biome, CLI build/type-check, and normal commit/push hooks pass.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

apurvvkumaria commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up fix-forward: signed commit e92c7f060896fe3ea5fb84cc4876ddba26c8fcf9 updates only the success-path fixtures that still emitted an unnamed sandbox not found. Those fixtures now prove explicit absence for alpha, while generic NotFound cases remain ambiguous by design. The two previously failing shards reproduce cleanly across 96 affected tests; normal commit and push hooks pass.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@cv
cv merged commit bc695ff into main Jul 26, 2026
69 of 72 checks passed
@cv
cv deleted the codex/7062-force-mcp-recovery branch July 26, 2026 01:47
cv added a commit that referenced this pull request Jul 26, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Closes two destructive-delete safety gaps discovered after #7196 merged.
Rebuild now rereads the sandbox registry immediately before deletion,
verifies the canonical sandbox and recorded gateway binding still match
the prepared target, and treats an accepted but unconfirmed deletion as
ambiguous so shields are not relocked prematurely.

## Related Issue

Follow-up to #7196 and #7062.

## Changes

- Reread and resolve the canonical sandbox target and recorded gateway
at the delete edge.
- Abort deletion, restore MCP state, and relock shields when the sandbox
identity or gateway binding drifts after MCP preparation.
- Mark an accepted but unconfirmed delete as ambiguous so the outer
finally path does not claim a locked posture.
- Recognize OpenShell's exact structured sandbox-absence response while
leaving gateway, provider, transport, and mixed diagnostics ambiguous.
- Add regressions for sandbox-name drift, gateway-binding drift, MCP
restoration, ambiguous deletion, and structured absence classification.

## 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: This correction restores the
delete-edge identity and ambiguous-deletion behavior already documented
in the rebuild, MCP, and trusted-boundary guides.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: The correction narrows
the destructive action by revalidating the exact target and gateway at
the delete edge, fails closed on drift, restores MCP before relocking,
and only classifies the exact structured sandbox-not-found response as
absence.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Documentation Writer Review

- [x] Documentation writer subagent reviewed the completed changes
- Result: `no-docs-needed`
- Evidence: Existing canonical docs already require delete-edge
target/gateway revalidation and ambiguous-deletion handling; the
structured response classifier is an internal compatibility correction
that does not change commands, configuration, supported surfaces, or
operator guidance.
- Agent: Codex Desktop
<!-- docs-review-head-sha: a3d5882 -->
<!-- docs-review-agents-blob-sha:
be20a09 -->

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit:
- Station profile/scenario:
- Result:
- Supporting evidence:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable —
normal hooks passed for the maintainer follow-up commit; the original
exact head passed `npm run check:diff`.
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — 46 focused CLI tests passed for the
current exact head; CLI typecheck, build, source-shape, test-title,
project-membership, and formatting checks passed. The original change
also passed its 88 changed tests and 52 adjacent integration tests.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: Not applicable; the
correction is isolated to the rebuild destroy phase and its focused
tests.
- [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: Carlos Villela <cvillela@nvidia.com>

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

* **Bug Fixes**
* Prevented sandbox deletion when gateway/registry details change during
rebuild preparation by re-checking the delete target right before
execution.
* Improved gateway pinning so the delete targets the intended gateway
even if ambient gateway selection shifts.
* Treated deletion as ambiguous when transport errors block
confirmation, triggering the ambiguous-delete flow rather than “deleted”
handling.
* Expanded handling of structured “sandbox not found” responses for
destructive reconciliation.
* **Tests**
* Added/extended coverage for gateway mismatch scenarios, ambiguous
deletion behavior, and structured absence variants.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: Apurv Kumaria <akumaria@nvidia.com>
@cv cv mentioned this pull request Jul 26, 2026
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression v0.0.96 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(rebuild): --force cannot recover an unreachable sandbox with managed MCP state

3 participants