Repository navigation
fix(access): scope per-user views of agent activity (ent#875) - #3777
Conversation
|
✅ Nightly unit-suite clean when this PR is merged into |
…nsus (ent#926) With #3777 and #3776 merged in, 36 of the 152 legacy accessor rows already have a ruling: the five shared-state reads and the model write are owner tier, the execution reads narrow to the caller's own rows, the five webhook routes are creator-or-owner, start/stop/model read stay open by ruling, and the six Files routes are tiered per verb and path. Each row now carries that reason; the legacy baseline drops to 116. The ent#875 census rules the new turn-tier route (the agent's own key only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
obasilakis
left a comment
There was a problem hiding this comment.
The share-holder narrowing on the routes ent#875 lists is correct and well tested: uniform 404 on execution detail/log/stream/terminate, webhook 403 only after the access check, unknown MCP scopes fail closed, SQL parameterized. Three things block it.
Major
src/backend/client_portal/work/service.py:372-374— Workspace/workcallsget_fleet_executions(agents, …)without the own-rows narrowing.roster_agent_names(include_owned=True)includes shared agents and_projectreturnstitle=clean_title(message), so a share holder still sees the first 120 chars of other people's prompts. Pass the viewer narrowing into the three calls andget_fleet_execution_stats, and add the route to the census test.src/backend/services/turn_tier_service.py:27-40— runs with nosource_user_id(schedule/webhook/manual) are rated OWNER. A share holder can create a schedule (create_scheduleusesassert_agent_access), mint its webhook, and have their own prompt run as an owner-tier turn with the full execution view. For runs carrying aschedule_id, rate the schedule'sowner_id.src/backend/dependencies.py:2695-2716— the agent-key narrowing applies only whenX-Trinity-Execution-Idis sent; missing ormanualgets the full view. The docstring relies on a turn-tier hook that is absent on this branch (it ships in #3778). Either move these commits into the ent#926 PR so they land with the hook, or fail closed, and correct the docstring.
Minor
src/backend/db/schedules/executions.py:549— a share holder's history for a schedule they created hides every cron run (nosource_user_id). Treat the schedule creator as owner tier on that history, or note it as intended.src/backend/models.py:4116—can_manage_webhook: bool = Truedefaults permissive. Default toFalse.routers/schedules.pyanalytics / analytics-summary — whole-agent aggregates stay visible to share holders. List them in the census test as ruled open.
- Workspace /work and /work/activity narrow every agent the viewer does not own to their own rows (user id, or email as requester / spawned-for client), in the WHERE before each LIMIT and in the window count; no other person's prompt reaches a card title. - turn_tier rates a schedule or webhook run by the schedule's creator, so a share holder's own schedule runs at share tier; a missing schedule fails closed. Its creator's history also shows its unattributed runs. - An agent key's narrowing no longer trusts X-Trinity-Execution-Id: it starts from the agent's running share-tier turns in the ledger, and the header can only narrow. Fails closed on a ledger error. Docstrings no longer lean on the turn-tier hook. - ScheduleResponse.can_manage_webhook defaults to False; the census covers the Work routes and rules the schedule analytics routes open. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@obasilakis thanks. All three blockers and the three minors are addressed in 6424f75 (it also merges Major 1: Workspace
Major 2: a share holder's own schedule ran at owner tier.
Major 3: the agent-key narrowing could be bypassed. This is closed in this PR alone and does not depend on #3778.
The header can only narrow further:
So leaving the header out, sending
Minors
Targeted unit tests: 532 passed. Those are the ent875/ent926 suites, the ent629/ent872 reach guards, the portal Work suites, fleet executions and the models guard. 🤖 Generated with Claude Code |
…te-census Keeps both PRs' guarantees: the agent key's execution reads start from the ledger (#3777: the header only narrows), and the turn-tier hook, the census-driven owner-route fence and turn_actor's visitor/person split stay (#3778). turn_actor now takes a row, rates a schedule on another agent as share and one with no recorded creator as the owner's (#3777 rules). Co-Authored-By: Claude Opus 5.5 <[email protected]>
obasilakis
left a comment
There was a problem hiding this comment.
Approving. Every point from my review is fixed, and each fix has a test that fails when the fix is reverted (checked one at a time: /work list filter, stats filter, activity filter, email match, schedule-creator rating, running-turn narrowing, include_unattributed, can_manage_webhook default).
This must land together with #3778.
Two points to settle, here or in a follow-up:
dependencies.py:2730-2756: while any share-tier turn runs on an agent (a Slack, Telegram or public-link chat has no user id, so it rates share tier), every request with that agent's key is narrowed to no rows, including the owner's own concurrent and scheduled runs, and gets 403 on/chat/history,/activityand/logs. The docstring states this;requirements/auth.md§2.11 does not. Please record it there as a known limit.turn_tier_service.py:35-39withchat_execution_service.py(~2181): a reminder or self-task the agent starts during a share turn rates as owner tier (reminder has no user id andtriggered_by="reminder"; a self-task is stamped with the owner's id). The running-turn check narrows it only while the parent turn runs, so a delayed one fires with the full view. This is the schedule-laundering path through a different trigger. Either carry the originating person onto the new turn and rate it share tier, or list reminders and self-tasks as a known limit next to loops. (Traced in code, not reproduced.)
…t#875) A person an agent is merely shared with sat at the accessor tier for execution reads and for the verbs that steer the agent: they listed, opened and streamed every other person's turns, read the activity timeline and the container log, terminated the owner's running turn, changed the model, forced a git pull and minted or read webhook URLs. Operator rulings (2026-10-15): one flat share grant, no schema change. Share holders see only executions they started (lists, detail, live stream, queued-prompt routes, fleet list narrowed in SQL before the limit). Terminate needs owner/admin or the execution's own requester. Webhook management is the schedule's creator or the agent owner. Model change and git force-pull are owner tier; start/stop stay open. - dependencies: viewer tier as an allowlist (owner / share / key), row scope helpers, assert_not_share_viewer (403 owner_tier_path) - db: keyword-only source_user_id / own_rows_user_id with an exemption list for agents the caller provably owns; NULL never matches - routers: schedules, chat, agents, git, executions, activities, fan_out, agent_config (capacity prompt previews) - frontend: webhook controls hidden when can_manage_webhook is false; own-rows note on the Tasks panel - scripts/management/list_webhook_rotation_candidates.py: read-only list of webhook schedules on currently shared agents, for rotation Tests: 241 new/updated unit tests, route census + AST guard over the read-helper call sites, real-SQLite narrowing proof, 18/18 mutations red. Related to Abilityai/trinity-enterprise#875 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- CodeQL: the rotation script prints token / signing-secret presence as constant text, so no credential-column value reaches the output. - regression diff: test_the_fleet_route_passes_the_narrowing_to_the_query failed only under CI's test order. The fleet router binds viewer_own_rows at import, and another test reloads the helpers module, so the test patched one module copy and the route called another. The helper now patches the globals of every copy the code under test can reach. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…s output path (ent#875) CodeQL classifies by name: a dict key called has_secret was treated as secret data even though only constant yes/no text reached the print. The fields are now url_minted and hmac_on. Output unchanged apart from the labels (url / signing). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…n it is (ent#926) ent#875 left an agent key at the full view of executions. An agent acts for whoever chats with it, so the auth dependency now records an agent key's X-Trinity-Execution-Id (#2392) privately on the principal, and the viewer helpers rate that turn with turn_tier_service: an owner-tier turn or no platform turn keeps the full view; a share-tier turn reads that person's rows (none with no platform user); an id that is not one of the key's agent's executions reads none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uard (ent#926) turn_tier_service rates the person who started a turn, read from the execution row, not the requesting principal, so no agent-key reach applies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g a fake roster (ent#875) - viewer_own_rows asks is_fleet_admin instead of comparing the role; agent keys already return before that line, so behaviour is unchanged. - turn_tier joins the guard's allowlist: the role it reads is the turn starter's user row, never the caller's, and it selects no roster. - _own_rows patched one module dict with both setattr and setitem. pytest undoes every setattr before any setitem, so the fake roster survived the test and broke ent#872's accessor tests under random order. Each dict is now patched once, with setitem. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Workspace /work and /work/activity narrow every agent the viewer does not own to their own rows (user id, or email as requester / spawned-for client), in the WHERE before each LIMIT and in the window count; no other person's prompt reaches a card title. - turn_tier rates a schedule or webhook run by the schedule's creator, so a share holder's own schedule runs at share tier; a missing schedule fails closed. Its creator's history also shows its unattributed runs. - An agent key's narrowing no longer trusts X-Trinity-Execution-Id: it starts from the agent's running share-tier turns in the ledger, and the header can only narrow. Fails closed on a ledger error. Docstrings no longer lean on the turn-tier hook. - ScheduleResponse.can_manage_webhook defaults to False; the census covers the Work routes and rules the schedule analytics routes open. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6424f75 to
b76b99a
Compare
Resolve tests/registry.json as a union of both sides' new entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#3777 merged into dev (91a2cef). Its branch was rewritten before landing, so its commits arrive again under new ids; the content equals the 6424f75 tip this branch had already absorbed (b76b99a is the same review-blocker fix). Every conflicted file therefore resolves to this branch's version, which is #3777's final text plus #3778's own extensions: - turn_tier_service.py, executions.py, dependencies.py: #3778 extends #3777's code (Workspace channel/email columns, the standing-work fence for every agent key); no #3777 line is dropped. - test_ent629/ent872 reach guards: the exemption follows the role check into _user_tier, where #3778 moved it. - auth.md: #3778's new section 2.12 and the renumbered 2.13 self-gate. - models.py: drop the duplicate _acting_execution_id PrivateAttr the auto-merge added (#3778 keeps it beside _acting_turn_cache). - registry.json: dev's file plus this PR's six ent926 entries; drop the duplicated ent875 entries the auto-merge produced. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hook call would pass The field applied only #3777's share-tier rule, so an agent key without `schedules.manage`, and the system key, read `can_manage_webhook: true` and then got 403 on every webhook route (trinity-enterprise#719 gates them with `require_person_or_capability("schedules.manage")`). The response now ANDs that rule, answered by a new non-raising `person_or_capability_admits` that shares the decorator's agent-key test and writes no audit row, with the share tier. The two lines #3777 left false once both landed are corrected: the "capability fence" sentence in webhook-triggers.md and the `_can_manage_webhook` docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWna79vVmnezQdhpaGRKbw
…schedule webhooks a person or schedules.manage (#4041) * fix(auth): sharing, public links and channel bindings take a person; schedule webhooks a person or schedules.manage Forty-nine owner- and access-tier routes decide who may reach an agent, who outside the platform sees it, or what a channel or webhook may do in its name. Each is a grant, so each now takes its rule as a decorator dependency, which FastAPI runs before the ownership or access check, so the refusal is the same whether or not the agent exists. - Schedule webhooks: a person or a schedules.manage holder; the own-agent exemption no longer covers them, since a webhook run is not bounded by autonomy. - Sharing, agent files, the operator's Workspace client management, public links and canvas share links: a person. Sharing and approving an access request write a Workspace sign-in, so they take a signed-in session. - Telegram, Slack, WhatsApp and VoIP bindings and exposure: a person; the three credential binds take a signed-in session. The agent-settable Telegram group fields stay agent-callable. FROZEN_BASELINE_COUNT is the baseline length. Part of Abilityai/trinity-enterprise#719 * fix(auth): the inline second layer on sharing, channel toggles and Workspace client control is the route's own allowlist Seven handlers carry a human-only rule in their decorator and keep an inline check "for direct callers": share and unshare, the Telegram progress-indicator toggle, the Slack proactive-consent toggle, and the Workspace client log out, block and unblock. The inline check was still `reject_agent_principal`, a denylist that refuses only an agent key, so a direct caller holding the system, ops, portal-delegate or an unknown-scope key, or a principal with no `mcp_scope`, got a weaker gate than the route has. Each first statement is now the allowlist its decorator applies: `reject_non_interactive_principal` on the INTERACTIVE share route, `assert_person` on the six PERSON routes. No HTTP caller sees a change: the decorator already refuses every one of those principals first. Tests: test_ent719_inline_layer_matches_route_rule.py calls each handler directly, with its first side effect replaced by a sentinel; 36 rows go red with the old denylist. Two direct-call pins (test_1310, test_223) now expect the PERSON detail, and test_837's sharing stand-in declares the session's `mcp_scope=None`, which the allowlist needs (the #2323 sentinel rule). Answers dolho's informational thread on client_portal/router.py:495. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWna79vVmnezQdhpaGRKbw * docs(grants): name the census, not a route list, for owner-tier writes outside the grants The "stay agent-reachable without a grant" bullet listed eight routes. This branch rules three of them (folders, file-sharing, access-policy) and the settings branch of trinity-enterprise#719 rules the other five, and every line of the list names routes from both, so the two branches could not edit it without conflicting. Both now replace the list with the same sentence, true before, between and after the two land: what stays agent-reachable is what the route census lists as agent-callable or still holds in its baseline, and no grant lifts a route that takes a person. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWna79vVmnezQdhpaGRKbw * docs(auth): the #1710 note on the Slack consent toggle names its current inline check requirements/auth.md said the toggle's inline `reject_agent_principal` was kept by #1710. The inline check is now `assert_person`, the allowlist the route decorator applies (trinity-enterprise#719), so the note says so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWna79vVmnezQdhpaGRKbw * fix(schedules): can_manage_webhook is true only when the caller's webhook call would pass The field applied only #3777's share-tier rule, so an agent key without `schedules.manage`, and the system key, read `can_manage_webhook: true` and then got 403 on every webhook route (trinity-enterprise#719 gates them with `require_person_or_capability("schedules.manage")`). The response now ANDs that rule, answered by a new non-raising `person_or_capability_admits` that shares the decorator's agent-key test and writes no audit row, with the share tier. The two lines #3777 left false once both landed are corrected: the "capability fence" sentence in webhook-triggers.md and the `_can_manage_webhook` docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWna79vVmnezQdhpaGRKbw --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: trinity-ability <[email protected]>
Summary
Scopes per-user access on the agent execution and control routes to operator rulings recorded on abilityai/trinity-enterprise#875 (private tracker; rationale, probes and release-note items live there).
Post-1.0 item: do not merge before the 1.0 cut (operator ruling 2026-10-13). Kept as a draft until then.
No schema change, no migration, no dependency, CI or Docker change.
Verification
test_ent751_gate_callers.py::TestPaidA2A, which fail identically on the base (stalepayments_pyin the local venv).Related to abilityai/trinity-enterprise#875
🤖 Generated with Claude Code