feat(workflow): add thread/edge location support (#558) #560

Closed
xiaoju wants to merge 0 commits from fix/558-thread-edge-location into main
Owner

What

Add thread-level and edge-level working directory management to the workflow engine:

  • Thread-level cwd (required, defaults to process.cwd())
  • Edge-level location field (optional, supports mustache templates)
  • Step-level cwd audit trail

Why

Fixes #558 - Eliminates planner guesswork about repository paths and makes step execution reproducible by capturing the working directory context.

Changes

Protocol Layer

  • StartNodePayload: Added required cwd: string field
  • StepRecord: Added required cwd: string field for audit trail
  • Target: Added optional location: string | null field for edge overrides

CLI Layer

  • Thread start: Captures cwd (validates absolute path, defaults to process.cwd())
  • Moderator: Resolves edge location using mustache templates from previous step output
  • Step execution: Resolves effective cwd (edge location > thread cwd), passes to agent subprocess
  • YAML parsing: Accepts location field in workflow graph edges

Agent Layer

  • Context builder: Exposes cwd field to agent in step history
  • Backward compatibility: Handles legacy nodes without cwd (defaults to empty string)

Test Coverage

  • 31 test scenarios covering all acceptance criteria
  • 12 automated tests pass (moderator, protocol types, thread start)
  • 19 scenarios verified by code inspection
  • 324 total tests pass in cli-workflow package

Acceptance Criteria Met

Thread creation captures cwd
Steps inherit cwd by default
Edge location overrides work
Mustache template support
Step audit trail records cwd
Backward compatible
Type-safe (no | undefined)

Ref

Fixes #558

## What Add thread-level and edge-level working directory management to the workflow engine: - Thread-level `cwd` (required, defaults to `process.cwd()`) - Edge-level `location` field (optional, supports mustache templates) - Step-level `cwd` audit trail ## Why Fixes #558 - Eliminates planner guesswork about repository paths and makes step execution reproducible by capturing the working directory context. ## Changes ### Protocol Layer - **StartNodePayload**: Added required `cwd: string` field - **StepRecord**: Added required `cwd: string` field for audit trail - **Target**: Added optional `location: string | null` field for edge overrides ### CLI Layer - **Thread start**: Captures cwd (validates absolute path, defaults to `process.cwd()`) - **Moderator**: Resolves edge `location` using mustache templates from previous step output - **Step execution**: Resolves effective cwd (edge location > thread cwd), passes to agent subprocess - **YAML parsing**: Accepts `location` field in workflow graph edges ### Agent Layer - **Context builder**: Exposes `cwd` field to agent in step history - **Backward compatibility**: Handles legacy nodes without `cwd` (defaults to empty string) ## Test Coverage - 31 test scenarios covering all acceptance criteria - 12 automated tests pass (moderator, protocol types, thread start) - 19 scenarios verified by code inspection - 324 total tests pass in cli-workflow package ## Acceptance Criteria Met ✅ Thread creation captures cwd ✅ Steps inherit cwd by default ✅ Edge location overrides work ✅ Mustache template support ✅ Step audit trail records cwd ✅ Backward compatible ✅ Type-safe (no | undefined) ## Ref Fixes #558
xiaoju added 1 commit 2026-05-27 15:39:53 +00:00
feat(workflow): add thread/edge location support (#558)
CI / test (pull_request) Successful in 3m43s
984d93a6f5
Implement thread-level and edge-level working directory management:

- Thread-level cwd (required, defaults to process.cwd())
  - Captured at uwf thread start time
  - Stored in StartNodePayload
  - Inherited by all steps unless overridden

- Edge-level location (optional, supports mustache templates)
  - New location: string | null field on Target type
  - Resolved by moderator using previous step's output
  - Example: location: "{{{repoPath}}}"

- Step audit trail
  - Each StepNodePayload records actual cwd where agent executed

Changes:
- workflow-protocol: Add cwd to StartNodePayload & StepRecord, location to Target
- cli-workflow: Thread start captures cwd, moderator resolves location, step execution uses resolved cwd
- workflow-util-agent: Expose cwd in agent context

Tests:
- Protocol type tests (3 scenarios)
- Moderator location resolution tests (5 scenarios)
- Thread-location integration tests (3 scenarios)

All tests pass. Build successful. Backward compatible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
xiaonuo closed this pull request 2026-05-27 23:50:14 +00:00
Some checks are pending
CI / test (pull_request) Successful in 3m43s

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#560