feat(#3149): add dedicated init.debug entry point for /gsd:debug
/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>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"paths": {
|
||||
"debug.md": "#3149 (prerequisite for #3128, ADR-1671 admission gate 2): debug.md gains a dedicated `init.debug` entry point (cmdInitDebug) and its Step 0 collapses THREE separate `gsd_run` round-trips into one. Removed: `gsd_run query state.load` (line 20, replaced in place), the `resolve-model gsd-debugger --pick model` block, and the `config-get workflow.tdd_mode --raw` block — 2 prose lead-ins and 2 fenced code blocks in total. Added: a 6-bullet extraction list documenting the bundle's fields (`commit_docs`, the now TOP-LEVEL `response_language`, `debug_dir`, `debugger_model`, `tdd_mode`, `section_manifest`) plus the `section_manifest: null` -> read-everything rule and the null-vs-empty-included distinction. Net SOURCE growth is +607 bytes (20,555 -> 21,162): the bullets that document one bundle cost more bytes than the two shell round-trips they replace, which is the intended trade — the round-trips cost three subprocess spawns at RUN time on every /gsd:debug invocation. No `<!-- gsd:section -->` marker is added and WHEN_VOCABULARY is unchanged at 29, so the composeWorkflow emission path is byte-identical in shape to before; only this file's own content moved. The `{TDD_MODE}` and `{debugger_model}` placeholders in the session-parameter blocks (lines ~137-145, ~226-234) are deliberately left byte-identical — they now resolve from the init bundle instead of shell variables, and rewording them would ripple into tests/fix-2257-debug-nonterminal-resume.test.cjs and tests/debug-session-manager-commit.test.cjs for no behavioral gain."
|
||||
}
|
||||
}
|
||||
87
tests/init-debug-workflow-contract.test.cjs
Normal file
87
tests/init-debug-workflow-contract.test.cjs
Normal file
@@ -0,0 +1,87 @@
|
||||
// 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'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user