Skip to content

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

Merged
webmixgamer merged 2 commits into
devfrom
feature/4501-approver-reach
Nov 13, 2026
Merged

webmixgamer merged 2 commits into
devfrom
feature/4501-approver-reach

Conversation

@webmixgamer

Copy link
Copy Markdown
Contributor

Summary

  • An agent's ask to: approver now reaches only the seated approvers who can open the agent. When none can, the raise is refused with 422 role_cannot_open_agent and nothing is filed.
  • Before, such an ask was filed with resolved: true for 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.
  • Same rule, same code and same wording as an ask to a canon role (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_ask and a reachable_people helper that the role:<id> path now shares.
  • src/backend/services/ask_service.py: the approver arm of _address uses it, maps the refusal by code, and logs it at warning level (role and agent, never a person). readdress_role inherits the rule through _fresh_audience.
  • src/mcp-server/src/tools/operator_queue.ts: the to description names the refusal and its remedy.
  • Tests: 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: user docs (approvals, MCP server), requirements, endpoint catalog, two feature flows, and a learnings fragment for the bug class (a fence widened to a new kind must carry the first kind's raise-time rules).
  • Security report: docs/security-reports/cso-diff-2026-11-12-4501-approver-reach.{md,json}.

What does not change

  • primary, viewer and operator asks: their answer is not fenced to the seat, so they are resolved as before.
  • Messages, reports and proposals addressed to the approver.
  • The fence itself (may_end): the recorded audience only shrinks.

Limits

  • Point in time. The check runs at the raise. If the agent is unshared from the approver afterwards, a pending ask is stuck again. That is the "unshare" debt already recorded in the learnings ledger (2026-11-04).
  • Rows already stuck stay until someone shares the agent with the approver or cancels the ask. A replayed request_id of such a row still answers with its first receipt.
  • A seat that moves to someone who cannot open the agent leaves pending asks with the previous approver (existing _fresh_audience behaviour, now also for this case).
  • A failed access lookup counts as "cannot open", as it already does for role:<id>.
  • Not covered here: a credential ask to an assigned primary who 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

  • New tests pass: cd tests && pytest unit/test_4501_approver_reach.py -v (15 passed)
  • Mutation: with _address reverted 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.
  • Neighbouring suites (263 unit files that touch asks, addressing, the gate, the docs or the registry), run at the merge-base and at the head: the same 47 fail on both (local environment: the full app does not import in my virtualenv), 9269 vs 9284 passed. The difference is the 15 new tests; nothing is red at the head only.
  • Pinned guards (302 files, CI flags, seed 12345), run at the merge-base and at the head: identical on both (20 failed, 74 errors, 12194 passed, 10 skipped; all from the same local import failure). CI is the authority for these.
  • MCP server: src/operator_queue.test.ts 116 passed; tsc --noEmit clean.
  • /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.
  • Re-test on the next RC by someone other than the author (release-matrix rule 1).

Fixes #4501

🤖 Generated with Claude Code

webmixgamer and others added 2 commits November 12, 2026 15:12
… 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]>
@webmixgamer
webmixgamer requested a review from dolho November 13, 2026 11:06

@dolho dolho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/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_end untouched. 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: _address has 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)

  1. A seated approver shared the agent after the raise stays outside resolved_to on a partially reachable seat.
  2. A credential ask to approver with several seated and exactly one reachable now passes the one-reader rule. Good outcome, not listed and not pinned.
  3. 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants