Skip to content

fix(turns): a person seated as primary has the agent work in full for them (abilityai/trinity-enterprise#1318) - #4708

Open
trinity-ability wants to merge 1 commit into
devfrom
feature/ent1318-primary-seat-reach
Open

trinity-ability wants to merge 1 commit into
devfrom
feature/ent1318-primary-seat-reach

Conversation

@trinity-ability

Copy link
Copy Markdown
Contributor

Fixes abilityai/trinity-enterprise#1318 (private tracker, closed manually at release). Submodule side: Abilityai/trinity-enterprise#1336.

What

A turn's reach was owner/admin or "shared with"; seats were never read, so the person seated as primary on an agent (not its owner) got no shell, none of the owner's MCP servers, no standing work and no Gemini/Codex turn, on that agent and at every agent-to-agent hop.

  • turn_tier_service: a second provider slot, register_primary_seat_provider, asked only about (person, this agent), never the calling agent, so the permission edge never decides reach. A primary rates (owner, primary, P) after the owner/admin and member rules while the per-agent guardrail primary_reach is on (default; read live, no recreate). A primary's turn dispatches as P, so each hop re-rates.
  • Managing the agent stays with the owner and admins: the agent key in a primary's turn may set up standing work but is still refused every other owner-tier route (restricts_owner_routes). This only narrows today's restriction.
  • Switch off: P is a shared person again; the turn-tier route adds reason: "primary_off" so the hook, the Gemini/Codex gate and the standing-work fence say the owner turned it off. Older images ignore the field.
  • UI: "The agent works in full for its primary person" toggle beside the visitor switch (only with seats available); Permissions tab copy; user docs; architecture/security.md.
  • Without a provider registered, nothing changes.

Tests

  • tests/unit/test_ent1318_primary_reach.py (33). Mutations: dropping the fence split, dropping PRIMARY from the hop carry, and dropping the reason parsing each turn a test red.
  • Hook cases added to test_ent926_turn_tier_hook.py (that file needs Linux /proc; its 39 local failures are identical on clean dev).
  • Backend sweep (test_ent9*, test_ent1*, test_29*, guardrails, SEC: User and Agent Enumeration via differential API responses #186): only failures that also fail on clean dev or pass on rerun.

Deploy

Needs a base-image rebuild for the switch-off wording. The reach itself is backend-only.

Follow-up

A header-less curl with the agent key during a primary's turn dispatches as the owner (as for visitors and members today); to be filed.

🤖 Generated with Claude Code

… them (Abilityai/trinity-enterprise#1318)

A turn's reach was decided from two levels: owner or admin, or "shared with".
Seats were never read, so the person an agent is built for (seated primary,
not its owner) got no shell, none of the owner's MCP servers, no standing
work, and no Gemini/Codex turn, on that agent and at every hop. The field
case: Mira asked Finance to run its weekly close for its primary; refused.

turn_tier_service: a second provider slot, register_primary_seat_provider,
asked only about (person, this agent), never the calling agent, so the
permission edge between agents never decides reach (ruling 4). _person_tier
rates a primary (owner, primary, P) after the owner/admin and the ent#1148
member rule, while the per-agent guardrail primary_reach is on (default,
read live, no container recreate). A primary's turn dispatches as P, so the
next agent rates P afresh.

Ruling 3: managing the agent stays with its owner and admins. The fence lets
the agent key in a primary's turn set up standing work (schedules, loops,
reminders, events: ruling 6) but still refuses every other owner-tier route
(restricts_owner_routes). This narrows today's restriction; nothing that was
open closes.

Switch off: the primary is a shared person again, and the turn-tier route
adds reason "primary_off" so the shell hook, the Gemini/Codex gate and the
standing-work fence say the owner turned it off. Older images ignore it.

UI: "The agent works in full for its primary person" toggle beside the
visitor switch, shown only with the assignments module. The Permissions
tab says the person's reach also applies on the called agent. User docs
state what each seat gives at run time. Submodule bump carries the provider.

Tests: test_ent1318_primary_reach.py (33). Mutations: dropping the fence
split turns test_a_primarys_turn_may_not_manage_the_agent red; dropping
PRIMARY from _is_the_owners_own turns the hop test red; dropping the reason
parsing in turn_scope turns the runtime-gate case red. Hook cases added to
test_ent926_turn_tier_hook.py run in CI (that file needs Linux /proc; its 39
local failures are identical on clean dev). Needs a base-image rebuild for
the switch-off wording; the reach itself is backend-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vybe

vybe commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

merge-train 2026-11-21: ejected — needs intent. The operator ruled at Gate 1 that this rides once a primary's reach is fenced. Rides the next train once fixed.

Ruling (operator, merge-train Gate 1): eject until fenced. Before merge:

  1. Standing work set up during a primary's turn. The agent key creates schedules as the owner (routers/schedules.py:342 → db/schedules/crud.py:171, owner_id=user["id"]), so at fire time turn_actor rates the run (owner, None, None) — unfenced, surviving seat removal and primary_reach off, with management-route reach (sidesteps ruling 3). Keep the standing-work fence closed for primaries, or record the primary as the creator. Note tests/unit/test_ent1318_primary_reach.py:135 stubs owner_id = MATE, which production never writes.
  2. Reads during a primary's turn. acting_turn_user_id narrows reads only for share turns (turn_tier_service.py:504-512), so the key reads every person's executions and chat history on this agent and agents it can call. Narrow to the primary, or the new security.md line ("their reach on every other agent is unchanged") is wrong.

Also found (fix alongside):

  • dependencies.py:3294 (assert_agent_owner) and services/agent_service/files.py:357 call restricted_agent_turn(current_user) without owner_routes=True — a primary turn can force_reset git pull and rewrite instructions via the Files API, contradicting AC7.
  • primary_seat_reach / has_primary_seat don't AND can_user_access_agent: an unshared person's leftover seat still lifts them via a hop.
  • Production wiring unpinned: deleting _register_primary_seat_provider() from enterprise register() leaves both suites green — the test calls the helper, never register(app).
  • primary_reach defaults on, so existing primaries get the shell on deploy — say so in the PR body for the release notes.

Enterprise #1336's red seed is only the missing OSS seam (passes 9/9 against this tree) — not a finding.

@vybe vybe added the status-needs-fix PR has an unaddressed review/validation finding; cleared by the author's next push (#2815) label Nov 21, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Live-instance suite skipped — merge conflict against dev.

Resolve by merging dev locally and pushing the result; the next nightly re-tests.

@github-actions

Copy link
Copy Markdown

⚠️ Nightly unit-suite check skipped — merge conflict against dev.

Resolve by running git merge dev locally and pushing the result. The next nightly run will re-test once the conflict is gone.

This branch has not been deployed

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

Labels

status-needs-fix PR has an unaddressed review/validation finding; cleared by the author's next push (#2815)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants