← Back to Pull requests

Add target_kind to UsageEvent #1224

Closed
unknown closed this pull request without merging on Nov 09, 2026 18:40 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 16:48 UTC
Author

Summary

UsageEvent does not say what kind of thing its target is. A consumer that records app-level sign-ins (for example "last login" for the connector's own app) cannot tell a sign-in to the app itself from use of an app reached through it. Today such a consumer has to match connector-specific target IDs, such as app/dropbox or usage-app/github, keyed by connector type. That does not work for self-hosted connectors, and it cannot separate targets that share one resource type (Google Workspace uses enterprise_application for both its own sign-ins and OAuth clients).

This PR adds an optional target_kind field (number 5) with a nested TargetKind enum to UsageEvent. TARGET_KIND_CHILD_APP is the common case, and an unset value means the same, so existing connectors keep their meaning and need no change. Connectors that emit sign-ins to their own app set TARGET_KIND_APP_ACCESS on those events. The field has no validate rule, so a value added later cannot make a consumer reject a whole event.

Changes

  • proto/c1/connector/v2/event_feed.proto: UsageEvent.target_kind = 5 and UsageEvent.TargetKind (TARGET_KIND_UNSPECIFIED = 0, TARGET_KIND_CHILD_APP = 1, TARGET_KIND_APP_ACCESS = 2).

  • Regenerated event_feed.pb.go, event_feed_protoopaque.pb.go and event_feed.pb.validate.go with make protogen.

  • event_feed_validate_test.go: TestUsageEventTargetKind covers the unset value, both defined values and an unknown value (99): validation passes and the value survives a marshal round-trip.
  • Compatibility

  • The field is additive, so buf breaking against main passes.

  • Older consumers ignore the field.

  • Newer consumers read an unset value from older connectors as TARGET_KIND_UNSPECIFIED, which means TARGET_KIND_CHILD_APP.
  • Testing

  • buf lint

  • buf breaking --against '.git#branch=origin/main'

  • go build ./...

  • go test ./pb/c1/connector/v2/...

  • go vet ./pb/c1/connector/v2/
  • Follow-ups (separate PRs)

  • Set TARGET_KIND_APP_ACCESS in baton-aws (SSO sign-ins), baton-github (usage-app/github), baton-dropbox (app/dropbox), baton-google-workspace (the Google sign-in feed) and baton-teleport.

  • Consume the field in ConductorOne.
  • 🤖 Generated with Claude Code

    Diff: 286 lines (+214 / -72) across 3 files Reviewer: ggreer Review duration: 111m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 286 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.339
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1224"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.8% (MEDIUM) · Higher = larger blast radius
    39.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.7% · Safe to merge
    15.7%