mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-27 20:09:10 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Human company members receive permission grants from their role preset. > - Human invitations use the Operator role by default. > - The old Operator preset only granted task assignment, so ordinary members could not edit agents or manage connections. > - This pull request gives Operators company editing and audit access while keeping join approval and member-permission management separate. > - Members can configure their agents and accounts without an Owner role. ## Linked Issues or Issue Description **What existing behavior does this improve?** The default permission grants for human Operators and the invitation role description. **Subsystem affected** server/ permission presets and invitation authorization, plus ui/ invitation and tool access gates. **Current behavior** Operators receive only `tasks:assign` as an explicit default grant. Agent configuration and managed account setup fail their permission checks. **Proposed behavior** Operators receive agent creation/configuration, skills, environments, invitations, task assignment, pipelines, connections, tool management/use, and audit grants. The preset excludes `joins:approve` and `users:manage_permissions`. Operators can invite Operators and Viewers. Inviting a role with either excluded power requires that power, so invitations cannot bypass the restriction. **Reason and benefit** Ordinary company members can edit company work and connect accounts through the existing routes. **Breaking changes** The Operator preset grants more permissions. The existing startup and Cloud sign-in seeding paths can insert these missing grants for existing Operators. They retain custom grant scopes. Explicit invitation grants still take precedence. Inviting Admins now requires join approval; inviting Owners also requires member-permission management. This PR adds no migration or new backfill path. Related: #5945 describes missing role grants in another membership entry point. This PR changes the preset and does not change that endpoint. ## What Changed - Expanded the Operator preset to 14 company editing, invitation, tool, and audit grants. - Kept join approval and member-permission management out of the preset. - Required those powers when an invitation's selected human role includes them, preventing Operators from delegating the excluded powers through Owner/Admin invitations. - Updated the invitation role copy and the product specifications. - Allowed active Operators (including legacy Member roles) through the invite shortcut and advanced tool/profile UI gates. Kept inactive memberships, Viewers, and other companies excluded; API grants remain authoritative. - Added tests for the default Operator grants, both excluded actions, agent editing, company boundaries, and invitation role authorization. - Simplified adapter-route test imports so authorization errors and the error handler use one module graph; retained the upstream mock-initialization fix. - Kept Owner/Admin/Viewer presets and explicit invitation grants unchanged. Added no EE code or database migration. ## Verification - Permission and invitation tests: 38 passed across access service, invitation defaults, and invitation creation routes. - UI access tests: 61 passed across invitation shortcuts, Operator tool/profile access, and invitation UI. - Adapter route tests: 15 passed after resolving the upstream test setup conflict. - `pnpm -r typecheck`, `pnpm build`, and `pnpm check:token-gates`: passed on the final branch. - The initial local `pnpm test:run` general-server batch reported three tool-access failures and eight upload-helper timeouts. Both complete affected suites passed in isolation on the final branch: 403 tests. The initial full local run was not green. - Both complete tool-access and adapter route suites also passed on an untouched snapshot of base `88ff98b83`: 387 tests. The earlier tool failures did not reproduce there. - [All CI gates passed](https://github.com/paperclipai/paperclip/actions/runs/37527422346) for `068be153b9c2a064f2aaccc0627fdf458e73747e`, including the previously failing serialized adapter lane, general tests, E2E, typecheck, build, Runner checks, and canary dry run. - Greptile scored that exact commit 5/5. Superagent passed. Both invitation review threads are resolved. ## Risks - Operators gain broad company editing and invitation access by design. - Existing default seeding can add the new missing grants during startup or Cloud sign-in. It does not replace existing scopes. - Company boundaries and the two excluded permission checks still apply. - An Admin without member-permission management can no longer invite an Owner. Operators retain invitation access for Operator/Viewer roles and agent-only invites. - This PR changes company permissions. Cloud workspace invitation rules remain separate. ## Model Used OpenAI Codex, GPT-6. The exact deployment model ID and context window were not exposed in this session. Used repository inspection, code editing, shell execution, and test tools. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting a merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
162 lines
5.8 KiB
TypeScript
162 lines
5.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
agentJoinGrantsFromDefaults,
|
|
humanJoinGrantsFromDefaults,
|
|
} from "../services/invite-grants.js";
|
|
import {
|
|
grantsForHumanRole,
|
|
normalizeHumanRole,
|
|
resolveHumanInviteRole,
|
|
} from "../services/company-member-roles.js";
|
|
import { NEW_STANDARD_AGENT_DEFAULT_GRANT_KEYS, newStandardAgentGrantScope } from "../services/agent-permissions.js";
|
|
|
|
const invitedAgentId = "agent-1";
|
|
const defaultAgentGrants = NEW_STANDARD_AGENT_DEFAULT_GRANT_KEYS.map((permissionKey) => ({
|
|
permissionKey,
|
|
scope: newStandardAgentGrantScope(permissionKey, invitedAgentId),
|
|
}));
|
|
|
|
describe("agentJoinGrantsFromDefaults", () => {
|
|
it("adds all new-agent grants when invite defaults do not specify grants", () => {
|
|
expect(agentJoinGrantsFromDefaults(null, invitedAgentId)).toEqual(defaultAgentGrants);
|
|
});
|
|
|
|
it("preserves invite agent grants and appends the missing defaults", () => {
|
|
expect(
|
|
agentJoinGrantsFromDefaults({
|
|
agent: {
|
|
grants: [
|
|
{
|
|
permissionKey: "agents:create",
|
|
scope: null,
|
|
},
|
|
],
|
|
},
|
|
}, invitedAgentId),
|
|
).toEqual([{ permissionKey: "agents:create", scope: null }, ...defaultAgentGrants]);
|
|
});
|
|
|
|
it("does not duplicate tasks:assign when invite defaults already include it", () => {
|
|
expect(
|
|
agentJoinGrantsFromDefaults({
|
|
agent: {
|
|
grants: [
|
|
{
|
|
permissionKey: "tasks:assign",
|
|
scope: { projectId: "project-1" },
|
|
},
|
|
],
|
|
},
|
|
}, invitedAgentId),
|
|
).toEqual([
|
|
{ permissionKey: "tasks:assign", scope: { projectId: "project-1" } },
|
|
...defaultAgentGrants.filter((grant) => grant.permissionKey !== "tasks:assign"),
|
|
]);
|
|
});
|
|
|
|
it("preserves an explicit scoped agent configuration grant", () => {
|
|
expect(agentJoinGrantsFromDefaults({
|
|
agent: { grants: [{ permissionKey: "agents:configure", scope: { agentIds: ["agent-1"] } }] },
|
|
}, invitedAgentId)).toEqual([
|
|
{ permissionKey: "agents:configure", scope: { agentIds: ["agent-1"] } },
|
|
...defaultAgentGrants.filter((grant) => grant.permissionKey !== "agents:configure"),
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("human invite roles", () => {
|
|
it("maps owner to the full management grant set", () => {
|
|
expect(grantsForHumanRole("owner")).toEqual([
|
|
{ permissionKey: "agents:create", scope: null },
|
|
{ permissionKey: "agents:configure", scope: null },
|
|
{ permissionKey: "skills:create", scope: null },
|
|
{ permissionKey: "environments:manage", scope: null },
|
|
{ permissionKey: "users:invite", scope: null },
|
|
{ permissionKey: "users:manage_permissions", scope: null },
|
|
{ permissionKey: "tasks:assign", scope: null },
|
|
{ permissionKey: "joins:approve", scope: null },
|
|
{ permissionKey: "tools:manage_connections", scope: null },
|
|
{ permissionKey: "tools:manage_runtime", scope: null },
|
|
{ permissionKey: "tools:use", scope: null },
|
|
{ permissionKey: "tools:admin", scope: null },
|
|
]);
|
|
});
|
|
|
|
it("maps admin to management grants including environment management", () => {
|
|
expect(grantsForHumanRole("admin")).toEqual([
|
|
{ permissionKey: "agents:create", scope: null },
|
|
{ permissionKey: "agents:configure", scope: null },
|
|
{ permissionKey: "skills:create", scope: null },
|
|
{ permissionKey: "environments:manage", scope: null },
|
|
{ permissionKey: "users:invite", scope: null },
|
|
{ permissionKey: "tasks:assign", scope: null },
|
|
{ permissionKey: "joins:approve", scope: null },
|
|
{ permissionKey: "tools:manage_connections", scope: null },
|
|
{ permissionKey: "tools:manage_runtime", scope: null },
|
|
{ permissionKey: "tools:use", scope: null },
|
|
{ permissionKey: "tools:admin", scope: null },
|
|
]);
|
|
});
|
|
|
|
it("maps operator to company editing grants without join approval or member permissions", () => {
|
|
expect(grantsForHumanRole("operator")).toEqual([
|
|
{ permissionKey: "agents:create", scope: null },
|
|
{ permissionKey: "agents:configure", scope: null },
|
|
{ permissionKey: "skills:create", scope: null },
|
|
{ permissionKey: "environments:manage", scope: null },
|
|
{ permissionKey: "users:invite", scope: null },
|
|
{ permissionKey: "tasks:assign", scope: null },
|
|
{ permissionKey: "pipelines:write", scope: null },
|
|
{ permissionKey: "tools:manage_connections", scope: null },
|
|
{ permissionKey: "tools:manage_profiles", scope: null },
|
|
{ permissionKey: "tools:manage_runtime", scope: null },
|
|
{ permissionKey: "tools:use", scope: null },
|
|
{ permissionKey: "tools:admin", scope: null },
|
|
{ permissionKey: "tools:view_audit", scope: null },
|
|
{ permissionKey: "audit:view_agent_actions", scope: null },
|
|
]);
|
|
});
|
|
|
|
it("defaults legacy or missing roles to operator", () => {
|
|
expect(normalizeHumanRole("member")).toBe("operator");
|
|
expect(resolveHumanInviteRole(null)).toBe("operator");
|
|
});
|
|
|
|
it("reads the configured human invite role from defaults", () => {
|
|
expect(
|
|
resolveHumanInviteRole({
|
|
human: {
|
|
role: "viewer",
|
|
},
|
|
}),
|
|
).toBe("viewer");
|
|
});
|
|
|
|
it("falls back to role grants when human invite defaults omit explicit grants", () => {
|
|
expect(humanJoinGrantsFromDefaults(null, "operator")).toEqual(grantsForHumanRole("operator"));
|
|
});
|
|
|
|
it("preserves explicit human invite grants", () => {
|
|
expect(
|
|
humanJoinGrantsFromDefaults(
|
|
{
|
|
human: {
|
|
grants: [
|
|
{
|
|
permissionKey: "users:invite",
|
|
scope: { companyId: "company-1" },
|
|
},
|
|
],
|
|
},
|
|
},
|
|
"operator",
|
|
),
|
|
).toEqual([
|
|
{
|
|
permissionKey: "users:invite",
|
|
scope: { companyId: "company-1" },
|
|
},
|
|
]);
|
|
});
|
|
});
|