fix: Correct OpenAPI access metadata for board-only agent session routes (#21024)

> [!NOTE]
> Opened by Prospector's automated issue-fix pipeline. A maintainer
reviews and decides; nothing here merges on its own.

## Thinking Path

- Issue #20942 reports a defect in paperclipai/paperclip.
- Root cause, as the fixing agent read it: The three session operations
were missing from BOARD_ONLY_OPERATIONS, so OpenAPI defaulted to
board_or_agent access and included AgentBearerAuth despite the handlers
requiring board access.
- This pull request: Correct OpenAPI access metadata for board-only
agent session routes

## What Changed

- `server/src/routes/openapi.ts`: Classify all three operations as
board-only while preserving existing handler permissions.
- `server/src/__tests__/openapi-routes.test.ts`: Add regression cases
for board security, authorization metadata, and forbidden responses on
each route. All three failed before the fix; all 48 OpenAPI tests and
the typecheck pass afterward.

## Verification

- Reproducing test(s), added in this PR:
`server/src/__tests__/openapi-routes.test.ts`
- They fail on the base commit and pass with the fix, each twice in a
fresh sandbox.
- 3 independent attempts wrote 3 reproductions; this fix passes every
one of them.
- The repository's compile command passes with the fix applied.
- 9 existing test file(s) near the change passed.
- The full test suite passes except for the 17 file(s) that already fail
on the base commit.

## Risks

- Written by an automated pipeline, not a person: review it as you would
an outside contribution.
- Risk tier of the touched paths: 2.
- The scope reviewer found it also changes, beyond the report:
search_api pagination using a cursor generated from the previous
catalog, for any query

## Model Used

- codex:gpt-6.1-sol, opus, sonnet (Anthropic Claude, via Claude Code;
OpenAI, via the Codex CLI), writing and checking the change in an
isolated sandbox.
- opus (Anthropic Claude, via Claude Code), reviewing it independently.

## Linked Issues

Fixes #20942

A search of paperclipai/paperclip's open and closed pull requests found
no other pull request that names #20942.

## 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)
- [ ] 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)
- [ ] 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
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

<!-- prospector:issue-fix v1 issue=20942 base=156212cfd58a
report=0d14759e2b96f394 -->

Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>
This commit is contained in:
commitperclip[bot] authored and GitHub committed 2026-11-23 19:37:58 -06:00
1 parent 362e3bb4e3
commit 451c09bfbe
2 files changed
+15

No files matched your search

@@ -502,6 +502,18 @@ describe("openapi routes", () => {
for (const code of ["200", "400", "401", "403", "404"]) expect(operation.responses[code]).toBeDefined();
});
it.each([
["get", "/api/agents/{id}/runtime-state"],
["post", "/api/agents/{id}/runtime-state/reset-session"],
["get", "/api/agents/{id}/task-sessions"],
])("documents %s %s as board-only", (method, path) => {
const spec = buildOpenApiSpec() as any;
const operation = spec.paths[path][method];
expect(operation.security).toEqual([{ BoardSessionAuth: [] }, { BoardApiKeyAuth: [] }]);
expect(operation["x-paperclip-authorization"]).toEqual({ actor: "board" });
expect(operation.responses["403"]).toBeDefined();
});
it("documents task-tree controls as board-only and names the human page", () => {
const spec = buildOpenApiSpec() as any;
const boardSecurity = [{ BoardSessionAuth: [] }, { BoardApiKeyAuth: [] }];
+3
View File
@@ -1489,6 +1489,9 @@ const BOARD_ONLY_OPERATIONS = new Set([
"POST /api/companies/{companyId}/chats/{agentRef}/onboarding",
"POST /api/companies/{companyId}/chats/{agentRef}/onboarding/greeting",
"PATCH /api/agents/{id}/permission-grants",
"GET /api/agents/{id}/runtime-state",
"POST /api/agents/{id}/runtime-state/reset-session",
"GET /api/agents/{id}/task-sessions",
// Budget changes are board-only (assertBoard in routes/costs.ts).
"POST /api/companies/{companyId}/budgets/policies",
"POST /api/companies/{companyId}/budget-incidents/{incidentId}/resolve",