Skip to content

fix(openclaw): exit devices approve after local fallback - #12178

Merged
rsliter merged 4 commits into
mainfrom
codex/adopt-12109
Sep 22, 2026
Merged

rsliter merged 4 commits into
mainfrom
codex/adopt-12109

Conversation

@rsliter

@rsliter rsliter commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Outcome

openclaw devices approve now exits successfully after its approval output is fully written, including when a failed gateway connection leaves Node handles open. Both human-readable and JSON output paths are covered.

Reason

The local fallback printed Approved and returned without calling defaultRuntime.exit(0). Leftover gateway handles could therefore keep the CLI alive and leave nemoclaw connect waiting indefinitely.

Related issues

Fixes #12064

Adopts the vetted contribution from #12109 onto a same-repository branch so required SDK-backed CI can run. Original contributor attribution is preserved in the commit.

Changes

  • Drain stdout and stderr before forcing a successful exit after device approval.
  • Apply the compatibility patch to fresh and previously patched OpenClaw runtimes.
  • Cover human and JSON output, leftover handles, repeated patching, upgrade repair, and the real-distribution audit marker.
  • Prove the upgrade removes the legacy approval branch rather than merely adding the new branch.

Verification

  • npx vitest run --project integration test/agents/openclaw/openclaw-device-self-approval-patch-upgrade.test.ts test/agents/openclaw/openclaw-device-self-approval-output-exit.test.ts test/agents/openclaw/openclaw-device-self-approval-patch.test.ts (97 tests passed)
  • npm run validate:pr (passed on the exact adoption branch after refreshing canonical main)
  • Diff checked for secrets; none found.

DCO Sign-Off

Signed-off-by: Rebecca Sliter 571084+rsliter@users.noreply.github.com

Summary by CodeRabbit

  • Bug Fixes

    • Device approval now exits cleanly after displaying human-readable or JSON results.
    • Approval output and errors are flushed before the process closes, preventing hangs caused by lingering connections.
    • Compatibility improvements support fresh and previously patched installations while preserving existing approval and authentication behavior.
  • Tests

    • Added coverage for clean process termination, output handling, JSON and human-readable approval flows, and upgrades from older patched versions.

rsliter and others added 2 commits September 21, 2026 11:27
Adopt the vetted contribution from PR #12109 and retain its regression coverage.

Co-authored-by: Cestercian <yashafaid@gmail.com>
Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>
…/adopt-12109

Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>
@rsliter rsliter self-assigned this Sep 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This repository limits you to 10 open pull requests. Please close or merge an existing PR before opening another one.

@github-actions github-actions Bot closed this Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA/NemoClaw/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b5056637-2c66-487c-bd52-86db42279c9e

📥 Commits

Reviewing files that changed from the base of the PR and between ae57eae and 16947cd.

📒 Files selected for processing (2)
  • Dockerfile
  • test/agents/openclaw/openclaw-device-self-approval-output-exit.test.ts

Included review availability: Your plan provides up to 12 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The patch drains approval output streams and exits successfully after OpenClaw device approval. It applies this behavior across patch layouts and upgrades. Tests cover human-readable and JSON output, child-process termination, marker validation, and idempotent upgrades.

Changes

Device approval exit handling

Layer / File(s) Summary
Approval exit patch and integration
scripts/patch-openclaw-device-self-approval.mts
The patch drains stdout and stderr, then exits with status 0 after approval output completes. The behavior applies to JSON and human-readable output, SQLite layouts, standard layouts, and eligible upgrades.
Output and upgrade regression coverage
test/agents/openclaw/*, test/helpers/openclaw-*, Dockerfile
Fixtures provide process streams and approval output. Tests verify flushed output, successful child-process exit, safeguard markers, upgrade behavior, idempotent patching, and patch removal criteria.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: prekshivyas, cv

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files. (1 skipped: 1 … 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 and concisely describes the main change: making openclaw devices approve exit after the local fallback completes.
Linked Issues check ✅ Passed Issue #12064 requires openclaw devices approve to exit with code 0 promptly after approval output. The PR adds stdout and stderr draining, exit handling for human-readable and JSON output, and suppo…
Out of Scope Changes check ✅ Passed The changed patch script, tests, harness updates, distribution audit, proof marker, and Dockerfile criteria directly support issue #12064. They validate or maintain the required approval exit behavior…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 Checkov (3.3.16)
Dockerfile

Checkov output exceeded the maximum buffer for this file


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

@github-code-quality

github-code-quality Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit 16947cd in the codex/adopt-12109 branch remains at 96%, unchanged from commit fe576fd in the main branch.

TypeScript / code-coverage/cli

The overall line coverage in commit 16947cd in the codex/adopt-12109 branch remains at 84%, unchanged from commit 22b01c7 in the main branch.

Show a line coverage summary of the most impacted files.
File main 22b01c7 codex/adopt-12109 16947cd +/-
src/lib/onboard/dashboard.ts 73% 71% -2%
src/lib/actions...dbox/connect.ts 85% 85% 0%
src/lib/onboard...uild-context.ts 73% 73% 0%
src/lib/actions...ter-recovery.ts 86% 87% +1%
src/lib/agent/s...ory-contract.ts 96% 97% +1%
src/lib/security/redact-url.ts 99% 100% +1%
src/lib/onboard...age/contract.ts 95% 98% +3%
src/lib/agent/dashboard-ui.ts 91% 94% +3%
src/lib/adapter.../forward-cli.ts 82% 87% +5%
src/lib/adapter...hell/forward.ts 0% 100% +100%

Updated September 22, 2026 00:03 UTC

@rsliter rsliter reopened this Sep 21, 2026
@rsliter

rsliter commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rsliter
rsliter enabled auto-merge (squash) September 21, 2026 23:06

@prekshivyas prekshivyas 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 exact head ae57eae. I found no blocking runtime defect in this change. I verified the patch against the real OpenClaw 2026.9.1 distribution: the forced exit is inserted immediately after the awaited approvePairingWithFallback result, the patch audit reports 7 OK and 0 missing, and the focused suite passes 97/97 tests. CodeRabbit also reports no actionable comments.

Two follow-ups remain, but I do not consider either proof that the implementation is broken: align the Dockerfile removal criteria with the new exit requirement, and consider extending the subprocess test through the local-fallback producer. I would wait to approve until the repository Advisor blockers and the currently failing growth-guardrail check are cleared.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review Advisor finished for commit 16947cd. Include the Advisor findings in the complete PR feedback collection. Verify and group valid findings before repair.

Request review only when Require no Advisor blockers is green.

All previous runs

@rsliter
rsliter merged commit efea304 into main Sep 22, 2026
105 of 107 checks passed
@rsliter
rsliter deleted the codex/adopt-12109 branch September 22, 2026 00:32
prekshivyas added a commit that referenced this pull request Sep 26, 2026
<!-- markdownlint-disable MD041 -->
## Outcome

OpenClaw device approval no longer hangs after a durable approval, and
uncertain output delivery exits nonzero instead of reporting false
success. The runtime patch now validates its complete installed shape,
including the explicit-admin scope-upgrade behavior.

The OpenClaw 2026.9.1 CLI bootstrap still settles its bounded non-admin
scopes automatically. A same-device local CLI upgrade to
`operator.admin` remains pending for explicit approval. The
managed-image activation gate now captures the exact request ID from
that failed agent turn, approves only that request through `nemoclaw
<sandbox> connect`, retries the normal agent turn, and still requires
`PONG`.

## Reason

PR #12178 fixed the reported approval hang, but follow-up E2E and
automated review exposed several adjacent defects: direct approval
retained handles, delayed exit regressed onboarding, stalled or failed
stream callbacks could hide uncertain delivery, marker-only validation
could accept damaged patches, the operational snapshot read a retired
JSON identity, malformed pairing records could look settled, and
OpenClaw silently approved the later CLI admin upgrade.

Exact-head managed-image run `35722871242` then showed that the repaired
authorization boundary invalidated the general activation gate's old
assumption. Both Docker and rootless Podman reached OpenClaw and
correctly stopped at `scope upgrade pending approval`; direct managed
startup and cleanup passed. This was a candidate-caused test-contract
failure, not a runner or platform flake.

### Related issues

Refs #12064

Follow-up to #12178.

## Changes

- Validate exactly one approval-exit marker and the complete expected
handler before accepting an installed patch.
- Exit `0` only after both output callbacks confirm delivery; exit `1`
on callback error, synchronous write failure, or the referenced
one-second timeout.
- Migrate the previously shipped unbounded and prior scope-upgrade
patches, reject unknown or structurally changed shapes, and prove
reapplication is byte-for-byte idempotent.
- Keep bounded non-admin CLI bootstrap settlement automatic while
routing the closed same-device `operator.admin` upgrade through explicit
approval.
- Read canonical OpenClaw SQLite pairing state through the reviewed
adapter, reject malformed records, and keep sensitive values out of
diagnostics.
- Make the managed activation gate prove the pending-admin outcome, bind
approval to the single UUID emitted by that failed turn, approve it
through the existing operator connect boundary, and retry the
user-facing agent command.
- Preserve the existing focused issue #4462 approval flow while teaching
its strict selector to use canonical SQLite identity state.

## Verification

- Focused OpenClaw patch tests passed on
`82a21f121711e26872f2a33aed2823720e95591b`: 15 tests across the
current-layout and migration suites.
- Focused E2E-support tests passed: 27 tests across the approval
fixture, canonical snapshot, and managed activation diagnostics suites.
- `npm run test:changed` passed: the 7-test growth-guardrail lane and 27
selected E2E-support tests passed.
- `npm run e2e:assertions:check` passed without increasing the live E2E
assertion budget.
- `npm run validate:pr`, commit hooks, and pre-push validation passed,
including repository checks, source-shape budgets, publication
validation, builds, and CLI TypeScript checks.
- GitHub marks `82a21f121711e26872f2a33aed2823720e95591b` as Verified.
- The 11-file diff from `main` contains no secrets, API keys, or
credentials.
- Focused E2E run `35686303357` on prior commit
`e9028a90d745a9a32ff5bf457498d31f6697a052` proved delayed exit regressed
direct approval; bindings were exact and cleanup completed.
- Focused E2E run `35708085195` on
`b1a526bac125f7a98dfb5015db935459de7a36be` exposed the stale JSON-only
identity probe; bindings were exact and cleanup completed.
- Focused E2E run `35718399558` on
`a7372929b2a2cc3ebcd0fb39a85ce91f638c3cef` exposed silent CLI admin
elevation; bindings were exact and cleanup completed.
- Managed-image run `35722871242` on
`59cdf7cd44802eec83adeec6601ce7ed85480481` published the exact
candidate, passed direct startup, and failed both exact activation jobs
at the newly required explicit-admin boundary with complete cleanup.

## Review notes

Sensitive paths: `scripts/patch-openclaw-device-self-approval.mts` and
the OpenClaw managed activation approval gate.

CodeRabbit's exact-shape, observable-outcome, and idempotence findings
on `59cdf7cd44802eec83adeec6601ce7ed85480481` are addressed in
`82a21f121711e26872f2a33aed2823720e95591b`. Exact-head source CI run
`35729243783` and managed-image publication run `35729243593` are
pending. CodeRabbit, all PR Review Advisor specialists, and the focused
manual E2E target `issue-4462-scope-upgrade-approval` must be clear for
this unchanged commit before the draft is ready.

---
Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>


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

- **Bug Fixes**
- Improved device approval handling for output-drain failures, stalled
output, and premature exits.
- Preserved safe, repeatable approval-flow updates and rejected
incomplete or structurally invalid updates.
- Expanded eligible administrator-scope approvals while retaining
safeguards for other requests.
- Strengthened pairing-state validation so malformed or incomplete
records fail clearly.
- Added clearer administrator-approval failure diagnostics while
protecting sensitive data from output.

- **Tests**
- Expanded end-to-end coverage for approvals, pairing state, request
validation, and secret redaction.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>
Signed-off-by: Rebecca Sliter <rsliter@nvidia.com>
Co-authored-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>
Co-authored-by: Prekshi Vyas <prekshiv@nvidia.com>
@wscurran wscurran added area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: integrations Third-party service integration behavior bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ubuntu 24.04][Agent&Skills] openclaw devices approve hangs after printing Approved on local fallback path

3 participants