Repository navigation
feat: set up on first launch and start eligible gateways - #91
Conversation
|
Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 1:15 PM ET / 17:15 UTC (Revision 4). ClawSweeper reviewWhat this changesThe Windows launcher provisions first-use installations and starts eligible gateways after successful interactive commands, with environment-variable opt-outs, progress output, and lifecycle regression coverage. Merge readiness✅ Ready for maintainer review This remains useful work absent from current main and the latest release. The earlier acknowledgement race is fixed, and the rebased patch has no actionable correctness or security findings. Priority: P2 Review scores
Verification
How this fits togetherThe Windows launcher forwards OpenClaw commands into an isolated agent session. Setup prepares that session, while gateway postflight uses configuration readiness and observed process state to decide whether to start the background gateway. flowchart TD
A[OpenClaw invocation] --> B{Setup marker absent?}
B -->|Yes and enabled| C[Shared setup owner]
B -->|No or opted out| D[Validate recorded session]
C --> D
D --> E[Run OpenClaw in isolation]
E --> F{Successful and eligible?}
F -->|Yes and enabled| G[Start gateway under lifecycle lock]
F -->|Otherwise| H[Preserve exit code and recovery guidance]
G --> H
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep provisioning and gateway startup in their existing owners, with automatic behavior limited by explicit state checks and documented opt-outs. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect reproduction: this PR adds automatic behavior. Source confirms main still requires explicit setup and provides a gateway-start hint. Is this the best way to solve the issue? Yes. Extracting the existing setup sequence and reusing the gateway controller avoids competing lifecycle owners while preserving argument forwarding and explicit degraded-state recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0afdfad29910. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
`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
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
da5293a to
f3b9873
Compare
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
661906f3f6d586504512a7f1dc3625663047a052after rebasing onto0afdfad. The managed and NativeAOT lanes ran at parentf3b9873af065b6ff42416b78cd2856e6bcd8577e; the head adds only a local-development documentation correction:.\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,062 passed.\scripts\Test-NativeAotCli.Tests.ps1— 24 scenarios passed, including PowerShell completion, 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— passed-SkipSetupinstruction was correctedda5293a0e015fe0d18164f4202afa5ce98e5623fwith no actionable or security findings; the rebase integration is additionally covered by the validation aboveNot run: