Files
msd-core/tests/init-debug-workflow-contract.test.cjs
Jakub Zych a9a7a328e6 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.
2026-10-06 01:47:40 +02:00

89 lines
3.7 KiB
JavaScript

// allow-test-rule: source-text-is-the-product (see #3149)
// msd-core/workflows/debug.md is shipped prompt content: the text IS what the
// runtime loads, so its Step 0 contract can only be asserted against the text.
// The behavioral half of this change lives in tests/init-debug.test.cjs, which
// carries no exemption.
'use strict';
/**
* `debug.md` Step 0 contract after the `init.debug` consolidation (#3149).
*
* Matrix: `.msd/phase/feat-3149-cmdinitdebug/50-test-matrix.md` group F.
*
* Guards the four ways this consolidation can silently regress:
* F1/F2 — a replaced round-trip creeping back, or the new one being lost.
* F3 — reading `config.response_language` (the nested state.load shape)
* instead of the flat top-level field withProjectRoot injects. This
* is the #2402 defect class: the workflow silently stays English.
* F4 — losing the `@file:` unwrap, which large init payloads still need.
* F5 — dropping the `section_manifest: null` -> read-everything rule,
* without which a null manifest reads as "read nothing".
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const WORKFLOW_PATH = path.join(__dirname, '..', 'msd-core', 'workflows', 'debug.md');
const workflow = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
/** Every `msd_run query <name>` invocation in the workflow, in document order. */
function queryInvocations(text) {
return [...text.matchAll(/msd_run query ([\w.-]+)/g)].map((m) => m[1]);
}
describe('debug.md Step 0 init contract (#3149, matrix §F)', () => {
test('calls init.debug exactly once (row F1)', () => {
const initDebugCalls = queryInvocations(workflow).filter((q) => q === 'init.debug');
assert.equal(initDebugCalls.length, 1, 'exactly one init.debug round-trip');
});
test('no longer makes the three replaced calls (row F2)', () => {
const queries = queryInvocations(workflow);
assert.equal(queries.includes('state.load'), false, 'state.load is replaced by init.debug');
assert.equal(
workflow.includes('resolve-model msd-debugger'),
false,
'debugger_model now rides the init bundle'
);
assert.equal(
workflow.includes('config-get workflow.tdd_mode'),
false,
'tdd_mode now rides the init bundle'
);
});
test('reads the flat response_language, not the nested state.load shape (row F3)', () => {
assert.equal(
workflow.includes('config.response_language'),
false,
'withProjectRoot injects response_language at the TOP level; reading config.response_language ' +
'against an init bundle resolves undefined and silently drops translated output (#2402)'
);
assert.ok(
workflow.includes('`response_language`'),
'the field is still documented, just at its new location'
);
});
test('still unwraps an @file: payload (row F4)', () => {
assert.ok(
workflow.includes('@file:'),
'init payloads can spill to a file; dropping the unwrap leaves INIT holding a path, not JSON'
);
});
test('documents the null-manifest read-everything fallback (row F5)', () => {
assert.ok(workflow.includes('section_manifest'), 'the field is documented');
assert.ok(
// eslint-disable-next-line local/no-unbounded-quantifier -- parses maintainer-authored workflow markdown, bounded prose, not adversarial input
/`null`[^\r\n]*read this workflow in full/i.test(workflow),
'a null section_manifest must be documented as "read everything" — without the rule, ' +
'a null manifest reads as an empty selection and the workflow reads nothing'
);
});
});