fix(gateway): avoid default provider auth startup prewarm#88514
fix(gateway): avoid default provider auth startup prewarm#88514vincentkoc wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 6:25 PM ET / 22:25 UTC. Summary PR surface: Source +4, Tests +53. Total +57 across 2 files. Reproducibility: yes. for the startup-scheduling defect from source: current main passes providerAuthPrewarm without enabled and schedules startup warm by omission. I did not run a live reproduction of the exact 284s Docker/WSL2 timing in this read-only review. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Refresh one canonical branch onto current main, preserve explicit startup warming plus auth-failure rewarm, and merge only after maintainers accept lazy/default-off provider-auth startup while tracking broader startup latency separately. Do we have a high-confidence way to reproduce the issue? Yes for the startup-scheduling defect from source: current main passes providerAuthPrewarm without enabled and schedules startup warm by omission. I did not run a live reproduction of the exact 284s Docker/WSL2 timing in this read-only review. Is this the best way to solve the issue? Yes, if maintainers accept the compatibility tradeoff. The PR targets the scheduler that creates unsolicited startup warm work, preserves explicit startup warming and auth-profile failure rewarm, and avoids adding a public config or env knob. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 843ad143647e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +53. Total +57 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
Landed the current-main replay in #100667 as The landed fix preserves this PR's important contract: normal Gateway startup keeps provider-auth failure rewarming but no longer schedules the broad startup sweep. The replay also removes the later redundant QA-only skip environment surface, adds the changelog entry, and passed focused provider/gateway tests, a full build, live authenticated Gateway RPC proof, the broad changed gate, fresh autoreview, and exact-head hosted CI including QA Smoke. This branch could not be refreshed directly because maintainer edits are disabled and it had diverged from current main. Vincent's authorship is preserved through Thank you for the careful WSL2 and native Windows proof. For future contributor branches, enabling Allow edits by maintainers lets us refresh and land the original PR instead of replaying it. Closing this PR as superseded by the landed canonical fix. |
Summary
This PR stops the gateway from running the provider-auth warm sweep by default during startup. The issue report shows Docker/WSL2 gateway event-loop starvation, local RPC timeouts, and a 284s provider-auth prewarm on 2026.5.22; current main had moved the warm path off-main-thread, but still scheduled the warm sweep automatically after ready.
The intended outcome is narrower: default startup should keep the gateway responsive and avoid unsolicited provider-auth sweep work, while explicit callers can still opt into startup warming and auth-profile failure events still trigger a rewarm.
Out of scope: this does not solve every context-size or runtime-startup latency signal from the issue, and native Windows proof here uses an isolated foreground gateway with no live provider credentials or channel accounts.
Reviewers should focus on the startup contract in
src/gateway/server-startup-post-attach.ts: default startup no longer schedules provider-auth prewarm, but the failure hook and explicitenabled: truepath remain covered.Linked context
Closes #86752
Related #85999, #86201, #86512, #86073.
Maintainer-requested as part of the Windows / WSL issue sweep from #74163.
Real behavior proof (required for external PRs)
cbx_be71611ba83d(harbor-lobster), Nodev22.22.2, pnpm11.2.2; AWS Crabbox native Windows leasecbx_8ccfe5ff4900(native-win-pr74163-aws), Nodev24.16.0, pnpm11.2.2, PowerShell5.1.20348.4294, Windows10.0.20348.5139.OPENCLAW_GATEWAY_STARTUP_TRACE=1, then ran authenticatedgateway status --require-rpcand directgateway call statusagainst the live gateway. On native Windows, hydrated the PR branch throughhydrate-windows-daemon, started an isolated foreground gateway with token auth andOPENCLAW_GATEWAY_STARTUP_TRACE=1, then ran authenticatedgateway status --require-rpc --jsonagainst the live gateway.run_76eb41a23a64reportedrpc.ok: true, directstatusRPC returned runtime status, gateway reached[gateway] ready, and startup logs did not containprovider auth state pre-warmed. Native Windows Crabbox runrun_0b72afe5ff48reportedrpc.ok: true, gateway reached[gateway] ready, startup trace showedeventLoopMax=0.0ms, and startup logs did not containprovider auth state pre-warmed.Tests and validation
Commands run:
node scripts/run-vitest.mjs src/gateway/server-startup-post-attach.test.ts src/agents/model-provider-auth.test.ts -- --runnode scripts/run-oxlint.mjs src/gateway/server-startup-post-attach.ts src/gateway/server-startup-post-attach.test.ts src/agents/model-provider-auth.ts src/agents/model-provider-auth.test.tsgit diff --check origin/main..HEAD.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/mainrun_101b08aeda52: targeted Vitest and oxlint in WSL2 after hydrating Node/pnpm.run_76eb41a23a64: authenticated live gateway RPC proof.26703936119:hydrate-windows-daemonon branchfix-wsl-event-loop-starvation-86752.run_db0c5343dbb9:node scripts/run-vitest.mjs src/gateway/server-startup-post-attach.test.ts -- --runpassed 46 tests.run_0b72afe5ff48: authenticated foreground gateway RPC proof.run_612f3d317f98:pnpm check:changedpassed after deepening the shallow checkout soorigin/main...HEADhad a merge base.Regression coverage added:
enabled: trueprewarm tests continue to cover the opt-in startup warm path.What failed before this fix:
If no test was added, why not?
Risk checklist
Did user-visible behavior change? (
Yes/No)Yes. Gateway startup no longer performs default provider-auth prewarm unless explicitly enabled.
Did config, environment, or migration behavior change? (
Yes/No)No config or migration shape changes.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)Yes. This changes when provider-auth state is warmed, but not the auth decision path itself.
What is the highest-risk area?
A provider account state that previously became available from default startup prewarm may now be computed lazily or after an auth-profile failure event.
How is that risk mitigated?
The explicit
enabled: truestartup warm path remains available and tested, and the auth-profile failure rewarm hook still runs even when default startup prewarm is disabled.Current review state
What is the next action?
Maintainer review the behavioral tradeoff: default startup responsiveness versus eager provider-auth state. The earlier native Windows proof gap is now covered by native Windows targeted tests,
check:changed, and foreground gateway RPC proof.What is still waiting on author, maintainer, CI, or external proof?
Human maintainer review of the startup behavior tradeoff. The WSL2 proof, native Windows proof, targeted tests, lint, changed gate, diff check, and autoreview are complete.
Which bot or reviewer comments were addressed?
Local autoreview completed cleanly with no accepted/actionable findings. The ClawSweeper native Windows proof caveat has been addressed with the native Windows proof runs listed above.