Skip to content

fix(brainbar): coverage counts terminal statuses (item F-1)#335

Merged
EtanHey merged 1 commit into
mainfrom
feat/brainbar-item-F-coverage
May 26, 2026
Merged

fix(brainbar): coverage counts terminal statuses (item F-1)#335
EtanHey merged 1 commit into
mainfrom
feat/brainbar-item-F-coverage

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented May 26, 2026

Summary

  • Implements Item F Fix 1 from /tmp/codex-mandate-item-F.md.
  • Changes coverage numerators from enrich_status = 'success' to enrich_status IS NOT NULL so terminal statuses like duplicate, noise, and future terminal outcomes count as covered.
  • Applies the same coverage semantics to dashboard counts, enrichment stats, and recall stats coverage output.
  • Leaves recent enrichment activity/rate queries success-only, since those measure successful enrichment events rather than terminal coverage.

Diagnosis cited

  • Demo dashboard was stuck at 88% because duplicate rows were terminal but excluded from the numerator.
  • Mandate math: 337,573 / 383,333 = 88.06%; counting terminal statuses gives 350,841 / 383,333 = 91.52% immediately.
  • Pending enrichment remains represented by enrich_status IS NULL; non-NULL statuses are terminal coverage.

TDD / Test plan

  • RED: DashboardTests/testDashboardStatsCountsTerminalEnrichmentStatusesAsCovered failed at 1 enriched / 33.33%.
  • RED: DashboardTests/testEnrichmentStatsCountsAnyTerminalStatusAsCovered failed at 1 enriched / 25.0%.
  • RED: DatabaseTests/testRecallStatsCoverageCountsAnyTerminalStatusAsEnriched failed at 1 enriched / 25.0%.
  • GREEN: all three targeted tests pass.
  • swift test --package-path brain-bar: 474 tests, 0 failures.
  • git diff --check: passed.
  • Pre-push gate: Python 2186 passed, 9 skipped, 75 deselected, 1 xfailed; MCP tool registration 3 passed; isolated eval/hook routing 36 passed; bun stale index 1 pass; regression shell passed.

Review note

  • Local CodeRabbit pre-commit review raised a concern that IS NOT NULL could count a future persisted pending status. I investigated and found pending enrichment is represented as NULL in this codebase; /tmp/codex-mandate-item-F.md explicitly requests IS NOT NULL to include future terminal statuses.

Note

Low Risk
Read-only SQL and metric semantics in BrainBar stats; no auth or write-path changes. Main risk is dashboard percentages shifting upward for duplicate/noise rows, which is intentional.

Overview
Enrichment coverage in BrainDatabase now treats any non-null enrich_status as covered (terminal outcomes like duplicate and noise), with NULL still meaning pending. Dashboard totals, enrichmentStats, and recallStats numerators use enrich_status IS NOT NULL instead of enrich_status = 'success'.

skippedTooShort in enrichmentStats is narrowed to chunks that are still pending and below the char threshold, so terminal statuses are no longer folded into that bucket.

Recent enrichment activity (last enriched time, sparkline buckets, rate, last-24h count) still filters success only, so live pipeline metrics stay tied to successful enrichments.

Tests were updated/added in DashboardTests and DatabaseTests to lock in terminal-status coverage and the split between coverage vs success-only activity.

Reviewed by Cursor Bugbot for commit 28c3e53. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix coverage counts in BrainBar to include all terminal enrichment statuses

  • Updates enrich_status IS NOT NULL as the predicate for coverage in BrainDatabase.enrichmentStats and BrainDatabase.recallStats, replacing the previous enrich_status = 'success' check.
  • Chunks with terminal statuses like duplicate or noise are now counted as covered, alongside success.
  • skippedTooShort now only counts chunks where both enrich_status and enriched_at are NULL and char_count < 50.
  • Behavioral Change: enriched_chunks, enrichedChunkCount, and derived percentages will be higher for databases containing non-success terminal statuses.

Macroscope summarized 28c3e53.

Summary by CodeRabbit

Bug Fixes

  • Updated enrichment coverage metrics to count all terminal enrichment states as covered, not only successful ones. Dashboard and report statistics now reflect this broader calculation for enrichment completion percentages.

Review Change Stack

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@coderabbitai review

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@macroscope-app review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@codex review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@cursor @BugBot review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

✅ Actions performed

Review triggered.

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.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 26, 2026

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented May 26, 2026

Code review triggered. The Approvability Check and Correctness Check are now running. Results will be posted when complete.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread brain-bar/Sources/BrainBar/BrainDatabase.swift Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

Database statistics methods dashboardCounts(), enrichmentStats(), and recallStats() now treat any terminal enrichment state (success, duplicate, noise) as covered, replacing logic that counted only successful enrichments. Test expectations are updated to validate this uniform terminal coverage semantics.

Changes

Enrichment Coverage Semantics

Layer / File(s) Summary
Database statistics enrichment logic
brain-bar/Sources/BrainBar/BrainDatabase.swift
dashboardCounts(), enrichmentStats(), and recallStats() change from counting only enrich_status = 'success' to counting any terminal state (enrich_status IS NOT NULL). The enrichmentStats layer introduces a terminalCoveragePredicate constant. Pending enrichment remains NULL.
Dashboard and enrichment statistics tests
brain-bar/Tests/BrainBarTests/DashboardTests.swift
Dashboard stats test method renamed to reflect terminal enrichment counting. Test data now inserts duplicate and noise terminal statuses. SQL mutations and assertions updated to expect all terminal statuses as covered. New test testEnrichmentStatsCountsAnyTerminalStatusAsCovered verifies enrichment stats counts success/duplicate/noise as enriched and reports correct percentages.
Recall statistics coverage test
brain-bar/Tests/BrainBarTests/DatabaseTests.swift
New test testRecallStatsCoverageCountsAnyTerminalStatusAsEnriched inserts four chunks with different enrichment statuses, verifies three terminal statuses are counted as enriched, and asserts 75% enrichment coverage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through enrichment's hall,
Terminal states now count them all—
Success and noise and duplicates too,
No longer just winning the "success" view. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: updating coverage logic to count terminal enrichment statuses (not just 'success'). It directly reflects the core change across all three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/brainbar-item-F-coverage

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented May 26, 2026

Approvability

Verdict: Would Approve

This is a self-contained fix to coverage metric calculations, changing the definition of 'enriched' to include all terminal statuses rather than just 'success'. The change is limited in scope, well-documented with comments, and accompanied by comprehensive test coverage. The author owns all modified files.

Macroscope would have approved this PR. Enable approvability here.

@EtanHey EtanHey force-pushed the feat/brainbar-item-F-coverage branch from 9cfb1cc to 28c3e53 Compare May 26, 2026 20:15
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

Macroscope high-severity thread fixed in 28c3e53: #335 (comment)

I added a red assertion proving the category invariant was broken: skippedTooShort was 2, and the category sum was 6 vs total 4. Then I narrowed skippedTooShort to only enrich_status IS NULL AND enriched_at IS NULL AND char_count < 50.

Verification after the fix: targeted test passed, full swift test --package-path brain-bar passed with 474 tests and 0 failures, and the pre-push gate passed again.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@macroscope-app review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@coderabbitai review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@codex review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented May 26, 2026

@cursor @BugBot re-review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 26, 2026

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

✅ Actions performed

Review triggered.

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.

@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented May 26, 2026

Code review triggered. The Approvability Check and Correctness Check are now running. Results will be posted when complete.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@EtanHey EtanHey merged commit 56ee32f into main May 26, 2026
8 checks passed
@EtanHey EtanHey deleted the feat/brainbar-item-F-coverage branch May 26, 2026 20:24
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