Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6cb112b
fix(onboard): require OpenClaw CLI pairing before completion
rsliter Aug 21, 2026
3234a4d
fix(onboard): fence OpenClaw pairing settlement
rsliter Aug 21, 2026
6a49e6c
fix(onboard): harden pairing failure handling
rsliter Aug 21, 2026
e0f659d
fix(onboard): close pairing readiness review gaps
rsliter Aug 21, 2026
77eee08
fix(onboard): preserve convergence with malformed requests
rsliter Aug 21, 2026
3c51826
Merge branch 'main' into codex/fix-9844-openclaw-pairing-readiness
rsliter Aug 21, 2026
28e8f2a
fix(onboard): skip pairing gate during rebuild handoff
rsliter Aug 21, 2026
e25a36d
fix(rebuild): wait for OpenClaw doctor completion
rsliter Aug 21, 2026
b0acddd
fix(onboard): drop shared auth during pairing settlement
rsliter Aug 21, 2026
3f51a64
test(e2e): preserve cleanup on onboarding failure
rsliter Aug 21, 2026
53792f7
fix(openclaw): authenticate pairing settlement list
rsliter Aug 21, 2026
1fcbde9
merge: refresh main
rsliter Aug 21, 2026
a7f3e9a
Merge remote-tracking branch 'origin/main' into codex/fix-9844-opencl…
rsliter Aug 21, 2026
44f1b1a
fix(onboard): allow pairing after policy skip
rsliter Aug 21, 2026
b8cb4af
fix(onboard): use pairing auth for warm-up polling
rsliter Aug 21, 2026
afbb5dc
fix(onboard): authenticate pairing warm-up poll
rsliter Aug 21, 2026
df716bc
merge: reconcile pairing E2E repair
rsliter Aug 21, 2026
156e0d8
merge: resolve conflicts with main
github-actions[bot] Aug 21, 2026
6e8ada5
fix(rebuild): preserve doctor timeout after merge
rsliter Aug 22, 2026
04032b6
merge(main): refresh pairing readiness base
rsliter Aug 22, 2026
f757690
fix(onboard): reuse lifecycle lock facade
rsliter Aug 22, 2026
0110595
fix(onboard): avoid inference during pairing warmup
rsliter Aug 22, 2026
05b10e1
Merge remote-tracking branch 'origin/main' into codex/9847-e2e-repair
rsliter Aug 22, 2026
dab1c5e
fix(onboard): reserve pairing settlement budgets
rsliter Aug 22, 2026
f89557e
merge(onboard): combine pairing settlement repairs
rsliter Aug 22, 2026
f158d64
merge(main): refresh pairing readiness base
rsliter Aug 22, 2026
fb68f0f
merge(main): refresh pairing readiness base
rsliter Aug 22, 2026
952a367
test(onboard): name pairing appearance deadline
rsliter Aug 22, 2026
2190ce5
Merge remote-tracking branch 'origin/main' into codex/9847-e2e-repair
rsliter Aug 22, 2026
c236cc2
docs(onboard): clarify pairing phase budgets
rsliter Aug 22, 2026
c5d0e55
fix(openclaw): synchronize self-approval credential state
rsliter Aug 22, 2026
ed69823
merge(main): refresh PR branch
rsliter Aug 22, 2026
066cdf5
fix(openclaw): validate self-approval auth scopes
rsliter Aug 22, 2026
881524a
merge(main): refresh OpenClaw credential hardening
rsliter Aug 22, 2026
abd8b41
merge(main): refresh OpenClaw credential hardening
rsliter Aug 22, 2026
5d3aa00
fix(ci): complete pairing readiness validation
jyaunches Aug 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/get-started/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Review the [Prerequisites](prerequisites) before you begin.

<Step title="Confirm the Sandbox Is Ready">
Wait for the ready summary, then check the sandbox state.
Before it prints this summary, default-profile OpenClaw onboarding waits for exactly one matching local CLI operator device.
It verifies the required baseline scopes and confirms that no pairing request for the same device remains pending.
If this bounded readiness check does not settle, NemoClaw keeps onboarding resumable and tells you to resume or rerun onboarding.

```bash
nemoclaw my-assistant status
Expand Down
72 changes: 67 additions & 5 deletions scripts/nemoclaw-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2619,10 +2619,18 @@ import os
import re
import stat
import subprocess
import sys
import time

print('[auto-pair] watcher started', flush=True)


def report_unhandled_watcher_exception(exc_type, _exc_value, _traceback):
print(f'[auto-pair] stage=watcher-execution failed error={exc_type.__name__}', flush=True)


sys.excepthook = report_unhandled_watcher_exception

APPROVAL_POLICY_FILE = '/usr/local/lib/nemoclaw/openclaw_device_approval_policy.py'


Expand Down Expand Up @@ -2722,6 +2730,10 @@ QUIET_POLLS = 0
APPROVED = 0
SLOW_MODE = False
HANDLED = set() # Track rejected/approved requestIds to avoid reprocessing
OBSERVED_REQUEST_IDS = set()
VALIDATED_REQUEST_IDS = set()
LAST_LIST_FAILURE_REASON = None
REQUEST_CREATION_WAITING_REPORTED = False
PAIRING_BOOTSTRAPPED = False
# SECURITY NOTE: clientId/clientMode are client-supplied and spoofable
# (the gateway stores connectParams.client.id verbatim). The policy requires
Expand Down Expand Up @@ -2934,6 +2946,31 @@ def brief_child_error(out, err):
lines = [line.strip() for line in f'{err}\n{out}'.splitlines() if line.strip()]
return (lines[-1] if lines else '')[:400]


def report_request_observed(request_id):
if request_id in OBSERVED_REQUEST_IDS:
return
OBSERVED_REQUEST_IDS.add(request_id)
print(f'[auto-pair] stage=request-creation observed request={request_id}')


def report_request_validation(request_id, accepted, reason):
if request_id in VALIDATED_REQUEST_IDS:
return
VALIDATED_REQUEST_IDS.add(request_id)
outcome = 'accepted' if accepted else 'rejected'
print(f'[auto-pair] stage=validation {outcome} request={request_id} reason={reason}')


def list_failure_reason(rc, out, err):
if rc == 124:
return 'timeout'
if is_pairing_required_list_failure(out, err):
return 'pairing-required'
if rc != 0:
return 'command-failed'
return 'empty-output'

# Workaround boundary (NemoClaw#4462): the watcher child sources the trusted
# runtime environment, so its first list call resolves the live gateway through
# local loopback and retains the shared token plus a private child marker. The
Expand Down Expand Up @@ -3009,12 +3046,23 @@ while time.time() < DEADLINE:
force_device_pairing=not PAIRING_BOOTSTRAPPED,
)
if rc != 0 or not out:
failure_reason = list_failure_reason(rc, out, err)
if failure_reason != LAST_LIST_FAILURE_REASON:
print(f'[auto-pair] stage=listing failed reason={failure_reason}')
LAST_LIST_FAILURE_REASON = failure_reason
initial_request_id = pairing_required_request_id(out, err)
if (
initial_request_id
and initial_request_id not in HANDLED
and initial_cli_request_is_allowlisted(initial_request_id)
):
if initial_request_id and initial_request_id not in HANDLED:
report_request_observed(initial_request_id)
initial_request_allowed = initial_cli_request_is_allowlisted(initial_request_id)
report_request_validation(
initial_request_id,
initial_request_allowed,
'allowlisted-initial-cli' if initial_request_allowed else 'not-allowlisted',
)
else:
initial_request_allowed = False
if initial_request_id and initial_request_id not in HANDLED and initial_request_allowed:
print(f'[auto-pair] stage=approval attempting request={initial_request_id}')
arc, aout, aerr = run(
OPENCLAW, 'devices', 'approve', initial_request_id, '--json', strip_gateway_env=True,
)
Expand All @@ -3036,13 +3084,21 @@ while time.time() < DEADLINE:
try:
data = json.loads(out)
except Exception:
if LAST_LIST_FAILURE_REASON != 'invalid-json':
print('[auto-pair] stage=listing failed reason=invalid-json')
LAST_LIST_FAILURE_REASON = 'invalid-json'
sleep_for_next_poll(SLOW_INTERVAL if SLOW_MODE else 1, productive=False)
continue
LAST_LIST_FAILURE_REASON = None

pending = data.get('pending') or []
paired = data.get('paired') or []
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
has_browser = any((d.get('clientId') == 'openclaw-control-ui') or (d.get('clientMode') == 'webchat') for d in paired if isinstance(d, dict))

if not pending and not paired and APPROVED == 0 and not REQUEST_CREATION_WAITING_REPORTED:
print('[auto-pair] stage=request-creation waiting reason=no-request')
REQUEST_CREATION_WAITING_REPORTED = True
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

if pending:
QUIET_POLLS = 0
attempted_request_ids = set()
Expand All @@ -3056,23 +3112,29 @@ while time.time() < DEADLINE:
pending_request_ids.add(request_id)
if request_id in HANDLED:
continue
report_request_observed(request_id)
decision = approval_request_decision(device)
client_id = decision['client_id']
client_mode = decision['client_mode']
if decision['reason'] == 'unknown-client':
HANDLED.add(request_id)
report_request_validation(request_id, False, 'unknown-client')
print(f'[auto-pair] rejected unknown client={client_id} mode={client_mode}')
continue
if decision['reason'] == 'malformed-scopes':
HANDLED.add(request_id)
report_request_validation(request_id, False, 'malformed-scopes')
print(f'[auto-pair] rejected malformed scopes client={client_id} mode={client_mode}')
continue
if decision['reason'] == 'disallowed-scopes':
HANDLED.add(request_id)
scopes = decision['scopes']
report_request_validation(request_id, False, 'disallowed-scopes')
print(f'[auto-pair] rejected disallowed scopes={sorted(scopes)} client={client_id} mode={client_mode}')
continue
report_request_validation(request_id, True, 'allowlisted-request')
attempted_request_ids.add(request_id)
print(f'[auto-pair] stage=approval attempting request={request_id}')
arc, aout, aerr = run(
OPENCLAW, 'devices', 'approve', request_id, '--json', strip_gateway_env=True,
)
Expand Down
15 changes: 7 additions & 8 deletions src/lib/actions/sandbox/auto-pair-warmup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
* immediately after) then approves it, so `operator.write` is persisted before
* handoff and the user's first run connects clean.
*
* Contract: best-effort, non-blocking, idempotent. The warm-up run will itself
* fall back to embedded mode on this first invocation (EXIT 0) — that is
* expected; its output is discarded. Any failure (exec timeout, gateway not up,
* agent error) is swallowed so finalization is never blocked; behavior then
* degrades to the v1 first-run-falls-back-then-recover path, strictly no worse
* than today. On re-onboard where `operator.write` is already paired the run
* Contract: best-effort, bounded, idempotent. The warm-up run will itself
* fall back to embedded mode on this first invocation (EXIT 0). That is
* expected, and its output is discarded. The leaf swallows execution failures, and
* onboarding separately observes the canonical pairing state before it reports
* success. On re-onboard where `operator.write` is already paired the run
* connects clean (no new pending) and the approval pass is a no-op.
*
* Workaround boundary (NemoClaw#4462): OpenClaw owns device-pairing semantics
Expand Down Expand Up @@ -180,8 +179,8 @@ function runSandboxWarmupScript(sandboxName: string, script: string): void {
/**
* Run the bounded, throwaway scope-upgrade warm-up inside the named sandbox via
* `openshell sandbox exec`. All failure modes (timeout, sandbox-exec errors,
* missing openclaw, gateway unreachable) are swallowed: this is best-effort and
* must never throw — onboard finalization must not be blocked.
* missing openclaw, gateway unreachable) are swallowed. The finalization
* settlement gate decides readiness from a later canonical observation.
*/
export function runSandboxScopeWarmupRun(sandboxName: string): void {
runSandboxWarmupScript(sandboxName, WARMUP_SCRIPT);
Expand Down
82 changes: 82 additions & 0 deletions src/lib/actions/sandbox/launch-readiness-ordinary-pairing.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it, vi } from "vitest";

import { loadAgent } from "../../agent/defs";
import type { SandboxEntry } from "../../state/registry";
import { type LaunchReadinessDeps, resolveOrdinaryOpenClawPairingTarget } from "./launch-readiness";

const SANDBOX_NAME = "alpha";
const GATEWAY_NAME = "nemoclaw";
const FINGERPRINT = "b".repeat(64);

function openClawEntry(): SandboxEntry {
return {
name: SANDBOX_NAME,
openshellDriver: "docker",
openshellVersion: "0.0.99",
gatewayName: GATEWAY_NAME,
gatewayPort: 8080,
lifecycleGeneration: "generation-1",
lifecycleLiveIdentityFingerprint: FINGERPRINT,
agent: null,
agentVersion: "1.0.0",
nemoclawVersion: "2.0.0",
imageTag: "example@sha256:immutable",
policyPresetsFinalized: true,
policies: ["managed_inference"],
policyTier: "standard",
provider: null,
model: null,
endpointUrl: null,
credentialEnv: null,
preferredInferenceApi: null,
compatibleEndpointReasoning: null,
compatibleEndpointReasoningEffort: null,
nimContainer: null,
};
}

describe("ordinary OpenClaw pairing target", () => {
const deps: LaunchReadinessDeps = {
getSandbox: vi.fn(),
listAgents: vi.fn(() => ["openclaw"]),
loadAgent: vi.fn(() => loadAgent("openclaw")),
};

it("resolves the finalized default OpenClaw runtime identity (#9844)", () => {
vi.mocked(deps.getSandbox!).mockReturnValue(openClawEntry());

expect(resolveOrdinaryOpenClawPairingTarget(SANDBOX_NAME, deps)).toEqual({
gatewayName: GATEWAY_NAME,
lifecycleGeneration: "generation-1",
lifecycleLiveIdentityFingerprint: FINGERPRINT,
stateDirectory: "/sandbox/.openclaw",
version: "1.0.0",
});
});

it.each([
["missing agent identity", { agent: undefined }],
["unfinished policy selection", { policyPresetsFinalized: undefined }],
["pending route reservation", { pendingRouteReservation: true }],
["changed gateway binding", { gatewayName: "nemoclaw-8081" }],
["missing lifecycle generation", { lifecycleGeneration: undefined }],
])("rejects %s (#9844)", (_label, mutation) => {
vi.mocked(deps.getSandbox!).mockReturnValue({
...openClawEntry(),
...mutation,
} as SandboxEntry);

expect(resolveOrdinaryOpenClawPairingTarget(SANDBOX_NAME, deps)).toBeNull();
});

it("returns no target when registry observation fails (#9844)", () => {
vi.mocked(deps.getSandbox!).mockImplementation(() => {
throw new Error("registry unavailable");
});

expect(resolveOrdinaryOpenClawPairingTarget(SANDBOX_NAME, deps)).toBeNull();
});
});
68 changes: 52 additions & 16 deletions src/lib/actions/sandbox/launch-readiness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ export type PortableOpenClawPairingSettlementResult =
| "portable-pairing-incomplete";
};

export interface OpenClawPairingSettlementTarget {
readonly gatewayName: string;
readonly lifecycleGeneration: string;
readonly lifecycleLiveIdentityFingerprint: string;
readonly stateDirectory: string;
readonly version: string;
}

type LaunchReadinessPublicationValidationCategory = Extract<
LaunchReadinessPublicationResult,
{ kind: "validation-failed" }
Expand Down Expand Up @@ -888,23 +896,19 @@ function portableReceiptChanged(
);
}

function resolvePortablePairingTarget(
function resolveOpenClawPairingSettlementTarget(
sandboxName: string,
entry: SandboxEntry | null,
registryGeneration: string,
deps: LaunchReadinessDeps,
): {
readonly gatewayName: string;
readonly stateDirectory: string;
readonly version: string;
} | null {
requiredGeneration?: string,
): OpenClawPairingSettlementTarget | null {
if (
!entry ||
entry.name !== sandboxName ||
entry.agent !== "openclaw" ||
(entry.agent !== null && entry.agent !== "openclaw") ||
entry.policyPresetsFinalized !== true ||
entry.lifecycleGeneration !== registryGeneration ||
!normalizedString(entry.lifecycleLiveIdentityFingerprint) ||
entry.pendingRouteReservation === true ||
entry.reservationSessionId ||
!Number.isInteger(entry.gatewayPort) ||
(entry.gatewayPort ?? 0) < 1 ||
(entry.gatewayPort ?? 0) > 65535
Expand All @@ -923,8 +927,40 @@ function resolvePortablePairingTarget(
const version = normalizedString(entry.agentVersion);
const expectedVersion = normalizedString(agent.expected_version);
const stateDirectory = normalizedString(agent.config?.dir);
if (!version || !expectedVersion || !stateDirectory) return null;
return { gatewayName, stateDirectory, version };
const lifecycleGeneration = normalizedString(entry.lifecycleGeneration);
const lifecycleLiveIdentityFingerprint = normalizedString(
entry.lifecycleLiveIdentityFingerprint,
);
if (
!version ||
!expectedVersion ||
!stateDirectory ||
!lifecycleGeneration ||
!lifecycleLiveIdentityFingerprint ||
(requiredGeneration !== undefined && lifecycleGeneration !== requiredGeneration)
) {
return null;
}
return {
gatewayName,
lifecycleGeneration,
lifecycleLiveIdentityFingerprint,
stateDirectory,
version,
};
}

/** Resolve the finalized ordinary OpenClaw runtime that owns pairing state. */
export function resolveOrdinaryOpenClawPairingTarget(
sandboxName: string,
deps: LaunchReadinessDeps = {},
): OpenClawPairingSettlementTarget | null {
try {
const getSandbox = deps.getSandbox ?? registry.getSandbox;
return resolveOpenClawPairingSettlementTarget(sandboxName, getSandbox(sandboxName), deps);
} catch {
return null;
}
}

/**
Expand Down Expand Up @@ -991,11 +1027,11 @@ export async function settlePortableOpenClawPairing(
if (firstEntry.policyPresetsFinalized !== true) {
return incompletePortablePairing("portable-policy-incomplete");
}
const firstTarget = resolvePortablePairingTarget(
const firstTarget = resolveOpenClawPairingSettlementTarget(
sandboxName,
firstEntry,
firstReceipt.registryGeneration,
deps,
firstReceipt.registryGeneration,
);
if (!firstTarget) return incompletePortablePairing("portable-runtime-identity-invalid");

Expand All @@ -1008,11 +1044,11 @@ export async function settlePortableOpenClawPairing(
if (lockedEntry?.policyPresetsFinalized !== true) {
return incompletePortablePairing("portable-policy-incomplete");
}
const target = resolvePortablePairingTarget(
const target = resolveOpenClawPairingSettlementTarget(
sandboxName,
lockedEntry,
lockedReceipt.registryGeneration,
deps,
lockedReceipt.registryGeneration,
);
if (
!target ||
Expand Down
Loading
Loading