Skip to content

feat(engine): workflow interpolation for ${input.*} and ${steps.*} (issue #16)#50

Merged
leo-aa88 merged 1 commit into
mainfrom
issue/16-workflow-interpolation
Apr 11, 2026
Merged

feat(engine): workflow interpolation for ${input.*} and ${steps.*} (issue #16)#50
leo-aa88 merged 1 commit into
mainfrom
issue/16-workflow-interpolation

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

Summary

Implements MVP workflow string interpolation from the design doc §13.1 (dot paths only, non–Turing-complete): ${input...} and ${steps...} against a small run context, with §13.2 step result shape (output, meta).

API (internal/engine/interpolation.go)

  • StepResult: Output any, Meta map[string]any (maps hold nested fields for dot lookup).
  • Context: Input map[string]any, Steps map[string]StepResult.
  • InterpolateString(s, ctx): finds ${...} tokens (inner path trimmed), resolves paths, substitutes string values (scalars formatted; objects/arrays JSON-encoded).
  • InterpolateWalk(v, ctx): recursively interpolates string leaves in map[string]any and []any (for workflow with trees).

Path rules

  • input.<key>[.<nested>...] — walk Context.Input.
  • steps.<step_id>.output[.<nested>...] or steps.<step_id>.meta.<key>... — walk StepResult.Output / Meta as map[string]any; drilling into non-maps returns a clear error.

Errors

  • Unknown keys / unknown step: messages include undefined path or unknown step where applicable (validation-friendly for callers).
  • Type mismatch when a segment needs a map but value is not: cannot resolve with %T.

Tests

  • §7.4 / §13.1 style: repo=${input.repo}, number=${input.number}, whole ${steps.fetch_pr.output}, nested ${steps.review.output.summary}, ${steps.fetch_pr.meta.durationMs}.
  • Unknown placeholder: ${input.unknown_key}.
  • Unknown step, drill into non-map output, empty ${}, whitespace inside token, InterpolateWalk on nested maps.

Verification

  • make fmt (go fmt ./...)
  • make test (go test ./... -race)
  • make vet

Closes #16

Made with Cursor

Add Context, StepResult, InterpolateString, and InterpolateWalk for
${input.*} and ${steps.<id>.output|meta.*} per design doc §13.1–§13.2.
Errors report undefined paths and type mismatches when drilling into
non-map values.

Tests cover §7.4-style repo/number, nested output.summary, meta, and
unknown placeholder handling (issue #16).

Made-with: Cursor
@leo-aa88 leo-aa88 merged commit c82cfdb into main Apr 11, 2026
4 checks passed
@leo-aa88 leo-aa88 deleted the issue/16-workflow-interpolation branch April 11, 2026 21:44
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.

[MVP] Workflow interpolation — ${input.*} and ${steps.*} dot paths (internal/engine)

1 participant