Skip to content

Commit 3cd924e

Browse files
jopemachineclaude
andcommitted
doc: explain what target_element resolves for a scoped search
The public branch names the fragment element while domain / user name their owner, which reads backwards until you know target_element is the permission chain's entry point rather than the entity being acted on. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fb589a4 commit 3cd924e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/ai/backend/manager/services/app_config_fragment/actions/scoped_search.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ def scope_id(self) -> str:
4444

4545
@override
4646
def target_element(self) -> RBACElementRef:
47-
element = self.scope.scope_type.to_rbac_element_type()
48-
if element is None:
47+
"""The element RBAC enters the permission chain at — the scope owner, not the fragment.
48+
49+
A domain / user scope resolves from its owner element. ``public`` is global and owns
50+
no element, so it names the fragment element with an empty id, which only a
51+
superadmin passes.
52+
"""
53+
owner_element = self.scope.scope_type.to_rbac_element_type()
54+
if owner_element is None:
4955
return RBACElementRef(RBACElementType.APP_CONFIG_FRAGMENT, "")
50-
# A non-null element type means domain or user scope, which always carries an owner.
51-
return RBACElementRef(element, str(self.scope.scope_id))
56+
return RBACElementRef(owner_element, str(self.scope.scope_id))
5257

5358

5459
@dataclass

0 commit comments

Comments
 (0)