Skip to content

test(e2e): Claude Enterprise cc_tool_accept + cc_tool_acceptance (#1440) - #1509

Merged
mozhaev-dev merged 2 commits into
mainfrom
test/e2e-ai-claude-enterprise
Jun 30, 2026
Merged

test(e2e): Claude Enterprise cc_tool_accept + cc_tool_acceptance (#1440)#1509
mozhaev-dev merged 2 commits into
mainfrom
test/e2e-ai-claude-enterprise

Conversation

@mozhaev-dev

@mozhaev-dev mozhaev-dev commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

What

The final two AI-Adoption bullet metrics for #1440cc_tool_accept and cc_tool_acceptance. These are the Claude Code tool-suggestion accept count and acceptance rate, which claude_team cannot supply (it sets tool_use_accepted/tool_use_offered to NULL). They come from the Claude Enterprise admin Analytics API instead.

spec metric_key class mapping
ai_cc_tool_accept cc_tool_accept sum (twin of cc_lines) tool_use_accepted ← code_tool_accepted_count
ai_cc_tool_acceptance cc_tool_acceptance reconstructed ratio 100 × Σ accepted ÷ Σ offered, offered ← accepted + rejected

Pipeline: bronze_claude_enterprise.claude_enterprise_usersclaude_enterprise__ai_dev_usage (tool='claude_code') → silver class_ai_dev_usage → gold insight.ai_bullet_rows → IC Bullet AI (…0013).

Values: cc_tool_accept alice 50 · bob 20 · carol 10 → value 50, median 20, range [10, 50] (dedup holds). cc_tool_acceptance alice accepted 50 of 80 offered → 62.5 (value-only).

Supporting changes

  • Bronze placeholder for claude_enterprise_users (+ schema + template, mirroring the connector InlineSchemaLoader). ⚠️ user_id is set distinct per seat in the template: the staging model dedups with LIMIT 1 BY tenant, source, user_id, date, so a shared/NULL user_id collapses the whole cohort to one row and the team median is wrong (caught in testing).
  • claude_enterprise__ai_dev_usage: the same empty-table watermark guard as the other AI staging models — … - INTERVAL 3 DAY underflows the Date range over an empty this (the rig resets staging between tests), filtering out every row. Short-circuited with (SELECT count() FROM this) = 0 OR ….
  • conftest: reset staging.claude_enterprise__ai_dev_usage at session start (warm-rerun determinism).

Coverage

This completes the AI-Adoption bullet (#1440) — all 23 served metric_keys now have an e2e spec across the cursor (#1468), claude_team (#1491), chatgpt_team (#1501), and this Claude Enterprise PR.

Verification

./e2e.sh test -k ai_cc_tool2 passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for Claude Enterprise usage data in initialization and test fixtures, including placeholder tables needed for fresh environments.
    • Expanded end-to-end metric coverage for Claude Enterprise-related acceptance and usage metrics.
  • Bug Fixes

    • Improved incremental data loading to handle empty target tables safely and avoid date-range issues.
    • Prevented duplicate records from affecting metric results during repeated syncs or reruns.

@mozhaev-dev
mozhaev-dev requested a review from a team as a code owner June 27, 2026 04:59
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 28 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

Run ID: add92b15-a107-4b22-9fc7-9293c9d47aec

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4ca32d18ac79cec60a7f4bb06b95cabc02a8e1 and 5434af9.

📒 Files selected for processing (7)
  • src/ingestion/connectors/ai/claude-enterprise/dbt/claude_enterprise__ai_dev_usage.sql
  • src/ingestion/scripts/create-bronze-placeholders.sh
  • src/ingestion/tests/e2e/conftest.py
  • src/ingestion/tests/e2e/metrics/ai_cc_tool_accept.test.yaml
  • src/ingestion/tests/e2e/metrics/ai_cc_tool_acceptance.test.yaml
  • src/ingestion/tests/e2e/metrics/schemas/bronze_claude_enterprise.claude_enterprise_users.yaml
  • src/ingestion/tests/e2e/metrics/templates/claude_enterprise_users.yaml
📝 Walkthrough

Walkthrough

Adds the bronze_claude_enterprise database and claude_enterprise_users placeholder table, fixes an incremental dbt model to guard against empty-target date underflow, and introduces e2e JSON schema, reusable fixtures, session-reset registration, and two new metric test specs for cc_tool_accept and cc_tool_acceptance.

Changes

Claude Enterprise bronze layer and metrics e2e

Layer / File(s) Summary
Bronze placeholder DB, table, and dbt incremental guard
src/ingestion/scripts/create-bronze-placeholders.sh, src/ingestion/connectors/ai/claude-enterprise/dbt/claude_enterprise__ai_dev_usage.sql
Creates the bronze_claude_enterprise database and claude_enterprise_users ReplacingMergeTree table. Wraps the incremental WHERE filter with an empty-target check to prevent Date epoch underflow when {{ this }} has no rows.
E2e schema, templates, and session reset
src/ingestion/tests/e2e/metrics/schemas/bronze_claude_enterprise.claude_enterprise_users.yaml, src/ingestion/tests/e2e/metrics/templates/claude_enterprise_users.yaml, src/ingestion/tests/e2e/conftest.py
Adds the JSON schema for bronze_claude_enterprise.claude_enterprise_users, a reusable ent_user template with alice/bob/carol instances, and registers staging.claude_enterprise__ai_dev_usage in the session-start truncation list.
E2e metric tests for cc_tool_accept and cc_tool_acceptance
src/ingestion/tests/e2e/metrics/ai_cc_tool_accept.test.yaml, src/ingestion/tests/e2e/metrics/ai_cc_tool_acceptance.test.yaml
Seeds bronze employee and Claude Enterprise usage rows (including duplicate re-sync entries) and asserts correct deduplication, value/median/range results for cc_tool_accept and the reconstructed ratio for cc_tool_acceptance.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Metric smoke: AI Adoption metrics #1440: The bronze schema, incremental model fix, and e2e metric fixtures directly support the Claude Enterprise usage data path exercised by the AI Adoption smoke track described in this issue.

Suggested reviewers

  • mitasovr
  • cyberantonz
  • ktursunov

🐇 A new bronze table appears with a hop and a spin,
The empty-table guard stops the epoch begin.
Alice and Bob and Carol align,
No double-counting — the ratios are fine!
cc_tool_accept says fifty's the score,
The rabbit checks fixtures and asks for no more. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately names the main change: new E2E coverage for Claude Enterprise cc_tool_accept and cc_tool_acceptance.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/e2e-ai-claude-enterprise

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/ingestion/tests/e2e/metrics/ai_cc_tool_acceptance.test.yaml (1)

24-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The re-sync duplicate does not actually guard the ratio against a dedup regression.

cc_tool_acceptance is 100 × Σaccepted ÷ Σoffered, which is invariant under row duplication (a doubled row scales numerator and denominator equally → 100/160 still 62.5). So if LIMIT 1 BY regressed, this case would still pass. Dedup is genuinely exercised by ai_cc_tool_accept (a sum), so coverage isn't lost — but consider asserting an additional non-ratio field here (e.g., the underlying accepted/offered sum or count) if you want this spec to independently catch a dedup break.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ingestion/tests/e2e/metrics/ai_cc_tool_acceptance.test.yaml` around lines
24 - 28, The duplicate re-sync row in ai_cc_tool_acceptance does not validate
dedup because cc_tool_acceptance is a ratio metric and remains unchanged when
rows are duplicated. Update the acceptance test data in
ai_cc_tool_acceptance.test.yaml so this case also asserts a non-ratio
signal—such as the underlying accepted/offered sum or row count—using the
existing templates/claude_enterprise_users.yaml reference and the
unique_key/date fields to ensure a LIMIT 1 BY regression would be caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/ingestion/tests/e2e/metrics/ai_cc_tool_acceptance.test.yaml`:
- Around line 24-28: The duplicate re-sync row in ai_cc_tool_acceptance does not
validate dedup because cc_tool_acceptance is a ratio metric and remains
unchanged when rows are duplicated. Update the acceptance test data in
ai_cc_tool_acceptance.test.yaml so this case also asserts a non-ratio
signal—such as the underlying accepted/offered sum or row count—using the
existing templates/claude_enterprise_users.yaml reference and the
unique_key/date fields to ensure a LIMIT 1 BY regression would be caught.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97b83e7f-7768-4d0e-84e0-30508147f522

📥 Commits

Reviewing files that changed from the base of the PR and between 5d8a577 and 3c4ca32d18ac79cec60a7f4bb06b95cabc02a8e1.

📒 Files selected for processing (7)
  • src/ingestion/connectors/ai/claude-enterprise/dbt/claude_enterprise__ai_dev_usage.sql
  • src/ingestion/scripts/create-bronze-placeholders.sh
  • src/ingestion/tests/e2e/conftest.py
  • src/ingestion/tests/e2e/metrics/ai_cc_tool_accept.test.yaml
  • src/ingestion/tests/e2e/metrics/ai_cc_tool_acceptance.test.yaml
  • src/ingestion/tests/e2e/metrics/schemas/bronze_claude_enterprise.claude_enterprise_users.yaml
  • src/ingestion/tests/e2e/metrics/templates/claude_enterprise_users.yaml

The last two AI-bullet metrics that claude_team can't supply (it sets
tool_use_accepted/offered = NULL): both come from the Claude Enterprise admin
Analytics API, where tool_use_accepted ← code_tool_accepted_count and
tool_use_offered ← code_tool_accepted_count + code_tool_rejected_count.

  - cc_tool_accept     — sum metric; alice 50 · bob 20 · carol 10 → median 20,
                         range [10, 50] (dedup holds).
  - cc_tool_acceptance — reconstructed ratio 100 × Σ accepted ÷ Σ offered;
                         alice 50 of 80 → 62.5 (value-only).

Pipeline: bronze_claude_enterprise.claude_enterprise_users →
claude_enterprise__ai_dev_usage (tool='claude_code') → silver class_ai_dev_usage
→ gold insight.ai_bullet_rows → IC Bullet AI (…0013).

Supporting:
- bronze placeholder for claude_enterprise_users (+ schema + template). Note:
  user_id MUST be distinct per seat — the staging model dedups with
  `LIMIT 1 BY tenant, source, user_id, date`, so a shared/NULL user_id collapses
  the cohort to one row and the team median is wrong.
- claude_enterprise__ai_dev_usage: same empty-table watermark guard as the other
  AI staging models (INTERVAL 3 DAY underflows over an empty `this`).
- conftest: reset staging.claude_enterprise__ai_dev_usage at session start.

Verified locally: 2 passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergei Mozhaev <mozhaev.dev@gmail.com>
@mozhaev-dev
mozhaev-dev force-pushed the test/e2e-ai-claude-enterprise branch from 3c4ca32 to e2d5e36 Compare June 30, 2026 08:57
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.

2 participants