Skip to content

fix(analytics): aggregate sections before sampling#424

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
codex/analytics-section-aggregation
Jul 10, 2026
Merged

fix(analytics): aggregate sections before sampling#424
ScriptedAlchemy merged 1 commit into
masterfrom
codex/analytics-section-aggregation

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

  • compute exact event totals and DB-side tool/hint rollups before rendering analytics sections
  • remove the generic latest-10,000 cap that produced false zero hint/tool counts
  • add upgrade-safe project/time indexes and a >10,000-event regression

Verification

  • cargo test --test mcp_suite analytics_test::
  • cargo test --test session_suite open_at_upgrades_existing_global_db_with_analytics_events_table
  • cargo clippy --lib --test mcp_suite --test session_suite -- -D warnings
  • cargo fmt --check

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 04d8d2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy ScriptedAlchemy force-pushed the codex/analytics-section-aggregation branch from 2a71bea to 04d8d2d Compare July 10, 2026 05:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a71bea5b1

ℹ️ 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 src/global_db.rs
Comment on lines +2931 to +2934
SUM(CASE WHEN event_kind IN ('hint_emitted', 'hint_escalated', 'missing_session') THEN 1 ELSE 0 END) AS emitted,
SUM(CASE WHEN event_kind = 'hint_outcome' AND LOWER(TRIM(COALESCE(outcome, ''))) = 'acted' THEN 1 ELSE 0 END) AS followed,
SUM(CASE WHEN event_kind = 'hint_outcome' AND LOWER(TRIM(COALESCE(outcome, ''))) = 'ignored' THEN 1 ELSE 0 END) AS ignored,
SUM(CASE WHEN event_kind LIKE 'suppressed_%' THEN 1 ELSE 0 END) AS suppressed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize hint event kinds in the SQL rollup

For legacy/imported analytics rows whose event_kind is hyphenated or differently cased (for example hint-emitted or suppressed-duplicate), the previous hint_summary_from_events path counted them after trimming/lowercasing and replacing - with _. This DB-side rollup now matches the raw value (and the WHERE clause below does the same), so those in-window rows are dropped and the MCP hints section reports zeros for data it used to include; apply the same event-kind normalization in the SQL predicates.

Useful? React with 👍 / 👎.

@ScriptedAlchemy ScriptedAlchemy merged commit 6c4b8b9 into master Jul 10, 2026
13 of 18 checks passed
ScriptedAlchemy added a commit that referenced this pull request Jul 10, 2026
Three-way verification pass after the rebase and external deepening
commits: reconcile remaining stale merge-state claims (#418 released,
#423/#424/#425/#407 merged at base 3567e31; #409 closed-not-merged),
enforce single canonical definitions (DiagnosticEnvelopeV1 -> plan 24,
SanitizationReceiptV1 -> plan 18, CursorPage -> plan 17), fix a stray
non-canonical error code in plan 01, and repair four tables broken by
unescaped pipes in inline code. Lab inventory, budgets, tool counts,
FM-001..103 contiguity, links after the docs/plans move, and PR-letter
namespace all verified clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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