Skip to content

feat(durable): add coordination projections for agent work - #97667

Closed
mjnkao wants to merge 6 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-durable-batch-b-coordination-projection
Closed

mjnkao wants to merge 6 commits into
openclaw:mainfrom
mjnkao:codex/openclaw-durable-batch-b-coordination-projection

Conversation

@mjnkao

@mjnkao mjnkao commented Jun 29, 2026

Copy link
Copy Markdown

Depends on:

This PR adds the first product-facing durable coordination slice without turning OpenClaw into a general-purpose workflow engine. It gives long-running agent work stable intake identity, branch/report route identity, and an optional projection into existing Task Flow state.

What changed:

  • Adds acceptDurableWorkflowIntake, a small idempotent frontdoor helper for creating a durable run, optional input ref, and optional initial step.
  • Adds durable report routes for branch-aware progress/fan-in metadata.
  • Adds a Task Flow projection bridge that maps a durable run into Task Flow status/state/wait metadata.

Why this matters:

  • Multi-step agent work needs stable IDs that survive gateway restart and do not rely on one chat/session channel as the source of truth.
  • Branch/report routes make fan-out/fan-in state explicit, reducing the chance that parallel subagent results are mixed together.
  • Task Flow integration shows how Durable Core can complement an existing OpenClaw primitive instead of creating a parallel orchestration product.

Partial acceptance path:

  • Commit 1 (feat(durable): add workflow intake primitive) is independent.
  • Commit 2 (feat(durable): add branch report routes) is independent once the durable store/ref primitives from feat(durable): add opt-in agent coordination kernel #97508 exist.
  • Commit 3 (feat(durable): project runs into taskflow state) is intentionally isolated. If maintainers want the core intake/routes first but want to revisit Task Flow projection semantics, this final commit can be dropped or deferred without invalidating the first two commits.

Boundaries:

  • No AICOS names, schemas, or MCP-specific semantics.
  • No Workboard dependency from Durable Core.
  • No worker loop or retry-policy changes in this PR.
  • Projection writes are best-effort and must not break durable recovery or live agent execution.

Review notes:

Validation:

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/durable/intake.test.ts src/durable/routes.test.ts src/durable/taskflow-bridge.test.ts src/tasks/task-flow-registry.test.ts
  • Full stacked check also passed on PR-C: node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/durable src/tasks/task-flow-registry.test.ts

@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 PR adds opt-in durable workflow intake/routes, shared SQLite durable state, CLI/Gateway inspection, agent/subagent lifecycle hooks, and Task Flow projection into persisted flow state.

PR surface: Source +5440, Tests +2144, Docs +14, Generated +306, Other +3. Total +7907 across 43 files.

Reproducibility: yes. Source inspection gives a high-confidence reproduction path: create a managed Task Flow with existing stateJson, sync a durable projection, and the patch replaces that state with only durable metadata.

Review metrics: 2 noteworthy metrics.

  • Config/env surfaces: 4 added. New durable feature, heartbeat, recovery interval, and stale-turn env controls change operator behavior when enabled.
  • Shared SQLite schema: 8 tables added. Seven durable workflow tables plus a schema lifecycle table make upgrade, retention, backup, and doctor behavior material before merge.

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 19 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #97667
Summary: This PR is the current coordination-projection slice in an open durable-workflow stack; the RFC, base kernel, upgrade-safety, and Workboard PRs are dependencies or adjacent slices, not merged replacements.

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: 🧂 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:

  • [P1] Fix the Task Flow stateJson preservation bug and add a regression with pre-existing flow state.
  • [P1] Add redacted real behavior proof for the projection path, such as terminal output showing durable state syncing into Task Flow without losing existing state.
  • Record maintainer acceptance of the durable-kernel schema, recovery, and Task Flow ownership boundary.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body lists focused unit-test commands, but it does not include after-change real CLI/Gateway/TaskFlow output; contributor proof is still needed with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Task Flow projection can discard existing persisted stateJson when a durable run syncs into a bound flow.
  • [P1] The PR adds shared SQLite tables and durable env controls, so upgrade, retention, backup, doctor, and operator expectations need maintainer acceptance before merge.
  • [P1] The durable coordination layer overlaps existing Task Flow, background task, session, and subagent ownership boundaries.
  • [P1] Contributor real behavior proof is still missing for the projection path, even though unit-test commands are listed.

Maintainer options:

  1. Preserve Task Flow State Before Merge (recommended)
    Pass the current flow state into the durable metadata merge and add a regression showing existing stateJson keys survive a projection sync.
  2. Require Durable Boundary Approval
    Have maintainers explicitly accept the core durable schema, env controls, recovery worker, and Task Flow ownership boundary before landing this implementation stack.
  3. Pause The Stack
    If maintainers are not ready to own a new durable coordination contract, keep the RFC open and pause or close the implementation slices.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve existing Task Flow stateJson when merging durable projection in src/durable/taskflow-bridge.ts, add a regression test proving existing state keys survive syncDurableRunToTaskFlow, and keep durable metadata under the existing durable key.

Next step before merge

  • [P1] A narrow repair can preserve existing Task Flow state and add regression coverage; contributor proof and maintainer architecture approval remain separate merge blockers.

Security
Cleared: No concrete security or supply-chain regression was found in the diff; it adds no dependencies, workflows, package scripts, or secret-handling expansion, and the new Gateway read is scoped to operator.read.

Review findings

  • [P1] Preserve existing Task Flow state — src/durable/taskflow-bridge.ts:106
Review details

Best possible solution:

Preserve existing Task Flow state during projection, add regression coverage and redacted real behavior proof, then land only after maintainers accept the durable schema and recovery boundary.

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

Yes. Source inspection gives a high-confidence reproduction path: create a managed Task Flow with existing stateJson, sync a durable projection, and the patch replaces that state with only durable metadata.

Is this the best way to solve the issue?

No. Projecting into Task Flow is plausible, but the patch should merge durable metadata into the current flow state rather than replacing stateJson, and the broader durable boundary still needs maintainer approval.

Full review comments:

  • [P1] Preserve existing Task Flow state — src/durable/taskflow-bridge.ts:106
    buildDurableTaskFlowPatch always calls mergeDurableProjectionIntoJsonObject(undefined, ...), so syncing a durable run replaces any existing flow.stateJson. Current Task Flow treats stateJson as persisted progress state, so bound flows can lose their own state when this projection runs; pass the current state into the merge and cover that case.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.89

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 feature with a concrete state-preservation defect and bounded default blast radius, not an emergency regression.
  • merge-risk: 🚨 compatibility: The PR adds env controls, CLI/Gateway surfaces, startup hooks, and shared SQLite schema that affect upgrades and operator expectations.
  • merge-risk: 🚨 session-state: The durable projection writes into Task Flow state and records agent/subagent coordination identity, so merging can corrupt or mis-associate persisted coordination state.
  • merge-risk: 🚨 availability: The opt-in startup recovery worker and reconciliation path can affect gateway recovery behavior when enabled.
  • 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 focused unit-test commands, but it does not include after-change real CLI/Gateway/TaskFlow output; contributor proof is still needed with private details redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +5440, Tests +2144, Docs +14, Generated +306, Other +3. Total +7907 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 29 5442 2 +5440
Tests 10 2144 0 +2144
Docs 1 14 0 +14
Config 0 0 0 0
Generated 2 306 0 +306
Other 1 4 1 +3
Total 43 7910 3 +7907

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs run --config test/vitest/vitest.unit.config.ts src/durable/taskflow-bridge.test.ts src/tasks/task-flow-registry.test.ts.
  • [P1] git diff --check.

What I checked:

  • AGENTS.md policy read: Root AGENTS.md and scoped docs/scripts/agents/gateway guides were read; the compatibility-sensitive config, persisted state, gateway, and Task Flow review rules apply to this PR. (AGENTS.md:1, 7e2f425c492c)
  • Current main lacks the proposed durable module: Current main has no src/durable directory, so the PR is not superseded or implemented on main. (7e2f425c492c)
  • Task Flow state overwrite in PR: The PR builds a Task Flow patch by merging durable metadata into undefined, so the patch replaces existing stateJson instead of preserving existing flow state. (src/durable/taskflow-bridge.ts:106, 5f596259f566)
  • Current Task Flow patch contract: Current main preserves stateJson when a patch omits it, but replaces stateJson whenever a patch supplies a new value; the PR supplies a new value every sync. (src/tasks/task-flow-registry.ts:406, 7e2f425c492c)
  • Existing persisted Task Flow state: Adjacent Task Flow store tests restore and assert arbitrary stateJson values, showing stateJson is persisted flow state rather than disposable projection scratch data. (src/tasks/task-flow-registry.store.test.ts:55, 7e2f425c492c)
  • Projection test gap: The new projection test creates a flow without pre-existing stateJson, so it does not cover preserving existing managed-flow state. (src/durable/taskflow-bridge.test.ts:22, 5f596259f566)

Likely related people:

  • vincentkoc: Recent history includes Task Flow restore, maintenance, registry observer, and naming work on the state surface this projection updates. (role: recent Task Flow contributor; confidence: high; commits: 7aa22959e47f, 0f45630d1937, a51c976d2716; files: src/tasks/task-flow-registry.ts, docs/automation/taskflow.md)
  • steipete: History shows shared Task Flow create-param/helper refactors and the shared SQLite state database work that this PR extends. (role: adjacent Task Flow and shared SQLite contributor; confidence: high; commits: 2f84c47b8bc2, 6e0957ca4789, bc848b367f0b; files: src/tasks/task-flow-registry.ts, src/state/openclaw-state-schema.sql)
  • Feelw00: Recent commits touched explicit task persistence failure handling in the Task Flow registry area affected by state projection writes. (role: recent task persistence contributor; confidence: medium; commits: 01193dea2637; files: src/tasks/task-flow-registry.ts)
  • giodl73-repo: Recent state-schema history includes hosted catalog snapshot persistence in the same shared SQLite schema surface this PR expands. (role: recent shared state-schema contributor; confidence: medium; commits: d1b917120a47; files: 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. labels Jun 29, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jun 29, 2026
@mjnkao

mjnkao commented Jun 29, 2026

Copy link
Copy Markdown
Author

Automated reviewer stack note:

This is Batch B in the OpenClaw-X durable-core stack. It depends on #97507, #97508, and Batch A #97666. GitHub currently shows this PR against main, so the commit list may include dependency commits from PR2 and Batch A. The intended unique review scope for Batch B is the coordination projection layer after #97666: shared durable intake, branch report routes, and Task Flow projection.

Internal mapping: Batch B = internal PR11 + PR12 + PR14.

@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