Skip to content

fix(e2e): repair managed image gateway cleanup - #8763

Closed
apurvvkumaria wants to merge 3 commits into
mainfrom
codex/fix-8759-managed-image-cleanup
Closed

fix(e2e): repair managed image gateway cleanup#8763
apurvvkumaria wants to merge 3 commits into
mainfrom
codex/fix-8759-managed-image-cleanup

Conversation

@apurvvkumaria

@apurvvkumaria apurvvkumaria commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Repair the protected managed-image qualification after Ollama readiness by exposing and validating the onboarding hooks consumed by the harness. Cleanup now yields while reaping the owned gateway and verifies that both its process and configured listener are gone.

Related Issue

Fixes #8759

Changes

  • Export the existing onboarding-scoped runOpenshell and sleepSeconds hooks required by the protected harness.
  • Validate every dynamically imported onboarding hook and report missing callable hooks precisely.
  • Replace blocking gateway cleanup polling with event-loop-yielding waits and verify loopback listener release.
  • Add a focused contract and real child-listener cleanup regression.

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 change is limited to the protected managed-image CI/E2E harness and does not alter documented CLI, configuration, onboarding, inference, or runtime 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: Agent review confirmed the change only exports existing onboarding helpers and hardens the isolated test harness contract and owned-process cleanup; no production security boundary or runtime behavior changes.
  • 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: No documentation paths changed; the repair affects only the internal protected managed-image CI/E2E harness.
  • Agent: Codex Desktop documentation writer subagent

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

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 — command/result or justification: npx vitest run --project integration test/managed-image-protected-runtime-contract.test.ts (24 passed); npm run typecheck:cli passed.
  • 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; this is a narrow harness contract and cleanup fix with focused regression coverage.
  • 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: Apurv Kumaria akumaria@nvidia.com

Summary by CodeRabbit

  • Bug Fixes

    • Improved managed-image onboarding compatibility by supporting default exports and validating required runtime hooks.
    • Improved gateway shutdown reliability, ensuring processes exit and network ports are released correctly.
    • Added clearer handling when a requested gateway port is unavailable.
    • Replaced blocking shutdown behavior with asynchronous cleanup for smoother operation.
  • Tests

    • Added coverage for onboarding module validation and gateway cleanup, including process termination and listener release.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria apurvvkumaria self-assigned this Aug 10, 2026
@copy-pr-bot

copy-pr-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The managed-image E2E flow validates required onboarding hooks, supports default exports, and exports the OpenShell helpers. Gateway cleanup now yields during shutdown, verifies process and listener termination, and includes focused contract and lifecycle tests.

Changes

Managed-image OpenShell runtime

Layer / File(s) Summary
Onboard module contract and loading
scripts/checks/run-managed-image-openshell-e2e.ts, src/lib/onboard.ts
The loader validates five callable onboarding hooks and supports direct or default module exports. runOpenshell and sleepSeconds are exported.
Asynchronous gateway cleanup
scripts/checks/run-managed-image-openshell-e2e.ts
Gateway termination uses asynchronous polling, accepts an explicit port, verifies listener release, and records process or port cleanup failures.
Contract and cleanup regression tests
test/managed-image-protected-runtime-contract.test.ts
Tests validate the runOpenshell contract and confirm that gateway shutdown reaps the child process and releases the TCP port.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: ericksoa

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the managed-image E2E gateway cleanup repair, which is a primary change in the pull request.
Linked Issues check ✅ Passed The changes expose and validate onboarding hooks, improve gateway cleanup, add focused regression tests, and satisfy the linked issue objectives [#8759].
Out of Scope Changes check ✅ Passed The changes are limited to the harness, onboarding exports, and focused contract and cleanup tests required by the linked issue [#8759].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/fix-8759-managed-image-cleanup

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

@github-code-quality

github-code-quality Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit fd486b8 in the codex/fix-8759-manag... branch remains at 96%, unchanged from commit 567a033 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit fd486b8 in the codex/fix-8759-manag... branch remains at 82%, unchanged from commit 567a033 in the main branch.

Show a code coverage summary of the most impacted files.
File main 567a033 codex/fix-8759-manag... fd486b8 +/-
src/lib/messagi...annel-config.ts 99% 95% -4%
src/lib/sandbox...rce-identity.ts 86% 86% 0%
src/lib/core/bo...e-transcript.ts 93% 97% +4%

Updated August 10, 2026 22:34 UTC

@github-actions

github-actions Bot commented Aug 10, 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): Failed after a partial review · low confidence · 0 blockers · 1 warning · 0 suggestions

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

1 semantic terminology decision

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

  • established — harness at scripts/checks/run-managed-image-openshell-e2e.ts:144: Retain “harness” for the E2E test component.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite against this exact revision.

Recommended E2E: managed-image-multiarch-startup, managed-image-protected-runtime, 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.

@apurvvkumaria
apurvvkumaria marked this pull request as ready for review August 10, 2026 21:39

@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)
scripts/checks/run-managed-image-openshell-e2e.ts (1)

299-319: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Prove gateway ownership before sending signals.

stopProcess checks only whether the PID exists. A reused PID can terminate an unrelated process. The port probe cannot identify the process that received the signal.

Route cleanup through the existing scoped ownership checks in src/lib/onboard/host-gateway-process.ts, or apply equivalent PID-file, runtime-marker, namespace, and command-line checks before each signal. If ownership is not proven, skip signaling and report cleanup failure. Add a decoy-process test in test/managed-image-protected-runtime-contract.test.ts.

🤖 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 `@scripts/checks/run-managed-image-openshell-e2e.ts` around lines 299 - 319,
Update stopProcess in scripts/checks/run-managed-image-openshell-e2e.ts to prove
gateway ownership using the scoped checks from
src/lib/onboard/host-gateway-process.ts, or equivalent PID-file, runtime-marker,
namespace, and command-line validation before every signal; skip signaling and
report cleanup failure when ownership is unproven. Add a decoy-process test
covering PID reuse in test/managed-image-protected-runtime-contract.test.ts
lines 46-84.

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 `@scripts/checks/run-managed-image-openshell-e2e.ts`:
- Around line 299-319: Update stopProcess in
scripts/checks/run-managed-image-openshell-e2e.ts to prove gateway ownership
using the scoped checks from src/lib/onboard/host-gateway-process.ts, or
equivalent PID-file, runtime-marker, namespace, and command-line validation
before every signal; skip signaling and report cleanup failure when ownership is
unproven. Add a decoy-process test covering PID reuse in
test/managed-image-protected-runtime-contract.test.ts lines 46-84.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ae0ba23d-7d12-4818-8c5e-2f54e1809522

📥 Commits

Reviewing files that changed from the base of the PR and between f817ad6 and 6fef6e5.

📒 Files selected for processing (3)
  • scripts/checks/run-managed-image-openshell-e2e.ts
  • src/lib/onboard.ts
  • test/managed-image-protected-runtime-contract.test.ts

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/checks/run-managed-image-openshell-e2e.ts (1)

134-145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the onboard hook inventory canonical.

OnboardModule declares five required hooks, and Line 145 repeats the same inventory. A future change can update one list and leave the validator out of sync. Define one runtime hook map and add a compile-time completeness check. Add a valid direct-export fixture beside the existing default-export contract test.

As per path instructions: “Derive inventories and limits from a canonical source where possible” and “Require focused tests for both detection and false-positive behavior.”

🤖 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 `@scripts/checks/run-managed-image-openshell-e2e.ts` around lines 134 - 145,
Make the required-hook inventory canonical for OnboardModule by defining one
runtime hook map whose keys are compile-time checked against all five
OnboardModule hooks, then reuse it in resolveManagedImageOnboardModule instead
of repeating the string list. Add a valid direct-export fixture alongside the
existing default-export contract test, covering both missing-hook detection and
acceptance of valid exports without false positives.

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.

Inline comments:
In `@scripts/checks/run-managed-image-openshell-e2e.ts`:
- Line 143: Update the candidate selection in the onboard-module loading logic
to use optional chaining on value before accessing default, then retain the
existing validation that checks whether the selected candidate is callable and
emits the intended missing-hook error. Ensure null or undefined inputs reach
that validation instead of causing a native TypeError.

---

Nitpick comments:
In `@scripts/checks/run-managed-image-openshell-e2e.ts`:
- Around line 134-145: Make the required-hook inventory canonical for
OnboardModule by defining one runtime hook map whose keys are compile-time
checked against all five OnboardModule hooks, then reuse it in
resolveManagedImageOnboardModule instead of repeating the string list. Add a
valid direct-export fixture alongside the existing default-export contract test,
covering both missing-hook detection and acceptance of valid exports without
false positives.
🪄 Autofix

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: e58188b1-0b33-4a6f-a2fa-b655fe0baa5e

📥 Commits

Reviewing files that changed from the base of the PR and between 6fef6e5 and 2cd4649.

📒 Files selected for processing (3)
  • scripts/checks/run-managed-image-openshell-e2e.ts
  • src/lib/onboard.ts
  • test/managed-image-protected-runtime-contract.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/managed-image-protected-runtime-contract.test.ts
  • src/lib/onboard.ts

Comment thread scripts/checks/run-managed-image-openshell-e2e.ts Outdated
@copy-pr-bot

copy-pr-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@senthilr-nv

Copy link
Copy Markdown
Collaborator

Closing as superseded by #8762, which merged the complete #8759 repair. After refreshing from main, this PR’s only remaining diff is a cosmetic biome-ignore comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protected managed-image runtime stops after Ollama on missing runOpenshell hook

3 participants