main
md 65 lines 3.39 KB
Rendered Raw
1 # tool_policy.py DOX
2
3 ## Purpose
4
5 - Own the single project/profile-aware tool policy used by catalogs, prompts, native
6 schemas, local execution, MCP invocation, and delegated agents.
7
8 ## Ownership
9
10 - `normalize_policy` owns the sparse allow/block configuration shape.
11 - `get_tool_catalog` owns canonical local, plugin, and MCP identities plus
12 unavailable-policy retention; local entries come from executable `tools/*.py`
13 files in the runtime path hierarchy. The catalog describes installed
14 capabilities independently of transient transport availability; connector
15 prompt/schema extensions remain responsible for live remote-tool exposure.
16 The editor applies the current draft policy instead of receiving duplicated
17 allowed/required flags from the backend.
18 - `tool_prompt_description` owns the shared compact description extracted for
19 the editor catalog and provider-native schemas; transport-specific names and
20 schemas remain with their transports.
21 - `resolve_tool` returns the effective decision and provenance.
22 - `ensure_tool_allowed` raises the stable repairable runtime policy error and
23 accepts an explicit canonical ID from transports that already resolved one.
24 - `filter_tool_prompt` removes denied local capabilities from the text protocol,
25 including complete fenced JSON examples that reference them, without taking
26 ownership of provider-native naming rules.
27
28 ## Runtime Contracts
29
30 - Scoped asset precedence comes from `helpers.plugins`: active project profile,
31 active project, user profile, bundled/plugin profile, then default.
32 `get_policy` selects the first custom policy; unknown-only and
33 explicit-inherit files remain on disk but defer to the next lower layer.
34 - Missing policy inherits standard access. A custom policy records independent
35 defaults for local/plugin tools and canonical MCP tools; explicit allowed or
36 blocked IDs take precedence over either default.
37 - Inherited prompt policy returns tool text unchanged without inventorying or
38 resolving individual tools; only custom policy pays the filtering cost.
39 - The `response` capability is a framework-required invariant: profile policy
40 cannot disable it, and the editor does not list it as a configurable tool.
41 - `vision_load` remains owned by the active chat model's vision configuration;
42 it is not exposed as a profile-policy choice and legacy policy IDs cannot
43 suppress the chat-configured capability.
44 - Policy IDs are namespaced as `local:`, `plugin:<id>:`, or `mcp:<server>:`.
45 Generic execution resolves canonical IDs from executable paths; MCP
46 invocation supplies its explicit namespaced ID.
47 - Plugin IDs are derived relative to the canonical roots from `helpers.plugins`,
48 not by independently parsing repository-relative path strings.
49 - Each executable local tool has its own policy identity, including tools that
50 share one Markdown prompt.
51 - Catalog descriptions call the supplied agent's prompt loader instead of
52 opening prompt files through a parallel path; the editor agent intentionally
53 keeps its existing raw, no-processor implementation.
54 - MCP catalog labels include a human-readable server and tool name while
55 canonical IDs retain the exact transport-qualified spelling.
56 - Unknown policy IDs remain in the catalog as unavailable entries.
57 - Resolution performs no model calls and logs no secrets.
58
59 ## Verification
60
61 - Run `tests/test_tool_policy.py` and the prompt/Responses/MCP focused tests.
62
63 ## Child DOX Index
64
65 No child DOX files.