* test(#4257): W002 harvest precision + workstream-scoped warning regression rows Tests-only RED commit: A-rows pin the command-mention/code-span harvest precision on statePhaseTokens, B-rows drive W002 under root and workstream scope (scope clause asserted, root grammar byte-identical), C-rows pin the additive workstream snapshot field. All fail on next; fix follows. * fix(#4257): harvest only prose phase references; W002 names its workstream scope Sub-defect (a): the statePhaseTokens harvest was the verbatim #3309 relocation of verify.cts's unanchored, markdown-blind scan ([Pp]hase\s+(TOKEN) over the raw file), so GSD's own command names (/gsd-execute-phase 5, bare or quoted) and any token inside a code span/fenced block were harvested as phase references and fired W002 on ledger rows. Now strips fenced blocks then inline spans via the canonical markdown-sectionizer seam (#2365 composition order) and matches with a left word boundary (?<![-\w]) so hyphen- or word-suffixed carriers are mentions, not references. Pinned tradeoff: a genuine reference written in backticks stops counting (a quoted literal is not a reference). Sub-defect (b): the valid set is workstream-scoped by construction (planningPaths under GSD_WORKSTREAM; per-workstream numbering is deliberate), but the message claimed 'only phases 1, 2 are declared' unqualified. New additive PlanningSnapshot.workstream field, sourced from planning-workspace's new resolveEnvWorkstream() — the ONE env discriminator planningDir itself applies — so the clause cannot disagree with the base the reads used. Root scope keeps the byte-identical message; the checker's scope is unchanged. * test(#4257): close the B2 quoted-literal code span (fixture typo) The B2 fixture wrote a single opening backtick — an unterminated span is literal text per CommonMark, so its content is prose and W002 correctly fired on it. The test's name, the A3 snapshot-level twin, and the B2 matrix row all intend a closed span; pre-fix this was indistinguishable because the unanchored harvest fired either way. * chore(#4257): changeset fragment (pr number to backfill) * chore(#4257): backfill PR number in changeset --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -175,6 +175,17 @@ const RULE_W002: Rule = {
|
||||
);
|
||||
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
// #4257: the valid set above is WORKSTREAM-scoped by construction (every
|
||||
// source field is read from `planningPaths(cwd)`'s base, which resolves
|
||||
// under `.planning/workstreams/<active-ws>/`), and per-workstream phase
|
||||
// numbering is deliberate — so under a workstream the message must NAME
|
||||
// that scope rather than make an unqualified project-wide claim (a
|
||||
// reference to a phase declared only in a SIBLING workstream reads as
|
||||
// "undeclared" against this list; that is the scope speaking, not drift).
|
||||
// Root scope (`workstream === null`, flat or root-planning projects)
|
||||
// keeps the byte-identical message — no clause is appended when none
|
||||
// applies.
|
||||
const scopeClause = snapshot.workstream ? ` in workstream ${snapshot.workstream}` : '';
|
||||
for (const ref of snapshot.statePhaseTokens.value) {
|
||||
const dotIdx = ref.indexOf('.');
|
||||
const head = dotIdx === -1 ? ref : ref.slice(0, dotIdx);
|
||||
@@ -184,7 +195,7 @@ const RULE_W002: Rule = {
|
||||
diagnostics.push({
|
||||
code: 'W002',
|
||||
severity: SEVERITY.WARNING,
|
||||
message: `STATE.md references phase ${ref}, but only phases ${sortedValid.join(', ')} are declared`,
|
||||
message: `STATE.md references phase ${ref}, but only phases ${sortedValid.join(', ')} are declared${scopeClause}`,
|
||||
remedy: adviseRemedy(
|
||||
'Review STATE.md manually before changing it; /gsd-health --repair will not overwrite an existing STATE.md for phase mismatches',
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user