fix: classify phantom references under AI quality#754
Open
7arnav1 wants to merge 1 commit into
Open
Conversation
Phantom references detect AI-hallucinated symbols, but negative context exported them under the generic completeness category. This diverged from signal_registry.py, which already files PHR under ai_quality, and made it impossible for agent consumers to filter AI-specific anti-patterns. - add AI_QUALITY to NegativeContextCategory - map PHANTOM_REFERENCE to AI_QUALITY in _SIGNAL_CATEGORY - render the new category as 'AI-Generated Code Anti-Patterns' - update the PHR generator, docs, and existing category assertion - add regression tests for the mapping, heading, and end-to-end export Closes mick-gsk#473
Author
|
I don't have permission to add labels — this should be release:fix per the labeling convention. |
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
Adds a dedicated
AI_QUALITYnegative-context category and uses it for phantom-reference findings, as proposed in #473.Problem
Phantom references identify hallucinated symbol usage from AI-assisted coding, but they were exported under the generic "Completeness Anti-Patterns" section. This diverged from
signal_registry.py, which already categorizes PHR asai_quality, and made it impossible for agent consumers to filter AI-specific constraints from negative-context output.Changes
AI_QUALITY = "ai_quality"toNegativeContextCategory(models/_enums.py)SignalType.PHANTOM_REFERENCEtoAI_QUALITYin_SIGNAL_CATEGORY(negative_context/core.py)AI-Generated Code Anti-Patternsheading to_CATEGORY_HEADING(negative_context/export.py)_gen_phringenerators.py, which hardcodedCOMPLETENESStests/test_negative_context.pytests/test_issue_473_ai_quality_category.py: the mapping, the heading, a completeness check that every category has a heading, and end-to-end tests that a PHR finding produces anAI_QUALITYitem rendered under the new sectionai_qualityto the category list indocs-site/reference/negative-context.mdChecked
drift.output.schema.json/drift.schema.json— neither enumeratesNegativeContextCategoryvalues, so no schema regeneration is needed.Note for consumers
Raw/JSON export now emits
"category": "ai_quality"for PHR items where consumers previously saw"completeness"(asked about this in #473 — happy to add a changelog note if wanted).Validation
pytest— 6682 passed. Excluded on my machine only:TestCalibrateRunWriteGuard(click 8.2 removedmix_stderr),test_date_parsing(timezone-dependent assertion, passes under UTC=+0 only),test_model_consistency_check_passes(SECURITY.md missing 2.51.x, pre-existing on main), and one rich-output snapshot test — all verified failing on a clean checkout ofmainas wellmainand pass with this changeruff check src/ tests/— cleanmypy src/drift— no new errors (same 2 pre-existingcli.pyerrors asmain)Closes #473