Add DutyMappingsAnnotation for entitlement duty mappings #1226
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
ggreer
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.
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/dutyin a separate release, once the product details are settled and the feature is closer to release.duty.Exactandduty.Inclusiveaccept any string-like type, asfield.WithTagsdoes, so typed names can be added then without an API change.Changes
annotation_duty.proto:DutyMappingsAnnotation { repeated DutyMapping mappings },DutyMapping { duty_id, precision, description }, andDutyMappingPrecision(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:
-
mappingshas between 1 and 16 entries.-
duty_idis 1 to 64 characters matching^[a-zA-Z0-9_.-]+$.-
precisionmust not beUNSPECIFIED. Values this version does not define are allowed, so a later value does not invalidate the annotation for an older reader.-
descriptionis an optional note of at most 1024 characters.pkg/duty(new):- Builders
Exact(id, description...)andInclusive(id, description...)return av2.DutyMapping. The description is an optional note.-
Validateruns 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-validateuniquerule 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 passduty.Validate.-
Cases()returns the wire-contract cases with their expectedduty.Validateresult, 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: takesv2.DutyMappingvalues, puts them in one annotation and returnsWithAnnotation. 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."redacted". Duty IDs are connector-supplied strings and may name app-specific objects. Without a handler, the sanitizer dropped the annotation.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
dutytestin the connector's tests and by the consumer when it reads the annotation.Not in this PR
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.dutytest.Cases().Test plan
go testonpkg/duty,pkg/types/entitlement,pkg/connectorbuilder,pkg/c1zsanitize,pkg/annotations,internal/chaosconnector, and the ledger static-entitlement test inpkg/syncbuf lint,buf format,buf breaking🤖 Generated with Claude Code