Skip to content

test(durable): prove upgrade-safe workflow store lifecycle - #97666

Closed
mjnkao wants to merge 3 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-durable-batch-a-upgrade-safety
Closed

mjnkao wants to merge 3 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-durable-batch-a-upgrade-safety

Conversation

@mjnkao

@mjnkao mjnkao commented Jun 29, 2026

Copy link
Copy Markdown

Depends on:

This is the first follow-up slice for the native durable coordination work. It keeps the change focused on restart and upgrade safety so the new durable store has a clear technical foundation before higher-level coordination projections are reviewed.

What changed:

  • Adds tests proving an existing SQLite state database can be upgraded with the durable workflow tables without rewriting unrelated state.
  • Records durable schema lifecycle in durable_schema_migrations.
  • Exposes the current durable schema version in store stats.
  • Rejects databases with a newer durable schema version than the running code understands.
  • Adds recovery coverage for reopening the store after a gateway restart and marking interrupted running work as lost while leaving waiting work intact.

Why this matters:

  • Durable coordination is only useful if it survives OpenClaw upgrades and gateway restarts safely.
  • This PR is intentionally storage-local and does not introduce a scheduler, worker loop, external service dependency, or AICOS-specific behavior.

Review notes:

Validation:

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/durable/recovery.test.ts src/durable/sqlite-store.test.ts
  • pnpm db:kysely:check

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 29, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 1:18 AM ET / 05:18 UTC.

Summary
The branch adds an opt-in durable workflow store with schema lifecycle tracking, restart/upgrade tests, Gateway and CLI inspection surfaces, and agent/subagent durable lifecycle hooks.

PR surface: Source +5060, Tests +1809, Docs +14, Generated +306, Other +3. Total +7192 across 37 files.

Reproducibility: yes. from source inspection: a database with a newer durable_schema_migrations version will still pass through durable workflow table/index creation and ensureColumn calls before the version error is raised. I did not run a mutating local reproduction because this review is read-only.

Review metrics: 2 noteworthy metrics.

  • Durable schema surfaces: 1 lifecycle table added, 7 workflow tables added. New persistent shared-state tables make upgrade, backup, retention, and downgrade behavior material before merge.
  • Operator/config surfaces: 4 env controls, 1 Gateway RPC, 1 CLI group added. These opt-in controls and inspection APIs can affect enabled deployments even when default-off.

Stored data model
Persistent data-model change detected: database schema: src/durable/sqlite-store.test.ts, database schema: src/state/openclaw-state-schema.generated.ts, database schema: src/state/openclaw-state-schema.sql, serialized state: src/agents/tools/sessions-spawn-tool.ts, serialized state: src/commands/durable.ts, serialized state: src/state/openclaw-state-db.generated.d.ts, and 15 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: partial_overlap
Canonical: #97508
Summary: This PR is a stacked upgrade-safety follow-up on the still-open durable coordination implementation, while the RFC remains the architecture decision point.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Move the future-schema version check before durable workflow DDL or column backfills.
  • [P1] Add a regression proving a future-version durable database remains unmodified after openDurableWorkflowSqliteStore throws.
  • [P1] Add redacted real upgrade/restart lifecycle proof from a real setup, such as terminal output, logs, or a linked artifact.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists unit-test and guardrail commands, but it does not show after-change real behavior output for the upgrade/restart lifecycle slice; add redacted terminal output, logs, or linked artifacts, then update the PR body for a fresh ClawSweeper review.

Risk before merge

  • [P1] Merging this branch accepts new shared SQLite durable workflow tables, schema lifecycle behavior, env controls, and Gateway/CLI inspection surfaces before the base durable architecture PRs are settled.
  • [P1] Older code opening a future durable schema can still mutate the durable workflow tables/indexes/columns before throwing, weakening the upgrade-safety guarantee this PR is meant to prove.
  • [P1] The durable kernel overlaps current Task Flow, background task, subagent, and session-state ownership, so maintainers still need to choose the long-term boundary.
  • [P1] The contributor has not supplied real after-change upgrade/restart lifecycle proof beyond unit and guardrail command names.

Maintainer options:

  1. Repair schema guard first (recommended)
    Move the future-version check after creating only durable_schema_migrations and before any durable workflow table/index/column DDL, then add a regression proving the failed open is non-mutating.
  2. Hold for base boundary
    Pause this stacked follow-up until maintainers decide whether the durable ledger belongs in core, Task Flow internals, or a narrower shared task/session module.
  3. Accept experimental storage risk
    Maintainers may deliberately accept the env-gated schema and runtime hooks now, but that should be explicit because CI does not settle upgrade or owner-boundary risk.

Next step before merge

  • [P1] Human review remains because missing real behavior proof and durable architecture direction cannot be supplied by automation, even though the schema-ordering defect is mechanical.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds no dependencies, workflows, package-resolution changes, secret-handling changes, or third-party code execution surface.

Review findings

  • [P2] Check future schema versions before mutating — src/durable/sqlite-store.ts:525
Review details

Best possible solution:

Fix the schema-version guard before durable workflow DDL, add a non-mutation regression for future schemas, supply redacted real behavior proof, and merge only after maintainers accept the durable coordination boundary.

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

Yes from source inspection: a database with a newer durable_schema_migrations version will still pass through durable workflow table/index creation and ensureColumn calls before the version error is raised. I did not run a mutating local reproduction because this review is read-only.

Is this the best way to solve the issue?

No as written: the schema-version guard should run before any durable workflow schema mutation, and the broader durable-kernel placement still needs maintainer direction. The narrow repair is straightforward, but merge readiness also needs real upgrade/restart proof.

Full review comments:

  • [P2] Check future schema versions before mutating — src/durable/sqlite-store.ts:525
    ensureDurableWorkflowSchema creates the durable workflow tables/indexes and runs column backfills before it checks durable_schema_migrations. An older OpenClaw binary opening a future-version durable DB can therefore mutate the DB and only then throw, so move the version guard ahead of all workflow DDL and add a regression that the failed open leaves the schema untouched.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7e2f425c492c.

Label changes

Label justifications:

  • P2: This is a substantial opt-in core/storage improvement with compatibility impact, but no urgent shipped regression or emergency is shown.
  • merge-risk: 🚨 compatibility: The PR changes shared SQLite schema, adds env controls, and introduces CLI/Gateway surfaces whose upgrade behavior must be safe.
  • merge-risk: 🚨 session-state: The durable ledger records agent turn, subagent, child-link, recovery, and session-linked coordination state.
  • merge-risk: 🚨 availability: The branch adds opt-in Gateway startup reconciliation and a periodic recovery worker that can affect enabled Gateway runtime behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body lists unit-test and guardrail commands, but it does not show after-change real behavior output for the upgrade/restart lifecycle slice; add redacted terminal output, logs, or linked artifacts, then update the PR body for a fresh ClawSweeper review.
Evidence reviewed

PR surface:

Source +5060, Tests +1809, Docs +14, Generated +306, Other +3. Total +7192 across 37 files.

View PR surface stats
Area Files Added Removed Net
Source 26 5062 2 +5060
Tests 7 1809 0 +1809
Docs 1 14 0 +14
Config 0 0 0 0
Generated 2 306 0 +306
Other 1 4 1 +3
Total 37 7195 3 +7192

What I checked:

  • Repository policy applied: Root and scoped AGENTS.md files were read; root policy treats stored data models, migrations, config/env surfaces, Gateway methods, startup behavior, and session state as compatibility-sensitive review surfaces. (AGENTS.md:29, 7e2f425c492c)
  • Future schema check runs after mutations: In the PR head, ensureDurableWorkflowSchema creates durable_schema_migrations plus all durable workflow tables and indexes, then runs ensureColumn on workflow tables before calling ensureDurableWorkflowSchemaVersion. (src/durable/sqlite-store.ts:335, 5faa04836991)
  • Regression only asserts throw: The future-version test creates only durable_schema_migrations and asserts openDurableWorkflowSqliteStore throws, but it does not assert the failed open left durable workflow tables and columns unmodified. (src/durable/sqlite-store.test.ts:37, 5faa04836991)
  • Current main lacks durable workflow implementation: A current-main search found no openDurableWorkflowSqliteStore, durable.coordination, OPENCLAW_DURABLE, durable_schema, or durable_workflow implementation under source/docs/scripts/packages, so this PR is not obsolete on main. (7e2f425c492c)
  • Existing orchestration surface: Current docs already describe Task Flow as durable multi-step flow tracking across gateway restarts, so the new durable kernel is an overlapping coordination surface that needs an owner-boundary decision. Public docs: docs/automation/taskflow.md. (docs/automation/taskflow.md:10, 7e2f425c492c)
  • Existing shared state tables: Current main already stores task_runs, subagent_runs, and flow_runs in the shared state schema, making this PR a new persistent coordination ledger rather than a small isolated test-only change. (src/state/openclaw-state-schema.sql:1004, 7e2f425c492c)

Likely related people:

  • steipete: Authored merged shared SQLite work for task/task-flow state and adjacent subagent/plugin SQLite persistence, which is the closest current-main storage ownership trail for this durable ledger. (role: recent shared-state SQLite contributor; confidence: high; commits: d115fb4cf9f9, 5374c7a8a208, bc848b367f0b; files: src/state/openclaw-state-schema.sql, src/tasks/task-registry.store.sqlite.ts, src/tasks/task-flow-registry.store.sqlite.ts)
  • vincentkoc: Merged Task Flow CLI, operator coverage, restore, and maintenance work in the orchestration surface that the durable kernel overlaps. (role: Task Flow and task operator surface contributor; confidence: high; commits: efe9464f5f70, 12bd6b7bb944; files: docs/automation/taskflow.md, src/tasks/task-flow-registry.store.sqlite.ts, src/commands/tasks.ts)
  • mbelinky: Merged early Task Flow registry and flow-control scaffold PRs, making them relevant for owner-boundary review between Task Flow and the proposed durable kernel. (role: Task Flow scaffold contributor; confidence: medium; commits: 7590c22db7d2; files: src/tasks/task-flow-registry.store.sqlite.ts, src/state/openclaw-state-schema.sql)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 29, 2026
@mjnkao

mjnkao commented Jun 29, 2026

Copy link
Copy Markdown
Author

Automated reviewer stack note:

This is Batch A in the OpenClaw-X durable-core stack. It depends on #97507 and #97508. GitHub currently shows this PR against main, so the commit list may include the PR2 foundation commit. The intended unique review scope for Batch A is the restart/upgrade proof and SQLite schema lifecycle layer after #97508.

Internal mapping: Batch A = internal PR3 + PR4.

@mjnkao

mjnkao commented Jul 1, 2026

Copy link
Copy Markdown
Author

Closing this follow-up batch for now to reduce reviewer noise while the durable core boundary is resolved in #97507 and #97508. This slice is not abandoned; it will be rebuilt or resubmitted only after the durable core base is accepted.

@mjnkao mjnkao closed this Jul 1, 2026
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 commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant