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 @@
/**
* GSD Tools Tests - reapply-patches post-merge verification
* MSD Tools Tests - reapply-patches post-merge verification
*
* Validates that the reapply-patches workflow includes post-merge
* verification to detect dropped hunks during three-way merge.
@@ -8,11 +8,11 @@
*
* #2790: reapply-patches.md (combined command+workflow) was consolidated into
* update.md as the --reapply flag. The workflow content now lives in
* gsd-core/workflows/reapply-patches.md.
* msd-core/workflows/reapply-patches.md.
*/
// allow-test-rule: source-text-is-the-product
// gsd-core/workflows/reapply-patches.md is the installed runtime workflow —
// msd-core/workflows/reapply-patches.md is the installed runtime workflow —
// its text IS the deployed behavioral contract for the --reapply path.
const { describe, test, before } = require('node:test');
@@ -26,7 +26,7 @@ const path = require('path');
const VERIFIER_TIMEOUT_MS = 30_000;
const WORKFLOW_PATH = path.join(
__dirname, '..', 'gsd-core', 'workflows', 'reapply-patches.md'
__dirname, '..', 'msd-core', 'workflows', 'reapply-patches.md'
);
function extractTagBlock(markdown, tagName) {
@@ -121,10 +121,10 @@ describe('reapply-patches post-merge verification (#1758)', () => {
__foldDescribe("folded:bug-2969-verify-reapply-patches (consolidation epic #1969 B5 #1974)", () => {
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
/**
* Bug #2969: /gsd-reapply-patches Step 5 hunk verification gate reports
* Bug #2969: /msd-reapply-patches Step 5 hunk verification gate reports
* success on lost content because the LLM-driven workflow fills in
* "verified: yes" without actually checking content presence.
*
@@ -151,10 +151,10 @@ const { cleanup } = require('./helpers.cjs');
const { runNode } = require('./helpers/process-seam.cjs');
const ROOT = path.join(__dirname, '..');
// Script lives at gsd-core/bin/ so the installer ships it under
// `${GSD_HOME}/gsd-core/bin/` (issue #2994). The top-level scripts/
// Script lives at msd-core/bin/ so the installer ships it under
// `${MSD_HOME}/msd-core/bin/` (issue #2994). The top-level scripts/
// directory is not copied to user installs.
const SCRIPT = path.join(ROOT, 'gsd-core', 'bin', 'verify-reapply-patches.cjs');
const SCRIPT = path.join(ROOT, 'msd-core', 'bin', 'verify-reapply-patches.cjs');
const { REASON } = require(SCRIPT);
let tmpRoot;
@@ -193,7 +193,7 @@ function runVerifier({ includePristine = true } = {}) {
}
before(() => {
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2969-'));
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2969-'));
patchesDir = path.join(tmpRoot, 'patches');
configDir = path.join(tmpRoot, 'installed');
pristineDir = path.join(tmpRoot, 'pristine');
@@ -340,21 +340,21 @@ describe('Bug #2969: deterministic Step 5 verification gate', () => {
assert.ok(!report.results[0].missing.includes(presentLine));
});
test('treats gsd-hook-version install-time substitution as upstream-owned, not missing user content (#229)', () => {
test('treats msd-hook-version install-time substitution as upstream-owned, not missing user content (#229)', () => {
resetFixture();
const rel = path.join('hooks', 'gsd-statusline.js');
const rel = path.join('hooks', 'msd-statusline.js');
const pristine = [
'// gsd-hook-version: {{GSD_VERSION}}',
'// msd-hook-version: {{MSD_VERSION}}',
'console.log("statusline hook");',
'',
].join('\n');
const backup = [
'// gsd-hook-version: 1.41.0',
'// msd-hook-version: 1.41.0',
'console.log("statusline hook");',
'',
].join('\n');
const installed = [
'// gsd-hook-version: 1.42.3',
'// msd-hook-version: 1.42.3',
'console.log("statusline hook");',
'',
].join('\n');
@@ -386,15 +386,15 @@ describe('Bug #2969: deterministic Step 5 verification gate', () => {
// product (workflow instructions consumed by AI agents), not a source .cjs file.
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
/**
* Bug #3657: verify-reapply-patches false-fails when gsd-pristine/ snapshot is
* Bug #3657: verify-reapply-patches false-fails when msd-pristine/ snapshot is
* newer than backup-meta baseline.
*
* Root cause: the verifier computes user-added lines as
* diff(backup, pristine_on_disk)
* but pristine_on_disk is from a LATER GSD version than the one captured in
* but pristine_on_disk is from a LATER MSD version than the one captured in
* backup-meta.json.pristine_hashes. Lines present in the backup but removed by
* the upstream update appear as "user-added lines that must survive", causing
* FAIL_USER_LINES_MISSING false positives even when the user's real
@@ -422,7 +422,7 @@ const { cleanup } = require('./helpers.cjs');
const { runNode } = require('./helpers/process-seam.cjs');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'gsd-core', 'bin', 'verify-reapply-patches.cjs');
const SCRIPT = path.join(ROOT, 'msd-core', 'bin', 'verify-reapply-patches.cjs');
const { REASON } = require(SCRIPT);
// ---------------------------------------------------------------------------
@@ -474,7 +474,7 @@ function runVerifier({ pristine = true } = {}) {
}
before(() => {
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-3657-'));
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-3657-'));
patchesDir = path.join(tmpRoot, 'patches');
configDir = path.join(tmpRoot, 'installed');
pristineDir = path.join(tmpRoot, 'pristine');
@@ -503,7 +503,7 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
test('exits 0 with reason=OK_PRISTINE_DRIFT_DETECTED when on-disk pristine hash does not match recorded hash', () => {
resetFixture();
const FILE = 'agents/gsd-executor.md';
const FILE = 'agents/msd-executor.md';
// v_old pristine: the file as it existed when the backup was made.
const oldPristineContent =
@@ -515,7 +515,7 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
oldPristineContent +
'model: sonnet in frontmatter — the user customisation to preserve\n';
// The installer later refreshed gsd-pristine/ to v_new.
// The installer later refreshed msd-pristine/ to v_new.
// The upstream update removed the second stock line entirely.
const newPristineContent =
'line present in old pristine and also in backup\n' +
@@ -557,7 +557,7 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
test('still catches FAIL_USER_LINES_MISSING when pristine matches recorded hash', () => {
resetFixture();
const FILE = 'agents/gsd-executor.md';
const FILE = 'agents/msd-executor.md';
const pristineContent =
'stock line one that is long enough to be significant\n' +
@@ -649,7 +649,7 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
test('handles mixed drift + real-failure across multiple files independently', () => {
resetFixture();
const DRIFT_FILE = 'agents/gsd-executor.md';
const DRIFT_FILE = 'agents/msd-executor.md';
const CLEAN_FILE = 'workflows/update.md';
const driftOldPristine = 'old upstream line that was removed in newer pristine version\n';
@@ -740,7 +740,7 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
test('Finding 1: JSON report includes top-level drifted count and drifted_files when drift is detected', () => {
resetFixture();
const FILE = 'agents/gsd-executor.md';
const FILE = 'agents/msd-executor.md';
const oldPristineContent = 'old pristine line that was present when backup was captured\n';
const newPristineContent = 'new upstream line in the refreshed pristine snapshot version\n';
const userLine = 'user customisation line that should be preserved across updates';
@@ -785,14 +785,14 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
test('Finding 1: drifted count and drifted_files aggregate correctly across multiple drifted files', () => {
resetFixture();
const FILE_A = 'agents/gsd-executor.md';
const FILE_A = 'agents/msd-executor.md';
const FILE_B = 'workflows/update.md';
const FILE_C = 'skills/custom/SKILL.md';
const oldPristineA = 'old pristine content for file A that was captured at backup time\n';
const newPristineA = 'refreshed upstream content for file A in the newer GSD snapshot\n';
const newPristineA = 'refreshed upstream content for file A in the newer MSD snapshot\n';
const oldPristineB = 'old pristine content for file B that was captured at backup time\n';
const newPristineB = 'refreshed upstream content for file B in the newer GSD snapshot\n';
const newPristineB = 'refreshed upstream content for file B in the newer MSD snapshot\n';
const pristineC = 'stable pristine for file C — this one did not drift between versions\n';
const userLineC = 'user customisation for file C that survived the merge successfully';
@@ -874,7 +874,7 @@ describe('Bug #3657: pristine-drift does not produce false FAIL_USER_LINES_MISSI
* fields that Finding 1 added to the JSON report.
*/
test('Finding 2: workflow Step 5a source contains drift-check section for DRIFTED_COUNT gate', () => {
const workflowPath = path.join(ROOT, 'gsd-core', 'workflows', 'reapply-patches.md');
const workflowPath = path.join(ROOT, 'msd-core', 'workflows', 'reapply-patches.md');
const workflowSource = fs.readFileSync(workflowPath, 'utf8');
// The drift-check block must be present in Step 5a.
@@ -920,7 +920,7 @@ describe('Bug #934: OK_NO_BASELINE when recordedHash present but pristine file a
/**
* Core regression: backup-meta.json has a pristine_hash for the file but
* the gsd-pristine/ snapshot is absent from disk (the installer's
* the msd-pristine/ snapshot is absent from disk (the installer's
* saveLocalPatches discarded the only candidate because its hash did not
* match the old-release hash — the file changed upstream between releases).
* Without the fix the verifier falls to over-broad mode and treats every
@@ -931,20 +931,20 @@ describe('Bug #934: OK_NO_BASELINE when recordedHash present but pristine file a
test('exits 0 with reason=OK_NO_BASELINE when recordedHash present but pristine absent', () => {
resetFixture();
const FILE = 'gsd-core/workflows/execute-phase.md';
const FILE = 'msd-core/workflows/execute-phase.md';
// The backup contains both the old upstream content and the user's line.
const backupContent =
'upstream line that was present in 1.4.0 but removed in 1.4.2 release\n' +
'another upstream line removed upstream between gsd-core releases here\n' +
'another upstream line removed upstream between msd-core releases here\n' +
'model: sonnet in frontmatter — this is the real user customisation line\n';
// The installed file has the new upstream content + the user's real line.
const installedContent =
'brand-new upstream line that replaced the old content in gsd-core 1.4.2\n' +
'brand-new upstream line that replaced the old content in msd-core 1.4.2\n' +
'model: sonnet in frontmatter — this is the real user customisation line\n';
// backup-meta.json records a hash (modern installer) but gsd-pristine/ is absent.
// backup-meta.json records a hash (modern installer) but msd-pristine/ is absent.
writeBackupMeta({ pristine_hashes: { [FILE]: 'sha256:deadbeef00000000000000000000000000000000000000000000000000000001' } });
writeFile(path.join(patchesDir, FILE), backupContent);
writeFile(path.join(configDir, FILE), installedContent);
@@ -971,7 +971,7 @@ describe('Bug #934: OK_NO_BASELINE when recordedHash present but pristine file a
test('falls through to over-broad mode when pristine absent AND no recordedHash', () => {
resetFixture();
const FILE = 'gsd-core/workflows/plan-phase.md';
const FILE = 'msd-core/workflows/plan-phase.md';
const droppedLine = 'user-added instruction that was dropped from the install output';
const backupContent =
'stock upstream line long enough to be significant in the file\n' +
@@ -1005,7 +1005,7 @@ describe('Bug #934: OK_NO_BASELINE when recordedHash present but pristine file a
test('does not short-circuit to OK_NO_BASELINE when pristine exists and hash matches', () => {
resetFixture();
const FILE = 'gsd-core/workflows/plan-phase.md';
const FILE = 'msd-core/workflows/plan-phase.md';
const pristineContent = 'stock upstream line long enough to be significant content\n';
const droppedLine = 'user customisation that was genuinely dropped from the merged output';
const backupContent = pristineContent + droppedLine + '\n';
@@ -1035,7 +1035,7 @@ describe('Bug #934: OK_NO_BASELINE when recordedHash present but pristine file a
test('does not return OK_NO_BASELINE when --pristine-dir is not provided', () => {
resetFixture();
const FILE = 'gsd-core/workflows/execute-phase.md';
const FILE = 'msd-core/workflows/execute-phase.md';
const backupContent =
'upstream line removed in newer version but present in backup\n' +
'model: sonnet — user customisation line in the backup file\n';
@@ -1089,7 +1089,7 @@ const { cleanup, scrubConfigLocationEnv } = require('./helpers.cjs');
const { runNode } = require('./helpers/process-seam.cjs');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'gsd-core', 'bin', 'verify-reapply-patches.cjs');
const SCRIPT = path.join(ROOT, 'msd-core', 'bin', 'verify-reapply-patches.cjs');
const { REASON } = require(SCRIPT);
let tmpRoot;
@@ -1124,7 +1124,7 @@ function runVerifier() {
}
beforeEach(() => {
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4086-vfy-'));
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4086-vfy-'));
patchesDir = path.join(tmpRoot, 'patches');
configDir = path.join(tmpRoot, 'home', '.codex');
fs.mkdirSync(patchesDir, { recursive: true });
@@ -1149,11 +1149,11 @@ afterEach(() => {
describe('Bug #4086: verifyFile resolves skills entries at the runtime skills root', () => {
test('verifyFile resolves skills entries at the runtime\'s skills root (#4086)', () => {
const key = 'skills/gsd-x/SKILL.md';
const key = 'skills/msd-x/SKILL.md';
writeFile(path.join(patchesDir, key), 'stock body line for the patch backup\nuser-added line that must survive merges\n');
writeFile(path.join(tmpRoot, 'home', '.agents', key), 'stock body line for the patch backup\nuser-added line that must survive merges\n');
// Manifest tells the verifier which runtime/scope owns this configDir.
writeFile(path.join(configDir, 'gsd-file-manifest.json'), JSON.stringify({
writeFile(path.join(configDir, 'msd-file-manifest.json'), JSON.stringify({
version: '1.12.0', runtime: 'codex', scope: 'global', files: {},
}));
@@ -1166,9 +1166,9 @@ describe('Bug #4086: verifyFile resolves skills entries at the runtime skills ro
});
test('verifyFile still fails when the skill file is genuinely missing (#4086)', () => {
const key = 'skills/gsd-gone/SKILL.md';
const key = 'skills/msd-gone/SKILL.md';
writeFile(path.join(patchesDir, key), 'stock body line for the patch backup\nuser-added line that must survive merges\n');
writeFile(path.join(configDir, 'gsd-file-manifest.json'), JSON.stringify({
writeFile(path.join(configDir, 'msd-file-manifest.json'), JSON.stringify({
version: '1.12.0', runtime: 'codex', scope: 'global', files: {},
}));
@@ -1186,11 +1186,11 @@ describe('Bug #4086: verifyFile resolves skills entries at the runtime skills ro
// ────────────────────────────────────────────────────────────────────────
// Folded regression block — #4145 (a hash-matching gsd-pristine/ baseline
// stored without the gsd-core/ prefix is never resolved). verifyFile() joined
// Folded regression block — #4145 (a hash-matching msd-pristine/ baseline
// stored without the msd-core/ prefix is never resolved). verifyFile() joined
// the manifest-keyed path strictly; when stat missed and a hash was recorded
// it reported OK_NO_BASELINE even though byte-correct content sat elsewhere
// under gsd-pristine/. The fix consults the recorded pristine_hashes — the
// under msd-pristine/. The fix consults the recorded pristine_hashes — the
// same authority the #3657 drift guard trusts — and adopts an exact-hash
// match found anywhere in the tree.
// ────────────────────────────────────────────────────────────────────────
@@ -1199,7 +1199,7 @@ describe('Bug #4086: verifyFile resolves skills entries at the runtime skills ro
__foldDescribe('folded:bug-4145-pristine-prefix-resolution', () => {
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
const { test, describe, before, after } = require('node:test');
const assert = require('node:assert/strict');
@@ -1211,10 +1211,10 @@ const { cleanup } = require('./helpers.cjs');
const { runNode } = require('./helpers/process-seam.cjs');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'gsd-core', 'bin', 'verify-reapply-patches.cjs');
const SCRIPT = path.join(ROOT, 'msd-core', 'bin', 'verify-reapply-patches.cjs');
const { REASON } = require(SCRIPT);
const { findPristineByHash } = require(
path.join(ROOT, 'gsd-core', 'bin', 'lib', 'pristine-baseline.cjs'),
path.join(ROOT, 'msd-core', 'bin', 'lib', 'pristine-baseline.cjs'),
);
let tmpRoot;
@@ -1267,7 +1267,7 @@ function runVerifier() {
}
before(() => {
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4145-'));
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4145-'));
patchesDir = path.join(tmpRoot, 'patches');
configDir = path.join(tmpRoot, 'installed');
pristineDir = path.join(tmpRoot, 'pristine');
@@ -1280,7 +1280,7 @@ after(() => {
describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', () => {
/**
* Core regression. The manifest key is `gsd-core/bin/lib/frontmatter.cjs`
* Core regression. The manifest key is `msd-core/bin/lib/frontmatter.cjs`
* but the snapshot sits at `bin/lib/frontmatter.cjs` — one segment away
* from the joined path. Its SHA-256 equals the recorded pristine_hashes
* entry. The upstream release replaced the file wholesale and only the
@@ -1290,7 +1290,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
*/
test('#4145: resolves a hash-matching prefix-less pristine baseline instead of reporting ok_no_baseline', () => {
resetFixture();
const FILE = 'gsd-core/bin/lib/frontmatter.cjs';
const FILE = 'msd-core/bin/lib/frontmatter.cjs';
const OLD_PRISTINE =
'outgoing pristine stock line one with substantial content\n' +
'outgoing pristine stock line two also substantial content\n';
@@ -1302,7 +1302,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
writeBackupMeta({ [FILE]: sha256(OLD_PRISTINE) });
writeFile(path.join(patchesDir, FILE), backupContent);
writeFile(path.join(configDir, FILE), installedContent);
// The orphan: same bytes, stored WITHOUT the gsd-core/ prefix.
// The orphan: same bytes, stored WITHOUT the msd-core/ prefix.
writeFile(path.join(pristineDir, 'bin', 'lib', 'frontmatter.cjs'), OLD_PRISTINE);
const { status, report } = runVerifier();
@@ -1316,10 +1316,10 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
assert.notEqual(r0.reason, REASON.OK_NO_BASELINE);
});
/** Negative space: nothing anywhere under gsd-pristine/ matches the record. */
test('#4145: still reports ok_no_baseline when the recorded hash matches nothing under gsd-pristine', () => {
/** Negative space: nothing anywhere under msd-pristine/ matches the record. */
test('#4145: still reports ok_no_baseline when the recorded hash matches nothing under msd-pristine', () => {
resetFixture();
const FILE = 'gsd-core/bin/lib/frontmatter.cjs';
const FILE = 'msd-core/bin/lib/frontmatter.cjs';
const backupContent =
'upstream line present in the backup of the outgoing release\n' +
'model: sonnet — the user customisation line in the backup file\n';
@@ -1345,7 +1345,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
*/
test('#4145: never adopts a hash-mismatching orphan — only exact recorded-hash matches', () => {
resetFixture();
const FILE = 'gsd-core/bin/lib/frontmatter.cjs';
const FILE = 'msd-core/bin/lib/frontmatter.cjs';
const OLD_PRISTINE = 'outgoing pristine bytes that the record hashes\n';
const OTHER_CONTENT = 'some other release snapshot with different bytes\n';
@@ -1369,7 +1369,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
*/
test('#4145: prefixed canonical baseline resolves exactly as today when an identical orphan also exists', () => {
resetFixture();
const FILE = 'gsd-core/workflows/execute-phase.md';
const FILE = 'msd-core/workflows/execute-phase.md';
const pristineContent = 'stock workflow line long enough to pass the significance threshold\n';
const droppedLine = 'user workflow customisation that was lost in the merge operation';
const backupContent = pristineContent + droppedLine + '\n';
@@ -1390,7 +1390,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
assert.equal(r0.reason, REASON.FAIL_USER_LINES_MISSING);
assert.ok(r0.missing.includes(droppedLine));
// Read-only verifier: the orphan is never relocated or pruned by a verify run.
assert.equal(fs.existsSync(orphanPath), true, 'verifier must not mutate gsd-pristine/');
assert.equal(fs.existsSync(orphanPath), true, 'verifier must not mutate msd-pristine/');
});
/**
@@ -1400,7 +1400,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
*/
test('#4145: canonical-path drift still reports ok_pristine_drift_detected even when a hash-matching orphan exists', () => {
resetFixture();
const FILE = 'gsd-core/agents/gsd-executor.md';
const FILE = 'msd-core/agents/msd-executor.md';
const oldPristine = 'old pristine line that was present when backup was captured\n';
const newPristine = 'refreshed upstream line in the newer pristine snapshot\n';
const userLine = 'user customisation line that should be preserved across updates';
@@ -1410,7 +1410,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
writeFile(path.join(configDir, FILE), newPristine + userLine + '\n');
writeFile(path.join(pristineDir, FILE), newPristine); // canonical drifted
// A hash-matching orphan exists elsewhere — drift must still win.
writeFile(path.join(pristineDir, 'agents', 'gsd-executor.md'), oldPristine);
writeFile(path.join(pristineDir, 'agents', 'msd-executor.md'), oldPristine);
const { status, report } = runVerifier();
@@ -1423,9 +1423,9 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
/** Module unit: deterministic sorted-first match, symlink skip, absent dir. */
test('#4145: findPristineByHash returns the sorted-first match, skips symlinks, and null on an absent dir', () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4145-unit-'));
const symRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4145-sym-'));
const outsideRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4145-out-'));
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4145-unit-'));
const symRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4145-sym-'));
const outsideRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4145-out-'));
try {
const contentA = 'identical bytes that two snapshots happen to share\n';
const hashA = sha256(contentA);
@@ -1476,7 +1476,7 @@ describe('Bug #4145: hash-matching prefix-less pristine baseline is resolved', (
__foldDescribe('folded:bug-4136-reapply-incorporated-status', () => {
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
/**
* Bug #4136: reapply-patches.md Step 4 item 6 defines three per-file statuses
@@ -1508,7 +1508,7 @@ const { cleanup } = require('./helpers.cjs');
const { runNode } = require('./helpers/process-seam.cjs');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'gsd-core', 'bin', 'verify-reapply-patches.cjs');
const SCRIPT = path.join(ROOT, 'msd-core', 'bin', 'verify-reapply-patches.cjs');
const { REASON, CLASSIFICATION } = require(SCRIPT);
let tmpRoot;
@@ -1572,7 +1572,7 @@ function runGate({ includePristine = true } = {}) {
}
before(() => {
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4136-'));
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4136-'));
patchesDir = path.join(tmpRoot, 'patches');
configDir = path.join(tmpRoot, 'installed');
pristineDir = path.join(tmpRoot, 'pristine');
@@ -1593,7 +1593,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 1 (RED regression): all user-added lines already upstream → incorporated', () => {
resetFixture();
const FILE = 'gsd-core/workflows/execute-phase.md';
const FILE = 'msd-core/workflows/execute-phase.md';
const pristineContent = [
'stock line one that is long enough to be significant',
'stock line two that is long enough to be significant',
@@ -1622,7 +1622,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 2: user line absent from fresh install → needs_merge; gate still catches drops', () => {
resetFixture();
const FILE = 'gsd-core/workflows/plan-phase.md';
const FILE = 'msd-core/workflows/plan-phase.md';
const pristineContent = 'stock baseline line long enough to be significant here\n';
const userLine = 'user custom instruction that upstream did NOT adopt yet';
const backupContent = pristineContent + userLine + '\n';
@@ -1653,7 +1653,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 3 (boundary): partially-superseded is needs_merge, not Incorporated', () => {
resetFixture();
const FILE = 'gsd-core/workflows/ship.md';
const FILE = 'msd-core/workflows/ship.md';
const pristineContent = 'stock line that is long enough to be significant\n';
const adoptedLine = 'user line number one that upstream did adopt upstream';
const unadoptedLine = 'user line number two that upstream has NOT adopted';
@@ -1675,9 +1675,9 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 4a: pristine drift (#3657 shape) → unknown, never Incorporated', () => {
resetFixture();
const FILE = 'agents/gsd-executor.md';
const FILE = 'agents/msd-executor.md';
const oldPristine = 'old pristine line present when the backup was captured\n';
const newPristine = 'refreshed upstream snapshot line in the newer GSD release\n';
const newPristine = 'refreshed upstream snapshot line in the newer MSD release\n';
const userLine = 'user customisation line that upstream adopted in the release';
const backupContent = oldPristine + userLine + '\n';
const freshInstall = newPristine + userLine + '\n';
@@ -1698,7 +1698,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 4b: recorded hash but pristine absent (#934 shape) → unknown', () => {
resetFixture();
const FILE = 'gsd-core/workflows/debug.md';
const FILE = 'msd-core/workflows/debug.md';
const pristineContent = 'stock line that is long enough to be significant x\n';
const userLine = 'user custom line upstream adopted, but baseline is missing';
const backupContent = pristineContent + userLine + '\n';
@@ -1719,7 +1719,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 4c: no --pristine-dir (two-way fallback) → unknown', () => {
resetFixture();
const FILE = 'gsd-core/workflows/scan.md';
const FILE = 'msd-core/workflows/scan.md';
const pristineContent = 'stock line that is long enough to be significant y\n';
const userLine = 'user custom line upstream adopted, but no baseline was passed';
const backupContent = pristineContent + userLine + '\n';
@@ -1739,7 +1739,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 4d: on-disk pristine but no recorded hash → unknown (unvalidated baseline)', () => {
resetFixture();
const FILE = 'gsd-core/workflows/undo.md';
const FILE = 'msd-core/workflows/undo.md';
const pristineContent = 'stock line that is long enough to be significant z\n';
const userLine = 'user custom line upstream adopted, but hash was never recorded';
const backupContent = pristineContent + userLine + '\n';
@@ -1761,13 +1761,13 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 4d-2: a #4145-recovered (hash-matched orphan) baseline can confirm adoption', () => {
resetFixture();
const FILE = 'gsd-core/workflows/import.md';
const FILE = 'msd-core/workflows/import.md';
const pristineContent = 'stock line that is long enough to be significant s\n';
const userLine = 'user custom line upstream adopted, baseline stored unprefixed';
const backupContent = pristineContent + userLine + '\n';
const freshInstall = pristineContent + userLine + '\n';
// The pristine snapshot sits WITHOUT the gsd-core/ prefix (an earlier
// The pristine snapshot sits WITHOUT the msd-core/ prefix (an earlier
// release's writer dropped it) — only the #4145 hash scan can find it.
writeBackupMeta({ [FILE]: sha256(pristineContent) });
writeFile(path.join(patchesDir, FILE), backupContent);
@@ -1787,7 +1787,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 4e: signature-looking short/fence lines do not drive the classification', () => {
resetFixture();
const FILE = 'gsd-core/workflows/health.md';
const FILE = 'msd-core/workflows/health.md';
const pristineContent = 'stock line that is long enough to be significant w\n';
// The user hunk: a short heading (under the 12-char significance floor),
// a code fence, and ONE significant line.
@@ -1816,7 +1816,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 5: backup with zero significant delta vs validated pristine → unknown, never a skip', () => {
resetFixture();
const FILE = 'gsd-core/workflows/note.md';
const FILE = 'msd-core/workflows/note.md';
const pristineContent = 'stock line that is long enough to be significant v\n';
const backupContent = pristineContent; // degenerate: backed up but identical
@@ -1835,7 +1835,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 6: structural failures classify unknown; classify still exits 0', () => {
resetFixture();
const FILE = 'gsd-core/workflows/stats.md';
const FILE = 'msd-core/workflows/stats.md';
const pristineContent = 'stock line that is long enough to be significant u\n';
const userLine = 'user custom line that upstream adopted in this release';
const backupContent = pristineContent + userLine + '\n';
@@ -1854,7 +1854,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 7: classify --json report shape is { checked, incorporated, incorporated_files, results }', () => {
resetFixture();
const FILE = 'gsd-core/workflows/help.md';
const FILE = 'msd-core/workflows/help.md';
const pristineContent = 'stock line that is long enough to be significant t\n';
const userLine = 'user custom line that upstream adopted in this release';
const backupContent = pristineContent + userLine + '\n';
@@ -1876,7 +1876,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
test('Row 8: Incorporated ends the re-graft cycle — the file drops out of the next backup', () => {
resetFixture();
const FILE = 'gsd-core/workflows/inbox.md';
const FILE = 'msd-core/workflows/inbox.md';
const pristineV1 = 'stock v1 line that is long enough to be significant\n';
const userLine = 'user custom loop guard that upstream adopted in v2';
const backupContent = pristineV1 + userLine + '\n';
@@ -1890,7 +1890,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
// The update wipes and installs v2; manifest now hashes v2's shipped bytes.
writeFile(path.join(configDir, FILE), freshV2);
const manifestV2 = { version: '2.0.0', files: { [FILE]: sha256(freshV2) } };
writeFile(path.join(configDir, 'gsd-file-manifest.json'), JSON.stringify(manifestV2, null, 2));
writeFile(path.join(configDir, 'msd-file-manifest.json'), JSON.stringify(manifestV2, null, 2));
// Pre-flight classification: incorporated → the workflow leaves the file untouched.
const cls = runClassifier();
@@ -1924,7 +1924,7 @@ describe('Bug #4136: deterministic Incorporated classification (--classify)', ()
});
describe('Bug #4136: workflow consumes the classifier (contract rows)', () => {
const WORKFLOW = path.join(ROOT, 'gsd-core', 'workflows', 'reapply-patches.md');
const WORKFLOW = path.join(ROOT, 'msd-core', 'workflows', 'reapply-patches.md');
test('Step 4 runs the classifier before merging and gates it on PRISTINE_DIR', () => {
// allow-test-rule: source-text-is-the-product (#4136)
@@ -1942,7 +1942,7 @@ describe('Bug #4136: workflow consumes the classifier (contract rows)', () => {
);
// Both invocations must be the runtime-installed path (locked separately
// by the #2994 fold); here we lock that the classify block is bounded by
// the same GSD_HOME-anchored script reference as the Step 5a gate.
// the same MSD_HOME-anchored script reference as the Step 5a gate.
const gateIdx = md.indexOf('verify-reapply-patches.cjs', classifyIdx);
assert.ok(gateIdx > classifyIdx, 'the Step 5a gate invocation must still follow the classify block');
});
@@ -2002,7 +2002,7 @@ describe('Bug #4136: workflow consumes the classifier (contract rows)', () => {
// ────────────────────────────────────────────────────────────────────────
// Folded regression block — #4135 (gsd-pristine/ regeneration yields
// Folded regression block — #4135 (msd-pristine/ regeneration yields
// near-zero coverage on a multi-version update). The #3407 promotion rule
// only keeps regeneration candidates byte-identical across the WHOLE
// version span, so the surviving baseline set is precisely the files
@@ -2017,7 +2017,7 @@ describe('Bug #4136: workflow consumes the classifier (contract rows)', () => {
__foldDescribe('folded:bug-4135-pristine-regen-coverage', () => {
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
const { test, describe, before, after } = require('node:test');
const assert = require('node:assert/strict');
@@ -2030,12 +2030,12 @@ const { runNode } = require('./helpers/process-seam.cjs');
const { gitOrThrow } = require('./helpers/git-fixture.cjs');
const ROOT = path.join(__dirname, '..');
const SCRIPT = path.join(ROOT, 'gsd-core', 'bin', 'verify-reapply-patches.cjs');
const SCRIPT = path.join(ROOT, 'msd-core', 'bin', 'verify-reapply-patches.cjs');
const { REASON } = require(SCRIPT);
const { findPristineInGit } = require(
path.join(ROOT, 'gsd-core', 'bin', 'lib', 'pristine-baseline.cjs'),
path.join(ROOT, 'msd-core', 'bin', 'lib', 'pristine-baseline.cjs'),
);
const WORKFLOW_PATH = path.join(ROOT, 'gsd-core', 'workflows', 'reapply-patches.md');
const WORKFLOW_PATH = path.join(ROOT, 'msd-core', 'workflows', 'reapply-patches.md');
// 30000ms: same class as the folded blocks above — one deterministic
// verifier pass (plus, for the git tier rows, the in-process git log/show
@@ -2095,7 +2095,7 @@ function gitCommitAll(dir, message) {
}
before(() => {
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4135-'));
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4135-'));
patchesDir = path.join(tmpRoot, 'patches');
configDir = path.join(tmpRoot, 'installed');
pristineDir = path.join(tmpRoot, 'pristine');
@@ -2110,7 +2110,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/**
* Core regression (headline): the issue's exact scenario — 13 backed-up
* customised files on a multi-version update, 12 changed upstream, 1
* byte-identical. gsd-pristine/ holds only the byte-identical survivor.
* byte-identical. msd-pristine/ holds only the byte-identical survivor.
* The green exit must CARRY a countable coverage aggregate instead of
* presenting like a fully-verified run.
*/
@@ -2118,7 +2118,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
resetFixture();
const pristineHashes = {};
for (let i = 1; i <= 13; i++) {
const rel = `gsd-core/workflows/flow-${String(i).padStart(2, '0')}.md`;
const rel = `msd-core/workflows/flow-${String(i).padStart(2, '0')}.md`;
const pristine =
`# Flow ${i}\nStock content of the outgoing release for file ${i}.\n` +
`Line two of outgoing stock content ${i} with plenty of substance.\n`;
@@ -2170,7 +2170,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
resetFixture();
const pristineHashes = {};
for (let i = 1; i <= 13; i++) {
const rel = `gsd-core/workflows/flow-${String(i).padStart(2, '0')}.md`;
const rel = `msd-core/workflows/flow-${String(i).padStart(2, '0')}.md`;
const pristine = `# Flow ${i}\nOutgoing stock line with substantial content ${i}.\n`;
const userLine = `User customisation line that survived the merge for file ${i}.\n`;
const upstream = `# Flow ${i} new\nIncoming release rewrote this file upstream ${i}.\n`;
@@ -2191,7 +2191,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Precedence: a real content failure outranks the coverage failure. */
test('#4135: strict gate yields to exit 1 when real content failed', () => {
resetFixture();
const rel = 'gsd-core/workflows/one.md';
const rel = 'msd-core/workflows/one.md';
const pristine = 'outgoing stock line with substantial content here\n';
const userLine = 'user customisation line that was dropped by the merge\n';
writeBackupMeta({ [rel]: sha256(pristine) });
@@ -2248,14 +2248,14 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/**
* Core regression (widening): multi-version collapse — no baseline under
* gsd-pristine/, but the config dir is a git repository whose history
* msd-pristine/, but the config dir is a git repository whose history
* holds the outgoing bytes (recorded pristine_hashes match). The
* recovered baseline must produce a REAL diff: the dropped user line is
* caught as fail_user_lines_missing, not skipped as ok_no_baseline.
*/
test('#4135: resolves the baseline from git history by recorded hash and catches a dropped user line', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-01.md';
const rel = 'msd-core/workflows/flow-01.md';
const pristine =
'# Flow 1\nOutgoing release stock line one with substance.\n' +
'Outgoing release stock line two also with substance.\n';
@@ -2269,7 +2269,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
// Config dir IS a git repo: outgoing pristine state, then the merged state.
gitIn(configDir, ['init', '-q', '-b', 'main']);
writeFile(path.join(configDir, rel), pristine);
gitCommitAll(configDir, 'gsd install of the outgoing release');
gitCommitAll(configDir, 'msd install of the outgoing release');
writeFile(path.join(configDir, rel), upstreamRewrite); // user line dropped
gitCommitAll(configDir, 'post-update merged state');
@@ -2291,7 +2291,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
*/
test('#4135: git-recovered baseline verifies surviving user lines instead of skipping', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-02.md';
const rel = 'msd-core/workflows/flow-02.md';
const pristine = '# Flow 2\nOutgoing stock line with substantial content.\n';
const userLine = 'user customisation line that survived the merge for flow two';
const upstreamRewrite = '# Flow 2 (rewritten)\nIncoming release rewrote the stock body.\n';
@@ -2300,7 +2300,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
writeFile(path.join(patchesDir, rel), pristine + userLine + '\n');
gitIn(configDir, ['init', '-q', '-b', 'main']);
writeFile(path.join(configDir, rel), pristine);
gitCommitAll(configDir, 'gsd install of the outgoing release');
gitCommitAll(configDir, 'msd install of the outgoing release');
writeFile(path.join(configDir, rel), upstreamRewrite + userLine + '\n');
gitCommitAll(configDir, 'post-update merged state');
@@ -2321,7 +2321,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
*/
test('#4135: single-version hop also recovers the baseline from git history', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-03.md';
const rel = 'msd-core/workflows/flow-03.md';
const vA = '# Flow 3\nVersion A stock line with substantial content.\n';
const vB = '# Flow 3\nVersion B stock line with substantial content.\n';
const userLine = 'user customisation line present in the merged output';
@@ -2329,9 +2329,9 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
writeFile(path.join(patchesDir, rel), vA + userLine + '\n');
gitIn(configDir, ['init', '-q', '-b', 'main']);
writeFile(path.join(configDir, rel), vA);
gitCommitAll(configDir, 'gsd install vA');
gitCommitAll(configDir, 'msd install vA');
writeFile(path.join(configDir, rel), vB);
gitCommitAll(configDir, 'gsd update to vB');
gitCommitAll(configDir, 'msd update to vB');
writeFile(path.join(configDir, rel), vB + userLine + '\n');
gitCommitAll(configDir, 'post-update merged state');
@@ -2345,7 +2345,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Negative space: no git, no pristine — the #934 advisory posture is unchanged. */
test('#4135: non-git config dirs keep the ok_no_baseline advisory posture', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-04.md';
const rel = 'msd-core/workflows/flow-04.md';
const pristine = '# Flow 4\nOutgoing stock line with substantial content.\n';
writeBackupMeta({ [rel]: sha256(pristine) });
writeFile(path.join(patchesDir, rel), pristine + 'user line that survived the merge here\n');
@@ -2362,7 +2362,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Negative space: git present but no blob matches the recorded hash. */
test('#4135: git tier adopts nothing when no blob matches the recorded hash', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-05.md';
const rel = 'msd-core/workflows/flow-05.md';
const pristine = '# Flow 5\nOutgoing stock line with substantial content.\n';
writeBackupMeta({ [rel]: sha256(pristine) });
writeFile(path.join(patchesDir, rel), pristine + 'user line that survived the merge here\n');
@@ -2380,7 +2380,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Drift-path lock: #3657 is never bypassed by the git tier. */
test('#4135: canonical drift is never rescued by the git-history tier', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-06.md';
const rel = 'msd-core/workflows/flow-06.md';
const pristine = '# Flow 6\nOutgoing stock line with substantial content.\n';
const drifted = '# Flow 6\nRefreshed newer-release stock line with substance.\n';
writeBackupMeta({ [rel]: sha256(pristine) });
@@ -2402,7 +2402,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Precedence lock: a matching canonical pristine beats the git tier. */
test('#4135: canonical pristine keeps precedence over the git-history tier', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-07.md';
const rel = 'msd-core/workflows/flow-07.md';
const pristine = '# Flow 7\nOutgoing stock line with substantial content.\n';
const droppedLine = 'user customisation line that the merge dropped for flow seven';
writeBackupMeta({ [rel]: sha256(pristine) });
@@ -2423,7 +2423,7 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Invocation-shape lock: no --pristine-dir → over-broad fallback, no git tier. */
test('#4135: no git-history resolution when --pristine-dir is not provided', () => {
resetFixture();
const rel = 'gsd-core/workflows/flow-08.md';
const rel = 'msd-core/workflows/flow-08.md';
const pristine = '# Flow 8\nOutgoing stock line with substantial content.\n';
const userLine = 'user customisation line that survived the merge for flow eight';
writeBackupMeta({ [rel]: sha256(pristine) });
@@ -2448,10 +2448,10 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
/** Module unit: findPristineInGit contract on a real fixture repo. */
test('#4135: findPristineInGit unit — match, no-match, non-repo', () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4135-git-unit-'));
const plain = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-4135-plain-'));
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4135-git-unit-'));
const plain = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-4135-plain-'));
try {
const rel = 'gsd-core/workflows/unit.md';
const rel = 'msd-core/workflows/unit.md';
const content = '# Unit\noutgoing pristine bytes for the git walk unit test\n';
gitIn(root, ['init', '-q', '-b', 'main']);
writeFile(path.join(root, rel), content);
@@ -2490,8 +2490,8 @@ describe('Bug #4135: baseline coverage is reported, gateable, and widened from g
*/
function seedTwoFilesOneCovered() {
const specs = [
{ rel: 'gsd-core/workflows/a.md', covered: true },
{ rel: 'gsd-core/workflows/b.md', covered: false },
{ rel: 'msd-core/workflows/a.md', covered: true },
{ rel: 'msd-core/workflows/b.md', covered: false },
];
const pristineHashes = {};
for (const { rel, covered } of specs) {