Skip to content

feat(mcp): a person runs a Workspace project with their own key (trinity-enterprise#1322) - #4688

Merged
vybe merged 13 commits into
devfrom
feature/ent1322-person-key-projects
Nov 21, 2026
Merged

vybe merged 13 commits into
devfrom
feature/ent1322-person-key-projects

Conversation

@vybe

@vybe vybe commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What

A person can run a Workspace project over MCP with their own key (trinity-enterprise#1322). Until now all 17 project tools called the agent-only routes, so a person's user key was refused agent_key_required and the acts only a person may do had no tool at all.

  • The existing project tools route by the key's scope. An agent key sends exactly the request it sent before. A person's user key goes to the Workspace project routes and acts as that person, with that person's permissions. A user key that names an agent is refused act_as_not_offered: there is no act-as-agent path on project tools. Any other scope is refused in the tool, key_not_supported, with no request sent.
  • Five tools for the acts that are a person's, listed to user keys only: set_project_lifecycle (start, stop, finish, archive, restore), update_project_settings (name, goal, tracker, steward, visibility, mode; one request per concern, each outcome reported), set_steward_waking, manage_project_members (a result per item), decide_project_runs (lists the waiting runs, then approves or declines; success only when every id was applied).
  • Listing is exact per key. 15 shared tools are listed to agent and user keys; start_project_task and propose_project_changes to agent keys only; the five person tools to user keys only; system keys see no project tool. A hidden tool called by name answers "not found" and the backend is never asked.
  • Texts point only at paths that work. No description or refusal names a tool the reading key is not listed. A steward's proposal carries proposal.how_to_decide for a person's key.
  • explain() reads a string 403 as "not licensed" only when it says so; every other string 403 passes through.

No backend route, gate or schema changes. Two comments in src/backend/client_portal/ are reworded because this change made them untrue.

Rulings carried (orchestrator, on the operator's behalf: plan file, issue comment of 2026-11-20)

  • The person acts as themself with their own key; no act-as-agent on project tools.
  • Five grouped person tools; shared tools routed by scope; system keys see none.
  • start_project_task stays agent-only in this release: the person route opens a chat and returns the first message for a browser to send, so a call with a person's key would report success with no run started.
  • Log lines read the same as from the Workspace; the MCP audit row carries the key's scope (already true, now pinned by a test).
  • One pointer line in the public user docs; the who-may-call table lives with the module's own docs.
  • A Workspace-only account cannot create an MCP key, so this reaches operator-level accounts.

Review + security

/review on a523c51: MERGEABLE AFTER FIXES. One must-fix (decide_project_runs reported success for refused ids; its fixture used a shape the backend never sends) and five small items, all closed in 507f4b1, da33ae5, b021ed1, f38c05d. The review's 22-tool by 6-scope table found no key listed a tool it cannot use and no key reaching the other route family; four mutations on routing and listing went red (17, 2, 45 and 15 tests). Agent-key requests were compared with dev by reading, not by a recorded diff.

/cso --diff: no finding in the diff. It was a partial run: no image checks, no full-history secret scan, no CVE list (no docker where it ran). The fix commits after a523c51 were covered by /validate-pr round 1 on 44764bc, which requested two changes: decide_project_runs claimed the approvals were applied when some ids were refused and the decline request then failed (fixed in 9fe4e68, red first), and one architecture page still said no MCP tool reaches the Workspace surface (fixed in d6a8cb3).

Tests

cd src/mcp-server && npm test: 1583 of 1583 at 9fe4e68; tsc --noEmit clean. New: projects-person-key.test.ts (103 tests), the project block in tool-visibility.test.ts over the real transport, a pointer test over descriptions and run-time refusals for user and agent keys.

Before merge

  • The private module's PR (tests pinning that the person routes admit a person's own user key) merges first.
  • Nothing here was exercised against a live backend: the person routes are stubbed at fetch. One call per person tool against a running instance before release.
  • The documented tool count is 190; recount if another tool PR merges first.

Handoffs

  • Whether a person starts a task's run over MCP is an open product question (it needs the tool to send the first message itself).

Journey Impact: none: no journey in the catalog covers operating a project over MCP today.

🤖 Generated with Claude Code

Trinity Agent (trinity) and others added 11 commits November 20, 2026 10:52
…enterprise#1322)

CP-P1 — access rules and listing. Two allow-list predicates in access.ts:
projectToolAccess (scope agent or user) for the shared project tools, and
agentKeyToolAccess (scope agent) for start_project_task and
propose_project_changes. Every project tool now carries its own canAccess, so
none inherits the operator gate and the system key, ops, connector, delegate
and any future scope are shown no project tool. The policy rows say the tools
route by the key's scope.

tool-visibility.test.ts gains a real-transport census: each project tool is
listed to exactly its scopes for seven key scopes, every registered project
tool has a row and its own canAccess, a person-rule row maps to [user]
exactly, and a hidden tool called by name is "not found" with zero backend
requests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (trinity-enterprise#1322)

CP-P2 — the person-route client and the read tools. A new module,
tools/projects_person_client.ts, calls the Workspace project routes with the
person's own user key (no act-as header, no turn), mirroring the agent door's
read methods by name and shape. The seven read tools (list_projects,
get_project, list_project_tasks, get_project_log, list_project_executions,
get_steward_digest, read_project_context) pick the door from the key's scope,
an allow-list: agent keeps today's exact request and its refusal of another
agent's name; user reads as the person; a user key naming an agent is
refused act_as_not_offered; any other scope is refused key_not_supported in
the tool, with no request. Keyless dev mode keeps today's path.
list_projects takes include_archived for a person's key.

projects-person-key.test.ts drives the real tools and client with only fetch
stubbed: per tool and scope, the request that leaves the server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…utes (trinity-enterprise#1322)

CP-P3 — the write tools. create_project_task, update_project_task,
add_project_task_note, add_project_log_entry, link_to_project,
set_project_health, create_project and import_project pick their door from the
key's scope on the same allow-list as the read tools (one doorFor): agent keeps
today's exact request; user acts as the person on the Workspace route with the
same body; a user key naming an agent is refused act_as_not_offered; any other
scope is refused key_not_supported in the tool, with no request. import_project
takes `agent` for a person's key (the agent whose folder it is) and refuses its
absence as agent_required.

No write tool listed to a user key can answer it "needs an agent key" any more:
the act-as path is gone from them. create_project_task, create_project and
import_project no longer point at propose_project_changes, which a person's key
cannot call. The #1024 project act-as tests now expect act_as_not_offered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (trinity-enterprise#1322)

CP-P4 — the person's acts, per the orchestrator's second rulings:
- set_project_lifecycle: start, stop, finish, archive, restore. Each has a
  person route (finish is PATCH status=done; the others their own POST). A note
  is logged on start and stop only, and note_recorded says so.
- update_project_settings: sends goal (never description); the fields, steward,
  visibility and mode each go in their own PATCH, and results reports each, so
  a refused mode never hides that visibility applied.
- set_steward_waking: on resumes, off pauses.
- manage_project_members: one request per item, in order, URL-encoded on
  DELETE, a result per item; at most 20, an item both added and removed is
  refused, and project_not_found stops the batch with the rest not_attempted.
- decide_project_runs: no ids lists the waiting runs with their ids; approve
  and decline pass the backend's per-id results through; an id in both lists
  is refused.

Each is listed to user keys only (humanOnlyToolAccess("person"), PERSON_ONLY
policy rows) and refuses any other key inside the tool: an agent key with
persons_act naming the path it has (ask_operator, or propose_project_changes
for people and steward), every other scope key_not_supported. The listing
census covers all 22 project tools, and a user-only project tool must carry
the person policy row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t reads them (trinity-enterprise#1322)

- explain(): only a 403 saying "is not licensed" reads as not licensed; any
  other plain-string 403 (account_has_no_email, a Workspace permission) is
  passed through unchanged. A test per source: list_projects, get_project, fail().
- A session with no scope takes the agent path only when the server requires
  no key; a keyed one is refused key_not_supported. Over the real server, a key
  row with no scope is listed and routed as a person's key.
- read_project_context promises truncated/next_offset to an agent's key only;
  an offset from a person's key is refused offset_not_offered, with no request.
- get_project gives a person's key the steward-proposal pointer on a waiting
  proposal: proposal.ask_id as item_id to respond_to_operator_queue, decided by
  the proposing agent's primary contacts. An agent key's page is unchanged.
- link_to_project, get_steward_digest and set_project_health reworded to read
  true for a person and an agent.
- Pointer test over the real transport: no project tool description, and no
  refusal those tools give, names a tool the reading key (user, agent) is not
  listed. It went red on a first draft that named respond_to_operator_queue in
  the shared get_project description.

Mutation: with the explain() and scope-less fixes reverted, the three
pass-through tests and the keyed scope-less test went red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…prise#1322)

- docs/memory/architecture/mcp-server.md: the scope allow-list on the project
  tools (agent / user / refused), the keyless-only scope-less path, listing per
  scope, the offset and proposal pointers, the explain() rule, and the guards.
- docs/user-docs/sharing-and-access/workspace-projects.md: one pointer line
  (ruling T5) — a person's own key works on the project tools; a
  Workspace-only account cannot create an MCP key.
- docs/user-docs/integrations/mcp-server.md: 190 tools, 185 operator tools,
  projects.ts 22 — the counts tool-count-docs.test.ts reads from createServer().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…applied (trinity-enterprise#1322)

The backend answers runs/approve|decline with HTTP 200 and one {id, outcome}
per id; a refused id (run_not_found, already_decided, ...) was returned under
success: true. Each id now carries applied + why, success is true only when
every id was applied, and approvals stay reported when the decline request
after them fails (review C1, I1). The fixture now uses the backend's real
shape; the run_not_found test went red on the previous code (success: true).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…visibility pins (trinity-enterprise#1322)

- The two agent-only tools answer a user key "this tool is for an agent's own
  key", naming no path (review I3).
- The not-found-by-name loop covers the agent key on the five person tools (I4).
- agent_name and list_projects describe both a person's key and an agent's (I5).
- get_project's proposal pointer, built from a backend answer, is walked for
  tools a user key is not listed (I2; red when the pointer names
  propose_project_changes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… scope (trinity-enterprise#1322)

Ruling T4: audit.ts::logToolCall writes mcp_scope from the session on every
wrapped call; a get_project call with a user key records mcp_scope 'user'.
Red with that field dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ies scope (trinity-enterprise#1322)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…an agent one

The project tools call the Workspace project routes with a person's own
user-scoped key, which get_portal_principal resolves to that person; an
agent key is still refused there. Reword the portal_auth comment and the
router's # mcp: header, which said no MCP tool targets the surface.

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

@trinity-ability trinity-ability 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.

PR validation: commits after a523c51 (507f4b1..44764bc)

Verdict: REQUEST CHANGES. I found two small items. The routing, listing and per-id logic hold.

Required changes

  • decide_project_runs says "The approvals were applied" when some were not. Inputs: approve [r1, r2], where the backend answers r1: started and r2: already_decided, then the decline request fails (503). The tool returns error: "The approvals were applied; the declines were not (…)", while approved[1] reads applied: false. The condition d.failed && approve.length && !a.failed checks that the approve request succeeded, not that every approve id was applied. Suggested fix: add && a.rows.every((r) => r.applied) to that branch. Otherwise fall through to the N of M not applied text, or name both counts. Add a test with exactly these inputs, asserting the error does not claim the approvals were applied.
  • docs/memory/architecture/workspace.md:184 still says "no MCP tool targets it". The PR body lists this under "Before merge" but the PR does not change it. Suggested sentence: "There is no legitimate agent caller of this surface. No agent image calls it, and its one MCP caller, the project tools (tools/projects.ts), reaches it only with a person's own user-scoped key, which resolves here to that person. An agent key is refused."

What was checked

(1) Each backend outcome maps to applied or not applied. I read the batch route on the companion module's main branch. It answers HTTP 200 with one {id, outcome} per id: the run's state when the decision was applied, or the refusal code otherwise. Whole-request 403s (person_required, the contribute check) come back as errors. I ran a scratch probe (since deleted) over every outcome for both approve and decline: started, ended, declined, proposed, withdrawn, run_not_found, already_decided, not_permitted, mode_track, project_stopped, dispatch_failed, task_run_live, task_done, agent_not_on_project, origin_cannot_view, an invented weird_new, and "".

  • applied: true only for approve ∈ {started, ended} and decline = declined. Every other value, including the unknown one and the empty one, gives applied: false, and success is true only when every id was applied. ✅
  • ended as an applied approve is right: a failed dispatch raises dispatch_failed instead, so ended only means the run already finished.
  • An approve that succeeds followed by a decline request that fails: the approvals are kept and reported. ✅ The wording is wrong only in the mixed case above.
  • Minor: a 200 with no results key ends in the catch branch, which reports "Projects could not be reached." It is treated as not applied, which is safe, but the text is misleading.

(2) Mutations. Each was restored from a copy, and the tree was clean after each.

  • success: notApplied === 0 changed to true → 3 red: an id the backend answers already_decided is not applied…, an id the backend answers run_not_found is not applied…, approvals that went through are reported when the decline request then fails.
  • The in-tool scope allowlist (doorFor) made to admit ops → 14 red: the ": any other scope is refused in the tool, with no request" family in projects-person-key.test.ts.
  • Extra: the listing allowlist PROJECT_TOOL_SCOPES with ops added → 2 red in tool-visibility.test.ts.

(3) The new refusal on the two agent-only tools names no tool and no path, and it is true for start_project_task and propose_project_changes. ✅ Nit: explain() also returns this text for any 403 agent_key_required, for example list_projects in keyless dev mode. There, "a person's key can't call it" is not true of that tool. Consider a variant of the text for that case.

(4) src/backend/client_portal/: the diff changes comment lines only. No code line changed. ✅ The new text is accurate: the project routes use that auth door, and router.py itself has no MCP caller.

(5) PR body "Before merge": honest.

  • The companion PR is still open, so "merges first" still applies.
  • No live-backend run happened, and the body says so.
  • The tool-count caveat is fair.
  • It is incomplete in two ways: it misses the wording defect above, and "all closed in 507f4b1…f38c05d3f" overstates that one.
  • No closing keyword: the body names several refs, so I did not patch it. After merge, set the linked issue's status by hand; the automation is same-repo only.

Security pass, this range only:

  • Diff greps for secrets, tokens, emails, IPs, symlinks or mode changes, host paths and invisible Unicode: 0 hits.
  • The range adds no request, route, header, scope or credential handling. decide parses only the tool's own fail() JSON, and backend text is passed through as data.
  • No finding.

Gate: 20 checks pass and 6 are skipped on 44764bc. dev-ci is success. As instructed, I did not re-run the suites CI ran.

Not run: a live-backend call per person tool, which the PR body already lists. I did not re-run the full MCP suite: only the three project test files ran, under mutation.

@trinity-ability trinity-ability added the status-needs-fix PR has an unaddressed review/validation finding; cleared by the author's next push (#2815) label Nov 20, 2026
Trinity Agent (trinity) and others added 2 commits November 20, 2026 12:21
…every id was

When the approve request succeeded but some ids were refused (e.g. r1
started, r2 already_decided) and the decline request then failed, the
error read "The approvals were applied". It now names both counts:
"1 of 2 approvals applied; the declines were not (...)".

Red first: "a decline failure after a partly applied approve names both
counts" failed on the old code (doesNotMatch /^The approvals were
applied/). Its mirror (every approval applied, decline fails) pins the
true claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on's key

Replace the stale "no MCP tool targets it" claim: the project tools reach
the surface with a person's own user-scoped key; an agent key is refused.
Grepped docs/ for the same claim about this surface: no other hit.

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

@trinity-ability trinity-ability 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.

Round-2 validation of 44764bc..d6a8cb3 only. Both changes I asked for are in.

Range scope. Three files change: tools/projects.ts (only the error branch of decide_project_runs), its test file (two new tests) and docs/memory/architecture/workspace.md. Nothing else.

decide_project_runs, by scenario (probe with approve [r1,r2], decline [r3], failed request = 503):

scenario success error per-id rows
every approval applied, decline request fails false "The approvals were applied; the declines were not (…)" r1, r2 applied; r3 not, with why
no approval applied, decline request fails false "0 of 2 approvals applied; the declines were not (…)" every row shows applied: false with why
approve request fails false "2 of 3 not applied; see approved and declined." r1, r2 not applied with why; r3 applied
approvals partly applied, declines succeed false "1 of 3 not applied; see approved and declined." r1 applied, r2 not (already decided), r3 applied
partly applied, decline request fails (the round-1 case) false "1 of 2 approvals applied; the declines were not (…)" r1 applied, r2 not, r3 not

None of these claims more than happened.

Mutation. I forced the new condition approvedCount === approve.length to always true, which is the old behaviour. The test "a decline failure after a partly applied approve names both counts" went red (102 pass / 1 fail). After restoring the file, it was 103 / 103.

Docs. The sentence is true at this tip:

  • get_portal_principal calls reject_agent_principal (client_portal/portal_auth.py:261), so an agent key is refused.
  • projects.ts sends only user-scoped keys to the person routes (it picks the route from the key's scope; any scope other than user or agent is refused in the tool).
  • The only other MCP tool near this surface is the files tool, and it uses the agent files route, not this dependency.

Nit, not blocking: the edited paragraph has one long line that was not re-wrapped.

Not run: the full suites (CI is green on the tip: 20 pass, 7 skipped; dev-ci success). I ran only the one test file, for the mutation.

APPROVE

@trinity-ability trinity-ability removed the status-needs-fix PR has an unaddressed review/validation finding; cleared by the author's next push (#2815) label Nov 20, 2026
@vybe
vybe marked this pull request as ready for review November 20, 2026 17:43
@vybe
vybe merged commit 7fc4c42 into dev Nov 21, 2026
28 checks passed
trinity-ability added a commit that referenced this pull request Nov 21, 2026
…1324) (#4696)

Carries the person user-key contract tests and the refusal wording for
project routes (Abilityai/trinity-enterprise#1322), the private half of
the change whose MCP half merged as #4688. One commit ahead of the old pin.

Co-authored-by: trinity-ability <[email protected]>
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants