Skip to content

feat(automation): structured parallel block (ADR-0031, task 3) - #1489

Merged
os-zhuang merged 2 commits into
mainfrom
claude/parallel-block-adr0031
Jun 2, 2026
Merged

feat(automation): structured parallel block (ADR-0031, task 3)#1489
os-zhuang merged 2 commits into
mainfrom
claude/parallel-block-adr0031

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Implements ADR-0031 task 3 (issue #1479) — engine execution for the structured parallel block with an implicit join. Builds on the merged loop-container PR (#1482), which already shipped the construct schemas (ParallelConfigSchema), region well-formedness analysis, and AutomationEngine.runRegion().

What's in this PR

@objectstack/service-automationbuiltin/parallel-node.ts (new)

  • The parallel node declares N branch regions in config.branches[]. The executor runs every branch concurrently (Promise.all, via runRegion) in the enclosing variable scope and continues once when all branches complete — the join is implicit at block end, engine-synchronized. No author-visible split/join gateway to mis-wire or deadlock; the node's ordinary out-edges are the after-block continuation.
  • Concurrency model: single-threaded JS → branches interleave only at await points and the shared variables map is never torn. Branches should write distinct variables (last-writer-wins on collision, same as the engine's existing unconditional-edge fan-out).
  • Failure: any branch failing fails the block (surfaced as a node failure → fault edge / error handling). Durable pause inside a branch → clear error (mirrors the loop container).
  • Registered as a built-in executor.

Well-formedness (≥2 branches; each branch single-entry/single-exit, acyclic) is already enforced at registerFlow() by validateControlFlow from the loop PR.

Showcase / changeset

  • FanOutNotifyFlow — notifies the owner and Slack concurrently, joining before completion.
  • Changeset added.

Tests

  • builtin/parallel-node.test.ts — 6 tests: all-branches-run + implicit join, join waits for the slowest branch, multi-node branch ordering, branch-failure fails the block, and two register-time rejections (<2 branches; malformed branch region).
  • Suites pass locally: service-automation 139 (incl. the 6 new), showcase 17 (build emits 12 flows).

Roadmap (#1479)

https://claude.ai/code/session_012ti8cx3TkdiQdjCnZXZg2Q


Generated by Claude Code

Add engine execution for the `parallel` block — a structured construct with an
implicit join (ADR-0031 §Decision 2), building on the loop container PR.
- new builtin/parallel-node.ts: runs config.branches[] regions concurrently in
the enclosing variable scope via engine.runRegion() and continues once when
all complete — no author-visible split/join gateway. Branch failure fails the
block (→ fault edge / error handling); durable pause inside a branch is a
clear error.
- registered as a built-in node executor (builtin/index.ts).
- well-formedness (>=2 branches, single-entry/single-exit regions) is already
enforced at registerFlow() by validateControlFlow (shipped with the loop PR).
- showcase FanOutNotifyFlow demonstrates the parallel block; changeset added.
https://claude.ai/code/session_012ti8cx3TkdiQdjCnZXZg2Q
@vercel

vercelBot commented Jun 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJun 2, 2026 12:33am

Request Review

@os-zhuang
os-zhuang marked this pull request as ready for review June 2, 2026 00:45
@os-zhuang
os-zhuang merged commit f06a6a5 into mainJun 2, 2026
12 checks passed
os-zhuang added a commit that referenced this pull request Jun 2, 2026
The structured control-flow constructs (loop/parallel/try-catch) and the BPMN
interop mapping are implemented and merged (#1482, #1489, #1499, #1500; docs
#1497). Flip ADR-0031 from Proposed to Accepted and record the implementing PRs
and the deferred follow-ups (#1504 BPMN XML plugin, #1505 region step logs).
https://claude.ai/code/session_012ti8cx3TkdiQdjCnZXZg2Q
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@os-zhuang@claude