Skip to content

fix(inference): diagnose blocked llama.cpp bridge - #8716

Merged
cv merged 3 commits into
mainfrom
codex/fix-ufw-llama-cpp-bridge
Aug 10, 2026
Merged

fix(inference): diagnose blocked llama.cpp bridge#8716
cv merged 3 commits into
mainfrom
codex/fix-ufw-llama-cpp-bridge

Conversation

@senthilr-nv

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

Copy link
Copy Markdown
Collaborator

Summary

Managed llama.cpp onboarding now distinguishes an OpenShell Docker bridge connection failure from a healthy internal runtime and host-loopback path. It stops without changing UFW and reports the validated bridge network, subnet, gateway IP address, fixed port, and narrow operator command.

Related Issue

Fixes #8712

Changes

  • Treat curl connection refusal and timeout from the authoritative openshell-docker bridge probe as the firewall-diagnosis case only after the host-loopback probe passes.
  • Validate the inspected subnet, gateway IP address, and port before including topology or a UFW command in the error.
  • Keep Docker execution failures and invalid topology on the existing generic failure path.
  • Use the invoked OpenClaw, Hermes, or Deep Agents CLI name in the recovery command.
  • Document the least-privilege UFW action, verification retry, and exact-rule removal procedure.
  • Cover resume-time bridge refusal while preserving the receipt-bound runtime, journal, and network for retry.
  • Move the shared Docker engine fixture into test support so the expanded lifecycle regression suite remains below the repository test-file size limit.

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: independent Codex Desktop review passed all nine security categories; the maintainer accepted the issue scope before implementation.
  • 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: docs-updated
  • Evidence: docs/inference/set-up-llama-cpp.mdx
  • Agent: Codex Desktop

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 — the complete equivalent ran from a clean worktree against refreshed upstream/main because this maintainer checkout uses origin for a fork; pre-commit, commitlint, and pre-push passed. The normal pre-push hook also passed during the upstream push.
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — 101 focused CLI tests passed before publication; 56 focused CLI tests passed again after automated review feedback.
  • Applicable broad gate passed — not applicable; this is a focused managed lifecycle diagnosis, formatter, documentation, and test-support extraction.
  • 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 build passed with 0 errors and the 2 pre-existing Fern warnings.
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Additional checks:

  • npm run typecheck:cli: passed.
  • npm run test-size:check: passed.
  • npm run docs: rendered the OpenClaw, Hermes, and Deep Agents variants with 0 errors.

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved managed llama.cpp onboarding diagnostics for OpenShell bridge connectivity and timeout failures.
    • Added private host-bridge verification using runtime status, route reachability, and health checks.
    • Prevented automatic UFW changes when connectivity checks fail.
    • Rejected unvalidated bridge network configurations.
    • Recovery instructions now use the CLI name invoked by the user.
  • Documentation

    • Added guidance for readiness checks, narrowly scoped firewall remediation, rollback, retry, and removal procedures.

Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
@senthilr-nv senthilr-nv self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Managed llama.cpp onboarding now checks host and OpenShell bridge reachability. Connectivity failures report validated network details and a narrow UFW command. Shared Docker fixtures and tests cover success, cleanup, invalid topology, resume behavior, and branded recovery instructions.

Changes

Managed llama.cpp bridge reachability

Layer / File(s) Summary
Bridge topology and remediation handling
src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts, src/lib/onboard/ufw-auto-apply.ts
The lifecycle retains the OpenShell bridge subnet, classifies connectivity-specific curl failures, validates UFW operands, and reports the network, subnet, gateway, and port.
Shared Docker fixture and lifecycle validation
src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle-engine.test-support.ts, src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.test.ts
Tests use a shared Docker fixture and cover bridge probing, connection and timeout failures, cleanup, resume behavior, Docker probe failures, and invalid subnet data.
Branded recovery guidance
src/lib/onboard/host-service-reachability.ts, src/lib/onboard/host-service-reachability.test.ts, docs/inference/set-up-llama-cpp.mdx
Recovery instructions use the invoked CLI name. Documentation describes private bridge verification, the narrow UFW rule, retry procedure, and rule removal.

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

Sequence Diagram(s)

sequenceDiagram
  participant Lifecycle as docker-llama-cpp-managed-lifecycle
  participant Bridge as OpenShell Docker network
  participant Host as managed llama.cpp host service
  participant Firewall as UFW
  Lifecycle->>Bridge: Probe gateway host and health endpoint
  Bridge->>Host: Forward request to managed port
  Host-->>Bridge: Return health response or connectivity failure
  Lifecycle->>Firewall: Validate subnet, gateway, and port operands
  Lifecycle-->>Lifecycle: Report remediation or standard probe failure
Loading

Possibly related PRs

Suggested labels: area: inference, area: onboarding, area: networking, bug-fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #8712 by diagnosing bridge blocks, validating topology, limiting UFW remediation, preserving failure handling, and adding focused tests and documentation.
Out of Scope Changes check ✅ Passed The fixture refactor, CLI-name handling, UFW export, tests, and documentation directly support the linked issue objectives.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: diagnosing blocked llama.cpp bridge connectivity during inference setup.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-ufw-llama-cpp-bridge

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 Aug 10, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 9a679bc in the codex/fix-ufw-llama-... branch remains at 96%, unchanged from commit bf81b95 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 9a679bc in the codex/fix-ufw-llama-... branch remains at 82%, unchanged from commit bf81b95 in the main branch.

Show a code coverage summary of the most impacted files.
File main bf81b95 codex/fix-ufw-llama-... 9a679bc +/-
src/lib/actions...ld-mcp-phase.ts 98% 87% -11%
src/lib/onboard...der/snapshot.ts 83% 75% -8%
src/lib/agent/dashboard-ui.ts 98% 91% -7%
src/lib/onboard...press-resume.ts 81% 78% -3%
src/lib/state/registry.ts 89% 87% -2%
src/lib/onboard...ed-lifecycle.ts 77% 76% -1%
src/lib/state/o...d-checkpoint.ts 85% 88% +3%
src/lib/agent/defs.ts 92% 95% +3%
src/lib/onboard...reachability.ts 63% 82% +19%
src/lib/onboard...test-support.ts 0% 95% +95%

Updated August 10, 2026 09:45 UTC

@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: 2

🧹 Nitpick comments (3)
src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts (1)

1045-1077: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the bridge failure classification into a helper.

probePrivateBridge now performs wiring, two probes, failure classification, and message assembly. The added block raises the function's cognitive complexity. Move the classification and message construction into a small local function, for example bridgeProbeFailure(gateway, port, probe), that returns an Error or undefined. The probe flow then stays linear.

The behavior is correct as written. This is a readability change only.

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

In `@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts`
around lines 1045 - 1077, Extract the conditional bridge failure classification
and remediation message construction from probePrivateBridge into a local helper
such as bridgeProbeFailure(gateway, port, probe) that returns Error or
undefined. Replace the inline block with a call to this helper while preserving
the existing throw behavior and requireSuccess flow unchanged.

Source: Coding guidelines

src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle-engine.test-support.ts (1)

184-199: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Make the bridge gateway configurable with the subnet.

The fixture hardcodes Gateway: "172.29.0.1" at Line 194 but exposes setOpenShellBridgeSubnet. A test that sets a subnet outside 172.29.0.0/16 produces a gateway that is outside the subnet. validateUfwRuleOperands then rejects the pair for the "gateway outside subnet" reason, not the reason the test intends. Add a matching setOpenShellBridgeGateway setter so each scenario controls both operands.

The current tests still pass, because 0.0.0.0/0 fails the prefix check first.

Also applies to: 364-364

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

In
`@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle-engine.test-support.ts`
around lines 184 - 199, Make the mocked bridge gateway configurable alongside
openShellBridgeSubnet in the test-support fixture. Add an openShellBridgeGateway
state value and setOpenShellBridgeGateway setter, then use that value instead of
the hardcoded gateway in the openshell-docker response; update scenarios as
needed so tests can control both operands.
src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.test.ts (1)

500-504: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the redundant assertions after the exact-match assertion.

Line 500 asserts the full message with toBe. Lines 503-504 then assert that the same string does not contain sudo ufw or 0.0.0.0/0. The exact match already proves both. Keep either the exact match or the two negative assertions.

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

In `@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.test.ts`
around lines 500 - 504, In the failure-message assertions for the Docker
llama.cpp private sandbox bridge probe test, remove the redundant negative
contains checks for “sudo ufw” and “0.0.0.0/0” after the exact toBe assertion,
keeping the exact message assertion as the sole validation.
🤖 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 `@docs/inference/set-up-llama-cpp.mdx`:
- Around line 168-178: Update the managed-installation documentation around the
authoritative OpenShell Docker bridge probe to state that the detailed error,
including the exact narrow UFW command and topology values, appears only when
the bridge topology passes validateUfwRuleOperands; otherwise onboarding emits
the generic probe error without network details or a command.

In `@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.test.ts`:
- Around line 476-486: Update the test around createLifecycle(...).start(...) to
assert that the thrown error message does not contain the UFW remediation text,
rather than inspecting fixture.capture Docker arguments for "ufw". Keep the
existing probe-failure error assertion and verify the lifecycle’s reported
remediation message directly.

---

Nitpick comments:
In
`@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle-engine.test-support.ts`:
- Around line 184-199: Make the mocked bridge gateway configurable alongside
openShellBridgeSubnet in the test-support fixture. Add an openShellBridgeGateway
state value and setOpenShellBridgeGateway setter, then use that value instead of
the hardcoded gateway in the openshell-docker response; update scenarios as
needed so tests can control both operands.

In `@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.test.ts`:
- Around line 500-504: In the failure-message assertions for the Docker
llama.cpp private sandbox bridge probe test, remove the redundant negative
contains checks for “sudo ufw” and “0.0.0.0/0” after the exact toBe assertion,
keeping the exact message assertion as the sole validation.

In `@src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts`:
- Around line 1045-1077: Extract the conditional bridge failure classification
and remediation message construction from probePrivateBridge into a local helper
such as bridgeProbeFailure(gateway, port, probe) that returns Error or
undefined. Replace the inline block with a call to this helper while preserving
the existing throw behavior and requireSuccess flow unchanged.
🪄 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: d80c83aa-d381-490d-913f-5eb67f270a9b

📥 Commits

Reviewing files that changed from the base of the PR and between f4b1e01 and 5e4aac0.

📒 Files selected for processing (7)
  • docs/inference/set-up-llama-cpp.mdx
  • src/lib/onboard/host-service-reachability.test.ts
  • src/lib/onboard/host-service-reachability.ts
  • src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle-engine.test-support.ts
  • src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.test.ts
  • src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts
  • src/lib/onboard/ufw-auto-apply.ts

Comment thread docs/inference/set-up-llama-cpp.mdx
@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): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings match; normalized terminology decisions differ; normalized E2E selections match; severity counts match.
2 terminology differences from the second opinion

Advisory only. These are normalized differences from the primary terminology receipt.

  • private host bridge at docs/inference/set-up-llama-cpp.mdx:138: primary classified it as justified; the second opinion classified it as define.
  • host-loopback health check at src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts:1067: primary classified it as justified; the second opinion classified it as define.

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

3 semantic terminology decisions

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

  • justified — private host bridge at docs/inference/set-up-llama-cpp.mdx:138: Keep the modifier because it identifies the restricted host-to-container exposure.
  • established — OpenShell Docker bridge at docs/inference/set-up-llama-cpp.mdx:168: Keep the established repository term.
  • justified — host-loopback health check at src/lib/onboard/runtime-provider/docker-llama-cpp-managed-lifecycle.ts:1067: Keep the modifier because it identifies the condition required before UFW remediation is reported.

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

1 optional E2E recommendation
  • llama-cpp-dgx-spark-qualification

Workflow run details

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

Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
@cv
cv merged commit dfef83e into main Aug 10, 2026
97 checks passed
@cv
cv deleted the codex/fix-ufw-llama-cpp-bridge branch August 10, 2026 10:59
@github-actions github-actions Bot added the v0.0.106 Release target label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v0.0.106 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(inference): handle UFW-blocked managed llama.cpp bridge traffic

2 participants