Skip to content

feat(durable): add workflow kernel primitives - #97468

Closed
mjnkao wants to merge 2 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-x-durable-pr2-core-kernel
Closed

mjnkao wants to merge 2 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-x-durable-pr2-core-kernel

Conversation

@mjnkao

@mjnkao mjnkao commented Jun 28, 2026

Copy link
Copy Markdown

Summary

This PR adds the native durable workflow kernel primitives.

It introduces:

  • durable workflow run, step, event, ref, link, timer, and signal types;
  • SQLite local-first store;
  • run and step claims;
  • timer and signal recovery primitives;
  • fan-in helper;
  • in-process workflow registry;
  • one-shot durable executor for registered safe step handlers.

Why

This creates the minimal native kernel needed before OpenClaw can make long-running agent work restart-visible, retryable, and resumable.

Stack Note

This is PR 2 in the durable core stack and should be reviewed after PR 1.

GitHub may show cumulative diff until PR 1 is merged because the branch is pushed from a fork and the upstream repository does not allow branch bases for this stack.

Incremental branch:

  • mjnkao:codex/openclaw-x-durable-pr2-core-kernel

Validation

  • npm test -- --run src/durable src/gateway/server-methods/durable.test.ts extensions/workboard/src/gateway.test.ts extensions/workboard/src/store.test.ts
  • npm run tsgo:core
  • npm run build

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XL triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 28, 2026, 6:23 AM ET / 10:23 UTC.

Summary
The branch adds durable workflow planning docs, new workflow run/step/event/ref/link/timer/signal types, a sidecar SQLite store, recovery/fan-in/executor primitives, tests, and a raw SQLite guardrail allowlist entry.

PR surface: Source +3127, Tests +934, Docs +2378, Other +3. Total +6442 across 18 files.

Reproducibility: not applicable. this is a new core feature PR rather than a bug report. The blocker is source-contract and upgrade-safety review, not a current-main reproduction path.

Review metrics: 2 noteworthy metrics.

  • Env/config surfaces: 4 added. The new OPENCLAW_DURABLE_* knobs affect operator setup and are compatibility-sensitive API surface.
  • Persistent stores: 1 dedicated SQLite DB added. A separate runtime database needs explicit lifecycle review before merge because it can bypass shared state backup, doctor, and migration expectations.

Stored data model
Persistent data-model change detected: vector/embedding metadata: src/durable/executor.ts, vector/embedding metadata: src/durable/recovery.test.ts, vector/embedding metadata: src/durable/recovery.ts, vector/embedding metadata: src/durable/registry.ts, vector/embedding metadata: src/durable/sqlite-store.test.ts, vector/embedding metadata: src/durable/types.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
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:

  • Align durable workflow storage with the shared state DB or document an approved dedicated DB lifecycle with upgrade proof.
  • [P1] Add redacted real behavior proof from an enabled durable workflow path, not only test command names.
  • [P1] Update the PR body into the required problem, user impact, and evidence sections so reviewers can evaluate the product direction.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists test/build command names but no redacted terminal output, logs, recording, or artifact from an enabled durable workflow run; the contributor should add proof and update the PR body to trigger a fresh review.

Risk before merge

  • [P1] Merging as-is would create workflow run, step, timer, signal, and recovery state outside the canonical shared state DB, leaving backup, doctor, schema-version, and upgrade behavior unproven.
  • [P1] The branch adds four OPENCLAW_DURABLE_* environment/config surfaces without maintainer-visible proof that existing defaults or a narrower product shape cannot cover the need.
  • [P1] The PR is a draft stack member with prerequisite and successor draft PRs still open, so maintainers need stack-order and cumulative-diff coordination before merge.
  • [P1] The PR body has command names but no redacted terminal output, logs, recording, or artifact showing an enabled durable workflow path running after the change.

Maintainer options:

  1. Align storage before merge (recommended)
    Move the workflow tables into the canonical shared state DB or add a maintainer-approved dedicated database lifecycle with schema versioning, backup/doctor coverage, and upgrade tests.
  2. Pause until the stack is reviewable
    Wait for the prerequisite and successor draft PRs to be rebased or split so maintainers can judge this kernel as a clean incremental diff.
  3. Accept the sidecar deliberately
    Maintainers can choose to accept the flagged sidecar only with explicit product ownership of its backup, upgrade, and recovery limitations.

Next step before merge

  • [P1] Manual review is needed because the blocker is an architecture/storage lifecycle decision plus stack coordination and contributor proof, not a narrow mechanical repair.

Security
Cleared: No concrete supply-chain issue was found; the diff does not change dependencies, workflows, lockfiles, package scripts, or secret handling, and the storage lifecycle concern is tracked as functional merge risk.

Review findings

  • [P1] Use the canonical durable state database — src/durable/config.ts:16
Review details

Best possible solution:

Align durable workflow state with the database-first control-plane contract, or get explicit maintainer approval for a dedicated DB lifecycle with schema versioning, backup/doctor coverage, upgrade tests, and real enabled-path proof.

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

Not applicable; this is a new core feature PR rather than a bug report. The blocker is source-contract and upgrade-safety review, not a current-main reproduction path.

Is this the best way to solve the issue?

No; the workflow kernel is a plausible direction, but putting persistent coordination state in a new sidecar DB is not the best merge shape without lifecycle approval and proof.

Full review comments:

  • [P1] Use the canonical durable state database — src/durable/config.ts:16
    resolveDurableWorkflowSqlitePath makes workflow state live in a new state/durable/workflows.sqlite sidecar while the PR also allowlists that store for direct DatabaseSync. Current OpenClaw storage policy puts shared coordination state, task/flow ledgers, backup metadata, and migration state in state/openclaw.sqlite; with this sidecar, enabled workflow runs/steps/timers/signals would sit outside existing backup, doctor, and schema compatibility checks. Please either model these tables in the canonical state DB or add an approved dedicated-DB lifecycle with schema versioning, backup/doctor coverage, and upgrade tests.
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8d168c836af3.

Label changes

Label justifications:

  • P2: This is a substantial core feature with bounded but meaningful merge risk, not an urgent shipped regression.
  • merge-risk: 🚨 compatibility: The PR adds env knobs and a separate persistent SQLite path that could bypass existing upgrade, migration, backup, and doctor contracts.
  • merge-risk: 🚨 session-state: Workflow runs, steps, timers, signals, and recovery rows are agent/session coordination state that can become stranded or stale outside the canonical lifecycle.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • 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 test/build command names but no redacted terminal output, logs, recording, or artifact from an enabled durable workflow run; the contributor should add proof and update the PR body to trigger a fresh review.
Evidence reviewed

PR surface:

Source +3127, Tests +934, Docs +2378, Other +3. Total +6442 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 8 3127 0 +3127
Tests 4 934 0 +934
Docs 5 2378 0 +2378
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 1 +3
Total 18 6443 1 +6442

What I checked:

  • Repository storage policy: Root policy requires OpenClaw runtime state to use canonical stores and says global runtime state should use state/openclaw.sqlite unless a dedicated SQLite DB clearly fits with its owner/schema. (AGENTS.md:76, 8d168c836af3)
  • Current database-first architecture: The database-first docs define the global database as the control-plane owner for shared gateway state, task/flow ledgers, plugin state, scheduler runtime state, backup metadata, and migration state. Public docs: docs/refactor/database-first.md. (docs/refactor/database-first.md:17, 8d168c836af3)
  • Shared state schema already owns adjacent ledgers: Current main has schema_meta, task_runs, flow_runs, migration_runs, migration_sources, and backup_runs in the shared state schema, which is the lifecycle this durable state would need to fit or intentionally amend. (src/state/openclaw-state-schema.sql:68, 8d168c836af3)
  • PR sidecar path: The PR resolves durable workflow storage to state/durable/workflows.sqlite and adds OPENCLAW_DURABLE_WORKFLOWS_DB_PATH as an override. (src/durable/config.ts:16, ca3efe44873f)
  • PR opens a separate SQLite database: The new store opens its own DatabaseSync handle and initializes its own schema outside the shared state DB lifecycle. (src/durable/sqlite-store.ts:521, ca3efe44873f)
  • Raw SQLite guardrail bypass: The PR adds src/durable/sqlite-store.ts to the direct DatabaseSync allowlist instead of routing this workflow store through the established shared-state/Kysely boundary. (scripts/check-kysely-guardrails.mjs:56, ca3efe44873f)

Likely related people:

  • giodl73-repo: Current blame/log tie the database-first docs, shared state DB lifecycle code, and raw SQLite guardrail baseline to recent database/state refactor work. (role: recent area contributor; confidence: high; commits: 4010b81a77f4, 82d05bdc461e; files: docs/refactor/database-first.md, src/state/openclaw-state-db.ts, scripts/check-kysely-guardrails.mjs)
  • steipete: History shows recent database-first runtime-state refactor work defining the global/per-agent SQLite contract this PR would need to fit or amend. (role: architecture sponsor; confidence: medium; commits: 410bbe69e8a4; files: docs/refactor/database-first.md, src/state/openclaw-state-db.ts)
  • mbelinky: History shows task and flow SQLite substrate work on the adjacent coordination surfaces named by the durable workflow bridge docs. (role: adjacent TaskFlow contributor; confidence: medium; commits: 8d63c5b3e617, faf90e219844; files: src/tasks/task-flow-registry.store.sqlite.ts, src/tasks/task-registry.store.sqlite.ts)
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. labels Jun 28, 2026

mjnkao commented Jun 28, 2026

Copy link
Copy Markdown
Author

Superseded by #97508. The replacement implementation PR is a single vertical slice on latest main, uses the shared state/openclaw.sqlite lifecycle, keeps the feature disabled by default, and includes regression proof for non-mutating disabled Gateway reads.

@mjnkao mjnkao closed this Jun 28, 2026
@mjnkao
mjnkao deleted the codex/openclaw-x-durable-pr2-core-kernel branch June 30, 2026 15:11
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 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