Repository navigation
fix(backup): preserve discovery under concurrent state writes - #146912
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: blocked before merge. Reviewed September 13, 2026, 6:52 AM ET / 10:52 UTC (Revision 4). ClawSweeper reviewWhat this changesBackup discovery and config revalidation use scoped SQLite snapshots, retain plugin discovery when workspace files are excluded, and refuse state archives when ownership discovery fails. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix absent from pinned main, with no concrete introduced correctness or security defect found. The subsequent exact-head owner-review approval resolves the earlier ownership blocker; the intentional recovery compatibility change remains visible. Priority: P2 Review scores
Verification
How this fits togetherBackup creation combines configuration, agent ownership, and plugin declarations into an archive inventory. Discovery determines which databases receive managed capture before the archive is verified and published. flowchart TD
A[Config and shared state] --> B[Scoped SQLite snapshot]
B --> C[Agent and plugin discovery]
C --> D{Ownership resolved?}
D -->|Yes| E[Select files and capture databases]
E --> F[Verify and publish archive]
D -->|No| G[Report error without publication]
A --> H[Explicit config-only export]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +53, Tests +124, Docs -5. Total +172 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one scoped snapshot lifetime for reliable ownership discovery, preserve authored-config safeguards, and retain clear documentation of the accepted config-only recovery limitation. Do we have a high-confidence way to reproduce the issue? Yes, a source-backed path is clear: sustained shared-state writes can defeat the synchronous artifact-preserving discovery copy, and the registered CLI cases target that condition. This review did not execute the reproduction. Is this the best way to solve the issue? Yes. Reusing the existing online snapshot owner addresses contention without a competing capture mechanism; the separately documented refusal policy has subsequent exact-head owner-review approval. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e9c1cb7e71b7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
landpr-approve-admin-merge |
|
Thanks @obviyus! Proof: Verified backups retain agent and declared plugin databases during concurrent state writes, with or without workspace files.
|
* temp/pr-146802: (51 commits) improve: reduce worktree filesystem stalls and archive syncs (#146906) fix(ui): avoid extra chat rail work while replies stream (#146883) improve(ui): speed up populated Usage timelines (#146947) test(gateway): retain auth recovery failure diagnostics (#146925) fix(tests): create private temporary home directories (#146931) fix(backup): preserve discovery under concurrent state writes (#146912) fix: keep queued deliveries in their original state directory (#146917) fix(discord): settle voice waveform work before releasing input (#146885) fix(memory): preserve newer indexes and disclose automatic rebuild costs (#146908) fix: retain route ownership while discovering conversations (#146927) refactor: reuse plugin fixture shell runner (#146920) fix(worker): stop preparing disabled live previews (#146896) fix(runtime): support Bun across tooling suite (#146807) chore(i18n): refresh native locales (#146924) perf(secrets): limit expiry metadata to transient credentials (#146882) fix(ui): preserve queued refreshes during session discovery (#146535) test(ui): wait for quiet scrolling and close named file tabs (#146836) fix(ui): prevent Usage hour filters from freezing during DST (#146919) test(ui): share browser page cleanup across layout fixtures (#146805) ci: balance complete PR runtime test groups (#146916) ...
…7476) Supersedes #146725 by @SunnyShu0925. ## What Problem This Solves Plugin inspection can fail during database writes without explaining the bounded failure or what to do next. ## User Impact The error names ten attempts, identifies concurrent writes as a possible cause, and tells the operator to wait for writes to settle and retry. It does not promise success during continuous writes. Risk is low and limited to diagnostic text. ## Why This Change Was Made The existing snapshot owner supplies the message for both strategies. The contributor's production change is unchanged; retries, source checks, canonical path, retained cause, and safe error propagation stay intact. Each corrected test now captures one error per mode and checks the exact count, qualified explanation, complete guidance, source path, and source-change cause. Cause prose must stay out of the top-level message. ## Evidence Retained real CLI proof for the unchanged production patch: `pnpm openclaw plugins info canvas --json`, with an isolated Gateway, synthetic SQLite state, and a sustained writer. Both versions exit 1 during writes and pass before writes and after the writer stops. The failure occurs during config readiness, before plugin inspection dispatch. Main `8cba5e03ddb45`, stderr with the source path redacted: ```text [openclaw] Reason: SQLite read-only worker SQLite source did not stabilize for read-only inspection: <source> ``` Contributor `5c76eff645e8`, with the same redaction: ```text [openclaw] Reason: SQLite read-only worker SQLite source did not stabilize after 10 read-only inspection attempts (the database may be under concurrent write activity): <source>. Wait a moment for write activity to settle, then retry the inspection ``` The corrected tests fail on main `e0cf191e2557` for the three missing guidance fields and pass on this branch. The cause and privacy assertions pass on both. Fresh merge `95650108b296` of `f7faef2077e1` with main `f6f241952b0e` passed 1,088 tests across 13 selected files, including both corrected cases, CLI inspection, snapshot readers, cleanup, error formatting, and routing assertions. One existing Linux-only case was skipped on macOS. The consistent no-color environment preserves the earlier stderr-fixture diagnosis; no assertion or skip was weakened. Changed-file lint, formatting, line limits, and assertion checks passed. Typechecks were not run locally. ## Consumers - CLI startup and plugin inspection, ownership admission, shared-state reads, Doctor/schema checks, update inspection and recovery, task recovery, cron, legacy auth inspection, memory diagnostics, and public snapshot helpers retain their existing control flow. - Backup discovery and config revalidation use the shared online snapshot scope introduced by #146912. Verified backup/checkpoint creation can also use journal-aware snapshot preparation. Failure still stops publication and carries the underlying diagnostic; no consumer parses the old exhaustion text. - Worker output, CLI JSON/stderr, and startup diagnostic logs consume the owner-generated message. Existing wrappers may add their own operation context. - Best-effort config-health reads and driving-updater inspection retain their existing suppression rules. Not every consumer displays the message. - No persisted state, cache invalidation, public function signature, schema, migration, config key, protocol, or retry-policy change is included. AI-assisted. Co-authored-by: SunnyShu0925 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…aw#146912) ## What Problem This Solves Concurrent state-database writes can make `backup create` report a valid config as invalid. Following its `--no-include-workspace` advice can then produce a verified archive with unresolved agent ownership and declared plugin databases copied as opaque bytes. ## Why This Change Was Made Discovery and config revalidation now use online SQLite read snapshots. Failed discovery refuses archive publication and reports the underlying error. `--no-include-workspace` changes file selection without changing plugin discovery; `--only-config` remains available for recovery. openclaw#146700 introduced opaque handling, which remains unchanged for genuinely undeclared files. openclaw#146713 made concurrent memory repair reachable from ordinary search, exposing this discovery failure. ## User Impact Backups retain agent and plugin protection under write load. Invalid or unreadable discovery cannot silently produce a partial state archive. ## Evidence Before: with a sustained root-database writer, full backup exited 1 blaming config; the no-workspace command exited 0 with empty agent roots and an opaque warning for a declared plugin database. After: both commands succeed with verification, resolved agent roots, and managed plugin capture. Idle backup and legacy-audit capture remain covered. ## Compatibility No schema, config key, flag, or archive-format change. Invalid-config state archives now fail closed; `--only-config` still exports the active JSON file. Production growth provides one scoped online-read lifetime shared by discovery and revalidation. This intentionally replaces the schema-invalid partial state archive supported by openclaw#143693. Both state archive modes now require resolved agent and plugin ownership. `--only-config` remains a raw root-file recovery export and does not include referenced config files. ## Consumers - `backup create`: reliable discovery under concurrent state writes and truthful failure output. - `backup create --no-include-workspace`: the same agent/plugin ownership protection with workspace files excluded. The decision `which declared plugin resources backup protects` is made by exactly one mechanism at `src/commands/backup-resource-inventory.ts:126`, supplied with resolved ownership before archive creation. - Pre-migration backup (`src/commands/migrate/apply.ts:26`) calls the same verified archive command before applying a migration. It consumes the archive path and propagates discovery failures. Only absent local state/config is treated as an empty installation. - Config staging revalidation (`src/infra/backup-config-capture.ts:119`) takes a fresh scoped state image while retaining authored config bytes, file identity, and include-graph checks. - Archive result, manifest, and text/JSON output no longer receive unresolved-ownership skipped entries. The existing manifest reader continues to accept earlier archives. ## Invalidation Each discovery or revalidation operation owns and closes its read snapshot. Config-file identity and include-graph checks remain active. Legacy-audit witnesses continue to read live state. ## Contention Real CLI backups run alongside a continuous SQLite writer. Both workspace modes retain their declared owners. ## Tests The registered backup CLI tests cover concurrent root-database writes in both workspace modes and unreadable-state refusal. Retained real CLI captures show the original full-backup failure and no-workspace ownership downgrade on the baseline, then successful verified archives on the candidate tree. Independent archive inspection confirms agent and declared plugin contents, workspace selection, and opaque handling for undeclared SQLite files. All 79 focused tests passed on a fresh merge of `63ef2a8a4b44` with main `d77d0ca76038309f1d2a4edc783be5b6cfc49928`: four CLI cases, 23 command/publication cases, 30 state-reader cases, and 22 config-capture/legacy-audit cases. Workspace-only plugin discovery passes in both workspace modes. Restoring the previous workspace filter makes the no-workspace case fail with an opaque warning for its declared database. Eight real CLI cases also passed on that integration. The final test-only correction passed all 140 backup-create tests, and CI is green at the landing head. AI-assisted. Co-authored-by: Ayaan Zaidi <[email protected]>
…nclaw#147476) Supersedes openclaw#146725 by @SunnyShu0925. ## What Problem This Solves Plugin inspection can fail during database writes without explaining the bounded failure or what to do next. ## User Impact The error names ten attempts, identifies concurrent writes as a possible cause, and tells the operator to wait for writes to settle and retry. It does not promise success during continuous writes. Risk is low and limited to diagnostic text. ## Why This Change Was Made The existing snapshot owner supplies the message for both strategies. The contributor's production change is unchanged; retries, source checks, canonical path, retained cause, and safe error propagation stay intact. Each corrected test now captures one error per mode and checks the exact count, qualified explanation, complete guidance, source path, and source-change cause. Cause prose must stay out of the top-level message. ## Evidence Retained real CLI proof for the unchanged production patch: `pnpm openclaw plugins info canvas --json`, with an isolated Gateway, synthetic SQLite state, and a sustained writer. Both versions exit 1 during writes and pass before writes and after the writer stops. The failure occurs during config readiness, before plugin inspection dispatch. Main `9977306fec733`, stderr with the source path redacted: ```text [openclaw] Reason: SQLite read-only worker SQLite source did not stabilize for read-only inspection: <source> ``` Contributor `5c76eff645e8`, with the same redaction: ```text [openclaw] Reason: SQLite read-only worker SQLite source did not stabilize after 10 read-only inspection attempts (the database may be under concurrent write activity): <source>. Wait a moment for write activity to settle, then retry the inspection ``` The corrected tests fail on main `56bde7c0bcd4` for the three missing guidance fields and pass on this branch. The cause and privacy assertions pass on both. Fresh merge `95650108b296` of `f7faef2077e1` with main `fcf8cfbaba0b` passed 1,088 tests across 13 selected files, including both corrected cases, CLI inspection, snapshot readers, cleanup, error formatting, and routing assertions. One existing Linux-only case was skipped on macOS. The consistent no-color environment preserves the earlier stderr-fixture diagnosis; no assertion or skip was weakened. Changed-file lint, formatting, line limits, and assertion checks passed. Typechecks were not run locally. ## Consumers - CLI startup and plugin inspection, ownership admission, shared-state reads, Doctor/schema checks, update inspection and recovery, task recovery, cron, legacy auth inspection, memory diagnostics, and public snapshot helpers retain their existing control flow. - Backup discovery and config revalidation use the shared online snapshot scope introduced by openclaw#146912. Verified backup/checkpoint creation can also use journal-aware snapshot preparation. Failure still stops publication and carries the underlying diagnostic; no consumer parses the old exhaustion text. - Worker output, CLI JSON/stderr, and startup diagnostic logs consume the owner-generated message. Existing wrappers may add their own operation context. - Best-effort config-health reads and driving-updater inspection retain their existing suppression rules. Not every consumer displays the message. - No persisted state, cache invalidation, public function signature, schema, migration, config key, protocol, or retry-policy change is included. AI-assisted. Co-authored-by: SunnyShu0925 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Concurrent state-database writes can make
backup createreport a valid config as invalid. Following its--no-include-workspaceadvice can then produce a verified archive with unresolved agent ownership and declared plugin databases copied as opaque bytes.Why This Change Was Made
Discovery and config revalidation now use online SQLite read snapshots. Failed discovery refuses archive publication and reports the underlying error.
--no-include-workspacechanges file selection without changing plugin discovery;--only-configremains available for recovery.#146700 introduced opaque handling, which remains unchanged for genuinely undeclared files.
#146713 made concurrent memory repair reachable from ordinary search, exposing this discovery failure.
User Impact
Backups retain agent and plugin protection under write load. Invalid or unreadable discovery cannot silently produce a partial state archive.
Evidence
Before: with a sustained root-database writer, full backup exited 1 blaming config; the no-workspace command exited 0 with empty agent roots and an opaque warning for a declared plugin database.
After: both commands succeed with verification, resolved agent roots, and managed plugin capture. Idle backup and legacy-audit capture remain covered.
Compatibility
No schema, config key, flag, or archive-format change. Invalid-config state archives now fail closed;
--only-configstill exports the active JSON file. Production growth provides one scoped online-read lifetime shared by discovery and revalidation.This intentionally replaces the schema-invalid partial state archive supported by #143693. Both state archive modes now require resolved agent and plugin ownership.
--only-configremains a raw root-file recovery export and does not include referenced config files.Consumers
backup create: reliable discovery under concurrent state writes and truthful failure output.backup create --no-include-workspace: the same agent/plugin ownership protection with workspace files excluded.The decision
which declared plugin resources backup protectsis made by exactly one mechanism atsrc/commands/backup-resource-inventory.ts:126, supplied with resolved ownership before archive creation.src/commands/migrate/apply.ts:26) calls the same verified archive command before applying a migration. It consumes the archive path and propagates discovery failures. Only absent local state/config is treated as an empty installation.src/infra/backup-config-capture.ts:119) takes a fresh scoped state image while retaining authored config bytes, file identity, and include-graph checks.Invalidation
Each discovery or revalidation operation owns and closes its read snapshot. Config-file identity and include-graph checks remain active. Legacy-audit witnesses continue to read live state.
Contention
Real CLI backups run alongside a continuous SQLite writer. Both workspace modes retain their declared owners.
Tests
The registered backup CLI tests cover concurrent root-database writes in both workspace modes and unreadable-state refusal. Retained real CLI captures show the original full-backup failure and no-workspace ownership downgrade on the baseline, then successful verified archives on the candidate tree. Independent archive inspection confirms agent and declared plugin contents, workspace selection, and opaque handling for undeclared SQLite files.
All 79 focused tests passed on a fresh merge of
63ef2a8a4b44with maina8a9114fb78784cb726ba271e3b4da74a40f01a9: four CLI cases, 23 command/publication cases, 30 state-reader cases, and 22 config-capture/legacy-audit cases. Workspace-only plugin discovery passes in both workspace modes. Restoring the previous workspace filter makes the no-workspace case fail with an opaque warning for its declared database. Eight real CLI cases also passed on that integration. The final test-only correction passed all 140 backup-create tests, and CI is green at the landing head.AI-assisted.