feat: set up on first launch and start eligible gateways - #91
paulcam206 wants to merge 4 commits into
Conversation
`openclaw` now provisions this installation when its setup marker is absent, then forwards its arguments unchanged. Only an absent marker is provisioned: unreadable, incomplete, foreign, newer-schema, preparing, and tearing-down state keep their explicit recovery messages. Where the launcher previously printed a `clawctl gateway-service start` hint, it now starts the managed gateway. A failed start warns on standard error and leaves the OpenClaw exit code untouched. CLAWCTL_AUTO_SETUP and CLAWCTL_AUTO_GATEWAY_START each restore the previous behavior exactly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e9ba17a2-0bca-4454-96e3-f42ba540a268
Record successful automatic gateway starts while the lifecycle lock is still held, and keep advisory acknowledgement failures distinct from startup failures. Drive the new NativeAOT setup scenarios through the production startup route and make concurrent first-launch coverage force real lock contention. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e9ba17a2-0bca-4454-96e3-f42ba540a268
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 8:58 PM ET / September 22, 2026, 00:58 UTC (Revision 3). ClawSweeper reviewWhat this changesThe Windows launcher automatically sets up a never-configured installation and starts eligible gateways after successful interactive commands, with environment-variable opt-outs. Merge readiness✅ Ready for maintainer review The previous acknowledgement-race blocker is resolved, and no remaining blocking defect was found. The feature remains absent from current main and the latest release. Priority: P2 Review scores
Verification
How this fits togetherThe Windows launcher forwards OpenClaw commands into an isolated agent session. Its setup and gateway lifecycle owners prepare that session, launch commands, and manage the background gateway. flowchart TD
A[OpenClaw invocation] --> B{Setup marker absent?}
B -->|Yes and enabled| C[Shared setup owner]
B -->|No| D[Validate recorded session]
C --> D
D --> E[Run command inside isolated session]
E --> F{Successful interactive command and eligible gateway?}
F -->|Yes and enabled| G[Start gateway under lifecycle lock]
F -->|Otherwise| H[Return child exit code]
G --> H
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep automatic first-use setup and eligible gateway startup within the existing lifecycle owners, preserving opt-outs and explicit recovery for degraded state. Do we have a high-confidence way to reproduce the issue? Not applicable to the feature request; source inspection confirms the prior race is repaired and its deterministic regression covers the reported interleaving. Is this the best way to solve the issue? Yes. Sharing the existing setup implementation and gateway controller avoids competing lifecycle owners while retaining state validation and opt-outs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 207d19d0fd28. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
Recheck per-logon gateway acknowledgement under the same lifecycle lock used by automatic startup, then use the controller's no-reacquire path to avoid nesting the non-reentrant lock. Add a deterministic delayed-postflight regression so a later acknowledged start and manual stop cannot be overridden. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e9ba17a2-0bca-4454-96e3-f42ba540a268
Preserve the process-console capability established before postflight so automatic gateway startup uses Spectre live status instead of redirected progress lines. Allow 90 seconds for a cold gateway listener to appear before reporting that startup is still in progress. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e9ba17a2-0bca-4454-96e3-f42ba540a268
What Problem This Solves
Users must currently run separate setup and gateway-start commands before a clean OpenClaw installation becomes fully usable.
User Impact
User impact:
openclawnow provisions an installation that has never been set up and automatically starts a startup-eligible stopped gateway after a successful interactive command.The first
openclawinvocation on a clean machine creates the MXC session, agent profile/runtime, and sign-in recovery state.CLAWCTL_AUTO_SETUP=0restores the previous fail-with-setup-guidance behavior, andCLAWCTL_AUTO_GATEWAY_START=0restores the previous gateway-start hint.Why This Change Was Made
Automatic setup reuses the existing setup owner and runs only when the setup marker is absent. Preparing, tearing-down, unreadable, incomplete, foreign-identity, newer-schema, and stale-runtime states retain their explicit recovery paths.
Gateway auto-start reuses the existing gateway controller and runs only after a successful interactive command when configuration is startup-eligible and the gateway is
NotStartedor positively observedStopped. Start failures warn on stderr without changing the OpenClaw child exit code. Successful startup and its per-logon acknowledgement are recorded in one lifecycle critical section.Automatic-start progress retains the process console capability established before postflight so interactive Windows Terminal sessions use Spectre live status. Cold starts wait up to 90 seconds for the listener before reporting that the gateway is still starting.
Evidence
Validated at head
da5293a0e015fe0d18164f4202afa5ce98e5623f:.\scripts\Test-DotNetQuality.ps1— passed with no warnings or errorsdotnet test .\tests\OpenClaw.Launcher.Tests\OpenClaw.Launcher.Tests.csproj --configuration Release --no-build --no-restore --nologo— 1,036 passed.\scripts\Test-NativeAotCli.Tests.ps1— 23 scenarios passed, including first launch, prepared launch, setup opt-out, gateway-start opt-out, stdout ownership, and native alias identity.\scripts\Test-DocReferences.ps1— 0 findingsgit diff --check— passedNot run: