test(organization): require rejection fixtures to prove their intended diagnostic - #122
Merged
Merged
Conversation
…d diagnostic Any OrganizationValidationError previously satisfied an invalid fixture, so a fixture could keep "passing" after drifting to reject for the wrong reason. Add an expected-rejections.json manifest naming the stable diagnostic each invalid fixture must produce, enforce it during corpus validation, and cover the mismatch and missing-expectation paths with focused tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
organization/fixtures/v1/invalid/expected-rejections.jsonnames the stable diagnostic each invalid organization fixture is meant to exercise (constraint label + a substring that must appear in the thrownOrganizationValidationError).scripts/lib/organization-validation.mjs:validateOrganizationnow loads that manifest, fails closed if its keys drift from the invalid-fixture corpus (missing or stale entries), and calls the new exportedassertExpectedRejectionon every invalid-fixture rejection so a fixture rejected for the wrong reason fails the check instead of silently passing because anyOrganizationValidationErrorwas thrown.test/organization-validation.test.mjs: focused coverage that (a) an unrelatedOrganizationValidationErrordoes not satisfy a fixture's expectation while a matching one does, (b) a fixture with no expectation fails closed, and (c) every fixture file underorganization/fixtures/v1/invalidhas a non-empty expected diagnostic in the manifest.Risk tier
Risk tier: 2 — quality-gate/test-only change (
scripts/lib/organization-validation.mjs,test/**, and a new fixture-expectations manifest). No schema semantics, product runtime behavior, or CI wiring changed; docs/skills/templates untouched so tier 1 doesn't apply.Docs housekeeping
Not applicable — no docs touched.
Verification
Also verified by hand that a deliberately mismatched manifest entry makes
validateOrganizationthrowrejected for a different diagnostic than its expected "..." constraintinstead of silently accepting the fixture.Test plan
npm run check:organization— 18/18 invalid fixtures match their expected diagnosticnode --test test/organization-validation.test.mjs— new tests passnpm run check— only the pre-existing, unrelatedrsync-dependent failures remain (verified present on the clean tree too)