Repository navigation
fix(auth): seat decisions and voice reply serve the turn the agent is in (ent#1062) - #4204
Conversation
… in (ent#1062) Applies the rule #4121 put on write_user_memory to the two other routes that resolve a person or a conversation from a caller-named execution_id. Seat decisions (POST/GET /api/agents/{name}/decisions): - agents only (agent_only for a person or a user-scoped key); a person reads and decides through the client-portal routes; - _seat_for refuses a run that is not running (decision_turn_not_live) and, through memory_service.another_live_scope, a turn beside another live turn that resolves to a different scope (decision_turn_ambiguous). Voice reply (POST /api/agents/{name}/voice-reply), fail-soft as before: - turn_not_live for a run that is not running; - turn_ambiguous while another live turn on the agent would deliver to a different conversation (voice_reply_service.another_live_destination). The agent answers in text. MCP record_decision / list_seat_decisions send resolveExecutionId (the platform's X-Trinity-Execution-Id wins over a typed id) and name the refusals. Tests: unit over the real routes with a real agent key, an integration test on a sibling stack, and decisions.test.ts. Fixes Abilityai/trinity-enterprise#1062 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
obasilakis
left a comment
There was a problem hiding this comment.
Requesting changes. The regression diff failures are stale tests. The missing route and the conflicts are the blockers.
GET /seat-autonomyis missed (seat_decisions.py:177,decisions.ts:186ondev). The head's merge base predates #2984, so the route is outside this diff. Once merged, a person the agent is shared with can name another person's running run and read that seat's verdict.get_autonomystill sends the typed id, so a stale id getsdecision_turn_not_live.agent_route_tiers.jsonis untouched: theseat-autonomy,recordandlistrows should becomeself, withLEGACY_ACCESSOR_BASELINEgoing 115 to 113. The census will not catch this becauseassert_agent_accessremains. Read.- Conflicts with
dev's_require_running_turninseat_decisions.py,decisions.tsandtest_ent839. With a naive resolution, 20 tests fail across 7 seat suites (ran).test_ent641::test_a_person_keeps_their_pathgets 403, so #2984's person path contradictsagent_onlyand someone has to decide which stands. By read: the MCP typed-id fallback hitsnot_this_turnwith no header, and a finished run has overlapping refusals. - The owner's seat is unprotected from headless runs (
seat_decisions.py_seat_for,memory_service.py:213). Owner and headless both resolve toAGENT_SCOPE. A cron turn naming the owner's live run recorded under the owner's seat (200, stored), while another person's seat in the same setup gets 422. Therecord_decisiondescription says a headless run refuses. Ran.
CI: 7 failures, all stale. test_2157 (4): the _execution fixture has no status, so turn_not_live fires first. test_ent814 (3): _record uses a person principal, so agent_only fires first. With status="running", id and an agent key added, all 57 tests in both files pass (ran).
Docs: workspace-seat-decisions.md and decisions.ts agent_name still say the override remains for a user-scoped key.
Mutation: reverting the two routers turns 16 of 22 test_ent1062 tests red.
Conflicts with #2984 (the platform turn header on decision records): - seat_decisions.py: both helpers kept (_agent_only, _require_running_turn); the new seat-autonomy read takes _agent_only like the other decision doors. - decisions.ts: the body carries the resolved turn, and the platform turn is still sent as the header (renamed so it no longer shadows `turn`). - tests: fixtures that called these doors as a person, or without the platform turn header or a running execution, now make the call an agent makes in its live turn (test_2157, test_ent638, test_ent641, test_ent814, test_ent839, test_ent1062). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ Nightly unit-suite clean when this PR is merged into |
…doors # Conflicts: # tests/registry.json
…ambiguous too (ent#1062) Review of #4204. - The decision doors used the memory doors' scope rule, where the owner and a headless run share one scope: a cron turn naming the owner's live run recorded under the owner's seat. `_seat_for` now refuses `decision_turn_ambiguous` while any other live turn serves anyone else (`memory_service.another_live_turn_not_serving`). - A finished run is refused once (`decision_turn_not_live`); the unreachable `turn_not_running` branch and the ent#641 test that pinned it through a stub are removed, and `_require_running_turn` drops the person path `_agent_only` already closed. - The seat-autonomy, record and list rows are `self` in agent_route_tiers.json; LEGACY_ACCESSOR_BASELINE 115 → 113. - MCP: record_decision with an agent key and no platform turn says so instead of forwarding a typed id the backend answers `not_this_turn`; get_autonomy sends the header's turn and refuses a foreign agent; no tool advertises a user-key agent_name override any more. - Docs: workspace-seat-decisions.md and core-agent.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the review in
CI: the stale Docs: MCP: |
|
merge-train (2026-11-04, evening): ejected — rides the next train once fixed.
|
…doors Rebuilt tests/registry.json from dev plus this PR's entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inity-enterprise#1062) record_decision and list_seat_decisions refuse every user-scoped key (_agent_only), and decisions.test.ts pins that description. The #840 guard still required "for a user-scoped key only", so the two tests could not both pass. Move the two tools to their own block: it requires the agent_only refusal and keeps banning override wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # tests/registry.json
…made stale #4204 (ent#1062) made the seat-decision doors agent-only, so the person path these entries described is gone and the scan reports them stale.
…ited, the saved-token fork takes a session, and no grant rests on an agent-only check (#4243) * fix(auth): human-only MCP tools follow their routes, refusals are audited, the saved-token fork takes a session, and no grant rests on an agent-only check - MCP listing: each tool whose route needs a person or a signed-in session is listed through one shared predicate, so no key is shown a tool its scope can never call; within a listed scope the route still decides. The descriptions state each route's rule. - MCP refusal reasons: a backend 403 whose detail is the person_required object, or the signed-in-session sentence, maps to the human-only answer. - Audit: the human-only primitives raise HumanOnlyRefused, and an app handler records one row per refused attempt, bounded per principal and route, with no request body; the response is unchanged and an audit failure still answers 403. - Agent creation: the arm that spends the creator's saved token as the new agent's is a credential bind and takes a signed-in session. - A static scan fails any grant route that rests on an agent-only check alone; it lists one reviewed deferral. The feature-flows index carries one row for the issue. Part of Abilityai/trinity-enterprise#719 * fix(mcp): inject_credentials and set_agent_github_pat are listed to a person's key On dev, writing a credential the caller supplies into its own agent takes a person (the ruled exception in requirements/auth.md §2.8): POST .../credentials/inject and PUT .../github-pat are require_person. The listing still treated inject as a signed-in-session bind (shown to no key) and said setting a per-agent PAT needed a session, so a person's own user key was hidden a tool its route admits. Both now take the person predicate; the visibility tests follow (3 + 14 + 13 refusals, 10 person/interactive rows, 10 user-listed tools on a fresh install). Part of Abilityai/trinity-enterprise#719 * docs(mcp): a fork through create_agent is refused for every key The create_agent fork block (ent#1007) relies on the backend spending the caller's saved GitHub token. That arm makes the token the new agent's own, a credential bind, so it runs only from a signed-in session, and an MCP call never is one. The tool description and the docs that said the tool spends the saved token now say a fork made through it is refused FORK_PAT_REQUIRED for every key and is created from the web UI. Part of Abilityai/trinity-enterprise#719 * fix(auth): the autonomy dial's owner writes take a person The Workspace door admits the system key for the Workspace's uses, and it resolves to the admin who owns the install, so the dial's owner check alone let it release a person's held class and rewrite the guard cap (both 200 before this). Releasing is a grant in the route's own words. Both writes now refuse a caller that is not a person first, as the readiness, canvas-pin and seat-decision writes beside them do. The grant scan found both, and the agent's own seat-decision record: its two agent-only checks narrow an agent key to its running turn and grant nothing, so they are listed as reviewed non-grants. Mutation: with the two person checks removed, four system-key cases in test_ent719_workspace_autonomy_person_only.py go red and the scan reports both routes. Part of Abilityai/trinity-enterprise#719 * docs(auth): the deferred grant and the remaining baseline point at their follow-up The scan's one deferral and the census baseline's remaining entries are tracked in trinity-enterprise#985, the follow-up filed for this issue. Part of Abilityai/trinity-enterprise#719 * docs(mcp): the credential and PAT tool lines say a person's key reaches inject and a PAT set Follows the listing change: inject_credentials and setting a per-agent PAT take a person on dev, so the lines that said they take a signed-in session, or that a user key can only clear a PAT, now say a person's own user key reaches both. Part of Abilityai/trinity-enterprise#719 * test(mcp): the fetch stubs compare the backend origin, not a URL prefix CodeQL reads url.startsWith(BACKEND) as an incomplete URL check. In these stubs it only routes a stubbed fetch, but comparing the origin says the same thing exactly and clears the alert. 70/70 pass in both files. Part of Abilityai/trinity-enterprise#719 * merge-train: list assert_tool_allowed as a reviewed non-grant guard (#4243) — train decision at Gate 1, see the PR note #4232 (trinity-enterprise#341) landed on dev after this PR's last dev merge and added the send block, services/tool_access_guard.py::assert_tool_allowed, in front of nine send routes. It is a per-agent tool restriction, never a grant, so the ent#719 scan lists it under NOT_GRANT_GUARDS with the nine routes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(auth): drop the two seat-decision NOT_GRANT_GUARDS entries #4204 made stale #4204 (ent#1062) made the seat-decision doors agent-only, so the person path these entries described is gone and the scan reports them stale. * test(auth): list the room-wake and Continue routes dev added under NOT_GRANT_GUARDS On the merged tree the grant scan reported six routes resting on an agent-only check alone. None is a grant: - trinity-enterprise#1135 returns an ended ask to its room on the agent's next start, so start, chat, task result and system deploy/restart now reach the room wake, and through the engine's reply post, `tagger_for`. That post carries no tags (`post_message` asks for a tagger only for a sender's own tags), so the check never runs there. - trinity#4302's Continue reaches `tagger_for` the same way, and calls `assert_tool_allowed` for parity with `/messages`. Its person check is `_is_room_person` in the service. --------- Co-authored-by: trinity-ability <309458136+trinity-ability@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Summary
Fixes Abilityai/trinity-enterprise#1062. This extends the rule #4121 put on
write_user_memoryto the two other routes that resolve a person or a conversation from anexecution_idnamed in the request: the seat-decision routes and voice reply. Each now serves only the turn the agent is in, by the ent#926 ledger rule.Seat decisions (
POST/GET /api/agents/{name}/decisions)403 agent_only. People read and decide through the client-portal routes, and nothing in the UI calls these._seat_forrefuses a run that is notrunningwith422 decision_turn_not_live.422 decision_turn_ambiguous, while another live turn on the agent resolves to a different scope (memory_service.another_live_scope, shared with the memory routes).Voice reply (
POST /api/agents/{name}/voice-reply), still fail-soft with200 {delivered: false, reason, guidance}:turn_not_livefor a run that is not running.turn_ambiguouswhile another live turn on the agent would deliver to a different conversation (channel, chat or thread), viavoice_reply_service.another_live_destination.MCP
record_decisionandlist_seat_decisionsnow sendresolveExecutionId(...): the platform'sX-Trinity-Execution-Idwins, and a typed id is the fallback. A typed id copied from a resumed session can no longer lose a real decision once the backend refuses non-live runs.execution_idis now optional, as on the memory tools.send_voice_replyalready resolved the id, and its description already tells the agent to readguidanceand reply in text.Other
test_ent875_exec_control_routes.py: theREAD_SITESreasons for_seat_forandsend_voice_reply_endpointare updated.workspace-seat-decisions.mdis updated.Acceptance criteria
resolveExecutionIdREAD_SITESreasons updatedThe
_EMAIL_REdrift acrosspublic_memory,seat_decisionsandmemory_subjectis left as is. Unifying it is a separate cleanup.Interaction with #2984. Its
GET /seat-autonomyresolves the seat through_seat_for, so it inherits the live-turn rule automatically. It will need the sameagent_onlycall when the two meet.Tests
tests/unit/test_ent1062_live_turn_doors.py, new, 22 tests. Real routes, realget_current_user, and a realtrinity_mcp_…agent key, with only the channel send stubbed.success/failed/cancelled) are refused for record, read and voice, and nothing is stored or sent.agent_only.16 of the 22 fail on
dev.tests/integration/test_ent1062_live_turn_doors.py, new. Run on a sibling stack built from this branch (prod images), over real HTTP with a real agent key:decisions.test.ts: 5 new tests:The full MCP suite passes: 1,138.
Updated:
test_ent638router tests andtest_ent839's person case now act as the agent's key, and a person getsagent_only.test_2792's voice cases use a live run (they pin the room reason, which now comes after liveness).Local: 1,458 related backend tests pass.
🤖 Generated with Claude Code