AI/Tasks/OrchestratorUpgrades/Orchestrator_Phase03_ToolPolicyAuthorization_Implementation.txt

PHASE 03 IMPLEMENTATION PROMPT - TOOL POLICY AND AUTHORIZATION HARDENING
 
Goal:
Implement a centralized tool registry and fail-closed authorization path so tool execution is validated before side effects occur.
 
Inputs:
- AI/Tasks/OrchestratorUpgrades/Orchestrator_Phase03_ToolPolicyAuthorization_Strict.txt
- AI/Tasks/OrchestratorUpgrades/Overview.txt
 
Required code work:
- Add or finalize a `ToolPolicy` model and registry for tool metadata, validation constraints, and authorization rules.
- Centralize mutation authorization and validate path-policy decisions before execution.
- Replace raw exception flattening with structured tool-execution results and redacted diagnostics.
- Add postcondition verification for write operations and mutation integrity checks.
 
Implementation constraints:
- Keep state-model and retry semantics separate from tool authorization work.
- Preserve current behavior except where policy enforcement is centralized and hardened.
- Do not implement full decision schema revision, loop-progress detection, NOAA routing hardening, or memory-privacy changes in this phase.
 
Minimum tests to add/update:
- Tool registry membership and validation tests.
- Authorization fail-closed tests for destructive or path-unsafe actions.
- Structured tool-result and postcondition verification tests.
- Negative path and mutation tests.
 
Validation commands:
- dotnet build src/TechToolbox.Agent/TechToolbox.Agent.csproj -c Release
- dotnet test src/TechToolbox.Agent/Tests/TechToolbox.Agent.Tests.csproj -c Release --filter "Orchestrator|Tool|Policy|Authorization|Safety|Strict"
 
Deliverable:
Return changed files, the final policy and authorization contract, and proof that mutation flows are centralized and fail-closed.