Repository navigation
fix(gateway): stop GitHub readiness from copying whole agent databases - #188025
Conversation
sessions.github.readiness ran inside the offline-inspection copy scope, so every read on a live Gateway full-copied agent databases and stalled all writers. Read through the live owner instead, and guard Gateway code against the scope.
|
🦞👀 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. What this changesGitHub publication readiness reads live agent databases without copying them, while preserving worker-based path checks and source-retirement checks. Example: An agent calls github_publish readiness with a 35 GB agent database.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This PR addresses a current Gateway stall and resolves both prior findings; no new actionable defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway accepts readiness requests from clients and the github_publish tool, reads session authority and publication facts through database workers, and returns observational readiness without initiating publication or credential refresh. flowchart TD
A[Client or github_publish] --> B[Gateway readiness dispatch]
B --> C[Worker path qualification]
C --> D[Live agent database owner]
D --> E[Session and registry authority]
E --> F[Readiness response]
Technical reviewBest possible solution: Use the existing live database owners for readiness, retain source and disclosure revocation checks, and reserve whole-database copies for offline inspection. Do we have a high-confidence way to reproduce the issue? Fetched main explicitly enables whole-agent-database inspection copies for readiness, matching the reported production stalls; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is the smallest complete repair: remove offline copying, retain worker qualification, and reuse existing registry and retirement owners rather than introducing another database path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e975c3603772. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +16, Tests +5, Docs +1. Total +22 across 12 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 30, 2026, 12:28 AM ET / 04:28 UTC (Revision 3). |
Split session discovery's inspection flag: artifact-preserving reads check paths in workers, and only the Doctor agent scope reads private copies.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Observational readiness keeps the registry witness and native retirement signal for the selected agent database without copying it; restore the retired, removed and replaced source cases.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed.
Thanks @fuller-stack-dev for the readiness work in #187152, and for #188009/#188070. With this landed, readiness no longer goes through the copy path; those PRs may still be useful for the remaining Doctor inspection copies. |
openclaw#188025) ## What Problem This Solves Since `sessions.github.readiness` shipped (f345b6d), every readiness read on a busy Gateway froze the whole Gateway for minutes. The agent `github_publish` tool calls readiness. The Gateway ran that request inside `withArtifactPreservingStateReads({ agentDatabases: true })`. That scope exists for offline Doctor inspection: it turns every agent-database read into a private whole-file copy. With a live 35 GB agent database, each readiness call: - copied the full database (about 9 minutes at about 1.6 GB/s; disk queue saturated); - held up writers. Session patches waited 400–600 s, session creates about 480 s, and simple reads (`users.prefs.get`, `board.get`) hit their 30 s timeouts; - left the copy behind. About 30 copies (about 640 GB) built up in the snapshot cache in 4 hours. Production trace on the team Gateway: each `github_publish` failure line has a matching 34 GB snapshot directory with the same timestamp, to the second (for example 21:18:22, 22:08:35, 22:16:07, 22:27:52). At each of those instants every stalled `board.get` completed at once. The copies started at the first readiness call after the build containing f345b6d went live. Before that, only occasional state-database snapshots existed. ## Why This Change Was Made The Gateway owns its live databases. A Gateway request reads them through that owner, as `sessions.github.options` and `status` already do. Private copies are for outside, offline readers. - `sessions.github.readiness` dispatch keeps the shared observation scope. That scope gives the existing guarantee that readiness never starts a login refresh, and a test covers it. The `agentDatabases: true` option is removed. - The duplicate scope inside `readGitHubPublicationReadiness` is removed; dispatch already provides it. - `qualifyGitHubPublicationSource` keeps the source-retirement watch: a registry witness plus the native retirement signal for the selected agent database. It now applies to every observational (artifact-preserving) read rather than only to copied readers. The watch copies nothing. If the source is closed, unregistered or replaced while readiness is pending, the request is refused before any response, so a replacement database cannot leave an obsolete visibility decision in place. So that this does not happen again: - A boundary test fails if any production file under `src/gateway/` requests `agentDatabases: true`. - `withArtifactPreservingStateReads` documents that the option is for offline inspection only. - `src/gateway/AGENTS.md` states the rule for Gateway code. The old scope did two jobs: it checked session-store paths in discovery workers, and it copied agent databases. This change keeps the first and drops the second: - In session discovery (`session-utils-store-worker.ts`, `session-sharing-preparation.ts`, `session-entry-read-runtime.ts`, `session-store-read-candidates.ts`), any artifact-preserving read now checks paths in a worker. Readiness keeps that scope. - Only the Doctor-only `agentDatabases` scope adds `preserveSourceArtifacts` or reads a private copy. - Discovery workers no longer force `preserveSourceArtifacts` on every prepared inventory. Callers add it under that scope. Doctor and update inspection keep the copy scope, with unchanged results. @fuller-stack-dev this changes one readiness guarantee from openclaw#187152. Readiness no longer promises byte-identical `-wal`/`-shm` sidecars for a cold agent database. SQLite creates those files when the owner opens the database for a normal read. Stored database bytes stay unchanged, and readiness now creates no snapshot copies; both are still tested. The alternative is a whole-database copy on every call, which stalls a production Gateway. ## User Impact On Gateways with large agent databases, agents calling `github_publish` no longer freeze chat, session updates and the Control UI for minutes, and no longer fill the disk with snapshot copies. ## Evidence - **Regression, red then green.** In `src/gateway/server-methods/sessions-github-readiness.test.ts`, the configured-locator test drives real readiness reads through the registered Gateway method and instruments native SQLite opens in the read workers. It previously asserted "readiness must open private images, not the source". It now asserts that readiness reads the source through its owner. - Against `main`'s production code: 3/3 variants **fail** (`expected 0 to be greater than 0`). - With this change: **pass**. - **Path checks stay off the Gateway thread, red then green.** The same configured-locator test now spies on Gateway-thread session-store path checks (`prepareSessionStoreTargetInventory`, `captureSessionStoreReadCandidates`, `captureSessionStoreReadCandidate`) during cold and warm readiness reads. - Without the split above, it fails with `[4, 4, 16]` calls. - With it: zero. - Remaining Gateway-thread `stat`/`realpath` calls on the source are the per-read admission identity checks that every live Gateway session read makes (`sessions.github.options`, chat). Avoiding those would require reading a private copy, which is the bug. - **Guard, red then green.** `src/state/artifact-preserving-state-reads.boundary.test.ts`: - with `main`'s `server-methods.ts`: fails, naming `server-methods.ts`; - now: passes (3 s wall). - **Custody tests:** - "Preserves cold DB…" and "keeps an absent shared database absent" now compare the stored database files and the count of private snapshot copies; both pass. - The login-refresh, connection, profile, grant, session, visibility and session-metadata post-await checks are unchanged and pass. - The `source`, `registry-remove`, `published-replacement` and `registry-same` post-await cases are kept and run against live reads; each now also asserts zero agent snapshot copies. Without the source-retirement watch, the first three fail (the request is not refused); with it they pass. - **Suites:** - `pnpm test src/gateway/server-methods/sessions-github-readiness.test.ts --maxWorkers=1`: 33 passed, 55 s wall. - Related publication, session-access, availability, store-lookup and `github_publish` tool suites: 193 passed. - Session discovery, entry-read, sharing, store-worker and Doctor lint/database-inspection suites: 342 passed across 35 files. - `pnpm check:changed` passes typecheck, lint and guards. The wrapper-shadowing check fails on `src/agents/skill-workshop-prompt.ts` / `src/plugin-sdk/agent-harness-runtime.ts`. This PR does not touch those files, and the failure is already on `main` (from openclaw#187661). No overlap with Pash/Sarah changes. **Merge danger:** two-way door. No schema, config or stored-state change; a revert restores the copy scope. **Blast radius:** only `sessions.github.readiness` (the `github_publish` readiness action). If this change were wrong, readiness would report from the live database, as `options` and `status` already do. **Follow-up:** with no Gateway caller left, the `preserveSourceArtifacts` plumbing that f345b6d added to session discovery (`session-store-target-inventory.ts` and related readers) runs only under Doctor scopes. It can be reviewed for removal separately. Co-authored-by: Ayaan Zaidi <[email protected]>
Backport bdaf7df (#188025). Separate off-thread path qualification from private Doctor inspection copies, retaining source retirement and post-await authority guards. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Since
sessions.github.readinessshipped (e242709), every readiness read on a busy Gateway froze the whole Gateway for minutes.The agent
github_publishtool calls readiness. The Gateway ran that request insidewithArtifactPreservingStateReads({ agentDatabases: true }). That scope exists for offline Doctor inspection: it turns every agent-database read into a private whole-file copy. With a live 35 GB agent database, each readiness call:users.prefs.get,board.get) hit their 30 s timeouts;Production trace on the team Gateway: each
github_publishfailure line has a matching 34 GB snapshot directory with the same timestamp, to the second (for example 21:18:22, 22:08:35, 22:16:07, 22:27:52). At each of those instants every stalledboard.getcompleted at once. The copies started at the first readiness call after the build containing e242709 went live. Before that, only occasional state-database snapshots existed.Why This Change Was Made
The Gateway owns its live databases. A Gateway request reads them through that owner, as
sessions.github.optionsandstatusalready do. Private copies are for outside, offline readers.sessions.github.readinessdispatch keeps the shared observation scope. That scope gives the existing guarantee that readiness never starts a login refresh, and a test covers it. TheagentDatabases: trueoption is removed.readGitHubPublicationReadinessis removed; dispatch already provides it.qualifyGitHubPublicationSourcekeeps the source-retirement watch: a registry witness plus the native retirement signal for the selected agent database. It now applies to every observational (artifact-preserving) read rather than only to copied readers. The watch copies nothing. If the source is closed, unregistered or replaced while readiness is pending, the request is refused before any response, so a replacement database cannot leave an obsolete visibility decision in place.So that this does not happen again:
src/gateway/requestsagentDatabases: true.withArtifactPreservingStateReadsdocuments that the option is for offline inspection only.src/gateway/AGENTS.mdstates the rule for Gateway code.The old scope did two jobs: it checked session-store paths in discovery workers, and it copied agent databases. This change keeps the first and drops the second:
session-utils-store-worker.ts,session-sharing-preparation.ts,session-entry-read-runtime.ts,session-store-read-candidates.ts), any artifact-preserving read now checks paths in a worker. Readiness keeps that scope.agentDatabasesscope addspreserveSourceArtifactsor reads a private copy.preserveSourceArtifactson every prepared inventory. Callers add it under that scope.Doctor and update inspection keep the copy scope, with unchanged results.
@fuller-stack-dev this changes one readiness guarantee from #187152. Readiness no longer promises byte-identical
-wal/-shmsidecars for a cold agent database. SQLite creates those files when the owner opens the database for a normal read. Stored database bytes stay unchanged, and readiness now creates no snapshot copies; both are still tested. The alternative is a whole-database copy on every call, which stalls a production Gateway.User Impact
On Gateways with large agent databases, agents calling
github_publishno longer freeze chat, session updates and the Control UI for minutes, and no longer fill the disk with snapshot copies.Evidence
src/gateway/server-methods/sessions-github-readiness.test.ts, the configured-locator test drives real readiness reads through the registered Gateway method and instruments native SQLite opens in the read workers. It previously asserted "readiness must open private images, not the source". It now asserts that readiness reads the source through its owner.main's production code: 3/3 variants fail (expected 0 to be greater than 0).prepareSessionStoreTargetInventory,captureSessionStoreReadCandidates,captureSessionStoreReadCandidate) during cold and warm readiness reads.[4, 4, 16]calls.stat/realpathcalls on the source are the per-read admission identity checks that every live Gateway session read makes (sessions.github.options, chat). Avoiding those would require reading a private copy, which is the bug.src/state/artifact-preserving-state-reads.boundary.test.ts:main'sserver-methods.ts: fails, namingserver-methods.ts;source,registry-remove,published-replacementandregistry-samepost-await cases are kept and run against live reads; each now also asserts zero agent snapshot copies. Without the source-retirement watch, the first three fail (the request is not refused); with it they pass.pnpm test src/gateway/server-methods/sessions-github-readiness.test.ts --maxWorkers=1: 33 passed, 55 s wall.github_publishtool suites: 193 passed.pnpm check:changedpasses typecheck, lint and guards. The wrapper-shadowing check fails onsrc/agents/skill-workshop-prompt.ts/src/plugin-sdk/agent-harness-runtime.ts. This PR does not touch those files, and the failure is already onmain(from fix(plugins): show tool guidance only while the tool is callable #187661).No overlap with Pash/Sarah changes.
Merge danger: two-way door. No schema, config or stored-state change; a revert restores the copy scope. Blast radius: only
sessions.github.readiness(thegithub_publishreadiness action). If this change were wrong, readiness would report from the live database, asoptionsandstatusalready do.Follow-up: with no Gateway caller left, the
preserveSourceArtifactsplumbing that e242709 added to session discovery (session-store-target-inventory.tsand related readers) runs only under Doctor scopes. It can be reviewed for removal separately.