Skip to content

fix(state): keep agent media floor stable across schema upgrades - #122008

Closed
steipete wants to merge 4 commits into
mainfrom
codex/fix-agent-media-schema-floor
Closed

steipete wants to merge 4 commits into
mainfrom
codex/fix-agent-media-schema-floor

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a Gateway with an already-migrated v16 agent database could park during an upgrade to schema v17 and incorrectly require openclaw doctor --fix. The media guard treated every version below the current structural schema as pre-media state, so it blocked the online v16-to-v17 lease-table retirement before that migration could run.

Why This Change Was Made

The completed media rewrite is now represented by its own durable schema floor: v16, with v15 as the Doctor-owned predecessor. Normal runtime opens accept v16 and converge it through the canonical v17 structural migration. Doctor first crosses the real v15-to-v16 media fence, then independently converges the database to the current structural schema and records the actual final registry version.

True pre-media databases remain fail-closed behind Doctor. No SQLite schema version is added or changed by this repair.

User Impact

Operators upgrading from an already-migrated v16 agent database to v17 no longer see the Gateway park for an offline migration that has already completed. Legacy v15 media state still requires and receives the existing Doctor rewrite.

Evidence

  • Direct runtime regression: normal open accepts v16, migrates to v17, and removes the retired state_leases table.
  • Doctor regression: v15 media data rewrites to the fixed v16 floor, then converges to v17 with the retired lease table removed.
  • Blacksmith Testbox: 121 tests passed, 6 skipped across agent DB, media migration, and target discovery (run).
  • Autoreview and changelog review: clean, no accepted/actionable findings.
  • git diff --check: clean.

Provenance: the latent current-version coupling was made visible when #121943 advanced the structural schema from v16 to v17.

@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.

ClawSweeper review complete

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

View the workflow run.

@steipete steipete self-assigned this Aug 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete
steipete force-pushed the codex/fix-agent-media-schema-floor branch from 2b173f6 to 777de21 Compare August 11, 2026 11:39
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 11, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The branch separates the completed media rewrite from the moving database schema version, allows normal v16-to-v17 upgrades, and refreshes Doctor’s database registrations.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The historical repair is coherent, but its remaining behavior and persisted-state integration no longer match the current migration contract.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its historical database regressions support the v17 repair, but do not establish compatibility of a reconciled candidate with the current schema-24 upgrade pipeline.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open for an owner decision. Merged work now covers Doctor convergence and registry recovery, but the branch’s online-upgrade behavior differs from the shipped stopped-writer contract. Maintainer ownership also prevents automated cleanup.

Priority: P2
Reviewed head: 231e061fc939cd13397644768418ef3717e2eeae
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this historical online-v16-upgrade proposal be retired in favor of the shipped Doctor-owned upgrade contract, or should a distinct online-upgrade capability be pursued?
  • Recommendation: Retain Doctor ownership: Retire the production proposal after confirming any useful historical coverage is preserved in the existing test work.
  • Why: The remaining behavioral difference concerns migration ownership, and the existing acceptance explicitly requires stopped writers.

Before merge

  • Resolve merge risk - The online v16 admission proposal is unreconciled with the shipped stopped-writer identity migration. No pinned merge result or persisted-state upgrade evidence establishes safe integration with schema 24.
  • Resolve merge risk - Retaining the +51 production-line repair would add convergence machinery alongside work now handled by the canonical Doctor owner; consolidate the added helper and duplicated completion paths before carrying them forward.
  • Complete next step - Confirm whether to retire the online-upgrade proposal; if retained, reconcile it with current main and verify persisted-state compatibility before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Agent review details

How this fits together

Per-agent SQLite databases hold session transcripts and agent state. Database admission and Doctor coordinate schema upgrades before that state becomes available to the Gateway.

flowchart TD
  A[Existing agent database] --> B[Database admission]
  B --> C{Media rewrite completed?}
  C -->|No| D[Doctor media rewrite]
  C -->|Yes| E[Structural schema migration]
  D --> E
  E --> F[Registry refresh]
  F --> G[Gateway session access]
Loading

Technical review

Best possible solution:

Keep schema advancement and registration publication in the current Doctor owner, preserving stopped-writer migrations; retain only independently useful regression coverage or a demonstrated remaining defect.

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

No current-main reproduction of the original accidental v16-to-v17 parking failure was established. The historical defect is source-backed, but current runtime refusal is an explicit migration contract.

Is this the best way to solve the issue?

No, this branch is no longer the best direct landing path: current Doctor already owns convergence and registration recovery, while online admission requires a separate decision against the shipped migration boundary.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Preserve the shipped migration owner (recommended)
    Pause this branch and retain the current Doctor pipeline, carrying forward only useful coverage after owner confirmation.
  2. Reconcile a demonstrated remaining defect
    If a current defect remains, repair it within the canonical migration owner and verify fresh initialization, historical-state upgrade, writer refusal, and registry agreement.

Security

None.

Evidence

What I checked:

PR surface

Source +51, Tests +44, Generated 0. Total +95 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 5 66 15 +51
Tests 3 49 5 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 17 17 17 0
Other 0 0 0 0
Total 25 132 37 +95

Review metrics

Metric Value Why it matters
Production versus tests Production +66/-15 (net +51); tests +49/-5 (net +44); generated baselines net 0 Production growth implements separate convergence plumbing that should be absorbed into the current migration owner if retained.
Upgrade admission 1 runtime version gate changed; 0 schema-version bumps Admitting v16 at normal open changes upgrade ownership even without changing the schema version.

Labels

Label changes:

  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This remains an upgrade-contract review, while current main already provides Doctor convergence and registry recovery.
  • merge-risk: 🚨 compatibility: The proposed online admission differs from the shipped stopped-writer upgrade requirement.
  • merge-risk: 🚨 session-state: Safe integration must preserve persisted transcripts, identity migrations, and database-registration agreement.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rank-up moves

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

  • Resolve whether the online admission proposal should survive the shipped Doctor-owned migration contract.
  • If production work remains, reconcile it within the current owner and verify persisted-state upgrades, stopped-writer refusal, and registry agreement.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-11T12:54:42.484Z sha bbc3b7a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T23:11:18.267Z sha 231e061 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T00:05:26.400Z sha 231e061 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T22:51:29.479Z sha 231e061 :: needs maintainer review before merge. :: none
  • reviewed August 20, 2026, 1:48 AM ET / 05:48 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T07:40:09.198Z sha 231e061 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T01:49:30.945Z sha 231e061 :: blocked before merge. :: none
  • reviewed 2026-09-27T10:04:44.881Z sha 231e061 :: blocked before merge. :: none

Reviewed October 3, 2026, 12:41 PM ET / 16:41 UTC (Revision 10).

@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 11, 2026
@steipete
steipete force-pushed the codex/fix-agent-media-schema-floor branch from 4a85ddb to bbc3b7a Compare August 11, 2026 12:48
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Oct 3, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks. The independent media-migration floor was implemented in #130986 and is now used by admission, prerequisite migration and media persistence. Current migration code also converges and registers the final schema when no content rewrite is needed. The useful behavior in this PR is covered by those owners, so closing as superseded.

@RomneyDa
RomneyDa deleted the codex/fix-agent-media-schema-floor branch October 22, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

2 participants