Skip to content

fix(phase): skip 999.x backlog phases in phase-add numbering#1493

Open
grgbrasil wants to merge 1 commit intogsd-build:mainfrom
grgbrasil:fix/phase-add-999-overflow
Open

fix(phase): skip 999.x backlog phases in phase-add numbering#1493
grgbrasil wants to merge 1 commit intogsd-build:mainfrom
grgbrasil:fix/phase-add-999-overflow

Conversation

@grgbrasil
Copy link
Copy Markdown
Contributor

Summary

  • cmdPhaseAdd included backlog phases (999.x) in maxPhase calculation, causing next phase number to be 1000 instead of the correct sequential value
  • Added if (num >= 999) continue; to skip backlog phases when determining the next phase ID
  • All 1527 existing tests pass; no regressions

Reproduction

  1. Have a ROADMAP.md with backlog entries using 999.x numbering (e.g., Phase 999.1:, Phase 999.2:)
  2. Run gsd-tools phase add "New Phase"
  3. Before fix: creates Phase 1000
  4. After fix: creates correct sequential phase (e.g., Phase 4 if phases 1-3 exist)

Test plan

  • Unit tests pass (1527/1528, 1 pre-existing unrelated failure)
  • Manual test: project with phases 1-3 + backlog 999.1/999.2 → phase add correctly produces phase 4, then 5

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@trek-e trek-e left a comment

Choose a reason for hiding this comment

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

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)
  • .gitignore modification (un-ignoring .planning/)
  • CLAUDE.md modification
  • 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.js hook

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

  1. Rebase onto main and resolve conflicts.
  2. Isolate the fix. Create a new branch from main with ONLY the 2-line change to get-shit-done/bin/lib/phase.cjs. The backlog skip fix is correct and should be its own PR.
  3. Remove all unrelated changes. The .planning/ directory, new agents, new commands, SDK changes, workflow modifications, .gitignore change, CLAUDE.md change, and new test files for unrelated features do not belong in a bugfix PR titled "skip 999.x backlog phases in phase-add numbering."
  4. Add a test for the actual fix -- a test that verifies cmdPhaseAdd correctly 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.

@trek-e trek-e added the review: changes requested PR reviewed — changes required before merge label Apr 1, 2026
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>
@grgbrasil grgbrasil force-pushed the fix/phase-add-999-overflow branch from 767d175 to a5cc451 Compare April 2, 2026 21:43
Copy link
Copy Markdown
Collaborator

@trek-e trek-e left a comment

Choose a reason for hiding this comment

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

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 numbering

Added 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 trek-e added review: approved PR reviewed and approved by maintainer bug Something isn't working area: workflow Phase execution, ROADMAP, STATE.md review: approved (merge conflict) PR approved but has merge conflicts — author must rebase and removed review: changes requested PR reviewed — changes required before merge review: approved PR reviewed and approved by maintainer labels Apr 4, 2026
Copy link
Copy Markdown
Collaborator

@trek-e trek-e left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

@trek-e trek-e left a comment

Choose a reason for hiding this comment

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

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.

@trek-e trek-e added the approved to merge Ready to merge — CI passing and review approved label Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved to merge Ready to merge — CI passing and review approved area: workflow Phase execution, ROADMAP, STATE.md bug Something isn't working review: approved (merge conflict) PR approved but has merge conflicts — author must rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants