* fix(#3951): two lint rules that could not reach the code they govern B6 names two widenings. Measuring them first turned up a defect the criterion did not know about, and refuted the reason it gave for one of them. 1. no-adhoc-markdown-parsing self-gates on its own filename. Lines 107-110 short-circuit create() to {} unless the path matches /(?:^|\/)src\/[^/]+\.cts$/. B6 says to widen the files: glob in eslint.config.mjs - but doing only that ships an INERT rule, because the gate still returns {} for every new path. Both halves have to change, and the gate is the load-bearing one. That same regex hides a live hole: [^/]+ is FLAT-ONLY, so it requires the file to sit directly in src/. The registered glob is src/**/*.cts, which includes subdirectories. 28 .cts files - health-diagnostic-rules/ (10), installer-migrations/ (11), observability/ (3), host-integration-adapters/ (2), vendor/ (2) - are inside the registered glob and silently skipped. Measured with the gate neutralized: 0 violations there today. The hole is hiding nothing right now, and is fixed anyway, because "no violations today" is not a property that keeps holding. The fix is not invented: require-subprocess-timeout.cjs:196 already carries the correct form of this guard, /(?:^|\/)src\/.*\.cts$/ with .*, one directory over. Checked the other 21 rules for the same bug - no-adhoc-regex-escape and no-private-binary-resolution short-circuit only to exempt their own seam file, which is the right shape, and no-crlf-fragile-split has no filename gate at all. This bug is unique to the one rule. 2. no-adhoc-regex-escape could not see the shape that actually occurs. Line 396 gated the whole UNSAFE-NEW-REGEXP arm on arg.type === 'Identifier'. Every check below it - the _SOURCE provenance check, the isSoleReturnOfOwnParameter shape - lives inside that branch, so new RegExp(obj['key']) and new RegExp(cfg.pattern) were never examined at all. Runtime data arrives as a property access far more often than as a bare identifier, which is exactly why this rule never fired on the #3477 ReDoS. Widened to MemberExpression, measured by AST walk across all five registered blocks rather than by grep. 27 sites, zero TSAsExpression: 18 safe new RegExp(X.source, flags) -> exempted, keyed strictly on the PROPERTY being `source`, never on the object. Keying on the object would wave through X.anything and buy nothing. B6 estimated ~10; that was an undercount. 3 _SOURCE-suffixed constants reached through a required module namespace (phaseId.BRACKET_PHASE_TOKEN_SOURCE) -> the same provenance-exempt class the rule already recognizes for bare identifiers, extended to reach them. Without this the widening produces 3 false flags. 6 real findings -> marked, each a test extracting a pattern from a shipped file at test time, where the runtime contract IS the product. Deliberately the NARROW MemberExpression form. The rule's own isSoleReturnOfOwnParameter doc comment records that an earlier broad "any non-literal identifier" heuristic produced ~25 false positives and was rejected; a re-run of the census after this change flags exactly the 6 above and nothing else. Verified by execution, not by reading: the gate now accepts src/<subdir>/x.cts, still accepts flat src/x.cts, and still exempts paths outside src/ - each pinned by a test proven to fail against the old regex. build:lib, lint and lint:ci all exit 0. Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(#3951): give no-adhoc-markdown-parsing its reach, and fix the 80 parses it finds The rule self-gates on filename AND is registered on one glob, so widening either half alone is inert. Both move here: the gate now accepts tests/**/*.cjs and scripts/**/*.cjs alongside src/**/*.cts, and eslint.config.mjs registers it on the same two. A test pins that the gate and the registration AGREE, in both directions. The original defect was a gate narrower than its registration; the failure mode of this fix is a gate wider than its registration. Both are silent, so the test asserts the pair rather than either half. 80 violations across 43 files, all in tests/, zero in scripts/. 70 are routed through the existing seams - scanFencedBlocks, collectSection, stripFencedCode, tokenizeHeadings from markdown-sectionizer; splitTableRow, parseMarkdownTable, findTableWithColumns from markdown-table. Headerless STATE.md tables use splitTableRow per line, because parseMarkdownTable needs a real delimiter row. 10 are suppressed, 12.5%, well under the third that would have meant the rule is mis-scoped for tests/ rather than the tests carrying debt. Each names its reason: three regression guards (#3873 / bug-#21) are deliberately independent of the generator's own fence handling, and routing them through the seam would have them test the generator against itself; one is a negative-text probe that extracts nothing; six are a shell-pipe-to-jq detector whose regex coincidentally matches the table fingerprint and is not markdown parsing at all. All ten sit in tests whose subject is .md content, which is normally a reason to prefer the seam. The marker used is allow-adhoc-markdown, distinct from no-source-grep's allow-test-rule, and lint:ci's lint-allow-test-rule-refs reports the same 280/280 unverified count as before - checked rather than assumed, because those two markers are easy to conflate. The widening earned its keep immediately: it found a test that passed for the wrong reason. tests/config-field-docs.test.cjs asserted notEqual(<cell>, '600') against the TYPE column instead of the DEFAULT column. notEqual('number', '600') is true forever, so the guard against workflow.subagent_timeout regressing to the old seconds default could never fire. docs/CONFIGURATION.md:434 is `| workflow.subagent_timeout | number | 300000 | ... |`, so the default is cell index 2; the assertion is now row-scoped through splitTableRow and reads 300000. That is the argument for the widening in one case: the violation was invisible to lint, the suite was green, and the assertion was vacuous. A rule that cannot reach a file cannot tell you the file is lying. Not fixed here, and recorded rather than assumed: #3426/#3239 are NOT reachable by this widening. tests/package-legitimacy-gate.test.cjs yields zero violations even with the gate bypassed - its hand-rolled scans are real, but built from line filters and split('|') rather than the regex-literal fingerprints this rule detects. They need new detectors. The epic assumed a wider glob would catch them. build:lib, lint and lint:ci all exit 0; the post-fix census across tests/** and scripts/** is 0 violations. Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(#3951): B7 — and #3356's defects were still live in the code B7 asks that each closed child be driven fail-first with a behavioral identity test at the CONSUMER's output. Four of eleven children had no test citing their issue number. Auditing them by BEHAVIOR rather than by number-grep changed the answer for three of the four. #3364 and #2540 — traceability only. Both were implemented by #3941 and their consumer-output tests exist and were shown failing-first; neither cited its originating issue, so an audit that greps for the number reports them uncovered. Tagged the specific asserting test in each file, following the citation form those files already use. #3372 — covered, but only at helper level, and the triage narrowed it. Of the four commands the issue names, only estimate-cli's collectCalibrationSamples actually enumerates phase dirs from disk; smart-entry, audit and roadmap-upgrade derive from ROADMAP/body text and never reach the sentinel path, so they are benign by construction and were left alone rather than "fixed" into churn. The existing #3882 rows asserted the helper's return value. Added a consumer-output test driving `query estimate-calibrate` and asserting sample_count and the persisted document. RED proof: reverted collectCalibrationSamples to a raw readdirSync and ran the real CLI - sample_count 3, sentinel leaked; restored - sample_count 2. #3356 — NOT covered, and BOTH halves of the defect were still live in source. The issue is closed; the bug was not fixed. Fixed here rather than writing tests that document a bug as correct. Defect 1, the contradicted row. quick.md:627 claimed `quick-tasks-append` performs "the equivalent write" to the Step 7c row. It did not: the `#` cell was a positional ordinal and `Directory` read `—`, because the route had no way to receive a quick id or task directory. Added OPTIONAL `--quick-id` / `--slug` / `--directory`. A caller with neither - fast.md, the original #2133 caller - omits them and gets the byte-identical prior row, so nothing existing changes. A caller that HAS a real id and directory now gets the canonical row quick.md:632 renders. The false-equivalence sentence itself is corrected rather than left to mislead the next reader. Defect 2, the forced re-derive. The route called readModifyWriteStateMd with no options, so a body-only append to the Quick Tasks table triggered a full re-derive of the disk-derived progress.* frontmatter. Every other body-only writer passes { resync: false } - src/state.cts's own docstring prescribes it - and this route was the lone outlier. RED proof: reverted the option, seeded a project with 2 real phase dirs and a curated total_phases of 25, ran quick-tasks-append; total_phases collapsed to 2. Restored; it stayed 25. That second one is the shape this epic exists to close: a silent write that replaces curated state with a re-derivation nobody asked for, exit 0 throughout. build:lib, lint and lint:ci all exit 0. Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(#3951): amend B6's ledger to what was measured, and document the new flags The ADR gains a ledger amendment in its own correction style - the sixth wrong premise it records, found the same way as the other five, by measuring before building. B6 says the net guard count must fall. It rose: 62 -> 69, +7, measured from the epic's filing commit to origin/next. The attribution is the point, though. Five of the seven came from PRs unrelated to this epic, one was added by a phase of it, and the epic did retire something sub-file - #3884 removed a detector with an explicit "net: -1 detector, 0 added" ledger. Every named casualty is load-bearing, two already carry retractions in this same document, and a sweep of all 22 rules plus every scripts/lint-* found no provably dead guard. There is no honest way to make the count fall; forcing it would trade coverage for a number, which is the Goodhart outcome Decision 6 exists to prevent. The amendment also records that B6's own prescribed fix for one widening was inert. no-adhoc-markdown-parsing self-gates on its filename, so widening only the files: glob - which is what the criterion says to do - ships a rule that still returns {} for every new path. And #3426/#3239 are not reachable by that widening at all; their scans use line filters and split('|'), not the regex fingerprints the rule detects. The roster row tracked them against the wrong mechanism. Three roster rows updated from aspiration to fact: the two widenings are DONE with their measured counts, and lint-phase-enumeration-drift is marked RETAINED rather than "expected casualty - verify before retiring", because Phase 5 verified it and kept it. The rule Decision 6 should carry forward is stated plainly: a guard ledger is a claim about COVERAGE, not about COUNT. "Net count must fall" is measurable and wrong. "Every guard is reachable, and each retirement names what makes its defect unrepresentable" is the property that was actually wanted. CLI-TOOLS.md documents the optional --quick-id/--slug/--directory flags and says plainly that omitting them keeps the pre-#3356 row byte-identical, plus that the append no longer re-derives progress frontmatter. New features fragment (id 3951); FEATURES.md regenerated rather than hand-edited. Changeset is Changed, pr:0 pending backfill. Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(#3951): correct four rows that pinned the lint rule's old narrow reach The remote suite came back RED with 5 failures, all in tests/eslint-rules.test.cjs. They are stale tests, not a regression: four rows assert that no-adhoc-markdown-parsing is inert outside src/*.cts, which is exactly the contract this deliverable changes. Confirmed by reading rather than inferred from the names - the row at :1981 used filename: 'tests/some.test.cjs' and filename: 'scripts/helper.cjs', the two roots the rule now covers on purpose. Worth recording WHY local gates missed this. npm run lint and lint:ci were green, and the touched test files passed standalone. Lint only reports violations in real files; these rows assert the rule's REACH using synthetic RuleTester filenames, so nothing but the full suite could see them. Local green on a rule change says nothing about the rule's own tests. Each row is rewritten with BOTH halves rather than flipped from valid to invalid: - the same fingerprint under tests/ or scripts/ is now flagged, with the right messageId - the negative space is preserved - the same fingerprint under a path outside all three roots (gsd-core/bin/lib/foo.cjs) is still NOT flagged The second half is the one that matters. Without it the rule has no boundary and nothing would catch an over-wide gate later, which is the mirror image of the bug this deliverable just fixed. Each row is renamed to state the current contract; the old names said "non-src/*.cts ... is not flagged" and would have been actively misleading once the bodies changed. Proven to test the widening rather than restate it: every flagged half was run against HEAD~2's pre-widening rule and does NOT fire there, then against the current rule and does. 12/12 on that probe; the full file is 178/178. Swept for the same staleness elsewhere and found none. require-subprocess-timeout's own "inert outside src/*.cts" row is untouched - that rule's gate was not widened here - and no-adhoc-regex-escape's test file already carries correctly-targeted rows. Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(#3951): acknowledge the quick.md growth the attribution guard reported The full suite came back RED with one failure, and it is mine: 1 file(s) grew without an acknowledgment: quick.md grew 364 bytes gsd-core/workflows/quick.md is runtime-loaded emitted content, so correcting its false 'performs the equivalent write' claim trips emitted-attribution by construction. This is the acknowledgment, not a workaround - there is nothing to regenerate. The fragment names ONE path, which is the only one the guard reported. The four spent acknowledgments it also listed (audit-uat, plan-phase, progress, review) belong to other fragments whose ripple the base already absorbs; they are inert, not failures, and are deliberately NOT copied here - naming paths I did not change would make this record false in the other direction. Byte figure corrected before committing: the guard reported 37220 -> 37584 (+364), but origin/next has since moved and quick.md is 37232 there now, so the measured delta is +352. The reason text says so and names the base as a moving figure rather than pinning a number that is already stale. Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * test(#3951): move the quick.md growth ack to a trailer, delete the obsolete fragment The acknowledgment mechanism changed under this branch. Merging next brought in the redesign - it also deleted .github/workflows/ack-fragment-sweep.yml, which was in the merge status and which I did not register at the time - and the guard now says so directly: Add a trailer to a commit in this PR (never a new file). Emitted-Drift-Ack-Growth: quick.md - <why this growth is deliberate> So tests/emitted-drift-acks/3951-quick-append-equivalence.json is obsolete on arrival. A fragment file is no longer read by anything, and leaving it would be a dead record that looks like an active one. It is deleted here rather than kept "just in case". The byte figure moved again with the merge: 37232 -> 37596, +364. The earlier fragment said +352, measured before the merge auto-merged quick.md itself. The trailer carries no number, which is the better design - the figure was stale twice in two attempts. Refs #3951 Emitted-Drift-Ack-Growth: quick.md — #3356/#3951 replaces a false claim with an accurate one. Line 627 said the `quick-tasks-append` shortcut "performs the equivalent write" to the Step 7c row rendered above it; it did not, and that was the documented half of #3356 — with no quick id or task directory the route emitted a positional ordinal in `#` and an em-dash in `Directory`, a visibly different row. The corrected sentence has to carry three facts the original elided: what the shortcut actually writes when it has neither input, that this is honest behavior for its real caller (`fast.md`, which has neither), and how a caller with both now gets the byte-identical canonical row via the new optional `--quick-id`/`--slug`/`--directory` flags. Prose is the product here — an executing agent reads this line to decide whether the shortcut is safe for its case, and a shorter correction would either drop the flags (leaving the reader unable to act on the fix) or drop the limitation (recreating the false claim in gentler words). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore(#3951): backfill changeset pr number Refs #3951 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: sim <sim@local> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
583 lines
23 KiB
JavaScript
583 lines
23 KiB
JavaScript
// allow-test-rule: docs-parity
|
|
// allow-test-rule: source-text-is-the-product — settings-advanced.md prompt text is the deployed contract (#1216)
|
|
// Extracts CONFIG_DEFAULTS keys from config-loader.cjs source to verify planning-config.md
|
|
// stays in sync. The canonical list of defaults lives in source; there is no runtime
|
|
// API to enumerate them. Source inspection is the only practical parity check here.
|
|
// CONFIG_DEFAULTS was extracted from core.cjs into config-loader.cjs by ADR-857 phase 2e.
|
|
|
|
/**
|
|
* Verify planning-config.md documents all config fields from source code.
|
|
*/
|
|
|
|
const { describe, test, before } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { splitTableRow } = require('../gsd-core/bin/lib/markdown-table.cjs');
|
|
|
|
const REFERENCE_PATH = path.join(__dirname, '..', 'gsd-core', 'references', 'planning-config.md');
|
|
const CORE_PATH = path.join(__dirname, '..', 'gsd-core', 'bin', 'lib', 'config-loader.cjs');
|
|
|
|
/** Find the markdown table row whose first cell is `` `key` `` and return its cells. */
|
|
function tableRowForKey(content, key) {
|
|
const target = `\`${key}\``;
|
|
for (const line of content.split(/\r?\n/)) {
|
|
const trimmed = line.trim();
|
|
if (!trimmed.startsWith('|')) continue;
|
|
const cells = splitTableRow(line);
|
|
if (cells[0] === target) return cells;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
describe('config-field-docs', () => {
|
|
let content;
|
|
|
|
before(() => {
|
|
content = fs.readFileSync(REFERENCE_PATH, 'utf-8');
|
|
});
|
|
|
|
test('contains Complete Field Reference section', () => {
|
|
assert.ok(
|
|
content.includes('## Complete Field Reference'),
|
|
'planning-config.md must contain a "Complete Field Reference" heading'
|
|
);
|
|
});
|
|
|
|
test('documents at least 15 config fields in tables', () => {
|
|
// Count table rows that start with | `<key>` (field rows, not header/separator)
|
|
const fieldRows = content.match(/^\| `[a-z_][a-z0-9_.]*` \|/gm);
|
|
assert.ok(fieldRows, 'Expected markdown table rows with backtick-quoted keys');
|
|
assert.ok(
|
|
fieldRows.length >= 15,
|
|
`Expected at least 15 documented fields, found ${fieldRows.length}`
|
|
);
|
|
});
|
|
|
|
test('contains example configurations', () => {
|
|
assert.ok(
|
|
content.includes('## Example Configurations'),
|
|
'planning-config.md must contain an "Example Configurations" section'
|
|
);
|
|
// Verify at least one JSON code block with a model_profile key
|
|
assert.ok(
|
|
content.includes('"model_profile"'),
|
|
'Example configurations must include model_profile'
|
|
);
|
|
});
|
|
|
|
test('contains field interactions section', () => {
|
|
assert.ok(
|
|
content.includes('## Field Interactions'),
|
|
'planning-config.md must contain a "Field Interactions" section'
|
|
);
|
|
});
|
|
|
|
test('every CONFIG_DEFAULTS key appears in the doc', () => {
|
|
// Extract CONFIG_DEFAULTS keys from config-loader.cjs source (moved from core.cjs by ADR-857 phase 2e)
|
|
const coreSource = fs.readFileSync(CORE_PATH, 'utf-8');
|
|
const defaultsMatch = coreSource.match(
|
|
// eslint-disable-next-line local/no-unbounded-quantifier -- parses this repo's own config-loader.cjs source, fixed-size author-controlled content
|
|
/const CONFIG_DEFAULTS\s*=\s*\{([\s\S]*?)\r?\n\};/
|
|
);
|
|
assert.ok(defaultsMatch, 'Could not find CONFIG_DEFAULTS in config-loader.cjs');
|
|
|
|
const body = defaultsMatch[1];
|
|
// Match property keys (word characters before the colon)
|
|
const keys = [...body.matchAll(/^\s*(\w+)\s*:/gm)].map(m => m[1]);
|
|
assert.ok(keys.length > 0, 'Could not extract any keys from CONFIG_DEFAULTS');
|
|
|
|
// CONFIG_DEFAULTS uses flat keys; the doc may use namespaced equivalents.
|
|
// Map flat keys to the namespace forms used in config.json and the doc.
|
|
const NAMESPACE_MAP = {
|
|
research: 'workflow.research',
|
|
plan_checker: 'workflow.plan_check',
|
|
verifier: 'workflow.verifier',
|
|
nyquist_validation: 'workflow.nyquist_validation',
|
|
ai_integration_phase: 'workflow.ai_integration_phase',
|
|
api_coverage_gate: 'workflow.api_coverage_gate',
|
|
text_mode: 'workflow.text_mode',
|
|
subagent_timeout: 'workflow.subagent_timeout',
|
|
branching_strategy: 'git.branching_strategy',
|
|
phase_branch_template: 'git.phase_branch_template',
|
|
milestone_branch_template: 'git.milestone_branch_template',
|
|
quick_branch_template: 'git.quick_branch_template',
|
|
security_enforcement: 'workflow.security_enforcement',
|
|
security_asvs_level: 'workflow.security_asvs_level',
|
|
security_block_on: 'workflow.security_block_on',
|
|
};
|
|
|
|
const missing = keys.filter(k => {
|
|
// Check both bare key and namespaced form
|
|
if (content.includes(`\`${k}\``)) return false;
|
|
const ns = NAMESPACE_MAP[k];
|
|
if (ns && content.includes(`\`${ns}\``)) return false;
|
|
return true;
|
|
});
|
|
assert.deepStrictEqual(
|
|
missing,
|
|
[],
|
|
`CONFIG_DEFAULTS keys missing from planning-config.md: ${missing.join(', ')}`
|
|
);
|
|
});
|
|
|
|
test('documents workflow namespace fields', () => {
|
|
const workflowFields = [
|
|
'workflow.research',
|
|
'workflow.plan_check',
|
|
'workflow.verifier',
|
|
'workflow.nyquist_validation',
|
|
'workflow.use_worktrees',
|
|
'workflow.subagent_timeout',
|
|
'workflow.text_mode',
|
|
];
|
|
const missing = workflowFields.filter(f => !content.includes(`\`${f}\``));
|
|
assert.deepStrictEqual(
|
|
missing,
|
|
[],
|
|
`Workflow fields missing from planning-config.md: ${missing.join(', ')}`
|
|
);
|
|
});
|
|
|
|
test('documents git namespace fields', () => {
|
|
const gitFields = [
|
|
'git.branching_strategy',
|
|
'git.base_branch',
|
|
'git.phase_branch_template',
|
|
'git.milestone_branch_template',
|
|
];
|
|
const missing = gitFields.filter(f => !content.includes(`\`${f}\``));
|
|
assert.deepStrictEqual(
|
|
missing,
|
|
[],
|
|
`Git fields missing from planning-config.md: ${missing.join(', ')}`
|
|
);
|
|
});
|
|
|
|
test('documents KNOWN_TOP_LEVEL internal fields not in CONFIG_DEFAULTS', () => {
|
|
// These fields are in KNOWN_TOP_LEVEL (core.cjs) and read by loadConfig()
|
|
// but not in CONFIG_DEFAULTS, so the CONFIG_DEFAULTS test doesn't cover them.
|
|
const internalFields = [
|
|
'model_overrides',
|
|
'agent_skills',
|
|
];
|
|
const missing = internalFields.filter(f => !content.includes(`\`${f}\``));
|
|
assert.deepStrictEqual(
|
|
missing,
|
|
[],
|
|
`KNOWN_TOP_LEVEL internal fields missing from planning-config.md: ${missing.join(', ')}`
|
|
);
|
|
});
|
|
|
|
test('documents sub_repos field (CONFIG_DEFAULTS, no namespace form)', () => {
|
|
// sub_repos is in CONFIG_DEFAULTS but has no NAMESPACE_MAP entry
|
|
// (it uses a planning.sub_repos nested lookup but is documented as a
|
|
// top-level field). Verify it explicitly since the NAMESPACE_MAP path
|
|
// would silently skip it.
|
|
assert.ok(
|
|
content.includes('`sub_repos`'),
|
|
'planning-config.md must document the sub_repos field'
|
|
);
|
|
});
|
|
|
|
test('documents features.thinking_partner field', () => {
|
|
// features.thinking_partner is in VALID_CONFIG_KEYS (config.cjs) and
|
|
// used by discuss-phase.md and plan-phase.md for conditional extended
|
|
// thinking at workflow decision points.
|
|
assert.ok(
|
|
content.includes('`features.thinking_partner`'),
|
|
'planning-config.md must document the features.thinking_partner field'
|
|
);
|
|
});
|
|
|
|
test('mode field documents correct allowed values', () => {
|
|
// mode values are "interactive" and "yolo" per templates/config.json
|
|
// and workflows/new-project.md — NOT "code-first"/"plan-first"/"hybrid"
|
|
assert.ok(
|
|
content.includes('"interactive"') && content.includes('"yolo"'),
|
|
'mode field must document "interactive" and "yolo" as allowed values'
|
|
);
|
|
assert.ok(
|
|
!content.includes('"code-first"'),
|
|
'mode field must NOT document non-existent "code-first" value'
|
|
);
|
|
});
|
|
|
|
test('discuss_mode field documents correct allowed values', () => {
|
|
// discuss_mode values are "discuss" and "assumptions" per workflows/settings.md
|
|
// NOT "auto" or "analyze" (those are CLI flags, not config values)
|
|
assert.ok(
|
|
content.includes('"assumptions"'),
|
|
'discuss_mode must document "assumptions" as an allowed value'
|
|
);
|
|
});
|
|
|
|
test('documents plan_checker alias for workflow.plan_check', () => {
|
|
// plan_checker is the flat-key form in CONFIG_DEFAULTS; workflow.plan_check
|
|
// is the canonical namespaced form. The doc should mention the alias.
|
|
assert.ok(
|
|
content.includes('`workflow.plan_check`'),
|
|
'planning-config.md must document workflow.plan_check'
|
|
);
|
|
assert.ok(
|
|
content.includes('plan_checker'),
|
|
'planning-config.md must mention the plan_checker flat-key alias'
|
|
);
|
|
});
|
|
|
|
test('workflow.test_command is documented in planning-config.md (#1216)', () => {
|
|
assert.ok(
|
|
content.includes('`workflow.test_command`'),
|
|
'planning-config.md must document workflow.test_command'
|
|
);
|
|
// Must appear specifically in the Complete Field Reference section
|
|
const completeRefSection = content.slice(content.indexOf('## Complete Field Reference'));
|
|
assert.ok(
|
|
completeRefSection.includes('`workflow.test_command`'),
|
|
'planning-config.md Complete Field Reference must include workflow.test_command'
|
|
);
|
|
});
|
|
|
|
test('workflow.build_command is documented in planning-config.md (#1216)', () => {
|
|
assert.ok(
|
|
content.includes('`workflow.build_command`'),
|
|
'planning-config.md must document workflow.build_command'
|
|
);
|
|
// Must appear specifically in the Complete Field Reference section
|
|
const completeRefSection = content.slice(content.indexOf('## Complete Field Reference'));
|
|
assert.ok(
|
|
completeRefSection.includes('`workflow.build_command`'),
|
|
'planning-config.md Complete Field Reference must include workflow.build_command'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Capability-enum doc parity (#3303) ─────────────────────────────────────
|
|
|
|
describe('capability-enum doc parity (#3303)', () => {
|
|
const CAPABILITY_PATH = path.join(
|
|
__dirname, '..', 'capabilities', 'code-review', 'capability.json'
|
|
);
|
|
|
|
let docContent;
|
|
let capability;
|
|
|
|
before(() => {
|
|
docContent = fs.readFileSync(REFERENCE_PATH, 'utf-8');
|
|
capability = JSON.parse(fs.readFileSync(CAPABILITY_PATH, 'utf-8'));
|
|
});
|
|
|
|
/**
|
|
* Extract a single Complete-Field-Reference table row by key and split it into
|
|
* trimmed cells: ['', '`key`', type, default, allowedValues, description, ''].
|
|
* Row-scoping keeps unrelated wording elsewhere in the doc from satisfying
|
|
* (or breaking) the parity assertions.
|
|
*/
|
|
function docRow(key) {
|
|
const line = docContent
|
|
.split(/\r?\n/)
|
|
.find(l => l.startsWith(`| \`${key}\` |`));
|
|
assert.ok(line, `planning-config.md must have a table row for \`${key}\``);
|
|
return line.split('|').map(c => c.trim());
|
|
}
|
|
|
|
test('workflow.code_review_depth allowed values match the capability registry (#3303)', () => {
|
|
const spec = capability.config && capability.config['workflow.code_review_depth'];
|
|
assert.ok(
|
|
spec && Array.isArray(spec.values),
|
|
'capabilities/code-review/capability.json must declare workflow.code_review_depth values'
|
|
);
|
|
|
|
const allowedCell = docRow('workflow.code_review_depth')[4];
|
|
const docValues = [...allowedCell.matchAll(/"([^"]+)"/g)].map(m => m[1]);
|
|
assert.ok(
|
|
docValues.length > 0,
|
|
`workflow.code_review_depth Allowed-Values cell must list quoted values, got: ${allowedCell}`
|
|
);
|
|
assert.deepStrictEqual(
|
|
[...docValues].sort(),
|
|
[...spec.values].sort(),
|
|
`planning-config.md workflow.code_review_depth allowed values (${docValues.join(', ')}) ` +
|
|
`must exactly match what config-set accepts per capability.json (${spec.values.join(', ')})`
|
|
);
|
|
});
|
|
|
|
test('workflow.code_review_depth default matches the capability registry (#3303)', () => {
|
|
const spec = capability.config && capability.config['workflow.code_review_depth'];
|
|
assert.ok(spec, 'capability.json must declare workflow.code_review_depth');
|
|
const defaultCell = docRow('workflow.code_review_depth')[3];
|
|
const [docDefault] = [...defaultCell.matchAll(/"([^"]+)"/g)].map(m => m[1]);
|
|
assert.strictEqual(
|
|
docDefault,
|
|
spec.default,
|
|
`planning-config.md workflow.code_review_depth default must match capability.json default (${spec.default})`
|
|
);
|
|
});
|
|
|
|
test('agent_skills row documents the array-of-strings form (#3303)', () => {
|
|
const cells = docRow('agent_skills');
|
|
const allowedCell = cells[4];
|
|
assert.ok(
|
|
/\[\s*"<skill-set>"\s*,/.test(allowedCell),
|
|
`agent_skills Allowed-Values cell must show the array-of-strings form, got: ${allowedCell}`
|
|
);
|
|
assert.ok(
|
|
/array/i.test(cells[5]),
|
|
'agent_skills description must explain the array form assigns multiple skill sets to one agent type'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── CONFIGURATION.md parity (#1216) ────────────────────────────────────────
|
|
|
|
describe('CONFIGURATION.md parity (#1216)', () => {
|
|
const DOCS_CONFIG_PATH = path.join(__dirname, '..', 'docs', 'CONFIGURATION.md');
|
|
const SETTINGS_ADVANCED_PATH = path.join(
|
|
__dirname,
|
|
'..',
|
|
'gsd-core',
|
|
'workflows',
|
|
'settings-advanced.md',
|
|
);
|
|
|
|
let docsContent;
|
|
let settingsAdvancedContent;
|
|
|
|
before(() => {
|
|
docsContent = fs.readFileSync(DOCS_CONFIG_PATH, 'utf-8');
|
|
settingsAdvancedContent = fs.readFileSync(SETTINGS_ADVANCED_PATH, 'utf-8');
|
|
});
|
|
|
|
test('CONFIGURATION.md workflow.subagent_timeout describes milliseconds, not seconds (#1216)', () => {
|
|
assert.ok(
|
|
docsContent.includes('millisecond') || docsContent.includes('milliseconds'),
|
|
'CONFIGURATION.md workflow.subagent_timeout must use the word "millisecond(s)"'
|
|
);
|
|
const row = tableRowForKey(docsContent, 'workflow.subagent_timeout');
|
|
assert.ok(row, 'CONFIGURATION.md must have a table row for workflow.subagent_timeout');
|
|
assert.notEqual(
|
|
row[2].replace(/`/g, ''),
|
|
'600',
|
|
'CONFIGURATION.md workflow.subagent_timeout default must not be 600 (that was the seconds default)'
|
|
);
|
|
});
|
|
|
|
test('CONFIGURATION.md workflow.subagent_timeout default is 300000 (#1216)', () => {
|
|
// Row-scoped: the actual table row for workflow.subagent_timeout must contain 300000
|
|
const row = tableRowForKey(docsContent, 'workflow.subagent_timeout');
|
|
assert.ok(row, 'CONFIGURATION.md must have a table row for workflow.subagent_timeout');
|
|
assert.equal(
|
|
row[2].replace(/`/g, ''),
|
|
'300000',
|
|
'CONFIGURATION.md workflow.subagent_timeout table row must have default 300000'
|
|
);
|
|
});
|
|
|
|
test('settings-advanced.md subagent_timeout prompt says milliseconds, not seconds (#1216)', () => {
|
|
assert.ok(
|
|
settingsAdvancedContent.includes('millisecond') ||
|
|
settingsAdvancedContent.includes('milliseconds'),
|
|
'settings-advanced.md subagent_timeout prompt must use "millisecond(s)"'
|
|
);
|
|
assert.ok(
|
|
!settingsAdvancedContent.includes('Integer number of seconds'),
|
|
'settings-advanced.md must NOT say "Integer number of seconds" for subagent_timeout'
|
|
);
|
|
});
|
|
|
|
test('settings-advanced.md subagent_timeout prompt default is 300000 not 600 (#1216)', () => {
|
|
assert.ok(
|
|
!settingsAdvancedContent.match(/value or 600/),
|
|
'settings-advanced.md must NOT show 600 as the subagent_timeout default'
|
|
);
|
|
assert.ok(
|
|
settingsAdvancedContent.includes('300000'),
|
|
'settings-advanced.md must show 300000 as the subagent_timeout default'
|
|
);
|
|
});
|
|
|
|
test('settings-advanced.md parse-default list must NOT show subagent_timeout default 600 (#1216)', () => {
|
|
// Line 53 regression: the parse-default list item must use 300000, not 600
|
|
assert.ok(
|
|
!(/`workflow\.subagent_timeout`[^\r\n]*default:[^\n]*`?600`?/.test(settingsAdvancedContent)),
|
|
'settings-advanced.md must NOT list subagent_timeout default as 600 (stale seconds default)'
|
|
);
|
|
});
|
|
|
|
test('settings-advanced.md confirmation table must NOT label subagent_timeout as {seconds} (#1216)', () => {
|
|
// Line 754 regression: the confirmation table row must say {milliseconds}, not {seconds}
|
|
assert.ok(
|
|
!(/workflow\.subagent_timeout\s*\|\s*\{seconds\}/.test(settingsAdvancedContent)),
|
|
'settings-advanced.md confirmation table must NOT label subagent_timeout as {seconds}'
|
|
);
|
|
});
|
|
|
|
test('settings-advanced.md bash example must NOT use subagent_timeout 900 (#1216)', () => {
|
|
// Line 501 regression: the bash example must not show the stale 900 value
|
|
assert.ok(
|
|
!(/subagent_timeout 900\b/.test(settingsAdvancedContent)),
|
|
'settings-advanced.md bash example must NOT set subagent_timeout to 900 (stale seconds value)'
|
|
);
|
|
});
|
|
|
|
test('CONFIGURATION.md review.models rows do not show shell command examples (#1216)', () => {
|
|
// The Integration Settings section (around line 195-202) used to have
|
|
// shell-command examples like "codex exec --model gpt-5". After the fix
|
|
// those rows must describe model ids, not full commands.
|
|
assert.ok(
|
|
!docsContent.includes('"codex exec --model'),
|
|
'CONFIGURATION.md must NOT contain "codex exec --model" shell command example'
|
|
);
|
|
assert.ok(
|
|
!docsContent.includes('"opencode run --model'),
|
|
'CONFIGURATION.md must NOT contain "opencode run --model" shell command example'
|
|
);
|
|
assert.ok(
|
|
!docsContent.includes('"gemini -m gemini'),
|
|
'CONFIGURATION.md must NOT contain "gemini -m gemini..." shell command example'
|
|
);
|
|
});
|
|
|
|
test('workflow.test_command is documented in CONFIGURATION.md (#1216)', () => {
|
|
assert.ok(
|
|
docsContent.includes('`workflow.test_command`'),
|
|
'CONFIGURATION.md must document workflow.test_command'
|
|
);
|
|
});
|
|
|
|
test('workflow.build_command is documented in CONFIGURATION.md (#1216)', () => {
|
|
assert.ok(
|
|
docsContent.includes('`workflow.build_command`'),
|
|
'CONFIGURATION.md must document workflow.build_command'
|
|
);
|
|
});
|
|
});
|
|
|
|
|
|
// ────────────────────────────────────────────────────────────────────────
|
|
// Folded from tests/enh-1494-workflow-config-key-docs.test.cjs — consolidation epic #1969 (B3 #1972)
|
|
// ────────────────────────────────────────────────────────────────────────
|
|
{
|
|
const { describe: __foldDescribe } = require('node:test');
|
|
__foldDescribe("folded:enh-1494-workflow-config-key-docs (consolidation epic #1969 B3 #1972)", () => {
|
|
'use strict';
|
|
|
|
/**
|
|
* Parity assertions for #1494: workflow config keys that are consumed by
|
|
* planning-pipeline code must be (a) accepted by VALID_CONFIG_KEYS and
|
|
* (b) documented in references/planning-config.md.
|
|
*
|
|
* Per DEFECT.GENERATIVE-FIX: a shared constant / key-list that spans two
|
|
* surfaces requires a parity assertion that fails when the surfaces diverge.
|
|
*/
|
|
|
|
const { describe, test, before, afterEach } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs');
|
|
|
|
const CONFIG_SCHEMA_PATH = path.join(__dirname, '..', 'gsd-core', 'bin', 'lib', 'config-schema.cjs');
|
|
const PLANNING_CONFIG_PATH = path.join(__dirname, '..', 'gsd-core', 'references', 'planning-config.md');
|
|
|
|
describe('VALID_CONFIG_KEYS parity — #1494 orphan-undocumented keys', () => {
|
|
const { VALID_CONFIG_KEYS } = require(CONFIG_SCHEMA_PATH);
|
|
|
|
test('workflow.mvp_mode is in VALID_CONFIG_KEYS', () => {
|
|
assert.ok(
|
|
VALID_CONFIG_KEYS.has('workflow.mvp_mode'),
|
|
'workflow.mvp_mode is read by config-loader.cts and plan-phase.md but was missing from VALID_CONFIG_KEYS (#1494)'
|
|
);
|
|
});
|
|
|
|
test('workflow.code_review_command is in VALID_CONFIG_KEYS', () => {
|
|
assert.ok(
|
|
VALID_CONFIG_KEYS.has('workflow.code_review_command'),
|
|
'workflow.code_review_command must be in VALID_CONFIG_KEYS'
|
|
);
|
|
});
|
|
|
|
test('workflow.plan_chunked is in VALID_CONFIG_KEYS', () => {
|
|
assert.ok(
|
|
VALID_CONFIG_KEYS.has('workflow.plan_chunked'),
|
|
'workflow.plan_chunked must be in VALID_CONFIG_KEYS'
|
|
);
|
|
});
|
|
|
|
test('workflow.test_command is in VALID_CONFIG_KEYS', () => {
|
|
assert.ok(
|
|
VALID_CONFIG_KEYS.has('workflow.test_command'),
|
|
'workflow.test_command must be in VALID_CONFIG_KEYS'
|
|
);
|
|
});
|
|
|
|
test('workflow.build_command is in VALID_CONFIG_KEYS', () => {
|
|
assert.ok(
|
|
VALID_CONFIG_KEYS.has('workflow.build_command'),
|
|
'workflow.build_command must be in VALID_CONFIG_KEYS'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('config-set accepts workflow.mvp_mode (#1494)', () => {
|
|
let tmpDir;
|
|
afterEach(() => { if (tmpDir) cleanup(tmpDir); });
|
|
|
|
test('config-set workflow.mvp_mode true succeeds and stores the value', () => {
|
|
tmpDir = createTempProject();
|
|
const result = runGsdTools(['config-set', 'workflow.mvp_mode', 'true'], tmpDir);
|
|
assert.ok(
|
|
result.success,
|
|
`config-set workflow.mvp_mode must succeed; got:\nstdout: ${result.output}\nstderr: ${result.error}`
|
|
);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.strictEqual(parsed.updated, true, 'response must have updated:true');
|
|
assert.strictEqual(parsed.key, 'workflow.mvp_mode', 'response must echo the key');
|
|
});
|
|
|
|
test('config-set workflow.mvp_mode false succeeds', () => {
|
|
tmpDir = createTempProject();
|
|
const result = runGsdTools(['config-set', 'workflow.mvp_mode', 'false'], tmpDir);
|
|
assert.ok(
|
|
result.success,
|
|
`config-set workflow.mvp_mode false must succeed; got:\nstdout: ${result.output}\nstderr: ${result.error}`
|
|
);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.strictEqual(parsed.updated, true);
|
|
});
|
|
});
|
|
|
|
// allow-test-rule: source-text-is-the-product — planning-config.md is the deployed reference contract (#1494)
|
|
describe('planning-config.md documents #1494 keys', () => {
|
|
let content;
|
|
before(() => { content = fs.readFileSync(PLANNING_CONFIG_PATH, 'utf-8'); });
|
|
|
|
const KEYS = [
|
|
'workflow.mvp_mode',
|
|
'workflow.code_review_command',
|
|
'workflow.plan_chunked',
|
|
'workflow.test_command',
|
|
'workflow.build_command',
|
|
];
|
|
|
|
for (const key of KEYS) {
|
|
test(`planning-config.md documents \`${key}\``, () => {
|
|
assert.ok(
|
|
content.includes(`\`${key}\``),
|
|
`planning-config.md must document \`${key}\` (#1494)`
|
|
);
|
|
});
|
|
|
|
test(`\`${key}\` appears in the Complete Field Reference section`, () => {
|
|
const refSection = content.slice(content.indexOf('## Complete Field Reference'));
|
|
assert.ok(
|
|
refSection.includes(`\`${key}\``),
|
|
`planning-config.md Complete Field Reference must include \`${key}\` (#1494)`
|
|
);
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|