Repository navigation
fix(asks): an ask to the approver reaches only approvers who can open the agent, and is refused by name when none can (#4501) - #4506
Conversation
… the agent, and is refused by name when none can (#4501) An ask addressed `to: approver` was filed for whoever the seat provider named, with no reach check. Since the approver answer fence (#4181) only the people recorded at the raise may answer, so a seated approver the agent is not shared with became the one person allowed to decide an ask they could never see: 201 with `resolved: true`, a 404 for them, `403 not_addressee` for everyone else. The raise now records only the seated approvers who can open the agent (`role_addressing.resolve_approver_for_ask`, the rule `role:<id>` asks and gated-skill approvals already apply) and refuses `422 role_cannot_open_agent` when none can. Nothing is filed; the refusal names the role and is logged. Mutation: with the call in `ask_service._address` reverted to the plain resolution, six tests in `tests/unit/test_4501_approver_reach.py` go red. Fixes #4501 Co-Authored-By: Claude Fable 5.2 <[email protected]>
dolho
left a comment
There was a problem hiding this comment.
/review — approve
Scope: clean. Intent (#4501): an ask to: approver must not be filed for a seated approver who cannot open the agent. Delivered: the first option from the issue (refuse by name, same code as role:<id>), plus filtering of a partially reachable seat. No drift; the three touched fixtures are the ones that seat an approver without a share.
Execution coverage
| changed symbol | executed by | live consumer | verdict |
|---|---|---|---|
role_addressing.resolve_approver_for_ask |
test_4501_approver_reach.py::TestRaise (real sink, real SQLite) |
ask_service._address (ask_service.py:1792) |
executed |
role_addressing.reachable_people |
same, plus test_ent1007_* through the role:<id> path |
resolve_approver_for_ask, resolve_role_id_for_ask |
executed |
_address approver arm + refusal mapping + log |
TestRaise, TestRaiseRoute (real route, 422 body), caplog test |
raise_ask (:1044), _fresh_audience (:854) |
executed |
readdress_role inheriting the rule |
TestReaddress with a positive control |
_fresh_audience |
executed |
No source-text assertions in the new file; every refusal test has a positive control.
Fix mutation: I could not run it locally (no pytest in my environment), so the author's 6-of-15 figure is not independently reproduced. By reading: with _address on the old resolve_addressee path nothing raises for a seated approver, so test_a_seated_approver_who_cannot_open_the_agent_refuses_the_raise fails at pytest.raises, and the filtered-audience test fails on resolved_to. The regression test is real. CI pytest (head, seed 12345) and regression diff are green on d6c6d59.
Critical
None.
- Auth: no route or dependency change;
may_enduntouched. The recorded audience can only shrink, and an empty result refuses rather than writing an empty snapshot (the one state that un-fences an approver row). - Call sites of the fixed behaviour:
_addresshas two callers (raise_ask,_fresh_audience), both covered. The gate path (skill_gate_service._approvers) already applied the rule. Reports/messages (routers/reports.py:148,role_addressing.py:466) are not fenced and correctly keep the plain resolution. - Disclosure: enterprise-docs guard pattern over the added doc lines: 0 hits. Refusal text and log name the role and agent only.
- No schema, SQL or concurrency change.
Informational (non-blocking, see inline)
- A seated approver shared the agent after the raise stays outside
resolved_toon a partially reachable seat. - A
credentialask toapproverwith several seated and exactly one reachable now passes the one-reader rule. Good outcome, not listed and not pinned. - A failed access lookup produces the "share the agent" remedy.
Docs: requirements, endpoint catalog, both feature flows, user docs and the MCP description all carry the new refusal. Learnings fragment is present and in the right form.
| else, which would hand a separate approval to the owner. | ||
| """ | ||
| r = resolve(agent_name, "approver") | ||
| reachable = reachable_people(agent_name, r.people) |
There was a problem hiding this comment.
Two consequences of filtering here that the PR's Limits section does not name. Neither blocks.
1. Late share on a partial seat. Seat = [A, B], agent shared with A only. The row records [A]. If the agent is later shared with B, B is a seated approver who can open the agent but is refused 403 not_addressee, because nothing re-resolves the row on a share: readdress_role has no caller in this repo and is driven by seat changes. A can still answer, so the ask is not stuck. Worth a line in Limits next to the unshare case, or a follow-up if a share should re-address.
2. Credential asks. raise_ask refuses a credential ask with no single addressee (no_person, ask_service.py:1045). With seat = [A, B] and only A reachable, single is now A, so a credential ask to: approver that was refused before is now filed for A. That is the right result (one reader, who can see it), but it is a behaviour change with no test. A one-case test would pin it.
| if e.code == "role_cannot_open_agent": | ||
| # A refusal files nothing, so the log is the only trace a stalled | ||
| # agent leaves. The role and the agent, never a person. | ||
| logger.warning("[AskService] an ask to the %s role from %s was refused: nobody " |
There was a problem hiding this comment.
Non-blocking. can_open_agent fails closed, so a transient DB error on the user lookup lands here too: the agent is told to ask its owner to share it with the approver, and this line logs "nobody seated in it can open the agent", when the share may already exist. can_open_agent does log its own warning with the traceback, so an operator can tell the two apart, but the agent cannot. Same as the existing role:<id> path, so fine to leave as is; noting it because the remedy text here is more specific than the canon-role one.
Summary
to: approvernow reaches only the seated approvers who can open the agent. When none can, the raise is refused with422 role_cannot_open_agentand nothing is filed.resolved: truefor a person who could never see it, and the approver answer fence (fix(asks): an answer to an approver ask needs the approver seat #4181) refused everyone else, so nobody could decide it.role:<id>) and a gated-skill approval.Found on
v1.0.5-rc2(af465288a) in release testing; this is the one defect behind the failing row.Changes
src/backend/services/role_addressing.py:resolve_approver_for_askand areachable_peoplehelper that therole:<id>path now shares.src/backend/services/ask_service.py: theapproverarm of_addressuses it, maps the refusal by code, and logs it at warning level (role and agent, never a person).readdress_roleinherits the rule through_fresh_audience.src/mcp-server/src/tools/operator_queue.ts: thetodescription names the refusal and its remedy.tests/unit/test_4501_approver_reach.py(new, 15). Three existing fixtures that seat an approver now say the agent is shared with them (test_ent1095_readdress_role.py,test_ent606_role_addressing.py,test_ent611_native_ask.py).docs/security-reports/cso-diff-2026-11-12-4501-approver-reach.{md,json}.What does not change
primary,viewerandoperatorasks: their answer is not fenced to the seat, so they are resolved as before.may_end): the recorded audience only shrinks.Limits
request_idof such a row still answers with its first receipt._fresh_audiencebehaviour, now also for this case).role:<id>.credentialask to an assignedprimarywho cannot open the agent has the same kind of dead end, because a credential ask cannot be answered from Operations. Separate, older bug.Test Plan
cd tests && pytest unit/test_4501_approver_reach.py -v(15 passed)_addressreverted to the plain resolution, 6 of the 15 go red (the refusal at the sink and at the route, the filtered audience, the fail-closed lookup, the log line, re-addressing); restored byte-identical.src/operator_queue.test.ts116 passed;tsc --noEmitclean./cso --diff: nothing at or above the gate; 358 guard tests pass. Report:docs/security-reports/cso-diff-2026-11-12-4501-approver-reach.md.Fixes #4501
🤖 Generated with Claude Code