fix(cli): use source checkout cwd for workflow discovery on resume/approve/reject#1743
Conversation
When a workflow paused at an approval gate is resumed via `workflow approve` or `workflow resume`, the CLI re-invoked `workflowRunCommand` with `run.working_path` as the discovery cwd. If `working_path` is a worktree or workspace clone that does not contain the user's local (often untracked) workflow YAML, discovery failed with "Workflow 'foo' not found" before execution could begin. Separate the discovery path from the execution path by adding an optional `discoveryCwd` to `WorkflowRunOptions`. Resume, approve, and reject now look up the codebase and pass `codebase.default_cwd` as `discoveryCwd`, so the source repo is searched even when `working_path` lives elsewhere. The execution cwd and the existing `findResumableRun` keying are unchanged. Changes: - Add `WorkflowRunOptions.discoveryCwd`; use it for `loadWorkflows` in `workflowRunCommand` - `workflowResumeCommand`, `workflowApproveCommand`, and `workflowRejectCommand` resolve `codebase.default_cwd` (with graceful fallback) and pass it through - Tests covering discovery from `codebase.default_cwd` and fallback to `working_path` when no codebase is available Fixes #1663
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR fixes workflow discovery during resume, approve, and reject operations to use the codebase's registered source directory instead of the run's working path. It adds a ChangesWorkflow Discovery and Resume Flow
Workflow Template Updates
Release Documentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review: NEEDS FIXES (4 items)The core CLI fix is correct — C1 — CRITICAL:
|
Comprehensive PR ReviewPR: #1743 — fix(cli): use source checkout cwd for workflow discovery on resume/approve/reject SummaryThe core fix is correct and minimal. Verdict:
🟠 High Issue (Blocker)Missing
|
- C1: Remove Write from denied_tools on analyze-impact and plan-refactor nodes in archon-refactor-safely.yaml — prompts write to $ARTIFACTS_DIR/*.md - H1: Add else branch with warn log when codebase record not found (null return) at all three discoveryCwd sites (resume/approve/reject) - H2: Log discovery path when discoveryCwd is set so the searched path is visible to users debugging workflow-not-found errors - I1: Add two regression tests for workflowRejectCommand discoveryCwd path (codebase found and fallback-when-null), mirroring approve/resume parity - Fix mock pollution: remove duplicate getWorkflowRun mockResolvedValueOnce in "throws when on_reject configured but working_path is null" test whose extra queued value leaked into subsequent tests - L3: Drop caller enumeration from discoveryCwd JSDoc; keep only the why - L4: Update codebaseId inline comment to include reject as a caller - L6: Fix workflowRejectCommand JSDoc to describe the auto-resume branch - M1: Add CHANGELOG entry for the #1663 fix under [Unreleased] - M2: Rename stale test name "fall through to auto-registration" to accurately describe the warn-and-fallback behavior on getCodebase failure - Regenerate bundled-defaults.generated.ts after YAML changes
⚡ Self-Fix Report (Aggressive)Status: COMPLETE Fixes Applied (9 total)
View all fixes
Bonus fix: Removed a duplicate Tests Added
Docs Updated
Skipped(none — all findings addressed) Suggested Follow-up Issues
Validation✅ Type check | ✅ Lint | ✅ Tests (99 passed across all packages) | ✅ Bundled defaults up to date Self-fix · aggressive mode · fixes pushed to |
Summary
workflow approve,workflow resume, andworkflow rejectfail with "Workflow '<name>' not found" for project-scoped workflows whenworktree.enabled: false(or when the workflow YAML lives only in the user's live checkout, not in the execution path)discoveryCwd?: stringtoWorkflowRunOptions; resume/approve/reject now look up the codebase record and passcodebase.default_cwdas the discovery root soloadWorkflows()searches the original source checkout instead of the execution worktree/clone pathworking_pathstorage,findResumableRunsignature, executor, web/chat orchestrator path, database schema — execution cwd is unchanged; only discovery cwd is separatedUX Journey
Before
After
Architecture Diagram
Before
After
Connection inventory:
workflowResumeCommandgetCodebaseworkflowApproveCommandgetCodebaseworkflowRejectCommandgetCodebaseworkflowRunCommandloadWorkflowsdiscoveryCwd ?? cwdWorkflowRunOptionsdiscoveryCwdfieldLabel Snapshot
risk: lowsize: Sclicli:workflowChange Metadata
bugcliLinked Issue
Validation Evidence (required)
All six checks passed:
check:bundledcheck:bundled-skillbun run type-checkbun run lintbun run format:checkbun run test3 new regression tests added:
workflowResumeCommand > should discover workflows from codebase.default_cwd, not working_pathworkflowResumeCommand > should fall back to working_path for discovery when codebase_id is missingworkflowApproveCommand > should discover workflows from codebase.default_cwd, not working_pathSecurity Impact (required)
Compatibility / Migration
discoveryCwdis optional; existing callers unchanged. Runs without acodebase_idfall back toworking_path(preserving pre-existing behavior).Human Verification (required)
discoverWorkflowsWithConfigis called withcodebase.default_cwdand notworking_pathcodebase_id(fallback toworking_path),getCodebasethrows (warn + fallback, graceful continue),rejectcommand sibling pathSide Effects / Blast Radius (required)
workflow resume,workflow approve,workflow rejectcommands onlyworking_path) is unchanged; only the discovery lookup is redirectedRollback Plan (required)
git revert HEAD~1(the fix commit is isolated)workflow approve/resume/reject(same error as before the fix)Risks and Mitigations
getCodebaseDB call added to hot path ofapprove/resume/reject— could add latency or fail if DB is unavailableworking_pathas discovery root) — no regression on DB hiccup, just the old bug reappears temporarilySummary by CodeRabbit