fix(opax): restore literal tool risk policy

This commit is contained in:
Chris Christiansen 2026-09-16 17:38:39 +00:00
parent 3a2aae98aa
commit f49cbc4612

View File

@ -2,7 +2,7 @@
Derives a trusted CallerContext from a request. Derives a trusted CallerContext from a request.
""" """
from typing import Dict, Any 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). # 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. # 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", "workspace_id": "ws:vauco",
"allowed_tool_policy": { "allowed_tool_policy": {
# This profile can read anything but requires approval for all writes # This profile can read anything but requires approval for all writes
"default": ToolRiskLevel.REQUIRES_APPROVAL, "default": "requires_approval",
"read_only": ToolRiskLevel.READ_ONLY, "read_only": "read_only",
"propose_only": ToolRiskLevel.PROPOSE_ONLY, "propose_only": "propose_only",
"forbidden": ToolRiskLevel.FORBIDDEN, "forbidden": "forbidden",
} }
}, },
"user:chris.christiansen@vauco.no": { "user:chris.christiansen@vauco.no": {
@ -25,9 +25,9 @@ _CALLER_REGISTRY: Dict[str, Dict[str, Any]] = {
"workspace_id": "ws:vauco", "workspace_id": "ws:vauco",
"allowed_tool_policy": { "allowed_tool_policy": {
# Admin can do safe writes directly, but needs high approval for destructive actions # Admin can do safe writes directly, but needs high approval for destructive actions
"default": ToolRiskLevel.REQUIRES_HIGH_APPROVAL, "default": "requires_high_approval",
"read_only": ToolRiskLevel.READ_ONLY, "read_only": "read_only",
"requires_approval": ToolRiskLevel.REQUIRES_APPROVAL, # Can do normal writes "requires_approval": "requires_approval", # Can do normal writes
} }
} }
} }
@ -38,7 +38,7 @@ _DEFAULT_CALLER_CONTEXT = CallerContext(
profile="readonly", profile="readonly",
owner_id="system:public", owner_id="system:public",
workspace_id="ws: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: def derive_caller_context(auth_identifier: str) -> CallerContext:
@ -61,6 +61,6 @@ def derive_caller_context(auth_identifier: str) -> CallerContext:
return CallerContext( return CallerContext(
caller_id=auth_identifier, 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 **caller_data
) )