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

@@ -2,7 +2,7 @@
/**
* Example-based unit tests for src/workflow-fragments.cts (compiled to
* gsd-core/bin/lib/workflow-fragments.cjs) — issue #2930 (epic #1671 Phase 3).
* msd-core/bin/lib/workflow-fragments.cjs) — issue #2930 (epic #1671 Phase 3).
*
* Covers 50-test-matrix.md rows 1-29 and 37 (unit level). Rows 30/31
* (property) live in workflow-fragments.property.test.cjs; rows 32-36
@@ -27,9 +27,9 @@ const {
composeWorkflow,
WHEN_VOCABULARY,
REASON,
} = require('../gsd-core/bin/lib/workflow-fragments.cjs');
const { composeWithinBudget } = require('../gsd-core/bin/lib/context-composer.cjs');
const { selectSections } = require('../gsd-core/bin/lib/section-manifest.cjs');
} = require('../msd-core/bin/lib/workflow-fragments.cjs');
const { composeWithinBudget } = require('../msd-core/bin/lib/context-composer.cjs');
const { selectSections } = require('../msd-core/bin/lib/section-manifest.cjs');
const measureBytes = (text) => Buffer.byteLength(text, 'utf8');
@@ -71,10 +71,10 @@ describe('single marker pair', () => {
test('singleMarkerPairStripsMarkersAndPreservesBody', () => {
const source = doc(
'before prose',
'<!-- gsd:section id="sec-a" when="flag:--wave" -->',
'<!-- msd:section id="sec-a" when="flag:--wave" -->',
'body line 1',
'body line 2',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'after prose',
);
const sections = parseWorkflowSections(source);
@@ -99,13 +99,13 @@ describe('multiple disjoint marker pairs', () => {
test('multiplePairsPartitionDocumentExactly', () => {
const source = doc(
'gap0',
'<!-- gsd:section id="a" when="always" -->',
'<!-- msd:section id="a" when="always" -->',
'bodyA',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'gap1',
'<!-- gsd:section id="b" when="state:has-prior-phases" -->',
'<!-- msd:section id="b" when="state:has-prior-phases" -->',
'bodyB',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'gap2',
);
const sections = parseWorkflowSections(source);
@@ -120,7 +120,7 @@ describe('multiple disjoint marker pairs', () => {
],
);
const markerLineRe = /^<!--\s*\/?gsd:section.*-->\s*$/;
const markerLineRe = /^<!--\s*\/?msd:section.*-->\s*$/;
const expected = source
.split('\n')
.filter((line) => !markerLineRe.test(line))
@@ -138,7 +138,7 @@ describe('real execute-phase.md', () => {
// absorb marker overhead, so the maintainer retargeted the pilot to
// execute-phase.md (partial-wave, gap-closure-artifacts, regression-gate).
test('pilotWorkflowParsesAndRendersToSourceMinusMarkers', () => {
const pilotPath = path.join(__dirname, '..', 'gsd-core', 'workflows', 'execute-phase.md');
const pilotPath = path.join(__dirname, '..', 'msd-core', 'workflows', 'execute-phase.md');
const original = fs.readFileSync(pilotPath, 'utf8');
// execute-phase.md carries the pilot's real marker pairs today: parsing
@@ -152,7 +152,7 @@ describe('real execute-phase.md', () => {
['partial-wave', 'gap-closure-artifacts', 'regression-gate'],
);
const composedOriginal = composeWorkflow(original, { sourcePath: pilotPath });
assert.equal(composedOriginal.includes('gsd:section'), false);
assert.equal(composedOriginal.includes('msd:section'), false);
assert.ok(Buffer.byteLength(composedOriginal, 'utf8') < Buffer.byteLength(original, 'utf8'));
// Wrap an ADDITIONAL, disjoint marker pair around an arbitrary interior
@@ -167,9 +167,9 @@ describe('real execute-phase.md', () => {
const sliceEnd = 15;
const markedLines = [
...lines.slice(0, sliceStart),
'<!-- gsd:section id="pilot-slice" when="always" -->',
'<!-- msd:section id="pilot-slice" when="always" -->',
...lines.slice(sliceStart, sliceEnd),
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
...lines.slice(sliceEnd),
];
const marked = markedLines.join('\n');
@@ -191,8 +191,8 @@ describe('real execute-phase.md', () => {
// ─── #2993 (epic #1671 Phase 6.2): real plan-phase.md — C1/D1/D4/D5 ───────
describe('real plan-phase.md (#2993)', () => {
const PLAN_PHASE_PATH = path.join(__dirname, '..', 'gsd-core', 'workflows', 'plan-phase.md');
const STEPS_DIR = path.join(__dirname, '..', 'gsd-core', 'workflows', 'plan-phase', 'steps');
const PLAN_PHASE_PATH = path.join(__dirname, '..', 'msd-core', 'workflows', 'plan-phase.md');
const STEPS_DIR = path.join(__dirname, '..', 'msd-core', 'workflows', 'plan-phase', 'steps');
// The 6 sections the #2993 design survey names, in document order.
const EXPECTED_SECTIONS = Object.freeze([
@@ -217,7 +217,7 @@ describe('real plan-phase.md (#2993)', () => {
test('parsesAndRendersWithoutThrowingAndStripsEveryMarker', () => {
const source = fs.readFileSync(PLAN_PHASE_PATH, 'utf8');
const composed = composeWorkflow(source, { sourcePath: PLAN_PHASE_PATH });
assert.equal(composed.includes('gsd:section'), false);
assert.equal(composed.includes('msd:section'), false);
assert.ok(Buffer.byteLength(composed, 'utf8') < Buffer.byteLength(source, 'utf8'));
});
@@ -315,7 +315,7 @@ describe('marker lookalikes inside fences', () => {
const source = doc(
'prose before',
'```',
'<!-- gsd:section id="fake" when="always" -->',
'<!-- msd:section id="fake" when="always" -->',
'```',
'prose after',
);
@@ -328,14 +328,14 @@ describe('marker lookalikes inside fences', () => {
test('markerInsideFenceInsideSectionStaysLiteral', () => {
const source = doc(
'<!-- gsd:section id="real" when="always" -->',
'<!-- msd:section id="real" when="always" -->',
'intro',
'```',
'<!-- gsd:section id="fake" when="always" -->',
'<!-- /gsd:section -->',
'<!-- msd:section id="fake" when="always" -->',
'<!-- /msd:section -->',
'```',
'outro',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
);
const sections = parseWorkflowSections(source);
assert.equal(sections.length, 1);
@@ -343,7 +343,7 @@ describe('marker lookalikes inside fences', () => {
assert.equal(sections[0].id, 'real');
assert.equal(
sections[0].body,
['intro', '```', '<!-- gsd:section id="fake" when="always" -->', '<!-- /gsd:section -->', '```', 'outro', ''].join(
['intro', '```', '<!-- msd:section id="fake" when="always" -->', '<!-- /msd:section -->', '```', 'outro', ''].join(
'\n',
),
);
@@ -359,9 +359,9 @@ describe('fence and comment mutual precedence', () => {
'```',
'still commented',
'-->',
'<!-- gsd:section id="after-comment" when="always" -->',
'<!-- msd:section id="after-comment" when="always" -->',
'body',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
);
// If the fence delimiter on line 2 had wrongly opened a fence, the real
// marker pair below would never be recognized (it would be swallowed as
@@ -378,9 +378,9 @@ describe('fence and comment mutual precedence', () => {
'```',
'<!-- unclosed comment token inside fence',
'```',
'<!-- gsd:section id="after-fence" when="always" -->',
'<!-- msd:section id="after-fence" when="always" -->',
'body',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
);
// If the `<!--` inside the fence had wrongly opened a real comment, the
// real marker pair below would never be recognized (swallowed as
@@ -398,7 +398,7 @@ describe('fence and comment mutual precedence', () => {
describe('loop-host and backtick negative space', () => {
test('loopHostMarkerIsNotASectionMarker', () => {
const source = doc(
'<!-- gsd:loop-host',
'<!-- msd:loop-host',
'step: plan',
'points: plan:pre, plan:post',
'-->',
@@ -413,8 +413,8 @@ describe('loop-host and backtick negative space', () => {
test('backtickedMarkerMentionIsNotAMarker', () => {
const source = doc(
'See `<!-- gsd:section id="x" when="always" -->` for the marker syntax.',
'And the close form is `<!-- /gsd:section -->` on its own line.',
'See `<!-- msd:section id="x" when="always" -->` for the marker syntax.',
'And the close form is `<!-- /msd:section -->` on its own line.',
);
const sections = parseWorkflowSections(source);
assert.equal(sections.length, 1);
@@ -428,7 +428,7 @@ describe('loop-host and backtick negative space', () => {
describe('structural negatives throw with file + line', () => {
test('unclosedSectionThrowsWithLocation', () => {
const source = doc('prose', '<!-- gsd:section id="a" when="always" -->', 'body, never closed');
const source = doc('prose', '<!-- msd:section id="a" when="always" -->', 'body, never closed');
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.message.includes('workflow.md:2') && err.reason === REASON.UNCLOSED_SECTION,
@@ -436,7 +436,7 @@ describe('structural negatives throw with file + line', () => {
});
test('unmatchedCloseThrowsWithLocation', () => {
const source = doc('prose', '<!-- /gsd:section -->', 'more prose');
const source = doc('prose', '<!-- /msd:section -->', 'more prose');
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.message.includes('workflow.md:2') && err.reason === REASON.UNMATCHED_CLOSE,
@@ -445,11 +445,11 @@ describe('structural negatives throw with file + line', () => {
test('nestedSectionThrows', () => {
const source = doc(
'<!-- gsd:section id="outer" when="always" -->',
'<!-- gsd:section id="inner" when="always" -->',
'<!-- msd:section id="outer" when="always" -->',
'<!-- msd:section id="inner" when="always" -->',
'body',
'<!-- /gsd:section -->',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'<!-- /msd:section -->',
);
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
@@ -459,12 +459,12 @@ describe('structural negatives throw with file + line', () => {
test('duplicateSectionIdThrows', () => {
const source = doc(
'<!-- gsd:section id="dup" when="always" -->',
'<!-- msd:section id="dup" when="always" -->',
'first',
'<!-- /gsd:section -->',
'<!-- gsd:section id="dup" when="flag:--wave" -->',
'<!-- /msd:section -->',
'<!-- msd:section id="dup" when="flag:--wave" -->',
'second',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
);
// Throws on the SECOND occurrence's line, not the first.
assert.throws(
@@ -478,7 +478,7 @@ describe('structural negatives throw with file + line', () => {
describe('attribute-shape negatives', () => {
test('missingIdAttributeThrows', () => {
const source = '<!-- gsd:section when="always" -->\nbody\n<!-- /gsd:section -->';
const source = '<!-- msd:section when="always" -->\nbody\n<!-- /msd:section -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.MISSING_ID,
@@ -486,7 +486,7 @@ describe('attribute-shape negatives', () => {
});
test('missingWhenAttributeThrows', () => {
const source = '<!-- gsd:section id="x" -->\nbody\n<!-- /gsd:section -->';
const source = '<!-- msd:section id="x" -->\nbody\n<!-- /msd:section -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.MISSING_WHEN,
@@ -494,7 +494,7 @@ describe('attribute-shape negatives', () => {
});
test('unknownWhenValueThrows', () => {
const source = '<!-- gsd:section id="x" when="flag:--nonexistent" -->\nbody\n<!-- /gsd:section -->';
const source = '<!-- msd:section id="x" when="flag:--nonexistent" -->\nbody\n<!-- /msd:section -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.UNKNOWN_WHEN,
@@ -503,7 +503,7 @@ describe('attribute-shape negatives', () => {
test('whenValueWithBooleanOperatorThrows', () => {
for (const when of ['flag:--wave && state:has-prior-phases', 'flag:--wave || state:has-prior-phases', '!flag:--wave']) {
const source = `<!-- gsd:section id="x" when="${when}" -->\nbody\n<!-- /gsd:section -->`;
const source = `<!-- msd:section id="x" when="${when}" -->\nbody\n<!-- /msd:section -->`;
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.UNKNOWN_WHEN,
@@ -513,7 +513,7 @@ describe('attribute-shape negatives', () => {
});
test('malformedAttributesThrows', () => {
const source = '<!-- gsd:section id="x" when -->\nbody\n<!-- /gsd:section -->';
const source = '<!-- msd:section id="x" when -->\nbody\n<!-- /msd:section -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.MALFORMED_ATTRIBUTES,
@@ -521,7 +521,7 @@ describe('attribute-shape negatives', () => {
});
test('unrecognizedAttributeThrows', () => {
const source = '<!-- gsd:section id="x" when="always" bogus="1" -->\nbody\n<!-- /gsd:section -->';
const source = '<!-- msd:section id="x" when="always" bogus="1" -->\nbody\n<!-- /msd:section -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.UNRECOGNIZED_ATTRIBUTE,
@@ -529,7 +529,7 @@ describe('attribute-shape negatives', () => {
});
test('malformedIdValueThrows', () => {
const source = '<!-- gsd:section id="-bad-" when="always" -->\nbody\n<!-- /gsd:section -->';
const source = '<!-- msd:section id="-bad-" when="always" -->\nbody\n<!-- /msd:section -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.MALFORMED_ID,
@@ -537,7 +537,7 @@ describe('attribute-shape negatives', () => {
});
test('closeMarkerWithAttributesThrows', () => {
const source = '<!-- gsd:section id="x" when="always" -->\nbody\n<!-- /gsd:section foo="1" -->';
const source = '<!-- msd:section id="x" when="always" -->\nbody\n<!-- /msd:section foo="1" -->';
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.CLOSE_WITH_ATTRIBUTES,
@@ -684,7 +684,7 @@ describe('widened when= vocabulary (#2994 code-review/complete-milestone)', () =
test('acceptsEveryWidenedAtom', () => {
for (const when of NET_NEW_ATOMS_2994B) {
const source = `<!-- gsd:section id="x" when="${when}" -->\nbody\n<!-- /gsd:section -->`;
const source = `<!-- msd:section id="x" when="${when}" -->\nbody\n<!-- /msd:section -->`;
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
assert.equal(explicitSections.length, 1, `expected acceptance for when="${when}"`);
@@ -715,7 +715,7 @@ describe('widened when= vocabulary (#2993)', () => {
test('acceptsEveryWidenedAtom (row A1)', () => {
for (const when of NET_NEW_ATOMS_2993) {
const source = `<!-- gsd:section id="x" when="${when}" -->\nbody\n<!-- /gsd:section -->`;
const source = `<!-- msd:section id="x" when="${when}" -->\nbody\n<!-- /msd:section -->`;
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
assert.equal(explicitSections.length, 1, `expected acceptance for when="${when}"`);
@@ -732,12 +732,12 @@ describe('widened when= vocabulary (#2993)', () => {
// token derivation). See section-manifest.test.cjs for the predicate-level
// half of this guard (no aliasing at evaluation time).
const source = doc(
'<!-- gsd:section id="research-section" when="flag:--research" -->',
'<!-- msd:section id="research-section" when="flag:--research" -->',
'researchBody',
'<!-- /gsd:section -->',
'<!-- gsd:section id="research-phase-section" when="flag:--research-phase" -->',
'<!-- /msd:section -->',
'<!-- msd:section id="research-phase-section" when="flag:--research-phase" -->',
'researchPhaseBody',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
);
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
@@ -790,7 +790,7 @@ describe('widened when= vocabulary (#2992)', () => {
test('acceptsEveryWidenedAtom (row A2)', () => {
for (const when of NET_NEW_ATOMS) {
const source = `<!-- gsd:section id="x" when="${when}" -->\nbody\n<!-- /gsd:section -->`;
const source = `<!-- msd:section id="x" when="${when}" -->\nbody\n<!-- /msd:section -->`;
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
assert.equal(explicitSections.length, 1, `expected acceptance for when="${when}"`);
@@ -802,12 +802,12 @@ describe('widened when= vocabulary (#2992)', () => {
test('sameAtomOnTwoDifferentSectionsIsLegal (row A19)', () => {
// Atom reuse is legal; only `id` must be unique.
const source = doc(
'<!-- gsd:section id="first" when="flag:--auto" -->',
'<!-- msd:section id="first" when="flag:--auto" -->',
'bodyA',
'<!-- /gsd:section -->',
'<!-- gsd:section id="second" when="flag:--auto" -->',
'<!-- /msd:section -->',
'<!-- msd:section id="second" when="flag:--auto" -->',
'bodyB',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
);
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
@@ -824,7 +824,7 @@ describe('widened when= vocabulary (#2992)', () => {
// A case variant of a real net-new atom must still throw — exact `===`,
// no case folding.
for (const when of ['Flag:--auto', 'flag:--Auto', 'FLAG:--AUTO', 'flag:--RESEARCH']) {
const source = `<!-- gsd:section id="x" when="${when}" -->\nbody\n<!-- /gsd:section -->`;
const source = `<!-- msd:section id="x" when="${when}" -->\nbody\n<!-- /msd:section -->`;
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.UNKNOWN_WHEN,
@@ -837,7 +837,7 @@ describe('widened when= vocabulary (#2992)', () => {
// A padded value must still throw — the value is not trimmed before the
// vocabulary membership check.
for (const when of [' flag:--auto', 'flag:--auto ', ' state:worktrees-enabled ']) {
const source = `<!-- gsd:section id="x" when="${when}" -->\nbody\n<!-- /gsd:section -->`;
const source = `<!-- msd:section id="x" when="${when}" -->\nbody\n<!-- /msd:section -->`;
assert.throws(
() => parseWorkflowSections(source, 'workflow.md'),
(err) => err instanceof TypeError && err.reason === REASON.UNKNOWN_WHEN,
@@ -849,9 +849,9 @@ describe('widened when= vocabulary (#2992)', () => {
test('crlfMarkerLineCarryingAWidenedAtomRoundTripsExactly (row A14)', () => {
const source = [
'prose one',
'<!-- gsd:section id="x" when="flag:--forensic" -->',
'<!-- msd:section id="x" when="flag:--forensic" -->',
'crlf body',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'prose two',
].join('\r\n');
const sections = parseWorkflowSections(source);
@@ -863,7 +863,7 @@ describe('widened when= vocabulary (#2992)', () => {
const rendered = composeWorkflow(source);
const expected = source
.split('\r\n')
.filter((line) => !/^<!--\s*\/?gsd:section.*-->\s*$/.test(line))
.filter((line) => !/^<!--\s*\/?msd:section.*-->\s*$/.test(line))
.join('\r\n');
assert.equal(rendered, expected);
});
@@ -879,7 +879,7 @@ describe('boundary documents', () => {
});
test('documentOfOnlyAMarkerPairYieldsEmptyBody', () => {
const source = '<!-- gsd:section id="x" when="always" -->\n<!-- /gsd:section -->';
const source = '<!-- msd:section id="x" when="always" -->\n<!-- /msd:section -->';
const sections = parseWorkflowSections(source);
assert.equal(sections.length, 1);
assert.equal(sections[0].explicit, true);
@@ -889,7 +889,7 @@ describe('boundary documents', () => {
});
test('unclosedFenceAtEofDoesNotThrow', () => {
const source = doc('prose', '```', 'never closed', '<!-- gsd:section id="x" when="always" -->');
const source = doc('prose', '```', 'never closed', '<!-- msd:section id="x" when="always" -->');
assert.doesNotThrow(() => parseWorkflowSections(source));
const sections = parseWorkflowSections(source);
// The whole document, including the marker-shaped line, is literal
@@ -904,19 +904,19 @@ describe('boundary documents', () => {
describe('cross-platform line endings and liberal marker formatting', () => {
test('crlfDocumentRoundTripsByteIdentical', () => {
const source = ['prose one', '<!-- gsd:section id="x" when="always" -->', 'crlf body', '<!-- /gsd:section -->', 'prose two'].join(
const source = ['prose one', '<!-- msd:section id="x" when="always" -->', 'crlf body', '<!-- /msd:section -->', 'prose two'].join(
'\r\n',
);
const rendered = composeWorkflow(source);
const expected = source
.split('\r\n')
.filter((line) => !/^<!--\s*\/?gsd:section.*-->\s*$/.test(line))
.filter((line) => !/^<!--\s*\/?msd:section.*-->\s*$/.test(line))
.join('\r\n');
assert.equal(rendered, expected);
});
test('mixedLineEndingsPreservedExactly', () => {
const source = 'prose\r\n<!-- gsd:section id="x" when="always" -->\r\nbody one\nbody two\n<!-- /gsd:section -->\nprose two';
const source = 'prose\r\n<!-- msd:section id="x" when="always" -->\r\nbody one\nbody two\n<!-- /msd:section -->\nprose two';
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
assert.equal(explicitSections.length, 1);
@@ -927,14 +927,14 @@ describe('cross-platform line endings and liberal marker formatting', () => {
test('attributeOrderAndSpacingAreAccepted', () => {
const variants = [
'<!-- gsd:section id="x" when="always" -->',
'<!--gsd:section id="x" when="always"-->',
'<!-- gsd:section when="always" id="x" -->',
' <!-- gsd:section when="always" id="x" --> ',
'<!--gsd:section when="always"id="x"-->',
'<!-- msd:section id="x" when="always" -->',
'<!--msd:section id="x" when="always"-->',
'<!-- msd:section when="always" id="x" -->',
' <!-- msd:section when="always" id="x" --> ',
'<!--msd:section when="always"id="x"-->',
];
for (const openLine of variants) {
const source = `${openLine}\nbody\n<!-- /gsd:section -->`;
const source = `${openLine}\nbody\n<!-- /msd:section -->`;
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
assert.equal(explicitSections.length, 1, `expected recognition for: ${openLine}`);
@@ -952,9 +952,9 @@ describe('cross-platform line endings and liberal marker formatting', () => {
describe('budget boundary set: nothing is ever trimmed', () => {
const source = doc(
'gap prose',
'<!-- gsd:section id="a" when="always" -->',
'<!-- msd:section id="a" when="always" -->',
'section a body',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'more gap prose',
);
@@ -1032,9 +1032,9 @@ describe('adversarial content bytes', () => {
test('unicodeHeadingRoundTripsByteIdentical', () => {
const source = doc(
'# 見出し — Ünïcödé Hëading 🚀',
'<!-- gsd:section id="sec" when="always" -->',
'<!-- msd:section id="sec" when="always" -->',
'body with 中文, кириллица, emoji 🎉',
'<!-- /gsd:section -->',
'<!-- /msd:section -->',
'trailing プロース',
);
const expected = doc('# 見出し — Ünïcödé Hëading 🚀', 'body with 中文, кириллица, emoji 🎉', 'trailing プロース');
@@ -1044,7 +1044,7 @@ describe('adversarial content bytes', () => {
});
test('nulByteInBodyRoundTripsByteIdentical', () => {
const source = `prose\0more\n<!-- gsd:section id="x" when="always" -->\nbody\0with\0nul\n<!-- /gsd:section -->\nafter\0`;
const source = `prose\0more\n<!-- msd:section id="x" when="always" -->\nbody\0with\0nul\n<!-- /msd:section -->\nafter\0`;
const sections = parseWorkflowSections(source);
const explicitSections = sections.filter((s) => s.explicit);
assert.equal(explicitSections.length, 1);
@@ -1054,13 +1054,13 @@ describe('adversarial content bytes', () => {
});
test('unicodeReplacementCharacterRoundTripsByteIdentical', () => {
const source = `prose <20> end\n<!-- gsd:section id="x" when="always" -->\nbody <20><>\n<!-- /gsd:section -->\nafter <20>`;
const source = `prose <20> end\n<!-- msd:section id="x" when="always" -->\nbody <20><>\n<!-- /msd:section -->\nafter <20>`;
const rendered = composeWorkflow(source);
assert.equal(rendered, 'prose <20> end\nbody <20><>\nafter <20>');
});
test('leadingByteOrderMarkRoundTripsByteIdentical', () => {
const source = '# Heading\n<!-- gsd:section id="x" when="always" -->\nbody\n<!-- /gsd:section -->\ntail';
const source = '# Heading\n<!-- msd:section id="x" when="always" -->\nbody\n<!-- /msd:section -->\ntail';
const sections = parseWorkflowSections(source);
const gaps = sections.filter((s) => !s.explicit);
// The BOM is ordinary content of the leading gap — never stripped or
@@ -1077,7 +1077,7 @@ describe('adversarial fence shapes', () => {
'prose before',
'````',
'```',
'<!-- gsd:section id="fake" when="always" -->',
'<!-- msd:section id="fake" when="always" -->',
'```',
'````',
'prose after',
@@ -1090,7 +1090,7 @@ describe('adversarial fence shapes', () => {
});
test('tildeFenceHidesMarkerLookalike', () => {
const source = doc('prose', '~~~', '<!-- gsd:section id="fake" when="always" -->', '~~~', 'prose after');
const source = doc('prose', '~~~', '<!-- msd:section id="fake" when="always" -->', '~~~', 'prose after');
const sections = parseWorkflowSections(source);
assert.equal(sections.length, 1);
assert.equal(sections[0].explicit, false);
@@ -1099,7 +1099,7 @@ describe('adversarial fence shapes', () => {
});
test('indentedFenceUpToThreeSpacesHidesMarkerLookalike', () => {
const source = doc('prose', ' ```', '<!-- gsd:section id="fake" when="always" -->', ' ```', 'prose after');
const source = doc('prose', ' ```', '<!-- msd:section id="fake" when="always" -->', ' ```', 'prose after');
const sections = parseWorkflowSections(source);
assert.equal(sections.length, 1);
assert.equal(sections[0].explicit, false);
@@ -1115,7 +1115,7 @@ describe('adversarial line-ending shapes', () => {
// module doc comment). The marker-shaped text is therefore never on its
// "own line" and must be left as ordinary literal content, not parsed
// as an open marker.
const source = '<!-- gsd:section id="x" when="always" -->\rbody, never a real line break';
const source = '<!-- msd:section id="x" when="always" -->\rbody, never a real line break';
const sections = parseWorkflowSections(source);
assert.equal(sections.length, 1);
assert.equal(sections[0].explicit, false);
@@ -1126,12 +1126,12 @@ describe('adversarial line-ending shapes', () => {
describe('fs.readFileSync fault injection mid-compose', () => {
test('readFailureDuringCompositionLeavesNoPartialArtifact', (t) => {
const tmpDir = createTempDir('gsd-wf-fault-');
const tmpDir = createTempDir('msd-wf-fault-');
t.after(() => cleanup(tmpDir));
const srcPath = path.join(tmpDir, 'source.md');
const destPath = path.join(tmpDir, 'composed.md');
fs.writeFileSync(srcPath, '<!-- gsd:section id="x" when="always" -->\nbody\n<!-- /gsd:section -->\n');
fs.writeFileSync(srcPath, '<!-- msd:section id="x" when="always" -->\nbody\n<!-- /msd:section -->\n');
function readComposeWrite() {
const content = fs.readFileSync(srcPath, 'utf8');