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

@@ -3,14 +3,14 @@
/**
* Broken-windows ledger — behavioral + property tests.
*
* Module: gsd-core/bin/lib/broken-windows.cjs (compiled from src/broken-windows.cts)
* CLI: gsd-tools windows <status|append|waive|fixed>
* Module: msd-core/bin/lib/broken-windows.cjs (compiled from src/broken-windows.cts)
* CLI: msd-tools windows <status|append|waive|fixed>
*
* Issue: #1950 — enforced cross-phase defect register gating /gsd-ship.
* Issue: #1950 — enforced cross-phase defect register gating /msd-ship.
*
* Coverage map (acceptance criteria from #1950):
* - Executor writes stubs to ledger → append (CLI + pure)
* - /gsd-ship fails while any entry is open → openCount + cmdWindowsStatus
* - /msd-ship fails while any entry is open → openCount + cmdWindowsStatus
* - Waive requires non-empty reason → markWaived / cmdWindowsWaive
* - Marking fixed removes from blocking set → markFixed / cmdWindowsMarkFixed
* - Open-window count in progress surface → cmdWindowsStatus emits open_count
@@ -29,15 +29,15 @@ const { spawn } = require('node:child_process');
const {
createTempDir,
cleanup,
runGsdTools,
runMsdTools,
TOOLS_PATH,
TEST_ENV_BASE,
} = require('./helpers.cjs');
const { PROBE_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
const fc = require('./helpers/fast-check-setup.cjs');
const brokenWindowsLib = require('../gsd-core/bin/lib/broken-windows.cjs');
const lockMod = require('../gsd-core/bin/lib/capability-lock.cjs');
const brokenWindowsLib = require('../msd-core/bin/lib/broken-windows.cjs');
const lockMod = require('../msd-core/bin/lib/capability-lock.cjs');
const {
REASON,
WindowsError,
@@ -499,7 +499,7 @@ describe('broken-windows: parseLedger backward compatibility for the #4487 miles
});
// ---------------------------------------------------------------------------
// CLI: gsd-tools windows status (acceptance: clean-ship on empty)
// CLI: msd-tools windows status (acceptance: clean-ship on empty)
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -550,14 +550,14 @@ describe('broken-windows: fence-width tolerant read (#3657)', () => {
test('windows status recovers on a formatter-normalized ledger (#3657)', (t) => {
const tmp = createTempDir();
t.after(() => cleanup(tmp));
const r0 = runGsdTools(
const r0 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'normalized ledger entry'],
tmp
);
assert.ok(r0.success, `seed append failed: ${r0.error || ''}`);
narrowLedgerOnDisk(path.join(tmp, '.planning', LEDGER_FILE_NAME));
const res = runGsdTools(['windows', 'status', '--raw'], tmp);
const res = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.ok(res.success, `status must recover on a normalized ledger: ${res.error || ''}`);
const obj = JSON.parse(res.output);
assert.equal(obj.ok, true);
@@ -568,25 +568,25 @@ describe('broken-windows: fence-width tolerant read (#3657)', () => {
const tmp = createTempDir();
t.after(() => cleanup(tmp));
const ledgerPath = path.join(tmp, '.planning', LEDGER_FILE_NAME);
const r0 = runGsdTools(
const r0 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'first'],
tmp
);
assert.ok(r0.success, `seed append failed: ${r0.error || ''}`);
narrowLedgerOnDisk(ledgerPath);
const rAppend = runGsdTools(
const rAppend = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'second'],
tmp
);
assert.ok(rAppend.success, `append must recover on a normalized ledger: ${rAppend.error || ''}`);
narrowLedgerOnDisk(ledgerPath);
const rWaive = runGsdTools(['windows', 'waive', '1', 'duplicate of second'], tmp);
const rWaive = runMsdTools(['windows', 'waive', '1', 'duplicate of second'], tmp);
assert.ok(rWaive.success, `waive must recover on a normalized ledger: ${rWaive.error || ''}`);
narrowLedgerOnDisk(ledgerPath);
const rFixed = runGsdTools(['windows', 'fixed', '2'], tmp);
const rFixed = runMsdTools(['windows', 'fixed', '2'], tmp);
assert.ok(rFixed.success, `fixed must recover on a normalized ledger: ${rFixed.error || ''}`);
// Writer contract unchanged: after any write the ledger is back on the
@@ -595,7 +595,7 @@ describe('broken-windows: fence-width tolerant read (#3657)', () => {
assert.match(after, /^````json$/m, 'rewritten ledger must re-emit the 4-backtick writer fence');
assert.doesNotMatch(after, /^```json$/m, 'the 3-backtick form is a formatter artifact, never written');
const status = runGsdTools(['windows', 'status', '--raw'], tmp);
const status = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.ok(status.success, `final status failed: ${status.error || ''}`);
assert.equal(JSON.parse(status.output).ledger.open_count, 0);
});
@@ -604,7 +604,7 @@ describe('broken-windows: fence-width tolerant read (#3657)', () => {
const tmp = createTempDir();
t.after(() => cleanup(tmp));
const ledgerPath = path.join(tmp, '.planning', LEDGER_FILE_NAME);
const r0 = runGsdTools(
const r0 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'prose carrier'],
tmp
);
@@ -615,7 +615,7 @@ describe('broken-windows: fence-width tolerant read (#3657)', () => {
fs.writeFileSync(ledgerPath, withProse, 'utf8');
narrowLedgerOnDisk(ledgerPath);
const rAppend = runGsdTools(
const rAppend = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'second'],
tmp
);
@@ -723,7 +723,7 @@ describe('broken-windows CLI: windows status', () => {
const tmp = createTempDir('bw-status-empty-');
t.after(() => cleanup(tmp));
const res = runGsdTools(['windows', 'status', '--raw'], tmp);
const res = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(res.success, true, `stderr: ${res.error || ''}`);
const obj = JSON.parse(res.output);
assert.equal(obj.ok, true);
@@ -740,7 +740,7 @@ describe('broken-windows CLI: windows status', () => {
'not valid markdown or frontmatter',
);
const res = runGsdTools(['windows', 'status', '--raw'], tmp);
const res = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(res.success, false);
assert.ok(res.exitCode !== 0);
assert.match(res.error, /malformed|invalid frontmatter|missing frontmatter/i);
@@ -778,7 +778,7 @@ describe('broken-windows CLI: windows status', () => {
fs.writeFileSync(path.join(tmp, '.planning', LEDGER_FILE_NAME), validLedger);
try { fs.chmodSync(path.join(tmp, '.planning', LEDGER_FILE_NAME), 0o000); } catch { return; }
const res = runGsdTools(['windows', 'status', '--raw'], tmp);
const res = runMsdTools(['windows', 'status', '--raw'], tmp);
// If the chmod actually took (non-root), the read must fail. If running as
// root (CI rarely does), the read may succeed — either way, the test must
// never see a false-green "open_count: 0" from a file we KNOW has open_count=1.
@@ -792,7 +792,7 @@ describe('broken-windows CLI: windows status', () => {
});
// ---------------------------------------------------------------------------
// CLI: gsd-tools windows append (acceptance: executor writes stubs)
// CLI: msd-tools windows append (acceptance: executor writes stubs)
// ---------------------------------------------------------------------------
describe('broken-windows CLI: windows append', () => {
@@ -800,7 +800,7 @@ describe('broken-windows CLI: windows append', () => {
const tmp = createTempDir('bw-append-create-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2',
'--file', 'src/auth.ts', '--line', '42',
'--description', 'hardcoded empty list in UserService.list'],
@@ -818,7 +818,7 @@ describe('broken-windows CLI: windows append', () => {
assert.equal(fs.existsSync(ledgerPath), true);
// Second invocation observes the persisted entry (idempotent read).
const res2 = runGsdTools(['windows', 'status', '--raw'], tmp);
const res2 = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(res2.success, true);
const obj2 = JSON.parse(res2.output);
assert.equal(obj2.ledger.open_count, 1);
@@ -839,7 +839,7 @@ describe('broken-windows CLI: windows append', () => {
'---\nmilestone: v2.0\n---\n# Project State\n',
'utf-8',
);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '5', '--description', 'x'],
tmp,
);
@@ -850,7 +850,7 @@ describe('broken-windows CLI: windows append', () => {
test('append stamps null when no milestone is resolvable (#4487)', (t) => {
const tmp = createTempDir('bw-append-milestone-none-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '5', '--description', 'x'],
tmp,
);
@@ -868,7 +868,7 @@ describe('broken-windows CLI: windows append', () => {
'# Roadmap\n\n## 🚧 **v3.1** — In Progress\n',
'utf-8',
);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '5', '--description', 'x'],
tmp,
);
@@ -880,12 +880,12 @@ describe('broken-windows CLI: windows append', () => {
const tmp = createTempDir('bw-append-second-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'first todo'],
tmp,
);
assert.equal(r1.success, true, `stderr: ${r1.error || ''}`);
const r2 = runGsdTools(
const r2 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'second todo'],
tmp,
);
@@ -898,7 +898,7 @@ describe('broken-windows CLI: windows append', () => {
test('append rejects unknown kind', (t) => {
const tmp = createTempDir('bw-append-badkind-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'bogus', '--phase', '2', '--description', 'x'],
tmp,
);
@@ -909,7 +909,7 @@ describe('broken-windows CLI: windows append', () => {
test('append rejects path-traversal in --file', (t) => {
const tmp = createTempDir('bw-append-traversal-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2',
'--file', '../../etc/passwd', '--description', 'x'],
tmp,
@@ -921,7 +921,7 @@ describe('broken-windows CLI: windows append', () => {
test('append rejects missing description', (t) => {
const tmp = createTempDir('bw-append-nodesc-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2'],
tmp,
);
@@ -934,31 +934,31 @@ describe('broken-windows CLI: windows append', () => {
t.after(() => cleanup(tmp));
// line=1: smallest valid line — limit boundary.
const r1 = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '1', '--description', 'b'], tmp);
const r1 = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '1', '--description', 'b'], tmp);
assert.equal(r1.success, true, `--line 1 should succeed: ${r1.error || ''}`);
assert.equal(JSON.parse(r1.output).entry.line, 1);
// line=large: limit+1 boundary (just confirm it accepts arbitrary positive int).
const r2 = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '999999', '--description', 'c'], tmp);
const r2 = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '999999', '--description', 'c'], tmp);
assert.equal(r2.success, true, `--line 999999 should succeed: ${r2.error || ''}`);
assert.equal(JSON.parse(r2.output).entry.line, 999999);
// line=0: limit-1 boundary — invalid (lines are 1-indexed; 0 is not a line).
// M2 fix: validateLine no longer treats 0 as omit; it rejects as non-positive.
const rZero = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '0', '--description', 'a'], tmp);
const rZero = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '0', '--description', 'a'], tmp);
assert.equal(rZero.success, false, '--line 0 must fail (positive integers only)');
assert.match(rZero.error, /line|positive integer/i);
// line=-1 and line=abc: also invalid — fail closed.
const rNeg = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '-1', '--description', 'd'], tmp);
const rNeg = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', '-1', '--description', 'd'], tmp);
assert.equal(rNeg.success, false);
assert.match(rNeg.error, /line|positive integer/i);
const rGarbage = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', 'abc', '--description', 'e'], tmp);
const rGarbage = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--line', 'abc', '--description', 'e'], tmp);
assert.equal(rGarbage.success, false);
assert.match(rGarbage.error, /line|positive integer/i);
// line OMITTED entirely: valid, line is null.
const rOmit = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'f'], tmp);
const rOmit = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'f'], tmp);
assert.equal(rOmit.success, true, `--line omitted should succeed: ${rOmit.error || ''}`);
assert.equal(JSON.parse(rOmit.output).entry.line, null);
});
@@ -966,7 +966,7 @@ describe('broken-windows CLI: windows append', () => {
test('append rejects 4-backtick description via CLI (H1 regression)', (t) => {
const tmp = createTempDir('bw-append-4tick-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'has ```` four backticks'],
tmp,
);
@@ -1002,7 +1002,7 @@ describe('broken-windows CLI: windows append', () => {
fs.writeFileSync(lp, initial + prose, 'utf8');
// First append.
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'test entry'],
tmp,
);
@@ -1010,7 +1010,7 @@ describe('broken-windows CLI: windows append', () => {
assert.equal(JSON.parse(res.output).ok, true);
// Second append — idempotency: prose must appear exactly once, not duplicated.
const res2 = runGsdTools(
const res2 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '3', '--description', 'second entry'],
tmp,
);
@@ -1036,7 +1036,7 @@ describe('broken-windows CLI: windows append', () => {
});
// ---------------------------------------------------------------------------
// CLI: gsd-tools windows waive (acceptance: waive-with-reason)
// CLI: msd-tools windows waive (acceptance: waive-with-reason)
// ---------------------------------------------------------------------------
describe('broken-windows CLI: windows waive', () => {
@@ -1044,7 +1044,7 @@ describe('broken-windows CLI: windows waive', () => {
const tmp = createTempDir('bw-waive-ok-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'skipped-test', '--phase', '3',
'--file', 'tests/x.test.cjs', '--line', '18',
'--description', 't.skip logout flow'],
@@ -1052,7 +1052,7 @@ describe('broken-windows CLI: windows waive', () => {
);
assert.equal(r1.success, true, `stderr: ${r1.error || ''}`);
const r2 = runGsdTools(
const r2 = runMsdTools(
['windows', 'waive', '1', 'Manual QA covers it; CI cannot reach logout URL'],
tmp,
);
@@ -1062,7 +1062,7 @@ describe('broken-windows CLI: windows waive', () => {
assert.equal(obj.ledger.entries[0].status, 'waived');
assert.equal(obj.ledger.entries[0].reason, 'Manual QA covers it; CI cannot reach logout URL');
const r3 = runGsdTools(['windows', 'status', '--raw'], tmp);
const r3 = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(r3.success, true);
const status = JSON.parse(r3.output);
assert.equal(status.ledger.open_count, 0); // waived does not block ship
@@ -1072,13 +1072,13 @@ describe('broken-windows CLI: windows waive', () => {
test('waive with empty reason fails', (t) => {
const tmp = createTempDir('bw-waive-empty-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'x'],
tmp,
);
assert.equal(r1.success, true, `stderr: ${r1.error || ''}`);
const r2 = runGsdTools(['windows', 'waive', '1', ''], tmp);
const r2 = runMsdTools(['windows', 'waive', '1', ''], tmp);
assert.equal(r2.success, false);
assert.match(r2.error, /waive.*reason|non-empty|reason.*required/i);
});
@@ -1086,14 +1086,14 @@ describe('broken-windows CLI: windows waive', () => {
test('waive unknown id fails', (t) => {
const tmp = createTempDir('bw-waive-unknown-');
t.after(() => cleanup(tmp));
const res = runGsdTools(['windows', 'waive', '999', 'because'], tmp);
const res = runMsdTools(['windows', 'waive', '999', 'because'], tmp);
assert.equal(res.success, false);
assert.match(res.error, /no window|id 999|not found/i);
});
});
// ---------------------------------------------------------------------------
// CLI: gsd-tools windows fixed (acceptance: fixed removes from blocking set)
// CLI: msd-tools windows fixed (acceptance: fixed removes from blocking set)
// ---------------------------------------------------------------------------
describe('broken-windows CLI: windows fixed', () => {
@@ -1101,17 +1101,17 @@ describe('broken-windows CLI: windows fixed', () => {
const tmp = createTempDir('bw-fixed-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'x'],
tmp,
);
assert.equal(r1.success, true, `stderr: ${r1.error || ''}`);
const rBefore = runGsdTools(['windows', 'status', '--raw'], tmp);
const rBefore = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(rBefore.success, true);
assert.equal(JSON.parse(rBefore.output).ledger.open_count, 1);
const r2 = runGsdTools(['windows', 'fixed', '1'], tmp);
const r2 = runMsdTools(['windows', 'fixed', '1'], tmp);
assert.equal(r2.success, true, `stderr: ${r2.error || ''}`);
const obj = JSON.parse(r2.output);
assert.equal(obj.ledger.open_count, 0);
@@ -1122,7 +1122,7 @@ describe('broken-windows CLI: windows fixed', () => {
test('fixed on unknown id fails', (t) => {
const tmp = createTempDir('bw-fixed-unknown-');
t.after(() => cleanup(tmp));
const res = runGsdTools(['windows', 'fixed', '999'], tmp);
const res = runMsdTools(['windows', 'fixed', '999'], tmp);
assert.equal(res.success, false);
assert.match(res.error, /no window|id 999|not found/i);
});
@@ -1137,14 +1137,14 @@ describe('broken-windows CLI: lifecycle', () => {
const tmp = createTempDir('bw-lifecycle-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'a'], tmp);
const r2 = runGsdTools(['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'b'], tmp);
const r3 = runGsdTools(['windows', 'waive', '1', 'deferred to follow-up'], tmp);
const r4 = runGsdTools(['windows', 'fixed', '2'], tmp);
const r1 = runMsdTools(['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'a'], tmp);
const r2 = runMsdTools(['windows', 'append', '--kind', 'todo', '--phase', '2', '--description', 'b'], tmp);
const r3 = runMsdTools(['windows', 'waive', '1', 'deferred to follow-up'], tmp);
const r4 = runMsdTools(['windows', 'fixed', '2'], tmp);
assert.equal(r1.success && r2.success && r3.success && r4.success, true,
`lifecycle steps failed: r1=${r1.error || 'ok'} r2=${r2.error || 'ok'} r3=${r3.error || 'ok'} r4=${r4.error || 'ok'}`);
const rFinal = runGsdTools(['windows', 'status', '--raw'], tmp);
const rFinal = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(rFinal.success, true);
const status = JSON.parse(rFinal.output);
assert.equal(status.ledger.open_count, 0); // ship gate would pass
@@ -1217,7 +1217,7 @@ describe('#3116: parseLedger handles CRLF ledgers', () => {
// unconditionally, with no check that the on-disk table agreed with the JSON
// beforehand — so a hand-edited table cell is silently reverted, and a
// table-only row silently vanishes, on the next append/waive/fixed. See
// .gsd/bug/fix-3689-windows-ledger-table-drift-guard/repro.cjs.
// .msd/bug/fix-3689-windows-ledger-table-drift-guard/repro.cjs.
// ---------------------------------------------------------------------------
describe('#3689: windows ledger table-vs-JSON drift guard', () => {
@@ -1225,12 +1225,12 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
function seedPristineLedger(t) {
const seedCwd = createTempDir('bw-3689-seed-');
t.after(() => cleanup(seedCwd));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '1', '--description', 'first entry', '--file', 'a/one.sh'],
seedCwd,
);
assert.ok(r1.success, `seed append 1 failed: ${r1.error || ''}`);
const r2 = runGsdTools(
const r2 = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '2', '--description', 'second entry', '--file', 'b/two.sh'],
seedCwd,
);
@@ -1289,10 +1289,10 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
writeLedgerFile(tmp, drifted);
const before = readLedgerFile(tmp);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '99', '--description', 'third entry', '--file', 'c/three.sh'],
tmp,
{ GSD_JSON_ERRORS: '1' },
{ MSD_JSON_ERRORS: '1' },
);
assert.equal(res.success, false, 'append must refuse on table drift');
@@ -1317,10 +1317,10 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
writeLedgerFile(tmp, withExtraRow);
const before = readLedgerFile(tmp);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '7', '--description', 'fourth entry', '--file', 'd/four.sh'],
tmp,
{ GSD_JSON_ERRORS: '1' },
{ MSD_JSON_ERRORS: '1' },
);
assert.equal(res.success, false, 'append must refuse rather than silently drop the table-only row');
@@ -1340,7 +1340,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
writeLedgerFile(tmp, drifted);
const before = readLedgerFile(tmp);
const res = runGsdTools(['windows', 'waive', '2', 'covered by manual QA'], tmp, { GSD_JSON_ERRORS: '1' });
const res = runMsdTools(['windows', 'waive', '2', 'covered by manual QA'], tmp, { MSD_JSON_ERRORS: '1' });
assert.equal(res.success, false, 'waive must refuse on table drift');
const parsed = JSON.parse(res.error);
@@ -1358,7 +1358,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
writeLedgerFile(tmp, drifted);
const before = readLedgerFile(tmp);
const res = runGsdTools(['windows', 'fixed', '2'], tmp, { GSD_JSON_ERRORS: '1' });
const res = runMsdTools(['windows', 'fixed', '2'], tmp, { MSD_JSON_ERRORS: '1' });
assert.equal(res.success, false, 'fixed must refuse on table drift');
const parsed = JSON.parse(res.error);
@@ -1376,10 +1376,10 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
writeLedgerFile(tmp, drifted);
const before = readLedgerFile(tmp);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '5', '--description', 'fifth entry', '--file', 'e/five.sh'],
tmp,
{ GSD_JSON_ERRORS: '1' },
{ MSD_JSON_ERRORS: '1' },
);
assert.equal(res.success, false, 'append must detect drift on the second data row, not just the first');
@@ -1395,13 +1395,13 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
test('windows append still succeeds when the table agrees with the JSON (#3689)', (t) => {
const tmp = createTempDir('bw-3689-agree-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '1', '--description', 'first entry'],
tmp,
);
assert.ok(r1.success, `seed append failed: ${r1.error || ''}`);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '2', '--description', 'second entry'],
tmp,
);
@@ -1416,7 +1416,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
t.after(() => cleanup(tmp));
assert.equal(fs.existsSync(path.join(tmp, '.planning', LEDGER_FILE_NAME)), false);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '1', '--description', 'first ever entry'],
tmp,
);
@@ -1427,7 +1427,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
test('windows append preserves trailing prose when the guard passes (#2893 + #3689)', (t) => {
const tmp = createTempDir('bw-3689-prose-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '1', '--description', 'prose carrier'],
tmp,
);
@@ -1435,7 +1435,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
const ledgerPath = path.join(tmp, '.planning', LEDGER_FILE_NAME);
fs.writeFileSync(ledgerPath, fs.readFileSync(ledgerPath, 'utf8') + 'Operator notes below the ledger.\n', 'utf8');
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'second entry'],
tmp,
);
@@ -1449,7 +1449,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
test('windows append tolerates a 3-backtick fence when locating the table (#3657 + #3689)', (t) => {
const tmp = createTempDir('bw-3689-narrowfence-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '1', '--description', 'narrowed fence entry'],
tmp,
);
@@ -1463,7 +1463,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
'utf8',
);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'second entry'],
tmp,
);
@@ -1473,14 +1473,14 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
test('windows append does not trip the guard on escaped pipes and backslashes (#3689)', (t) => {
const tmp = createTempDir('bw-3689-escaping-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '1',
'--description', 'path with \\| separator and | pipe and \\ backslash'],
tmp,
);
assert.ok(r1.success, `seed append with escaped content failed: ${r1.error || ''}`);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '2', '--description', 'second entry'],
tmp,
);
@@ -1496,7 +1496,7 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
'precondition: seeded ledger renders the empty-table placeholder row',
);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'stub', '--phase', '1', '--description', 'first real entry'],
tmp,
);
@@ -1518,10 +1518,10 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
'```json\n[{"note": "a"}, {"note": "b"}, {"note": "c"}]\n```\n';
writeLedgerFile(tmp, withProse);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '3', '--description', 'third entry', '--file', 'c/three.sh'],
tmp,
{ GSD_JSON_ERRORS: '1' },
{ MSD_JSON_ERRORS: '1' },
);
assert.equal(res.success, true, `append must succeed — the ledger table agrees with the real JSON entries, not the unrelated prose array: ${res.error || ''}`);
@@ -1555,13 +1555,13 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
// `\` and `|` but not newlines, so this row physically spans two file
// lines. A `|`-prefix scan of the pre-fence text stops dead at that
// continuation line; the header-anchored fix must not.
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '1', '--description', 'line one\nline two', '--file', 'a/one.sh'],
tmp,
);
assert.ok(r1.success, `seed append with newline description failed: ${r1.error || ''}`);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '2', '--description', 'second entry', '--file', 'b/two.sh'],
tmp,
);
@@ -1579,12 +1579,12 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
test('windows append still detects drift on a ledger whose description contains a newline (#3689)', (t) => {
const tmp = createTempDir('bw-3689-newline-desc-drift-');
t.after(() => cleanup(tmp));
const r1 = runGsdTools(
const r1 = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '1', '--description', 'line one\nline two', '--file', 'a/one.sh'],
tmp,
);
assert.ok(r1.success, `seed append 1 failed: ${r1.error || ''}`);
const r2 = runGsdTools(
const r2 = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '2', '--description', 'second entry', '--file', 'b/two.sh'],
tmp,
);
@@ -1598,10 +1598,10 @@ describe('#3689: windows ledger table-vs-JSON drift guard', () => {
writeLedgerFile(tmp, drifted);
const before = readLedgerFile(tmp);
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'deviation', '--phase', '3', '--description', 'third entry', '--file', 'c/three.sh'],
tmp,
{ GSD_JSON_ERRORS: '1' },
{ MSD_JSON_ERRORS: '1' },
);
assert.equal(res.success, false, 'append must still detect drift on row 2 even though row 1 spans multiple physical lines');
@@ -1728,7 +1728,7 @@ describe('#3689 property: table region extraction round-trip', () => {
// degrades, never throws"). `fs.chmodSync(path, 0o000)` is not used: root
// (how CI/Docker run) bypasses mode bits entirely, so that approach would
// pass with zero real coverage. This must go in-process (not through
// runGsdTools) because a monkeypatch in the parent process is invisible to a
// runMsdTools) because a monkeypatch in the parent process is invisible to a
// child process.
// ---------------------------------------------------------------------------
@@ -1790,7 +1790,7 @@ describe('#1950-H2 / #3689: writeLedgerAtomic pre-image read failure', () => {
// cycle ending in an atomic rename: two parallel invocations read the same
// snapshot, computed the same nextId, and the second rename won — the first
// mutation was silently lost while its invocation still reported ok:true
// (a false-green /gsd-ship gate, since the ship decision reads open_count).
// (a false-green /msd-ship gate, since the ship decision reads open_count).
// The fix serializes the mutating commands on a `.planning/.WINDOWS.lock`
// ledger lock backed by the shared capability-lock primitive (the
// capability-consent precedent: waitForFresh + raised budget, typed throw
@@ -1804,7 +1804,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
* The sync process seam cannot interleave two writers in one thread, and a
* concurrency regression needs genuinely concurrent children. Async spawn,
* bounded by the CLI-probe class timeout, env built exactly the way
* runGsdTools builds it (process env + TEST_ENV_BASE).
* runMsdTools builds it (process env + TEST_ENV_BASE).
*/
function spawnAppend(tmp, description) {
return new Promise((resolve) => {
@@ -1837,7 +1837,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
return handle;
}
test('two concurrent gsd-tools append processes both land their entries', async (t) => {
test('two concurrent msd-tools append processes both land their entries', async (t) => {
const tmp = createTempDir('bw-3780-race-');
t.after(() => cleanup(tmp));
@@ -1867,10 +1867,10 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
const handle = acquireHeldLock(tmp);
t.after(() => lockMod.releaseLock(handle));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '1', '--description', 'blocked writer'],
tmp,
{ GSD_JSON_ERRORS: '1' },
{ MSD_JSON_ERRORS: '1' },
);
assert.equal(res.success, false, 'append must refuse while the ledger lock is held by a live writer');
const parsed = JSON.parse(res.error);
@@ -1887,7 +1887,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
// After release the same mutation proceeds — the refusal was contention,
// not corruption.
lockMod.releaseLock(handle);
const res2 = runGsdTools(
const res2 = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '1', '--description', 'after release'],
tmp,
);
@@ -1898,7 +1898,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
test('append releases the ledger lock after success', (t) => {
const tmp = createTempDir('bw-3780-release-ok-');
t.after(() => cleanup(tmp));
const res = runGsdTools(
const res = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '1', '--description', 'solo'],
tmp,
);
@@ -1913,7 +1913,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
test('append releases the ledger lock even when the append itself fails', (t) => {
const tmp = createTempDir('bw-3780-release-fail-');
t.after(() => cleanup(tmp));
const bad = runGsdTools(
const bad = runMsdTools(
['windows', 'append', '--kind', 'no-such-kind', '--phase', '1', '--description', 'x'],
tmp,
);
@@ -1923,7 +1923,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
false,
'no lock file may survive a failed append',
);
const good = runGsdTools(
const good = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '1', '--description', 'retry'],
tmp,
);
@@ -1933,7 +1933,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
test('waive refuses typed while the ledger lock is held and proceeds after release', (t) => {
const tmp = createTempDir('bw-3780-held-waive-');
t.after(() => cleanup(tmp));
const seed = runGsdTools(
const seed = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '1', '--description', 'entry'],
tmp,
);
@@ -1941,20 +1941,20 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
const handle = acquireHeldLock(tmp);
t.after(() => lockMod.releaseLock(handle));
const res = runGsdTools(['windows', 'waive', '1', 'waiver reason'], tmp, { GSD_JSON_ERRORS: '1' });
const res = runMsdTools(['windows', 'waive', '1', 'waiver reason'], tmp, { MSD_JSON_ERRORS: '1' });
assert.equal(res.success, false, 'waive must refuse while the ledger lock is held');
const parsed = JSON.parse(res.error);
assert.equal(parsed.reason, 'windows_ledger_lock', `expected typed lock reason, got: ${res.error}`);
lockMod.releaseLock(handle);
const res2 = runGsdTools(['windows', 'waive', '1', 'waiver reason'], tmp);
const res2 = runMsdTools(['windows', 'waive', '1', 'waiver reason'], tmp);
assert.equal(res2.success, true, `post-release waive must succeed: ${res2.error || ''}`);
});
test('fixed refuses typed while the ledger lock is held', (t) => {
const tmp = createTempDir('bw-3780-held-fixed-');
t.after(() => cleanup(tmp));
const seed = runGsdTools(
const seed = runMsdTools(
['windows', 'append', '--kind', 'todo', '--phase', '1', '--description', 'entry'],
tmp,
);
@@ -1962,7 +1962,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
const handle = acquireHeldLock(tmp);
t.after(() => lockMod.releaseLock(handle));
const res = runGsdTools(['windows', 'fixed', '1'], tmp, { GSD_JSON_ERRORS: '1' });
const res = runMsdTools(['windows', 'fixed', '1'], tmp, { MSD_JSON_ERRORS: '1' });
assert.equal(res.success, false, 'fixed must refuse while the ledger lock is held');
const parsed = JSON.parse(res.error);
assert.equal(parsed.reason, 'windows_ledger_lock', `expected typed lock reason, got: ${res.error}`);
@@ -1973,7 +1973,7 @@ describe('#3780: parallel writers serialize on the ledger lock', () => {
t.after(() => cleanup(tmp));
const handle = acquireHeldLock(tmp);
t.after(() => lockMod.releaseLock(handle));
const res = runGsdTools(['windows', 'status', '--raw'], tmp);
const res = runMsdTools(['windows', 'status', '--raw'], tmp);
assert.equal(res.success, true, `status must not take the writer lock: ${res.error || ''}`);
assert.equal(JSON.parse(res.output).ledger.open_count, 0);
});