/gsd:debug was one of the last workflows with no cmdInit* of its own: its Step 0 made three separate round-trips (state.load, resolve-model gsd-debugger, config-get workflow.tdd_mode) to assemble one context. Because no debug-scoped fact was computed at any entry point, ADR-1671 admission gate (2) could never be satisfied for debug — an applicability atom naming such a fact would evaluate FALSE forever and silently exclude its section. Adds cmdInitDebug (init.debug), registers it in the init router and the command-alias table, and collapses debug.md Step 0 to one call. Every field resolves through the same primitive the call it replaces used: loadConfig for commit_docs, withProjectRoot for response_language (#2402), planningPaths for debug_dir, resolveModelInternal for debugger_model, and the existing Boolean(workflow.tdd_mode) idiom for tdd_mode. PlanningPaths gains a debug field so state.load and init.debug share ONE debug-directory expression rather than two kept in sync by hand. state.load keeps emitting debug_dir: it is a shipped query surface with its own test anchor, so narrowing it would break unseen consumers for no gain. No WHEN_VOCABULARY atom and no gsd:section marker: gate (1), a consuming section of at least 400 bytes, belongs to the change that adds the section. Closes #3149 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
88 lines
3.5 KiB
JavaScript
88 lines
3.5 KiB
JavaScript
// allow-test-rule: source-text-is-the-product (see #3149)
|
|
// gsd-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: `.gsd/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, '..', 'gsd-core', 'workflows', 'debug.md');
|
|
const workflow = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
|
|
/** Every `gsd_run query <name>` invocation in the workflow, in document order. */
|
|
function queryInvocations(text) {
|
|
return [...text.matchAll(/gsd_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 gsd-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(
|
|
/`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'
|
|
);
|
|
});
|
|
});
|