mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-10 02:34:22 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Its server and UI test suites protect company-scoped plugin access and instance settings behavior > - Recent governed-access contracts intentionally added company invocation scope and new experimental-setting defaults > - Four existing tests were not updated consistently with those contracts, causing current-master CI failures unrelated to the changes under review > - The runtime behavior is intentional, so changing production code would weaken the new authorization and settings contracts > - This pull request aligns the stale tests with current behavior and removes one UI assertion accidentally pulled forward from a later stacked feature > - The benefit is a focused, low-risk repair that restores master CI without changing application behavior ## Linked Issues or Issue Description - **Bug:** Current master has four regression failures in plugin authorization, plugin execution-workspace bridging, instance settings normalization, and experimental settings UI tests. - **Expected behavior:** Tests provide required company/invocation scope, use the governed object-shaped secret reference contract, include all current defaults, and only assert UI controls implemented at this stack level. - **Actual behavior:** Tests exercised obsolete request shapes or expected a later-stack Apps toggle that is not present on current master. - **Reproduction:** Run the four test files listed in the Verification section on master before this commit. ## What Changed - Updates plugin config authorization coverage to include company scope and an object-shaped `secret_ref` binding. - Supplies invocation company scope to execution-workspace host-client tests. - Adds `enableApps` and `enableSmokeLab` to normalized settings expectations. - Removes the premature Apps toggle UI test introduced without its later-stack implementation. ## Verification - `pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts server/src/__tests__/plugin-execution-workspace-bridge.test.ts server/src/__tests__/instance-settings-service.test.ts ui/src/pages/InstanceExperimentalSettings.test.tsx` — 73 tests passed. - `pnpm exec vitest run packages/plugins/sdk/tests/host-client-factory.test.ts server/src/__tests__/plugin-secrets-handler.test.ts server/src/__tests__/instance-settings-routes.test.ts ui/src/lib/instance-settings.test.ts` — 39 tests passed. - `git diff --check` — passed. ## Risks - Low risk: test-only changes with no production runtime, schema, API, or UI behavior changes. - The removed Apps toggle assertion should return in the later stacked change that introduces the actual control. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex, exact model ID `gpt-5.4`; runtime-managed context window; medium reasoning with repository, shell, GitHub CLI, and code-execution tools enabled. ## 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 merge
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { createHostClientHandlers } from "../../../packages/plugins/sdk/src/host-client-factory.js";
|
|
import { PLUGIN_RPC_ERROR_CODES } from "../../../packages/plugins/sdk/src/protocol.js";
|
|
|
|
describe("plugin execution workspace bridge", () => {
|
|
it("routes metadata reads through the host client when the capability is declared", async () => {
|
|
const get = vi.fn().mockResolvedValue({
|
|
id: "workspace-1",
|
|
companyId: "company-1",
|
|
projectId: "project-1",
|
|
projectWorkspaceId: null,
|
|
path: "/tmp/workspace-1",
|
|
cwd: "/tmp/workspace-1",
|
|
repoUrl: null,
|
|
baseRef: "main",
|
|
branchName: "feature/workspace-1",
|
|
providerType: "git_worktree",
|
|
providerMetadata: null,
|
|
});
|
|
const handlers = createHostClientHandlers({
|
|
pluginId: "workspace-plugin",
|
|
capabilities: ["execution.workspaces.read"],
|
|
services: {
|
|
executionWorkspaces: { get },
|
|
} as any,
|
|
});
|
|
|
|
await expect(
|
|
handlers["executionWorkspaces.get"](
|
|
{ workspaceId: "workspace-1", companyId: "company-1" },
|
|
{ invocationScope: { companyId: "company-1" } },
|
|
),
|
|
).resolves.toMatchObject({
|
|
id: "workspace-1",
|
|
cwd: "/tmp/workspace-1",
|
|
});
|
|
expect(get).toHaveBeenCalledWith({ workspaceId: "workspace-1", companyId: "company-1" });
|
|
});
|
|
|
|
it("rejects metadata reads when the plugin lacks execution.workspace read access", async () => {
|
|
const get = vi.fn();
|
|
const handlers = createHostClientHandlers({
|
|
pluginId: "workspace-plugin",
|
|
capabilities: [],
|
|
services: {
|
|
executionWorkspaces: { get },
|
|
} as any,
|
|
});
|
|
|
|
await expect(
|
|
handlers["executionWorkspaces.get"](
|
|
{ workspaceId: "workspace-1", companyId: "company-1" },
|
|
{ invocationScope: { companyId: "company-1" } },
|
|
),
|
|
).rejects.toMatchObject({
|
|
code: PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED,
|
|
});
|
|
expect(get).not.toHaveBeenCalled();
|
|
});
|
|
});
|