Repository navigation
fix(systems): create-mode deploy writes the platform prompt for an admin only (#4025) - #4247
Conversation
) `POST /api/systems/deploy` admits `require_role("creator")` plus `capability_fence("agents.manage")`, and wrote a manifest's `prompt:` into the platform-wide `trinity_prompt` for anyone it admitted. A creator, or an agent key holding `agents.manage` (it carries its owner's role, so an admin-owned one passes the role gate too), could replace the instructions every agent receives at its next start. The settings route reserves that key for `assert_admin`. Deploy now writes the prompt only for a caller who passes `assert_admin`, the same predicate apply already used; both modes share one helper. Anyone else still gets the fleet, `prompt_updated: false`, and a `prompt_requires_admin:` line in `warnings[]` (the response contract is pinned, as #4130 did for `deploy: false`). A non-admin dry run says the same, so the preview predicts the write and does not ask the caller to acknowledge a prompt change that will not happen. The create-mode golden is regenerated by its docstring procedure. Only the creator case changes: `prompt_updated` flips to false, one warning is added, and the `trinity_prompt` row is no longer written. Fixes #4025
…the predicate per scope (#4025) - A non-admin whose manifest prompt already equals the stored one gets no `prompt_requires_admin` warning, in the preview or the deploy: nothing is withheld, which apply reports as `unchanged`. - `_caller_may_set_platform_prompt` is renamed `_caller_passes_admin_gate`, the name of what it is, which also matches apply's `caller_is_admin`. - A table test pins the predicate to `assert_admin` across every MCP scope and both roles. Connector and portal-delegate keys stop at the deploy route's fence, so the route-level parity test never reached the predicate for them. - Docs: the `sets_prompt` comment, the flow's parity wording and the user doc's "the result says so" (only once agents are created) now say what the code does.
- Say why the matching-prompt check may tell a non-admin whether a guess matches: apply's verdict already does, and their agents receive it. - The guide lists the prompt write after agent creation, where the code has done it since trinity-enterprise#125. - The golden's regenerated_by entry describes the change, like its siblings.
…ty principals (#4025) The feature flow said three. The fence refuses the connector key and the portal-delegate key (403 agent_management_not_permitted); the creator, the admin JWT, the admin's user and system keys and the agent key holding agents.manage all reach deploy.
Structural and security review, head 3676bc2Both reviews ran against the diff from the merge-base with What the structural review checked
What the security review checked
No security finding. Findings
|
#4025) Deploy now gates the prompt the same way apply does, so the requirement's third stated difference is false. Mechanical, per the merge-train note on the PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
merge-train (2026-11-04): pushed one commit to this branch,
Validated READY at
|
Problem
POST /api/systems/deployadmitsrequire_role("creator")+capability_fence("agents.manage"). If at least one agent was created, it wrote a manifest'sprompt:into the platform-widetrinity_promptfor anyone those two gates let through. So a creator, or an agent key holdingagents.manage, could replace the instructions every agent on the instance receives at its next start. That includes an agent key whose owner is an admin, because the key carries its owner's role and so passes the role gate. The settings route reserves the same key forassert_admin.Change
assert_admin, the settings route's own gate. That covers an admin JWT and an admin'suserorsystemkey. A creator, any agent key, a connector key and a portal-delegate key are refused._caller_passes_admin_gate, so they can't drift apart.prompt_updated: falseand aprompt_requires_admin:line inwarnings[]. That is the same code apply'srequires_adminverdict uses.SystemDeployResponseis unchanged: its contract is pinned by the create-mode golden, so the skip is reported in the warnings, as Apply and deploy results misstate what happened in five edge cases #4130 did fordeploy: false.prompt_updated: falsewith the same warning, so the preview predicts the write. Since the UI's consent gate readsprompt_updated, a non-admin is no longer asked to acknowledge a prompt change that will not happen. Enabled schedules still trigger the acknowledgement. No.vuechange.unchanged).Golden
Regenerated by the procedure in its docstring (
TRINITY_ENT695_REGENERATE_GOLDEN=abilityai/trinity#4025, serial). The fixture diff touches onlydeployed_by_creator_over_foreign_name:prompt_updatedgoes true → false, oneprompt_requires_admin:warning is added, and thesystem_settingstrinity_promptrow is no longer written._meta.regenerated_byrecords the issue. Every other case is byte-identical, including the OpenAPI fragment.Tests
tests/unit/test_4025_deploy_prompt_admin_only.pydrives the real systems and settings routers with their real gates. Only the principal and the two Docker-bound create/start functions are stubbed.trinity_promptis pre-seeded to a value no default could produce.agents.manageget200 deployedwhile the stored prompt stays unchanged. Before the fix, both overwrote it; that is the agent-key path the issue had not executed yet.PUT /api/settings/trinity_promptwould accept the same caller. Connector and portal-delegate keys stop at the fence there, so a table test also pins the predicate itself toassert_adminacross every MCP scope and both roles.deployed_by_creator_over_foreign_name: a creator deploying with no stored prompt row; always deny turns 6 route-level red, 9 in the file.src/frontend/tests/unit/manifestPreviewPromptRequiresAdmin.mount.spec.js: with the non-admin preview payload, the note renders, the prompt clause of the consent gate is absent, and a schedule still raises the gate.trinity_prompt: 2245 passed. The new file and the golden pass under random-order seeds 1–3.Validation: the new test file fails on unfixed
dev(creator and agent-key cases write the prompt) and passes after; golden 14/14 after regeneration; 2245 passed across the 50 related unit files; frontend spec 3/3; the one-line MCP tool-description change passes CI's MCP typecheck (Build (typecheck) + unit).Mutation: helper forced to allow → 20 red in the file (7 route-level + 13 in the scope table), plus the golden's
deployed_by_creator_over_foreign_name(a creator deploying with no stored prompt row); forced to deny → 6 route-level red, 9 in the file;role == "admin" and not agent_name→ 4 red (the scope table); the matching-prompt check dropped → 2 red; the component's prompt clause forced on → the schedule case of the mount spec red.Unverified: no live-stack deploy with real agent containers (create/start are stubbed, as in the golden).
Journey Impact: none: an authorization fix on the deploy route; an admin's deploy and every user journey through it are unchanged
Fixes #4025