From 34e4c8d13be5d1a62637235393b80957c904ed8f Mon Sep 17 00:00:00 2001 From: Brad Groux <3053586+BradGroux@users.noreply.github.com> Date: Sat, 25 Jul 2026 06:31:50 -0500 Subject: [PATCH] fix: reject ambiguous focused test wrappers (#1060) --- AGENTS.md | 7 ++++--- CHANGELOG.md | 7 ++++--- CONTRIBUTING.md | 5 +++-- prompt-registry/bug-triage.md | 2 +- prompt-registry/feature-development.md | 2 +- prompt-registry/task-completion.md | 2 +- scripts/check-delivery-cadence.mjs | 3 ++- scripts/check-delivery-cadence.test.mjs | 24 +++++++++++++++++++++++- 8 files changed, 39 insertions(+), 13 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 582ff053..31ff6423 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -118,9 +118,10 @@ Do not run `npm install`, `yarn`, or `bun install`. If lockfile conflicts arise, - During implementation, run the narrowest useful loop: type-check touched packages, lint changed files, and run focused tests for changed behavior and high-risk edges. - Run focused Vitest slices with - `pnpm --filter exec vitest run `. Do not use the ambiguous - `pnpm --filter test -- --run ` form; package wrappers can ignore that - file boundary and expand into the entire package suite. + `pnpm --filter exec vitest run `. Do not use + `pnpm --filter test -- ` or + `pnpm --filter test -- --run `; package wrappers can ignore that file + boundary and expand into the entire package suite. - Do not rerun an unchanged passing gate after documentation, comments, or formatting-only edits. Rerun only the checks affected by the later change. - Use the complete workspace suite once at an explicit integration, critical-security, or release diff --git a/CHANGELOG.md b/CHANGELOG.md index 39e2cf65..4805b8de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -121,9 +121,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Standardized focused Vitest verification on direct `pnpm --filter exec vitest run ` invocation. The dependency-free delivery cadence checker now rejects active guidance that - presents the ambiguous package `test -- --run` wrapper as focused - verification, preventing an intended file slice from silently expanding into - an entire package suite (#1044). + presents either of the ambiguous package `test -- ` or + `test -- --run ` wrappers as focused verification, preventing + an intended file slice from silently expanding into an entire package suite + (#1044, #1058). - Reworked GitHub release notes to use natural page-width prose and concise lists instead of ragged hanging-indent blocks or unmarked stacks of bold-led paragraphs. The release-format gate now rejects long wrapping list items, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9fd8a156..39a01a22 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,8 +83,9 @@ veritas-kanban/ ``` Use direct `exec vitest run` invocation for exact-file slices. Do not use - `pnpm --filter test -- --run ` as a focused command; - package wrappers can ignore that file boundary and expand into the entire + `pnpm --filter test -- ` or + `pnpm --filter test -- --run ` as a focused command. + Package wrappers can ignore that file boundary and expand into the entire package suite. Build `@veritas-kanban/shared` first and type-check its known consumers when diff --git a/prompt-registry/bug-triage.md b/prompt-registry/bug-triage.md index 9f1c9130..1662c061 100644 --- a/prompt-registry/bug-triage.md +++ b/prompt-registry/bug-triage.md @@ -46,7 +46,7 @@ integration, critical-security, or release milestone. vk begin # ... investigate and fix ... pnpm --filter typecheck -pnpm --filter test -- +pnpm --filter exec vitest run vk done "Fixed: . Solution: " ```` diff --git a/prompt-registry/feature-development.md b/prompt-registry/feature-development.md index abacdf6b..10404335 100644 --- a/prompt-registry/feature-development.md +++ b/prompt-registry/feature-development.md @@ -48,7 +48,7 @@ Implement feature: vk begin # ... implement ... pnpm --filter typecheck -pnpm --filter test -- +pnpm --filter exec vitest run vk done "Implemented : " ```` diff --git a/prompt-registry/task-completion.md b/prompt-registry/task-completion.md index d1edb4b7..ac8566ed 100644 --- a/prompt-registry/task-completion.md +++ b/prompt-registry/task-completion.md @@ -47,7 +47,7 @@ Write a brief summary covering: ```bash # Run the narrowest useful verification from AGENTS.md pnpm --filter typecheck -pnpm --filter test -- +pnpm --filter exec vitest run # Complete the task vk done "" diff --git a/scripts/check-delivery-cadence.mjs b/scripts/check-delivery-cadence.mjs index 184694f1..0c9d61bb 100644 --- a/scripts/check-delivery-cadence.mjs +++ b/scripts/check-delivery-cadence.mjs @@ -267,7 +267,8 @@ export function findUnsafeCanonicalCadenceStatements(files) { export function findAmbiguousFocusedTestCommands(files) { const violations = []; - const pattern = /\bpnpm\s+--filter\s+\S+\s+test\s+--\s+--run\b/gi; + const pattern = + /\bpnpm\s+(?:--filter(?:=|\s+)|-F\s+)\S+\s+(?:run\s+)?test\s+--(?=\s)/gi; for (const [file, content] of Object.entries(files)) { const normalized = normalizeWhitespace(content); diff --git a/scripts/check-delivery-cadence.test.mjs b/scripts/check-delivery-cadence.test.mjs index b62a073b..68985191 100644 --- a/scripts/check-delivery-cadence.test.mjs +++ b/scripts/check-delivery-cadence.test.mjs @@ -202,6 +202,28 @@ test('rejects package test wrappers that can expand an intended file slice', () ); }); +test('rejects package test wrappers with a direct file argument', () => { + for (const command of [ + 'pnpm --filter @veritas-kanban/server test -- src/example.test.ts', + 'pnpm --filter=@veritas-kanban/server test -- src/example.test.ts', + 'pnpm -F @veritas-kanban/server test -- src/example.test.ts', + 'pnpm --filter @veritas-kanban/server run test -- src/example.test.ts', + ]) { + assert.deepEqual( + findAmbiguousFocusedTestCommands({ + 'prompt-registry/example.md': `Run \`${command}\`.`, + }), + [ + { + file: 'prompt-registry/example.md', + message: + 'focused Vitest files must use direct `pnpm --filter exec vitest run ` invocation', + }, + ] + ); + } +}); + test('allows direct Vitest exact-file invocation', () => { assert.deepEqual( findAmbiguousFocusedTestCommands({ @@ -216,7 +238,7 @@ test('allows an explicit warning against the ambiguous package test wrapper', () assert.deepEqual( findAmbiguousFocusedTestCommands({ 'AGENTS.md': - 'Do not use `pnpm --filter test -- --run ` for focused verification.', + 'Do not use `pnpm --filter test -- ` or `pnpm --filter test -- --run ` for focused verification.', }), [] );