Skip to content

fix(state): repair mis-stamped v17 agent databases - #122171

Merged
steipete merged 2 commits into
mainfrom
codex/v17-same-version-repair
Aug 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/v17-same-version-repair

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • recognize an exact retired state_leases table as pending same-version agent-schema convergence
  • validate that retired table's v16 shape before removing it atomically with its indexes and SQLite statistics
  • preserve current v17 ownership metadata, auth rows, and schema version while rejecting foreign same-name structures

Root cause

The v17 retirement ran only while upgrading an older user_version. A database stamped v17 before the retirement completed took the current-version early return, and the general schema contract intentionally permits unrelated tables, so the retired lease table survived indefinitely.

The canonical agent-schema owner now classifies that structure as pending convergence and removes it inside the existing BEGIN IMMEDIATE transaction before the same-version branch. This covers Doctor media repair, explicit maintenance, and writable runtime opens while keeping read-only access nonmutating.

Proof

  • pre-fix regression: 3/5 focused cases failed (retained table, foreign structure accepted, writable open skipped convergence)
  • node scripts/run-vitest.mjs src/state/openclaw-agent-db-retired-lease-repair.test.ts src/infra/state-migrations.media-persistence.additive-schema.test.ts — 6 passed
  • node scripts/run-vitest.mjs src/state/openclaw-agent-db.test.ts — 101 passed, 4 skipped
  • pnpm format and git diff --check — passed
  • pnpm plugin-sdk:api:check — passed with repair helpers module-private
  • autoreview — no accepted/actionable findings; patch correct at 0.98 confidence
  • independent owner/history/final review lanes — clean final verdict

Production delta is +32 lines, justified by the explicit retired structural contract and shared same-version detection/repair boundary. Tests add 274 lines covering mis-stamped v17 repair, clean no-op/idempotence, both auth stores, schema ownership/version preservation, malformed-table rejection, transaction rollback, read-only nonmutation, writable convergence, index/stat cleanup, and integrity/foreign-key checks.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete force-pushed the codex/v17-same-version-repair branch from 0149abf to c403d77 Compare August 11, 2026 18:04
@steipete steipete self-assigned this Aug 11, 2026
@steipete
steipete merged commit 0771787 into main Aug 11, 2026
126 checks passed
@steipete
steipete deleted the codex/v17-same-version-repair branch August 11, 2026 18:34
@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

maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant