Skip to content

refactor(tasks): add executor facade - #57474

Merged
vincentkoc merged 2 commits into
mainfrom
pr1/task-executor
Mar 30, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
pr1/task-executor

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • Problem: task lifecycle writes still come straight from the registry surface, so there is no explicit executor seam for detached/background runs.
  • Why it matters: the remaining task work needs a stable contract before ACP, subagents, and cron can migrate producer-by-producer without more registry churn.
  • What changed: added a thin src/tasks/task-executor.ts facade over the existing task lifecycle helpers, switched ACP parent-stream progress reporting to use it, and added focused executor tests.
  • What did NOT change (scope boundary): no backend change, no cron target split, no heartbeat semantics change, and no broad producer migration yet.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: N/A
  • Missing detection / guardrail: N/A
  • Prior context (git blame, prior PR, issue, or refactor if known): N/A
  • Why this regressed now: N/A
  • If unknown, what was ruled out: N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/tasks/task-executor.test.ts
  • Scenario the test should lock in: queued/start/complete and running/progress/fail/delivery executor flows keep mapping to the existing task ledger correctly.
  • Why this is the smallest reliable guardrail: it validates the new executor seam directly without pulling broader producer behavior into this checkpoint PR.
  • Existing test that already covers this (if any): src/tasks/task-registry.test.ts still covers the downstream task behavior.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

None.

Diagram (if applicable)

Before:
producer -> task-registry lifecycle helper -> task row

After:
producer -> task-executor -> task-registry lifecycle helper -> task row

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22 / pnpm
  • Model/provider: N/A
  • Integration/channel (if any): ACP parent-stream progress path
  • Relevant config (redacted): default local task sqlite state

Steps

  1. Create a detached/background run through the executor seam.
  2. Advance it through progress / terminal transitions.
  3. Verify the resulting task row still matches existing registry semantics.

Expected

  • The executor is only a thin seam over current task lifecycle behavior.

Actual

  • The executor now owns a first explicit lifecycle contract, with one ACP progress consumer switched to it.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios:
    • pnpm test -- src/tasks/task-executor.test.ts src/tasks/task-registry.test.ts
    • pnpm build
  • Edge cases checked:
    • queued -> running -> succeeded path
    • running -> progress -> failed path
    • ACP parent-stream progress path still compiles through the new seam
  • What you did not verify:
    • full ACP/subagent/cron producer migration; those are follow-up PRs in the sequence
    • codex review --base origin/main could not complete locally because the tool hit the known local 127.0.0.1 transport failure

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: thin facade adds an extra layer without yet removing direct registry imports elsewhere.
    • Mitigation: this PR keeps the layer intentionally small and migrates one contained consumer only; later PRs move producers in sequence.

AI-assisted: yes. Fully tested on the touched surface.

@vincentkoc vincentkoc self-assigned this Mar 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Mar 30, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review March 30, 2026 04:31
@greptile-apps

greptile-apps Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a thin task-executor facade module (src/tasks/task-executor.ts) that wraps the existing task-registry lifecycle helpers under executor-oriented names (e.g. createQueuedTaskRun, startTaskRunByRunId, completeTaskRunByRunId, failTaskRunByRunId). One consumer in acp-spawn-parent-stream.ts is migrated to use the new seam, and focused executor tests are added.

  • The facade is correctly implemented: every exported function is a straightforward one-liner that delegates to the matching registry helper, with types preserved and no behavioral drift.
  • The three recordTaskProgressByRunId → recordTaskRunProgressByRunId call-site migrations in acp-spawn-parent-stream.ts are accurate and the import is updated.
  • Tests cover the two primary lifecycle paths (queued→start→complete and running→progress→fail→delivery-status) and assert the correct final state against the underlying registry.
  • markTaskRunLostById and cancelDetachedTaskRunById are exported but not directly tested in this PR; the PR description explicitly scopes them as out of range for this checkpoint.

Confidence Score: 5/5

Safe to merge — pure additive refactor with no behavioral changes, correct type delegation, and adequate test coverage for the migrated surface.

All three changed files are straightforward and correct. The facade introduces no new logic: every wrapper is a transparent one-liner over an existing, tested registry function. The one migrated consumer (acp-spawn-parent-stream.ts) makes an equivalent call through the new seam. No P0 or P1 findings; remaining observations are P2 scope notes already acknowledged by the PR description.

No files require special attention.

Important Files Changed

Filename Overview
src/tasks/task-executor.ts New facade module that re-exports thin wrappers around existing task-registry lifecycle helpers, correctly delegates all operations and preserves all parameter types.
src/tasks/task-executor.test.ts New focused tests covering the queued→running→succeeded and running→progress→failed→delivery-status paths through the executor seam.
src/agents/acp-spawn-parent-stream.ts Migrated three recordTaskProgressByRunId call sites from the registry directly to the equivalent executor facade function recordTaskRunProgressByRunId; import updated accordingly.

Reviews (1): Last reviewed commit: "Merge branch 'main' into pr1/task-execut..." | Re-trigger Greptile

@vincentkoc vincentkoc mentioned this pull request Mar 30, 2026
7 of 25 tasks
@vincentkoc
vincentkoc merged commit 5b2d9b6 into main Mar 30, 2026
8 checks passed
@vincentkoc
vincentkoc deleted the pr1/task-executor branch March 30, 2026 04:35
Alix-007 pushed a commit to Alix-007/openclaw that referenced this pull request Mar 30, 2026
alexjiang1 pushed a commit to alexjiang1/openclaw that referenced this pull request Mar 31, 2026
pgondhi987 pushed a commit to pgondhi987/openclaw that referenced this pull request Mar 31, 2026
pgondhi987 pushed a commit to pgondhi987/openclaw that referenced this pull request Mar 31, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Tardisyuan pushed a commit to Tardisyuan/openclaw that referenced this pull request Apr 30, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 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 maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant