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

@@ -4,7 +4,7 @@
'use strict';
/**
* #2650 — plan-phase hangs after gsd-planner writes all plans; completion never
* #2650 — plan-phase hangs after msd-planner writes all plans; completion never
* reaches orchestrator.
*
* plan-phase.md's five planner/plan-checker Agent() spawns (standard planner,
@@ -17,8 +17,8 @@
* execute-phase.md (bug #3212, commit e7942c21b).
*
* The fix extracts the decision logic into a pure, unit-testable bash
* function (`gsd_stall_should_recover`) embedded in the lazily-loaded
* `gsd-core/workflows/plan-phase/steps/stall-detection-helpers.md` (kept out
* function (`msd_stall_should_recover`) embedded in the lazily-loaded
* `msd-core/workflows/plan-phase/steps/stall-detection-helpers.md` (kept out
* of plan-phase.md's own measured bytes — plan-phase.md is frozen under the
* ADR-857 Phase 6 `PRE_PHASE6` gate, `tests/phase6-capstone-conformance.test.cjs`,
* with ~36 bytes of headroom at baseline) and exercised here via the SAME
@@ -28,10 +28,10 @@
* hand-copied duplicate (avoids the "Generative Fix Divergence" defect
* class).
*
* Seam: gsd-core/workflows/plan-phase.md,
* gsd-core/workflows/plan-phase/steps/stall-detection-helpers.md,
* Seam: msd-core/workflows/plan-phase.md,
* msd-core/workflows/plan-phase/steps/stall-detection-helpers.md,
* src/config.cts (SCHEMA_DEFAULTS),
* gsd-core/bin/shared/config-schema.manifest.json, docs/CONFIGURATION.md
* msd-core/bin/shared/config-schema.manifest.json, docs/CONFIGURATION.md
*/
const { describe, test, mock } = require('node:test');
@@ -47,21 +47,21 @@ const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const fc = require('fast-check');
const { cleanup, readFileNormalized, readWorkflowCombined, runGsdTools } = require('./helpers.cjs');
const { cleanup, readFileNormalized, readWorkflowCombined, runMsdTools } = require('./helpers.cjs');
const REPO_ROOT = path.join(__dirname, '..');
const PLAN_PHASE_PATH = path.join(REPO_ROOT, 'gsd-core', 'workflows', 'plan-phase.md');
const STALL_HELPERS_PATH = path.join(REPO_ROOT, 'gsd-core', 'workflows', 'plan-phase', 'steps', 'stall-detection-helpers.md');
const CHUNKED_PLANNING_MODE_PATH = path.join(REPO_ROOT, 'gsd-core', 'workflows', 'plan-phase', 'steps', 'chunked-planning-mode.md');
const CONFIG_SCHEMA_MANIFEST_PATH = path.join(REPO_ROOT, 'gsd-core', 'bin', 'shared', 'config-schema.manifest.json');
const CONFIG_DEFAULTS_MANIFEST_PATH = path.join(REPO_ROOT, 'gsd-core', 'bin', 'shared', 'config-defaults.manifest.json');
const PLAN_PHASE_PATH = path.join(REPO_ROOT, 'msd-core', 'workflows', 'plan-phase.md');
const STALL_HELPERS_PATH = path.join(REPO_ROOT, 'msd-core', 'workflows', 'plan-phase', 'steps', 'stall-detection-helpers.md');
const CHUNKED_PLANNING_MODE_PATH = path.join(REPO_ROOT, 'msd-core', 'workflows', 'plan-phase', 'steps', 'chunked-planning-mode.md');
const CONFIG_SCHEMA_MANIFEST_PATH = path.join(REPO_ROOT, 'msd-core', 'bin', 'shared', 'config-schema.manifest.json');
const CONFIG_DEFAULTS_MANIFEST_PATH = path.join(REPO_ROOT, 'msd-core', 'bin', 'shared', 'config-defaults.manifest.json');
const CONFIGURATION_DOCS_PATH = path.join(REPO_ROOT, 'docs', 'CONFIGURATION.md');
const PT_BR_CONFIGURATION_DOCS_PATH = path.join(REPO_ROOT, 'docs', 'pt-BR', 'CONFIGURATION.md');
const ZH_CN_CONFIGURATION_DOCS_PATH = path.join(REPO_ROOT, 'docs', 'zh-CN', 'CONFIGURATION.md');
const JA_JP_CONFIGURATION_DOCS_PATH = path.join(REPO_ROOT, 'docs', 'ja-JP', 'CONFIGURATION.md');
const KO_KR_CONFIGURATION_DOCS_PATH = path.join(REPO_ROOT, 'docs', 'ko-KR', 'CONFIGURATION.md');
const ZH_CN_PLANNING_CONFIG_PATH = path.join(REPO_ROOT, 'docs', 'zh-CN', 'references', 'planning-config.md');
const SETTINGS_ADVANCED_PATH = path.join(REPO_ROOT, 'gsd-core', 'workflows', 'settings-advanced.md');
const SETTINGS_ADVANCED_PATH = path.join(REPO_ROOT, 'msd-core', 'workflows', 'settings-advanced.md');
function readPlanPhase() {
return readFileNormalized(PLAN_PHASE_PATH);
@@ -85,8 +85,8 @@ function readStallHelpersDoc() {
}
/**
* Extract the ```bash fence that defines gsd_stall_should_recover (and its
* sibling gsd_stall_watch) from the lazily-loaded stall-detection-helpers.md
* Extract the ```bash fence that defines msd_stall_should_recover (and its
* sibling msd_stall_watch) from the lazily-loaded stall-detection-helpers.md
* step file. Throws with a clear message if the anchor or fence cannot be
* found — this is what makes row 1 of the test matrix a genuine failing-first
* regression test (pre-fix, the function does not exist anywhere in the repo).
@@ -94,7 +94,7 @@ function readStallHelpersDoc() {
function extractStallHelpersBash() {
const content = readStallHelpersDoc();
const anchor = 'gsd_stall_should_recover';
const anchor = 'msd_stall_should_recover';
const anchorIdx = content.indexOf(anchor);
if (anchorIdx === -1) {
throw new Error(`extractStallHelpersBash: could not find "${anchor}" anywhere in ${STALL_HELPERS_PATH}`);
@@ -119,8 +119,8 @@ function extractStallHelpersBash() {
}
const body = after.slice(0, closeIdx);
if (!body.includes('gsd_stall_watch')) {
throw new Error('extractStallHelpersBash: sanity check failed — extracted block does not also define gsd_stall_watch');
if (!body.includes('msd_stall_watch')) {
throw new Error('extractStallHelpersBash: sanity check failed — extracted block does not also define msd_stall_watch');
}
// readStallHelpersDoc() reads through helpers.cjs's readFileNormalized(),
// which strips \r\n -> \n at the read boundary before any slicing above
@@ -172,7 +172,7 @@ function extractStallHelpersBash() {
* `timeout` key is silently ignored rather than honoured.
*/
function runBashScript(script, args = [], opts = {}) {
const scriptDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-sh-'));
const scriptDir = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-sh-'));
try {
const scriptPath = path.join(scriptDir, 'script.sh');
fs.writeFileSync(scriptPath, `#!/usr/bin/env bash\n${script}`, { mode: 0o755 });
@@ -182,8 +182,8 @@ function runBashScript(script, args = [], opts = {}) {
//
// 1. HOOK_FANOUT_TIMEOUT_MS — the class norm for a bash invocation that FANS OUT
// to nested subprocesses. This script does exactly that: the extracted fence
// opens with the runtime-launcher preamble, which resolves gsd-tools.cjs and
// really runs two `gsd_run query config-get` lines, i.e. two Node spawns
// opens with the runtime-launcher preamble, which resolves msd-tools.cjs and
// really runs two `msd_run query config-get` lines, i.e. two Node spawns
// (measured 236ms vs 2ms for the fallback shape). The old hard-coded 10000ms
// was sized for a cheap probe and was exceeded at 10006ms on
// `full test (windows-latest, 24, shard 1/3)`. timeouts.cjs records the same
@@ -211,22 +211,22 @@ function runBashScript(script, args = [], opts = {}) {
}
/**
* Run gsd_stall_should_recover with the given args inside the extracted
* Run msd_stall_should_recover with the given args inside the extracted
* script and return its stdout (trimmed). No real sleeping happens — the
* function is pure and synchronous.
*/
function runShouldRecover(helpersBash, elapsedSeconds, thresholdMinutes, markerFound, artifactFresh) {
const script = `${helpersBash}\ngsd_stall_should_recover "$1" "$2" "$3" "$4"\n`;
const script = `${helpersBash}\nmsd_stall_should_recover "$1" "$2" "$3" "$4"\n`;
const result = runBashScript(script,
[String(elapsedSeconds), String(thresholdMinutes), String(markerFound), String(artifactFresh)]);
assert.equal(result.status, 0, `gsd_stall_should_recover exited non-zero: ${result.stderr}`);
assert.equal(result.status, 0, `msd_stall_should_recover exited non-zero: ${result.stderr}`);
return result.stdout.trim();
}
describe('bug #2650 plan-phase stall detection — gsd_stall_should_recover (pure decision function)', () => {
describe('bug #2650 plan-phase stall detection — msd_stall_should_recover (pure decision function)', () => {
let helpersBash;
test('stall-detection-helpers.md defines gsd_stall_should_recover inside a ```bash fence', () => {
test('stall-detection-helpers.md defines msd_stall_should_recover inside a ```bash fence', () => {
helpersBash = extractStallHelpersBash();
assert.ok(helpersBash.length > 0);
});
@@ -289,8 +289,8 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_should_recover (pur
// stall-watcher itself with that bash syntax error, silently defeating
// the exact hang-recovery this issue exists to ship. Prove the function
// degrades to a safe default instead of erroring.
const marker = `gsd-2650-untouched-${process.pid}-${Date.now()}`;
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-malformed-'));
const marker = `msd-2650-untouched-${process.pid}-${Date.now()}`;
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-malformed-'));
t.after(() => cleanup(tmp));
const payload = `$(touch ${path.join(tmp, marker)})`;
const result = runShouldRecover(helpersBash, 0, payload, 'false', 'false');
@@ -302,15 +302,15 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_should_recover (pur
});
});
describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real execution, not just the pure classifier)', () => {
describe('bug #2650 plan-phase stall detection — msd_stall_watch (real execution, not just the pure classifier)', () => {
// CORRECTION (#2650 follow-up): an earlier version of this comment claimed the
// extracted script runs WITHOUT `gsd_run` defined, so the `|| echo "<default>"`
// extracted script runs WITHOUT `msd_run` defined, so the `|| echo "<default>"`
// fallback in the config-get lines fires. That is false, and it is why the spawn
// bound below was mis-sized. extractStallHelpersBash slices the ENTIRE ```bash
// fence, which opens with the runtime-launcher preamble; that preamble finds
// gsd-core/bin/gsd-tools.cjs from the repo root and DEFINES gsd_run, so both
// config-get lines really spawn Node. Verified: `gsd_run defined: function`,
// GSD_TOOLS=<repo>/gsd-core/bin/gsd-tools.cjs. The resolved values are then
// msd-core/bin/msd-tools.cjs from the repo root and DEFINES msd_run, so both
// config-get lines really spawn Node. Verified: `msd_run defined: function`,
// MSD_TOOLS=<repo>/msd-core/bin/msd-tools.cjs. The resolved values are then
// discarded anyway — runWatch overrides both PLANNER_STALL_* vars right after the
// helpers, and runShouldRecover passes them as arguments — so the two spawns are
// dead cost that the bound must nonetheless accommodate. They are deliberately NOT
@@ -321,7 +321,7 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
test('loads helpers', () => {
helpersBash = extractStallHelpersBash();
assert.ok(helpersBash.includes('gsd_stall_watch()'));
assert.ok(helpersBash.includes('msd_stall_watch()'));
});
// Routed through the shared runBashScript() helper (#2650 Windows CI —
@@ -332,14 +332,14 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
// the script itself changes.
function runWatch(intervalMinutes, thresholdMinutes, dispatchTs, outputFile, artifactGlob, markers) {
const overrides = `PLANNER_STALL_INTERVAL_MINUTES=${intervalMinutes}\nPLANNER_STALL_THRESHOLD_MINUTES=${thresholdMinutes}\n`;
const call = `gsd_stall_watch ${JSON.stringify(String(dispatchTs))} ${JSON.stringify(outputFile)} ${JSON.stringify(artifactGlob)}` +
const call = `msd_stall_watch ${JSON.stringify(String(dispatchTs))} ${JSON.stringify(outputFile)} ${JSON.stringify(artifactGlob)}` +
markers.map((m) => ` ${JSON.stringify(m)}`).join('');
const script = `${helpersBash}\n${overrides}${call}\n`;
return runBashScript(script, []);
}
test('marker present in the real output file (via real grep, interval=0 so sleep is instant) -> marker_received', (t) => {
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-watch-'));
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-watch-'));
t.after(() => cleanup(tmp));
const outputFile = path.join(tmp, 'agent-output.txt');
fs.writeFileSync(outputFile, 'some agent output\n## PLANNING COMPLETE\nmore text\n');
@@ -351,7 +351,7 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
});
test('no marker, no output file, dispatch far in the past, threshold=0 (via real find/date, interval=0) -> stalled', (t) => {
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-watch-'));
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-watch-'));
t.after(() => cleanup(tmp));
const missingOutputFile = path.join(tmp, 'never-written.txt');
const glob = `${tmp.replace(/\\/g, '/')}/*-PLAN.md`; // the tmp dir contains no *-PLAN.md files -> no fresh activity
@@ -362,7 +362,7 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
});
test('marker absent, dispatch just now, non-zero threshold (via real find/date, interval=0) -> waiting', (t) => {
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-watch-'));
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-watch-'));
t.after(() => cleanup(tmp));
const missingOutputFile = path.join(tmp, 'never-written.txt');
const glob = `${tmp.replace(/\\/g, '/')}/*-PLAN.md`;
@@ -385,7 +385,7 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
// than N minutes ago"), which needs no date-string parsing and is
// supported identically by GNU find and BSD find.
//
// This runs the REAL shipped gsd_stall_watch (not a hand-copied
// This runs the REAL shipped msd_stall_watch (not a hand-copied
// find invocation — see this file's header on Generative Fix
// Divergence), with `sleep` shadowed to a no-op bash function so the
// test does not actually wait a real PLANNER_STALL_INTERVAL_MINUTES;
@@ -412,14 +412,14 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
// so the test matches what production actually passes, while still
// exercising the real shipped `find` line. Do not "simplify" this back
// to a bare `path.join`; that silently reintroduces the failure.
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-fresh-'));
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-fresh-'));
t.after(() => cleanup(tmp));
fs.writeFileSync(path.join(tmp, 'x-PLAN.md'), 'freshly written\n');
const glob = `${tmp.replace(/\\/g, '/')}/*-PLAN.md`;
const missingOutputFile = path.join(tmp, 'never-written.txt');
const now = Math.floor(Date.now() / 1000);
const overrides = 'sleep() { :; }\nPLANNER_STALL_INTERVAL_MINUTES=1\nPLANNER_STALL_THRESHOLD_MINUTES=99999\n';
const call = `gsd_stall_watch ${JSON.stringify(String(now))} ${JSON.stringify(missingOutputFile)} ${JSON.stringify(glob)}` +
const call = `msd_stall_watch ${JSON.stringify(String(now))} ${JSON.stringify(missingOutputFile)} ${JSON.stringify(glob)}` +
` ${JSON.stringify('## PLANNING COMPLETE')}`;
const script = `${helpersBash}\n${overrides}${call}\n`;
const result = runBashScript(script, []);
@@ -435,7 +435,7 @@ describe('bug #2650 plan-phase stall detection — gsd_stall_watch (real executi
describe('bug #2650 config schema — planner.stall_* keys mirror executor.stall_*', () => {
test('config schemas register planner stall detector keys', () => {
const { VALID_CONFIG_KEYS: cjsKeys } = require('../gsd-core/bin/lib/config-schema.cjs');
const { VALID_CONFIG_KEYS: cjsKeys } = require('../msd-core/bin/lib/config-schema.cjs');
const manifest = JSON.parse(fs.readFileSync(CONFIG_SCHEMA_MANIFEST_PATH, 'utf-8'));
const manifestKeys = new Set(manifest.validKeys);
@@ -452,12 +452,12 @@ describe('bug #2650 config schema — planner.stall_* keys mirror executor.stall
});
test('config-get returns schema defaults for planner stall detector keys', (t) => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2650-'));
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2650-'));
t.after(() => cleanup(tmp));
fs.mkdirSync(path.join(tmp, '.planning'));
fs.writeFileSync(path.join(tmp, '.planning/config.json'), '{}\n');
const toolsPath = path.join(REPO_ROOT, 'gsd-core', 'bin', 'gsd-tools.cjs');
const toolsPath = path.join(REPO_ROOT, 'msd-core', 'bin', 'msd-tools.cjs');
const interval = toLegacyResult(runNode([toolsPath, 'config-get', 'planner.stall_detect_interval_minutes', '--raw'], { cwd: tmp, timeoutMs: PROBE_TIMEOUT_MS }));
const threshold = toLegacyResult(runNode([toolsPath, 'config-get', 'planner.stall_threshold_minutes', '--raw'], { cwd: tmp, timeoutMs: PROBE_TIMEOUT_MS }));
@@ -470,7 +470,7 @@ describe('bug #2650 config schema — planner.stall_* keys mirror executor.stall
describe('enhancement #4570 config contract — planner stall detection has a typed default-on opt-out', () => {
function makeProject(t, config = {}) {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4570-config-'));
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4570-config-'));
t.after(() => cleanup(tmp));
fs.mkdirSync(path.join(tmp, '.planning'), { recursive: true });
fs.writeFileSync(path.join(tmp, '.planning', 'config.json'), `${JSON.stringify(config, null, 2)}\n`);
@@ -490,13 +490,13 @@ describe('enhancement #4570 config contract — planner stall detection has a ty
const tmp = makeProject(t);
const env = { HOME: tmp, USERPROFILE: tmp };
const absent = runGsdTools(['config-get', 'planner.stall_detection_enabled', '--raw'], tmp, env);
const absent = runMsdTools(['config-get', 'planner.stall_detection_enabled', '--raw'], tmp, env);
assert.equal(absent.success, true, absent.error);
assert.equal(absent.output, 'true');
const noConfig = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4570-no-config-'));
const noConfig = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4570-no-config-'));
t.after(() => cleanup(noConfig));
const absentFile = runGsdTools(
const absentFile = runMsdTools(
['config-get', 'planner.stall_detection_enabled', '--raw'],
noConfig,
{ HOME: noConfig, USERPROFILE: noConfig },
@@ -504,13 +504,13 @@ describe('enhancement #4570 config contract — planner stall detection has a ty
assert.equal(absentFile.success, true, absentFile.error);
assert.equal(absentFile.output, 'true');
const set = runGsdTools(['config-set', 'planner.stall_detection_enabled', 'false'], tmp, env);
const set = runMsdTools(['config-set', 'planner.stall_detection_enabled', 'false'], tmp, env);
assert.equal(set.success, true, set.error);
const onDisk = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf8'));
assert.equal(onDisk.planner.stall_detection_enabled, false);
assert.equal(typeof onDisk.planner.stall_detection_enabled, 'boolean');
const roundTrip = runGsdTools(['config-get', 'planner.stall_detection_enabled', '--raw'], tmp, env);
const roundTrip = runMsdTools(['config-get', 'planner.stall_detection_enabled', '--raw'], tmp, env);
assert.equal(roundTrip.success, true, roundTrip.error);
assert.equal(roundTrip.output, 'false');
});
@@ -526,7 +526,7 @@ describe('enhancement #4570 config contract — planner stall detection has a ty
fc.assert(
fc.property(invalidValue, (value) => {
const result = runGsdTools(
const result = runMsdTools(
['config-set', 'planner.stall_detection_enabled', value],
tmp,
{ HOME: tmp, USERPROFILE: tmp },
@@ -539,7 +539,7 @@ describe('enhancement #4570 config contract — planner stall detection has a ty
test('hand-edited non-booleans fail safely to true on both config-get and Config Loader reads', (t) => {
const tmp = makeProject(t, { planner: { stall_detection_enabled: 'false' } });
const result = runGsdTools(
const result = runMsdTools(
['config-get', 'planner.stall_detection_enabled', '--raw'],
tmp,
{ HOME: tmp, USERPROFILE: tmp },
@@ -547,18 +547,18 @@ describe('enhancement #4570 config contract — planner stall detection has a ty
assert.equal(result.success, true, result.error);
assert.equal(result.output, 'true', 'a string "false" must not disable the watchdog');
const { loadConfig } = require('../gsd-core/bin/lib/config-loader.cjs');
const { loadConfig } = require('../msd-core/bin/lib/config-loader.cjs');
assert.equal(loadConfig(tmp).planner_stall_detection_enabled, true);
});
test('manifest skew cannot make a non-boolean planner setting disable detection', () => {
const { resolvePlannerStallDetectionEnabled } = require('../gsd-core/bin/lib/config-loader.cjs');
const { resolvePlannerStallDetectionEnabled } = require('../msd-core/bin/lib/config-loader.cjs');
for (const value of [undefined, null, 'false', 0, {}]) {
assert.equal(resolvePlannerStallDetectionEnabled(value), true);
}
});
test('root, GSD_PROJECT, and workstream reads retain canonical scope precedence', (t) => {
test('root, MSD_PROJECT, and workstream reads retain canonical scope precedence', (t) => {
const tmp = makeProject(t, { planner: { stall_detection_enabled: false } });
const projectDir = path.join(tmp, '.planning', 'product-a');
const workstreamDir = path.join(tmp, '.planning', 'workstreams', 'alpha');
@@ -568,24 +568,24 @@ describe('enhancement #4570 config contract — planner stall detection has a ty
fs.writeFileSync(path.join(workstreamDir, 'config.json'), '{"planner":{"stall_detection_enabled":true}}\n');
const home = { HOME: tmp, USERPROFILE: tmp };
assert.equal(runGsdTools(['config-get', 'planner.stall_detection_enabled', '--raw'], tmp, home).output, 'false');
assert.equal(runGsdTools(
assert.equal(runMsdTools(['config-get', 'planner.stall_detection_enabled', '--raw'], tmp, home).output, 'false');
assert.equal(runMsdTools(
['config-get', 'planner.stall_detection_enabled', '--raw'], tmp,
{ ...home, GSD_PROJECT: 'product-a' },
{ ...home, MSD_PROJECT: 'product-a' },
).output, 'true');
assert.equal(runGsdTools(
assert.equal(runMsdTools(
['config-get', 'planner.stall_detection_enabled', '--raw'], tmp,
{ ...home, GSD_WORKSTREAM: 'alpha' },
{ ...home, MSD_WORKSTREAM: 'alpha' },
).output, 'true');
const { loadConfig } = require('../gsd-core/bin/lib/config-loader.cjs');
const { loadConfig } = require('../msd-core/bin/lib/config-loader.cjs');
assert.equal(loadConfig(tmp).planner_stall_detection_enabled, false);
assert.equal(loadConfig(tmp, { workstream: 'alpha' }).planner_stall_detection_enabled, true);
fs.writeFileSync(path.join(workstreamDir, 'config.json'), '{"planner":{}}\n');
assert.equal(runGsdTools(
assert.equal(runMsdTools(
['config-get', 'planner.stall_detection_enabled', '--raw'], tmp,
{ ...home, GSD_WORKSTREAM: 'alpha' },
{ ...home, MSD_WORKSTREAM: 'alpha' },
).output, 'false', 'an omitted workstream value must inherit the root value');
assert.equal(loadConfig(tmp, { workstream: 'alpha' }).planner_stall_detection_enabled, false);
});
@@ -619,7 +619,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
});
test('plan-phase.md points at the lazily-loaded stall-detection-helpers.md step file (step 7.99)', () => {
assert.match(workflow, /gsd-core\/workflows\/plan-phase\/steps\/stall-detection-helpers\.md/);
assert.match(workflow, /msd-core\/workflows\/plan-phase\/steps\/stall-detection-helpers\.md/);
});
test('stall-detection-helpers.md resolves PLANNER_STALL_INTERVAL_MINUTES / PLANNER_STALL_THRESHOLD_MINUTES from config', () => {
@@ -632,7 +632,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
test('invalid or absent toggle values normalize to default-on; only boolean false disables', (t) => {
const helpersBash = extractStallHelpersBash();
for (const [stored, expected] of [[undefined, 'true'], [true, 'true'], [false, 'false'], ['false', 'true'], [0, 'true'], [null, 'true']]) {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4570-resolve-'));
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4570-resolve-'));
t.after(() => cleanup(tmp));
fs.mkdirSync(path.join(tmp, '.planning'), { recursive: true });
const config = stored === undefined ? {} : { planner: { stall_detection_enabled: stored } };
@@ -642,7 +642,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
[],
{
cwd: tmp,
env: { ...process.env, HOME: tmp, USERPROFILE: tmp, RUNTIME_DIR: REPO_ROOT, GSD_PROJECT: '', GSD_WORKSTREAM: '' },
env: { ...process.env, HOME: tmp, USERPROFILE: tmp, RUNTIME_DIR: REPO_ROOT, MSD_PROJECT: '', MSD_WORKSTREAM: '' },
},
);
assert.equal(result.status, 0, result.stderr);
@@ -650,30 +650,30 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
}
});
test('standard planner spawn (step 8) dispatches with run_in_background=true and calls gsd_stall_watch', () => {
const idx = workflow.indexOf('## 8. Spawn gsd-planner Agent');
test('standard planner spawn (step 8) dispatches with run_in_background=true and calls msd_stall_watch', () => {
const idx = workflow.indexOf('## 8. Spawn msd-planner Agent');
assert.notEqual(idx, -1);
// #2993 moved "## 8.5. Chunked Planning Mode" itself out of plan-phase.md
// (now a <!-- gsd:section --> pointer to steps/chunked-planning-mode.md,
// (now a <!-- msd:section --> pointer to steps/chunked-planning-mode.md,
// asserted separately below) — bound this slice at the next heading that
// still actually exists in plan-phase.md instead.
const nextSectionIdx = workflow.indexOf('## 9. Handle Planner Return', idx);
const section = workflow.slice(idx, nextSectionIdx === -1 ? undefined : nextSectionIdx);
assert.match(section, /run_in_background\s*=\s*true/, 'standard planner spawn must set run_in_background=true');
assert.match(section, /gsd_stall_watch/, 'standard planner spawn must invoke the bounded stall watcher');
assert.match(section, /gsd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'standard planner spawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
assert.match(section, /msd_stall_watch/, 'standard planner spawn must invoke the bounded stall watcher');
assert.match(section, /msd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'standard planner spawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
});
test('plan-phase.md points at the lazily-loaded chunked-planning-mode.md step file (8.5, #2993)', () => {
// #2993 (epic #1671 Phase 6.2, unrelated to #2650) extracted the whole
// "Chunked Planning Mode" section into gsd-core/workflows/plan-phase/steps/
// chunked-planning-mode.md, leaving a <!-- gsd:section --> pointer behind.
// "Chunked Planning Mode" section into msd-core/workflows/plan-phase/steps/
// chunked-planning-mode.md, leaving a <!-- msd:section --> pointer behind.
// The two stall-watch spawn sites that used to live inline (8.5.1 outline,
// 8.5.2 per-plan) moved with it — asserted directly against that file below.
assert.match(workflow, /gsd-core\/workflows\/plan-phase\/steps\/chunked-planning-mode\.md/);
assert.match(workflow, /msd-core\/workflows\/plan-phase\/steps\/chunked-planning-mode\.md/);
});
test('chunked outline spawn (8.5.1) dispatches with run_in_background=true and calls gsd_stall_watch', () => {
test('chunked outline spawn (8.5.1) dispatches with run_in_background=true and calls msd_stall_watch', () => {
// Lives in the extracted steps/chunked-planning-mode.md since #2993, not
// in plan-phase.md itself — read that file directly (see
// readChunkedPlanningMode()'s doc comment for why not the generic
@@ -684,11 +684,11 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
const nextSectionIdx = chunkedDoc.indexOf('### 8.5.2 Per-Plan Tasks', idx);
const section = chunkedDoc.slice(idx, nextSectionIdx === -1 ? undefined : nextSectionIdx);
assert.match(section, /run_in_background\s*=\s*true/, 'chunked outline spawn must set run_in_background=true');
assert.match(section, /gsd_stall_watch/, 'chunked outline spawn must invoke the bounded stall watcher');
assert.match(section, /gsd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'chunked outline spawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
assert.match(section, /msd_stall_watch/, 'chunked outline spawn must invoke the bounded stall watcher');
assert.match(section, /msd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'chunked outline spawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
});
test('chunked per-plan spawn (8.5.2) dispatches with run_in_background=true and calls gsd_stall_watch', () => {
test('chunked per-plan spawn (8.5.2) dispatches with run_in_background=true and calls msd_stall_watch', () => {
// Same relocation as the outline spawn above (#2993) — read
// steps/chunked-planning-mode.md directly. 8.5.2 is the LAST section in
// that file, so an unbounded slice to EOF is precise here (unlike slicing
@@ -699,34 +699,34 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
assert.notEqual(idx, -1);
const section = chunkedDoc.slice(idx);
assert.match(section, /run_in_background\s*=\s*true/, 'chunked per-plan spawn must set run_in_background=true');
assert.match(section, /gsd_stall_watch/, 'chunked per-plan spawn must invoke the bounded stall watcher');
assert.match(section, /gsd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'chunked per-plan spawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
assert.match(section, /msd_stall_watch/, 'chunked per-plan spawn must invoke the bounded stall watcher');
assert.match(section, /msd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'chunked per-plan spawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
});
test('plan-checker spawn (step 10) dispatches with run_in_background=true and calls gsd_stall_watch', () => {
const idx = workflow.indexOf('## 10. Spawn gsd-plan-checker Agent');
test('plan-checker spawn (step 10) dispatches with run_in_background=true and calls msd_stall_watch', () => {
const idx = workflow.indexOf('## 10. Spawn msd-plan-checker Agent');
assert.notEqual(idx, -1);
const nextSectionIdx = workflow.indexOf('## 11. Handle Checker Return', idx);
const section = workflow.slice(idx, nextSectionIdx === -1 ? undefined : nextSectionIdx);
assert.match(section, /run_in_background\s*=\s*true/, 'plan-checker spawn must set run_in_background=true');
assert.match(section, /gsd_stall_watch/, 'plan-checker spawn must invoke the bounded stall watcher');
assert.match(section, /gsd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'plan-checker spawn must bind {outputFile} into the stall watcher call — this is the ONLY completion signal on a clean PASS, since a passing checker touches no *-PLAN.md files');
assert.match(section, /msd_stall_watch/, 'plan-checker spawn must invoke the bounded stall watcher');
assert.match(section, /msd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'plan-checker spawn must bind {outputFile} into the stall watcher call — this is the ONLY completion signal on a clean PASS, since a passing checker touches no *-PLAN.md files');
});
test('revision-loop planner respawn (step 12) dispatches with run_in_background=true and calls gsd_stall_watch', () => {
test('revision-loop planner respawn (step 12) dispatches with run_in_background=true and calls msd_stall_watch', () => {
const idx = workflow.indexOf('## 12. Revision Loop');
assert.notEqual(idx, -1);
const nextSectionIdx = workflow.indexOf('## 12.5. Plan Bounce', idx);
const section = workflow.slice(idx, nextSectionIdx === -1 ? undefined : nextSectionIdx);
assert.match(section, /run_in_background\s*=\s*true/, 'revision-loop planner respawn must set run_in_background=true');
assert.match(section, /gsd_stall_watch/, 'revision-loop planner respawn must invoke the bounded stall watcher');
assert.match(section, /gsd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'revision-loop planner respawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
assert.match(section, /msd_stall_watch/, 'revision-loop planner respawn must invoke the bounded stall watcher');
assert.match(section, /msd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/, 'revision-loop planner respawn must bind {outputFile} into the stall watcher call, not a dead bash variable');
});
test('no spawn site references an unbound $PLANNER_OUTPUT_FILE / $CHECKER_OUTPUT_FILE bash variable', () => {
// Regression for the blocker an independent review found: the original
// design named PLANNER_OUTPUT_FILE/CHECKER_OUTPUT_FILE as bash variables
// in the gsd_stall_watch calls, but nothing in plan-phase.md ever ASSIGNED
// in the msd_stall_watch calls, but nothing in plan-phase.md ever ASSIGNED
// them — with the variable permanently empty, `[ -f "$output_file" ]` is
// always false, marker_found can never become true, and marker_received is
// unreachable. Worse for the plan-checker spawn specifically: a checker
@@ -737,8 +737,8 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
// same convention docs-update.md:471 already uses for a real
// run_in_background=true Agent() return). This test proves the dead
// variable name is gone from every spawn site, not just that
// gsd_stall_watch behaves correctly when handed a valid argument
// (tests/fix-2650-plan-phase-stall-detection.test.cjs's gsd_stall_watch
// msd_stall_watch behaves correctly when handed a valid argument
// (tests/fix-2650-plan-phase-stall-detection.test.cjs's msd_stall_watch
// describe block below already covers that half — this covers the
// production wiring the previous tests never exercised).
assert.doesNotMatch(workflow, /\$PLANNER_OUTPUT_FILE\b/, 'plan-phase.md must not reference an unassigned $PLANNER_OUTPUT_FILE bash variable');
@@ -750,7 +750,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
assert.doesNotMatch(chunkedDoc, /\$CHECKER_OUTPUT_FILE\b/, 'chunked-planning-mode.md must not reference an unassigned $CHECKER_OUTPUT_FILE bash variable');
});
test('exactly five gsd_stall_watch spawn-site invocations exist across plan-phase.md and its steps/*.md files', () => {
test('exactly five msd_stall_watch spawn-site invocations exist across plan-phase.md and its steps/*.md files', () => {
// The whole point of #2650 is that EVERY planner/plan-checker spawn is
// bounded — not "at least one". #2993 relocated two of the five call
// sites (chunked outline, chunked per-plan) into
@@ -759,15 +759,15 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
// test noticing (mirrors tests/plan-phase-drift-guard.test.cjs's #913
// ORCHESTRATOR RULE label count, which already does this).
const combined = readWorkflowCombined(PLAN_PHASE_PATH);
const callCount = (combined.match(/gsd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/g) || []).length;
const callCount = (combined.match(/msd_stall_watch\s+"\$TS"\s+"\{outputFile\}"/g) || []).length;
assert.equal(callCount, 5,
`expected exactly 5 gsd_stall_watch "$TS" "{outputFile}" spawn-site invocations across plan-phase.md + steps/*.md, found ${callCount}`);
`expected exactly 5 msd_stall_watch "$TS" "{outputFile}" spawn-site invocations across plan-phase.md + steps/*.md, found ${callCount}`);
});
test('all five spawn classes gate background surveillance and retain a runtime-native blocking result path', () => {
const mainSections = [
['standard planner', '## 8. Spawn gsd-planner Agent', '## 9. Handle Planner Return'],
['plan-checker', '## 10. Spawn gsd-plan-checker Agent', '## 11. Handle Checker Return'],
['standard planner', '## 8. Spawn msd-planner Agent', '## 9. Handle Planner Return'],
['plan-checker', '## 10. Spawn msd-plan-checker Agent', '## 11. Handle Checker Return'],
['revision planner', '## 12. Revision Loop', '## 12.5. Plan Bounce'],
];
const chunkedDoc = readChunkedPlanningMode();
@@ -785,7 +785,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
for (const [label, section] of sections) {
assert.match(section, /PLANNER_STALL_DETECTION_ENABLED/, `${label}: missing toggle gate`);
assert.match(section, /`true`[\s\S]*run_in_background=true[\s\S]*gsd_stall_watch/,
assert.match(section, /`true`[\s\S]*run_in_background=true[\s\S]*msd_stall_watch/,
`${label}: default-on branch must retain background watcher behavior`);
assert.match(section, /`false`[\s\S]{0,700}(?:omit|without) `?run_in_background`?[\s\S]{0,700}(?:ordinary|runtime-native)[\s\S]{0,500}(?:return|result)/i,
`${label}: explicit-off branch must omit backgrounding and await the real runtime result`);
@@ -795,7 +795,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
test('step 7.99 documents that {outputFile} must be bound from the real Agent() return (not passed literally)', () => {
const idx = workflow.indexOf('## 7.99. Bounded Stall-Detection Helpers');
assert.notEqual(idx, -1);
const nextSectionIdx = workflow.indexOf('## 8. Spawn gsd-planner Agent', idx);
const nextSectionIdx = workflow.indexOf('## 8. Spawn msd-planner Agent', idx);
const section = workflow.slice(idx, nextSectionIdx === -1 ? undefined : nextSectionIdx);
assert.match(section, /\{outputFile\}/, 'step 7.99 must mention {outputFile} so a reader knows it is a binding token, not literal text');
// The full binding contract (docs-update.md precedent, why a bash variable
@@ -828,14 +828,14 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
});
test('researcher (line ~404) and pattern-mapper (line ~681) spawns are untouched (out of scope)', () => {
const researcherIdx = workflow.indexOf('### Spawn gsd-phase-researcher');
const patternMapperIdx = workflow.indexOf('## 7.8. Spawn gsd-pattern-mapper Agent');
const researcherIdx = workflow.indexOf('### Spawn msd-phase-researcher');
const patternMapperIdx = workflow.indexOf('## 7.8. Spawn msd-pattern-mapper Agent');
assert.notEqual(researcherIdx, -1);
assert.notEqual(patternMapperIdx, -1);
const researcherSection = workflow.slice(researcherIdx, workflow.indexOf('### Handle Researcher Return'));
const patternMapperSection = workflow.slice(patternMapperIdx, workflow.indexOf('## 7.9. Regenerate API-SURFACE.md'));
assert.doesNotMatch(researcherSection, /gsd_stall_watch/, 'researcher spawn must remain a plain blocking call (out of scope per Agent Brief)');
assert.doesNotMatch(patternMapperSection, /gsd_stall_watch/, 'pattern-mapper spawn must remain a plain blocking call (out of scope per Agent Brief)');
assert.doesNotMatch(researcherSection, /msd_stall_watch/, 'researcher spawn must remain a plain blocking call (out of scope per Agent Brief)');
assert.doesNotMatch(patternMapperSection, /msd_stall_watch/, 'pattern-mapper spawn must remain a plain blocking call (out of scope per Agent Brief)');
});
});
@@ -844,7 +844,7 @@ describe('bug #2650 plan-phase — all five planner/plan-checker spawns dispatch
//
// runBashScript hard-coded `timeout: 10000`. The script it runs is not a cheap
// probe: extractStallHelpersBash slices the ENTIRE ```bash fence, whose runtime-launcher
// preamble resolves gsd-tools.cjs and really runs two `gsd_run query config-get` lines —
// preamble resolves msd-tools.cjs and really runs two `msd_run query config-get` lines —
// two full Node spawns (measured 236ms vs 2ms for the fallback the old comment claimed
// fires: 118x). On `full test (windows-latest, 24, shard 1/3)` that bound was exceeded at
// 10006ms and spawnSync's kill surfaced as `status: null`, which the call site asserted
@@ -929,9 +929,9 @@ describe('#2650 follow-up: runBashScript bounds and reports a bash fan-out corre
// The helper must still clean up its temp dir when the seam throws — the throw
// escapes through runBashScript's `finally`, which is what makes the rejection safe
// to rely on rather than a resource leak.
const before = fs.readdirSync(os.tmpdir()).filter((n) => n.startsWith('gsd-2650-sh-')).length;
const before = fs.readdirSync(os.tmpdir()).filter((n) => n.startsWith('msd-2650-sh-')).length;
assert.throws(() => runBashScript('exit 0\n', [], { timeoutMs: RUN_BASH_SCRIPT_TIMEOUT_BOUNDARY_ZERO_MS }), TypeError);
const after = fs.readdirSync(os.tmpdir()).filter((n) => n.startsWith('gsd-2650-sh-')).length;
const after = fs.readdirSync(os.tmpdir()).filter((n) => n.startsWith('msd-2650-sh-')).length;
assert.equal(after, before, 'a rejected bound must not leak the script temp dir');
});
});