fix(opax): restore literal tool risk policy
This commit is contained in:
parent
3a2aae98aa
commit
f49cbc4612
|
|
@ -2,7 +2,7 @@
|
|||
Derives a trusted CallerContext from a request.
|
||||
"""
|
||||
from typing import Dict, Any
|
||||
from contracts.common import CallerContext, ToolRiskLevel
|
||||
from contracts.common import CallerContext
|
||||
|
||||
# This is a placeholder for a future, more robust caller registry (e.g., Firestore).
|
||||
# The key would be the hash of the API key or the IAP-verified user email.
|
||||
|
|
@ -13,10 +13,10 @@ _CALLER_REGISTRY: Dict[str, Dict[str, Any]] = {
|
|||
"workspace_id": "ws:vauco",
|
||||
"allowed_tool_policy": {
|
||||
# This profile can read anything but requires approval for all writes
|
||||
"default": ToolRiskLevel.REQUIRES_APPROVAL,
|
||||
"read_only": ToolRiskLevel.READ_ONLY,
|
||||
"propose_only": ToolRiskLevel.PROPOSE_ONLY,
|
||||
"forbidden": ToolRiskLevel.FORBIDDEN,
|
||||
"default": "requires_approval",
|
||||
"read_only": "read_only",
|
||||
"propose_only": "propose_only",
|
||||
"forbidden": "forbidden",
|
||||
}
|
||||
},
|
||||
"user:chris.christiansen@vauco.no": {
|
||||
|
|
@ -25,9 +25,9 @@ _CALLER_REGISTRY: Dict[str, Dict[str, Any]] = {
|
|||
"workspace_id": "ws:vauco",
|
||||
"allowed_tool_policy": {
|
||||
# Admin can do safe writes directly, but needs high approval for destructive actions
|
||||
"default": ToolRiskLevel.REQUIRES_HIGH_APPROVAL,
|
||||
"read_only": ToolRiskLevel.READ_ONLY,
|
||||
"requires_approval": ToolRiskLevel.REQUIRES_APPROVAL, # Can do normal writes
|
||||
"default": "requires_high_approval",
|
||||
"read_only": "read_only",
|
||||
"requires_approval": "requires_approval", # Can do normal writes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ _DEFAULT_CALLER_CONTEXT = CallerContext(
|
|||
profile="readonly",
|
||||
owner_id="system:public",
|
||||
workspace_id="ws:public",
|
||||
allowed_tool_policy={"default": ToolRiskLevel.READ_ONLY}
|
||||
allowed_tool_policy={"default": "read_only"}
|
||||
)
|
||||
|
||||
def derive_caller_context(auth_identifier: str) -> CallerContext:
|
||||
|
|
@ -61,6 +61,6 @@ def derive_caller_context(auth_identifier: str) -> CallerContext:
|
|||
|
||||
return CallerContext(
|
||||
caller_id=auth_identifier,
|
||||
caller_type=auth_identifier.split(":")[0], # cheap trick
|
||||
caller_type='human' if auth_identifier.startswith('user:') else auth_identifier.split(":")[0], # cheap trick
|
||||
**caller_data
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user