Skip to content

fix(validate): warn on references to non-existing requirements - #498

Merged
jimisola merged 3 commits into
mainfrom
fix/490-dangling-reference-warning
Nov 22, 2026
Merged

jimisola merged 3 commits into
mainfrom
fix/490-dangling-reference-warning

Conversation

@jimisola

@jimisola jimisola commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Requested by Jimisola · project thread

Summary

Fixes #490. validate accepted references.requirement_ids pointing at requirements that don't exist (exit 0, no output), and export wrote the dangling ID as if it were valid.

validate now reports each such reference as a warning:

⚠ ms-001:REQ_010    references non-existing requirement nope-999:REQ_DOES_NOT_EXIST
  • Dangling means the target (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).
  • Warning, not error, for now, so existing projects don't start failing CI. --strict promotes it to exit 1 like the other coverage warnings. This should become an error in the next major version.
  • Implementation: RequirementsRepository.get_dangling_requirement_references() (LEFT JOIN query) used by ValidateCommand._check_dangling_references. No schema change: the DB deliberately has no FK on the reference target, so export / status / report are untouched.
  • Dogfooding: new VALIDATE_0006 / SVC_VALIDATE_0006, openspec validate spec and usage.adoc updated.

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

  • New unit tests: repository query (dangling / existing target), validate warns (exit 0), --strict fails (exit 1), valid reference in test_basic baseline not flagged
  • The new tests fail against the pre-fix code (4 of 5 fail; the fifth guards against false positives)
  • hatch run dev:pytest tests/unit (897 passed), black, flake8
  • Issue repro on a copy of test_standard/baseline: warning shown, exit 0; --strict exit 1
  • Regression smoke: validate output on test_standard and test_basic baselines identical before/after. status, report and export code paths are not touched. reqstool-demo was not run (no target/ 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

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 jimisola self-assigned this Nov 21, 2026
@jimisola
jimisola marked this pull request as ready for review November 22, 2026 01:05
@jimisola
jimisola merged commit db9bafd into main Nov 22, 2026
10 checks passed
@jimisola
jimisola deleted the fix/490-dangling-reference-warning branch November 22, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: validate accepts a reference to a requirement that does not exist

1 participant