Fix T-820: Batch Remove Shifts Phase Boundaries#90
Conversation
Code Review: Fix T-820 - Batch Remove Shifts Phase BoundariesOverviewThis PR fixes a real and impactful bug: batch remove operations on phased files were silently stripping all phase headers because the CLI dispatch logic only checked whether an operation referenced a phase, not whether the file itself contained phases. The fix is well-motivated, clearly explained, and comes with a regression test and a detailed bug report. Strengths
Issues and SuggestionsMinor: Unchecked errors in the test The test discards errors from Minor: Test verifies phase containment but not task renumbering after remove The test uses Negligible: Performance overhead for non-phased files
Observation: Fallback path coverage There is no new test explicitly asserting that non-phased files still exercise the Summary
Solid, well-documented bugfix. The main item worth addressing before merge is the unchecked |
PR Review Overview - Iteration 1PR: #90 | Branch: T-820/bugfix-batch-remove-shifts-phase-boundaries | Date: 2025-07-22 Valid Issues (all minor — no fixes required)No blockers, critical, or major issues found. Minor Issues (not fixed — non-blocking)
Negligible / Observations (no action needed)
CI StatusAll 12 checks passed ✅ — no CI issues to fix. |
|
Claude finished @ArjenSchwarz's task in 5m 40s —— View job PR Review - Iteration 2Addressed both minor issues from Iteration 1. All changes are in
Changes made
1. Fix unchecked errors — 2. Add task renumbering assertions — After removing tasks 1 and 3 from the phased file, the four remaining tasks must be renumbered 1–4. The batch engine applies removes highest-ID-first (3 then 1), so the expected result is: Also added explicit assertions that the removed tasks ( 3. Bonus fix: All unit tests pass ( |
The batch command's executeBatchCommand only used phase-aware execution when an operation explicitly referenced a phase (op.Phase or add-phase). Plain remove operations on files with phases took the non-phase path, parsing without phases and writing back without phase headers. Fix: always parse with ParseFileWithPhases so the file's own phase markers are detected. Dispatch to ExecuteBatchWithPhases when the file has phases or operations reference phases; fall back to regular ExecuteBatch only when neither condition applies. - cmd/batch.go: restructure dispatch to always detect file phases - cmd/batch_test.go: add regression test for remove-only batch on phased files - specs/bugfixes/batch-remove-shifts-phase-boundaries/report.md: add bugfix report Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
200b9f6 to
618dec7
Compare
Code Review: Fix T-820 - Batch Remove Shifts Phase BoundariesOverviewThis PR fixes a logic error in Code Quality and Correctness
Test Coverage
The test covers the happy path well, but has a few gaps worth addressing:
if strings.Contains(contentStr, "Define requirements") {
t.Error("Task 1 should have been removed")
}
if strings.Contains(contentStr, "Write code") {
t.Error("Task 3 should have been removed")
}
SecurityNo concerns. The change is purely dispatch logic with no new file path handling, no user-controlled format strings, and no new external inputs. Performance
SummaryThe root cause analysis is correct, the fix is minimal and well-scoped, and the regression test covers the primary scenario. Main suggestions:
These are minor — the fix itself is solid. Good work tracking down the root cause in the CLI dispatch layer rather than in the internal library. |
Summary
Batch remove operations on phased files were stripping all phase headers because
cmd/batch.goonly used phase-aware execution when an operation explicitly referenced a phase (op.Phaseoradd-phase). Plain removes took the non-phase path, destroying the phase structure.Root Cause
The dispatch logic in
executeBatchCommandcheckedhasPhaseOps(whether any operation names a phase), but not whether the file itself contains phases. The internalExecuteBatchWithPhasesalready had the correct guard (len(phaseMarkers) > 0 || hasPhaseOps), but the CLI layer short-circuited before reaching it.Fix
Always parse with
ParseFileWithPhasesso the file's own phase markers are detected. UseExecuteBatchWithPhaseswhen the file has phases or operations reference phases; fall back to regularExecuteBatchonly when neither condition applies.Changes
cmd/batch.go— Restructure dispatch to always detect file phasescmd/batch_test.go— Add regression testTestBatchCommand_RemoveOnPhasedFilePreservesPhasesspecs/bugfixes/batch-remove-shifts-phase-boundaries/report.md— Bugfix reportTesting
make test)