refactor: hard-fork GSD -> MSD (Make Software Done)

Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
This commit is contained in:
Jakub Zych
2026-10-06 01:47:40 +02:00
parent fe069b2a56
commit a9a7a328e6
2763 changed files with 78465 additions and 78434 deletions

View File

@@ -1,5 +1,5 @@
/**
* Tests for src/phase-locator.cts (compiled to gsd-core/bin/lib/phase-locator.cjs).
* Tests for src/phase-locator.cts (compiled to msd-core/bin/lib/phase-locator.cjs).
*
* Verifies behavioural contracts of the phase-locator helpers extracted from
* core.cjs per ADR-857 rollout phase 2d (#881):
@@ -24,10 +24,10 @@ const fs = require('node:fs');
const path = require('node:path');
const fc = require('./helpers/fast-check-setup.cjs');
const phaseLocator = require('../gsd-core/bin/lib/phase-locator.cjs');
const planDependencyGraph = require('../gsd-core/bin/lib/plan-dependency-graph.cjs');
const phaseLocator = require('../msd-core/bin/lib/phase-locator.cjs');
const planDependencyGraph = require('../msd-core/bin/lib/plan-dependency-graph.cjs');
const {
runGsdTools, createTempProject, createTempDir, cleanup, isolateWorkstreamEnv, restoreWorkstreamEnv,
runMsdTools, createTempProject, createTempDir, cleanup, isolateWorkstreamEnv, restoreWorkstreamEnv,
captureFdSync,
} = require('./helpers.cjs');
const driftGuard = require('../scripts/lint-phase-enumeration-drift.cjs');
@@ -39,7 +39,7 @@ describe('findPhaseInternal: active phase lookup', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('returns null for falsy phase argument', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
assert.strictEqual(phaseLocator.findPhaseInternal(tmpDir, null), null);
assert.strictEqual(phaseLocator.findPhaseInternal(tmpDir, ''), null);
assert.strictEqual(phaseLocator.findPhaseInternal(tmpDir, 0), null);
@@ -48,20 +48,20 @@ describe('findPhaseInternal: active phase lookup', () => {
test('returns null when phases dir does not exist', () => {
// Use a raw tmpDir (no phases subdir) to simulate missing phases dir
tmpDir = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'gsd-pl-test-'));
tmpDir = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'msd-pl-test-'));
fs.mkdirSync(path.join(tmpDir, '.planning'), { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
assert.strictEqual(result, null);
});
test('returns null when phases dir is empty', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
assert.strictEqual(result, null);
});
test('finds a simple phase by number (zero-padded dir)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// Phase dirs use zero-padded format: normalizePhaseName('1') = '01'
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01-setup');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -76,7 +76,7 @@ describe('findPhaseInternal: active phase lookup', () => {
});
test('finds phase by full normalized id', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '02-auth');
fs.mkdirSync(phaseDir, { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '02');
@@ -86,7 +86,7 @@ describe('findPhaseInternal: active phase lookup', () => {
});
test('reports plans and summaries from phase directory', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01-impl');
fs.mkdirSync(phaseDir, { recursive: true });
fs.writeFileSync(path.join(phaseDir, 'FEATURE-PLAN.md'), '# Plan');
@@ -99,7 +99,7 @@ describe('findPhaseInternal: active phase lookup', () => {
});
test('includes incomplete plans (plans without corresponding summaries)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '03-work');
fs.mkdirSync(phaseDir, { recursive: true });
fs.writeFileSync(path.join(phaseDir, 'A-PLAN.md'), '# A Plan');
@@ -112,7 +112,7 @@ describe('findPhaseInternal: active phase lookup', () => {
});
test('directory is a posix-style relative path from cwd', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01-setup');
fs.mkdirSync(phaseDir, { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -122,7 +122,7 @@ describe('findPhaseInternal: active phase lookup', () => {
});
test('returns null when requested phase is not present', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
fs.mkdirSync(path.join(tmpDir, '.planning', 'phases', '02-other'), { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
assert.strictEqual(result, null);
@@ -136,7 +136,7 @@ describe('findPhaseInternal: decimal and complex phase ids (adversarial)', () =>
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('finds decimal sub-phase (e.g. 01.1)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// normalizePhaseName('1.1') = '01.1'
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01.1-subsection');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -147,7 +147,7 @@ describe('findPhaseInternal: decimal and complex phase ids (adversarial)', () =>
});
test('decimal sub-phase dir is not matched by integer-only search', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// Create only 01.1-sub, NOT 01-something: searching for '1' should return null
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01.1-sub');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -157,7 +157,7 @@ describe('findPhaseInternal: decimal and complex phase ids (adversarial)', () =>
});
test('handles phases with multi-segment names', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '05-some-long-phase-name');
fs.mkdirSync(phaseDir, { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '5');
@@ -167,7 +167,7 @@ describe('findPhaseInternal: decimal and complex phase ids (adversarial)', () =>
});
test('phase with unicode in name — does not throw', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
try {
const phaseDir = path.join(tmpDir, '.planning', 'phases', '06-中文');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -191,7 +191,7 @@ describe('findPhaseInternal: archived milestone phase lookup', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('finds archived phase when not in active phases', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const milestonesDir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
fs.mkdirSync(path.join(milestonesDir, '01-archived'), { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -202,7 +202,7 @@ describe('findPhaseInternal: archived milestone phase lookup', () => {
});
test('prefers active phase over archived phase', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// Set up both active and archived phase 01
fs.mkdirSync(path.join(tmpDir, '.planning', 'phases', '01-active'), { recursive: true });
const milestonesDir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
@@ -215,7 +215,7 @@ describe('findPhaseInternal: archived milestone phase lookup', () => {
});
test('searches most recent milestone first (reverse sort)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// v1.2.0 archive has phase 03, v1.1.0 archive also has phase 03
const v110 = path.join(tmpDir, '.planning', 'milestones', 'v1.1.0-phases');
const v120 = path.join(tmpDir, '.planning', 'milestones', 'v1.2.0-phases');
@@ -228,7 +228,7 @@ describe('findPhaseInternal: archived milestone phase lookup', () => {
});
test('returns null when phase exists in neither active nor archive', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const milestonesDir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
fs.mkdirSync(path.join(milestonesDir, '02-other'), { recursive: true });
const result = phaseLocator.findPhaseInternal(tmpDir, '99');
@@ -236,14 +236,14 @@ describe('findPhaseInternal: archived milestone phase lookup', () => {
});
test('returns null when milestones dir does not exist', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// No .planning/milestones dir — only .planning/phases (empty)
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
assert.strictEqual(result, null);
});
test('ignores non-matching milestone dir names (not vX.Y.Z-phases)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
// Directory that doesn't match /^v[\d.]+-phases$/ should be skipped
const badDir = path.join(tmpDir, '.planning', 'milestones', 'not-a-phases-dir');
fs.mkdirSync(path.join(badDir, '01-phase'), { recursive: true });
@@ -259,13 +259,13 @@ describe('getArchivedPhaseDirs', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('returns empty array when .planning/milestones does not exist', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const result = phaseLocator.getArchivedPhaseDirs(tmpDir);
assert.deepEqual(result, []);
});
test('returns empty array when milestones dir has no matching phase-archive dirs', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const milestonesDir = path.join(tmpDir, '.planning', 'milestones');
fs.mkdirSync(milestonesDir, { recursive: true });
fs.mkdirSync(path.join(milestonesDir, 'not-phases-dir'));
@@ -274,7 +274,7 @@ describe('getArchivedPhaseDirs', () => {
});
test('returns phase entries from a single milestone archive', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const archiveDir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
fs.mkdirSync(path.join(archiveDir, '01-feature'), { recursive: true });
fs.mkdirSync(path.join(archiveDir, '02-bugfix'), { recursive: true });
@@ -286,7 +286,7 @@ describe('getArchivedPhaseDirs', () => {
});
test('result entries have correct shape', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const archiveDir = path.join(tmpDir, '.planning', 'milestones', 'v2.1.0-phases');
fs.mkdirSync(path.join(archiveDir, '03-auth'), { recursive: true });
const result = phaseLocator.getArchivedPhaseDirs(tmpDir);
@@ -303,7 +303,7 @@ describe('getArchivedPhaseDirs', () => {
});
test('aggregates phases from multiple milestone archives (most recent first)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const v1Dir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
const v2Dir = path.join(tmpDir, '.planning', 'milestones', 'v2.0.0-phases');
fs.mkdirSync(path.join(v1Dir, '01-old'), { recursive: true });
@@ -317,7 +317,7 @@ describe('getArchivedPhaseDirs', () => {
});
test('adversarial: milestone-prefixed dir names that do not match pattern are skipped', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const milestonesDir = path.join(tmpDir, '.planning', 'milestones');
fs.mkdirSync(milestonesDir, { recursive: true });
// These should all be ignored (do not match /^v[\d.]+-phases$/):
@@ -330,7 +330,7 @@ describe('getArchivedPhaseDirs', () => {
});
test('returns empty array for empty milestone archive dirs', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const archiveDir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
fs.mkdirSync(archiveDir, { recursive: true });
// Archive dir exists but has no phase subdirs
@@ -351,7 +351,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('returns null when no matching subdirectory exists', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
fs.mkdirSync(path.join(phasesDir, '02-other'), { recursive: true });
const result = phaseLocator.searchPhaseInDir(phasesDir, '.planning/phases', '01');
@@ -359,7 +359,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('finds matching dir and returns correct structure', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
fs.mkdirSync(path.join(phasesDir, '01-hello'), { recursive: true });
const result = phaseLocator.searchPhaseInDir(phasesDir, '.planning/phases', '01');
@@ -372,7 +372,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('relBase is prepended to directory in result', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const archiveDir = path.join(tmpDir, '.planning', 'milestones', 'v1.0.0-phases');
fs.mkdirSync(path.join(archiveDir, '03-feat'), { recursive: true });
const result = phaseLocator.searchPhaseInDir(archiveDir, '.planning/milestones/v1.0.0-phases', '03');
@@ -381,7 +381,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('adversarial: dir with normal name does not produce path traversal', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
fs.mkdirSync(path.join(phasesDir, '01-normal-phase'), { recursive: true });
const result = phaseLocator.searchPhaseInDir(phasesDir, '.planning/phases', '01');
@@ -391,7 +391,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('adversarial: phase number with repeated decimal segments (e.g. 1.1.1)', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
fs.mkdirSync(path.join(phasesDir, '01.1.1-deep'), { recursive: true });
// Result may be found or null depending on normalization; must not throw
@@ -400,7 +400,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('returns has_research/has_context/has_verification/has_reviews as booleans', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
const phaseDir = path.join(phasesDir, '01-test');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -415,7 +415,7 @@ describe('searchPhaseInDir: direct filesystem search', () => {
});
test('adversarial: empty phases dir (no subdirs) returns null', () => {
tmpDir = createTempProject('gsd-pl-test-');
tmpDir = createTempProject('msd-pl-test-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
const result = phaseLocator.searchPhaseInDir(phasesDir, '.planning/phases', '01');
assert.strictEqual(result, null);
@@ -428,7 +428,7 @@ describe('#2237: ambiguous phase-directory collision', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('searchPhaseInDir returns ambiguous_matches when two dirs share phase number', () => {
tmpDir = createTempProject('gsd-pl-collision-');
tmpDir = createTempProject('msd-pl-collision-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
// Two unrelated projects with same phase number
fs.mkdirSync(path.join(phasesDir, '04-alpha-feature'), { recursive: true });
@@ -443,7 +443,7 @@ describe('#2237: ambiguous phase-directory collision', () => {
});
test('findPhaseInternal propagates ambiguous result', () => {
tmpDir = createTempProject('gsd-pl-collision-');
tmpDir = createTempProject('msd-pl-collision-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
fs.mkdirSync(path.join(phasesDir, '05-gamma'), { recursive: true });
fs.mkdirSync(path.join(phasesDir, '05-delta'), { recursive: true });
@@ -454,7 +454,7 @@ describe('#2237: ambiguous phase-directory collision', () => {
});
test('single match still resolves normally (no false positive)', () => {
tmpDir = createTempProject('gsd-pl-collision-');
tmpDir = createTempProject('msd-pl-collision-');
const phasesDir = path.join(tmpDir, '.planning', 'phases');
fs.mkdirSync(path.join(phasesDir, '03-only-phase'), { recursive: true });
const result = phaseLocator.searchPhaseInDir(phasesDir, '.planning/phases', '03');
@@ -535,10 +535,10 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('direct dependent of a halted plan is blocked, not runnable', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
buildBaseFixture(tmpDir);
const result = runGsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
assert.ok(result.success, `phase-plan-index should succeed: ${result.error}`);
const data = JSON.parse(result.output);
@@ -550,10 +550,10 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('transitive dependent (2 hops) is blocked via chain', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
buildBaseFixture(tmpDir);
const result = runGsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const data = JSON.parse(result.output);
const p03 = data.plans.find((p) => p.id === '01-03');
@@ -563,13 +563,13 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('transitive dependent at 3 hops stays blocked', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = buildBaseFixture(tmpDir);
writePlan(phaseDir, '01-05-PLAN.md', [
'wave: 4', 'objective: 3-hop dependent', 'autonomous: true', 'depends_on:', ' - 01-03',
]);
const result = runGsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const data = JSON.parse(result.output);
const p05 = data.plans.find((p) => p.id === '01-05');
@@ -579,7 +579,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('diamond dependency is blocked by both halted ancestors', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '02-diamond');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -592,7 +592,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'depends_on:', ' - 02-01', ' - 02-02',
]);
const result = runGsdTools(['phase-plan-index', '2', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '2', '--raw'], tmpDir);
assert.ok(result.success, `phase-plan-index should succeed: ${result.error}`);
const data = JSON.parse(result.output);
@@ -606,10 +606,10 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('unrelated decoupled plan stays runnable', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
buildBaseFixture(tmpDir);
const result = runGsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const data = JSON.parse(result.output);
const p04 = data.plans.find((p) => p.id === '01-04');
@@ -619,10 +619,10 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('incomplete field stays byte-identical when blocked plans are present', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
buildBaseFixture(tmpDir);
const result = runGsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const data = JSON.parse(result.output);
// Pre-#2830 semantics: incomplete = every plan without a matching SUMMARY,
@@ -637,7 +637,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('dependency on an ordinary incomplete (non-halted) plan is not "blocked"', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '03-ordinary');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -648,7 +648,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'depends_on:', ' - 03-01',
]);
const result = runGsdTools(['phase-plan-index', '3', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '3', '--raw'], tmpDir);
const data = JSON.parse(result.output);
const p01 = data.plans.find((p) => p.id === '03-01');
@@ -661,7 +661,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('unresolved depends_on id is ignored, not blocked', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '04-unresolved');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -670,7 +670,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'depends_on:', ' - 99-99',
]);
const result = runGsdTools(['phase-plan-index', '4', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '4', '--raw'], tmpDir);
assert.ok(result.success, `phase-plan-index should not throw on an unresolved dependency: ${result.error}`);
const data = JSON.parse(result.output);
@@ -681,7 +681,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('malformed (unterminated) SUMMARY frontmatter fails open to not-halted', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '05-malformed');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -700,7 +700,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'---\nphase: 05-malformed\nplan: 01\nstatus: halted\n', // no closing '---'
);
const result = runGsdTools(['phase-plan-index', '5', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '5', '--raw'], tmpDir);
assert.ok(result.success, `phase-plan-index must not throw on malformed frontmatter: ${result.error}`);
const data = JSON.parse(result.output);
@@ -713,7 +713,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('CRLF SUMMARY frontmatter still detects status: halted', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '06-crlf');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -726,7 +726,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'wave: 2', 'objective: Depends on CRLF-summarized halt', 'autonomous: true', 'depends_on:', ' - 06-01',
]);
const result = runGsdTools(['phase-plan-index', '6', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '6', '--raw'], tmpDir);
assert.ok(result.success, `phase-plan-index should succeed on CRLF frontmatter: ${result.error}`);
const data = JSON.parse(result.output);
@@ -739,7 +739,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('status complete does not block dependents', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '07-complete');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -749,7 +749,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'wave: 2', 'objective: Depends on completed plan', 'autonomous: true', 'depends_on:', ' - 07-01',
]);
const result = runGsdTools(['phase-plan-index', '7', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '7', '--raw'], tmpDir);
const data = JSON.parse(result.output);
const p01 = data.plans.find((p) => p.id === '07-01');
@@ -762,7 +762,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
});
test('dependency cycle detection is unaffected by halt propagation', () => {
tmpDir = createTempProject('gsd-2830-');
tmpDir = createTempProject('msd-2830-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '08-cycle');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -773,7 +773,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
'wave: 1', 'objective: Cycle B', 'autonomous: true', 'depends_on:', ' - 08-01',
]);
const result = runGsdTools(['phase-plan-index', '8', '--raw'], tmpDir);
const result = runMsdTools(['phase-plan-index', '8', '--raw'], tmpDir);
// CONTRIBUTING.md "Prohibited: Raw Text Matching on Test Outputs" bans
// regex-matching a child process's human-readable stderr/reason prose —
// assert on the typed failure signal (`result.success`) instead. Pair it
@@ -787,7 +787,7 @@ describe('phase-plan-index: halt propagation (#2830)', () => {
writePlan(acyclicDir, '09-02-PLAN.md', [
'wave: 1', 'objective: No cycle B', 'autonomous: true', 'depends_on:', ' - 09-01',
]);
const acyclicResult = runGsdTools(['phase-plan-index', '9', '--raw'], tmpDir);
const acyclicResult = runMsdTools(['phase-plan-index', '9', '--raw'], tmpDir);
assert.strictEqual(
acyclicResult.success,
true,
@@ -801,7 +801,7 @@ describe('findPhaseInternal: halt propagation (#2830)', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('direct dependent of a halted plan is blocked', () => {
tmpDir = createTempProject('gsd-2830-pl-');
tmpDir = createTempProject('msd-2830-pl-');
buildBaseFixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -811,7 +811,7 @@ describe('findPhaseInternal: halt propagation (#2830)', () => {
});
test('transitive dependent is blocked via chain', () => {
tmpDir = createTempProject('gsd-2830-pl-');
tmpDir = createTempProject('msd-2830-pl-');
buildBaseFixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -820,7 +820,7 @@ describe('findPhaseInternal: halt propagation (#2830)', () => {
});
test('diamond dependency blocked by both halted ancestors', () => {
tmpDir = createTempProject('gsd-2830-pl-');
tmpDir = createTempProject('msd-2830-pl-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '02-diamond');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -843,7 +843,7 @@ describe('findPhaseInternal: halt propagation (#2830)', () => {
});
test('unrelated decoupled plan stays runnable', () => {
tmpDir = createTempProject('gsd-2830-pl-');
tmpDir = createTempProject('msd-2830-pl-');
buildBaseFixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -852,7 +852,7 @@ describe('findPhaseInternal: halt propagation (#2830)', () => {
});
test('incomplete_plans stays byte-identical when blocked plans are present', () => {
tmpDir = createTempProject('gsd-2830-pl-');
tmpDir = createTempProject('msd-2830-pl-');
buildBaseFixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -864,7 +864,7 @@ describe('findPhaseInternal: halt propagation (#2830)', () => {
});
test('halted_plans reports the halted plan itself by filename', () => {
tmpDir = createTempProject('gsd-2830-pl-');
tmpDir = createTempProject('msd-2830-pl-');
buildBaseFixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
@@ -877,10 +877,10 @@ describe('parity: phase-plan-index and findPhaseInternal agree on blocking (#283
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('same fixture yields the same blocked-plan set and cause set from both readers', () => {
tmpDir = createTempProject('gsd-2830-parity-');
tmpDir = createTempProject('msd-2830-parity-');
buildBaseFixture(tmpDir);
const cliResult = runGsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
const cliResult = runMsdTools(['phase-plan-index', '1', '--raw'], tmpDir);
assert.ok(cliResult.success, `phase-plan-index should succeed: ${cliResult.error}`);
const cliData = JSON.parse(cliResult.output);
@@ -1030,10 +1030,10 @@ describe('init execute-phase: halt propagation passthrough (#2830)', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('halted_plans, blocked_by, runnable_plans are forwarded; incomplete fields stay byte-identical', () => {
tmpDir = createTempProject('gsd-2830-init-');
tmpDir = createTempProject('msd-2830-init-');
buildBaseFixture(tmpDir);
const result = runGsdTools(['init', 'execute-phase', '1', '--raw'], tmpDir);
const result = runMsdTools(['init', 'execute-phase', '1', '--raw'], tmpDir);
assert.ok(result.success, `init execute-phase should succeed: ${result.error}`);
const json = JSON.parse(result.output);
@@ -1096,7 +1096,7 @@ describe('#2830 review findings', () => {
afterEach(() => { if (tmpDir) { cleanup(tmpDir); tmpDir = null; } });
test('defect 1: cycle repro — 08-02 depends_on [halted 08-01, 08-03]; 08-03 depends_on [08-02]', () => {
tmpDir = createTempProject('gsd-2830-review-cycle-');
tmpDir = createTempProject('msd-2830-review-cycle-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '08-cyclehalt');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -1110,7 +1110,7 @@ describe('#2830 review findings', () => {
'wave: 2', 'objective: Cyclic peer of 08-02', 'autonomous: true', 'depends_on:', ' - 08-02',
]);
const result = runGsdTools(['init', 'execute-phase', '8', '--raw'], tmpDir);
const result = runMsdTools(['init', 'execute-phase', '8', '--raw'], tmpDir);
assert.ok(result.success, `init execute-phase should succeed: ${result.error}`);
const json = JSON.parse(result.output);
assert.strictEqual(json.phase_found, true, 'phase must be found for the rest of this test to be meaningful');
@@ -1130,7 +1130,7 @@ describe('#2830 review findings', () => {
});
test('defect 1: self-dependency (A depends_on A, nothing halted) must not be silently runnable', () => {
tmpDir = createTempProject('gsd-2830-review-self-');
tmpDir = createTempProject('msd-2830-review-self-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '09-selfdep');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -1138,7 +1138,7 @@ describe('#2830 review findings', () => {
'wave: 1', 'objective: Depends on itself', 'autonomous: true', 'depends_on:', ' - 09-01',
]);
const result = runGsdTools(['init', 'execute-phase', '9', '--raw'], tmpDir);
const result = runMsdTools(['init', 'execute-phase', '9', '--raw'], tmpDir);
assert.ok(result.success, `init execute-phase should succeed: ${result.error}`);
const json = JSON.parse(result.output);
assert.strictEqual(json.phase_found, true, 'phase must be found for the rest of this test to be meaningful');
@@ -1154,7 +1154,7 @@ describe('#2830 review findings', () => {
});
test('defect 2: SUMMARY status with an inline YAML comment still blocks the dependent', () => {
tmpDir = createTempProject('gsd-2830-review-comment-');
tmpDir = createTempProject('msd-2830-review-comment-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '10-inlinecomment');
fs.mkdirSync(phaseDir, { recursive: true });
@@ -1164,7 +1164,7 @@ describe('#2830 review findings', () => {
'wave: 2', 'objective: Depends on the inline-commented halt', 'autonomous: true', 'depends_on:', ' - 10-01',
]);
const result = runGsdTools(['init', 'execute-phase', '10', '--raw'], tmpDir);
const result = runMsdTools(['init', 'execute-phase', '10', '--raw'], tmpDir);
assert.ok(result.success, `init execute-phase should succeed: ${result.error}`);
const json = JSON.parse(result.output);
assert.strictEqual(json.phase_found, true, 'phase must be found for the rest of this test to be meaningful');
@@ -1212,7 +1212,7 @@ describe('#2830 review findings', () => {
// resolve to a same-numbered phase archived under the ROOT tree (an
// unrelated workstream's history, or a flat-mode project's archive).
//
// GSD_WORKSTREAM/GSD_PROJECT are read directly from process.env by
// MSD_WORKSTREAM/MSD_PROJECT are read directly from process.env by
// planningDir() when omitted, so every test here explicitly saves/restores
// both to avoid leaking state across tests or picking up ambient shell env.
// ═══════════════════════════════════════════════════════════════════════
@@ -1229,7 +1229,7 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
});
test('does not leak root-tree archived phase into an unrelated workstream', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
// Root archive holds phase 03 (unrelated workstream's / flat-mode history).
const rootArchive = path.join(tmpDir, '.planning', 'milestones', 'v1.0-phases', '03-legacy');
fs.mkdirSync(rootArchive, { recursive: true });
@@ -1237,19 +1237,19 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
// Workstream "beta" exists with an empty phases/ dir — phase 03 is pending.
fs.mkdirSync(path.join(tmpDir, '.planning', 'workstreams', 'beta', 'phases'), { recursive: true });
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.findPhaseInternal(tmpDir, '3');
assert.strictEqual(result, null, 'pending workstream phase must not resolve to the root archive');
});
test('does not leak root archive when workstream phases dir is entirely absent', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const rootArchive = path.join(tmpDir, '.planning', 'milestones', 'v2.0-phases', '01-legacy');
fs.mkdirSync(rootArchive, { recursive: true });
// Brand-new workstream: no .planning/workstreams/gamma/ directory at all yet.
process.env.GSD_WORKSTREAM = 'gamma';
process.env.MSD_WORKSTREAM = 'gamma';
const result = phaseLocator.findPhaseInternal(tmpDir, '1');
assert.strictEqual(result, null, 'a workstream with no directory yet must not resolve to the root archive');
@@ -1262,7 +1262,7 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
// inference from reading the source.
for (const roadmapHasEntry of [true, false]) {
test(`does not leak root archive whether or not the workstream's ROADMAP.md already lists the phase (roadmapHasEntry=${roadmapHasEntry})`, () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const rootArchive = path.join(tmpDir, '.planning', 'milestones', 'v1.0-phases', '03-legacy');
fs.mkdirSync(rootArchive, { recursive: true });
@@ -1274,7 +1274,7 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
['# Roadmap', '', '### Phase 03: Pending Work', ''].join('\n'),
);
}
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.findPhaseInternal(tmpDir, '3');
assert.strictEqual(result, null, 'ROADMAP.md presence/absence must not affect the archive-leak guard');
@@ -1282,10 +1282,10 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
}
test('still finds a phase genuinely archived under the active workstream\'s own tree', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const ownArchive = path.join(tmpDir, '.planning', 'workstreams', 'beta', 'milestones', 'v1.0-phases', '03-real');
fs.mkdirSync(ownArchive, { recursive: true });
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.findPhaseInternal(tmpDir, '3');
assert.ok(result !== null, 'workstream\'s own archived phase must still resolve');
@@ -1298,10 +1298,10 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
});
test('flat/non-workstream project archive resolution is unchanged', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const rootArchive = path.join(tmpDir, '.planning', 'milestones', 'v1.0-phases', '03-flat');
fs.mkdirSync(rootArchive, { recursive: true });
// No GSD_WORKSTREAM / GSD_PROJECT set — flat mode.
// No MSD_WORKSTREAM / MSD_PROJECT set — flat mode.
const result = phaseLocator.findPhaseInternal(tmpDir, '3');
assert.ok(result !== null, 'flat-mode archive lookup must be unaffected by the fix');
@@ -1311,33 +1311,33 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
});
test('two workstreams with same-numbered archived phases never cross-resolve', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const alphaArchive = path.join(tmpDir, '.planning', 'workstreams', 'alpha', 'milestones', 'v1.0-phases', '03-alpha-work');
const betaArchive = path.join(tmpDir, '.planning', 'workstreams', 'beta', 'milestones', 'v1.0-phases', '03-beta-work');
fs.mkdirSync(alphaArchive, { recursive: true });
fs.mkdirSync(betaArchive, { recursive: true });
process.env.GSD_WORKSTREAM = 'alpha';
process.env.MSD_WORKSTREAM = 'alpha';
const alphaResult = phaseLocator.findPhaseInternal(tmpDir, '3');
assert.ok(alphaResult !== null);
assert.strictEqual(alphaResult.phase_name, 'alpha-work');
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const betaResult = phaseLocator.findPhaseInternal(tmpDir, '3');
assert.ok(betaResult !== null);
assert.strictEqual(betaResult.phase_name, 'beta-work');
});
test('project+workstream combination scopes the archive fallback', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const rootArchive = path.join(tmpDir, '.planning', 'milestones', 'v1.0-phases', '05-root-legacy');
fs.mkdirSync(rootArchive, { recursive: true });
const scopedArchive = path.join(tmpDir, '.planning', 'proj-x', 'workstreams', 'beta', 'milestones', 'v1.0-phases', '05-scoped');
fs.mkdirSync(scopedArchive, { recursive: true });
process.env.GSD_PROJECT = 'proj-x';
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_PROJECT = 'proj-x';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.findPhaseInternal(tmpDir, '5');
assert.ok(result !== null, 'project+workstream scoped archive must resolve');
@@ -1349,10 +1349,10 @@ describe('#2855: findPhaseInternal does not leak cross-workstream archived phase
});
test('workstream-scoped archived directory is posix-style', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const ownArchive = path.join(tmpDir, '.planning', 'workstreams', 'beta', 'milestones', 'v1.0-phases', '07-posix');
fs.mkdirSync(ownArchive, { recursive: true });
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.findPhaseInternal(tmpDir, '7');
assert.ok(result !== null);
@@ -1369,22 +1369,22 @@ describe('#2855: getArchivedPhaseDirs does not leak cross-workstream archived ph
});
test('does not leak root-tree archive entries under an active workstream', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const rootArchive = path.join(tmpDir, '.planning', 'milestones', 'v1.0-phases', '03-legacy');
fs.mkdirSync(rootArchive, { recursive: true });
fs.mkdirSync(path.join(tmpDir, '.planning', 'workstreams', 'beta', 'phases'), { recursive: true });
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.getArchivedPhaseDirs(tmpDir);
assert.deepEqual(result, [], 'getArchivedPhaseDirs must not surface the root archive for a workstream');
});
test('still finds phases genuinely archived under the active workstream\'s own tree', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const ownArchive = path.join(tmpDir, '.planning', 'workstreams', 'beta', 'milestones', 'v2.0-phases', '04-own');
fs.mkdirSync(ownArchive, { recursive: true });
process.env.GSD_WORKSTREAM = 'beta';
process.env.MSD_WORKSTREAM = 'beta';
const result = phaseLocator.getArchivedPhaseDirs(tmpDir);
assert.strictEqual(result.length, 1);
@@ -1399,10 +1399,10 @@ describe('#2855: getArchivedPhaseDirs does not leak cross-workstream archived ph
});
test('flat/non-workstream project resolution is unchanged', () => {
tmpDir = createTempProject('gsd-2855-');
tmpDir = createTempProject('msd-2855-');
const archiveDir = path.join(tmpDir, '.planning', 'milestones', 'v2.1.0-phases');
fs.mkdirSync(path.join(archiveDir, '03-auth'), { recursive: true });
// No GSD_WORKSTREAM / GSD_PROJECT set — flat mode.
// No MSD_WORKSTREAM / MSD_PROJECT set — flat mode.
const result = phaseLocator.getArchivedPhaseDirs(tmpDir);
assert.strictEqual(result.length, 1);
@@ -1426,7 +1426,7 @@ describe('#2855: getArchivedPhaseDirs does not leak cross-workstream archived ph
// proof. `tests/estimate-calibrate.test.cjs` (rows A1a/A1b/A2/A3) covers the
// actual calibration defect this issue fixes; this section covers rows
// B1-B4, C1, D1-D3, E1/E2, F1-F3 from
// .gsd/phase/feat-3882-enumerations/50-test-matrix.md.
// .msd/phase/feat-3882-enumerations/50-test-matrix.md.
//
// Per that doc's §G test-hermeticity rule: every fixture here builds its own
// temp project via helpers.cjs and removes it through `cleanup()` — no raw
@@ -1436,7 +1436,7 @@ describe('#2855: getArchivedPhaseDirs does not leak cross-workstream archived ph
/** Build `<tmp>/.planning/phases/<name>` for each of `names`. Returns the phases dir. */
function build3882PhasesFixture(names) {
const tmp = createTempDir('gsd-3882-');
const tmp = createTempDir('msd-3882-');
const phasesDir = path.join(tmp, '.planning', 'phases');
fs.mkdirSync(phasesDir, { recursive: true });
for (const name of names) fs.mkdirSync(path.join(phasesDir, name));
@@ -1493,7 +1493,7 @@ describe('listAllPhaseDirs (#3882, ADR-3473 §8.2)', () => {
});
test('absent phases dir is a real empty (scope: complete), not a failure', (t) => {
const tmp = createTempDir('gsd-3882-');
const tmp = createTempDir('msd-3882-');
t.after(() => cleanup(tmp));
const phasesDir = path.join(tmp, '.planning', 'phases'); // never created
@@ -1502,7 +1502,7 @@ describe('listAllPhaseDirs (#3882, ADR-3473 §8.2)', () => {
});
test('an existing-but-unreadable phases dir is scope: unreadable, not a silent empty (#8.5)', () => {
const tmp = createTempDir('gsd-3882-');
const tmp = createTempDir('msd-3882-');
const phasesDir = path.join(tmp, '.planning', 'phases');
fs.mkdirSync(phasesDir, { recursive: true });
@@ -1622,7 +1622,7 @@ describe('migrated exemptions behave identically (#3882 rows E1/E2)', () => {
/**
* Run `subject(tmpDir, false)` in-process with `fs.readdirSync` forced to a
* FIXED order for the exact `phasesDir` path, and return its parsed JSON
* output. `runGsdTools` spawns a real subprocess, which neither
* output. `runMsdTools` spawns a real subprocess, which neither
* `fs.readdirSync` monkeypatching nor stdout capture can cross — this
* drives the actual shipped command function directly instead, mirroring
* tests/config-get-default.test.cjs's established in-process CLI pattern.
@@ -1676,9 +1676,9 @@ describe('migrated exemptions behave identically (#3882 rows E1/E2)', () => {
// earlier ones in the Map, so the LAST directory wins). Same input order,
// opposite winners — exactly the risk a raw-fs -> comparePhaseNum reorder
// creates and the one this row exists to catch.
const roadmap = require('../gsd-core/bin/lib/roadmap.cjs');
const init = require('../gsd-core/bin/lib/init.cjs');
const { tmpDir, phasesDir } = buildCollidingPhaseFixture('gsd-3882-e1-collide-');
const roadmap = require('../msd-core/bin/lib/roadmap.cjs');
const init = require('../msd-core/bin/lib/init.cjs');
const { tmpDir, phasesDir } = buildCollidingPhaseFixture('msd-3882-e1-collide-');
try {
// Forced order: '01-duplicate' (no summary) BEFORE '01-real' (has one).
const order = ['01-duplicate', '01-real'];
@@ -1699,9 +1699,9 @@ describe('migrated exemptions behave identically (#3882 rows E1/E2)', () => {
});
test('E1a: reversing the forced tie order reverses BOTH callers\' selections — confirms the effect tracks the collision, not a fixed name preference', () => {
const roadmap = require('../gsd-core/bin/lib/roadmap.cjs');
const init = require('../gsd-core/bin/lib/init.cjs');
const { tmpDir, phasesDir } = buildCollidingPhaseFixture('gsd-3882-e1a-collide-');
const roadmap = require('../msd-core/bin/lib/roadmap.cjs');
const init = require('../msd-core/bin/lib/init.cjs');
const { tmpDir, phasesDir } = buildCollidingPhaseFixture('msd-3882-e1a-collide-');
try {
// Reversed order: '01-real' (has summary) BEFORE '01-duplicate' (none).
const order = ['01-real', '01-duplicate'];
@@ -1726,7 +1726,7 @@ describe('migrated exemptions behave identically (#3882 rows E1/E2)', () => {
// BEFORE this list is ever consulted (collectAnalyzePhases), so a
// sentinel directory can never be the value looked up. Assert that
// invariance directly, mirroring A1a/A1b's differential shape.
const tmpDir = createTempProject('gsd-3882-e1-');
const tmpDir = createTempProject('msd-3882-e1-');
try {
const roadmapPath = path.join(tmpDir, '.planning', 'ROADMAP.md');
fs.writeFileSync(roadmapPath, [
@@ -1740,10 +1740,10 @@ describe('migrated exemptions behave identically (#3882 rows E1/E2)', () => {
].join('\n'));
fs.mkdirSync(path.join(tmpDir, '.planning', 'phases', '01-real'), { recursive: true });
const before = JSON.parse(runGsdTools('query roadmap.analyze', tmpDir).output);
const before = JSON.parse(runMsdTools('query roadmap.analyze', tmpDir).output);
fs.mkdirSync(path.join(tmpDir, '.planning', 'phases', '999-icebox'), { recursive: true });
const after = JSON.parse(runGsdTools('query roadmap.analyze', tmpDir).output);
const after = JSON.parse(runMsdTools('query roadmap.analyze', tmpDir).output);
assert.deepEqual(after.phases, before.phases,
'adding a sentinel phase directory must not change the resolved phase list');
@@ -1900,7 +1900,7 @@ describe('phase-plan-index: DAG-ready view (#4628)', () => {
}
test('locator: the wave-7 pair is ready; the wave-9/10 dependents are runnable but NOT ready', () => {
tmpDir = createTempProject('gsd-4628-');
tmpDir = createTempProject('msd-4628-');
build4628Fixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '7');
@@ -1919,7 +1919,7 @@ describe('phase-plan-index: DAG-ready view (#4628)', () => {
});
test('completed plans never appear in ready_plans (ready is a property of incomplete plans)', () => {
tmpDir = createTempProject('gsd-4628-');
tmpDir = createTempProject('msd-4628-');
build4628Fixture(tmpDir);
const result = phaseLocator.findPhaseInternal(tmpDir, '7');
@@ -1928,10 +1928,10 @@ describe('phase-plan-index: DAG-ready view (#4628)', () => {
});
test('CLI: per-plan ready/unresolved_dependencies name the missing predecessors', () => {
tmpDir = createTempProject('gsd-4628-');
tmpDir = createTempProject('msd-4628-');
build4628Fixture(tmpDir);
const result = runGsdTools(['phase-plan-index', '7', '--json'], tmpDir);
const result = runMsdTools(['phase-plan-index', '7', '--json'], tmpDir);
assert.ok(result.success, `phase-plan-index should succeed: ${result.error}`);
const data = JSON.parse(result.output);
@@ -1955,7 +1955,7 @@ describe('phase-plan-index: DAG-ready view (#4628)', () => {
});
test('a halted dependency keeps blocked_by semantics AND reads not-ready', () => {
tmpDir = createTempProject('gsd-4628-');
tmpDir = createTempProject('msd-4628-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '08-halt');
fs.mkdirSync(phaseDir, { recursive: true });
writePlan(phaseDir, '08-01-PLAN.md', ['wave: 1', 'objective: Halted', 'autonomous: true']);
@@ -1999,7 +1999,7 @@ describe('phase-plan-index: readiness fail-closed edges (#4628)', () => {
);
}
test('an unresolved depends_on token carries no evidence — the plan is not ready', () => {
tmpDir = createTempProject('gsd-4628-tok-');
tmpDir = createTempProject('msd-4628-tok-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '09-tok');
fs.mkdirSync(phaseDir, { recursive: true });
writePlan(phaseDir, '09-01-PLAN.md', ['wave: 1', 'objective: Ready by itself', 'autonomous: true']);
@@ -2013,14 +2013,14 @@ describe('phase-plan-index: readiness fail-closed edges (#4628)', () => {
assert.ok(!locator.ready_plans.includes('09-02-PLAN.md'),
'a dropped edge carries no completion evidence — fail closed');
const cli = runGsdTools(['phase-plan-index', '9', '--json'], tmpDir);
const cli = runMsdTools(['phase-plan-index', '9', '--json'], tmpDir);
const data = JSON.parse(cli.output);
const p02 = data.plans.find((p) => p.id === '09-02');
assert.strictEqual(p02.ready, false, 'CLI must fail closed identically to the locator');
});
test('a dependency whose SUMMARY declares status: blocked is NOT completion evidence', () => {
tmpDir = createTempProject('gsd-4628-blk-');
tmpDir = createTempProject('msd-4628-blk-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '10-blk');
fs.mkdirSync(phaseDir, { recursive: true });
writePlan(phaseDir, '10-01-PLAN.md', ['wave: 1', 'objective: Blocked dependency', 'autonomous: true']);
@@ -2034,14 +2034,14 @@ describe('phase-plan-index: readiness fail-closed edges (#4628)', () => {
assert.ok(!locator.ready_plans.includes('10-02-PLAN.md'),
'a status:blocked SUMMARY is a failure record, not completion evidence');
const cli = runGsdTools(['phase-plan-index', '10', '--json'], tmpDir);
const cli = runMsdTools(['phase-plan-index', '10', '--json'], tmpDir);
const data = JSON.parse(cli.output);
const p02 = data.plans.find((p) => p.id === '10-02');
assert.strictEqual(p02.ready, false, 'CLI and locator must agree: blocked dep = not ready');
});
test('locator and CLI agree on the issue chain (lockstep pin)', () => {
tmpDir = createTempProject('gsd-4628-lock-');
tmpDir = createTempProject('msd-4628-lock-');
const phaseDir = path.join(tmpDir, '.planning', 'phases', '11-lock');
fs.mkdirSync(phaseDir, { recursive: true });
// completed
@@ -2053,7 +2053,7 @@ describe('phase-plan-index: readiness fail-closed edges (#4628)', () => {
writePlan(phaseDir, '11-03-PLAN.md', ['wave: 3', 'objective: Waiting', 'autonomous: true', 'depends_on:', ' - 11-02']);
const locator = phaseLocator.findPhaseInternal(tmpDir, '11');
const cli = JSON.parse(runGsdTools(['phase-plan-index', '11', '--json'], tmpDir).output);
const cli = JSON.parse(runMsdTools(['phase-plan-index', '11', '--json'], tmpDir).output);
// the locator reports FILENAMES in ready_plans; the CLI reports plan ids —
// normalize the filename form before comparing the two views.
const locatorIds = locator.ready_plans.map((f) => f.replace(/-PLAN\.md$/, '')).sort();