mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 06:52:20 +02:00
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
"""Dispatcher doubles must simulate the receipt boundary as well as the result."""
|
|
from src.agent_runtime.journal import mark_dispatch, record_action
|
|
|
|
|
|
def server_authorized_executor(executor):
|
|
"""Give standalone dispatcher fixtures their explicit server grants.
|
|
|
|
These existing suites exercise handlers, policy, confinement and approvals.
|
|
Their fixture grants cover the declared native tool registry, independently
|
|
of the proposed block. Request-authority denial tests use the raw dispatcher.
|
|
"""
|
|
from functools import wraps
|
|
from inspect import signature
|
|
from src.agent_runtime.authority import OperationGrant, RequestAuthority
|
|
from src.tool_policy import known_tool_names
|
|
from src.turn_contract import canonical_tool
|
|
call_signature = signature(executor)
|
|
@wraps(executor)
|
|
async def execute(*args, **kwargs):
|
|
bound = call_signature.bind(*args, **kwargs)
|
|
parameters = bound.arguments
|
|
kwargs.setdefault("request_authority", RequestAuthority(
|
|
"standalone-test-request", str(parameters.get("owner") or "").strip().casefold(),
|
|
str(parameters.get("session_id") or ""), str(parameters.get("workspace") or ""),
|
|
tuple(OperationGrant(name) for name in sorted(
|
|
{canonical_tool(n) for n in known_tool_names()} | {"list_dir", "find_files"})),
|
|
))
|
|
return await executor(*args, **kwargs)
|
|
return execute
|
|
|
|
|
|
def authoritative_executor(function):
|
|
@record_action
|
|
async def execute(block, *args, **kwargs):
|
|
mark_dispatch()
|
|
return await function(block, *args, **kwargs)
|
|
return execute
|