Skip to content

feat(workflow): engine API with fakes#96

Draft
Waishnav wants to merge 1 commit into
pr/dw-2-store-sandboxfrom
pr/dw-3-engine
Draft

feat(workflow): engine API with fakes#96
Waishnav wants to merge 1 commit into
pr/dw-2-store-sandboxfrom
pr/dw-3-engine

Conversation

@Waishnav

Copy link
Copy Markdown
Owner

Summary

  • createWorkflowApi: agent/parallel/pipeline/phase/log/workflow + semaphore + ALS phase
  • executeWorkflow host entry; nest depth 1; isolation worktree hook
  • Unit tests with fake runProvider (no real LLM)

Stack

PR3 of 5 · base: pr/dw-2-store-sandbox

Test plan

  • tsx src/workflow-engine.test.ts
  • Cover: parallel null-on-throw, pipeline no barrier, phase ALS, worktree cwd, nest depth
  • npm run typecheck

agent/parallel/pipeline/phase/log/workflow primitives, semaphore,
ALS phase, isolation worktree hook, nest depth 1, and executeWorkflow
against injectable runProvider for unit tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5192a094-3f2f-4428-a12a-7bcaeb28b058

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr/dw-3-engine

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/workflow-api.ts
"isolation: 'worktree' requires createWorktree host support",
);
}
worktree = await deps.createWorktree({

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0] Worktree creation happens before beginAgentCall, but the catch path always calls failAgentCall. If setup fails (non-Git workspace, missing Git, bad base SHA, collision), the original error is masked by Unknown workflow agent call. Begin a preparing row before fallible setup, or guard failure journaling with a callStarted flag.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by stacked PR #101 (d5b00f5). The agent path now tracks whether beginAgentCall actually succeeded and only calls failAgentCall for an existing row. A worktree setup failure preserves the original error and still emits a typed agent_call_failed event. A regression test makes createWorktree throw and verifies that the error is not replaced by Unknown workflow agent call. This thread becomes obsolete once #101 is merged.

Comment thread src/workflow-api.ts
runId: deps.runId,
callIndex: index,
responseText: truncate(result.finalResponse, WORKFLOW_LIMITS.responseTextBytes),
structuredJson: structuredJson

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Please do not truncate structured JSON. A truncated payload is invalid JSON; replay then silently falls back to response text and changes the return type from object to string. Reject oversized structured results or persist them as an artifact/reference. Only free-form response text should be truncated.

Comment thread src/workflow-engine.ts
// Child surface: reuse parent agent/parallel/pipeline/phase/log/budget/workflow
// so callIndex + semaphore stay shared. Override args + meta for the child body.
const childApi: WorkflowApi = {
agent: input.parentApi.agent,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Reusing the parent's agent closure also reuses the parent's meta and phase context, so a child's defaultProvider and phase semantics are not actually honored. Share only runtime state (semaphore, call counter, replay, signal, journal), then construct a child API with the child's own meta and args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant