Skip to content

fix: native Gateway setup loses startup window to slow validation - #1952

Merged
karkarl merged 2 commits into
openclaw:karkarl-native-setup-finalizationfrom
karkarl:karkarl-progress-confirmed-native-startup-budget
Nov 4, 2026
Merged

karkarl merged 2 commits into
openclaw:karkarl-native-setup-finalizationfrom
karkarl:karkarl-progress-confirmed-native-startup-budget

Conversation

@karkarl

@karkarl karkarl commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: native Gateway setup can roll back before the configured startup window when config validate --json is slow.

User Impact

User impact: A successful configuration validation no longer consumes the bounded native Gateway admission window; the Gateway receives its full configured startup budget.

Why This Change Was Made

Configuration validation now has its own two-minute timeout and must return successfully before the one-shot admission deadline starts. Later retries keep using that same deadline. The package has no verified attempt-bound startup progress callback, so repeated starting snapshots and unverified Gateway log phases do not extend the absolute startup ceiling.

Evidence

  • Supplied pre-fix logs confirm config validate --json exited 0 after 87.2 seconds, then the shared 210-second deadline rolled back 118.4 seconds after the start request.
  • SlowConfigurationValidation_DoesNotReduceNativeStartupBudget advances a manual clock by 87 seconds for validation and 165 seconds for startup, then confirms preparation succeeds without charging validation time to the admission window.
  • The change does not claim that this will complete the latest slow launch: the reported retry suggests only about two additional seconds when validation takes 31 seconds.
  • A rubber-duck review raised a cancellation-classification concern and requested clearer timeout diagnostics. The cancellation concern was verified against the linked operation token, and the diagnostic-clarity suggestion was applied. The documented P0-P3 Copilot code-review fallback found no significant issues; Codex CLI was unavailable, model identity is unverified, and this narrative fallback does not provide helper isolation, frozen-input checks, or structured result validation.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: No capacity-dependent pool directly validates this native Gateway startup-budget contract. The WSL Gateway pool is not native Gateway proof. The post-fix isolated Companion/Gateway rerun is pending with the coordinator.

Validation

  • .\build.ps1 - PASS. Windows ARM64 host; Debug build targeted win-arm64. Documentation and proof-pool validation passed.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --verbosity minimal - PASS: 4,847 passed, 24 skipped.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --verbosity minimal - PASS: 4,754 passed. An earlier full run had two unrelated failures; their focused reruns passed, and the final full Tray run passed.
  • dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore --filter 'FullyQualifiedName~NativeGatewaySetupTests|FullyQualifiedName~NativeGatewaySetupConnectionTests' --verbosity minimal - PASS: 137 passed.
  • dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore --filter 'FullyQualifiedName~IsolatedGatewayRuntimeTests' --verbosity minimal - PASS: 75 passed.
  • Full dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore --verbosity minimal - FAIL: 15 failed, 2,488 passed, 1 skipped (2,504 total). All 15 are GatewayPackageCleanupTests; the host execution policy blocks loading their generated receipt-test.ps1. This is unrelated to the startup-budget change.
  • git diff --check - PASS. The tested uncommitted diff hash 8add7a4c166914f82f158e668aa2df6d480a16a2 matches the committed diff for 09118d5ca8c78e942c9b4b935196098bc7c7d29c.
  • CI impact classification selected tray-tests, ui-tests, and setup-e2e; those hosted lanes have not run yet.

Real Behavior Proof

  • Environment tested: Windows ARM64 worktree; Debug win-arm64 build and automated tests. No Companion or Gateway process was launched.
  • PR head or commit tested: 09118d5ca8c78e942c9b4b935196098bc7c7d29c; the test-run candidate diff hash matches this commit's parent-relative diff (8add7a4c166914f82f158e668aa2df6d480a16a2).
  • Exact steps or command run: Focused native setup and connection tests listed above; the slow-validation regression uses a manual clock.
  • Evidence after fix: SlowConfigurationValidation_DoesNotReduceNativeStartupBudget passes with 87 seconds of validation and 165 seconds of startup.
  • Observed result: Preparation succeeds; validation time is outside the admission/startup window.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A.
  • Not verified or blocked: A post-fix native Companion/Gateway rerun is pending with the coordinator. The latest reported 31-second validation followed by rollback about 178 seconds after start means this change is not yet proven sufficient to complete startup. The current status contract provides no validated attempt-bound phase progress, so identical status samples cannot safely extend the deadline.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR gives configuration validation a separate timeout before starting the native Gateway admission deadline.

Example: Configuration validation takes 87 seconds and Gateway preparation takes another 165 seconds.

  • Before: The combined 252 seconds exceeds the lower stack's shared 210-second admission deadline.
  • After: Validation finishes within its separate 120-second limit, leaving the full admission allowance for Gateway preparation and connection.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused and source-correct, with useful deterministic coverage but no demonstrated native runtime result.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Slow successful configuration validation can leave too little time for native Gateway startup and trigger rollback.
Reason: The maintainer-authored correction preserves the lower stack's finite admission contract while removing unrelated pre-start validation time from it.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored draft open: it makes a focused correction to its lower stack's admission deadline, and no concrete introduced defect was found.

Priority: P2
Reviewed head: 09118d5ca8c78e942c9b4b935196098bc7c7d29c

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-head native setup run demonstrates slow successful validation followed by startup and operator admission, and no executed base-fail/head-pass comparison is supplied.
Agent review details

How this fits together

NativeGatewaySetupService creates a staged setup session; the session validates configuration, authorizes the package-owned runtime, and passes its remaining admission allowance to NativeGatewaySetupConnection.

flowchart TD
A[Native setup page] --> B[Setup service]
B --> C[Setup session]
C --> D[Configuration validation]
D --> E[Bounded runtime authorization]
E --> F[Operator connection and pairing]
Loading

Technical review

Best possible solution:

Keep validation outside the one-shot admission deadline in the existing session owner while preserving bounded startup, cancellation, and fresh ownership checks.

Do we have a high-confidence way to reproduce the issue?

The pinned base starts admission before validation, so 87 seconds of validation plus 165 seconds of preparation exceeds its 210-second allowance; this source path belongs to the lower stack rather than current main.

Is this the best way to solve the issue?

The patch is a small complete fix for validation consuming admission time, but it does not establish that every reported slow Gateway launch will finish within the unchanged startup ceiling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a4dd026cc5f8.

Provenance checked

  • Initial admission accounting changes intended behavior with a stated reason (8c7220b: The lower admission PR deliberately retained one monotonic deadline across preparation and failed connection retries.)
  • Configuration command timeout keeps the original intent (dba8121: Guided native setup already gave configuration validation a two-minute command timeout; the patch centralizes that existing value and bounds the session phase.)
  • Startup timeout documentation and diagnostics keeps the original intent (e5122db: Earlier startup work preserved bounded waiting and exposed timeout details and recovery actions; the patch clarifies phase budgets without changing the runtime ceiling.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit dba8121 adds src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs:188 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dba81213371c; files: src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs)
  • Barbara Kudiess: Raw commit d318127 adds src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs:344 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d318127350b5; files: src/OpenClaw.SetupEngine/NativeGatewaySetupSession.cs)
  • Pedro Larroy: Raw commit e5122db adds src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs:32 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: e5122db3c943; files: src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs)

Review metrics

Metric Value Why it matters
Introduced scope Production +56/-17; tests +51/-2; documentation +39/-21 Growth supports separate bounded phases and two distinct regression cases without adding another owner or persistence layer.

Labels

Label changes:

  • add P2: A focused setup deadline correction within an unmerged stack, with limited scope and no established current-main regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A focused setup deadline correction within an unmerged stack, with limited scope and no established current-main regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach current-head native setup output showing slow successful validation, subsequent startup, and operator admission; redact credentials and non-public endpoints.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 31, 2026, 12:38 PM ET / 16:38 UTC.

karkarl commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Hanselman dual-model review

Scope: PR #1952, head 09118d5ca8c78e942c9b4b935196098bc7c7d29c, base 4f2452bdbb71fd6da133315a25919a99e95e0698.

Reviewers: Claude Opus 5.5 (claude-opus-5.5, default context, high reasoning) and GPT-6 Astra (gpt-6-astra, long_context, high reasoning). Both reviewed the same pinned revision. Source review only; tests were not run.

Both Models Agree: HIGH consensus

No shared findings.

Only One Model Flagged: LOW consensus

Issue Opus 5.5 GPT-6 Astra Fix Confidence
On a retry after legacy setup finalization fails, ConnectWithBudgetAsync starts the admission deadline before PrepareConnectionAsync. If the reload backup was restored away, that call runs RestartAsync, which validates configuration and starts the Gateway under the same deadline. Slow validation can therefore consume the startup window this PR intends to preserve (NativeGatewaySetupConnection.cs:69-80; NativeGatewaySetupSession.cs:81-87, 340-360, 429-438). MEDIUM not flagged 90%

Impact and suggested fix: A retry can spend, for example, 87 seconds validating and 165 seconds starting, exceeding the 210-second admission budget even though startup itself fits. Apply the same separation to the retry/restart path: bound validation independently, then start the admission budget immediately before runtime authorization/startup, while preserving caller cancellation. This is a one-reviewer finding and is not HIGH consensus.

@karkarl
karkarl force-pushed the karkarl-native-setup-finalization branch from f47cfa3 to 8499d9a Compare November 4, 2026 17:54

karkarl commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Hanselman review (local rebased state)

Reviewed local commit 62439a4540d42ad38718aeed7aaf5713b5c6a49c plus the uncommitted retry-path patch (3abe6db6ff0cc6f10342658718c61aa231b171b16a5c841377d8ee87089c633a) against base 8499d9a0d0e78104295bdf496c8fc0d3971d3a79. Combined diff SHA-256: e4d72cbb386fd1331af32171728f378779919b28e128bc47babed2bea7777eeb.

Reviewers: claude-opus-5.5 (default context) and gpt-6-astra (long context), both at high reasoning. The PR's remote head is still 09118d5ca8c78e942c9b4b935196098bc7c7d29c, and GitHub currently reports it as conflicting. This review therefore covers local changes not yet pushed to the PR.

Issue Opus 5.5 GPT-6 Astra Consensus Fix confidence
ConfigurationValidationTimeout is now fixed at two minutes in NativeGatewaySetupService.cs, and the host and session both enforce it. This replaces the existing NativeGatewayCliTimeout.ResolveTimeout() path (four minutes by default, overridable with OPENCLAW_SETUP_NATIVE_CLI_TIMEOUT). A documented ~131-second ARM64 config validate can now time out, and the override cannot raise this limit. HIGH not flagged LOW 90%
ConnectWithBudgetAsync performs restart/config-validation preflight before checking whether an existing admission window has already expired. A doomed retry can therefore wait through validation and run temporary config changes before timing out. LOW not flagged LOW 90%

Opus reported 171 targeted setup/CLI tests passing. No fixes were made as part of this review. The separate retry-path fix is also still local and has not been pushed.

Run legacy restart validation before a new admission window without renewing existing deadlines. Preserve the configurable native CLI validation timeout and reject exhausted retries before restart side effects.

Co-authored-by: Copilot <[email protected]>
@karkarl
karkarl force-pushed the karkarl-progress-confirmed-native-startup-budget branch from 09118d5 to d10894e Compare November 4, 2026 20:17
@karkarl
karkarl merged commit 6e346f1 into openclaw:karkarl-native-setup-finalization Nov 4, 2026
3 checks passed
karkarl added a commit that referenced this pull request Nov 5, 2026
* fix(connection): retry while the Gateway reports startup unavailable

Honor bounded structured startup retry hints without changing auth, pairing, provenance or caller deadlines.

Co-authored-by: Copilot App <[email protected]>

* fix(connection): exclude stale startup state during a new upgrade

Co-authored-by: Copilot App <[email protected]>

* improve(setup): record safe native Gateway handshake phases

Co-authored-by: Copilot App <[email protected]>

* docs: name a single handshake ownership guard

Co-authored-by: Copilot App <[email protected]>

* fix(setup): preserve handshake diagnostic identity and categories

Keep client attempt ordinals unique across replacement native setup sessions. Classify observed transport failures without scanning exception stack frames, leaving existing failure policy unchanged. Cover both regressions and document the page-owned file sink boundary.

Co-authored-by: Copilot App <[email protected]>

* fix(setup): align handshake sink with rebased logger owner

Use the setup host's current logger parameter and describe window-owned sink lifetime after the lower stack's main rebase. No UI, logging lifetime or handshake policy changes.

Co-authored-by: Copilot App <[email protected]>

* fix(connection): observe keepalive transport disconnections

Cover the upstream-added keepalive cancellation path with the same current-generation disconnect observation as adjacent transport loss paths. Extend the existing real-socket ping timeout test to protect generation and ordering without changing recovery or timing policy.

Co-authored-by: Copilot App <[email protected]>

* fix(setup): keep native Gateway admission within one owned attempt

Share the launch-to-operator budget across preparation, authorization and retries. Use optional packaging launch receipts for conditional, attempt-owned cleanup without changing shipping v1 compatibility.

Co-authored-by: Copilot App <[email protected]>

* test(setup): preserve staged authorization under admission cancellation

Update the existing ownership guard for preparation's linked caller, session and admission-deadline token.

Co-authored-by: Copilot App <[email protected]>

* fix(setup): preserve startup rejection across cancellation disposal

Capture the current transport rejection before prompt cancellation disposal and synchronize the callback before classifying a delayed continuation. Preserve caller and session cancellation, and reject stale startup state after a fresh transport.

Co-authored-by: Copilot App <[email protected]>

* fix(setup): integrate admission layer with updated native startup owners

Use the existing logged package invocation and result parser for receipt operations. Align independent fake-clock thresholds and documentation with the inherited five-minute startup budget plus thirty-second handoff allowance, preserving the existing production deadlines.

Co-authored-by: Copilot App <[email protected]>

* fix: native setup cannot remain stuck finishing indefinitely

Bound production finalization and restart publication with one retained execution deadline across retries. Join admitted work through late settlement before releasing setup ownership.

Co-authored-by: Copilot App <[email protected]>

* fix(setup): report expiry when retry deadline has elapsed

Keep the original execution deadline and reject late retries with the existing timeout diagnostic rather than an unrelated replay error.

Co-authored-by: Copilot App <[email protected]>

* test(setup): follow startup-derived finishing execution budget

Advance lifecycle clocks to the configured execution window after lower-stack startup defaults changed. Keep timing defaults independently asserted and avoid duplicating the default in finishing documentation.

Co-authored-by: Copilot App <[email protected]>

* fix: native Gateway setup loses startup window to slow validation (#1952)

* fix: preserve native startup budget after slow validation

Co-authored-by: Copilot App <[email protected]>

* fix(setup): preserve validation timeout and reject exhausted retries

Run legacy restart validation before a new admission window without renewing existing deadlines. Preserve the configurable native CLI validation timeout and reject exhausted retries before restart side effects.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant