fix(phase): skip 999.x backlog phases in phase-add numbering#1493
fix(phase): skip 999.x backlog phases in phase-add numbering#1493grgbrasil wants to merge 1 commit intogsd-build:mainfrom
Conversation
trek-e
left a comment
There was a problem hiding this comment.
Adversarial Review -- PR #1493
Author: grgbrasil
Title: fix(phase): skip 999.x backlog phases in phase-add numbering
Summary
The stated fix is a 2-line change to get-shit-done/bin/lib/phase.cjs that adds if (num >= 999) continue; to skip backlog phases (999.x numbering) when calculating the next sequential phase ID in cmdPhaseAdd. Without this, having backlog phases causes the next phase to be numbered 1000 instead of the correct sequential value.
Merge Status
CONFLICTING -- this PR cannot be merged in its current state.
Critical Problem: Scope Contamination
This PR modifies 94 files across 94 commits. The actual fix is 2 lines in phase.cjs. The remaining 92+ files are the contributor's entire local .planning/ directory, project research, milestone audits, new agents, new commands, new test files, new workflows, config changes, SDK modifications, and more. Files include:
.planning/PROJECT.md,.planning/ROADMAP.md,.planning/STATE.md(project-specific state).planning/phases/01-*through.planning/phases/06-*(full phase artifacts in Portuguese).gitignoremodification (un-ignoring.planning/)CLAUDE.mdmodification- New agents (
gsd-cataloger.md), new commands (ops-add.md,ops-init.md,ops-map.md) - New CLI modules (
fmap.cjs,ops.cjs,preflight.cjs) - SDK changes (
context-engine.ts,phase-prompt.ts,types.ts) - New test files (
fmap.test.cjs,ops.test.cjs,preflight.test.cjs,impact-analysis.test.cjs) - Workflow modifications (
execute-phase.md,new-project.md,plan-phase.md,ui-phase.md) - A
hooks/gsd-impact-guard.jshook
This is not a focused fix PR. This is an entire feature branch (impact analysis system, ops foundation, function mapping, preflight dependency resolver) with the 2-line backlog fix buried inside.
Security Concern
The .gitignore change removes the .planning/ ignore rule, which would cause every GSD user's local planning artifacts to show up as untracked files. This is a behavioral change that affects all users.
The CLAUDE.md modification and new agents/workflows would alter the behavior of the entire GSD system for all users if merged.
Requested Changes
- Rebase onto main and resolve conflicts.
- Isolate the fix. Create a new branch from
mainwith ONLY the 2-line change toget-shit-done/bin/lib/phase.cjs. The backlog skip fix is correct and should be its own PR. - Remove all unrelated changes. The
.planning/directory, new agents, new commands, SDK changes, workflow modifications,.gitignorechange,CLAUDE.mdchange, and new test files for unrelated features do not belong in a bugfix PR titled "skip 999.x backlog phases in phase-add numbering." - Add a test for the actual fix -- a test that verifies
cmdPhaseAddcorrectly produces phase 4 when phases 1-3 and 999.1/999.2 exist.
Verdict: REQUEST CHANGES
The 2-line fix itself is correct, but this PR ships ~95 unrelated files including security-relevant changes (.gitignore, CLAUDE.md, new hooks). Extract the fix into a clean single-concern PR.
Backlog phases use 999.x numbering and should not be counted when calculating the next sequential phase ID. Without this fix, having backlog phases causes the next phase to be numbered 1000+. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
767d175 to
a5cc451
Compare
trek-e
left a comment
There was a problem hiding this comment.
Adversarial Re-Review — APPROVED
Author completely reworked the PR since last review. All 4 blocking issues have been resolved.
Prior Issue Tracking
1. Scope contamination (94 files across 94 commits): FIXED
The PR is now 2 files, 1 commit. Only get-shit-done/bin/lib/phase.cjs (the actual fix) and tests/phase.test.cjs (the test). All unrelated changes (.planning/ directory, new agents, new commands, SDK changes, .gitignore modification, CLAUDE.md modification) have been removed.
2. Rebase onto main: FIXED
The PR is down to a single clean commit. Merge status shows UNKNOWN (GitHub may need to recalculate), but the diff is clean against the 2 files.
3. Isolate the fix: FIXED
The PR now contains exactly the 2-line fix to phase.cjs plus the test.
4. Add a test: FIXED
A test case 'skips 999.x backlog phases when calculating next phase number' has been added. It creates a ROADMAP with phases 1-3 and backlog phases 999.1/999.2, then verifies phase add Dashboard produces phase 4 (not 1000). The test checks: the phase_number in output, the slug, and the directory name. Correct and thorough.
Implementation Review
The fix itself is 2 lines:
if (num >= 999) continue; // backlog phases use 999.x numberingAdded inside the while loop that scans ROADMAP.md for phase numbers. Skips any phase number >= 999 when calculating the next sequential ID. Clean, minimal, correct.
No new issues found.
trek-e
left a comment
There was a problem hiding this comment.
Code Review
Verdict: APPROVE
Security
No issues found.
Logic / Correctness
The fix is correct. The regex /#{2,4}\s*Phase\s+(\d+)[A-Z]?(?:\.\d+)*:/gi already captures the leading integer of 999.x phases as 999, so the if (num >= 999) continue; guard fires at the right boundary. The threshold of 999 is appropriate given the stated convention that backlog phases use 999.x numbering; any legitimate active phase would never reach that number in practice. No off-by-one risk.
Test Coverage
Coverage is solid. The added test in tests/phase.test.cjs exercises the exact reproduction scenario (phases 1–3 plus backlog entries 999.1 and 999.2), asserts both the numeric output (phase_number === 4) and the filesystem artifact (04-dashboard directory exists). The PR description notes 1527 existing tests continue to pass.
One gap worth noting: there is no test confirming that adding a phase when 999.x entries are the only phases in the roadmap (i.e., no active phases yet) correctly produces phase 1 rather than 0 or erroring. Not a blocker — the logic falls through to maxPhase = 0 and would produce phase 1 correctly — but a regression test here would close the loop completely.
Style
Code and comment style matches the surrounding file. The inline comment // backlog phases use 999.x numbering is helpful.
Summary
Minimal, targeted fix for a clear off-by-one in the phase numbering logic; all CI checks pass across macOS, Ubuntu, and Windows on Node 22/24. One untested edge case (backlog-only roadmap) is logically safe but could use a follow-up test.
trek-e
left a comment
There was a problem hiding this comment.
Code Review Update (Pass 2)
Verdict: APPROVE — CI passing, issues resolved
Prior Review Resolution
The prior review approved the 999.x backlog phase skip fix. CI passes on all platforms. The fix is correct and the new test (skips 999.x backlog phases when calculating next phase number) provides adequate coverage.
Summary
Ready to merge. CI is green, prior review is APPROVED.
Summary
cmdPhaseAddincluded backlog phases (999.x) inmaxPhasecalculation, causing next phase number to be 1000 instead of the correct sequential valueif (num >= 999) continue;to skip backlog phases when determining the next phase IDReproduction
Phase 999.1:,Phase 999.2:)gsd-tools phase add "New Phase"Test plan
phase addcorrectly produces phase 4, then 5🤖 Generated with Claude Code