Repository navigation
fix: start Gateway while slow agent database checks finish - #150755
Conversation
|
🦞👀 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. |
5d86a07 to
3f2d72b
Compare
|
Codex review: blocked before merge. Reviewed September 17, 2026, 6:42 AM ET / 10:42 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR lets healthy agents serve while slow database inspections continue, then restores deferred agents after credential, session, and model preparation. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful fix absent from fetched main. No actionable introduced defect was found, and the maintainer explicitly disposed of the previous upgrade-proof request. Priority: P1 Review scores
Verification
How this fits togetherGateway startup checks each agent’s SQLite database before allowing session access. This change transfers unfinished checks into the Gateway lifetime while keeping affected agents unavailable until preparation succeeds. flowchart TD
A[Configured agent databases] --> B[Bounded startup inspections]
B --> C[Healthy agents serve]
B --> D[Deferred agent stays degraded]
D --> E[Background inspection]
E --> F[Guarded credential and session preparation]
F --> G[Publish models and readmit agent]
H[Gateway shutdown] --> E
H --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource +894, Tests +1095, Docs +37, Other 0. Total +2026 across 38 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single admission owner and guarded recovery path, with the accepted upgrade-proof limitation and agent-specific repair guidance visible. Do we have a high-confidence way to reproduce the issue? Yes: current main propagates inspection failure through startup, and the supplied differential fixture demonstrates the timeout trigger. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: separating the foreground wait from inspection cancellation preserves integrity checks and reuses existing preparation owners without adding configuration or a competing scheduler. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 15f258319a9a. LabelsLabel 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)
|
Retain unfinished agent inspections under the Gateway lifetime instead of turning a foreground timeout into a fatal startup error. Keep the agent degraded until inspection and guarded credential, session, and model preparation complete; cancel and join that work during shutdown. Preserve caller cancellation, propagate failures until background handoff, and keep inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Refs #150574, #141918, #142179, #150444.
3f2d72b to
afe7cd5
Compare
|
Merged via squash.
|
…150755) Retain unfinished agent database inspections under the Gateway lifetime so a slow healthy database no longer turns its foreground wait timeout into a fatal startup error. Keep affected agents degraded until inspection and guarded credential, session, and model preparation complete; healthy agents can serve in the meantime. Corruption and pending migrations retain Doctor guidance. Compose deferred admission with the existing Linux spawn-broker owner. Shutdown cancels and joins retained inspection and preparation before broker cleanup. Preserve caller cancellation, foreground failures before handoff, and inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Validation: recorded focused and real SQLite-child/HTTP boundary proof, scoped-clean Codex review, and green exact-head CI. Published-updater and retained Windows-service compatibility remain unverified; the PR records the scoped Rank-up skip. Closes openclaw#150574. Related: openclaw#141918, openclaw#142179, openclaw#150444, openclaw#150564.
Supersedes #150677 (GitHub lost the head refresh after a force-push; same branch, same change)
Closes #150574.
Related: #141918, #142179, #150444, #150564.
What Problem This Solves
Fixes Gateway startup aborting when an agent database inspection exceeds its wait budget without finding corruption.
Thanks to @desksk for the report and offline integrity timings that distinguished slow storage contention from database damage.
User Impact
The Gateway starts and serves healthy agents while an unfinished agent remains degraded with its reason and Doctor guidance. Its inspection continues in the background. The agent becomes available only after its credentials, sessions, and models are prepared. Genuine corruption leaves that agent degraded; shutdown cancels and joins retained work.
Shared-state database failures retain their existing behavior. There are no new configuration options, CLI flags, environment variables, dependencies, or SQLite schema changes.
Why This Change Was Made
At this PR's baseline, two fleet-preflight slots and a 635-second allowance for a 267.5 MiB database without sidecars are already on main but unreleased. The reporter's installed 2026.9.4 still has the older budget and concurrency. This PR fixes the remaining fatal timeout path; it preserves that scheduler, budget formula, and supervisor policy.
The existing inspection scheduler now separates its foreground wait from native worker cancellation. Startup transfers unfinished inspections to the Gateway lifetime and records agent admission refusals. Recovery uses the existing secrets, session, and model owners under current file, roster, configuration, and publication authority before clearing a refusal. Caller cancellation still cancels the native readers, and failed inspections remain foreground errors until their background handoff succeeds.
The Gateway startup owner composes this admission lifetime with the Linux spawn broker from #150564. Broker readiness precedes core startup. Admission remains registered in the existing Gateway lifetime-sidecar registry; the outer broker cleanup also joins that same admission if core cleanup fails before reaching its sidecars. Deferred preparation re-enters only the captured broker context, preserving its private database-preparation authority.
Evidence
Gateway failed to start: SQLite schema inspection timed out after 0.001 seconds. The original database bytes were unchanged./healthz: healthy agents serve while a slow agent is refused, preparation completes before recovery, corruption stays agent-local, queued peers recover independently, and shutdown joins native work.healthz=200while the slow agent isagent-database-inspection-pending; readmission clears only after credential/session/model preparation, and a command spawned during preparation has the broker as its parent. Removing the broker-context capture fails this parent-process assertion.pnpm install --frozen-lockfile,pnpm check:changed, andpnpm buildpassed on the composed candidate. No lint substitute or baseline edit was needed.--mode branch --base origin/main --max-priority P1returnedscoped-cleanon the committed head.Proof uses isolated state directories and free ports with deterministic native-child pauses and the existing budget seam. It does not claim a physical slow-volume benchmark or a shipped-driver respawn reproduction.
Ownership and line-count tradeoff
Production: +1,092 / −198 (net +894, 26 files). Tests: +1,113 / −18 (net +1,095, 9 changed files). Docs: net +37. Generated Swift protocol: +2 / −2 (net 0).
Production growth owns the previously missing transfer from CLI preflight to Gateway lifetime, agent-specific pending admission and cancellation, and guarded recovery through existing credential/session/model preparation. It also prevents an unavailable inherited auth store from taking healthy agents down. The existing scheduler remains the concurrency owner. The broker composition adds 10 net production lines, reuses the same idempotent admission stop operation, and removes the reused-scope early return that skipped failure cleanup; it adds no parallel work registry.
ClawSweeper Rank-up disposition
The exact-head review found no actionable correctness or security defect. Its additional published-driver × candidate retained-state validation, including the Windows supervisor path, is skipped for this landing under the maintainer instruction to apply or explicitly state-skip Rank-up moves. The existing real SQLite-child, HTTP, guarded-readmission, and broker-lifetime evidence supports the runtime repair; it does not establish published-updater or retained Windows-service compatibility. Migration-required agents remain degraded with Doctor guidance. This proof limitation remains open and is not represented as a passing platform test.
Exact-head CI was reverified on
afe7cd506d9bac34615d686419b33e22a06eb063: run 35207940594,GREEN, GitHub rollupSUCCESS, zero pending checks. The recorded Codex review isscoped-clean; no source changes were made for this landing.