Skip to content

feat(events): auto-detect and persist platform_source on correction events#66

Merged
Gradata merged 2 commits into
mainfrom
wt-platform-source-tagging
Apr 15, 2026
Merged

feat(events): auto-detect and persist platform_source on correction events#66
Gradata merged 2 commits into
mainfrom
wt-platform-source-tagging

Conversation

@Gradata

@Gradata Gradata commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

Auto-detects the platform each correction came from (claude-code / cursor / windsurf / mcp-server / anthropic-sdk / openai-sdk / raw-python) via env-var sniff. Attaches platform_source to event data at emit() time. No signature changes to correct().

Files

  • src/gradata/_platform.py (new) — detect_platform_source() with GRADATA_PLATFORM_SOURCE override
  • src/gradata/_events.py — 1-line data.setdefault("platform_source", detect_platform_source()) at emit
  • tests/test_platform_source.py — 16 round-trip tests

Tests

2273 pass (+16), ruff clean. Composes cleanly with applies_to from PR #57 (explicit test).

Commits

  • a9021b7 feat(events): auto-detect and persist platform_source
  • 737aa2b refactor(platform): hoist detector import, collapse env tables, kill dead except

Co-Authored-By: Gradata noreply@gradata.ai

Gradata and others added 2 commits April 15, 2026 00:14
…vents

Add env-var-based platform detection (claude-code, cursor, windsurf,
mcp-server, anthropic-sdk, openai-sdk, raw-python) and enrich every
event emitted via _events.emit() with a platform_source key on its
data dict. No public API signatures change; detection runs at
event-emit time so correction signatures stay untouched and this
stacks cleanly on top of the applies_to scope work in PR #57.

- src/gradata/_platform.py: new detect_platform_source() helper,
  ordered checks (IDE beats SDK), GRADATA_PLATFORM_SOURCE override.
- src/gradata/_events.py: copy caller data dict, inject
  platform_source unless already present, preserve existing value
  (so callers/backfill tools can force it).
- tests/test_platform_source.py: 16 tests covering env detection,
  override, fallback, non-mutation of caller dicts, and coexistence
  with applies_to-style scope metadata.

Co-Authored-By: Gradata <noreply@gradata.ai>
…ables

- _events.emit: hoist detect_platform_source import to module top so it
  isn't re-looked-up on every event emit; drop the impossible
  try/except-ImportError fallback (sibling module, can't fail to import).
  Collapse the two-line "check-then-set" to data.setdefault().
- _platform: collapse _PLATFORM_ENV_CHECKS + _SDK_ENV_CHECKS into one
  ordered tuple — iteration is identical and IDE-beats-SDK is already
  expressed by tuple order. Simplify override handling: strip once,
  return if truthy, else fall through. Extract _OVERRIDE_ENV / _FALLBACK
  constants.

No behavior change. 2273 tests pass, ruff clean.

Co-Authored-By: Gradata <noreply@gradata.ai>

@greptile-apps greptile-apps 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.

Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Gradata has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 39 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 39 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0bea0939-6788-45ea-87cd-a5ad85796d37

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd7215 and 737aa2b.

📒 Files selected for processing (3)
  • src/gradata/_events.py
  • src/gradata/_platform.py
  • tests/test_platform_source.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wt-platform-source-tagging

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying gradata-dashboard with  Cloudflare Pages  Cloudflare Pages

Latest commit: 737aa2b
Status: ✅  Deploy successful!
Preview URL: https://a1eb395d.gradata-dashboard.pages.dev
Branch Preview URL: https://wt-platform-source-tagging.gradata-dashboard.pages.dev

View logs

@Gradata Gradata merged commit 63a6ae3 into main Apr 15, 2026
16 checks passed
@Gradata Gradata deleted the wt-platform-source-tagging branch April 17, 2026 19:47
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