← Back to Pull requests

Add DutyMappingsAnnotation for entitlement duty mappings #1226

Closed
unknown closed this pull request without merging on Nov 17, 2026 21:27 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 22:08 UTC
Author

Summary

Connectors can now declare which business duties an entitlement allows. ConductorOne is meant to read these mappings for separation-of-duties checks. The annotation carries only facts the connector knows about its own app.

entitlement.NewPermissionEntitlement(r, "release",
    entitlement.WithDuties(duty.Exact("payment.release")),
)
entitlement.NewPermissionEntitlement(role, "member",
    entitlement.WithDuties(
        duty.Inclusive("payment.release"),
        duty.Inclusive("payment.authorize", "Finance Administrator role"),
    ),
)

A duty ID is a plain string defined by ConductorOne's duty catalog. This PR does not ship a list of duty names. The list will be added to pkg/duty in a separate release, once the product details are settled and the feature is closer to release. duty.Exact and duty.Inclusive accept any string-like type, as field.WithTags does, so typed names can be added then without an API change.

Changes

  • Proto annotation_duty.proto: DutyMappingsAnnotation { repeated DutyMapping mappings }, DutyMapping { duty_id, precision, description }, and DutyMappingPrecision (EXACT, INCLUSIVE).

  • - EXACT: the entitlement exists to grant this one duty.
    - INCLUSIVE: a broad entitlement that allows this duty among others.
    - Both match rules the same way; the difference is the evidence shown. When whether an entitlement allows a duty depends on a setting the connector does not read, the connector omits the mapping.
    - Field rules:
    - mappings has between 1 and 16 entries.
    - duty_id is 1 to 64 characters matching ^[a-zA-Z0-9_.-]+$.
    - precision must not be UNSPECIFIED. Values this version does not define are allowed, so a later value does not invalidate the annotation for an older reader.
    - description is an optional note of at most 1024 characters.
  • pkg/duty (new):

  • - Builders Exact(id, description...) and Inclusive(id, description...) return a v2.DutyMapping. The description is an optional note.
    - Validate runs the field rules, rejects a duty ID listed twice, and requires each duty ID to follow the <object>.<action> naming convention (^[a-z][a-z0-9_]
    \.[a-z][a-z0-9_]$). The convention is checked in Go only; the proto field rule is the character set and length. The protoc-gen-validate unique rule does not cover message items, so uniqueness is also checked here.
  • pkg/duty/dutytest (new):

  • - AssertEntitlement(t, ent) fails a test when an entitlement has more than one duty annotation or one that does not pass duty.Validate.
    - Cases() returns the wire-contract cases with their expected duty.Validate result, including the 16-mapping limit, an undefined precision value, and IDs that pass the field rule but not the naming convention. A consumer can import them to test its reader against the same annotations.
  • entitlement.WithDuties: takes v2.DutyMapping values, puts them in one annotation and returns WithAnnotation. With no mappings it attaches nothing. It does not merge or de-duplicate, so call it once per entitlement with all of the entitlement's duties.

  • c1zsanitize: keeps precision, replaces every duty ID with a keyed hash, and replaces a non-empty description with "redacted". Duty IDs are connector-supplied strings and may name app-specific objects. Without a handler, the sanitizer dropped the annotation.

  • chaosconnector: registers the annotation as preserved domain data.
  • Nothing runs on the sync path. connectorbuilder does not inspect duty annotations, and the syncer stores entitlement annotations unchanged; static entitlement materialization copies them to each generated entitlement, and a test covers the copy. A bad duty annotation is caught by dutytest in the connector's tests and by the consumer when it reads the annotation.

    Not in this PR

  • The list of duty names in pkg/duty, and a check of a connector's duty IDs against it. Until then a misspelled duty ID that follows the naming convention is not caught by the SDK.

  • A precision for mappings that depend on a setting.

  • ConductorOne does not read this annotation yet. The ingest work should validate and skip per mapping rather than per annotation, keep mappings with an unrecognized duty ID or precision and surface unrecognized IDs, and test against dutytest.Cases().
  • Test plan

  • go test on pkg/duty, pkg/types/entitlement, pkg/connectorbuilder, pkg/c1zsanitize, pkg/annotations, internal/chaosconnector, and the ledger static-entitlement test in pkg/sync

  • buf lint, buf format, buf breaking

  • golangci-lint on the changed packages
  • 🤖 Generated with Claude Code

    Diff: 592 lines (+444 / -148) across 7 files Reviewer: ggreer Review duration: 11479m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 592 lines diff across 7 files
    0.50
    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.382
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1226"
    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: 50.0% (MEDIUM) · Higher = larger blast radius
    50.0%
    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: 19.8% · Safe to merge
    19.8%