Conversation
|
Thanks for the focused policy-composition fix. Current The proposed aggregation is consistent with the dispatcher: No blocking correctness or completeness issue found. This is an automated hermes-sweeper review. |
`_get_pre_tool_call_directive_details` returned the first valid block-or-approve in registration order, so a plugin registered earlier that returned `approve` hid a later security plugin's `block`; under `approvals.mode: off` an approve means no prompt at all, so the veto was dropped silently. Precedence is now `block` > `approve` > none: a valid block still returns immediately (modify directives seen before it stay attached, as before), a valid approve is held back until the whole result list has been scanned for a veto, and among approves the first valid one (with its rule_key) still wins. Modify accumulation is unchanged and now also keeps modify directives that follow the winning approve, since the scan no longer stops there. Docstring and hooks.md no longer describe "first valid directive wins". Slim redo of #68644 (earliest) and #87449 against the modify-aware shape of the function on main; both PRs predate it and could not be cherry-picked. Fixes #87420 Supersedes #68644 Supersedes #87449 Co-authored-by: synscott <1563043+synscott@users.noreply.github.com> Co-authored-by: Jack Lau <72348727+jackulau@users.noreply.github.com>
`_get_pre_tool_call_directive_details` returned the first valid block-or-approve in registration order, so a plugin registered earlier that returned `approve` hid a later security plugin's `block`; under `approvals.mode: off` an approve means no prompt at all, so the veto was dropped silently. Precedence is now `block` > `approve` > none: a valid block still returns immediately (modify directives seen before it stay attached, as before), a valid approve is held back until the whole result list has been scanned for a veto, and among approves the first valid one (with its rule_key) still wins. Modify accumulation is unchanged and now also keeps modify directives that follow the winning approve, since the scan no longer stops there. Docstring and hooks.md no longer describe "first valid directive wins". Slim redo of #68644 (earliest) and #87449 against the modify-aware shape of the function on main; both PRs predate it and could not be cherry-picked. Fixes #87420 Supersedes #68644 Supersedes #87449 Co-authored-by: synscott <1563043+synscott@users.noreply.github.com> Co-authored-by: Jack Lau <72348727+jackulau@users.noreply.github.com>
`_get_pre_tool_call_directive_details` returned the first valid block-or-approve in registration order, so a plugin registered earlier that returned `approve` hid a later security plugin's `block`; under `approvals.mode: off` an approve means no prompt at all, so the veto was dropped silently. Precedence is now `block` > `approve` > none: a valid block still returns immediately (modify directives seen before it stay attached, as before), a valid approve is held back until the whole result list has been scanned for a veto, and among approves the first valid one (with its rule_key) still wins. Modify accumulation is unchanged and now also keeps modify directives that follow the winning approve, since the scan no longer stops there. Docstring and hooks.md no longer describe "first valid directive wins". Slim redo of #68644 (earliest) and #87449 against the modify-aware shape of the function on main; both PRs predate it and could not be cherry-picked. Fixes #87420 Supersedes #68644 Supersedes #87449 Co-authored-by: synscott <1563043+synscott@users.noreply.github.com> Co-authored-by: Jack Lau <72348727+jackulau@users.noreply.github.com>
|
Closing as superseded by #118844 (#118844), commit Thanks for the contribution — the underlying problem this PR addresses has been resolved on current main. If you believe this was closed in error, please comment and we'll reopen. |
Summary
blockdirectives take precedence over validapprovedirectives regardless of plugin registration orderProblem
_get_pre_tool_call_directive_details()returned the first valid directive from the collectedpre_tool_callhook results. If an approval-policy plugin was registered before a blocking policy plugin, an earlierapprovecould mask a laterblock:That makes policy composition depend on plugin discovery order and allows adding an approval hook to weaken an existing veto.
Fix
Collect the first valid block and first valid approve from the already-materialized hook results, then return:
All callbacks are still invoked once by
invoke_hook()before selection. A selected block bypasses the human approval prompt; approve-only behavior remains unchanged and fail-closed.Tests
Added regression coverage for:
rule_keypreservationFocused canonical test runs on the submitted commit:
Ruff lint,
compileall, andgit diff --checkalso pass.Baseline limitation
The complete upstream suite is not green in this host environment. A prior full run produced unrelated dependency/environment failures that were reproduced by failure class on an unchanged worktree at the same base. This change does not touch those systems, and the affected plugin/approval/dispatch slices above pass on the submitted commit.