You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add tool requirements policy enforcement system
Introduces a PreToolUse hook-based policy system that evaluates tool calls
against RFC 2119-style requirements defined in .deepwork/tool_requirements/*.yml.
Policies are checked via an HTTP sidecar server (spawned alongside the MCP server)
using Haiku for semantic evaluation. Failed checks can be appealed via a new
appeal_tool_requirement MCP tool. Approvals are cached with a 1-hour TTL.
Key features:
- Policy files with tools, match (param regex), requirements, extends (inheritance)
- no_exception rules that cannot be appealed
- Fail-closed: hook denies if MCP sidecar is unreachable
- Loop prevention: appeal tool calls skip the hook
- Multi-instance support via PID-keyed + session-keyed port files
- Evaluator encapsulated behind ABC for future swap to direct API calls
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
"description": "Schema for .deepwork/tool_requirements/*.yml policy files that define RFC 2119-style rules for AI agent tool calls.",
5
+
"type": "object",
6
+
"required": ["tools", "requirements"],
7
+
"additionalProperties": false,
8
+
"properties": {
9
+
"summary": {
10
+
"type": "string",
11
+
"description": "Human-readable summary of what this policy enforces."
12
+
},
13
+
"tools": {
14
+
"type": "array",
15
+
"description": "Normalized tool names (shell, write_file, edit_file, etc.) or MCP tool names (mcp__server__tool) this policy applies to.",
16
+
"items": {
17
+
"type": "string"
18
+
},
19
+
"minItems": 1
20
+
},
21
+
"match": {
22
+
"type": "object",
23
+
"description": "Optional parameter-level filtering. Keys are tool_input parameter names, values are regex patterns. Policy only applies when at least one pattern matches.",
24
+
"patternProperties": {
25
+
"^[a-zA-Z0-9_-]+$": {
26
+
"type": "string"
27
+
}
28
+
},
29
+
"additionalProperties": false
30
+
},
31
+
"extends": {
32
+
"type": "array",
33
+
"description": "List of policy file stems to inherit requirements from.",
34
+
"items": {
35
+
"type": "string"
36
+
}
37
+
},
38
+
"requirements": {
39
+
"type": "object",
40
+
"description": "RFC 2119 keyed requirements. Keys are requirement identifiers, values define the rule and exception policy.",
41
+
"patternProperties": {
42
+
"^[a-zA-Z0-9_-]+$": {
43
+
"type": "object",
44
+
"required": ["rule"],
45
+
"additionalProperties": false,
46
+
"properties": {
47
+
"rule": {
48
+
"type": "string",
49
+
"description": "RFC 2119 statement (using MUST, SHOULD, MAY, etc.)."
50
+
},
51
+
"no_exception": {
52
+
"type": "boolean",
53
+
"description": "If true, this requirement cannot be appealed. Defaults to false.",
0 commit comments