feat(01KVS2MG): Authoring refuses a story whose vitest target cannot resolve to a runnable package#440
Merged
Conversation
…le package Authoring and scan-time discipline now reject a story whose vitest verification target has no package.json between it and the repo root (e.g. a wrong-prefix `mcp-server/tests/x.test.ts` instead of `plugins/flow/mcp-server/tests/x.test.ts`), with a new `unresolvable-test-target` violation that names the offending target — before any build is wasted. - Extract findPackageRoot (and its workspace helpers) from tools/run-reviewer-session.ts into lib/find-package-root.ts so the author/scan-time check and the review-time vitest check share ONE walk and cannot diverge. run-reviewer-session.ts re-exports findPackageRoot so it stays importable by name. - discipline-resolvability.ts runs the shared walk after the existing shape check; the test FILE need not exist (the build creates it), only an enclosing package must resolve — so a not-yet-existing test file under a real package still passes. - Existing non-runnable-test-target shape check and artifact/cited-source existence checks unchanged (no regression). - Tests cover: wrong-prefix refusal, not-yet-existing-file pass, shape-invalid still non-runnable-test-target. Fixtures across the suite seed a workspace-root package.json so shape-valid vitest targets resolve. - Rebuilt committed dist bundle. Claude-Session: https://claude.ai/code/session_01E5VyKQMGJSL6fRfRmCzuvs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Authoring and scan-time planning-discipline now refuse a story whose
vitest:verification target cannot resolve to a runnable package — catching wrong-path test markers BEFORE a build is wasted.The validator already existence-checked cited sources and
artifact:targets, butvitest:targets were only shape-checked (isRunnableTestTarget). That left a gap: a wrong-prefix target likemcp-server/tests/x.test.ts(instead ofplugins/flow/mcp-server/tests/x.test.ts) is a perfectly valid shape but has no package above it, so the build/review round was doomed yet still started.How
findPackageRoot(and its workspace helpershasLocalVitest,findVitestInWorkspaceMembers,findWorkspaceYamlInSubtree) fromtools/run-reviewer-session.tsinto a new shared liblib/find-package-root.ts.run-reviewer-session.tsnow imports and re-exportsfindPackageRootby name, so existing callers (and an upcoming story) keep their import path. The review-time vitest check and the new author/scan-time check now share one walk and cannot diverge.discipline-resolvability.tsruns the sharedfindPackageRootwalk after the existing shape check, for eachvitest:target. On no package root, it pushes a newunresolvable-test-targetviolation naming the offending target. This validator backs both author time (writeNativeStory) and scan time (scanSources).unresolvable-test-targetcode added to theDisciplineViolationReasonunion.Acceptance criteria
vitest:target is refused withunresolvable-test-targetnaming the target; nothing is written/materialised (the gate throws before any build). Covered by the new resolvability tests indiscipline-runnable-test-kind.test.ts.stat-confirmed absent, yet zero violations).__tests__/, not.test/.spec) still fails with the EXISTINGnon-runnable-test-targetviolation, and the new resolvability check does NOT double-report. No regression.Test / build
src/validators/__tests__/discipline-runnable-test-kind.test.ts(27 tests).package.jsonso the target resolves (the real monorepo always has one).dist/index.js,dist/cli.js) — no drift..flow/state/**touched.https://claude.ai/code/session_01E5VyKQMGJSL6fRfRmCzuvs