Skip to content

refactor(state): retire unused database mutation scopes - #154776

Merged
steipete merged 1 commit into
mainfrom
codex/database-mutation-retirement
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/database-mutation-retirement

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150153.

Refreshed-head CI passed. The branch now includes main’s correction for the upstream chat-position-rail test failure. The retirement patch is unchanged; the published 2026.9.5 qualification below remains bound to its preserved pre-rebase candidate.

What Problem This Solves

Database lifecycle code retains an asynchronous file-mutation path that has no production callers, along with its private snapshots and handle bookkeeping.

User Impact

No intended user-visible change. Existing synchronous writes, source exclusion, private inspection, and maintenance refusal remain with their current owners. Schemas, durability, retention, permissions, and public SDK contracts are unchanged.

Why This Change Was Made

Retire the unused mutation producer and its dependent snapshot, lease, and handle paths. Readers and preflight keep the supported source-exclusion and snapshot operations. Fresh native agent opens still refuse ordinary access during maintenance; tests exercise that boundary through real maintenance ownership.

This focused change removes 387 application lines and 552 test/support lines. Documentation changes are neutral; no main-branch changes are included in those counts.

Evidence

The runtime and build results below are retained qualification for the pre-rebase source. Refreshed-head CI passed on 98b99a495033d3931ebf5ea238d2fa6afcb910f0.

  • Scoped independent P2 review is clean for the retirement and its two fixture corrections; a final naming-only lint repair was reviewed separately.
  • Source-qualified remote runs passed 253 unique tests across 19 focused files. The final maintenance suite passed all 18 cases in 21.83 seconds. These are retained runs across the recorded revisions, not a claim that every suite reran on the final tree.
  • The final full pnpm build passed in 280.41 seconds, including declarations, UI, native built-module/Doctor closure checks, and SDK exports. Production and test types and the registered architecture/format/dead-export guards passed. One test-variable shadowing error from the broader check was repaired; final focused lint passed with no warnings or errors.
  • A narrow negative control removed only the fresh native maintenance refusal. The intended refusal assertion failed; the original source was restored and reverified clean. This proves the retained boundary, not a defect in the original baseline.
  • The refresh applied without conflicts and preserves the exact reviewed retirement patch (git patch-id --stable: dfe41f68ef700bea705da0f2d95f30c1008b6b34). Overlapping upstream snapshot, read-admission, startup-refusal, and WAL-maintenance changes were inspected and retained. No public SDK or bundled-plugin caller uses the retired producer.

The genuine published 2026.9.5 updater qualification passed against the preserved pre-rebase candidate below; this cell was not rerun on the refreshed head. The installed updater exited 0 in 398.949 seconds, activated the source-qualified artifact, restarted the native Gateway, passed readiness and the shared-worker canary, and recorded successful durable finalization. All 267 retained evidence files and the candidate tarball were verified; the native service stopped and uninstalled cleanly, and the isolated lease was independently confirmed released. This proves the Linux native update flow; it does not claim transcript preservation or a production deployment.

Earlier CI failed one upstream UI expectation in chat-position-rail.test.ts; every other selected job passed. Main corrected the asynchronous assertion ordering in 0883394977d1fb3af657635967f6e447bd7fff9a, then added focused-marker coverage in d229666927c6a0f75199fef8a93f76a25166824f. Both commits are included in the refreshed base. The original failure is retained; the refreshed exact-head CI run now passes.

Historical qualified source: c2d976ee4f22858aca6e4c339998860c72cd6dfd, tree 67a0b5d8f89d9af913580ad961b552236ead455e, based on 187bc24e8839e84aa447c78fa86fce94fc91ffb3. Final remote source/build proof.

Refreshed head: 98b99a495033d3931ebf5ea238d2fa6afcb910f0, tree eb8bed9f60200007ac42e99c656bfa5a7342d7f3, based on 146fba007c95c1e30b3c3d5c8dbfaa35f96e0dcf. The 32-file retirement delta is unchanged at +265/−1,204 overall lines.

Compatibility review: the lifecycle-write-custody.ts edit only narrows an internal TypeScript phase union backed by a process-local map. It changes no persisted data model; the retained published-updater proof and matching patch identity confirm upgrade compatibility.

Maintainer compatibility confirmation.

@steipete steipete self-assigned this Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 21, 2026, 12:22 PM ET / 16:22 UTC (Revision 3).

ClawSweeper review

What this changes

Removes unused asynchronous database mutation scopes and their supporting bookkeeping, while updating tests and documentation for the retained maintenance and snapshot paths.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open as useful, maintainer-owned cleanup. Current main still contains the retired path; no blocking defect was found, and the retained published-updater qualification addresses the earlier upgrade-proof concern.

Priority: P3
Reviewed head: 98b99a495033d3931ebf5ea238d2fa6afcb910f0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coherent retirement with meaningful retained boundary coverage and source-bound upgrade qualification; no blocking defect was identified.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Retained published-2026.9.5-to-candidate Linux qualification exercises database lifecycle changes through the real updater and native Gateway, with restart, readiness, worker-canary, and durable-finalization success. The retirement patch is independently verified unchanged after rebase; this is historical qualification, not fresh-head execution.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Retained published-2026.9.5-to-candidate Linux qualification exercises database lifecycle changes through the real updater and native Gateway, with restart, readiness, worker-canary, and durable-finalization success. The retirement patch is independently verified unchanged after rebase; this is historical qualification, not fresh-head execution.
Evidence reviewed 10 items Pinned introduction reviewed: Reviewed the merge-base-to-head delta. Raw commit records confirm the original head has parent 146fba0; the test merge separately has the pinned base followed by this head. Base-only changes were not attributed to this PR.
Retired producer has no application callers: Baseline references to withDatabaseFileMutation comprise its internal definition, forwarding plumbing, and tests. Searches of the reviewed source, extensions, docs, and test tree found no remaining references to the removed mutation APIs. No public SDK caller was identified.
Retained ownership safeguards: Synchronous canonical-write scopes still revoke admission on callback completion. Source exclusion retains ownership, expiry, generation checks, and cleanup settlement. Ordinary agent lease claims refuse maintenance, and fresh native opens refuse before publishing their handle.
Findings None None.
Security None None.

How this fits together

OpenClaw’s database lifecycle layer coordinates agent and shared-state access during reads, writes, maintenance, and updates. It admits operations under live ownership and retains database handles until their work and cleanup finish.

flowchart TD
  A[Database operation] --> B[Lifecycle admission]
  B --> C{Operation type}
  C --> D[Ordinary reads and writes]
  C --> E[Maintenance owner]
  E --> F[Source exclusion and snapshots]
  D --> G[Settlement and cleanup]
  F --> G
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -387, Tests -552, Docs 0. Total -939 across 32 files.

View PR surface stats
Area Files Added Removed Net
Source 15 37 424 -387
Tests 15 223 775 -552
Docs 2 5 5 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 32 265 1204 -939

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/infra/lifecycle-write-custody.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep database access with the existing synchronous-write, maintenance, and snapshot owners without retaining an unused parallel mutation lifecycle.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR retires unused internal machinery rather than reporting a user-facing defect; source inspection supports the absence of application callers.

Is this the best way to solve the issue?

Yes. Removing the unused producer and its dependent paths is a focused simplification, while meaningful maintenance-refusal, excluded-read, and cleanup coverage remains.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d083a215e8f5.

Labels

Label justifications:

  • P3: This is internal cleanup with no intended user-visible change or demonstrated urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Retained published-2026.9.5-to-candidate Linux qualification exercises database lifecycle changes through the real updater and native Gateway, with restart, readiness, worker-canary, and durable-finalization success. The retirement patch is independently verified unchanged after rebase; this is historical qualification, not fresh-head execution.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained published-2026.9.5-to-candidate Linux qualification exercises database lifecycle changes through the real updater and native Gateway, with restart, readiness, worker-canary, and durable-finalization success. The retirement patch is independently verified unchanged after rebase; this is historical qualification, not fresh-head execution.

Evidence

What I checked:

  • Pinned introduction reviewed: Reviewed the merge-base-to-head delta. Raw commit records confirm the original head has parent 146fba0; the test merge separately has the pinned base followed by this head. Base-only changes were not attributed to this PR. (98b99a495033)
  • Retired producer has no application callers: Baseline references to withDatabaseFileMutation comprise its internal definition, forwarding plumbing, and tests. Searches of the reviewed source, extensions, docs, and test tree found no remaining references to the removed mutation APIs. No public SDK caller was identified. (src/state/openclaw-state-lease-context.ts:3, 146fba007c95)
  • Retained ownership safeguards: Synchronous canonical-write scopes still revoke admission on callback completion. Source exclusion retains ownership, expiry, generation checks, and cleanup settlement. Ordinary agent lease claims refuse maintenance, and fresh native opens refuse before publishing their handle. (src/infra/state-database-coordinator.ts:562, 98b99a495033)
  • Credential reads retain live admission: Auth-profile reads retain captured lifecycle admission, maintenance admission, source-exclusion checks, file identity checks, cancellation, and post-read validation. The removed check served the retired mutation producer; credential selection, persistence, and redaction contracts are unchanged. (src/agents/auth-profiles/sqlite-read.ts:119, 98b99a495033)
  • Upgrade qualification and review continuity: The captured PR body reports published 2026.9.5 upgrading to candidate c2d976e: updater exit 0, native Gateway restart, readiness, shared-worker canary, and durable finalization succeeded. The qualification remains tied to that historical candidate, not a fresh run of the rebased head. Its linked Crabbox portal was blocked by this reviewer’s network policy; that inspection limitation does not negate the retained evidence. No schema, serialized format, retention, or migration change was found requiring a separate compatibility decision. (c2d976ee4f22)
  • Historical qualification matches the introduced patch: The GitHub historical commit diff and current local commit diff independently produce stable patch ID dfe41f68ef700bea705da0f2d95f30c1008b6b34. This supports retaining prior qualification across the rebase without describing it as current-head execution. (c2d976ee4f22)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-21T11:35:31.977Z sha c2d976e :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T12:19:36.561Z sha c2d976e :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 21, 2026 11:36
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 98b99a495033d3931ebf5ea238d2fa6afcb910f0
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/sqlite-read.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 21, 2026
@steipete
steipete force-pushed the codex/database-mutation-retirement branch from c2d976e to 98b99a4 Compare September 21, 2026 15:39
@steipete steipete closed this Sep 21, 2026
@steipete steipete reopened this Sep 21, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Compatibility confirmation for 98b99a495033d3931ebf5ea238d2fa6afcb910f0:

The remaining checklist request is covered by the source and upgrade evidence already recorded in this PR. In lifecycle-write-custody.ts, the only edit removes "coordinator-write" from an internal TypeScript phase union. The owner is a process-local Map; its sole producer belongs to the unused mutation path removed here. This changes no schema, serialized record, retention rule, or migration. The current technical review independently reaches that same conclusion.

The published 2026.9.5 updater qualification passed against preserved candidate c2d976ee4f22858aca6e4c339998860c72cd6dfd: updater exit 0, activation, native Gateway restart, readiness, shared-worker canary, and durable finalization all succeeded. All 267 retained evidence files were verified. The refreshed retirement has the identical stable patch ID dfe41f68ef700bea705da0f2d95f30c1008b6b34, and fresh exact-head CI passed on 98b99a495033d3931ebf5ea238d2fa6afcb910f0.

This confirms the requested compatibility evidence. The published-updater cell remains historical qualification of the unchanged retirement patch; no fresh-head updater run or transcript-preservation claim is added.

@steipete
steipete merged commit c89b8ca into main Sep 21, 2026
215 checks passed
@steipete
steipete deleted the codex/database-mutation-retirement branch September 21, 2026 17:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant