Validate code-review article slugs against BCQuality - #804
Open
Wenjie Fan (gggdttt) wants to merge 1 commit into
Open
Validate code-review article slugs against BCQuality#804Wenjie Fan (gggdttt) wants to merge 1 commit into
Wenjie Fan (gggdttt) wants to merge 1 commit into
Conversation
The ArticleId pattern only checks the <domain>/<slug> shape, so a typo passes schema validation and every test. Such a typo is doubly wrong: it credits coverage to a nonexistent article and leaves the real one in zero-coverage. Add an opt-in dataset test that resolves BCQUALITY_ROOT, enumerates the article inventory and fails on any declared slug missing from it, naming the offending entry ids. It skips when BCQUALITY_ROOT is unset, so CI (which has no BCQuality checkout) is unaffected.
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.
Problem
ArticleIdonly validates the shape of an article reference:Nothing checks that the article actually exists in BCQuality. A one-character typo passes schema validation and the entire test suite:
That is worse than a missing annotation, because it corrupts the coverage report in both directions: the entry is credited to a nonexistent article, and the real article silently stays in
zero_coverage— so the very report meant to show which articles need gold answers hides a genuine gap.Today the only signal is the
unknown_articlesfield innotebooks/code-review-coverage.ipynb, which has to be run and read manually. With 17 of 144 entries annotated so far and ~215 comments still to tag, manual inspection does not scale.Change
Add one opt-in dataset test to
tests/test_bcquality_article_coverage.py:resolve_bcquality_root()(BCQUALITY_ROOT).dataset/codereview.jsonland asserts no declared slug is missing from the enumerated inventory.BCQUALITY_ROOTis unset, so CI — which has no BCQuality checkout — is unaffected.No production code changes; this reuses
collect_declared_articles,enumerate_inventoryandbuild_coverage_reportas-is.Validation
...wildcard-grants->...wildcard-grant) intodataset/codereview.jsonl; the test failed witharticle slugs not found in <root>: {'security/permission-set-avoid-wildcard-grant': ['synthetic__security-005']}, then passed again after reverting.BCQUALITY_ROOTpointed at BCQualitymain: 11 passed.BCQUALITY_ROOT: 10 passed, 1 skipped.ruff format,ruff checkclean;ty checkreports only the pre-existingsrc/bcbench/redteam.py:150unused-ignore warning.