Skip to content

feat(automation): structured try/catch/retry block (ADR-0031, task 4) - #1499

Merged
os-zhuang merged 1 commit into
mainfrom
claude/try-catch-adr0031
Jun 2, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/try-catch-adr0031

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Implements ADR-0031 task 4 (issue #1479) — engine execution for the structured try_catch construct, completing the native control-flow execution trio (loop #1482 / parallel #1489 / try-catch). Builds on the schemas + runRegion + region validation already on main.

What's in this PR

@objectstack/service-automation — builtin/try-catch-node.ts (new)

  • Runs the protected try region via runRegion in the enclosing variable scope.
  • On failure, retries the try region with exponential backoff (config.retry: maxRetries, retryDelayMs, backoffMultiplier, maxRetryDelayMs, jitter).
  • If it still fails, runs the optional catch region with the caught error bound to config.errorVariable (default $error).
  • Outcomes: try (or a retry) succeeds → node succeeds; catch handles the failure → node succeeds; no catch, or catch itself fails → node fails, surfacing to the flow's fault edge / error handling.
  • This surfaces the engine's existing fault + backoff-retry semantics as a construct (not BPMN boundary events). Registered as a built-in executor.

Well-formedness (single-entry/single-exit try/catch regions) is already enforced at registerFlow() by validateControlFlow from the loop PR.

Showcase / changeset

  • ResilientSyncFlow — pushes a task to an external system, retrying on failure and recording the error via catch.
  • Changeset added.

Tests

  • builtin/try-catch-node.test.ts — 8 tests: try-succeeds (catch not run), catch-on-failure (+error binding), retry-then-succeed, retry-exhausted→catch, no-catch→node fails, catch-itself-fails, malformed-try rejected at register, multi-node try ordering.
  • Local suites: service-automation 147 (9 files, incl. the 8 new); showcase build emits 13 flows; service-automation dts build clean.

Roadmap (#1479)

https://claude.ai/code/session_012ti8cx3TkdiQdjCnZXZg2Q


Generated by Claude Code

Add engine execution for the `try_catch` construct — the structured error
model (ADR-0031 §Decision 3), completing the native control-flow trio
(loop / parallel / try-catch).

- new builtin/try-catch-node.ts: runs the protected `try` region via
  engine.runRegion; on failure retries with exponential backoff
  (config.retry), then runs the optional `catch` region with the caught error
  bound to config.errorVariable (default `$error`). try success (incl. a
  retry) → node succeeds; catch handling a failure → node succeeds; no catch /
  failing catch → node fails to the flow's fault edge / error handling.
- registered as a built-in node executor.
- well-formedness (single-entry/single-exit try/catch regions) already enforced
  at registerFlow() by validateControlFlow (shipped with the loop container).
- showcase ResilientSyncFlow + 8 executor tests; changeset added.

https://claude.ai/code/session_012ti8cx3TkdiQdjCnZXZg2Q
@vercel

vercel Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 2, 2026 12:59am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jun 2, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review June 2, 2026 01:09
@os-zhuang
os-zhuang merged commit 4ee139d into main Jun 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>
@github-actions
github-actions Bot deleted the claude/try-catch-adr0031 branch September 7, 2026 04:49

This branch was successfully deployed

1 active deployment
Preview — 0df108cd Deployed Jun 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants