Skip to content

CF-7 Remediation Phase 3: exhaustive-category heuristic hardening - #61

Merged
hardcoreerik merged 5 commits into
masterfrom
feat/cf7-exhaustive-heuristic-hardening
Jul 15, 2026
Merged

CF-7 Remediation Phase 3: exhaustive-category heuristic hardening#61
hardcoreerik merged 5 commits into
masterfrom
feat/cf7-exhaustive-heuristic-hardening

Conversation

@hardcoreerik

@hardcoreerik hardcoreerik commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

Implements review item #4: BuildExhaustiveAnswer's entity-scoped vs. category-wide classification is a heuristic (minDocumentFrequency < 50% of cards), not a proof, and the Grading Spec has flagged since 2026-07-04 that a genuinely category-wide question with no hyphenated identifier could be misclassified — with no regression test proving it.

Investigation finding: this risk is currently latent, not live. All 15 Exhaustive questions in the actual 150-question suite name a hyphenated identifier and are fully handled by Tier 1c's verbatim anchor match — the fallback heuristic this hardening targets is never reached by any question in the current corpus.

  • Added a regression test reproducing the exact failure with a synthetic 10-card corpus (3 of 10 relevant cards happen to use the literal scored word, the other 7 use different phrasing) — confirms the documented risk is real, not just theoretical.
  • Added FabricBenchmarkQuestion.ExhaustiveIsEntityScopedOverride (nullable bool): an optional authored ground-truth annotation. BuildExhaustiveAnswer uses it directly when set, bypassing the heuristic — the "pre-compute ground-truth classification" resolution the Grading Spec had tracked as not-yet-implemented. Proven by a second test with the identical fixture, confirming all 10 cards match once set.
  • Deliberately not backfilled onto the existing 150-question suite — every current question is already correctly handled by Tier 1c, so setting the override on them would be a no-op. It's there for future question authors to set explicitly on any new hyphen-free Exhaustive question.
  • Docs updated: Grading Spec §5.3 known-limitation note, Bug History §7d.

Test plan

  • dotnet build clean across ContextFabricBench and OrchestratorIDE.Avalonia
  • dotnet test — 561/565 pass (4 pre-existing GPU-conditional skips), including both new tests, which passed on first try (confirms the fixture accurately reproduces the bug and the fix genuinely resolves it, not just asserting a tautology)
  • All 5 pre-existing ContextFabricExhaustiveAnswerTests pass unmodified

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved exhaustive-answer classification for category-wide questions that contain uncommon terms.
    • Added an optional explicit classification override for exhaustive questions when heuristic detection is insufficient.
  • Tests

    • Added regression coverage for misclassification scenarios and verified that explicit overrides return all relevant results.
  • Documentation

    • Documented the classification limitation, mitigation, and guidance for authoring new exhaustive questions.

Implements review item #4: BuildExhaustiveAnswer's entity-scoped vs.
category-wide classification is a heuristic (minDocumentFrequency <
50% of cards), not a proof, and the Grading Spec has flagged since
2026-07-04 that a genuinely category-wide question with no hyphenated
identifier could be misclassified as entity-scoped by corpus
coincidence -- with no regression test proving it.

Investigation finding: this risk is currently LATENT, not live. All 15
Exhaustive questions in the actual 150-question suite name a hyphenated
identifier and are fully handled by Tier 1c's verbatim anchor match --
the fallback heuristic this hardening targets is never reached by any
question in the current corpus.

- Added a regression test reproducing the exact failure with a
  synthetic 10-card corpus: a category-wide question where only 3 of
  10 relevant cards happen to use the literal word being scored (the
  other 7 use different phrasing), causing the heuristic to hard-
  require that word and silently drop the 7 differently-phrased cards.
  Confirms the documented risk is real, not just theoretical.
- Added FabricBenchmarkQuestion.ExhaustiveIsEntityScopedOverride
  (nullable bool): an optional authored ground-truth annotation.
  BuildExhaustiveAnswer uses it directly when set, bypassing the
  heuristic entirely -- the "pre-compute ground-truth classification"
  resolution the Grading Spec had tracked as not-yet-implemented.
  Proven by a second test using the identical fixture with the
  override set, confirming all 10 cards match correctly.
- Deliberately NOT backfilled onto the existing 150-question suite --
  every current question is already correctly handled by Tier 1c, so
  setting the override on them would be a no-op. It's there for future
  question authors to set explicitly on any new hyphen-free Exhaustive
  question, not retrofitted onto questions that don't need it.
- Docs: Grading Spec §5.3 known-limitation note updated to reflect the
  mitigation and its scope; Bug History §7d records the investigation.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hardcoreerik, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f2d8f1d2-1e7a-4a49-b48a-63ec1ff35517

📥 Commits

Reviewing files that changed from the base of the PR and between 899e447 and bc8956b.

📒 Files selected for processing (3)
  • OrchestratorIDE/Services/ContextFabric/ContextFabricContracts.cs
  • OrchestratorIDE/Services/ContextFabric/ContextFabricFeasibilityRunner.cs
  • docs/CONTEXT_FABRIC_GRADING_SPEC.md
📝 Walkthrough

Walkthrough

Adds a nullable exhaustive-question classification override, applies it in BuildExhaustiveAnswer, and adds regression tests and documentation for category-wide versus entity-scoped classification.

Changes

Exhaustive classification remediation

Layer / File(s) Summary
Override contract and answer inference
OrchestratorIDE/Services/ContextFabric/ContextFabricContracts.cs, OrchestratorIDE/Services/ContextFabric/ContextFabricFeasibilityRunner.cs
FabricBenchmarkQuestion gains ExhaustiveIsEntityScopedOverride; BuildExhaustiveAnswer uses the override when set and otherwise retains document-frequency inference.
Boundary regression coverage and documentation
OrchestratorIDE.UnitTests/ContextFabricExhaustiveAnswerTests.cs, docs/CONTEXT_FABRIC_*.md
Tests reproduce the heuristic boundary case and verify that false includes all corpus segments; documentation records the limitation, remediation, and authoring guidance.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • hardcoreerik/TheOrc#34: Modifies the same exhaustive entity-versus-category heuristic in BuildExhaustiveAnswer.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: hardening the exhaustive-category classification heuristic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cf7-exhaustive-heuristic-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Both docs claimed the fallback unigram classification path was never
reached by any live question. Wrong -- DeterministicFabricCorpus.cs's
own exhaustive-archive-tokens question ("List every archive token in
section order", no hyphenated identifier) exercises it on every
cf7-gate run. It currently classifies correctly only because every
segment's text literally contains "archive token", giving that term
100% document frequency in that specific corpus -- nowhere near the
<50% threshold that triggers misclassification. Corrected both docs:
the heuristic path is live and currently correct by fortunate corpus
construction, not unreached; the boundary-case FAILURE MODE (not the
heuristic path itself) is what remains untriggered by any current
question, which is what the new regression test reproduces
synthetically.
The two doc fixes corrected the "never reached by any live question"
claim; this code comment made the identical overclaim and was missed.
…eview)

§9 still said the boundary case had no regression test, contradicted by
the two Phase 3 tests and §5.3's rewrite earlier in the same commit range.
Fourth and hopefully final instance of the "fallback heuristic isn't
reached by any live question" overclaim, this time in
FabricBenchmarkQuestion's own XML doc comment. Did a repo-wide grep for
the phrase pattern afterward to confirm no more instances remain.
@hardcoreerik

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hardcoreerik
hardcoreerik merged commit d43ac96 into master Jul 15, 2026
2 checks passed
@hardcoreerik
hardcoreerik deleted the feat/cf7-exhaustive-heuristic-hardening branch July 18, 2026 02:23
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