fix(plan-eng-review): register the structure question id so never-ask can fire

The complexity gate's Original/Smaller arrangement question had no
registered question_id, so each run invented a per-plan slug (one install
logged ten different ids for it). --check matches ids exactly, so a stored
never-ask could never fire and the question was asked every time.

- Register plan-eng-review-structure as a two-way routing question.
- The template names that exact id and says AUTO_DECIDE picks the
  recommended arrangement; the preamble's check-first rule does the rest.
  Wording is byte-neutral against the parity budget and the per-host pins.
- --check falls back to $GSTACK_HOME/global-question-preferences.json, the
  file the question-preference hook already reads, when the project file
  has no entry for the id, so one setting covers every repo and both
  layers agree. A project entry still wins, the one-way and split-chain
  guards run first, a malformed or non-object global file is ignored with
  a NOTE, and --write stays per-project.
- Tests for the fallback and the template contract; two wording pins
  updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit fb0334eb5c)
This commit is contained in:
Trevor Bezdek authored and garrytan committed 2026-10-19 18:30:44 +00:00
1 parent 9cf105ccff
commit 58d99ddaae
7 files changed
+97 -16

No files matched your search

+51
View File
@@ -132,6 +132,57 @@ describe('--check with preferences set', () => {
});
});
// The global file ($GSTACK_HOME/global-question-preferences.json, the same file
// the question-preference hook reads) is a hand-edited fallback for --check
// only: one setting covers every project, a project entry for the same id
// wins, and the one-way / split-chain guards still run.
describe('--check global preference fallback', () => {
function plantGlobal(contents: string) {
fs.writeFileSync(path.join(tmpHome, 'global-question-preferences.json'), contents);
}
test('global never-ask with no project entry → AUTO_DECIDE', () => {
plantGlobal(JSON.stringify({ 'plan-eng-review-structure': 'never-ask' }));
const r = run('--check', 'plan-eng-review-structure');
expect(r.status).toBe(0);
expect(r.stdout.trim()).toBe('AUTO_DECIDE');
});
test('project entry wins over the global entry', () => {
plantGlobal(JSON.stringify({ 'plan-eng-review-structure': 'never-ask' }));
run('--write', JSON.stringify({ question_id: 'plan-eng-review-structure', preference: 'always-ask', source: 'plan-tune' }));
const r = run('--check', 'plan-eng-review-structure');
expect(r.stdout.trim()).toBe('ASK_NORMALLY');
});
test('global never-ask on a one-way id → ASK_NORMALLY with safety note', () => {
plantGlobal(JSON.stringify({ 'ship-test-failure-triage': 'never-ask' }));
const r = run('--check', 'ship-test-failure-triage');
expect(r.stdout).toContain('ASK_NORMALLY');
expect(r.stdout).toContain('one-way door overrides');
});
test('global never-ask on a split-chain id → ASK_NORMALLY', () => {
plantGlobal(JSON.stringify({ 'plan-eng-review-split-option-a': 'never-ask' }));
const r = run('--check', 'plan-eng-review-split-option-a');
expect(r.stdout.split('\n')[0]).toBe('ASK_NORMALLY');
});
test.each(['{not json', 'null', '["never-ask"]'])('unusable global file %p is ignored with a note', (contents) => {
plantGlobal(contents);
const r = run('--check', 'plan-eng-review-structure');
expect(r.status).toBe(0);
expect(r.stdout.trim()).toBe('ASK_NORMALLY');
expect(r.stderr).toContain('global-question-preferences.json is unreadable');
});
test('--write stays per-project and never touches the global file', () => {
plantGlobal('{}');
run('--write', JSON.stringify({ question_id: 'plan-eng-review-structure', preference: 'never-ask', source: 'plan-tune' }));
expect(fs.readFileSync(path.join(tmpHome, 'global-question-preferences.json'), 'utf-8')).toBe('{}');
});
});
// #2024: the keyword net only fires when the question TEXT reaches the
// classifier. --summary-stdin pipes it (stdin, not argv — summaries carry
// quotes/newlines/shell metacharacters). Without the summary, an unregistered