Repository navigation
fix: avoid full agent database copies during startup version checks - #145541
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. |
|
Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 3:54 AM ET / 07:54 UTC (Revision 11). ClawSweeper reviewWhat this changesReads agent database version metadata in a read-only child without copying ordinary database contents, while retaining private snapshots for validation, recovery, and exclusive ownership scopes. Merge readiness✅ Ready for maintainer review This remains a useful, bounded repair absent from current main and the latest release. The previous timeout finding is resolved, ownership checks remain intact, and no blocking defect was found. Priority: P2 Review scores
Verification
How this fits togetherGateway startup and update checks inspect database versions before proceeding. This change optimizes the per-agent metadata check; full database readiness and ownership validation retain their existing paths. flowchart TD
A[Startup or update check] --> B[Agent database preflight]
B --> C{Full validation or ownership check?}
C -->|Yes| D[Private snapshot and validation]
C -->|No| E[Read-only child]
E --> F{Recovery or exclusive scope?}
F -->|Yes| D
F -->|No| G[Read coherent version metadata]
D --> H[Compatibility result]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +262, Tests +435, Docs +2, Other 0. Total +699 across 18 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep metadata inspection with the existing child reader and preserve full validation, ownership admission, and recovery at their current owners. Do we have a high-confidence way to reproduce the issue? Yes: current main unconditionally snapshots agent databases for header-only calls, and the supplied real-preflight regression records a full 67,182,592-byte copy. This review verified the source path without executing it. Is this the best way to solve the issue? Yes: the patch extends the existing reader and preserves the snapshot branches required by validation, ownership, and journal recovery; it adds no persistent cache or competing admission policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8c2996e01303. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
|
Fixed in 9924a30. The live header reader now retains the existing 30-second source-reader tolerance; the global runtime/private-snapshot timeout and child deadline are unchanged. A real preflight regression with an exclusive rollback writer held for eight seconds fails on the previous head with The CI architecture finding is also addressed by using Kysely and the existing schema-version, deferred-transaction, and busy-timeout owners. The redundant header module is removed; no allowlist or ignore expansion was needed. Sixty-four affected tests and the Kysely/import-cycle guards pass, and a fresh independent review of the complete candidate is scoped-clean at P0–P2. The PR body contains the updated evidence and remaining live-proof status. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The shared build failure is fixed in 9d15739. The lightweight version module is byte-identical to its pre-PR version; the coherent header reader remains isolated and uses Kysely, the deferred transaction owner, and the existing SQLite PRAGMA owner. No budget or allowlist was expanded. The exact final tree passed a full neutral-Linux @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
9d15739 to
10053a9
Compare
|
Rebased onto main's new per-agent ownership admission in 10053a9. Ownership inspection retains its private snapshot even without full schema validation; ordinary header-only startup checks still use the bounded reader. All six agent roles now have config-only admission coverage. The rebased candidate passes 158 focused tests with one existing skip, plus scoped type-aware lint. Fresh independent review is complete with no verified actionable findings. The PR body distinguishes the prior Linux build/large-store proof from current-head integration validation. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Read agent schema metadata through the existing bounded read-only child while retaining source admission and native close ownership. Keep full validation and required private snapshot paths unchanged. Accepted storage scope: #145412.
Keep the existing 30-second source-reader wait, prove an exclusive rollback writer can release after eight seconds without refusing an update, and reuse Kysely and the existing schema-version/transaction owners. No timeout or SQL guard exceptions are added.
Keep the version reader byte-identical to its prior lightweight contract. Header inspection retains Kysely and the deferred transaction owner, with read-only PRAGMAs owned by the existing SQLite configuration boundary. Full neutral Linux package build, native lock tests, and large-store proof pass without changing budgets or allowlists.
Cover config-only ownership admission for all six agent roles after integrating the current startup isolation owner. Header-only inspection must not skip copied-owner refusal or alter source bytes.
Let runtime launch, packaged output, and precompiled test workers consume one declaration. This removes measured cold TypeScript loading from functional worker proof without increasing deadlines or changing the worker's source or installed path.
Main independently landed the same worker registry consolidation in #145708. Keep its canonical registration and remove the duplicate introduced by Git integration; all three worker registration/build files now match main exactly.
847454b to
da3b1cb
Compare
|
The published-updater compatibility gap is now covered. Main independently landed the same worker-entrypoint consolidation in #145708. I integrated that upstream fix and removed the duplicate registration from Git's automatic merge; the registry, runtime and build files now match main exactly. The remaining 18-file PR delta has stable patch ID @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
|
Related follow-up: #145577 has merged and reduces redundant copying inside Doctor's disposable shared-state lint database. It complements this PR's agent-database startup header optimization rather than replacing it. The two changes address different inspection paths: agent schema-version headers here, and repeated reads of Doctor's private shared-state database in #145577. |
…penclaw#145541) * fix: avoid full agent copies during schema version preflight Read agent schema metadata through the existing bounded read-only child while retaining source admission and native close ownership. Keep full validation and required private snapshot paths unchanged. Accepted storage scope: openclaw#145412. * fix: preserve source inspection lock tolerance Keep the existing 30-second source-reader wait, prove an exclusive rollback writer can release after eight seconds without refusing an update, and reuse Kysely and the existing schema-version/transaction owners. No timeout or SQL guard exceptions are added. * fix: keep schema inspection out of lightweight version imports Keep the version reader byte-identical to its prior lightweight contract. Header inspection retains Kysely and the deferred transaction owner, with read-only PRAGMAs owned by the existing SQLite configuration boundary. Full neutral Linux package build, native lock tests, and large-store proof pass without changing budgets or allowlists. * test: preserve ownership admission during header preflight Cover config-only ownership admission for all six agent roles after integrating the current startup isolation owner. Header-only inspection must not skip copied-owner refusal or alter source bytes. * fix: share the model context worker entrypoint Let runtime launch, packaged output, and precompiled test workers consume one declaration. This removes measured cold TypeScript loading from functional worker proof without increasing deadlines or changing the worker's source or installed path. * fix: retain only the upstream context worker registration Main independently landed the same worker registry consolidation in openclaw#145708. Keep its canonical registration and remove the duplicate introduced by Git integration; all three worker registration/build files now match main exactly.
Closes #145412
What Problem This Solves
Fixes an issue where Gateway startup and restart could spend time and temporary disk copying large agent databases even when only checking their schema versions. The header-only preflight path used full-snapshot machinery before reading a few metadata values.
Why This Change Was Made
Header-only agent preflight now uses the existing read-only worker to read a coherent SQLite schema/version header without copying ordinary database payloads. The worker retains source-reader admission through native database closure; the parent retains cancellation and cleanup ownership through child closure. WAL-visible version and writer metadata come from the same read transaction.
The header reader remains separate from lightweight version utilities, preserving the native hook relay's startup import contract. Metadata SELECT uses Kysely, read transactions use the existing deferred transaction owner, and read-only PRAGMAs belong to the existing SQLite configuration owner. Source-reader lock tolerance stays at the previous 30 seconds; the global/runtime and private-snapshot timeout and child deadlines are unchanged.
Full integrity, foreign-key, schema readiness, agent-ownership admission, physical writable-open validation, and shared-state inspection remain unchanged. The rebased integration preserves the private snapshot whenever
agentAdmissionConfigrequests ownership inspection, even without full schema validation. Rollback recovery, incomplete WAL families (including cleanly closed WAL stores without sidecars), and existing exclusive source/mutation scopes retain their necessary private snapshots. Complete WAL families keep the previous reader's native SHM coordination; sidecar presence does not prove live native clients. There is no catch-all retry/copy fallback, new persistent cache, schema migration, configuration option, or SDK surface expansion.The accepted storage-inspection scope is recorded in #145412. Existing installed update/deployment drivers remain unchanged, and rollback requires no data conversion. Worker bootstrap, worktree cleanup, and broader cross-lease validation reuse are out of scope.
User Impact
Ordinary agent version checks no longer allocate temporary snapshots proportional to retained history. Required full validation still runs at its existing ownership boundaries. This removes measured startup I/O amplification; it does not claim to eliminate every cold-start copy or establish the cause of a historical production integrity timeout.
Evidence
[email protected]updater installed candidate10053a93e70f38c790eac8b4bf6345272bf8a7d4through the canonical Dockerlegacy-operator-state/auto-authsurvivor cell. Update state finished/succeeded; the supervisor changed from 2580 to 6261. Authenticated Gateway RPC reported build2026.9.4-10053a93e70f-2026-09-12T07-03-21.725Z, matching the candidate tarball rather than the published baseline build. Authored approvals, agent/model config, workspace skill bytes, cron ownership/IDs and plugin config were preserved; health/readiness, mock-provider turns, already-current repeat update, and Doctor lint passed. Update/restart took 159 seconds with 69,680 ms reported downtime. Proof run. Tarball SHA-256:ff7626e5c92b33d540feab0de436d024b285c75a56358e317d4072c78e3096d5. This is real Gateway-process proof under the Docker systemd fixture with synthetic state, not native-host systemd or production-data proof. A local evidence-extraction failure occurred after remote success and was recovered without repeating the update.aa600dbf3a059ac52ab58e00d9191ca01388107a, identical to the reviewed and published-updater-proven10053a93e70f38c790eac8b4bf6345272bf8a7d4delta. No additional worker changes, test deadline increases, or weaker assertions remain in this PR.ce4de90b2ec6d48c5ae7143503c12ab2b84ceac5equals the tree of9d15739a059889b53bf1c0ab32127ccb587cb0d2.pnpm buildpassed in the neutral Linux checkout, including the CLI/bootstrap import guard and Plugin SDK export check. 147 tests across eight focused suites passed on Linux, including parent POSIX locks, native child/lease lifetime, failed close, cancellation/deadline settlement, private rollback recovery, inactive complete/incomplete WAL families, and exclusion/mutation scopes. Kysely and import-cycle architecture guards passed.SQLITE_BUSY/indeterminate and an update refusal on the initial PR head. The repaired preflight succeeds after release, retaining the original source-reader tolerance without changing global limits.pager.c: read-only handles returnSQLITE_READONLY_ROLLBACKbefore attempting exclusive recovery locks; the previous snapshot path also retains the same read-only-error fallback. Earlier CI findings were repaired at their owners: no raw-SQL allowlist expansion, no bundle-budget increase, and no dependency or formatter override. The complete selected changed-file gates also passed in the earlier neutral Linux validation; final exact-head CI remains the landing gate.This evidence does not claim production deployment or a production full-scan result. No additional live full-database scan is part of the validation request.