Files
Igor Šćekić 8045e72da2 fix(cli): apply permission rules to workflow and subagent tool calls (#16499)
* fix(cli): apply permission rules to workflow and subagent tool calls

* fix(cli): apply the edit and read permissions to their tool aliases

* fix(cli): keep a path-scoped rule from changing a tool's preapproval

* fix(cli): single-source the tool-to-permission map

The workflow tool gate and the disabled-tool check each carried their own
copy of the map from a tool name to the permission that governs it. The gate
read a local map and the check read two inline arrays, so a new alias, or a
changed one, could apply to only one of them.

Export one resolver from Permission and read it from both places, and extend
the gate test to the resource tools so a drift in their aliases fails.

* test(cli): cover the workflow tool and subagent delegation wiring

The gate and the task permission check had unit tests, but nothing exercised
the session wiring that installs them. Add two test files:

- workflow-attach: reaches the real workflow branch through a provider stub and
  drives the installed executor, so a whole-tool rule, an unoffered name, a
  path-scoped rule and each result shape are asserted against the code that
  runs them.
- named-agent-types: drives a real prompt turn whose message names a subagent,
  and asserts the turn delegates and creates the child session.

Both fail when the corresponding wiring changes.

* test(cli): resolve the session service through the test layer

The named-agent test created its session through the global runtime handle.
Dispose that handle in the test instead and let the compiled layer do the
work, matching the other session tests in this directory.

* test(cli): resolve the session and prompt services in one scope

The named-agent test created its session through a separate runtime, so the
database instance it wrote to was not the one the prompt read. Resolve both
services from the same layer and create the session inside that scope.

* fix(cli): keep the tool-to-permission lookup to its own entries

A name that the map does not define resolved to an inherited built-in
member instead of itself, so the gate handed a non-string to the wildcard
matcher and the call failed with a thrown error rather than the gate's
not-available answer. The map now answers only for the entries it
declares.

Also mark the removed wildcard import in the session runtime and pin the
scoped-rule ordering and the unknown-name answer in tests.

* docs(cli): state what the workflow preapproval list contains

The gate also lists a tool that no rule covers, and one whose matching
rule is scoped to a path. The comment now says that, so a later change
does not narrow the list by mistake.
2026-11-22 16:44:40 +01:00
..
2026-08-07 16:07:19 +02:00
2026-08-07 16:07:19 +02:00
2026-07-30 14:24:24 +02:00