Skip to content

feat(workflow-executor): add TriggerActionStepExecutor with confirmation flow#1501

Open
Scra3 wants to merge 9 commits intofeat/prd-219-update-record-step-executorfrom
feat/trigger-action-step-executor
Open

feat(workflow-executor): add TriggerActionStepExecutor with confirmation flow#1501
Scra3 wants to merge 9 commits intofeat/prd-219-update-record-step-executorfrom
feat/trigger-action-step-executor

Conversation

@Scra3
Copy link
Member

@Scra3 Scra3 commented Mar 20, 2026

Summary

  • Implements TriggerActionStepExecutor following the UpdateRecordStepExecutor pattern (branches A/B/C, automaticExecution, confirmation flow)
  • AI selects an action via a select-action tool (Zod enum of display names + technical names as hints); resolveActionName maps displayName → technical name with name fallback
  • Adds TriggerActionStepExecutionData with executionParams: { actionDisplayName, actionName }, executionResult: { success } | { skipped }, and pendingAction for the awaiting-confirmation state
  • Adds NoActionsError for collections with no actions
  • Fixes buildStepSummary in BaseStepExecutor to include trigger-action pendingAction in prior-step AI context (parity with update-record pendingUpdate)
  • Action result intentionally discarded — privacy constraint (no client data leaves the infrastructure)

Test plan

  • Branch B (automaticExecution: true) — triggers action, saves executionParams with both display and technical name, returns success
  • Branch C (no automaticExecution) — saves pendingAction, returns awaiting-input
  • Branch A confirmed — triggers action, preserves pendingAction for traceability
  • Branch A rejected — action not called, saves { skipped: true }
  • Branch A no pending action — throws
  • NoActionsError — returns error outcome
  • WorkflowExecutorError from executeActionerror outcome (branches A & B)
  • Infrastructure errors propagate (branches A & B)
  • resolveActionName failure (Branch A — action deleted between confirmation steps)
  • displayName → technical name resolution + fallback
  • Multi-record AI selection
  • RunStore error propagation (5 scenarios across all branches)
  • AI malformed / missing tool call → error outcome
  • Default prompt fallback
  • Previous steps context in AI messages
  • Schema caching (single getCollectionSchema call per collection)
  • stepOutcome shape

🤖 Generated with Claude Code

Note

Add TriggerRecordActionStepExecutor with confirmation flow to workflow-executor

  • Adds TriggerRecordActionStepExecutor to select and trigger actions on records, supporting automatic execution and confirmation-gated (awaiting-input) flows.
  • Introduces RecordTaskStepExecutor, a shared abstract base that provides a common handleConfirmationFlow and buildOutcomeResult for record-task step executors.
  • Refactors BaseStepExecutor to wrap execution in a doExecute() pattern, converting WorkflowExecutorError to error outcomes uniformly across all step executors.
  • Renames pendingUpdate to pendingData and updates the shape to { displayName, name, value } across UpdateRecordStepExecutor and related types; ReadRecordStepExecutor similarly replaces fieldNames with structured { name, displayName } field refs.
  • Adds NoActionsError and StepPersistenceError to errors.ts; persistence failures after a successful action now throw StepPersistenceError rather than propagating the raw error.
  • Behavioral Change: pendingUpdate and fieldNames/fieldName keys in persisted step execution data are replaced with pendingData and fields/name — existing persisted executions using the old shape will not match the new expectations.

Macroscope summarized c8b9247.

…ion flow

Implements TriggerActionStepExecutor following the UpdateRecordStepExecutor
pattern (branches A/B/C, confirmation flow, automaticExecution).

- Add TriggerActionStepExecutionData type with executionParams (actionDisplayName
  + actionName), executionResult ({ success } | { skipped }), and pendingAction
- Add NoActionsError for collections with no actions
- Implement selectAction via AI tool with displayName enum and technical name hints
- resolveAndExecute stores the technical actionName in executionParams for
  traceability; action result discarded per privacy constraint
- Fix buildStepSummary in BaseStepExecutor to include trigger-action pendingAction
  in prior-step AI context (parity with update-record pendingUpdate)
- Export TriggerActionStepExecutor, TriggerActionStepExecutionData, NoActionsError

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the feat/trigger-action-step-executor branch from ac706e8 to c884d37 Compare March 20, 2026 10:45
@qltysh
Copy link

qltysh bot commented Mar 20, 2026

Qlty

Coverage Impact

⬆️ Merging this pull request will increase total coverage on feat/prd-219-update-record-step-executor by 0.02%.

Modified Files with Diff Coverage (8)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
...s/workflow-executor/src/executors/read-record-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
...ges/workflow-executor/src/executors/condition-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/executors/base-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
...workflow-executor/src/executors/update-record-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/errors.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/index.ts100.0%
New file Coverage rating: A
...s/workflow-executor/src/executors/record-task-step-executor.ts100.0%
New file Coverage rating: A
...-executor/src/executors/trigger-record-action-step-executor.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

…t and pendingAction

Resolve actionName once in handleFirstCall and store it in pendingAction,
so resolveAndExecute receives it directly via ActionTarget without re-fetching
the schema. Rename TriggerTarget → ActionTarget for consistency with English
naming conventions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@qltysh
Copy link

qltysh bot commented Mar 20, 2026

All good ✅

alban bertolini and others added 7 commits March 20, 2026 12:40
…f shapes to { name, displayName }

- Extract ActionRef { name, displayName } from inline types in TriggerActionStepExecutionData
- Extract FieldRef { name, displayName } replacing FieldReadBase in ReadRecord types
- UpdateRecordStepExecutionData executionParams/pendingUpdate now use FieldRef & { value }
- Rename actionDisplayName/actionName → displayName/name, fieldDisplayName/fieldName → displayName/name
- Move resolveFieldName to handleFirstCall (no re-resolution in resolveAndUpdate)
- Add missing tests: resolveActionName not-found path, saveStepExecution not-called assertions, trigger-action pendingAction in buildStepSummary
- Export ActionRef, FieldRef, NoActionsError from index; update CLAUDE.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…store display names in executionParams

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rams for consistency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…-executor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y" wording

Use fieldNames instead of fieldDisplayNames and actionName instead of
displayName in tool schemas exposed to the AI, to avoid confusion between
property names and their semantics (values remain display names).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ize pending state

- Make buildOutcomeResult abstract on BaseStepExecutor; each branch owns its outcome shape
- Add RecordTaskStepExecutor intermediate class implementing buildOutcomeResult for 'record-task'
- Add pendingData to BaseStepExecutionData, replacing pendingUpdate/pendingAction per-type fields; each executor sets it when saving, base class reads it directly with no type discrimination
- Rename TriggerActionStepExecutor → TriggerRecordActionStepExecutor for naming consistency with ReadRecord/UpdateRecord

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…idate error handling

- Introduce doExecute() as the abstract hook; execute() in the base class wraps it
  with the single try-catch that converts WorkflowExecutorErrors to error outcomes
  and rethrows infrastructure errors — removing all try-catch boilerplate from subclasses
- Inline the former buildErrorOutcomeOrThrow helper directly into execute(), it no
  longer needs to be a named method
- Add StepPersistenceError (extends WorkflowExecutorError) for post-side-effect
  persistence failures; these are now consistently converted to error outcomes
- Extract handleConfirmationFlow into RecordTaskStepExecutor to DRY the
  confirmation pattern shared by update-record and trigger-record-action
- Split the !execution?.pendingData guard into two distinct WorkflowExecutorErrors
  for clearer debug messages
- Export BaseStepStatus from step-outcome; remove pendingData from BaseStepExecutionData
  (declared only on the concrete types that need it)
- Fix extractToolCallArgs to throw MalformedToolCallError when args is null/undefined

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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