Skip to content

feat(workflow-executor): add guidance step type (PRD-272)#1532

Merged
Scra3 merged 1 commit intofeat/prd-214-setup-workflow-executor-packagefrom
feature/prd-272-guidance-step
Apr 7, 2026
Merged

feat(workflow-executor): add guidance step type (PRD-272)#1532
Scra3 merged 1 commit intofeat/prd-214-setup-workflow-executor-packagefrom
feature/prd-272-guidance-step

Conversation

@Scra3
Copy link
Copy Markdown
Member

@Scra3 Scra3 commented Apr 3, 2026

Summary

Add a new "guidance" step type for manual user input without AI.

Flow

  1. Front displays instruction + text input to user
  2. User types and clicks Submit
  3. Front triggers POST /runs/:runId/trigger with { pendingData: { userInput: "..." } }
  4. Executor saves input in RunStore and returns success
  5. Subsequent AI steps see the input in their context

Changes

  • StepType.Guidance + GuidanceStepDefinition
  • GuidanceStepExecutor: reads userInput from store, saves executionResult, returns success
  • patchPendingData auto-creates execution for never-polled steps (scoped to Guidance only)
  • Zod validator: { userInput: z.string().min(1) }
  • Step summary formatter for AI context in subsequent steps

Test plan

  • 437 tests pass
  • TypeScript compiles
  • Lint clean
  • GuidanceStepExecutor: success path, no execution error, no userInput error
  • patchPendingData auto-creation for guidance
  • Zod validation rejects empty userInput
  • Step formatter outputs correct summary

fixes PRD-272

🤖 Generated with Claude Code

Note

Add guidance step type to workflow executor

  • Introduces GuidanceStepExecutor, a new step type that records user-provided userInput from incomingPendingData and returns a success outcome without any AI calls.
  • Moves pending data validation and persistence from Runner.patchPendingData into individual executors via a new BaseStepExecutor.patchAndReloadPendingData method, giving each executor control over its own pending data schema.
  • Extends StepExecutorFactory to construct GuidanceStepExecutor for StepType.Guidance and passes incomingPendingData through the execution context.
  • Adds a formatGuidance formatter to StepExecutionFormatters so guidance results render a summary line quoting the user input.
  • Behavioral Change: the /runs/:runId/trigger endpoint no longer returns 400/404 for invalid or missing pending data; such errors are now handled inside executors and fall through to a 500 if unhandled.

Macroscope summarized 26b9c2f.

@linear
Copy link
Copy Markdown

linear bot commented Apr 3, 2026

@qltysh
Copy link
Copy Markdown

qltysh bot commented Apr 3, 2026

5 new issues

Tool Category Rule Count
qlty Structure Function with many returns (count = 8): create 3
qlty Structure Function with many parameters (count = 4): create 1
qlty Structure Function with high complexity (count = 15): build 1

@qltysh
Copy link
Copy Markdown

qltysh bot commented Apr 3, 2026

Qlty

Coverage Impact

⬇️ Merging this pull request will decrease total coverage on feat/prd-214-setup-workflow-executor-package by 0.02%.

Modified Files with Diff Coverage (14)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/runner.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/executors/step-executor-factory.ts100.0%
Coverage rating: A Coverage rating: A
...ow-executor/src/executors/load-related-record-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
...orkflow-executor/src/executors/summary/step-summary-builder.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/types/step-outcome.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/types/step-definition.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/executors/base-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/http/executor-http-server.ts100.0%
Coverage rating: A Coverage rating: A
...workflow-executor/src/executors/update-record-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
...-executor/src/executors/trigger-record-action-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/index.ts100.0%
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/executors/mcp-step-executor.ts100.0%
Coverage rating: A Coverage rating: A
...ow-executor/src/executors/summary/step-execution-formatters.ts100.0%
New file Coverage rating: A
...ages/workflow-executor/src/executors/guidance-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.

@Scra3 Scra3 force-pushed the feature/prd-272-guidance-step branch 5 times, most recently from df424c2 to b6697ee Compare April 7, 2026 08:18
* validates it against the step-type schema and merges it into the execution.
* Returns the (possibly updated) execution, or undefined if none exists.
*/
protected async patchAndReloadPendingData<TExec extends WithPendingData>(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium executors/base-step-executor.ts:127

patchAndReloadPendingData uses a non-null assertion (!) on patchBodySchemas[execution.type], but patchBodySchemas is a Partial that only includes schemas for specific step types. When the method is called with an execution whose type is not in that set (e.g., condition or read-record), schema becomes undefined and schema.safeParse(pendingData) throws a runtime error. Consider validating that the schema exists and throwing a StepStateError when the step type does not support pending data patches.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file packages/workflow-executor/src/executors/base-step-executor.ts around line 127:

`patchAndReloadPendingData` uses a non-null assertion (`!`) on `patchBodySchemas[execution.type]`, but `patchBodySchemas` is a `Partial` that only includes schemas for specific step types. When the method is called with an execution whose type is not in that set (e.g., `condition` or `read-record`), `schema` becomes `undefined` and `schema.safeParse(pendingData)` throws a runtime error. Consider validating that the schema exists and throwing a `StepStateError` when the step type does not support pending data patches.

Evidence trail:
- packages/workflow-executor/src/executors/base-step-executor.ts lines 127-140 (REVIEWED_COMMIT): `patchAndReloadPendingData` method with `patchBodySchemas[execution.type]!` at line 134
- packages/workflow-executor/src/pending-data-validators.ts lines 5-43 (REVIEWED_COMMIT): `patchBodySchemas` defined as `Partial<Record<StepExecutionData['type'], z.ZodTypeAny>>` with only 5 step types having schemas
- packages/workflow-executor/src/types/step-execution-data.ts lines 140-150 (REVIEWED_COMMIT): `StepExecutionData` union type includes 8 types, 3 of which (`condition`, `read-record`, `record`) have no schema in `patchBodySchemas`
- packages/workflow-executor/src/executors/guidance-step-executor.ts lines 17-20 (REVIEWED_COMMIT): Shows correct pattern with explicit `if (!schema)` check before use

Add a new "guidance" step type for manual user input. The frontend
triggers the executor directly with { pendingData: { userInput } }.
No AI, no polling — the executor saves the input and returns success.

Also refactor pendingData handling: move from Runner into executors.
Each executor manages its own pendingData via incomingPendingData
in the context. The Runner no longer patches or validates pendingData.

- Add StepType.Guidance + GuidanceStepExecutor
- Add incomingPendingData to ExecutionContext
- Add patchAndReloadPendingData helper in BaseStepExecutor
- 4 confirmation-flow executors use patchAndReloadPendingData
- Guidance executor validates and saves input directly
- Runner.patchPendingData removed entirely
- Step summary formatter for AI context in subsequent steps

fixes PRD-272

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the feature/prd-272-guidance-step branch from b6697ee to 26b9c2f Compare April 7, 2026 08:32
@Scra3 Scra3 merged commit 1798709 into feat/prd-214-setup-workflow-executor-package Apr 7, 2026
30 checks passed
@Scra3 Scra3 deleted the feature/prd-272-guidance-step branch April 7, 2026 08:41
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