Skip to content

fix(agents): names work once trinity- is reserved for the 12 and names are unique - #1573

Open
DealAppSeo wants to merge 4 commits into
mainfrom
fix/agent-names-unique
Open

DealAppSeo wants to merge 4 commits into
mainfrom
fix/agent-names-unique

Conversation

@DealAppSeo

@DealAppSeo DealAppSeo commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Owner action

You merge (Sean). MAJOR: it is the code half of a prod schema change and renames. Do not auto-merge.

Order:

  1. fix(pai): register each PAI under its own name trustshell#726 (each PAI registers under its own name) — merge and let it deploy.
  2. This PR — merge and let Railway deploy.
  3. Then the SQL paste (sent in chat, not in this repo). It adds a case-insensitive unique index on repid_agents.agent_name, gives trinity- back only to the 12 original agents, and strips it from every other agent.

Everything in this PR works both before and after the SQL runs, so step 2 can sit for as long as needed.

What changes

  • src/routes/repid.ts, src/routes/route.ts, src/services/agent-passport.ts: a name lookup tries the trinity- form first, then the exact name. Until now repid/route tried only the trinity- form, which stops finding other agents once they lose the prefix. The trinity- form goes first so a row holding only a bare slug like sophia can never outrank an original (Strix finding; the passport had the reverse order before this PR).
  • src/routes/agents-external.ts: a name another agent already has returns 409. It matches on the index name, so a duplicate wallet address is still the 500 it was.
  • src/routes/agents.ts: each human gets its own name (human-<12 hex>) instead of every human being HUMAN. The name is independent of the human's private id.
  • src/analytics/agent-performance.ts: the agent leaderboard drops humans by is_human, not by the name HUMAN. Side effect: the two human rows not named HUMAN also leave the agent leaderboard.
  • CLAUDE.md: what the prefix means, and that the unique index has to be checked before anyone relies on it.

Checked

  • New test: a taken name is a 409. It fails on main and passes here. A second test pins that a wallet clash stays a 500.
  • New test: with both trinity-shofet and a plain shofet present, the passport for shofet is the original. It fails on the old order and passes now.
  • tsc --noEmit clean. The 11 suites that touch these routes and the passport: 155/155 pass.
  • Full local run: 15 suites fail, and the same 15 suites fail with the same 146 tests on main in this Windows checkout (ENV). CI is the judge for those.
  • The first version used one .in() query; that broke every test double that only mocks .eq(), so it is two .eq() lookups now.

🤖 Generated with Claude Code

DealAppSeo and others added 2 commits November 16, 2026 14:10
Prepares the code for the 2026-11-16 SQL (applied separately by Sean), which
gives the trinity- prefix back only to the 12 original agents and adds a
case-insensitive unique index on repid_agents.agent_name. Everything here works
both before and after that SQL runs.

- repid.ts / route.ts: a name lookup tries the exact name and the trinity- form,
  instead of only the trinity- form. External agents lose the prefix.
- agents-external.ts: a taken name returns 409, keyed on the index name, so a
  duplicate wallet address is still reported as the 500 it was.
- agents.ts: each human gets its own name (human-<12 hex>) instead of "HUMAN";
  it is independent of the human's private id.
- agent-performance.ts: the leaderboard excludes humans by is_human instead of
  by the name HUMAN.
- CLAUDE.md: what the prefix means now, and that the index must be checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The single .in() query broke every test double that only implements eq().
Exact name first, then the trinity- form, the same order fetchAgentRow uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@strix-security

strix-security Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Strix Security Review

✅ No open security findings. All previously reported findings have been resolved.

PR summary: This PR resolves agent names canonical-first (`trinity-<name>`, then the exact name) across the score-card, LLM-completion, passport and task-bridge lookups, gives every human row a random `human-<hex>` name instead of `HUMAN`, returns 409 when registration hits the new unique agent-name index, and filters humans off the leaderboard by `is_human`.

Review summary

The changed identity handling holds up: the three name resolvers now try the canonical trinity- form first and fall back to the exact name, the passport and repid score-card surfaces return only already-public data, the LLM-completion attribution comparison fails closed on a mismatch, the new duplicate-name 409 branch runs before any write and leaves the anti-spam dedup and rate limits untouched, and the per-human name is 48 bits of CSPRNG output that is never used as a credential. The previously reported T12 task-score misattribution is fixed: pollCompletedTasks now falls back to the bare name and the new test pins that a trinity-foo task is scored to the agent now named foo. Nothing new was confirmed; the leads that were checked and rejected were the swallowed lookup error on duplicate names, resolver divergence with the untouched x402/caps/owner gates, human rows on the leaderboard, self-asserted is_human at registration, unproven wallet binding, and the unescaped agent name in the card SVG. One thing worth passing back to the author, not a security issue: the human insert never sets is_human, so the new .eq('is_human', false) leaderboard filter does not do what the description claims — its only consumer is currently unreachable, so it has no security effect today.

1 resolved finding
Ruled out (6)
  • Can an ambiguous duplicate name make a bare-slug row outrank the canonical agent in the repid score-card lookups?
    The dropped error on the canonical lookup is real, but exploiting it needs the non-unique-name state and a legacy bare-named row, and it only yields a wrong public score or proof card — the same underlying reservation issue the team already dismissed for this PR.
  • Does one caller-supplied name resolve to different agents on the passport and on the x402-gate, durable-cap and owner-resolution surfaces?
    Each of those gates resolves the caller's own name string at the same call site that makes the decision and fails closed on ambiguity, and no changed file imports or reaches any of them.
  • Do human rows still reach the agent leaderboard because nothing sets is_human to true?
    The filter is indeed ineffective for `human-<hex>` rows, but getAgentsLeaderboard's only caller (assignMentorships) has no caller in any route, cron or scheduler, so no score, rank or reward effect can be triggered.
  • Can anyone declare itself human at keyless registration to claim the reward multiplier or hide its identity?
    The self-asserted `is_human` write and its consumers are on lines this PR does not change or reach; the only diff line touching the flag is a leaderboard display filter.
  • Can a registrant bind another agent's wallet address to disturb that agent's settlement or auditor eligibility?
    The wallet binding is pre-existing and outside the diff, and the settlement impact only applies when the grounding and same-owner modes are set to enforce, both of which default to off.
  • Does the unescaped agent name in the card SVG execute script?
    The app-wide default Helmet CSP blocks inline scripts and event handlers, and neither the card renderer nor the registration name write is touched or reached by this PR.
Review history (3)
  • Review 3 · e31b95b · Nov 16 23:01 UTC · Fixed 1
  • Review 2 · 6e58863 · Nov 16 22:44 UTC · Found 1 new Low Vulnerability
  • Review 1 · 9d8f41d · Nov 16 22:32 UTC · Found 1 Medium Vulnerability

Review 3 on this PR · e31b95b · requested Nov 16 22:53 UTC on a new commit


Reviewed by Strix
Re-run review · Configure security review settings · Try a deeper review with @strix-security /deep

@strix-security strix-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strix flagged a new security finding below. See the pinned summary comment for the full PR status.

Comment thread src/routes/repid.ts Resolved
Comment thread src/routes/route.ts Resolved
Strix (PR #1573): exact-name-first let a row holding only "sophia" outrank
trinity-sophia in /repid/:id, /v1/llm/complete attribution and the passport.
All three resolvers now try the trinity- form first, then the exact name. The
passport had the same order before this PR; fixed with the rest.

New test: both "trinity-shofet" and a plain "shofet" exist; the passport for
"shofet" must be the original. It fails on the old order and passes now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DealAppSeo

Copy link
Copy Markdown
Owner Author

@strix-security please re-review 6e58863 (lookup order now puts the trinity- form first in all three resolvers).

@strix-security strix-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strix flagged a new security finding below. See the pinned summary comment for the full PR status.

Comment thread src/routes/repid.ts Resolved
Comment thread src/services/agent-passport.ts Resolved
Strix (PR #1573): the task bridge looked up only the trinity- form of a task's
agent name. trinity_tasks' own trigger still prefixes every name it stores, so
once the companion SQL strips the prefix from non-original agents, their tasks
would be skipped. The bridge now tries the trinity- form first (the 12), then
the bare name. The passport comment names all four resolvers.

New test: a task recorded as trinity-foo, agent row named foo, is scored. It
fails without the fallback and passes now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DealAppSeo

Copy link
Copy Markdown
Owner Author

@strix-security please re-review e31b95b (task bridge now tries the trinity- name first, then the bare name).

@strix-security strix-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changed identity handling holds up: the three name resolvers now try the canonical trinity- form first and fall back to the exact name, the passport and repid score-card surfaces return only already-public data, the LLM-completion attribution comparison fails closed on a mismatch, the new duplicate-name 409 branch runs before any write and leaves the anti-spam dedup and rate limits untouched, and the per-human name is 48 bits of CSPRNG output that is never used as a credential. The previously reported T12 task-score misattribution is fixed: pollCompletedTasks now falls back to the bare name and the new test pins that a trinity-foo task is scored to the agent now named foo. Nothing new was confirmed; the leads that were checked and rejected were the swallowed lookup error on duplicate names, resolver divergence with the untouched x402/caps/owner gates, human rows on the leaderboard, self-asserted is_human at registration, unproven wallet binding, and the unescaped agent name in the card SVG. One thing worth passing back to the author, not a security issue: the human insert never sets is_human, so the new .eq('is_human', false) leaderboard filter does not do what the description claims — its only consumer is currently unreachable, so it has no security effect today.


Reviewed by Strix
Configure security review settings

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant