Repository navigation
fix(asks): a credential ask goes to a person who can open its field — the primary, else the owner, else refused by name (#4579) - #4580
Conversation
… the primary, else the owner, else refused by name (#4579) A credential ask is answered only through the Workspace secret field, and that field opens for the ask's one reader only when the agent is on their Workspace roster (shared with them, or their own). The raise picked the reader with no such check, so a seated primary the agent was not shared with became the only reader of an ask nobody could fill: 201, resolved: true, no expiry. The reader is now a chain with the field's reach checked at each step (role_addressing.resolve_credential_reader): the agent's primary person, else its owner, else the raise is refused 422 role_cannot_open_agent and nothing is filed. The check is the field's own rule (on_workspace_roster: shared or owned, account active, fails closed), not can_open_agent, which also counts an admin's access through Operations, where a credential cannot be filled. readdress_role moves a pending credential row by the same rule. Tests: tests/unit/test_4579_credential_primary_reach.py (23; 12 red before the fix). Mutation: with the credential arm of raise_ask removed, 10 go red; swapping the predicate for can_open_agent turns the admin-primary test red. Fixes #4579 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…a reader who can open its field (#4579) dev gained admin_readdress (re-address a pending card "by its rule"). For an agent's credential ask it re-ran the plain primary role, which would move the ask to a seated primary who cannot open the secret field: the state this branch stops the raise from creating. It now reads the same reader chain as the raise and readdress_role. Tests: three more in tests/unit/test_4579_credential_primary_reach.py (26 in total). Mutation: with the admin path reading the plain role again, two of them go red. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
pavshulin
left a comment
There was a problem hiding this comment.
Reviewed as the B2 re-tester for v1.0.5 (release matrix rule 1: not the author). Ran /review, /validate-pr 4580 and /cso --diff against head 1844c84a0 (merge-base cb29afd5a), plus my own mutation runs in the backend image on a scratch copy.
Verdict: comment for now; I approve once the three points below are answered (any of them may change the diff, and an approval given before that would be stale on the next push). No critical finding in any of the three. The fix is right and proven: 26 new tests green; reverting the raise call site → 12 red, roster check failing open → 14 red, readdress_role ignoring the rule → 2 red, owner step removed → 6 red. Reader set only narrows and stays inside the field's door (_owned_ask); refusal names roles and the agent's own name only; no credential value path touched; enterprise-docs guard 0 hits on the added doc lines. The chain (primary → owner → refused by name) has the same shape as the project-ask chain (steward → creator → project_unreachable), which is the parity Eugene asked for.
Three things to fix in the description or decide; none requires code, but point 3 may add some:
readdress_rolenow has a production caller ondev. The description says it has none. Since #4581 (18:24 UTC), the enterprise assignments write re-addresses the agent's pending asks throughask_service.readdress_role(agent, "primary", …)after every primary seat write. With this PR that re-address is reach-aware (yourTestReaddresscovers exactly that arm — good). Without it, a seat write would move a pending credential ask onto a primary who cannot open the agent, so this PR closes a path thatdevopened today. Please update "Limits" and the Test Plan; the "corner for whoever adds the first caller" is live behaviour now.- Second raise door, not covered: the queue-file channel (
services/operator_queue_service/filechannel.py:178,_primary_addresseeafter_validated_addressee(include_owned=False)) files a credential entry for the primary only when that email is on the shared roster; otherwise the row is unaddressed, and a credential row with no reader can only be cancelled. Same state class through a different door. Fine to leave for a follow-up — say which in the description. - Third door (from
/cso, availability only):on_workspace_rosterchecks suspension (users.suspended_at) and the roster, not the ent#281 client block. A blocked outside client has nousersrow,block_clientleavesagent_sharingrows, and_reject_if_blockedstops their sign-in — so a blocked outside-client primary with a share is recorded as the one reader and can never fill. Oneis_client_blocked(email)check plus a test closes it;can_open_agent(#4501) has the same gap. In-PR if quick, otherwise a follow-up issue.
Also: the attached CSO report predates the second commit (its merge-base is b046b7af4, no mention of admin_readdress). The arm was audited here and only tightens (audience_unchanged 409 / rule_refused 409 pinned), but please regenerate or annotate it.
Minor: a roster-lookup error is reported to the agent as role_cannot_open_agent with the "ask an admin to share" remedy; fail-closed is right, the wording misleads during an outage. Wording only.
Validation notes for the record: Tier 1 CI green; journey-smoke / e2e skip on this path set by design (Lane B mechanically; they run on dev after merge). Re-test of row B2 on rc3 is mine.
dolho
left a comment
There was a problem hiding this comment.
Read the source diff at head 1844c84a0 against the code it relies on (client_portal/asks/service.py::_owned_ask / _on_roster, client_portal/service.py::agent_on_roster / email_account_suspended, raise_ask, both re-address arms). I did not run the suite locally; CI is green at this head.
No blocking finding. The fix is correct and I see no way it refuses a raise that could be filled before.
What I checked:
- The new predicate matches the door.
_owned_askadmits the addressee only whenagent_on_roster(agent, email, include_owned=is_platform).on_workspace_rosterasks the same function withinclude_owned=True, and the owned read joinsusersby email, so it can only differ from the door for an owner on an outside-client session (already listed under Limits). - Nothing that worked is now refused. A primary on the roster and an owner standing in on their own agent resolve exactly as before. Every case that now gets
role_cannot_open_agentor goes to the owner was a row the field refused for its only reader. - Branch order in
raise_askis safe. The credential branch sits afternamed/pre/to: project, so platform-named rows and project asks keep their own rules, and_validated_askalready refuses a credential withto != primary(invalid_to), so ignoringnorm["to"]in_address_credentialcannot record a row under the wrong role. - Replay order holds. The
request_idreplay returns before addressing, so a retry of a row filed earlier gets its receipt, not the new refusal. - Re-address arms.
readdress_rolecaches per(gate, own_credential), so a question row and a credential row on the same seat write no longer share one audience.admin_readdressreads the same helper. Both leave the row alone on a refusal.
Three small things, none of which needs to hold the merge:
- Client block (agree with Pavlo's point 3, confirmed in the code). The sign-in gate reads
is_client_blocked(portal_auth.py:63,email_has_access),on_workspace_rosterreads suspension only. A blocked outside client who still has the share row is recorded as the one reader and cannot sign in to fill it. One extra check next toemail_account_suspendedcloses it. Fine as a follow-up if you want this PR to stay as tested. - The refusal's remedy is wrong when nobody is seated. With no primary and an owner who cannot open the agent (a suspended owner, covered by
test_nobody_seated_and_an_owner_off_the_roster_is_refused), the message still says "Ask an admin to share with its primary person". There is no primary person, and an agent cannot be shared with its own owner. Wording only. admin_readdressreports the wrong cause for this case. When the credential rule refuses, the admin reads "Nobody can be found for the primary role on this agent … end it with a reason instead". Someone is seated; they cannot open the agent, and the fix the admin has is to share it, not to end the ask. Wording only.
On the release question: this is safe to take into rc3 from the code side. The change only narrows who is recorded as a reader and adds one named refusal; no value path, door or schema is touched.
dolho
left a comment
There was a problem hiding this comment.
Ran /validate-pr 4580 at head 1844c84a0 on top of my code read from this morning (comment above). Approve.
| Check | Result |
|---|---|
| Lane | B (no auth, credential-store, schema or CI path touched) |
| Base, commits, closing keyword | dev, conventional, Fixes #4579 (same repo, so the issue promotes on merge) |
| Docs | requirements, the credential-in-chat flow, both catalogs and user docs updated; enterprise-docs guard: 0 hits on added lines |
| Secret / email / IP / mode / host-path scans | nothing (one false hit: @pytest.fixture) |
| New env vars, new backend packages | none |
| Tier 1 | green, including regression diff, prod-image-smoke and the MCP build + unit job |
dev before merge |
dev-ci green |
Execution coverage. The new tests call ask_service.raise_ask, readdress_role and admin_readdress against a real database, and TestRealRoster runs the real agent_on_roster and owner lookup instead of the stubs. TestRaiseRoute goes through the HTTP route. None of it is source-text matching. The live consumers are raise_ask (the credential branch), readdress_role and admin_readdress. Mutation was done twice, by the author and independently by Pavlo: with the raise call site reverted, 12 tests go red. I did not repeat it.
Not blocking, and I would not hold the merge for them:
- Two doors this PR leaves open (Pavlo's points 2 and 3): the queue-file channel files a credential row with no reader when the primary is off the shared roster, and a blocked outside client with a share is still recorded as the reader. Both are the same dead end through a different door, both existed before this PR, and neither is made worse by it. They need a follow-up issue each so they are not lost.
- The description is out of date in one place. It says
readdress_rolehas no production caller. Since #4581 the enterprise assignments write calls it after every primary seat write, so that arm is live. No committed file repeats the claim; it is the PR body only. Please fix the body before the squash so the commit message does not carry it. - The committed CSO report predates the second commit (merge-base
b046b7af4, noadmin_readdress). Pavlo audited that arm in his review. A one-line note in the report is enough. - The two wording notes from my earlier comment stand.
On the release: safe to take into rc3. It only narrows who is recorded as the reader and adds one named refusal. If it does not merge before the tag, B2 stays red on rc3 for the t#4579 leg and needs a release note.
|
merge-train (2026-11-15): merging this into
On the merged tree (this PR on top of @webmixgamer nothing was pushed to your branch. @pavshulin row B2 is yours to re-test on rc3. |
Fixes #4579
Summary
credentialask is answered only through the Workspace secret field, and that field opens for the ask's one reader only when the agent is on their Workspace roster (shared with them, or their own). The raise picked the reader with no such check, so a seated primary the agent was not shared with became the only reader of an ask nobody could fill:201,resolved: true, no expiry.422 role_cannot_open_agentand nothing is filed.readdress_roleand by an admin's re-address "by its rule" (admin_readdress, which landed ondevwhile this was in review and would otherwise have moved the ask back to a primary who cannot open it).v1.0.5-rc2(af465288a) in release testing (row B2). Same class as bug(asks): an ask to: approver is filed for a seated approver who cannot open the agent, and then nobody can answer it #4501, on theprimarypath, which 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 did not touch.Why not #4506's check
role_addressing.can_open_agentalso counts an admin's access to any agent, because an approval can be decided in Operations. A credential cannot. An admin seated as primary on an agent they neither own nor were given would still have been recorded. The new predicate asks the field's own rule.Changes
src/backend/services/role_addressing.py:on_workspace_roster(the field's rule: shared or owned, account active, fails closed) andresolve_credential_reader(the chain).src/backend/services/ask_service.py: the agent's own credential raise reads the chain (_address_credential);readdress_roleandadmin_readdressre-address a pending credential row by the same rule (_fresh_credential_audience).src/mcp-server/src/tools/operator_queue.ts:ask_for_credentialnames the refusal (description 1,820 of 2,048 characters).tests/unit/test_4579_credential_primary_reach.py(new, 26), one MCP case and one description pin.docs/security-reports/cso-diff-2026-11-14-4579-credential-primary-reach.{md,json}.What does not change
to: primary: anyone with access can answer those in Operations.no_person(nobody, or several people, fillprimary).credential_sink), the field's door, the answer refusal.request_idstill answers with its first receipt.Limits
to: primaryreaches someone other than a messageto: primarydoes.readdress_rolehas no production caller yet, so the re-address arm is proven by unit test only. One corner for whoever adds the first caller: when the seat moves and neither the new primary nor the owner can open the field, the pending ask keeps its previous reader, who can still fill it while the agent is on their roster (the same class as credential ask: the addressee is frozen at raise time, not re-resolved as the agent's primary at answer time #4189). Ending such an ask instead is a separate decision.Test Plan
cd tests && pytest unit/test_4579_credential_primary_reach.py -v— 26 passed. Before the fix: 12 of the first 23 failed (the rest are controls and unchanged cases); the three admin re-address tests were added afterdevgained that path.on_workspace_rosterswapped forcan_open_agent(1: the admin primary);include_owned=False(3, incl. the owner on real rows); the suspended clause dropped (2); the owner step removed (4); no refusal (8); the roster lookup failing open (1); re-address ignoring the rule (2); the refusal naming the person (2); the admin's re-address reading the plain role (2).b046b7af4: nothing is red only on the branch. The same 98 test ids are red on both (real-app, route-census and pin-parity tests my machine's environment cannot import); the merge-base has one more (test_3010_autosync_toggle, not touched here). 12,344 passed on the branch against 12,321: the 23 tests of that run. This run predates the second merge ofdevand the admin re-address commit; after those, the new file, both bug: /api/telemetry/containers blocks ~6s on Docker stats (ThreadPool capped at 4, no cache) — stalls Dashboard/UI #1096 suites, the ask neighbours and the registry readers pass locally (280), and CI is the authority for the guards.src/operator_queue.test.ts117 passed;tsc --noEmitclean./cso --diff: nothing at or above the gate; 746 guard tests pass across 22 auth, fence and credential files. Report:docs/security-reports/cso-diff-2026-11-14-4579-credential-primary-reach.md.Journey Impact: none: an ask that could never be answered is now handed to a person who can answer it, or refused; no journey promise changes
🤖 Generated with Claude Code