Skip to content

feat: flow engine quick wins — outputSchema, bash env, conditional retry, escape pipes#72

Merged
moekatib merged 1 commit intomainfrom
feat/flow-quick-wins
Apr 7, 2026
Merged

feat: flow engine quick wins — outputSchema, bash env, conditional retry, escape pipes#72
moekatib merged 1 commit intomainfrom
feat/flow-quick-wins

Conversation

@moekatib
Copy link
Copy Markdown
Contributor

@moekatib moekatib commented Apr 7, 2026

Summary

Bundles five flow-engine quick wins into a single PR. Closes #59, #54, #53, #61, #58.

Stress testing

After implementation, 6 parallel sub-agents ran adversarial test suites against each new feature plus a regression sweep. They found two real bugs, both fixed in this PR:

  1. validateOutputSchemas was double-reporting errors for selectors inside loop/condition/parallel substeps (walkValue recursed into nested step arrays that walkSteps also visited). Fix: skip nested-steps fields in walkValue.
  2. resolveValue's routing check (value.includes('{{$.')) silently ignored the space-padded pipe form {{ $.x | json }}. Fix: routing check now uses a regex that allows optional whitespace.

Both bugs have regression tests.

Test plan

  • npx tsx test-flow-features.ts — 70 tests, 69 passing (1 pre-existing While Loop failure unrelated to this change)
  • npm run typecheck — only pre-existing errors in relay.ts / flow-runner.ts remain
  • npm run build — clean
  • 23 new unit tests covering each feature, edge cases, and the two stress-found bugs
  • Manual smoke test in a downstream flow once merged

Docs

  • skills/one/references/flows.md — new sections on bash structured env, conditional retry, escape pipes, dynamic flow.key, and outputSchema
  • src/lib/flow-schema.ts — auto-generated guide picks up outputSchema in the common-fields table and gets new prose sections for the same features

Version

Bumped to 1.27.0 (minor — additive features, no breaking changes).

🤖 Generated with Claude Code

…try, escape pipes

Closes #59 #54 #53 #61 #58

- #59 outputSchema: declare a step's output shape so downstream
  $.steps.X.output.field references are validated at flow load time.
  Catches the most common wiring bug (typo'd field names).
- #54 bash env JSON-safe injection: bash step env values now accept
  { json: ... } (serialized to a temp file, env var holds the path,
  auto-cleaned) and { shell: ... } (resolved + safely word-split via
  bash double-quotes). Eliminates the file-write→bash workaround.
- #53 conditional retry: onError now supports retryOn / failFastOn so
  transient (429, 502, ETIMEDOUT) and permanent (401, 403, 404)
  failures are handled differently. failFastOn takes precedence;
  retryOn requires a match.
- #53 Handlebars escape pipes: {{ \$.x | json|shell|url|md|html }}
  for context-aware escaping at the template level. Replaces
  per-call sanitization.
- #61 dynamic flow.key dispatch: flow.key already accepted selectors
  via resolveValue, but the spaced-pipe routing fix here makes it
  fully reliable; covered by new tests.
- #58 parallel partial results: $.steps.X.status / errorCode /
  durationMs metadata is exposed on parallel substeps so downstream
  gates can branch on timeout vs failure; covered by new tests.

Stress-tested by 6 parallel sub-agents — caught two real bugs that
are also fixed here:
1. validateOutputSchemas was duplicate-reporting errors for selectors
   inside loop/condition/parallel substeps (walkValue recursed into
   nested step arrays that walkSteps also visited). Fixed by skipping
   nested-steps fields in walkValue.
2. resolveValue's routing check (\`value.includes('{{\$.')\`) missed the
   space-padded form \`{{ \$.x | json }}\`. Fixed by switching to a regex
   that matches optional whitespace.

23 new unit tests added; 70 total / 69 passing (1 pre-existing
While Loop failure unrelated to this change). Docs updated in
skills/one/references/flows.md and the auto-generated guide via
src/lib/flow-schema.ts. Version bumped to 1.27.0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@moekatib moekatib merged commit 6adcb72 into main Apr 7, 2026
@moekatib moekatib deleted the feat/flow-quick-wins branch April 7, 2026 22:51
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.

[Feature Request] Step output type declarations for safer wiring

1 participant