Skip to content

fix: honor workstream in verify-work init#3386

Merged
trek-e merged 2 commits into
mainfrom
fix/3381-init-verify-work-ws
May 11, 2026
Merged

fix: honor workstream in verify-work init#3386
trek-e merged 2 commits into
mainfrom
fix/3381-init-verify-work-ws

Conversation

@trek-e
Copy link
Copy Markdown
Collaborator

@trek-e trek-e commented May 11, 2026

Fix PR

Using the wrong template?
— Enhancement: use enhancement.md
— Feature: use feature.md


Linked Issue

Fixes #3381


What was broken

gsd-sdk query init.verify-work <phase> --ws <workstream> ignored the selected workstream and looked in root .planning/, so workstream-scoped phases returned phase_found: false.

The verify-work workflow also called workstream-sensitive SDK queries without forwarding the --ws argument from $ARGUMENTS.

What this fix does

Threads the SDK workstream parameter through initVerifyWork phase lookup and config loading.

Extracts ${GSD_WS} in verify-work.md and forwards it to init.verify-work, phase.mvp-mode, and roadmap.get-phase. The command hint now advertises --ws <name>.

Root cause

getPhaseInfoForVerifyWork was a separate helper from the shared init phase lookup path and called findPhase / roadmapGetPhase without passing the QueryHandler workstream argument.

Testing

How I verified the fix

  • npm test -- --run src/query/init.test.ts
  • node --test tests/bug-3381-verify-work-workstream.test.cjs
  • npm run build in sdk/
  • Manual SDK CLI repro against a temp workstream fixture:
    • Before: init.verify-work 32 --ws delivery returned phase_found: false
    • After: phase_found: true and phase_dir: ".planning/workstreams/delivery/phases/32-shipment-creation-tracking-numbers-print-forms"
  • npm run lint:tests
  • npm run lint:changeset

Regression test added?

  • Yes — added tests for SDK initVerifyWork workstream routing and workflow ${GSD_WS} forwarding
  • No — explain why:

Platforms tested

  • macOS
  • Windows (including backslash path handling)
  • Linux
  • N/A (not platform-specific)

Runtimes tested

  • Claude Code
  • Gemini CLI
  • OpenCode
  • Other: SDK CLI query path
  • N/A (not runtime-specific)

Checklist

  • Issue linked above with Fixes #NNNPR will be auto-closed if missing
  • Linked issue has the confirmed-bug label
  • Fix is scoped to the reported bug — no unrelated changes included
  • Regression test added (or explained why not)
  • All existing tests pass (npm test)
  • .changeset/ fragment added if this is a user-facing fix (npm run changeset -- --type Fixed --pr <NNN> --body "...") — or no-changelog label applied
  • No unnecessary dependencies added

Breaking changes

None

Summary by CodeRabbit

  • New Features

    • Added optional --ws parameter to gsd-verify-work for resolving phases within a selected workstream.
  • Bug Fixes

    • Phase and roadmap resolution now respects the chosen workstream instead of falling back to the root planning area.
    • When in MVP mode, verify-work validates that phase goals follow the User Story format and prompts corrective steps if not.
  • Tests

    • Added tests to verify workstream-aware phase resolution and flag parsing.

Review Change Stack

@trek-e trek-e requested a review from glittercowboy as a code owner May 11, 2026 00:02
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3306c97d-41c2-40bf-9764-2509fbc3c51a

📥 Commits

Reviewing files that changed from the base of the PR and between 7f54253 and 315ac6b.

📒 Files selected for processing (2)
  • get-shit-done/workflows/verify-work.md
  • tests/bug-3381-verify-work-workstream.test.cjs
🚧 Files skipped from review as they are similar to previous changes (2)
  • get-shit-done/workflows/verify-work.md
  • tests/bug-3381-verify-work-workstream.test.cjs

📝 Walkthrough

Walkthrough

Threads an optional --ws workstream argument from the verify-work workflow into the SDK init handler and MVP checks. initVerifyWork now accepts workstream and resolves phases within the selected workstream; workflow forwards GSD_WS and validates MVP Goal format before proceeding.

Changes

Workstream-aware phase resolution

Layer / File(s) Summary
SDK handler signature and phase lookup logic
sdk/src/query/init.ts
initVerifyWork now accepts an optional workstream parameter; getPhaseInfoForVerifyWork forwards workstream to findPhase and roadmapGetPhase; fallback slug uses generateSlugInternal.
Unit test for workstream-scoped phase resolution
sdk/src/query/init.test.ts
New test asserts initVerifyWork(['32'], tmpDir, 'delivery') returns phase_dir under .planning/workstreams/delivery/phases/....
Workflow argument threading and validation
get-shit-done/workflows/verify-work.md
Workflow extracts --ws into GSD_WS, passes it into gsd-sdk query init.verify-work and phase.mvp-mode, and when MVP_MODE=true validates the phase Goal is in User Story format (exits with guidance if invalid).
Integration test for workflow contract
tests/bug-3381-verify-work-workstream.test.cjs
Node.js test verifies verify-work.md initializes GSD_WS, strips --ws from ARGUMENTS to derive PHASE_ARG, and forwards ${GSD_WS} into init.verify-work, phase.mvp-mode, and roadmap.get-phase queries.
Command documentation and changeset
commands/gsd/verify-work.md, .changeset/fix-3381-init-verify-work-ws.md
argument-hint updated to document optional --ws <name>; changeset notes workstream-scoped phase resolution fix.

Sequence Diagram(s)

sequenceDiagram
  participant User as CLI
  participant Workflow as verify-work.md
  participant SDK as gsd-sdk
  participant Roadmap as roadmap.get-phase
  User->>Workflow: gsd-verify-work <phase> --ws <name>
  Workflow->>SDK: query init.verify-work(phase, workstream=GSD_WS)
  SDK->>Roadmap: roadmap.get-phase(phase, workstream=GSD_WS)
  Roadmap-->>SDK: phase metadata (phase_dir, Goal)
  SDK-->>Workflow: phase_info
  Workflow->>SDK: query phase.mvp-mode(phase, workstream=GSD_WS)
  SDK-->>Workflow: MVP_MODE result
  Workflow->>Workflow: validate Goal with user-story.validate (if MVP_MODE)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bug, area: workflows, area: core, needs-review

Suggested reviewers

  • glittercowboy
  • Ari4ka

Poem

🐰 I hopped through args and found a trail,
A hidden ws that made phases prevail.
Threaded through SDK, workflow, and file,
Now verify-work returns with a smile.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: honor workstream in verify-work init' accurately and concisely describes the main change: ensuring the verify-work initialization respects the workstream parameter.
Description check ✅ Passed The PR description follows the fix template, clearly explaining the bug, root cause, solution, testing approach, and regression tests added, with all checklist items appropriately addressed.
Linked Issues check ✅ Passed All code changes directly address the linked issue #3381: initVerifyWork now accepts and forwards the workstream parameter [#3381], verify-work.md threads GSD_WS through SDK queries [#3381], and tests validate workstream-aware phase resolution [#3381].
Out of Scope Changes check ✅ Passed All changes are scoped to fixing issue #3381: SDK parameter threading, workflow forwarding, command documentation, and focused regression tests with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3381-init-verify-work-ws

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/bug-3381-verify-work-workstream.test.cjs (1)

17-21: 💤 Low value

Consider relaxing the character-count bounds in the regex.

The regex on line 19 uses exact character limits ([\s\S]{0,260} and [\s\S]{0,160}) to verify the GSD_WS extraction logic. While this validates the contract, the tight bounds are fragile—adding comments or reformatting could break the test even if the behavior is correct.

Consider using a more flexible pattern that checks for the presence of both grep commands without strict distance limits, or document that this test is intentionally strict about formatting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/bug-3381-verify-work-workstream.test.cjs` around lines 17 - 21, The
test's regex on the variable workflow is brittle because it uses exact
character-count bounds ([\s\S]{0,260} and [\s\S]{0,160}); update the assertion
to relax those bounds by replacing them with a non-greedy any-span pattern
(e.g., [\s\S]*? or equivalent) or by splitting into two assertions that
independently check for the two grep invocations, referencing the workflow
variable and the grep -qE and grep -oE patterns so the test verifies presence
and order without strict distance limits.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@get-shit-done/workflows/verify-work.md`:
- Around line 33-36: The INIT call uses an undeclared PHASE_ARG; add extraction
of PHASE_ARG from $ARGUMENTS before invoking gsd-sdk so the phase is passed
correctly — remove any --ws argument first, trim whitespace, and assign to
PHASE_ARG (ensure this runs after detecting/extracting GSD_WS) so INIT=$(gsd-sdk
query init.verify-work "${PHASE_ARG}" ${GSD_WS}) receives a valid phase;
reference symbols: PHASE_ARG, GSD_WS, INIT, and gsd-sdk query init.verify-work.

---

Nitpick comments:
In `@tests/bug-3381-verify-work-workstream.test.cjs`:
- Around line 17-21: The test's regex on the variable workflow is brittle
because it uses exact character-count bounds ([\s\S]{0,260} and [\s\S]{0,160});
update the assertion to relax those bounds by replacing them with a non-greedy
any-span pattern (e.g., [\s\S]*? or equivalent) or by splitting into two
assertions that independently check for the two grep invocations, referencing
the workflow variable and the grep -qE and grep -oE patterns so the test
verifies presence and order without strict distance limits.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e861fc0-88fd-4889-8652-2bc6fcd2e380

📥 Commits

Reviewing files that changed from the base of the PR and between 570dddd and 7f54253.

📒 Files selected for processing (6)
  • .changeset/fix-3381-init-verify-work-ws.md
  • commands/gsd/verify-work.md
  • get-shit-done/workflows/verify-work.md
  • sdk/src/query/init.test.ts
  • sdk/src/query/init.ts
  • tests/bug-3381-verify-work-workstream.test.cjs

Comment thread get-shit-done/workflows/verify-work.md
@github-actions github-actions Bot added size/M and removed size/M labels May 11, 2026
@trek-e trek-e merged commit 574d1f4 into main May 11, 2026
15 checks passed
@trek-e trek-e deleted the fix/3381-init-verify-work-ws branch May 11, 2026 00:25
github-actions Bot pushed a commit that referenced this pull request May 11, 2026
* fix: honor workstream in verify-work init

* fix: define verify-work phase arg

(cherry picked from commit 574d1f4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: init.verify-work ignores --ws workstream

1 participant