Skip to content

fix: classify phantom references under AI quality#754

Open
7arnav1 wants to merge 1 commit into
mick-gsk:mainfrom
7arnav1:fix/ai-quality-negative-context
Open

fix: classify phantom references under AI quality#754
7arnav1 wants to merge 1 commit into
mick-gsk:mainfrom
7arnav1:fix/ai-quality-negative-context

Conversation

@7arnav1

@7arnav1 7arnav1 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Adds a dedicated AI_QUALITY negative-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 as ai_quality, and made it impossible for agent consumers to filter AI-specific constraints from negative-context output.

Changes

  • Added AI_QUALITY = "ai_quality" to NegativeContextCategory (models/_enums.py)
  • Mapped SignalType.PHANTOM_REFERENCE to AI_QUALITY in _SIGNAL_CATEGORY (negative_context/core.py)
  • Added the AI-Generated Code Anti-Patterns heading to _CATEGORY_HEADING (negative_context/export.py)
  • Updated _gen_phr in generators.py, which hardcoded COMPLETENESS
  • Updated the existing PHR category assertion in tests/test_negative_context.py
  • Added tests/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 an AI_QUALITY item rendered under the new section
  • Added ai_quality to the category list in docs-site/reference/negative-context.md

Checked drift.output.schema.json / drift.schema.json — neither enumerates NegativeContextCategory values, 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 removed mix_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 of main as well
  • New regression tests verified to fail against unpatched main and pass with this change
  • ruff check src/ tests/ — clean
  • mypy src/drift — no new errors (same 2 pre-existing cli.py errors as main)

Closes #473

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
@7arnav1
7arnav1 requested a review from mick-gsk as a code owner July 23, 2026 02:52
@7arnav1

7arnav1 commented Jul 23, 2026

Copy link
Copy Markdown
Author

I don't have permission to add labels — this should be release:fix per the labeling convention.

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.

[Feature] NegativeContextCategory has no AI_QUALITY variant — PHR findings are misclassified as Completeness anti-patterns

1 participant