mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 11:59:26 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - #21473 added machine sign-in (MCP OAuth client credentials) for organization connections > - Auto-merge squashed #21473 from an earlier head, so its last review fixes did not reach master > - Those fixes close a P1 race and two smaller setup gaps that Greptile found on #21473 > - This pull request applies that last commit to current master, with its tests > - The benefit is that a client ID and its secret always stay together, and key switching and app selection work as intended ## Linked Issues or Issue Description Refs #21473 **What existing behavior does this improve?** Machine sign-in setup and rotation, added in #21473. **Problem** - A connection test wrote a replacement client secret before checking whether the connection changed. If the save was then refused, the secret stayed and could pair with another client ID, so the next token request failed. - Switching a client-secret connection to a Paperclip key always created an RS256 key, even when the sign-in service accepts only ES256. - Machine sign-in dropped the setup's app ID and created a separate app. **Proposed improvement** Write the secret and the settings in one locked transaction after the change check. Record the accepted signing algorithms and use them. Pass the app ID through. ## What Changed - `client-credentials-service.ts`: `saveConnection` locks the row, checks that the sign-in method and credential references are unchanged and that the connection is not removed, then writes any new credential and the settings in the same transaction. Test, secret rotation and key staging all use it. - Setup records `tokenEndpointAuthSigningAlgValuesSupported`. Switching from a secret to a key uses `chooseAssertionAlgorithm` on it. - UI: `MachineSignInSetup` takes `applicationId`, and the custom-server flow passes `prefill.applicationId`. - Tests: two new server tests and one UI expectation. ## Verification - `server/src/__tests__/tool-access-client-credentials.test.ts`: 25/25 pass. The 2 new tests fail on master's service code ("never leaves a refused test's secret behind with another client ID", "creates the kind of key the sign-in service accepts when switching from a secret"). - `MachineSignInSetup.test.tsx` and `GenericMcpConnectStep.machine.test.tsx`: 8/8. The app ID expectation fails on master's component. - Server `tsc --noEmit` clean. UI `tsc` clean except the pre-existing generated Storybook catalog imports. ## Risks Low. The change is limited to machine sign-in. A concurrent change now returns 409 `client_credentials_changed` instead of saving partly. No migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (shell, file edits, test runs). ## 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 - [ ] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>