Files
msd-core/tests/quick-planner-scope-guard.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

57 lines
3.0 KiB
JavaScript

'use strict';
// ─────────────────────────────────────────────────────────────────────────────
// #3786 — the /msd-quick planner constraints must carry a mutable-scope
// AUTHORITY rule.
//
// A minimized planner probe committed HISTORICAL scope as authorized edit /
// verification scope in 2 of 3 trials: for a merge-conflict task whose fresh
// merge had not run, one trial provisionally authorized 65 cached PR-diff
// paths, another broadened verification to the whole PR integration surface.
// Adding one explicit requirement — authorized scope comes only from the
// fresh merge index — reduced failures to 0 of 3. The rule lives in the
// shipped planner prompt (quick.md's <constraints> block), so a structural
// guard over that text pins it.
// ─────────────────────────────────────────────────────────────────────────────
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const QUICK_MD = path.join(__dirname, '..', 'msd-core', 'workflows', 'quick.md');
// quick.md is shipped workflow text — the bytes ARE what the runtime loads,
// so a structural scan over it tests the deployed contract (same shape as
// tests/config-get-raw-guard.test.cjs; no allow-test-rule marker needed for
// .md reads).
function plannerConstraints() {
const md = fs.readFileSync(QUICK_MD, 'utf-8');
// quick.md carries TWO <constraints> blocks (planner at ~315, executor at
// ~479). Anchor to the PLANNER's: the last block opening before its
// subagent_type declaration — step reordering can never silently redirect
// the guard to another agent's block.
const plannerDispatch = md.indexOf('subagent_type="msd-planner"');
assert.ok(plannerDispatch > 0, 'quick.md must dispatch the msd-planner agent');
const start = md.lastIndexOf('<constraints>', plannerDispatch);
const end = md.indexOf('</constraints>', start);
assert.ok(start > 0 && end > start, 'quick.md must contain the planner <constraints> block');
return md.slice(start, end);
}
test('#3786: the quick planner constraints carry a mutable-scope authority rule', () => {
const constraints = plannerConstraints();
assert.ok(
/live observation/i.test(constraints) && /conditional/i.test(constraints),
'#3786: scope derived from mutable external state must be live-observed or kept conditional',
);
assert.ok(
/may guide investigation only/i.test(constraints),
'#3786: historical STATE.md/recovery/cached-diff paths must be labeled investigation-only, never edit/verification authority',
);
assert.ok(
constraints.includes('git diff --name-only --diff-filter=U'),
'#3786: the conflict-resolution case must name the fresh-merge-index command the probe validated',
);
});