Skip to content

refactor(state): retire commitments schema - #122176

Merged
steipete merged 17 commits into
mainfrom
steipete/commitments-schema-v7
Aug 12, 2026
Merged

steipete merged 17 commits into
mainfrom
steipete/commitments-schema-v7

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The commitments runtime was removed by #121479, while #122143 kept its shared-state table in an explicit retirement ledger pending an approved schema migration. Existing shared databases could therefore retain inert commitment rows and five indexes with no remaining runtime owner.

Why This Change Was Made

Shared-state schema version 7 removes only the retired commitments table and its five canonical indexes. The agent schema remains version 17.

Runtime open and Doctor use the same transactional migration. They validate the supported v5/v6 owner and stable-table shape, recognize exact early, partially additive, and final commitments layouts, reject unknown columns/definitions/indexes/triggers, and refuse inbound foreign keys or retained view/trigger/virtual-table dependencies before dropping data. The drop and dependency checks are savepoint-protected, then PRAGMA user_version and schema_meta advance together. Doctor reports the retirement only when it occurred.

Direct v5-to-v7 and v6-to-v7 upgrades remain supported. Missing unrelated stable v5/v6 tables are refused and never recreated empty. Shared state_leases, agent_database_leases, Teams poll/plugin state, ACPX leases, and all per-agent schemas remain untouched. Native clients accept shared schema v7 but do not migrate it.

The public database reference records state schema v7 and gives the exact backup-first manual v7-to-v6 procedure, which recreates the v6 commitments table empty before lowering both schema markers.

Recovery rebased the existing PR onto current main and dropped recovery-only Slack, approval, UI, browser, and stale generated-baseline repairs that had already landed independently. The final diff contains only schema v7, necessary native/generated/Doctor/docs surfaces, and focused tests.

User Impact

Operators upgrading to schema v7 stop carrying storage for a fully retired feature. Only inert, unowned commitment rows are discarded. Foreign or dependent schema objects fail closed before any deletion, with the database left at its prior version.

There is no config, protocol, dependency, changelog, package-version, publication, or release change.

Evidence

  • Focused unique-cache Vitest: 8 files, 277 passed, 1 existing skip. Coverage includes runtime and Doctor retirement, exact/partial additive layouts, direct v5/v6 upgrades, missing-stable-table refusal, foreign/dependent schema preservation, restart handoff, native version alignment, profiles, secret store, retirement ledger, and package metadata.
  • node --import tsx scripts/generate-kysely-types.mts --verify
  • node --max-old-space-size=8192 --import tsx scripts/generate-plugin-sdk-api-baseline.ts --check
  • node scripts/check-native-state-schema-version.mjs (v7)
  • pnpm docs:list
  • pnpm docs:check-mdx (771 files)
  • pnpm format:docs:check (755 files)
  • Targeted Oxfmt/Oxlint and git diff --check
  • Patch-identical current schema diff: full changed classifier passed on Testbox tbx_01kzvm0tay25a1w0qbsrscr0jt, Actions run 31628259237, exit 0. A later actual-conflict rebase changed only generated Plugin SDK hashes; those regenerated hashes passed their check and a separate P2 review.
  • Full-branch Codex autoreview through P2 plus TruffleHog: clean, no accepted/actionable findings. Review findings about dependent objects, index subsets, virtual-table discovery, and partially additive historical layouts were fixed and re-reviewed.
  • Exact pushed head: 785c39e7e3c49beb4267377c29718d47e25dfdcf.
  • Exact-head hosted CI: 31640137019, success. Repo-native prepare accepted hosted exact-head gates and merge b6548e509aac607530247127a5c98ec49d88b904 is on main.

LOC classification against the rebased base:

  • Production/schema/native/metadata: +401/-104 (net +297). The growth is the validated destructive-migration boundary: exact historical-layout recognition plus foreign/view/trigger/virtual-table dependency refusal and rollback.
  • Tests: +785/-51 (net +734)
  • Docs: +82/-14 (net +68)
  • Generated Kysely and Plugin SDK baselines: +18/-52 (net -34)

Known proof gap: no live operator database was mutated. The migration is deterministic SQLite ownership code exercised through both production entry paths against materialized historical databases.

@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 docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 17:45
@steipete
steipete requested a review from a team as a code owner August 11, 2026 17:45
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 5:02 PM ET / 21:02 UTC.

ClawSweeper review

What this changes

The PR advances shared SQLite state to schema v7 and removes the retired commitments table and indexes through startup and Doctor migrations.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This is an active, maintainer-owned schema migration with no code-level blocker found. It needs explicit owner confirmation for the irreversible v7 data-retirement decision and green exact-head CI before merge.

Priority: P2
Reviewed head: 785c39e7e3c49beb4267377c29718d47e25dfdcf
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The migration implementation and focused coverage are solid; documented approval and exact-head CI remain merge gates.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned internal migration is covered through production entry-path fixtures; the external-contributor real-behavior-proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned internal migration is covered through production entry-path fixtures; the external-contributor real-behavior-proof gate does not apply.
Evidence reviewed 7 items Current main behavior: Current main still defines state schema v6, including the commitments table; the requested v7 retirement is not already implemented.
Runtime migration owner: The exact PR head validates v5/v6 before migration and calls the retirement inside the existing synchronous startup transaction.
Destructive-operation safeguards: The retirement recognizes supported historical layouts, refuses foreign keys and retained-object dependencies, and rolls back its savepoint on failure before the enclosing version update can commit.
Findings None None.
Security None None.

How this fits together

The shared-state database stores OpenClaw-wide runtime records. Startup and Doctor validate its schema, apply bounded migrations, then make it available to core and native clients.

flowchart LR
  A[Existing shared SQLite database] --> B[Startup or Doctor]
  B --> C[Schema and dependency validation]
  C --> D[Commitments retirement]
  D --> E[Schema version markers]
  E --> F[Core and native clients]
Loading

Decision needed

Question Recommendation
Does the existing retirement decision explicitly approve advancing shared state to v7 and permanently discarding commitments rows from supported v5/v6 databases? Approve schema v7 retirement: Confirm the retained rows are inert migration debt and allow merge after exact-head required CI is green.

Why: Repository policy requires explicit user discussion and acceptance for SQLite schema-version bumps, and the prior ledger deferred this exact migration decision.

Before merge

  • Resolve merge risk (P1) - Upgrading permanently discards retained commitment rows; unsupported or dependent schemas fail closed, but the storage-retirement decision itself needs explicit approval.
Agent review details

Security

None.

PR surface

Source +297, Tests +734, Docs +68, Config 0, Generated -34, Other 0. Total +1065 across 38 files.

View PR surface stats
Area Files Added Removed Net
Source 10 399 102 +297
Tests 4 783 49 +734
Docs 2 82 14 +68
Config 1 1 1 0
Generated 19 18 52 -34
Other 2 3 3 0
Total 38 1286 221 +1065

Review metrics

Metric Value Why it matters
Production vs test delta production +401/-104 (net +297); tests +785/-51 (net +734) The production growth is concentrated in destructive-migration validation and rollback handling; the test growth exercises historical and refusal paths.

Stored data model

Persistent data-model change detected: database schema: src/secrets/store/secret-store.test.ts, database schema: src/state/openclaw-state-db-maintenance.ts, database schema: src/state/openclaw-state-db-schema-repair.ts, database schema: src/state/openclaw-state-db.test.ts, database schema: src/state/openclaw-state-schema.sql, serialized state: src/state/openclaw-schema-retirements.json, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #122176
Summary: This PR is the remaining canonical physical-storage retirement after the commitments runtime was removed.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Record approval before merge (recommended)
    Confirm the schema-version bump and permanent retirement of supported-database rows, then let exact-head CI decide merge readiness.
  2. Keep the retired storage
    Pause the migration if the retained rows should remain recoverable beyond the documented manual downgrade path.

Technical review

Best possible solution:

Record approval for the v7 destructive migration, then merge only after the exact current head completes required CI successfully while retaining the documented backup-first downgrade path.

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

Yes—source-reproducible: focused materialized v5/v6 fixtures cover runtime startup and Doctor migration paths, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes, conditionally: removing storage at the shared-state schema owner is the canonical repair, provided a maintainer explicitly approves the irreversible retirement decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 79380000e01d.

Labels

Label justifications:

  • P2: This is a bounded upgrade-path change with real persisted-state impact but no active user outage.
  • merge-risk: 🚨 compatibility: The PR changes existing v5/v6 shared databases to v7 and permanently removes a table and its rows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned internal migration is covered through production entry-path fixtures; the external-contributor real-behavior-proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the active migration and the preceding retirement bookkeeping work. (role: recent area contributor; confidence: high; commits: 785c39e7e3c4, 6792921deabe; files: src/state/openclaw-state-db.ts, src/state/openclaw-state-db-schema-repair.ts)
  • obviyus: Authored the merged removal of the commitments runtime that left physical schema retirement as follow-up work. (role: feature-removal contributor; confidence: medium; commits: 4b0151682ef4; files: src/state/openclaw-state-schema.sql)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the schema-v7 approval.
  • Wait for exact-head required CI to complete green.

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 (20 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-12T11:10:55.874Z sha 6e1fbef :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T13:07:46.042Z sha be632af :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T13:18:37.618Z sha 01ded7b :: found issues before merge. :: [P2] Expose the commitments drop to Doctor
  • reviewed 2026-08-12T14:18:40.760Z sha 64b2e25 :: needs changes before merge. :: [P2] Expose the commitments retirement to Doctor
  • reviewed 2026-08-12T15:02:52.156Z sha c1a4e3b :: found issues before merge. :: [P2] Register the commitments retirement with Doctor
  • reviewed 2026-08-12T15:17:55.831Z sha 61c9138 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T16:05:39.781Z sha 7a57cc8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T19:18:33.098Z sha 9827071 :: found issues before merge. :: [P2] Update the remaining state-schema documentation

@steipete
steipete force-pushed the steipete/commitments-schema-v7 branch 2 times, most recently from d0fb3ee to ff79c42 Compare August 11, 2026 18:23
@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: L and removed size: M labels Aug 11, 2026
@steipete
steipete force-pushed the steipete/commitments-schema-v7 branch from ff79c42 to 7da5efb Compare August 11, 2026 18:38
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Aug 11, 2026
@steipete
steipete force-pushed the steipete/commitments-schema-v7 branch 2 times, most recently from 8a8ceda to 918cc84 Compare August 11, 2026 19:22
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

All rank-up moves from the latest review are addressed on head 918cc84ed4571c8368fab0b40e0fdeee8ef5abe7:

  • Doctor now validates both supported v5 and v6 shapes before any retirement, with refusal/rollback regressions for both paths.
  • Doctor records Retired shared state commitments table and indexes; state, restart-handoff, and command-level migration tests assert the visible result.
  • Doctor's successful retirement test inspects PRAGMA user_version = 7 and schema_meta.schema_version = 7 immediately after repair, before runtime reopen.
  • Native clients accept v7 and fail closed at v8+, with the exact macOS Swift lane green.
  • package.json shared-schema support metadata is aligned at v7.

Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/31527538577
Focused proof: 266 passed, 1 existing skip across the migration, Doctor, metadata, native, profile, secret, and restart-handoff files. Fresh full-branch P2 autoreview and TruffleHog are clean.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for exact head 918cc84ed4571c8368fab0b40e0fdeee8ef5abe7:

  • Focused unique-cache Vitest across migration, Doctor, package metadata, restart handoff, native guard, profiles, and secret store: 266 passed, 1 existing skip.
  • node --import tsx scripts/generate-kysely-types.mts --verify: clean.
  • node --max-old-space-size=8192 --import tsx scripts/generate-plugin-sdk-api-baseline.ts --check: clean.
  • node scripts/check-native-state-schema-version.mjs: v7 clean.
  • Targeted oxfmt, oxlint, docs MDX, changed-path classification, and git diff --check: clean.
  • Fresh full-branch autoreview through P2 plus TruffleHog: no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/31527538577 — success, including macOS Swift, iOS, Android, Node shards, and openclaw/ci-gate.
  • Repo-native review artifacts: READY FOR /prepare-pr, zero findings, issue valid, behavioral sweep passed.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 122176: hosted CI/Testbox gates passed.

All prior ClawSweeper rank-up moves are implemented; current-head re-review is in progress at https://github.com/openclaw/clawsweeper/actions/runs/31530291754.

Known proof gap: no live operator database was mutated. Both production migration entry paths are exercised against materialized v5/v6 databases, including damaged-schema refusal, preserved shared leases, visible Doctor output, and immediate atomic v7 markers.

@steipete
steipete force-pushed the steipete/commitments-schema-v7 branch from 918cc84 to 7a11bce Compare August 11, 2026 20:04
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 11, 2026
@steipete
steipete force-pushed the steipete/commitments-schema-v7 branch from 7a11bce to 8cfd4b3 Compare August 11, 2026 20:11
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 11, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 12, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for exact PR head 785c39e7e3c49beb4267377c29718d47e25dfdcf:

The latest ClawSweeper rank-up moves are satisfied: the shared schema-v7 retirement was explicitly maintainer-approved, and exact-head required CI is green. No live operator database was mutated; both production migration entry paths are exercised against materialized historical databases, including supported partial-additive layouts, damaged/dependent-schema refusal, preserved sibling state, visible Doctor output, and atomic v7 markers.

Merged as b6548e509aac607530247127a5c98ec49d88b904.

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

Labels

app: macos App: macos channel: voice-call Channel integration: voice-call docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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