From 53879d8c939a4f7fa4fe203c3b509ecea3eb4f6c Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Tue, 5 May 2026 18:38:37 -0400 Subject: [PATCH 1/2] test(3150): add stats.json regression for 06.10 decimal-gap sequence --- ...-3150-stats-json-decimal-gap-regression.md | 5 +++ ...150-stats-json-decimal-phase-gaps.test.cjs | 44 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .changeset/fix-3150-stats-json-decimal-gap-regression.md create mode 100644 tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs diff --git a/.changeset/fix-3150-stats-json-decimal-gap-regression.md b/.changeset/fix-3150-stats-json-decimal-gap-regression.md new file mode 100644 index 000000000..4dfead42d --- /dev/null +++ b/.changeset/fix-3150-stats-json-decimal-gap-regression.md @@ -0,0 +1,5 @@ +--- +type: Fixed +pr: 3150 +--- +**`stats.json` decimal phase ordering now has explicit regression coverage** — added a fixture ensuring `06.7/06.8/06.9` remain present when `06.10` exists, preventing dropped-phase regressions in mixed decimal phase ranges. \ No newline at end of file diff --git a/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs b/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs new file mode 100644 index 000000000..35251c7f0 --- /dev/null +++ b/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs @@ -0,0 +1,44 @@ +'use strict'; + +const { test, describe } = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs'); + +describe('bug #3150: stats.json includes contiguous decimal phases when .10 exists', () => { + test('stats json preserves 06.7/06.8/06.9 alongside 06.10', () => { + const tmpDir = createTempProject('gsd-bug-3150-'); + try { + fs.writeFileSync( + path.join(tmpDir, '.planning', 'ROADMAP.md'), + `# Roadmap\n\n### Phase 06.6: P06.6\n**Goal:** G\n\n### Phase 06.7: P06.7\n**Goal:** G\n\n### Phase 06.8: P06.8\n**Goal:** G\n\n### Phase 06.9: P06.9\n**Goal:** G\n\n### Phase 06.10: P06.10\n**Goal:** G\n` + ); + + const dirs = ['06.6-a', '06.7-b', '06.8-c', '06.9-d', '06.10-e']; + for (const dirName of dirs) { + const phaseDir = path.join(tmpDir, '.planning', 'phases', dirName); + fs.mkdirSync(phaseDir, { recursive: true }); + fs.writeFileSync(path.join(phaseDir, 'PLAN.md'), '# plan\n'); + fs.writeFileSync(path.join(phaseDir, 'SUMMARY.md'), '# summary\n'); + } + + const result = runGsdTools('stats json', tmpDir); + assert.ok(result.success, `Command failed: ${result.error}`); + + const output = JSON.parse(result.output); + const phaseNumbers = output.phases.map((p) => p.number); + + assert.deepStrictEqual( + phaseNumbers, + ['06.6', '06.7', '06.8', '06.9', '06.10'], + 'stats.json must not skip 06.7/06.8/06.9 when 06.10 exists' + ); + assert.equal(output.phases_total, 5); + assert.equal(output.total_plans, 5); + assert.equal(output.total_summaries, 5); + } finally { + cleanup(tmpDir); + } + }); +}); From b694d31239017b3b4632eae8aca0811d8c840b76 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Tue, 5 May 2026 18:53:35 -0400 Subject: [PATCH 2/2] chore(3155): address CodeRabbit changeset ref and test diagnostics --- ...fix-3150-stats-json-decimal-gap-regression.md | 2 +- ...g-3150-stats-json-decimal-phase-gaps.test.cjs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.changeset/fix-3150-stats-json-decimal-gap-regression.md b/.changeset/fix-3150-stats-json-decimal-gap-regression.md index 4dfead42d..8fd458586 100644 --- a/.changeset/fix-3150-stats-json-decimal-gap-regression.md +++ b/.changeset/fix-3150-stats-json-decimal-gap-regression.md @@ -1,5 +1,5 @@ --- type: Fixed -pr: 3150 +pr: 3155 --- **`stats.json` decimal phase ordering now has explicit regression coverage** — added a fixture ensuring `06.7/06.8/06.9` remain present when `06.10` exists, preventing dropped-phase regressions in mixed decimal phase ranges. \ No newline at end of file diff --git a/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs b/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs index 35251c7f0..56851750c 100644 --- a/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs +++ b/tests/bug-3150-stats-json-decimal-phase-gaps.test.cjs @@ -26,7 +26,21 @@ describe('bug #3150: stats.json includes contiguous decimal phases when .10 exis const result = runGsdTools('stats json', tmpDir); assert.ok(result.success, `Command failed: ${result.error}`); - const output = JSON.parse(result.output); + let output; + assert.doesNotThrow( + () => { + output = JSON.parse(result.output); + }, + `Command output must be valid JSON. Raw output prefix: ${result.output.slice(0, 200)}` + ); + assert.ok( + output && typeof output === 'object' && !Array.isArray(output), + `Expected object output, got: ${typeof output}` + ); + assert.ok( + Array.isArray(output.phases), + `Expected output.phases array. Raw output prefix: ${result.output.slice(0, 200)}` + ); const phaseNumbers = output.phases.map((p) => p.number); assert.deepStrictEqual(