Skip to content

Fix analyze-report misdetecting Strategic Overviews as AI Strategy#147

Merged
blisspixel merged 3 commits into
mainfrom
fix/analyze-report-type-detection
Jul 21, 2026
Merged

Fix analyze-report misdetecting Strategic Overviews as AI Strategy#147
blisspixel merged 3 commits into
mainfrom
fix/analyze-report-type-detection

Conversation

@blisspixel

Copy link
Copy Markdown
Owner

Summary

Fixes a self-inflicted QA-gate bug surfaced by primr-zero testing: an agent that follows the skill's own report-contract.md (a 23-section Strategic Overview) could be failed by the skill's own primr --analyze-report gate.

Root cause: _detect_report_type classified the report as ai_strategy whenever the substring "ai strategy" appeared anywhere in the body — so a Strategic Overview that merely discusses a company's AI strategy was graded against the AI-strategy template's required sections (Current State / Recommendations / Implementation), none of which are in the 23-section contract. Detection was also filename-fragile, which is exactly why a host-written report with a non-conforming filename tripped it.

Changes

  • Section-fingerprint detection. _detect_report_type now uses the filename first, then classifies by which template's distinctive ## headings are present (Products and Services / SWOT / Porter's / Strategic Positioning … vs Executive Decision Brief / Opportunity Inventory / Board Decision …). It only consults the legacy content phrases when there is no structural signal.
  • Documented citation format. report-contract.md (primr-zero skill) now spells out the exact format the gate scores — inline [cite: N] markers + a ## Sources appendix — with a worked example, so a contract-compliant report also passes analyze-report. Mirrors re-synced.
  • Regression tests. An overview mentioning "AI strategy" with a non-conforming filename now detects as strategic_overview; an AI Strategy doc detects by its sections.

Testing

  • tests/test_qa/ + tests/test_primr_zero_skill.py: 461 passed (including the new regression tests and the skill-mirror sync check). ruff clean.

Independent of #146 (branched off main).

Report-type detection keyed on the substring "ai strategy" appearing anywhere in
the body, so a 23-section Strategic Overview that merely discussed a company's AI
strategy was classified as ai_strategy and graded against the wrong template's
required sections (Current State / Recommendations / Implementation), failing the
skill's own QA gate for a contract-compliant report.

- _detect_report_type now uses the filename first, then a section-structure
  fingerprint (distinctive Strategic Overview vs AI Strategy headings), and only
  falls back to legacy content phrases when there is no structural signal.
- report-contract.md documents the exact citation format the gate scores (inline
  [cite: N] markers + a ## Sources appendix) with a worked example, so an agent
  following the contract also passes analyze-report. Mirrors re-synced.
- Add regression tests: an overview mentioning "AI strategy" with a non-conforming
  filename detects as strategic_overview; an AI Strategy doc detects by sections.
@blisspixel
blisspixel merged commit 89beb45 into main Jul 21, 2026
10 checks passed
@blisspixel
blisspixel deleted the fix/analyze-report-type-detection branch July 21, 2026 18:19
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.

1 participant