Skip to content

refactor(frontend): add action-primary token + sweep indigo (#554) - #815

Merged
vybe merged 1 commit into
devfrom
feature/554-sweep-slice-10-action-primary
May 12, 2026
Merged

vybe merged 1 commit into
devfrom
feature/554-sweep-slice-10-action-primary

Conversation

@oleksandr-korin

Copy link
Copy Markdown
Contributor

Summary

Final slice of the design-system migration (#554). Introduces the action-primary token family and sweeps all 376 indigo references across 55 files.

After this lands, the frontend uses tokens for every semantic palette use (status, state, brand, accent, action) — the structural migration is complete.

Changes

1. New token family

tailwind.config.js:

'action-primary': colors.indigo,

Documented alongside status/state/brand/accent — describes "interactive surface that performs a verb (primary buttons, links, focus rings)".

2. Validator update

scripts/check-design-tokens.mjs — adds action-primary to EXPECTED_ALIASES and action: new Set(['primary']) to KNOWN_FAMILIES.

3. Bulk sweep

55 files migrated, 376 raw indigo refs → action-primary. Palette-equivalent, zero visual change.

What's intentionally NOT touched

Blue/sky/teal references survive as raw colors:

  • blue (157 refs) — heterogeneous: manual-trigger-badge, status-info-ish accents, decorative
  • sky (1 ref) — chat-trigger-badge in TasksPanel
  • teal (20 refs) — public-trigger-badge, integration callouts

These are category labels, not semantic selected-state. A state-selected token would need per-callsite judgment, not a mechanical sweep. Defer to a future cleanup if/when we have UX direction on what "selected" should look like.

Lessons from prior slices

Perl prefix list deliberately excludes accent this time. Slices 8 and 9 had accent in the alternation, which caused accent-purple-X (already-migrated refs and Tailwind form-control accent uses) to double-substitute to accent-accent-purple-X. Verified post-migration: zero family-family- patterns anywhere in source.

Verification

  • grep -rE 'indigo-\d+' src/ → 0
  • grep -rE '(accent\|action\|state\|status\|brand)-(accent\|action\|state\|status\|brand)-' → 0
  • npm run check:tokens → ✅ 11 tokens equivalent, all references resolve
  • npm run build → ✅
  • e2e smoke: deferred to CI

Test plan

  • frontend-build CI green
  • frontend-e2e CI green (label: ui)
  • Manual sanity: any view with primary actions (Create Agent button, focus rings, links) renders the same indigo

Closes the migration arc of #554.

🤖 Generated with Claude Code

Final slice of the design-system migration. Introduces the
`action-primary` token family (aliased to colors.indigo, same palette
as the prior indigo uses — zero visual change) and sweeps all 376
indigo references across 55 files.

Changes:

1. tailwind.config.js — adds `'action-primary': colors.indigo` and
   documents the family alongside status/state/brand/accent.

2. scripts/check-design-tokens.mjs — registers the new family in
   EXPECTED_ALIASES and KNOWN_FAMILIES.

3. Bulk substitution — `indigo-X` → `action-primary-X` everywhere
   under src/frontend/src/ (55 files, 376 refs).

Notes:

- The perl prefix list deliberately excludes `accent` this time to
  avoid the double-prefix bug that affected slices 8 and 9. Verified
  zero `family-family-` patterns post-migration.
- Blue/sky/teal references are NOT touched in this slice. Audit showed
  they're heterogeneous category labels (chat-trigger-badge sky, public-
  trigger-badge teal, manual-trigger-badge blue, etc.) rather than
  semantic selected-state. A `state-selected` token doesn't have a
  clean mechanical mapping; defer to a future cleanup if needed.

Post-migration the frontend uses tokens for every semantic palette
use (status, state, brand, accent, and now action). The design-system
migration (#554) is structurally complete.

Verification:
- npm run check:tokens → 11 tokens equivalent, all references resolve
- npm run build → clean
- grep for raw indigo / double-prefix → 0 results

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@oleksandr-korin oleksandr-korin added the ui PR touches the frontend UI — triggers Playwright e2e tests label May 12, 2026
@oleksandr-korin
oleksandr-korin requested a review from vybe May 12, 2026 14:13

@vybe vybe 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.

Clean mechanical sweep — palette-equivalent, zero behavior change, tooling updated, double-prefix bug avoided. LGTM.

@vybe
vybe merged commit 53f31aa into dev May 12, 2026
11 checks passed
dolho added a commit that referenced this pull request Oct 8, 2026
…pawned, read directly (trinity-enterprise#629)

dev's ent#611/#715/#815 queue suites (29 tests) went red after the merge:
an admin-owned agent key's scope was built from the owner's
accessible-agent list and then filtered agent by agent, so a self or
permitted agent without an ownership row (every one in those fixtures)
dropped out. The scope now starts from {self} ∪ the agent's edges — the
MCP's own rule — bounded by a non-admin owner's set, plus the owner's
agents it spawned. The edge read fails closed. The router also gets the
logger it was missing.

ent#715's heads-ups fixture seeds the agent key's edge to the agent it
reads, so the test still checks that person rows are withheld, not that
the whole queue is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vybe pushed a commit that referenced this pull request Oct 13, 2026
… it spawned — on the raw backend routes too (trinity-enterprise#629) (#3346)

* fix(auth): an agent key reaches only itself, its edges and the agents it spawned — on the raw backend routes too (trinity-enterprise#629)

An agent-scoped MCP key resolves to its OWNER carrying the owner's role
(Invariant #8), so every access/owner predicate said yes for any sibling the
owner holds — on an admin-owned install, every agent. The agent_permissions
edge the MCP layer checks (P-02) did not exist one hop down: with its injected
key and TRINITY_BACKEND_URL, agent A could chat with, task, loop, read the
history and logs of, or replace the git token of any sibling B. Ruling
(operator, 2026-10-06): fix the hole.

Narrowed in the shared gate, not per endpoint (the #1890 lesson):

- dependencies.agent_may_reach(current_user, target, manage=):
  * use tier — get_authorized_agent[_by_name], assert_agent_access, A2A
    inbound: itself, an edge target, an agent it spawned with its current key;
  * manage tier — get_owned_agent[_by_name], assert_agent_owner: itself or an
    agent it spawned. An edge means "may call", never "may manage".
  Outside its reach reads as the uniform 404 (#186). Every other principal is
  unchanged. The edge read fails closed, like the MCP layer's.
- get_skill_managed_agent_by_name keeps the plain owner fence: skills.manage
  (ent#596) IS the grant to manage the owner's other agents.
- Every inline can_user_access_agent / can_user_share_agent call (16 files)
  ANDs the reach in; nevermined's admin shortcut no longer skips it.
- The operator queue had its own predicate (admin role → no filter): an agent
  key now always gets a set narrowed to its reach.
- MCP: every `baselined: ENT629` row in TOOL_ACCESS_POLICY is `enforce` on its
  agent parameter; the "tool-surface gate only" notes now name the backend fence.

Collection reads (the agent list, event-subscription list, MCP key list) are
not narrowed: they disclose names, never act on an agent.

Tests: tests/unit/test_ent629_agent_reach.py — the reach truth table on a real
schema, every helper, A2A inbound, the operator queue, the skills capability
keeping its reach, the dispatch routes resolving through the narrowed gate,
and an AST guard that fails the build on an inline access check without the
reach (exemptions carry their reason). Mutation-checked: reach always-true,
edge-as-manage, the access dependency dropping it, and an inline site
dropping it each turn tests red.

Docs: Invariant #8, security.md §5, P-02, the J10 docstring, mcp-server.md
and the affected feature flows and requirements.

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

* fix(auth): keep skills.manage's owner-wide reach through the files tab; regression fixes (trinity-enterprise#629)

From the regression run over every unit file touching a changed module
(14 new failures vs dev, all traced):

- The skill fence's owner check is its own seam again,
  `get_capability_owned_agent_by_name` (not narrowed: the capability is the
  grant), so the ent#596 recorder patches a named function.
- files.py: a skills.manage holder writing a sibling's skills path reaches it
  without an edge (`_may_reach_for_path`); every other path is narrowed. The
  capability gate still decides the write.
- share_agent_file checks "an agent key shares only its own volume" before the
  (now narrowed) owner gate, so a sibling gets the specific refusal.
- The depth suites (#2806, #2973) seed the A→B edge their sibling calls need.
- The edge read fails closed (a fixture schema without agent_permissions
  refused instead of raising — the enterprise assignment suites).

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

* fix(operator-queue): an agent key's queue scope is {self} ∪ edges ∪ spawned, read directly (trinity-enterprise#629)

dev's ent#611/#715/#815 queue suites (29 tests) went red after the merge:
an admin-owned agent key's scope was built from the owner's
accessible-agent list and then filtered agent by agent, so a self or
permitted agent without an ownership row (every one in those fixtures)
dropped out. The scope now starts from {self} ∪ the agent's edges — the
MCP's own rule — bounded by a non-admin owner's set, plus the owner's
agents it spawned. The edge read fails closed. The router also gets the
logger it was missing.

ent#715's heads-ups fixture seeds the agent key's edge to the agent it
reads, so the test still checks that person rows are withheld, not that
the whole queue is refused.

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

* fix(auth): a capability earns reach per request, not per holder (trinity-enterprise#629)

Merge-train review (2026-10-08, 2026-10-10): the narrowed gate revoked the
cross-agent reach that ent#164 capabilities exist to grant. A
`schedules.manage` holder got 404/403 on a sibling's schedule routes, an
`instructions.manage` holder on its instruction files and git reset, and an
`agents.manage` holder on `PUT /{name}/model`, because `agent_may_reach`
never saw which capability the route had checked.

- The two capability fences (`capability_fence`,
  `require_person_or_capability`) record the target they admitted on the
  request's principal (`User._capability_reach`, a private attribute), after
  the grant check and the owner bound. `agent_may_reach` honours that record
  on both tiers. This replaces `_manages_owners_agent`, which widened every
  owner check for an `agents.manage` holder on every route.
- `files._may_reach_for_path`: the path exception covers `instructions.manage`
  as well as `skills.manage`, needs the grant for each file class the path
  touches, and is bounded to agents the owner OWNS (`owner_owns_agent`). It
  used to reach any agent the owner could access.
- `loops._check_loop_access`: reach is checked before the admin and
  initiator shortcuts, so an agent key cannot read or stop a sibling's loop
  by id.
- Operator queue: the spawned set is one query
  (`list_agents_spawned_by_key`), not two lookups per held agent.

Also merges dev: the agents.py activity routes stay deleted (#3483), and
access.ts takes dev's owner constants alongside this PR's enforce rows.

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

* fix(mcp): a backend refusal of the loop read is the uniform loop refusal (trinity-enterprise#629)

J10 `test_without_permission_an_agent_cannot_read_or_stop_a_loop_on_another`
failed on journey-smoke. Since the backend checks an agent key's reach before
the admin shortcut in `_check_loop_access`, `GET /api/loops/{id}` answers 403
for a loop on an agent outside the caller's reach. `get_loop_status` and
`stop_loop` resolve the loop through that read before their own gate, so the
caller got a raw `API error (403)` instead of "Loop '<id>' not found or not
accessible" and the hint.

A 403 on the read now returns the same uniform body as the MCP gate, with the
same log line and audit row. The stop is still never sent. A 404 (no such
loop) keeps the backend's own shape, as the existing test pins.

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

* fix(credentials): an agent key gets the human-only refusal before the owner fence (trinity-enterprise#629)

The backend regression diff caught 4 new failures in
`test_3435_credential_tool_gates::test_agent_key_is_refused_human_only_even_for_its_owner`.
With the narrowed owner fence, `get_owned_agent_by_name` answers an agent key
on a sibling with the uniform 404, so the handler-body
`reject_agent_principal` never ran. The agent was told "Agent not found"
instead of the rule it hit.

`dependencies.human_only` is the route-level form of `reject_agent_principal`.
On export and import it now runs before the ownership dependency. The refusal
depends on the principal alone, before any lookup, so it discloses nothing
about the target (#186). The inline call stays as belt-and-braces.

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

* fix(auth): one owner bound per capability, a DB-decided MCP edge, and the #3346 review (trinity-enterprise#629)

Addresses webmixgamer's review of f9cd838.

1. `skills.manage` reached another user's agent through the skills routes on
   an admin-owned install. `get_skill_managed_agent_by_name` went through the
   unnarrowed owner fence, which `can_user_share_agent` answers True for any
   agent when the owner is admin; the files tab refused the same target. The
   skills fence now applies the bound every capability fence applies (grant,
   then `owner_owns_agent`, then record the reach) and returns the narrowed
   `get_owned_agent_by_name`. `can_manage_agent_skills` takes the same bound.
   The skill-gate writes use `get_owned_agent_by_name` (`_gate_writer`
   records first), so `get_capability_owned_agent[_by_name]` and
   `_owned_agent_or_404(narrow=False)` are gone: one mechanism.
2. The MCP `enforce` gate read the lenient permissions list, which is built
   from the Docker-filtered fleet. A ghost with no container, a child being
   recreated, a spawned child whose edge was removed, and every call during a
   Docker fault all read as "not permitted". New
   `GET /api/agents/{caller}/reach/{target}` answers from the edge or the
   spawn record in the database; `TrinityClient.isAgentPermitted` reads it
   and fails closed.
3. security.md no longer says collection reads "disclose names, never act":
   fleet-level routes still answer an agent key with its owner's reach, some
   of them write, and some return task text and emails. A private follow-up
   tracks them.
4. Tests for the review's surviving mutations:
   - credential export's `human_only`;
   - the queue's non-admin bound;
   - `deleted_at` in the spawned set;
   - a schedules holder through the real route via TestClient (same principal
     object for the fence and the path dependency);
   - another user's agent on the skills fence;
   - the reach endpoint.
   Each mutation now fails a test.
5. An agent key never gets the admin "every user" chat history or sessions
   view: "may call" is not "may read everyone's conversations with it".

Also: learnings fragment (capability bound in one helper).

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

* test(ent754): the gate-map world records who owns the gated agent (trinity-enterprise#629)

The backend regression diff caught
`test_probe_is_a_persons_even_for_a_key_that_may_manage_skills[agent_key_with_skills_manage]`.
Since the #3346 review, an agent key's `skills.manage` reaches only agents its
owner OWNS (`owner_owns_agent`), not every agent `can_user_share_agent`
admits. The fixture stubbed "may share" but never said who owns
`gated-agent`, so the bound read "unknown owner" and refused. The test's
premise is unchanged: the key's owner owns the agent, so the manage check
admits it and the probe is still refused for a key.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
developerjillur pushed a commit to developerjillur/trinity that referenced this pull request Oct 13, 2026
…t a sharee's (trinity-enterprise#866)

Every Workspace thumbs-down raises a `workspace_problem_report` alert that
names the rater, and with trinity#3521 quotes their comment. The operator
queue lists, for a non-admin, every agent they own OR are shared on. A person
an agent is shared with is often a client too, so client B could read client
A's email (and words) through `GET /api/operator-queue`, while
`GET /evaluations` withheld exactly those facts from the same caller.

`workspace-problem-` rows are now owner-only (`OWNER_ONLY_ID_PREFIXES`,
`is_owner_only`). A non-admin person sees them only for agents they own:
- list and per-agent list: a SQL condition beside the Abilityai#715/Abilityai#815 machine-key
  exclusion, so `total` and paging stay exact; the Python projection keeps a
  matching belt;
- by id: "Queue item not found";
- respond and cancel: 404; bulk-cancel counts them as skipped.

Owners and admins see the full alert. Machine keys already never see it. Only
the complaint is owner-only: a shared operator still sees and answers a skill
gate's approval (`gate-`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui PR touches the frontend UI — triggers Playwright e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants