fix(3259): non-mutating --help guard for native query handlers (#3272)

* fix(3259): non-mutating --help guard for native query handlers; reject --help as milestone version

Adds a dispatcher-level guard in query-dispatch.ts that short-circuits
to a non-mutating help stub whenever --help/-h appears in args destined
for a native mutating handler (fail-closed by default). Adds defense-
in-depth in milestoneComplete to reject --help/-h as a version value
before any disk write. Regression tests cover: per-handler --help guard,
registry-driven invariant across all mutating commands, handler-level
GSDError for both flags, and preservation of the #3019 CJS fallback
contract.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: add changeset fragment for #3272

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-08 23:53:27 -04:00
committed by GitHub
parent ecd57e622c
commit 288b3b4170
5 changed files with 300 additions and 1 deletions

View File

@@ -1781,6 +1781,14 @@ export const milestoneComplete: QueryHandler = async (args, projectDir, workstre
if (!version) {
throw new GSDError('version required for milestone complete (e.g., v1.0)', ErrorClassification.Validation);
}
// #3259: defense-in-depth — reject --help / -h as a version value before
// any disk write, regardless of whether the dispatcher guard intercepted first.
if (version === '--help' || version === '-h') {
throw new GSDError(
`"${version}" is not a valid milestone version; see \`gsd-sdk query --help\` for command list`,
ErrorClassification.Validation,
);
}
assertNoNullBytes(version, 'version');
const nameOpt = parseMultiwordArg(args, 'name');