Skip to content

fix(mcp): fence get_agent_assignments — built, not registered, for the 0.9.5 cut (F1) - #2863

Merged
vybe merged 3 commits into
devfrom
fix/f1-fence-get-agent-assignments
Sep 17, 2026
Merged

vybe merged 3 commits into
devfrom
fix/f1-fence-get-agent-assignments

Conversation

@dolho

@dolho dolho commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

0.9.5 work order F1 ("The assignments tool gets fenced"). Related to abilityai/trinity-enterprise#500 (moved back to status-in-progress).

What

  • src/mcp-server/src/server.ts: createAssignmentTools no longer imported or added to toolGroups — get_agent_assignments is not advertised to any scope. Comment at the site says why and how to re-enable.
  • src/mcp-server/src/access.ts: policy row removed (the ent#628 totality test forbids a row for a tool that isn't registered); kept as a commented line to restore.
  • src/mcp-server/src/tool-visibility.test.ts: the ent#500 block now pins the absence of the registration (module still builds; no write tool still asserted).
  • tools/assignments.ts + assignments.test.ts untouched — the module stays; only the registration is withheld.
  • Docs: architecture/mcp-server.md, user-docs/integrations/mcp-server.md, feature-flows/role-assignments.md say fenced.

Re-enable = one import + one toolGroups line + the access row + flip the test.

Verification

  • npm test (MCP server): 409 passed, 0 failed — includes access.test.ts (policy total over registered tools) and the flipped visibility test.
  • tsc --noEmit: clean.

🤖 Generated with Claude Code

…e 0.9.5 cut (work-order F1, ent#500)

The assignments layer is not shipping in 0.9.5, so the MCP tool that reads it must not be
advertised. `server.ts` no longer imports/registers `createAssignmentTools`; `access.ts`
drops the policy row (the ent#628 totality test forbids a row for an unregistered tool);
`tool-visibility.test.ts` pins the ABSENCE of the registration instead of its presence.
`tools/assignments.ts` and `assignments.test.ts` stay — re-enabling is one import + one
line + the row. Docs rows (architecture, user-docs, feature-flow) say "fenced".

MCP suite: 409/409; `tsc --noEmit` clean.

Related to Abilityai/trinity-enterprise#500

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@dolho

dolho commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

/review Report

Branch: fix/f1-fence-get-agent-assignments → dev (merge-base 3a47f74)
Files Changed: 6 (+26/−9) — 3 MCP-server source/test files, 3 docs
Scope: CLEAN — intent (0.9.5 work-order F1): remove get_agent_assignments from the MCP tool list; move ent#500 to in-progress. Delivered: registration + policy row removed, test flipped, docs marked fenced; ent#500 relabelled status-in-progress (comment on the issue).
Plan Completion: 2 done — tool list: server.ts:44 (import gone), server.ts:640-644 (toolGroups entry gone); label move: done on ent#500 (outside the diff, verified).

Critical Findings (block merge)

None.

Informational Findings (review required)

[I1] Consistency (4.7): the flipped test block's names now say the opposite of what it asserts (Confidence: 8/10)
File: src/mcp-server/src/tool-visibility.test.ts:407-433
Evidence: describe("ent#500 get_agent_assignments is operator-scope only", …) with it("advertises to user, agent and system scopes") and messages `${scope} should see get_agent_assignments` — but those cases exercise makeOperatorOnly generically, and the new case at :445 asserts the tool is not registered for any scope. The block passes; it is misleading to read.
Suggestion: rename the describe to "ent#500 get_agent_assignments — operator-scope gate (module) + fenced registration (0.9.5 F1)" and the two scope cases to name operatorOnly rather than the tool; or fold the scope cases into the existing generic makeOperatorOnly describe. Test-only rename.

[I2] Documentation staleness (4.13): the advertised tool counts (Confidence: 7/10)
Files: docs/memory/architecture/mcp-server.md:17 ("129 across 33 tool modules"), docs/user-docs/integrations/mcp-server.md:3 ("130 tools across 33 modules")
Evidence: the two headline counts already disagree by one on dev, and this PR removes one registered tool without touching either number; the per-module row was updated ((1 — not registered …) / 0 (fenced)), the totals were not.
Suggestion: derive once from builtinToolNames (the access.test.ts boot gives it) and set both; at minimum decrement both by one here.

[I3] Scope note (4.14): the fence is the MCP advertisement only (Confidence: 9/10)
Evidence: client.ts:3371 getAgentAssignments remains; no OSS router serves assignments (src/backend/routers/ has none — the REST surface is the enterprise module, ent#500's own PR). F1 says "remove from the MCP tool list", which this does exactly; the enterprise REST read stays reachable to JWT/ops principals where the module is mounted and entitled. If the ruling meant the whole surface, that is an enterprise-side change, not this PR. Recording so nobody reads "fenced" as "gone".

Clean Categories

  • 4.3 auth — removing an advertisement narrows exposure; nothing widened. access.test.ts (policy total over registered tools, both directions) passes with the row removed, so no stale-row or missing-row drift.
  • 4.1 / 4.2 / 4.4 / 4.5 / 4.8 / 4.10 / 4.11 / 4.12 — no runtime code path added; the change is subtractive.
  • 4.9 tests — the absence is pinned (doesNotMatch on both the import and the toolGroups call), so a stray re-registration goes red; the module's own assignments.test.ts still runs (module retained).
  • Re-enable path is documented at both sites and in the feature-flow note; one import + one line + the row + flip the test.
  • MCP suite 409/409; tsc --noEmit clean.

Summary

  • Critical: 0 — none found
  • Informational: 3 — I1/I2 are naming/doc-count tidy-ups (cheap, could ride this PR); I3 is a scope statement for the release notes
  • Scope: clean

Review complete. Next: /validate-pr 2863; the release notes line for F1 should say "not registered in the MCP server this cut", not "removed".

dolho and others added 2 commits September 17, 2026 14:39
`fallback_to_api_key` fails OPEN on a raising settings read, so the test
kept running past its mocked `db` into two call-time reads it never
stubbed: the agent container and the platform API key. Whatever the
pytest process held decided the outcome — on CI under one randomly
order a key leaked in from an earlier test, the fallback ran for real,
and the `is None` assertion failed on a PR that touched only the MCP
server (regression-diff job on #2863).

Reproduced locally with ANTHROPIC_API_KEY set: identical assertion
message. Stub both reads so the assertion states its actual premise —
no key ⇒ nothing to fall back onto ⇒ None, and no exception.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…129 (F1) — mechanical

/review I1: the ent#500 describe/it names said the tool is advertised to
operator scopes; those cases exercise the operatorOnly gate, and the block
now pins that the tool is NOT registered. /review I2: the booted server
registers 129 tools (124 operator) with inline login on; the user doc said
130/125. The architecture doc already reads 129.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@vybe

vybe commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

merge-train 2026-09-17: one mechanical commit pushed to this branch — 413439f11, closing /review I1 + I2:

  • tool-visibility.test.ts: the ent#500 describe and its three scope cases are renamed to say they exercise the operatorOnly gate (they no longer claim the tool is advertised); assertions untouched. npm test 409/409, tsc --noEmit clean.
  • docs/user-docs/integrations/mcp-server.md: 130 → 129 tools, 125 → 124 operator tools. A boot of this branch's server registers 129 with inline login on (127 off). The architecture doc already read 129.

Noted, not changed: the "not registered" pin at tool-visibility.test.ts:457-458 is a source-text match (a renamed import slips past it); the boot-time totality test in access.test.ts still catches a naive re-registration without its policy row.

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

merge-train: batch validated on train/20260917-1237 (#2868)

@vybe
vybe merged commit 1d9022e into dev Sep 17, 2026
28 checks passed
AndriiPasternak31 added a commit that referenced this pull request Oct 2, 2026
…sed consent, gitlink bump (Abilityai/trinity-enterprise#500) (#3034)

* fix(assignments): unresolved proactive consent fails closed (trinity-enterprise#500 [I1])

_render_assignment appended the consent qualifier only when
proactive_consent was not None, so a provider answering
{primary_user_display, role_id} and nothing else -- a valid answer,
since _validated skips absent keys -- rendered a bare name. That is the
inference the function's own docstring forbids: a name with no
qualifier reads as permission to reach out.

Only an explicit True now renders "permitted"; False and None both
render the restrictive clause. The compose-time merge in
compose_system_prompt is left as is: it preserves None, which the
renderer now closes, and no src/ caller pre-fills the fields.

dolho's go-live condition from the #2596 review.

* feat(mcp): register get_agent_assignments again -- reverse the 0.9.5 fence (#2863) (trinity-enterprise#500)

#2863 withheld the tool from toolGroups for the 0.9.5 cut because the
assignments layer had no backend. PR2a (trinity-enterprise#669) ships
that layer, so the registration, the access.ts policy row and the
presence pins in tool-visibility.test.ts return, along with the doc
text #2863 replaced (restored verbatim from its diff).

Must not merge before the enterprise gitlink bump: on a build without
#669 the tool is advertised but always answers "not available".

* fix(mcp): get_agent_assignments never echoes the raw error text (trinity-enterprise#500 [I3])

degrade() returned `detail: error.message` beside the curated message.
On the unexpected-status branch that is a raw backend body or an
internal URL, handed unfiltered to a model. Drop the field on every
branch; the curated per-status sentence is the whole answer.

dolho's [I3] from the #2596 review.

* fix(mcp): get_agent_assignments enforces agent self-scope in the tool (trinity-enterprise#500 [I2])

The tool description promises "an agent may only read its own roster",
but only the backend route -- in the private module -- enforced it. An
agent key naming another agent, or carrying no agent name, is now
refused with not_authorized before any backend call and audited as a
denial via accessDenied. Deliberately redundant with the backend, like
a2a_call.ts checkSelf. user and system keys still pass to the backend.

The access.ts row moves from baselined to in-tool. The I3 doc note for
the degraded shape lands here too, in the same flow section.

dolho's [I2] from the #2596 review.

* fix(assignments): a non-bool consent is unresolved, never coerced (trinity-enterprise#500 [R1])

assignment_provider._validated coerced proactive_consent with bool(value),
and bool("false") is True -- so a provider answering the string "false"
(or "0", "no") rendered "proactive contact permitted". The same
permission-fails-open class as [I1], one layer earlier.

Only a real bool is kept now. Anything else is dropped with a WARNING
like any malformed field, so consent is unresolved and the renderer's
[I1] path states the restrictive clause.

test_proactive_consent_is_coerced_to_bool pinned the coercion and is
replaced. New tests were red against bool() (8 failed) and green after;
the end-to-end one drives the real compose_system_prompt path with a
provider answering "false".

Found in the PR3 pre-push review.

* docs(user-docs): count get_agent_assignments in the MCP tool totals (142 -> 143, 137 -> 138 operator)

* chore(enterprise): bump the private module to trinity-enterprise#669 (Abilityai/trinity-enterprise#500)

Points src/backend/enterprise at be1160f3a, the squash-merge of the
assignments record and prompt (#669) on trinity-enterprise main. Adds
migration 0018_agent_assignments; one enterprise Alembic head.
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