Skip to content

feat(durable): expose gateway and CLI lifecycle - #97469

Closed
mjnkao wants to merge 3 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-x-durable-pr3-gateway-cli
Closed

mjnkao wants to merge 3 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-x-durable-pr3-gateway-cli

Conversation

@mjnkao

@mjnkao mjnkao commented Jun 28, 2026

Copy link
Copy Markdown

Summary

This PR exposes the durable workflow kernel through OpenClaw Gateway and CLI lifecycle paths.

It adds:

  • durable agent turn lifecycle recording;
  • durable gateway startup record and startup reconciliation;
  • recovery worker startup hook;
  • openclaw durable CLI inspection commands;
  • durable.coordination.get gateway read API;
  • gateway protocol documentation.

Why

The kernel is useful only if accepted agent work becomes visible in normal OpenClaw runtime paths. This PR records agent turns durably and gives operators a native inspection path.

Stack Note

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

GitHub may show cumulative diff until previous PRs are 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-pr3-gateway-cli

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 gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations size: XL triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. 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:22 AM ET / 10:22 UTC.

Summary
This PR adds a durable workflow runtime slice with SQLite storage, gateway lifecycle recording, a recovery worker, CLI inspection/control commands, a durable.coordination.get gateway RPC, and protocol/planning docs.

PR surface: Source +4734, Tests +1148, Docs +2390, Other +3. Total +8275 across 33 files.

Reproducibility: yes. for the review finding: source inspection shows durable.coordination.get opens the durable store without checking OPENCLAW_DURABLE_WORKFLOWS. I did not run the gateway path because this was a read-only review.

Review metrics: 3 noteworthy metrics.

  • Config/env surfaces: 5 added. The feature flag, DB path, recovery interval, stale threshold, and heartbeat interval affect operator setup and upgrade expectations.
  • Persistent store surface: 1 dedicated SQLite DB, 7 tables. A new durable workflow database needs schema, migration, backup, and doctor expectations reviewed before merge.
  • Operator lifecycle controls: 1 RPC added, 1 CLI group with 5 write actions. The new read API and cancel/retry/resume/signal/mark-unknown commands change how operators inspect or mutate workflow state.

Stored data model
Persistent data-model change detected: serialized state: src/cli/program/register.durable.ts, serialized state: src/commands/durable.ts, vector/embedding metadata: src/durable/coordination-projection.test.ts, vector/embedding metadata: src/durable/executor.ts, vector/embedding metadata: src/durable/recovery.test.ts, vector/embedding metadata: src/durable/recovery.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

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

  • [P1] Add redacted real behavior proof for gateway lifecycle recording, durable.coordination.get, and openclaw durable on a real or packaged setup.
  • [P1] Fix the feature-flag/store-creation finding and add a focused disabled-by-default regression test.
  • Resolve the stacked predecessors or split/rebase this PR so maintainers can review the true incremental gateway/CLI diff.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists tests/build commands but does not include after-fix real gateway or CLI output; add redacted terminal output, copied live output, logs, or a recording, and update the PR body to trigger re-review.

Risk before merge

  • [P1] The PR adds a new persistent SQLite data model and five durable env/config surfaces, so upgrade, doctor, backup, and operator documentation expectations need maintainer-visible approval before merge.
  • [P1] The PR wires gateway startup recovery and agent-turn lifecycle recording into gateway hot paths; unit tests alone do not prove disabled-by-default, fresh-install, restart, and upgrade behavior.
  • [P1] The branch is cumulative with two open draft predecessor PRs, so maintainers cannot review this PR as a clean incremental gateway/CLI diff until the stack is resolved or split.
  • [P1] The PR body lists tests/build commands but no after-fix real gateway or CLI output, so the external-contributor proof gate is still missing.

Maintainer options:

  1. Gate and document the durable prototype before merge (recommended)
    Require the gateway RPC, CLI behavior, state path, and env flags to preserve disabled-by-default behavior and include focused tests/docs for fresh and existing installs.
  2. Accept the durable prototype as maintainer-owned experimental surface
    Maintainers could intentionally accept the new durable DB and lifecycle semantics as opt-in prototype behavior, but should do so with explicit upgrade and operator-risk acknowledgment.
  3. Pause until the stack is reviewable
    Because this branch includes cumulative docs and kernel primitives from open predecessor PRs, maintainers can pause this PR until those predecessors land or the branch is split.

Next step before merge

  • [P1] Needs maintainer/product review and contributor real behavior proof; the narrow feature-flag defect is repairable, but durable state direction and stack ordering are human gates.

Security
Cleared: No malicious or concrete supply-chain issue was found; the security-sensitive parts remain privileged operator surfaces and persistent state semantics.

Review findings

  • [P2] Gate durable reads behind the feature flag — src/gateway/server-methods/durable.ts:26
Review details

Best possible solution:

Keep this as a draft stack item until the durable RPC and lifecycle paths are explicitly gated, the durable state/env contract is reviewed, predecessor PRs are resolved, and real gateway/CLI proof is added.

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

Yes for the review finding: source inspection shows durable.coordination.get opens the durable store without checking OPENCLAW_DURABLE_WORKFLOWS. I did not run the gateway path because this was a read-only review.

Is this the best way to solve the issue?

No. Exposing durable lifecycle state is a plausible direction, but this branch is not the best merge shape until disabled-by-default behavior, state/env contracts, stack ordering, and real behavior proof are settled.

Full review comments:

  • [P2] Gate durable reads behind the feature flag — src/gateway/server-methods/durable.ts:26
    The rest of the durable lifecycle path no-ops unless OPENCLAW_DURABLE_WORKFLOWS is enabled, but this registered operator.read RPC opens the durable store unconditionally. Since openDurableWorkflowSqliteStore creates state/durable/workflows.sqlite, a read against a default install mutates persistent state and makes the disabled prototype appear active; return a disabled error or avoid opening the store unless the feature is enabled.
    Confidence: 0.91

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 draft feature with bounded durable runtime/gateway/CLI impact, not an urgent live regression.
  • merge-risk: 🚨 compatibility: The PR adds env flags, a new state DB path, a gateway RPC, and CLI lifecycle commands that can affect existing operators and upgrades.
  • merge-risk: 🚨 session-state: The PR records and reconciles agent turn lifecycle state, including terminal/lost run states, which can affect how session and run state is interpreted.
  • merge-risk: 🚨 availability: The PR adds gateway startup/recovery work and store opening in runtime paths, so a store or feature-gating bug can affect gateway operation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • 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 tests/build commands but does not include after-fix real gateway or CLI output; add redacted terminal output, copied live output, logs, or a recording, and update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +4734, Tests +1148, Docs +2390, Other +3. Total +8275 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 20 4734 0 +4734
Tests 6 1148 0 +1148
Docs 6 2390 0 +2390
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 1 +3
Total 33 8276 1 +8275

What I checked:

  • Live PR scope: Live PR metadata shows a draft external PR at f1e88d4 with 33 changed files across durable runtime, gateway server methods, CLI command registration, docs, and guardrail scripts. (f1e88d423e7f)
  • Current main lacks the proposed durable core surface: Current main has no src/durable tree and no matches for the proposed durable workflow flag, CLI command, or gateway RPC; only unrelated WhatsApp durable receive constants matched the broad durable search. (8d168c836af3)
  • Feature flag and state path contract: The PR adds OPENCLAW_DURABLE_WORKFLOWS and OPENCLAW_DURABLE_WORKFLOWS_DB_PATH, resolving the default durable store to state/durable/workflows.sqlite. (src/durable/config.ts:7, f1e88d423e7f)
  • Gateway lifecycle is feature-gated: Gateway startup recording returns early when durable workflows are disabled, showing the intended disabled-by-default contract for runtime lifecycle writes. (src/durable/startup.ts:15, f1e88d423e7f)
  • Review finding source: The new durable.coordination.get handler opens the durable SQLite store unconditionally before reading a run, without checking the durable feature flag. (src/gateway/server-methods/durable.ts:26, f1e88d423e7f)
  • Store creation side effect: openDurableWorkflowSqliteStore resolves the durable DB path, creates the parent directory, opens DatabaseSync, and ensures schema, so a read call can create persistent state on a default install. (src/durable/sqlite-store.ts:517, f1e88d423e7f)

Likely related people:

  • giodl73-repo: Current-main blame/log for the gateway method registry, agent handler, gateway run loop, and CLI command registry all point to the recent PR 95846 refactor by this author/merger; the history is shallow, so this is a routing hint rather than full durable ownership. (role: recent adjacent contributor; confidence: low; commits: 4010b81a77f4; files: src/gateway/server-methods.ts, src/gateway/server-methods/agent.ts, src/cli/gateway-cli/run-loop.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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 28, 2026

mjnkao commented Jun 28, 2026

Copy link
Copy Markdown
Author

Superseded by #97508. The replacement implementation PR keeps Gateway/CLI review together with the storage and subagent fan-in changes so agent reviewers can see the complete boundary.

@mjnkao mjnkao closed this Jun 28, 2026
@mjnkao
mjnkao deleted the codex/openclaw-x-durable-pr3-gateway-cli 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

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: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. 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