-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workspace): deferred workspace creation — reference prior step outputs in workspace config #699
Description
Problem
Workspace configuration is resolved at pipeline parse time, before any steps execute. This means workspace fields like branch: can only use static values or pipeline-level template variables ({{ pipeline_id }}), not outputs from prior steps.
This forces patterns like:
- Create a throwaway worktree on
{{ pipeline_id }} - Inside the step prompt,
git fetch && git checkoutthe real branch - The worktree creation was wasted work
This matters most for cross-pipeline workflows like ops-pr-rework, where the target branch name comes from a prior step's output (the PR's headRefName).
Proposed Solution
Support step output references in workspace config:
steps:
- id: fetch-review
# ... produces artifact with head_branch field
- id: apply-fixes
dependencies: [fetch-review]
workspace:
type: worktree
branch: "{{ steps.fetch-review.artifacts.review-findings.head_branch }}"The workspace for apply-fixes is created after fetch-review completes, using the resolved value from its output artifact.
Implementation
Deferred resolution in executor
In internal/pipeline/executor.go, the workspace creation path currently runs before step execution. Change to:
- At step start, check if workspace config contains
{{ steps.* }}references - If yes, resolve the references from prior step artifacts (already available in
.wave/artifacts/) - Then create the workspace with the resolved config
This is a narrow change — only the workspace creation path needs to defer, not the full config resolution.
Template syntax
Reuse the existing template variable system. Add a steps namespace:
{{ steps.<step-id>.artifacts.<artifact-name>.<json-path> }}— read a field from a prior step's JSON artifact{{ steps.<step-id>.output.<field> }}— read from step outcome metadata
Fallback
If the referenced step hasn't completed or the artifact doesn't exist, fail with a clear error rather than creating a broken workspace.
Acceptance Criteria
- Workspace
branch:field can reference prior step artifact values - Workspace creation is deferred until references are resolved
- Clear error if referenced step/artifact doesn't exist
- Existing static workspace configs unaffected
-
ops-pr-reworkpipeline updated to use deferred branch resolution