feat(events): auto-detect and persist platform_source on correction events#66
Conversation
…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>
There was a problem hiding this comment.
Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Deploying gradata-dashboard with
|
| 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 |
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_sourceto event data atemit()time. No signature changes tocorrect().Files
src/gradata/_platform.py(new) —detect_platform_source()withGRADATA_PLATFORM_SOURCEoverridesrc/gradata/_events.py— 1-linedata.setdefault("platform_source", detect_platform_source())at emittests/test_platform_source.py— 16 round-trip testsTests
2273 pass (+16), ruff clean. Composes cleanly with
applies_tofrom PR #57 (explicit test).Commits
a9021b7feat(events): auto-detect and persist platform_source737aa2brefactor(platform): hoist detector import, collapse env tables, kill dead exceptCo-Authored-By: Gradata noreply@gradata.ai