Repository navigation
feat(guardrails): tool-access profiles — one choice sets read-only mode and the tools an agent can't use (abilityai/trinity-enterprise#341) - #4232
Conversation
…de and the tools an agent can't use (Abilityai/trinity-enterprise#341) Settings › Guardrails gains a Tool access section: Full access (default), Workspace-only, Read-only + report, Strict read-only and Custom. A profile is a fixed bundle that sets the read-only layer and `disallowed_tools` together, so the two can no longer disagree; read-only mode IS the Strict profile, and the header and Dashboard-list Read-only toggle is its shortcut (ON for Strict only, OFF returns to the profile it came from), now sent through the agents store. - Storage is materialized: `disallowed_tools` and the read-only columns stay exactly what is enforced, so env injection, the drift check's inputs and the base image are unchanged. `guardrails_config.tool_access` records the choice (and Custom's remembered settings); the drift check ignores it. No migration. - Nothing changes on upgrade: an agent with no stored profile has it derived; a read-only agent reads "Strict read-only · send block not applied" + Apply. - Three writers (PUT /tool-access, PUT /read-only, PUT /guardrails) share one compare-and-set over the guardrails blob and the read-only columns (409 on a lost race); racing live applies converge to the row; every change is audited with the before and after state. - The send block is refused by the backend, not only hidden: the nine routes behind the seven send tools and report refuse an agent-scoped caller (or the agent it sends as) whose enforced list names the tool, on every runtime. - The toggle never loosens silently: ON from a list that removes tools Strict allows is a 409 naming them. - Per-runtime coverage on every card; GET /guardrails shows the profile id only. - No MCP surface: no tool reads or writes a profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt and the view switch (#1953) The Dashboard list was the last toast on `fixed top-20 right-4`, where it covered Create Agent and the Timeline/Grid/List buttons; the tool-access toggle's longer sentences made it cover more. Same placement as AgentDetail.vue and FilesPanel.vue (`bottom-24` clears the help FAB). Pinned by agentListToastPlacement.mount.spec.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolutions: - check_guardrails_env_matches: the drift check ignores both live keys, ent#926's visitor_shell and this branch's tool_access. - tests/registry.json: both sides' new entries kept (additive). - agent_route_tiers.json: owner-tier rows for GET/PUT /tool-access. - GuardrailsPanel: the ent#926 visitor-shell toggle's stored copy also leaves out tool_access and disallowed_tools once a profile is stored (spec added). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
merge-train (2026-11-04): merged at |
…4243) — train decision at Gate 1, see the PR note #4232 (trinity-enterprise#341) landed on dev after this PR's last dev merge and added the send block, services/tool_access_guard.py::assert_tool_allowed, in front of nine send routes. It is a per-agent tool restriction, never a grant, so the ent#719 scan lists it under NOT_GRANT_GUARDS with the nine routes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ited, the saved-token fork takes a session, and no grant rests on an agent-only check (#4243) * fix(auth): human-only MCP tools follow their routes, refusals are audited, the saved-token fork takes a session, and no grant rests on an agent-only check - MCP listing: each tool whose route needs a person or a signed-in session is listed through one shared predicate, so no key is shown a tool its scope can never call; within a listed scope the route still decides. The descriptions state each route's rule. - MCP refusal reasons: a backend 403 whose detail is the person_required object, or the signed-in-session sentence, maps to the human-only answer. - Audit: the human-only primitives raise HumanOnlyRefused, and an app handler records one row per refused attempt, bounded per principal and route, with no request body; the response is unchanged and an audit failure still answers 403. - Agent creation: the arm that spends the creator's saved token as the new agent's is a credential bind and takes a signed-in session. - A static scan fails any grant route that rests on an agent-only check alone; it lists one reviewed deferral. The feature-flows index carries one row for the issue. Part of Abilityai/trinity-enterprise#719 * fix(mcp): inject_credentials and set_agent_github_pat are listed to a person's key On dev, writing a credential the caller supplies into its own agent takes a person (the ruled exception in requirements/auth.md §2.8): POST .../credentials/inject and PUT .../github-pat are require_person. The listing still treated inject as a signed-in-session bind (shown to no key) and said setting a per-agent PAT needed a session, so a person's own user key was hidden a tool its route admits. Both now take the person predicate; the visibility tests follow (3 + 14 + 13 refusals, 10 person/interactive rows, 10 user-listed tools on a fresh install). Part of Abilityai/trinity-enterprise#719 * docs(mcp): a fork through create_agent is refused for every key The create_agent fork block (ent#1007) relies on the backend spending the caller's saved GitHub token. That arm makes the token the new agent's own, a credential bind, so it runs only from a signed-in session, and an MCP call never is one. The tool description and the docs that said the tool spends the saved token now say a fork made through it is refused FORK_PAT_REQUIRED for every key and is created from the web UI. Part of Abilityai/trinity-enterprise#719 * fix(auth): the autonomy dial's owner writes take a person The Workspace door admits the system key for the Workspace's uses, and it resolves to the admin who owns the install, so the dial's owner check alone let it release a person's held class and rewrite the guard cap (both 200 before this). Releasing is a grant in the route's own words. Both writes now refuse a caller that is not a person first, as the readiness, canvas-pin and seat-decision writes beside them do. The grant scan found both, and the agent's own seat-decision record: its two agent-only checks narrow an agent key to its running turn and grant nothing, so they are listed as reviewed non-grants. Mutation: with the two person checks removed, four system-key cases in test_ent719_workspace_autonomy_person_only.py go red and the scan reports both routes. Part of Abilityai/trinity-enterprise#719 * docs(auth): the deferred grant and the remaining baseline point at their follow-up The scan's one deferral and the census baseline's remaining entries are tracked in trinity-enterprise#985, the follow-up filed for this issue. Part of Abilityai/trinity-enterprise#719 * docs(mcp): the credential and PAT tool lines say a person's key reaches inject and a PAT set Follows the listing change: inject_credentials and setting a per-agent PAT take a person on dev, so the lines that said they take a signed-in session, or that a user key can only clear a PAT, now say a person's own user key reaches both. Part of Abilityai/trinity-enterprise#719 * test(mcp): the fetch stubs compare the backend origin, not a URL prefix CodeQL reads url.startsWith(BACKEND) as an incomplete URL check. In these stubs it only routes a stubbed fetch, but comparing the origin says the same thing exactly and clears the alert. 70/70 pass in both files. Part of Abilityai/trinity-enterprise#719 * merge-train: list assert_tool_allowed as a reviewed non-grant guard (#4243) — train decision at Gate 1, see the PR note #4232 (trinity-enterprise#341) landed on dev after this PR's last dev merge and added the send block, services/tool_access_guard.py::assert_tool_allowed, in front of nine send routes. It is a per-agent tool restriction, never a grant, so the ent#719 scan lists it under NOT_GRANT_GUARDS with the nine routes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(auth): drop the two seat-decision NOT_GRANT_GUARDS entries #4204 made stale #4204 (ent#1062) made the seat-decision doors agent-only, so the person path these entries described is gone and the scan reports them stale. * test(auth): list the room-wake and Continue routes dev added under NOT_GRANT_GUARDS On the merged tree the grant scan reported six routes resting on an agent-only check alone. None is a grant: - trinity-enterprise#1135 returns an ended ask to its room on the agent's next start, so start, chat, task result and system deploy/restart now reach the room wake, and through the engine's reply post, `tagger_for`. That post carries no tags (`post_message` asks for a tagger only for a sender's own tags), so the check never runs there. - trinity#4302's Continue reaches `tagger_for` the same way, and calls `assert_tool_allowed` for parity with `/messages`. Its person check is `_is_room_person` in the service. --------- Co-authored-by: trinity-ability <309458136+trinity-ability@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Summary
disallowed_toolslist together, so the two can no longer disagree. Each card states in plain language what the agent can and cannot do, plus one coverage line for the agent's runtime.fetch/ direct axios calls are gone). The General pane's read-only row moved into Tool access.send_message,send_group_message,send_notification,send_voice_reply,call_user,post_to_room,share_file) andreportrefuse an agent-scoped caller whose enforced list names the tool. The same refusal applies to the agent a route sends as. It works on every runtime, whatever path the call took (shell, an aliased MCP entry). The tool-list removal stays as a second layer.--sandboxdanger-full-accessdanger-full-accessread-onlyreportread-onlyHow it works
guardrails_config.disallowed_toolsand the read-only columns stay exactly what is enforced, so env injection,write-runtime-config.pyand the drift check's inputs are unchanged.guardrails_config.tool_accessrecords the choice: the profile, Custom's remembered settings, and where the shortcut returns. The drift check ignores it next tovisitor_shell.PUT /tool-access(new),PUT /read-only(the shortcut), andPUT /guardrails(keeps the stored profile).agents.manage, never the agent on itself. The system agent is refused.GET /tool-accessis owner tier.GET /guardrailsnow shows only the profile id.services/tool_access_profiles.py: the pure policy.services/agent_service/tool_access.py: reads and writers.services/tool_access_guard.py: the send check.agent-settings/ToolAccessSection.vue.bottom-24 right-6, the fix(ui): Agent Detail toast overlaps the agent header controls (Running toggle + Delete) #1953 placement AgentDetail and FilesPanel already use. It covered Create Agent and the view switch, and the toggle's longer messages made that worse.visitor_shelltoggle in the rules editor leaves the profile and its list out of its save once a profile is stored.Stated limits
A failed live read-only apply is reported only by the save that tried it (
read_only_applied: false,restart_required: true). A later read does not remember it. The next agent start re-syncs the read-only file from the row.Agent-to-agent asks aren't sends.
chat_with_agent,fan_out,call_a2a_agent,emit_eventandask_operatorare not removed by any profile. So a blocked agent can ask another agent to send, which then sends under its own identity and its own profile.Codex and Gemini enforce what the coverage lines say.
Test plan
0dab359af. Covered: a legacy read-only agent reading as Strict with Apply, all five profiles and their toasts, Customize → Custom withBash, the 51-line error, and the header and Dashboard-list toggle round trips. Those include Read-only + report and the 409 namingBash. Also covered: the Codex and Gemini coverage lines, the restart banner, and both themes. A live check before the restart got the 403send_notification is blocked by this agent's tool access (Workspace-only)…. After the restart the agent's tool list went 174 → 167, and of the send set onlyreportremained. The dev merge (64c315ce5) and the toast move (dcaae7121) came after the eyeball. The toast is covered byagentListToastPlacement.mount.spec.js, not re-eyeballed.test_ent341_tool_access_profiles.py,test_ent341_tool_access_routes.py(compare-and-set race, mutation-proved) andtest_ent341_send_block.py(all nine routes driven through their real routers, plus an AST pin).sys.moduleslint hit on the new test file, fixed since. After the merge I re-ran every unit file touching the changed modules: 9,753 passed.test_ent926_turn_tier_hook.py, host-only. Its inputs are byte-identical todev, and it anchors paths at/home/developer, which macOS lacks.toolAccessSection,readOnlyShortcut,guardrailsToolAccess,agentListToastPlacement. New plain specs:toolAccess,toolAccessStore. Updated:agentHeaderIdentityEdit.@vue/compiler-sfcor@vue/compiler-core, or depend on the installed DOMPurify version) and touch nothing in this diff./verify-local --skip-agent, on64c315ce5withTRINITY_DEFAULT_SYSTEM_MANIFEST=disabled:test_ent926_turn_tier_hook.py(above);test_3262, which the manifest export trips.--skip-unit: pass. Build + import smoke, boot + health and test-preflight are OK. Integration: 74 passed, 13 skipped (0 infra-broken), 2 deselected per the known-false-fails registry.tests/test_read_only_mode.py, a live root-tier file outsidetests/integration./cso --diff: 0 findings at the gate. The report is indocs/security-reports/cso-diff-2026-11-03-ent341-tool-access-profiles.md.tests/test_read_only_mode.pyasserted the old toggle messages.No migration (SQLite or PostgreSQL) and no base-image rebuild needed.
Fixes abilityai/trinity-enterprise#341
🤖 Generated with Claude Code