Repository navigation
fix(validate): warn on references to non-existing requirements - #498
Merged
Merged
Conversation
A requirement whose references.requirement_ids named a requirement that does not exist passed `validate` silently, and `export` wrote the dangling ID as if it were valid. `validate` now reports each such reference as a warning (an error with --strict). The target may be a missing ID or a URN that is not part of the dataset. Reported as a warning for now so existing projects do not start failing CI; it should become an error in the next major version. Adds VALIDATE_0006 / SVC_VALIDATE_0006. Closes #490 Signed-off-by: Jimisola Laursen <jimisola@jimisola.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mt2FATTF7iprD7ygyHVxHW
jimisola
marked this pull request as ready for review
November 22, 2026 01:05
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.
Requested by Jimisola · project thread
Summary
Fixes #490.
validateacceptedreferences.requirement_idspointing at requirements that don't exist (exit 0, no output), andexportwrote the dangling ID as if it were valid.validatenow reports each such reference as a warning:(urn, id)is not a requirement in the loaded database: a missing ID, or a URN that is not part of the dataset (the repro in the issue).--strictpromotes it to exit 1 like the other coverage warnings. This should become an error in the next major version.RequirementsRepository.get_dangling_requirement_references()(LEFT JOIN query) used byValidateCommand._check_dangling_references. No schema change: the DB deliberately has no FK on the reference target, soexport/status/reportare untouched.VALIDATE_0006/SVC_VALIDATE_0006, openspec validate spec andusage.adocupdated.Note: because the check runs after filters and implementation-child exclusion, a reference to a requirement that was filtered out or lives only in an implementation child is also reported.
Test plan
validatewarns (exit 0),--strictfails (exit 1), valid reference intest_basicbaseline not flaggedhatch run dev:pytest tests/unit(897 passed), black, flake8test_standard/baseline: warning shown, exit 0;--strictexit 1validateoutput ontest_standardandtest_basicbaselines identical before/after.status,reportandexportcode paths are not touched.reqstool-demowas not run (notarget/artifacts here).—
Written by @jimisola together with Claude. I've reviewed this reply and the fix myself before posting.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mt2FATTF7iprD7ygyHVxHW