mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
aa85bcb5185fca52ce82a0edeff10d8a97e7eb95
2733
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
aa85bcb518 |
feat(plugins): carry a Google sign-in to plugin Runners for Google Antigravity (#22933)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugin environments (for example, an agent computer) run agents as plugin Runner tasks. Core sends each task one typed credential, and gets refreshed sign-ins back through the task's `credentials` snapshot. > - #22930 let a Google Antigravity task carry a Gemini API key. A Google subscription sign-in was still refused with "Google sign-in is not supported." > - The Cloud rollout plan (#22923) needs both routes. This is gaps G3 and G4 and work item 2: deliver the sign-in, and save a rotated refresh token safely, as Codex does. > - This pull request sends the saved, sanitized sign-in as the `antigravity` `provider-env` credential under `PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`. It saves a refreshed token from the snapshot only after the generation, epoch and Google account checks. > - The benefit is that a plugin (for example, the Cloud agent computer) can run an Antigravity task with a person's Google sign-in, and token refreshes are not lost or saved to the wrong account. The picker, Test and save refusals for plugin targets (item 6) and the qualification flip (item 8) stay out of scope. ## Linked Issues or Issue Description Refs #22923 Refs #22930 **What problem does this solve?** A plugin Runner task cannot use a Google sign-in for Google Antigravity. Core refuses it at run start. There is also no path to save a refresh token that the Runner rotated on the plugin's computer. **Proposed solution** Add the sign-in variable as a second `antigravity` key set in `provider-env`. Core reads the sign-in from the run's private managed home, runs it through `sanitizeAntigravityCredential`, and sends that exact output. Core saves the write-back binding (grant, secret, session epoch, and a SHA-256 of the starting sign-in) on the lease. When the task stops, Core reads the snapshot and saves a new token only if all checks pass. **Alternatives considered** A new credential type for the sign-in. `provider-env` already has the exact-set check, the credential binding contract and the cross-check against the Runner's allowlists. The Cloud plan already describes the Launcher row as "`GEMINI_API_KEY` or the sign-in key". ## What Changed - `packages/plugins/sdk/src/environment-tasks.ts`: the `antigravity` key sets are now `GEMINI_API_KEY` or `PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`. A mix of both stays rejected. - `server/src/services/native-runtime/plugin-runner-credentials.ts`: with no Gemini API key, Core reads `antigravity-acp/acp_token.json` from the selected managed home and sends the sanitizer's complete output (client ID, client secret, refresh token, token URI, `scopes`, and `project_id` when present). It never sends an access token or the account email. The task needs write-back authority. A sign-in supplied through the environment is refused. An unreadable or invalid saved sign-in fails with "The selected Google Antigravity account is unavailable. Reconnect the Google account, then retry." No error contains credential text. - `server/src/services/ai-connection-runtime.ts`: a Google subscription run now returns a write-back binding with `google.credentialSha256` of the starting sign-in. - `server/src/services/managed-ai-credential-writeback.ts`: new `syncManagedAntigravityCredential`. It requires an active grant, the same secret reference and session epoch, a Google subscription connection, and a saved sign-in that still hashes to the starting generation. It verifies a changed token with the existing account check (`prepareAntigravityCredentialWriteback`) in a private temporary home, then rechecks all of the above under the account lock before it rotates the secret. It writes `ai_connection.credential_refreshed` on save. For a different account, or a connection with no saved account, it saves nothing, writes `ai_connection.credential_refresh_refused` with a plain reason, and settles as `account_refused`. - `server/src/services/plugin-task-credential-writeback.ts`: a handoff with a Google binding takes the snapshot's `provider-env` `antigravity` sign-in and uses the Google write-back. Codex is unchanged. - `server/src/services/native-runtime/native-session-executor.ts`: a sign-in credential needs a Google write-back binding, and a Codex credential needs a non-Google one. - `server/src/services/native-runtime/antigravity-runner-credentials.ts`: the account mismatch is a typed error. The message is unchanged. - Docs: `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and `doc/plugins/PLUGIN_RUNNER_EXECUTION.md` describe the sign-in credential, where the Runner stages it, and the snapshot that the plugin must return. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the changed SDK source. ## Verification - Red first: with the source changes removed, 22 of the new and updated tests failed (the refusal, no write-back binding, no Google write-back). - Green after the change: - `cd server && npx vitest run src/__tests__/antigravity-plugin-task-credential-writeback.test.ts` (11 passed, embedded PostgreSQL): delivery of the exact sanitized sign-in; same-account rotation saved and logged; a second rotation during the account check saved; a different account refused and recorded in plain words; unchanged token with no Google call; reconnect (new generation and epoch) and a revoked grant discard the write-back without an export; a Google outage keeps the handoff pending and the next cleanup saves it; Codex, API-key and invalid snapshots refused. No token, client secret or access token in lease metadata, activity rows or errors. - `cd server && npx vitest run src/services/native-runtime/plugin-runner-credentials.test.ts src/__tests__/plugin-runner-credential-names.test.ts` (39 passed). The names test checks that the Runner forwards the sign-in variable to the sidecar and keeps it out of the provider process. - `cd packages/plugins/sdk && npx vitest run tests/environment-task-release-resume.test.ts tests/environment-tasks.test.ts` (104 passed) - `cd server && pnpm typecheck` (clean) - `pnpm verify` (see the CI run for broad coverage) - No live run, no Google login and no real token was used. All Google calls are fixtures. ## Risks - Low for current users. Plugin targets still refuse Antigravity in the picker, Test and save (item 6), so no existing agent reaches this path until item 6 merges. - The lease now stores a SHA-256 of the starting sign-in. It is a one-way digest of a high-entropy token, and it is the same kind of generation value that Core already derives for the local route. - If Google rotates the token during the account check and the database save then fails, the cleanup retries from the plugin's snapshot. Google does not normally rotate these refresh tokens, so this matches the local route's exposure without its recovery journal. - The Launcher must return the Runner's `auth-refresh.json` (or `acp_token.json` before lease close) in the snapshot. A Launcher that returns the starting sign-in only records `unchanged`, so no token is lost on the Core side, but a rotation on the computer would not be saved. > 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 - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edits, test runs). Standard context window, extended reasoning. ## 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 - [x] 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> |
||
|
|
57bd302c81 |
feat(antigravity): add hosted Google loopback-relay sign-in (#22932)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Google Antigravity supports Google account sign-in through Paperclip Runner's pinned, isolated `agy_acp_server.par` process. > - On `authenticated + public` deployments (including hosted Cloud instances), `supportsLocalAiLogin` returns `false`, and the user's browser cannot directly reach the server's `127.0.0.1:<ephemeral_port>` loopback callback listener. > - Because `client_secret` lives only inside `agy_acp_server.par` and uses PKCE with a one-shot `127.0.0.1` listener, hosted deployments need an authenticated relay path instead of an anonymous callback route or extracted secret. > - This pull request adds an authenticated loopback-relay flow across Runner, server policy/routes/redaction, and the UI so users on hosted deployments can sign in with Google, copy the `127.0.0.1` redirect URL from their address bar, and paste it to complete authentication. > - The benefit is that Google Antigravity subscription sign-in works on hosted public deployments while keeping Claude, OpenAI, and Grok server-host login disabled and preventing SSRF, secret leakage, or cross-tenant access. ## Linked Issues or Issue Description Refs #22923 **Subsystem affected** Cross-cutting (packages/paperclip-runner, packages/shared, server/, ui/) **Problem or motivation** Google Antigravity sign-in launches Paperclip's pinned, isolated `agy_acp_server.par` closure, which opens a one-shot `127.0.0.1:<ephemeral_port>` OAuth callback listener. On hosted `authenticated + public` deployments, server-host login routes are blocked and the user's browser cannot connect to the server's loopback interface, so users cannot sign in with a Google account on Cloud or remote instances. **Proposed solution** Add an authenticated loopback-relay flow: 1. Runner exposes a single-use `submitRedirect(rawRedirectUrl)` handler on `AntigravityBrowserLoginState` that validates the pasted URL (length, printable ASCII, `http://127.0.0.1:<expectedPort>/`, no credentials/hash, no duplicate `state`/`code`, no `error` param, `timingSafeEqual` state check, bounded 5-attempt bad-paste cap, SHA-256 reused-code tracking) and issues an SSRF-proof reconstructed `GET` to `expectedRedirect.origin` with `redirect: "manual"`. 2. Server adds `supportsHostedGoogleAiLogin` (exposed on `/api/health` as `hostedGoogleAiLoginSupported`), permits Google through the authenticated `/api/companies/:companyId/ai-connections/local/*` routes while keeping `anthropic`/`openai`/`xai` blocked on public deployments, accepts up to 4096-character redirect URLs on `/code` while preserving Claude's 512-byte limit, runs the loopback relay outside DB transactions, falls back cleanly when a stack has no active `local` environment row, and redacts `browserCode`/`redirectUrl` and marks `/code` secret-sensitive. 3. UI enables Google sign-in for `antigravity_runtime` on non-local environments when `hostedGoogleAiLoginSupported` is true, renders the external Google sign-in link plus plain-language `127.0.0.1` copy/paste instructions with analytics masking/no-capture markers, and triggers an immediate status check after submission. **Alternatives considered** - Adding an anonymous public OAuth callback route on the server: rejected because it widens the unauthenticated attack surface and cannot change the loopback `redirect_uri` bound inside `agy_acp_server.par`. - Extracting Google OAuth `client_secret` out of `agy_acp_server.par`: rejected by policy; secrets remain owned solely inside the pinned closure. ## What Changed - `packages/paperclip-runner/src/drivers/acpx/antigravity-auth.ts` & `packages/paperclip-runner/src/index.ts` & `server/src/vendor/paperclip-runner/index.ts`: add single-use `submitRedirect` on `AntigravityBrowserLoginState` with strict validation, `timingSafeEqual` state verification, 5-attempt cap, bounded SHA-256 reused-code set, and SSRF-proof loopback relay. - `packages/shared/src/ai-connections.ts`: add `LOCAL_AI_LOGIN_CODE_MAX_LENGTH` (4096), `localAiLoginCodeSchema`, and `submitLocalAiLoginCodeSchema` while preserving Claude's 512-byte `BROWSER_CODE_MAX_LENGTH` and `browserCodeSchema`. - `server/src/services/local-ai-login-policy.ts` & `server/src/routes/health.ts`: add `supportsHostedGoogleAiLogin` and expose `hostedGoogleAiLoginSupported` on `/api/health`. - `server/src/services/local-ai-browser-login.ts`, `server/src/services/local-ai-login.ts`, `server/src/routes/ai-connections.ts`: permit hosted Google sign-in on authenticated public deployments while keeping Claude/OpenAI/Grok blocked; enforce `Cache-Control: no-store`, owner/company/active/expiry checks, and Claude's 512-byte cap; run Google `submitRedirect` outside any DB transaction; fall back cleanly to an active environment or savepoint-wrapped `ensureLocalEnvironment` when no active `local` environment row exists. - `server/src/middleware/redact-sensitive.ts`, `server/src/middleware/http-log-redaction.ts`, `server/src/middleware/http-log-policy.ts`: redact `browserCode`/`redirectUrl`/`redirect_url` unconditionally and classify `/api/companies/:companyId/ai-connections/local/attempts/:sessionId/code` as secret-sensitive (`local_ai_login_code`). - `ui/src/api/health.ts`, `ui/src/components/ai-connections/useLocalAiLogin.ts`, `ui/src/components/AdapterLoginChrome.tsx`, `ui/src/components/new-agent/AgentProviderConnection.tsx`, `ui/src/components/ai-connections/AiConnectionCredentialStep.tsx`, `ui/src/components/OnboardingWizard.tsx`: enable hosted Google sign-in for `antigravity_runtime` on hosted/non-local environments, render the hosted `127.0.0.1` redirect paste flow with `ANALYTICS_MASK_CLASS` and `ANALYTICS_NO_CAPTURE_CLASS`, preserve retryable paste errors inline, and trigger immediate status re-check on submit. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the updated `packages/shared/src/ai-connections.ts` schema. - Unit, integration, and UI tests across `antigravity-auth.test.ts`, `local-ai-login-policy.test.ts`, `health.test.ts`, `health-dev-server-token.test.ts`, `redact-sensitive.test.ts`, `http-log-policy.test.ts`, `antigravity-local-ai-login.test.ts`, `ai-connections.test.ts`, `AdapterLoginChrome.test.tsx`, `useLocalAiLogin.test.tsx`, and `AgentProviderConnection.test.tsx`. ## Verification - `pnpm --filter @paperclipai/shared build && pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/paperclip-runner typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm --filter @paperclipai/shared exec vitest run src/validators/claude-setup-token-session.test.ts` — 15/15 passed. - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/acpx/antigravity-auth.test.ts src/drivers/acpx/antigravity-auth-stream-order.test.ts` — 33/33 passed (including real `127.0.0.1` loopback HTTP relay with fake ACP peer, bad-paste cap, reused-code rejection, single-use, and non-200 failure). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/local-ai-login-policy.test.ts src/__tests__/health.test.ts src/__tests__/health-dev-server-token.test.ts src/__tests__/redact-sensitive.test.ts src/__tests__/http-log-policy.test.ts src/__tests__/antigravity-local-ai-login.test.ts` — all passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/ai-connections.test.ts` — 167/167 passed against embedded PostgreSQL (including hosted Google end-to-end route test, redaction of activity and HTTP logs, and continued blocking of Anthropic/OpenAI/xAI on hosted public deployments). - `pnpm --filter @paperclipai/ui exec vitest run src/components/AdapterLoginChrome.test.tsx src/components/ai-connections/useLocalAiLogin.test.tsx src/components/new-agent/AgentProviderConnection.test.tsx` — 30/30 passed. - `pnpm verify --explain` returned exit 2 (`tests/runner-e2e/source-sdk-public-inputs.json` broad input); required CI supplies full-repo coverage. - Note: live end-to-end sign-in against real `agy_acp_server.par` and Google OAuth on a live Cloud stack was not run in this unit/integration environment and remains a live-staging verification step. ## Risks - Low-to-moderate risk. All hosted Google sign-in endpoints stay authenticated, company-scoped, owner-bound, and `Cache-Control: no-store`; `localAiLoginSupported` remains `false` on `authenticated + public` deployments so Claude, OpenAI, and Grok server-host login stay blocked. - Loopback relay runs strictly against the validated `127.0.0.1:<ephemeral_port>` origin printed by `agy_acp_server.par` with `redirect: "manual"` and a 5-second timeout, outside any database transaction. - No database migrations are required. ## Model Used - Google Gemini (Antigravity agent with tool use and code execution) ## 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
07d444a717 |
feat(plugins): carry a Gemini API key to plugin Runners for Google Antigravity (#22930)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugin environments (for example, an agent computer) run agents as plugin Runner tasks. Core sends each task one typed credential. > - The typed `provider-env` credential carries API keys for Grok, Copilot and OpenCode. It has no entry for Google Antigravity. > - So an Antigravity agent cannot get its Gemini API key on a plugin Runner task. This is gap G3 and work item 1 in the Antigravity Cloud rollout plan (#22923). > - This pull request adds `antigravity` to `provider-env`, with the single variable set `GEMINI_API_KEY`. It follows the Copilot pattern from #22359. > - The benefit is that a plugin (for example, the Paperclip Cloud agent computer) can now accept a Gemini API key for an Antigravity task. Google sign-in, the plugin-target refusal and the qualification flip stay out of scope. ## Linked Issues or Issue Description Refs #22923 Refs #22359 **What problem does this solve?** A plugin Runner task cannot carry a Gemini API key. `provider-env` accepts only `grok`, `copilot` and `opencode`, and Core throws "Plugin Runner does not support the selected credential provider" for Antigravity. **Proposed solution** Add `antigravity: [["GEMINI_API_KEY"]]` to the published key sets and to the `provider-env` provider enum. Core transfers only that key. Core refuses a Google sign-in or a missing key with a plain message. **Alternatives considered** A new credential type only for Gemini. The generic `provider-env` type already has the exact-set check, the binding contract and the cross-check against the Runner's allowlists, so a new type adds no value. ## What Changed - `packages/plugins/sdk/src/environment-tasks.ts`: `ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS` has `antigravity: [["GEMINI_API_KEY"]]`. The `provider-env` provider enum accepts `antigravity`. Mixed, partial and extra variable sets stay rejected. - `server/src/services/native-runtime/plugin-runner-credentials.ts`: for provider `antigravity`, Core sends only `GEMINI_API_KEY`. Core refuses a Google sign-in document (`PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`) or a missing or blank key with "Plugin Runner supports Google Antigravity only with a Gemini API key. Google sign-in is not supported." No key value is in any error message. - Tests: SDK schema cases (accept the key; reject a sign-in document, a key mixed with a sign-in document, `GOOGLE_API_KEY`, extra routing variables, empty values, and the key under another provider). Core transfer and refusal cases. Dispatch only for the matching `antigravity` harness, with no key in persisted lease metadata or in a worker error. A Runner check that the Antigravity process gets the key and no `GOOGLE_*` or other `GEMINI_*` variable. - Docs: `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and `doc/plugins/PLUGIN_RUNNER_EXECUTION.md` list the new set, the binding requirement and the sign-in refusal. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the changed SDK source. ## Verification - Red first: the new tests failed before the change (the schema rejected `antigravity`, and Core threw "does not support the selected credential provider"). - Green after the change: - `cd packages/plugins/sdk && npx vitest run tests/` (322 passed) - `cd server && npx vitest run src/__tests__/plugin-runner-credential-names.test.ts src/services/native-runtime/plugin-runner-credentials.test.ts src/__tests__/environment-task-runtime.test.ts` (94 passed) - `cd packages/plugins/sdk && npx tsc --noEmit -p .` and `cd server && npx tsc --noEmit -p .` (clean) - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` (no change) - `pnpm verify` asks for broad CI coverage (exit 2) because an SDK test file changed. Required CI supplies that coverage. - No live run. Antigravity on a plugin target stays refused by Core until a later change lifts that refusal, so this change is not reachable in a run yet. ## Risks - Low risk. The change adds one enum value and one key set. Existing providers keep the same behavior. - Plugins that validate with an older SDK reject an `antigravity` credential. This is the expected fail-closed result. - The key reaches the Runner only through the typed credential. The Runner still requires a matching `PAPERCLIP_ACPX_CREDENTIAL_BINDING` and still removes other `GOOGLE_*` and `GEMINI_*` variables. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits) and extended thinking. ## 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 - [x] 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> |
||
|
|
4622965a25 |
fix(github): recover response requests that ran out of retries; restore lost regression tests (#22906)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull request threads, and each request's comment must end in a real reply or an honest final notice > - After #22672, #22710, #22798 and #22807, new review-bot comments on staging settle: 0 of 85 comments since the deploy are stuck > - Two older "Working on this…" comments (PRs #22649 and #22676) still did not settle. Before those fixes, their requests spent all acknowledgement retries and were left `failed`, a state no recovery path reads again > - Separately, the chat-channels split (#22838) was built from an older copy of the monolith and dropped the regression tests those fixes added > - This pull request adds a one-time recovery migration for exhausted requests and restores the lost regression tests > - The benefit is that the last stuck comments settle, and the settle rules stay covered by tests that run on every PR ## Linked Issues or Issue Description Refs #22672, #22710, #22798, #22807, #22838 **Describe the bug** Two GitHub request comments from 2026-11-23 still read "Working on this…" on staging after the settle fixes deployed. Before #22798, an unsettled reply made each acknowledgement attempt fail with "GitHub reply is still being resolved", so these requests spent all 8 retries and stayed `failed` with `retryable: false`. Neither the acknowledgement sweep (retryable only) nor the terminal sweep (processed only) reads them again. **Steps to reproduce** 1. A request's acknowledgement fails 8 times and is left `failed`, `retryable: false`, with its comment still "Working on this…". 2. Deploy the settle fixes. Nothing reads the request again. **Expected behavior** Such a request settles with the current decision once. ## What Changed - Migration `0509_recover_exhausted_github_responses.sql`: one UPDATE that returns failed, non-final `github_response_comment` rows that already hold a posted comment to `processed` (code `recovered_after_exhausted_retries`, wait key and retry time cleared), so the terminal sweep settles them. Marked `online_compatible`. - Restored regression tests dropped by the split, in `server/src/__tests__/chat-channels/github-review-workflow.integration.test.ts`: published review kept in the main comment (ended / paused), older status settles against a newer placeholder, back-to-back runs settle, waited thread links a later response (including a different-PR guard), inline-only review link, waited thread settles when the task finishes, refused reply settles. - New tests: a failed run whose automatic retry finished the task (inline and issue threads), and the exhausted-retries recovery. ## Verification - `github-review-workflow.integration.test.ts` restored + new tests: 11 passed locally. The recovery test shows the comment stuck before the migration and settled after it. - Test tree typecheck (`src/__tests__/tsconfig.json`) is clean. - After deploy: the two remaining placeholders on #22649 and #22676 should settle within a sweep pass; I will check them on staging. ## Risks - The migration updates only failed, non-final GitHub request rows that have a posted comment; on staging that is a handful of rows. Each is read once by the terminal sweep and then settles or waits under the current rules. - Restored tests add a few seconds to the GitHub review workflow suite. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## 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> |
||
|
|
4aaa77e6fc |
perf(ci): split 6 single-file Vitest stragglers across runner, chat, server, and serialized lanes (#22916)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Profiling live 8-core PR runs (`45592683902`, `45578886514`, `45591289735`, `45587659461`) showed that every single top Vitest critical-path straggler across all 4 Vitest lanes was caused by **single-file tail pinning**—one massive file running solo while 4–6 CPU cores sat idle—rather than insufficient shard counts: > - `Verify Paperclip Runner (vitest package 1/6)` (`245s` job): `runnerd-codex-transport.test.ts` = `190.9s` solo > - `Verify Paperclip Runner (vitest package 2/6)` (`236s` job): `runnerd-codex-transport-deadlines.test.ts` = `181.3s` solo > - `Verify Paperclip Runner (vitest package 3/6)` (`185s` job): `runnerd-codex-transport-settlement.test.ts` = `123.6s` solo > - `General tests (chat 1/2)` (`229s` job): `github-review-workflow.integration.test.ts` = `179.2s` solo > - `General tests (server 1/20)` (`209s` job): `connection-management.integration.test.ts` = `160.1s` solo > - `Verify serialized server suites (1/9)` (`190s` job): `issue-queued-comments-routes.test.ts` = `132.8s` solo > - Instead of bloating shard counts, this pull request splits those 6 single-file tails into 20 focused sibling suites (`<925 LOC` per new file) with shared non-test harness helpers so existing 8-core workers execute them in parallel, keeps all 6 original anchor filenames intact so every existing `maps/` and contract reference remains valid, and refreshes all 4 Vitest LPT duration manifests from live 8-core measurements. > - Every single original test case is preserved (`694/694` live pass across the 20 split suites, zero deleted assertions) while shaving `60–105s` off every Vitest lane's critical-path tail. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Parallel wall-clock execution time of the slowest shards across `Verify Paperclip Runner (vitest package)`, `General tests (chat)`, `General tests (server)`, and `Verify serialized server suites`. **Subsystem affected** packages/paperclip-runner/, server/, and scripts/ — Vitest integration test layout, sequencer priorities, and LPT shard duration manifests **Current behavior** Six oversized test files (`123s–191s` solo each) pin the tail of the slowest shard in every Vitest lane while peer workers on the 8-core runner sit idle. **Proposed behavior** Split those 6 single-file stragglers into 20 parallelizable sibling suites (retaining all 6 original anchor filenames and extracting shared non-test harnesses) and refresh `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `scripts/chat-shard-durations.json`, `scripts/general-server-shard-durations.json`, and `scripts/serialized-shard-durations.json` plus `packages/paperclip-runner/scripts/vitest-sequencer.mjs`. ## What Changed - **Split all 6 single-file stragglers (31 files changed: 11 modified, 20 new; every new file `<925 LOC`, 100% of test cases preserved):** 1. `packages/paperclip-runner/test/runnerd-codex-transport-deadlines.test.ts` (`181.3s` CI) → 3 files (`anchor` + `-lease-expiry` + `-cold-admission`, 9/9 tests) 2. `packages/paperclip-runner/test/runnerd-codex-transport-settlement.test.ts` (`123.6s` CI) → 2 files (`anchor` + `-settlement-revocation`, 19/19 tests) + 3 non-test support harnesses (`runnerd-settlement-assertions.ts`, `runnerd-settlement-harness.ts`, `runnerd-settlement-fixture.ts`) 3. `packages/paperclip-runner/test/runnerd-codex-transport.test.ts` (`190.9s` CI) → 4 files (`anchor` + `-backlog-proxy` + `-held-calls` + `-provider-turns`, 337/337 tests) 4. `server/src/__tests__/chat-channels/github-review-workflow.integration.test.ts` (`179.2s` CI) → 4 files (`anchor` + `-finding-threads` + `-response-maintenance` + `-publications`, 89/89 tests) + `github-review-harness.ts` 5. `server/src/__tests__/connection-management.integration.test.ts` (`160.1s` CI) → 4 files (`anchor` + `-providers` + `-delegated-policy` + `-gateways`, 92/92 tests) + `helpers/connection-management-harness.ts` 6. `server/src/__tests__/issue-queued-comments-routes.test.ts` (`132.8s` CI) → 3 `*routes*` files (`anchor` + `-steering-routes` + `-dispatch-routes`, 148/148 tests, all matching `routeTestPattern` in the `serialized` lane) + `helpers/issue-queued-comments-harness.ts` - **Updated sequencer & LPT duration manifests:** - Updated `packages/paperclip-runner/scripts/vitest-sequencer.mjs` and refreshed `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `scripts/chat-shard-durations.json`, `scripts/general-server-shard-durations.json`, and `scripts/serialized-shard-durations.json` from live 8-core PR run `45592683902` with exact `coverage` reconciliation. ## Verification - Live execution of all 20 split suites: **20/20 files, 694/694 tests PASS** (`deadlines` 9/9 in `81.1s` parallel, `settlement` 19/19 in `105.4s` parallel, `transport` 337/337 in `109.2s` parallel, `github-review` 89/89 under shared PG, `connection-management` 92/92 under shared PG, `issue-queued-comments` 148/148 under shared PG) - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (105 nightly suites, 11 test files checked, 0 violations) - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capability IDs aligned) - `pnpm --filter @paperclipai/paperclip-runner exec tsc --noEmit` — **PASS** (0 errors) - `pnpm --filter @paperclipai/paperclip-runner exec vitest run scripts/vitest-sequencer.test.mjs` — **5/5 PASS** - `node --test` across `native-completion-source-contract`, `run-vitest-stable-shard`, `run-vitest-stable-pr-mode`, `runner-vitest-package-lanes`, `test-selection-pr-timings`, `test-selection-timings`, `e2e-shard`, `check-test-budget`, and `ci-plan` — **121/121 PASS** ## Risks - Low risk: all 6 original anchor filenames remain intact, zero `.github/**` or `CODEOWNERS` files are touched, zero cross-test-file imports were introduced (shared setup lives in non-test harness modules), and full CI will execute all 20 split suites live before merge. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`vitest-runner`, `verifier`, `ci-pipeline`). ## 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 |
||
|
|
007d1c2ef1 |
perf(runner): parallelize static checks and memoize contract fingerprinting (#22912)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - On 8-core PR runners (`45592683902`, `45578886514`), `Verify Paperclip Runner (static checks)` was the #3 PR critical-path straggler at `192s–222s` (`142s–178s` inside `check:static`) because `check:static` ran every build, contract check, prep test, and API-authority Vitest suite serially on a single chain—rebuilding `@paperclipai/paperclip-eval-kernel` 4 times, repeating `acpx-profiles`/`protocol-types`/`tsc` twice, re-parsing Rust files uncached in `contract-fingerprints.mjs` (`26s`), running a duplicate contract test behind a serial `&&` barrier (`52s`), and running `check-api-authority.mjs` (`75s`) without `--project @paperclipai/server` or shared-PG `fsync=off`. > - This pull request eliminates every redundant rebuild/check inside `packages/paperclip-runner`, memoizes `contract-fingerprints.mjs` by content hash (`sha1`, bit-for-bit identical digest, `10x` faster), consolidates `test:typescript:prep` into one parallel `node:test` runner, wires `check-api-authority.mjs` to `--project @paperclipai/server` + disposable shared PostgreSQL while preserving standalone self-contained execution for `release-verify.yml`, and orchestrates `check:static` via a race-free 5-phase DAG (`run-check-static.mjs`) that overlaps disjoint builds and tests across available CPU cores. > - All changes stay strictly within `packages/paperclip-runner/` and preserve 100% of original static, protocol, build, prep-test, and API-authority checks. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Execution speed of `pnpm --filter @paperclipai/paperclip-runner run check:static` (`Verify Paperclip Runner (static checks)` CI job) on multi-core runners. **Subsystem affected** packages/paperclip-runner/ — static checks, contract fingerprinting, and prep/authority test orchestration **Current behavior** `check:static` chains `check:eval-kernel && check:protocol-without-vitest && check:api-authority` serially, rebuilding `paperclip-eval-kernel` 4x, running `tsc` and protocol checks 2x, re-stripping/re-parsing Rust sources uncached in `contract-fingerprints.mjs`, running `acpx-message-boundaries-package-contract.test.mjs` twice across a serial `&&` barrier, and running `check-api-authority.mjs` without `--project @paperclipai/server` or disposable shared PG. **Proposed behavior** Memoize Rust comment-stripping/parsing in `contract-fingerprints.mjs` with bit-for-bit identical digest parity, merge `test:typescript:prep` into one deduplicated parallel runner (`run-prep-tests.mjs`), add `--project @paperclipai/server` + disposable shared PostgreSQL + `--skip-build` to `check-api-authority.mjs`, and execute `check:static` via a race-free 5-phase parallel DAG (`run-check-static.mjs`). ## What Changed - **Memoized contract fingerprinting (`packages/paperclip-runner/scripts/contracts/contract-fingerprints.mjs`, `contract-fingerprints.test.mjs`):** - Added content-addressed (`sha1`) caches for `stripRustComments`, `withoutTestModules`, `rustSerdeItems`, per-file string constants, and `#[cfg(test)] mod` declarations, plus compact `probeCache` keys (`16.23s -> 1.63s` locally = `10.0x` speedup, bit-for-bit identical digest `sha256:bacaefb049aa9a0841fe782fefb11ede1f99222d15151873e92194e2aab9c608`). - **Deduplicated parallel prep test runner (`packages/paperclip-runner/scripts/run-prep-tests.mjs`):** - Removed duplicate `test/acpx-message-boundaries-package-contract.test.mjs` and merged the 8 Copilot `node:test` files plus `run-check-static.test.mjs` into one parallel `node-test.mjs` invocation (`44` unique suites, no serial `&&` barrier). - **Optimized API-authority verification (`packages/paperclip-runner/scripts/check-api-authority.mjs`):** - Scoped Vitest to `--project @paperclipai/server`, wrapped with `scripts/ci/vitest-shared-postgres.mjs` when no external test PG URL is supplied, and added `--skip-build` / `--dry-run` while keeping standalone `pnpm run check:api-authority` (used by `release-verify.yml`) 100% self-contained. - **Race-free 5-phase parallel `check:static` orchestrator (`packages/paperclip-runner/scripts/run-check-static.mjs`, `run-check-static.test.mjs`, `packages/paperclip-runner/package.json`):** - Phase 1: `check:eval-kernel` (builds & tests `eval-kernel` once). - Phase 2 (parallel, read-only): `acpx-profiles`, `antigravity-models`, `protocol-manifest`, 6 `node --check` checks, 4 `protocol-types` checks (each once). - Phase 3 (3 disjoint parallel chains): (A) TS builds + entrypoints + copilot assets + replay goldens, (B) serialized Cargo debug then release builds (zero `target/.cargo-lock` contention), (C) `plugin-sdk ensure-build-deps`. - Phase 4: `stage-runner-binary.mjs` after A and B complete. - Phase 5 (parallel): `run-prep-tests.mjs --skip-build` alongside `check-api-authority.mjs --skip-build` with buffered per-step output and signal forwarding. ## Verification - Verified exact digest parity: `sha256:bacaefb049aa9a0841fe782fefb11ede1f99222d15151873e92194e2aab9c608` (unchanged) - `node --test packages/paperclip-runner/scripts/contracts/contract-fingerprints.test.mjs packages/paperclip-runner/scripts/run-check-static.test.mjs packages/paperclip-runner/scripts/build-inputs.test.mjs packages/paperclip-runner/scripts/stage-runner-binary.test.mjs` — **35/35 PASS** (`2.46s`) - `node packages/paperclip-runner/scripts/run-check-static.mjs --dry-run` and `node packages/paperclip-runner/scripts/check-api-authority.mjs --dry-run` — **PASS** - `node scripts/check-test-budget.mjs --base origin/master`, `node scripts/check-maps.mjs`, `node --test scripts/check-test-budget.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs .github/scripts/tests/ci-plan.test.mjs` — **PASS** - Live Linux execution of `Verify Paperclip Runner (static checks)` (including embedded PG `check-api-authority.mjs` and Copilot asset installation) will be verified end-to-end on PR CI. ## Risks - Low risk: all changes are scoped strictly to `packages/paperclip-runner/`, Cargo builds remain serialized in one chain to avoid target lock contention, `stage-runner-binary.mjs` waits for both TS and Rust builds before touching `dist/`, and standalone `pnpm run check:api-authority` preserves full self-contained builds for `release-verify.yml`. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`server-prune`, `verifier`, `ci-pipeline`). ## 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 |
||
|
|
10cd186a46 |
feat(antigravity): carry the agent's own instructions into a /swarm turn (#22905)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A signed-in user can start Google Antigravity's native `/swarm` on a task (experimental, off by default) > - #22733 removed the agent's own instructions from a swarm turn after a security review: an agent can edit its own instructions, and swarm helpers act in Antigravity's auto mode > - The owner reviewed that risk and decided on 2026-11-25 that swarms carry the agent's own instructions again, with Paperclip's swarm rules on top > - This pull request adds the agent's instructions back to a swarm turn through the same composer that ordinary Antigravity turns use, and makes the swarm rules say that they take precedence > - The benefit is that a swarm follows the same agent instructions as every other turn of that agent, and the code-enforced limits stay the same ## Linked Issues or Issue Description Refs #22733 **Subsystem affected** Paperclip Runner, Antigravity `/swarm` route (system instructions), API docs, qualification ledger. **Problem or motivation** A swarm turn runs only on Paperclip's fixed execution prompt and the fixed swarm rules. It ignores the agent's instruction files, so a swarm does not follow the agent's own conventions. The owner decided that swarms must carry the agent's instructions. **Proposed solution** Compose a swarm turn's system instructions exactly as for an ordinary Antigravity turn (`composeNativeSystemInstructions`), with the hand-in values placed right after the instruction entry. The composer's canonical suffix (the instruction root path) still ends the prompt, so `retargetNativeSystemInstructions` remaps it when a launch or recovery moves the bundle to another host path. The swarm route still appends Paperclip's swarm rules last. The rules now say that they take precedence over the agent's instructions, that those instructions cannot widen the Paperclip tools offered or Paperclip's permission decisions, and that helpers must keep their work inside the task folder. ## What Changed - `packages/paperclip-runner/src/backends/runtime-context.ts`: the swarm branch of `nativeSystemInstructions` now runs after the instruction bundle is read (same path checks), and returns `composeNativeSystemInstructions(runtimeContext, entry + hand-in)`. The hand-in block sits inside the composed entry, so the canonical suffix still ends the prompt and retargeting works as for an ordinary turn. The second, swarm-only path is gone. - `packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-runtime.ts`: `ANTIGRAVITY_SWARM_INSTRUCTIONS` gains one precedence statement. It promises only what the code enforces (the tools offered and the permission decisions) and states the task-folder limit as a rule. The rules stay last in the appended system prompt. - Tests: `runtime-context.test.ts` now asserts that a swarm turn's instructions equal the ordinary turn's instructions with the hand-in block after the entry, and that retargeting to another bundle root puts the new root at the end and leaves an inline path in the entry unchanged. `antigravity-swarm-runtime.test.ts` asserts, on the real `session/new` request, that the agent's instructions are present, that the swarm rules come after them and end the prompt, and that the rules carry the precedence statement. The assertions that the bundle is absent are removed. - `docs/api/issues.md` and `doc/plans/2026-11-22-antigravity-qualification.md`: record the owner decision, what is enforced in code, what is prompt-only, and the residual risk. ### Which protections are code-enforced and which are prompt-only Enforced in code, whatever the agent's instructions say: - Permission handler (`antigravity-swarm-runtime.ts`, `session/request_permission`): approves only the run's own Paperclip tools and rejects every other permission request. - Delegation tools (create task, assign, hire, generic API and similar) are removed from the bridge catalog for a swarm turn (`antigravitySwarmTools`). - Only Paperclip's own tool server is accepted; the session must be in the task folder (guard `sessionRequest`, runtime open checks). - A helper started with `share` or `branch` stops the swarm (`antigravitySwarmWorkspaceEscape`). - A visible change outside the task folder in a reported tool call stops the swarm (`antigravityOutsideChange`). This is a best-effort detector, not a boundary. - A changed model, thinking level or auto mode fails the run (guard `assertStable`). Plan mode, a restored session and extra tool servers are refused. Not enforced by Paperclip: helper shell commands. Helper tool calls do not reach the client, so they can write wherever Antigravity's own sandbox allows (the task folder and temp directories). This is unchanged by this pull request. Prompt-only: the precedence statement itself, handing in once, naming files by task-folder path, and not mentioning the rules. Residual risk, accepted by the owner: an agent that can edit its own instructions can influence what its swarm helpers do inside the task folder. ## Verification - Red: with only the test changes, `npx vitest run src/backends/runtime-context.test.ts src/drivers/acpx/antigravity-swarm-runtime.test.ts` (in `packages/paperclip-runner`) failed 2 tests: the swarm instructions lacked the agent's text, and the `session/new` system prompt did not contain it. - Green: with the change, `npx vitest run src/backends src/drivers/acpx src/live/runner-provider-launch.test.ts src/cli/acpx-runtime-sidecar.test.ts` passed (one timing-sensitive launcher test failed once under load and passed on re-run). - Retarget red/green: with the hand-in appended after the canonical suffix, the swarm composition test fails; with it inside the entry, it passes. - `pnpm typecheck` in `packages/paperclip-runner`: passed. - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`: unchanged. - `pnpm verify` exited 2 (docs are a global CI input), so required CI supplies broad coverage. - No live swarm run. ## Risks - Security: agent-editable instructions now reach a swarm whose helpers act in auto mode. The owner reviewed and accepted this. The code-enforced limits above are unchanged. - Behavior: a swarm now fails like an ordinary turn when the agent's instruction entry is missing or outside its bundle. - The system prompt is larger by the size of the agent's instructions. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (file edits, shell, tests). ## 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 - [x] 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> |
||
|
|
95ffa0c855 |
fix(agents): state the follow-up request plainly and keep run ids out of the prompt (#22899)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - When a user comments on a finished task, Paperclip starts a
follow-up turn. The agent gets a prompt with the fresh-session history,
the wake payload, and the task context.
> - On Google Antigravity follow-ups after a swarm, the agent spent 3 to
6 minutes and 1 to 2.7 million cached tokens on a one-line file edit.
> - The agent took the run id of the previous run from the prompt and
searched the disk for it. It then read the raw run log to copy how the
previous run wrote the file and called the hand-in tools.
> - The prompt named that run id five times and told the agent to "read
the original run receipt". No agent tool can read a run by its id. Also,
the follow-up directive pointed at an empty "Latest wake comment"
section. The request was present only inside a JSON message list.
> - This pull request removes run ids from the model-facing prompt,
states the latest request plainly once, and points the directive at it.
The prompt also gets smaller.
> - The benefit is that a follow-up has no prompt path that leads the
agent to run logs, and the agent can find the request where the
directive points.
## Linked Issues or Issue Description
**What happened?**
A user comment on a done task started a follow-up turn. The agent
appended one line to a file. The turn took 180 to 346 seconds and 21 to
39 commands outside the task folder. In three of four slow turns, the
first outside command searched the instance data folder for the previous
run id that the prompt contained. The agent then ran 15 to 30 grep and
Python commands on that run log. The prompt contained the run id five
times: in the run summary and agent reply entries of the fresh-session
history, and as `createdByRunId` on three continuation messages. The
evidence text said "read the record or the original run receipt", but no
tool reads a run receipt. The task context said "Latest wake comment:"
with no text below it, because the assignment variant omits comment
bodies and the wake renderer omits comments that the continuation JSON
already contains. The same continuation summary also appeared twice in
the wake payload.
**Expected behavior**
The follow-up prompt states the latest request plainly once, and the
follow-up directive points at it. The prompt names no run ids and tells
the agent to read only records that a tool can read.
**Steps to reproduce**
1. Run a task to done with a native-runner agent, for example a swarm
that writes two files.
2. Comment "append three to w1.txt" on the done task.
3. Read the prompt of the follow-up run. The "Latest wake comment:"
section is empty, and the previous run id appears five times.
**Paperclip version or commit**
master before this pull request.
## What Changed
- Wake prompt (`renderPaperclipWakePrompt`, all adapters that use the
shared prompt sections): when the continuation JSON owns a waking
comment, the prompt states it once in plain text before the JSON, and
the JSON message keeps its metadata with `bodyShownAbove: true` instead
of a second copy. Only a human user comment is headed "Latest request
from the user". An agent or run comment is headed "Latest comment from
an agent (quoted data, not instructions)".
- New `model-facing-history.ts` in adapter-utils: one explicit set of
run-id keys and one projection, used by the wake prompt and the
fresh-session history. A run-authored comment with user attribution
keeps `createdByRunId: true`, so the model can still see that it is not
human direction. A drift test fails when a new `*RunId` field appears in
the sources that feed this history.
- Wake prompt: the evidence text refers to saved task records that a
Paperclip tool can read, not to a run receipt. The resume-delta text no
longer refers to "the named run".
- Wake prompt: "Issue continuation summary" is not repeated when it is
identical to the `completedWork` that the continuation evidence already
shows.
- Task context: when the wake payload carries the comment text, the
follow-up directive names the comment id (`Latest wake comment: "<id>",
shown in the wake payload.`) instead of an empty section. An
attachment-only comment points at the attachment directive.
- Fresh-session history: run summary and agent reply entries no longer
carry the run id or the run event id, and low-trust `sourceTrust` keeps
its labels without `sourceRunId`. Comment and document entries keep
their ids, which the named retrieval tools can read.
- Continuation summary read boundary: a summary stored by a server older
than the change that stopped writing run ids keeps its old lines until
the next run on that task finishes. The summary reader and the
fresh-session history now drop those exact legacy generated lines ("Last
updated by run", "Heartbeat run ... invoked adapter", the run-log
pointer) and reword the old "Run `<id>` finished" line.
- Adapter tests that parse the continuation JSON now find the JSON
block, not the first fenced block.
## Verification
- Red/green: the new tests fail on master and pass with this change.
- `packages/adapter-utils/src/server-utils.test.ts`: a sanitized fixture
of the measured follow-up wake
(`test-fixtures/follow-up-after-swarm-wake.ts`). The test checks one
plain statement of the request, no run id, no `createdByRunId` value, no
"run receipt" text, and one continuation summary. A second test checks
resumed sessions, completed actions, and a run-authored user comment.
- `server/src/services/heartbeat/task-markdown.test.ts`: the directive
names the comment id when bodies are omitted. The legacy variant still
prints the body.
- `server/src/services/native-runtime/native-session-handoff.test.ts`:
the history keeps comment and document ids and drops run ids.
- `pnpm verify` and the focused suites pass locally.
- Prompt size: the measured follow-up prompt goes from 16,398 to about
15,117 bytes (-7.8%). The fixture wake payload goes from 5,014 to 4,509
bytes. Run id mentions go from 5 to 0.
## Risks
- Scope: run ids are removed from the continuation context and the
fresh-session history. Recovery wakes (disposition repair, liveness
continuation) still print their source run; they are not part of the
follow-up path.
- Low risk. The change affects only model-facing prompt text. Server
envelopes, receipts, and stored data do not change.
- Models no longer see run ids in the continuation JSON. No agent tool
accepts a run id, so the model loses no capability.
- This change removes the prompt path to run logs. It does not prevent
filesystem reads. A model that wants examples can still search the disk.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use and code execution.
## 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>
|
||
|
|
8de6686739 |
fix(apps): save action choices when the provider no longer offers some actions (#22877)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Connections give agents actions in other apps, and the Permissions page controls which actions agents can use > - A managed Google Workspace connection moved from Paperclip's REST tools to Google's MCP servers (#22815) > - Google's MCP servers do not list two Gmail actions, so the catalog refresh marked them as removed (`disabled`, `mcp_tool_removed`) > - The Permissions page still sent these two actions as enabled, and the server refused every save that contained them, except on remote MCP aggregators > - An admin could not release the 34 held actions, so the connection stayed unusable > - This pull request makes the server accept a removed action for every connection kind, and makes the UI stop sending disabled or removed actions > - The benefit is that an admin can always save the review after a provider removes actions, and a disabled action still cannot be turned on ## Linked Issues or Issue Description Refs #22815 **What happened?** On a managed Google Workspace connection that runs on Google's MCP servers, the Permissions page showed "Review 34 new actions". After "Turn all on" and "Save choices", the save failed with the message "Couldn't save that — Disabled actions cannot be enabled". The held actions stayed held. **What did you expect to happen?** The save releases the reviewed actions. Actions that Google no longer offers stay off and do not block the save. **Steps to reproduce** 1. Connect Google Workspace with the managed method while the transport is Paperclip REST. Keep all actions on. 2. Move the connection to Google's MCP servers (#22815). The refresh holds the actions for review, and Google's listing does not include `gmail__list_threads` and `gmail__search_messages`. 3. Open the connection's Permissions page. Select "Review 34 new actions", then "Turn all on", then "Save choices". 4. See the error "Disabled actions cannot be enabled". **Cause** - `useConnectionPermissionSave.ts` sent `enabledCatalogEntryIds: [...next.enabled]`. This set came from the saved profile and still contained the two removed actions. - `finishGalleryAppConnection` in `server/src/services/tool-access.ts` refused an enabled row with `status === "disabled"`. It accepted a removed row (`quarantineReason === "mcp_tool_removed"`) only for remote MCP aggregators (`isRemoteMcpConnectorMethod`). The catalog refresh writes `mcp_tool_removed` also for Google Workspace and plugin connections, so these connections did not get the same exception. ## What Changed - Server: `finishGalleryAppConnection` accepts a row that the provider's listing removed (`mcp_tool_removed`) for every connection kind. Only the catalog refresh writes this marker, and only when the provider's listing no longer has the action. This is the same behavior that remote MCP aggregators already had. Any other disabled row is still refused with "Disabled actions cannot be enabled". A removed row is not active, so the gateway does not offer it to agents. - Shared: `@paperclipai/shared` has three named predicates in `tool-catalog-availability.ts`. `isCatalogEntryOffered` is true for active and held actions. `isCatalogEntryRemovedByProvider` is true for `removed` rows and for `disabled` rows with `mcp_tool_removed`. `isCatalogEntryBlocked` is true for every other disabled row. The server and the UI use these predicates, so the rule is in one place. - Server: the review coverage check ignores a reviewed id that the provider removed after the page loaded. Before this change, that save failed with "Action review decisions must cover every currently quarantined action exactly once". - Server: a save no longer sets a `removed` row back to active. - UI: a new `withoutUnavailableActions` helper drops catalog entries that are not offered (`isCatalogEntryOffered` is false) from an enabled list. - UI: the Permissions page save (`finishAppPermissions` in `useConnectionPermissionSave.ts`) sends only available actions as enabled or Ask first. The page already showed and counted only active and held actions, so the removed actions do not show, count, or toggle. The page has no existing pattern for removed actions, so this change adds no new text. - UI: the setup flow (`ConnectionSetupFlow.tsx`, which also serves task-hosted setup) and the pasted-config flow (`PasteConfigTab.tsx`) also drop disabled actions before they finish a connection. Before this change, a provider-blocked action (for example a Gmail write action on a read-only method) could make the first save fail the same way. `RemoteMcpProductionSetup.tsx` already sends only active actions. `QuarantinedActionsReview` in `SetupPanel.tsx` selects only from held actions. ## Verification - Red, then green: `server/src/__tests__/google-workspace-mcp-transport.test.ts` → "saves the review when Google no longer offers actions that were on, and still refuses a disabled action". The test saves a managed Google Workspace connection on REST, moves it to Google's MCP servers while Google does not list `list_threads` and `search_messages`, then saves the review with the removed actions in the enabled list. Before the fix it failed with "Disabled actions cannot be enabled". After the fix it passes. The same test makes sure that a disabled action without the removal marker is still refused, and that agents are not offered the removed actions. - Red, then green: `ui/src/pages/apps/app-detail/action-permissions.test.ts` → "finishAppPermissions never asks to turn on an action Google no longer offers or a disabled action". Without the filter, the test fails. - `packages/shared/src/tool-catalog-availability.test.ts` covers the three predicates. - The transport test also sends the removed ids in `reviewedCatalogEntryIds`. Without the coverage fix it fails with "Action review decisions must cover every currently quarantined action exactly once". It also makes sure that the removed rows stay disabled after the save. - Local runs: `google-workspace-mcp-transport.test.ts` and `tool-access-service.test.ts` (542 passed). UI tests in `app-detail`, `features/connections` and `pages/tools` (143 passed). - `pnpm verify` selected the full server suite (1520 files) because `tool-access.ts` is a shared service. On this machine, under load from other sessions, 31 of 33876 tests failed. The run output did not keep the names of the failed tests. The touched test files pass when run alone, and the CI server shards run the full suite on the final head. - `tsc --noEmit` for `server` and for `ui/src`. ## Risks - Low risk. The security rule stays: a disabled action that the provider did not remove cannot be turned on. - Behavior change: Google Workspace and plugin connections now accept a removed action in the enabled list, as remote MCP aggregators already did. The UI no longer sends removed actions, so after a save from the page a removed action stays off if the provider lists it again. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through 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> |
||
|
|
3fbf872d9e |
fix(antigravity): make the task thread read in plain language (#22886)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - A task thread shows what an agent did during a run, as a list of
activity rows under its reply
> - Google Antigravity runs (ordinary and `/swarm`) send no tool
identity, so each row was named after the CLI's display title
> - Users saw rows like "Ran a command · failed Run
mcp_paperclip_paperclip_finish", "Ran File runtime paperclip runner acpx
…", lowercased sentences, and a sha256 dump
> - Each attached file also showed twice, nothing marked a message as a
swarm request, and a refused send only showed a short toast
> - This pull request gives Antigravity tool calls the identity other
harnesses send, and makes the thread read the same live and after the
run
> - The benefit is a task thread that reads in plain language for
Antigravity, with fixes that also help other harnesses
## Linked Issues or Issue Description
**What happened?**
In a live Antigravity `/swarm` run, the task thread showed raw tool
names and internal paths. Examples: "Run mcp_paperclip_paperclip_finish
· failed", "Ran File runtime paperclip runner acpx 5230… antigravity
home … SKILL md", "Ran Swarm started in the task folder with gemini 3 8
flash low …" (lowercased, punctuation removed), "Registered title:
u1.txt, sha256: 7692…". The live list and the finished list used
different words. The CLI's first reads of u1.txt failed ("must be an
absolute path") and were read again successfully, but the thread showed
"failed". Each file showed twice: a file card, and an agent message
"Prepared u1.txt for this response." with a second card. The user's
bubble did not show that the message was a swarm request. When the
server refused a send (for example `/swarm` in Plan mode), only a short
toast explained it.
**Expected behavior**
Rows say what the agent did in plain words, the same while live and
after the run. No raw tool names, internal paths, hashes or key/value
dumps. The refused-then-accepted completion call is hidden as for every
other harness. A failure that a later call recovered reads as "retried".
Each file shows once. A swarm request has a small "Swarm" marker. A
refused send keeps an inline, dismissible error under the composer.
**Steps to reproduce**
1. Assign a task to a Google Antigravity agent with the experimental
swarm setting on.
2. Send `/swarm Create u1.txt containing "one" and u2.txt containing
"two", one helper per file, then verify both.`
3. Expand the activity list while the run is live, and again after it
finishes.
4. Put another task in Plan mode and send `/swarm do something`.
## What Changed
- Runner (Antigravity-owned): new `antigravity-tool-identity.ts` names
each call. Paperclip bridge tools become
`mcp__paperclip__<canonicalRunnerToolName(tool)>` (from the CLI's
`mcp_paperclip_<tool>`, an ordinary run's `paperclip_<tool>` title, or
ACP `_meta.mcp`). Native CLI tools keep their own names (`run_command`,
`view_file`, …) with the command as the subject. Reads of the CLI's own
built-in files (its private Antigravity home) are dropped. Swarm
progress lines get one neutral identity (`swarm_update`) whose subject
is the plain sentence. Swarm file locations are task-relative.
- Runner: a narrow activity-adapter hook (`createToolEventProjection`)
applies this in both places that pump an ACPX turn (in-process driver
and sidecar). The sidecar now keeps a provider-supplied tool detail
instead of overwriting it.
- UI: live rows use the call's subject, drop raw technical names
(Paperclip's own tools need no source label), and use the same "verb +
subject" form as settled rows, so both lists read the same.
- UI: a bridge call recorded under its own id (providers that pass no
tool-use id) joins the provider's row for the same Paperclip tool, in
the live log and in stored events. `register_deliverable` reads
"Attached u1.txt"; content digests never show in an input summary.
- UI: a failed call whose later call of the same tool on the same target
succeeded shows as "· retried" (token-only, same muted style).
Unrecovered failures stay "· failed".
- UI: generated "Prepared <file> for this response." receipts are hidden
for any file that already shows as the run's file card (before, only
images).
- Server + shared + UI: `IssueComment.nativeCommand` ("swarm") is
derived read-only from the server's own activity record on comment list,
get and the POST response. The user's bubble shows a small "Swarm" note.
The `/swarm` eligibility rule (`isAntigravityAgent`,
`antigravitySwarmAvailable`) now lives in `packages/shared`; the
composer shows a light hint when the text starts with `/swarm` and the
assignee can run a swarm.
- UI: the composer keeps the server's message as an inline, dismissible
error after any 4xx refusal, until dismissed or the next send. The
optimistic "Working" row behaviour is unchanged.
Not changed, by design: after a reload, a settled run's activity is
deferred behind "More run output" for every native harness (cold-load
speed), so Antigravity already matches the others.
## Verification
- Red/green runner test `antigravity-tool-identity.test.ts` with a
fixture rebuilt from a live swarm run's updates (ids, paths and hashes
replaced): names, subjects, dropped internal reads, hidden finish
identity, ordinary-run titles and `_meta.mcp`.
- Red/green UI test `antigravity-thread.test.tsx` renders the real run's
stored events (settled) and the same events through the live run-log
parser. It asserts the exact rows, "retried" reads, one "Attached" row
per file, no finish rows, no raw names/paths/hashes, and live ==
settled. It fails on master (raw "Ran Swarm update …", "Read · failed",
"Registered title: …, sha256: …").
- Red/green `TaskChatThread.test.tsx`: a prepared text file shows once;
a refused send shows the server message inline until dismissed and the
Working row clears; only a server-marked comment shows "Swarm".
- `TaskChatComposer.test.tsx`: the `/swarm` hint shows only for an
Antigravity assignee with the setting on.
- Server `antigravity-swarm-request-path.test.ts` (embedded Postgres):
only the user's recorded request is marked; text, metadata, another
user's or an agent's comment are not.
- Local: paperclip-runner acpx/sidecar/provider-events suites, UI
task-chat/transcript/adapters/thread/hooks suites (1630 tests), server
swarm suite, and shared/server/ui/runner typechecks pass. `pnpm verify`
exited 2 (broad input), so CI supplies the broad coverage.
Before (live swarm run, done state):
```
Ran This swarm runs on the google account of this agent s google connection
Ran File runtime paperclip runner acpx 523076a3 3689 4b28 9910 c101bc6b64d8 97d9fb76f6aa11b6 a…
Ran File u1 txt · failed u1.txt
Ran a command · failed
Registered title: u1.txt, sha256: 7692c3ad3540bb803c020b3aee66cd8887123234ea0c6e7143c0…
```
After (same events, settled and live):
```
Swarm This swarm runs on the Google account of this agent's Google connection.
Swarm Started helper writer1: Create a file named u1.txt in the current workspace directory containing exactly "one"
Read · retried u1.txt
Read u1.txt
$ shasum -a 256 u1.txt u2.txt; wc -c u1.txt u2.txt
Attached u1.txt
Swarm Files changed in the task folder: u1.txt, u2.txt
```
## Risks
- Live tool rows for all harnesses no longer show a raw technical name
("Paperclip · search_tasks", "Bash") next to the activity. Rows with a
concrete subject now read like settled rows ("Read README.md", "$ npm
test"). This is a deliberate wording change.
- `register_deliverable` reads "Attached <file>" for all harnesses.
- Generated file receipts are hidden for any file with its own card, not
only images. Human text and agent progress with attachments stay visible
(the same marker and link checks as for images).
- Bridge-call pairing is display only and matches only a Paperclip tool
of the same name that is in flight. Claude already shares one id and is
unchanged.
- One extra indexed activity-log query per comment list or get. No
schema change.
> 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
- Claude Opus 5.5 (`claude-opus-5-5`) in 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
- [x] 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>
|
||
|
|
c0b0517dc3 |
fix(antigravity): stop every process a swarm's CLI started before reporting its outcome (#22875)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` on the native Runner (experimental flag, #22733, #22865) > - In a live run, the `agy acp` CLI process was killed mid-swarm. Its helper shell commands kept running for about 14 s, and one wrote a file in the task folder 14 s after the kill > - The failure was recorded only when those helpers exited, because they held the CLI's output pipe open. Automatic recovery then starts a fresh swarm in the same folder, so old helpers can race it > - Recovery must just work, and nothing may write in a task folder after its run ended > - This pull request records every process the CLI starts and stops all of them before a failed or stopped swarm turn is reported and on shutdown, and detects a lost CLI on exit > - The benefit is that a crashed, stopped, timed-out or shut-down swarm leaves no process behind and recovery never races old helpers ## Linked Issues or Issue Description Refs #22733, #22865 **What happened?** After a `kill -9` of the swarm's `agy acp` process, three helper commands outlived it by about 14 s. One wrote a file in the task folder 14 s after the kill. The run failure was recorded about 15 s after the kill, right after the last helper exited. On a user Stop the helpers were gone in 0.2 s, because the CLI stops them itself. **What did you expect?** When the CLI exits for any reason, every process it or its helpers started stops within about 2 s, before Paperclip records the outcome and before recovery starts in the same folder. **Steps to reproduce** Start `/swarm` on a task with helpers that run shell commands. Kill the `agy acp` process. Watch the helper processes and the task folder. **Why it happened** - `retireAntigravityProcess` signals only the launcher's process group. The CLI starts each helper command as its own process-group leader, and when the CLI dies those commands are re-parented. - The swarm connection detected a lost CLI on the child's `close` event. `close` waits until every copy of stdout is closed, and the helpers inherited that pipe. - runnerd already records the full process lineage of the sidecar (`process_lineage.rs`) and stops it when the sidecar is torn down. That happens after the turn outcome is published, so it cannot keep the helpers from writing first. ## What Changed - New `antigravity-process-lineage.ts`: records the lineage of the CLI launcher while it runs, with runnerd's `LineageTracker` membership rules, scoped to the CLI's subtree. A process belongs when its parent belongs, or when it is in a group or session that a member leads and started no earlier than that leader (sessions on Linux; macOS `ps` reports no session id). Identity is PID plus start time, re-read just before each signal, so a reused PID is never signalled. A recorded member that exists but cannot be read stays unresolved, and a table read that does not list this process is rejected; neither proves the lineage gone. Membership never depends on a command name, so other `agy` processes of the same user are never touched. It reads `/proc` on Linux and `/bin/ps` (numbers only) on macOS, every 200 ms while the CLI runs. `terminate()` re-reads the table each round, sends SIGKILL to every live member (the first round before any deadline), and proves none remain within 1.5 s. - Why not runnerd's tracker directly: it is rooted at the sidecar and stops the whole lineage, the sidecar included, only at sidecar teardown. It has no operation for one subtree. The swarm must stop the CLI subtree while the sidecar keeps serving the run, also on Stop and helper timeout, when the CLI is still alive. Reusing it needs a new sidecar-to-runnerd operation and a Rust change, which is out of scope here. The macOS retirement check in `antigravity-process.ts` now uses the same process-table reader. - `antigravity-swarm-runtime.ts`: the CLI's retirement now also terminates that lineage. A swarm turn that did not complete (CLI lost, Stop, helper timeout, refusal) retires the CLI and its lineage before the outcome is returned. `close()` (runner shutdown) does the same. A swarm turn is the port's only turn, so nothing else uses the CLI after it. - Cleanup fails closed. A failed or incomplete process-table read is retried. If the helpers still cannot be proven stopped after three attempts, the turn fails as not retryable with plain text, so Paperclip does not continue the task on its own in that folder. A failed retirement is not cached, so `close()` tries again. - A lost CLI is detected on the child's `exit` event. Output already written is read for up to 200 ms after exit; the inherited pipe no longer delays the failure. - Fake CLI scenario `orphan-helpers`: a helper that leads its own process group, holds the CLI's output pipe, and writes `late.txt` after a delay. The CLI never stops it itself. - Qualification ledger: the live re-check of #22865 (Stop usage 36,910 in / 869 out; killed-run usage still 0 with CLI 1.5.15; kill text and automatic recovery; receipt event; clean thread text) and this fix (fake-CLI proof, live proof pending). Investigated and not changed here: an ordinary (non-swarm) Antigravity run read the instance's run logs and the CLI's private files outside its task folder. No existing Runner policy confines reads for this harness; confining them would be a new policy, so it is reported separately. ## Verification - Red/green: with only the runtime change reverted, the new swarm tests fail (the failure waited on the pipe; helper alive after Stop; helper alive after shutdown; unproven cleanup reported as recoverable). With the change they pass. - Swarm tests kill the fake CLI with SIGKILL and check that the helper is dead when the failure is reported, that `late.txt` is never written (the helper writes it after 3 s, so a report that waited on its pipe would fail), and that an unrelated process of the same user survives. They also cover Stop, runtime close mid-swarm, and a failing process listing (not retryable; the helper stays alive past the cleanup budget and the later close stops it). - Lineage unit tests: re-parented helpers and their children are kept; session members are kept; a reused PID, a reused group id and an earlier-started process are never claimed; zombies are dropped; unreadable members stay unresolved; failed, empty, self-less and unreadable reads never prove the lineage gone and a later call retries; a PID whose start time changed is never signalled; the first kill round runs even when its read exceeds the deadline; pure macOS `ps` and Linux `/proc` parsers; a detached grandchild of a dead root is stopped and an unrelated process survives. Each review-driven rule was checked by reverting it and seeing its test fail. - All Antigravity driver suites (packages/paperclip-runner): 20 files, 363 tests passed. `tsc --noEmit` for the Runner package passed. - `pnpm verify` exited 2 (the fake CLI fixture is a broad input), so CI supplies the broad coverage. `tests/runner-e2e/source-sdk-public-inputs.mjs --write` reported no change. - Not run: a live swarm (live proof is pending and recorded as pending in the ledger). Linux ran only in CI. ## Risks - A sampler reads the process table every 200 ms while a swarm CLI runs (`ps` on macOS, about 25 ms wall time; `/proc` on Linux). Only swarm turns run it. - A helper that starts and leaves its group and session within one 200 ms sample, before it is seen, can escape this tracker. runnerd's sidecar lineage still stops it at sidecar teardown. - A swarm turn that ended without completing now stops the CLI before reporting. The port already refuses a second swarm turn, so no later turn depended on that CLI. - If cleanup cannot be proven (for example the process table cannot be read), the swarm fails without automatic recovery instead of risking a race. - macOS start times have one-second resolution, so a PID reused within the same second as the original start could match. The group and parent rules also need a recorded member, which keeps this narrow. - On macOS there is no session rule, because `ps` reports no session id. A helper that calls `setsid` is still recorded as a group leader when a sample sees it. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through 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 - [x] 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> |
||
|
|
cd8bcfba16 |
fix(antigravity): swarm usage on Stop/kill, honest recovery text, clean thread text, run-record receipt (#22865)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` from a task (#22733, experimental flag) > - The first complete live run of `/swarm` found gaps: a stopped or killed swarm recorded no usage, the lost-process text asked for Retry while Paperclip recovered on its own, CLI-only text and local `file://` paths reached the task thread, and the swarm's settings receipt never reached the run record > - Usage must always be recorded, recovery must just work, and users must not see local paths or internal jargon > - This pull request fixes each gap at the module that owns it, with a red/green test for each > - The benefit is a swarm whose cost, recovery and thread text match what happened ## Linked Issues or Issue Description Refs #22733, #22731 **What happened?** In a live local run of `/swarm` (Gemini 3.8 Flash and Gemini 4 Neon, Google sign-in): - A swarm stopped after 29 s with 7 helpers recorded 0 tokens. A swarm whose CLI process was killed also recorded 0 tokens. - After the CLI process died, the failure text said "Retry starts a fresh swarm in the same task folder" and was marked not retryable, but Paperclip recovered on its own with a fresh swarm. - The thread showed "Run /swarm board (default shortcut alt+s) to open the live board", a stray "." line, links to absolute local `file:///…/<company id>/<task id>/a.txt` paths (on ordinary Antigravity replies too), and a mention of "the Paperclip swarm rules". - The structured swarm receipt (requested and confirmed model, channel, CLI version, account match) was not in the run record. **What did you expect?** Usage recorded for every swarm, text that matches automatic recovery, a thread without CLI hints or local paths, and a queryable receipt. **Steps to reproduce** Run `/swarm` on a task for an Antigravity agent, then Stop it or kill the `agy acp` process, and read the run usage and the thread. ## What Changed - **Usage on Stop and process death** (`antigravity-swarm-runtime.ts`). A stopped prompt's own answer is awaited within the grace window and its `usage` is kept. When no answer arrives (the CLI exited, or did not answer in time), the token counts the CLI streamed in `usage_update` (`_meta.usage`, read with the shared ACP converter) are kept; after an earlier answered prompt they only raise a counter (per-counter maximum), because a streamed count may be session-wide, so nothing is counted twice. The usage is one receipt per run request, so a recovery run never counts it again. What cannot be known: if the CLI exits before it streams any token counts, that prompt's usage is lost with the process. The pinned CLI 1.5.15 declares `usage_update` and a prompt-answer `usage`; whether it fills `_meta.usage` mid-prompt is not proven live. - **Lost CLI process.** The failure is retryable and says "Files the helpers already wrote stay in the task folder", with no instruction to press Retry. Automatic recovery is unchanged and is bounded by the server's existing per-request cap (three failed attempts, then a plain refusal); a new database test pins that cap for the lost-process error code across continuation, recovery and assignment wakes. - **Terminal hint split across chunks** (`antigravity-swarm-presentation.ts`). The swarm passes raw coordinator text to a streaming filter that holds text that could still become the hint, so the hint and its trailing period are dropped wherever the CLI splits them. The fake CLI now streams the hint in the recorded live pieces. - **Local file links, both Antigravity routes** (`antigravity-local-links.ts`, wired in `runtime-host.ts` for agent `antigravity` only). No existing mechanism did this: other harnesses only emit file-reference events, and an ordinary Antigravity reply showed the same links. Before a reply leaves the Runner, a link to a task-folder file becomes its folder-relative path in code (the thread opens a nested path as a task-folder file; a root-level name stays plain text beside its deliverable link, as before, since the thread never opened the `file://` target), a descriptive label keeps the path beside it, other `file://` links keep only their label, a bare task-folder prefix is removed, and the folder named on its own reads "the task folder". Sentence punctuation stays outside file names. `/api/...` and web links are unchanged. Text that could still become a link is held across chunks. - **Swarm rules** tell the coordinator that its text is shown in the task thread: name files by task-folder path, no absolute paths or `file://` links, no terminal commands, shortcuts or live board, no mention of the rules. - **Swarm receipt in the run record** (`antigravity-activity.ts`, `profile-activity.ts`). The sidecar's status sanitizer dropped `antigravitySwarmReceipt`. It now reaches the run as a `provider.notice.recorded` event (category `antigravity_swarm_receipt`) through the same post-turn hook as Cursor's native receipt. It carries requested and confirmed model, thinking level, mode, channel, CLI version and whether the CLI sign-in matches the connection. No account, path, session id or instruction text. No protocol schema change. - The link parsing reuses `localTarget` and `workspaceRelativePath`, now exported from `live/workspace-file-reference.ts`. - The public SDK input registry is resynced for a `packages/shared` change that landed on master. - **Ledger** (`doc/plans/2026-11-22-antigravity-qualification.md`): what the live swarm and Neon runs prove, and what they do not. - Not changed: the user's own `/swarm` comment has no marker in the thread. The thread has no per-message marker for Plan-mode requests either, and comments do not store `nativeCommand`, so there is no pattern to reuse. ## Verification - Red/green: the new runtime and presentation tests fail on the old source (6 failed) and pass with the fix; the receipt test fails without the `antigravity` activity registration. - `cd packages/paperclip-runner && npx vitest run src/drivers/acpx src/cli/acpx-runtime-sidecar.test.ts`: 120 files, 2239 passed. - `cd server && npx vitest run src/services/antigravity-swarm.db.test.ts`: 52 passed. - `pnpm run check:acpx-profiles`, `scripts/contracts/contract-fingerprints.test.mjs` and `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` (unchanged) pass. - `pnpm verify` exits 2 (the fake CLI fixture is a broad input), so CI supplies the broad coverage. - Not run: a live swarm (no paid or live runs from this change). ## Risks - Low to medium. The link filter applies to every Antigravity reply. It holds a short tail of text that could still become a link or local path, and releases it before the next non-text event and at turn end. A tool event that arrives in the middle of a link releases the partial link unchanged. - A lost swarm process is now marked retryable. The server's recovery decision does not read this flag; automatic recovery behaves as before. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code execution in Claude Code. ## 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 - [x] 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> |
||
|
|
627d59c5aa |
fix(inbox): group repeated provider failures and clear recovered tasks (#22846)
## Thinking Path > - Paperclip helps people manage work that agents do. > - The inbox tells a person which tasks need a decision. > - A provider usage limit can stop several attempts on one task or affect several tasks. > - Separate failure cards made it hard to tell which tasks still needed attention. > - This change groups failures using the account, reset time, or retry links that Paperclip can verify. > - A person can now see which task to retry, which tasks are waiting, and which ones recovered. ## Linked Issues or Issue Description **What existing behavior does this improve?** It improves the Coordinator inbox when a provider limits usage. **Current behavior** Repeated run failures can fill the inbox. Resolved failures can still appear beside open decisions. **Proposed behavior** Show personal actions in Needs you, automatic retries and snoozes in Waiting, and past events in History. Keep an archived retry chain hidden during automatic attempts. Return it to Needs you when a person must act. **Additional context** Related work includes #18020 on completed tasks, #9704 on archive behavior, and #21570 on usage limits in chat. ## What Changed - Group verified account and reset windows. When that evidence is missing, count linked attempts per task and show the tasks in a collapsible group. - Separate the reported reset time from each task’s retry schedule. Keep unresolved ownership recoveries visible after task closure. Use persisted native retry requests to preserve the original archive and increment the attempt count. - Keep personal archive in the card menu. Put decision receipts and run logs in History. - Align inbox filters, tabs, and history. Share empty-state artwork and placement across Inbox, Goals, Routines, and Secrets. - Index run-history pages and resumed-work lookups, and rate-limit history requests per company and viewer. Add synthetic fixtures for both grouping paths and a manual walkthrough. ## Verification - The author and a human tester completed the synthetic retry-chain walkthrough. Chromium also verified archive, repeat failure, exhaustion, and recovery. - The 64 focused server tests and the UI and server typechecks passed before rebasing. See `doc/testing/coordinator-inbox-test-drive.md` to repeat the manual checks. - The shared SDK input check and all 64 focused server tests passed after rebasing. The OpenAPI suite (59 tests), API catalog suite (2,309 tests), and both demo seed paths passed locally after the CI fixes. - The affected inbox and native-runtime suites passed locally after merging the upstream conformance test fix in #22854. The browser access-denial scenarios passed three runs each for 403 and 404. - The migration checks and 79 focused tests passed, including an index-plan regression with 5,000 unrelated runs. The migration and query plan were reverified after renumbering. [Full CI on `cf52b80161`](https://github.com/paperclipai/paperclip/actions/runs/45529834793) passed after rerunning a timed-out server shard. ## Risks The attention feed reads retry ancestry. Long chains can increase query cost. Task and company checks bound the traversal, and cycle detection stops repeated visits. Providers that omit the reset time leave the card with an unknown reset. Migration 0508 adds two indexes concurrently. Each run-history page returns at most 100 records. ## Model Used OpenAI Codex, GPT-6 family, with repository editing, local test execution, and browser verification. ## 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 --------- Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
81e2c50aa9 |
fix(shared): allow one answer per ask_user_questions question (max 64) (#16702)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents ask board users questions with `ask_user_questions` interactions > - The question payload allows up to 64 questions (`askUserQuestionsPayloadFields`) > - The response schema `respondIssueThreadInteractionSchema` allows only 20 answers > - A card with 21 to 64 questions can be created, but the user cannot submit all answers > - This pull request raises the answer limit to 64, the same as the question limit > - The benefit is that every valid card can be answered ## Linked Issues or Issue Description **What happened?** An `ask_user_questions` card with more than 20 questions is accepted on creation. When the user answers every question, the response is rejected by validation because `answers` has a maximum of 20 items. **Steps to reproduce** 1. Create an `ask_user_questions` interaction with 21 questions (the limit is 64). 2. Answer all 21 questions. 3. Send the response to `respondIssueThreadInteractionSchema`. **Expected behavior** One answer per question is accepted, up to 64. **Actual behavior** Validation fails because `answers` allows at most 20 items. No existing public issue found (searched issues and PRs for `respondIssueThreadInteraction`). ## What Changed - `packages/shared/src/validators/issue.ts`: `answers` maximum changed from 20 to 64 to match the question maximum. - `packages/shared/src/validators/issue.test.ts`: new test. 64 answers pass. 65 answers fail. ## Verification - `LC_ALL=C pnpm --filter @paperclipai/shared exec vitest run src/validators/issue.test.ts` — 44 passed. ## Risks Low risk. The change only raises an upper bound to a value the question schema already allows. ## Model Used Claude (Anthropic), model ID `claude-sonnet-5-5`, with tool use and code execution in Claude Code. A human reviewed the change. ## 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 (none needed) - [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 |
||
|
|
0c3ed144cb | Label opt-in traces with the public instance hostname (#22856) | ||
|
|
12944919c6 |
feat(google): keep Google Technical Information at most 30 days and keep Google data out of training exports (#22842)
Adds a durable, sleep-aware 30-day sweep for Google Technical Information, keeps Google results out of decision training and shared feedback traces, and deletes the remaining copies of a cleaned run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3ad8f00192 |
feat(antigravity): trusted /swarm from the task composer, behind an experimental flag (#22733)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` (a coordinator, helpers and a verifier) only on the Antigravity CLI > - #22731 adds a verified CLI route to the Runner, but nothing selects it yet > - A swarm must start only when the signed-in user asks for it, only when an admin turned the experimental feature on, and never silently run as an ordinary request when it cannot run > - This pull request adds the trusted `/swarm` request in the task composer, the server checks and run selection behind an experimental flag, removes Paperclip delegation tools from a swarm turn, and adds the attended catalog cells, docs and ledger > - The benefit is that a user can start a native swarm from a task, and gets one plain message when it is not available ## Linked Issues or Issue Description Refs #22731, #22727, #22728, #22701 **Subsystem affected** Task composer (UI), issue comments API, run selection (server), Paperclip Runner tool bridge, runner-e2e catalog, docs. **Problem or motivation** A user who writes `/swarm <request>` to a Google Antigravity agent should get a real native swarm in the task folder. Today `/swarm` is neutralised text, and the task runs as an ordinary request. **Proposed solution** Read a leading `/swarm` with the shared rule from #22727 in the composer, send it as a structured request, check it on the server, and select the CLI route from #22731 for that run only. ## What Changed - **Trusted start (UI).** `parseSwarmCommand` in `composer-commands.ts` uses `parseLeadingUserCommand` (the one rule from #22727). A leading `/swarm` in the task composer sends the request text with `nativeCommand: "swarm"`; a bare `/swarm` asks for a request; `/swarm` with an assignee change is refused; `/swarm` anywhere else stays text. A resent draft keeps the structured request. - **Contract.** `addIssueCommentSchema` gains `nativeCommand: "swarm"`. `instance.experimental.enableAntigravitySwarm` (feature catalog, settings page, server defaults), off by default. No Cloud policy in Core. - **Server (`services/antigravity-swarm.ts`, comments route, runtime selection).** - The comments route accepts `nativeCommand` only from a signed-in board user. When a swarm cannot run it answers 422 with one plain message and posts nothing: flag off, not a Google Antigravity assignee, a chat, Plan mode. - An accepted request is recorded in the activity log (`issue.antigravity_swarm_requested`, server-written) and the assignee's wake carries the comment id. Comment text is never read as a command. - Run selection makes the run a swarm only when that activity record exists. It refuses a remote or cloud environment and Plan mode with a plain run failure, so a swarm is never run as an ordinary request. It logs `issue.antigravity_swarm_started` in plain language: helper actions are auto-approved, Paperclip does not sandbox the helpers and cannot see their shell commands, and usage is one total. - The native execution input sets the Antigravity provider mode `swarm` for that run only, and carries the verified request in its own field, `provider.swarmRequest` (the Runner contract accepts it only with that mode and requires it there, 1 to 16,000 characters). The Runner copies it into the model envelope as `swarmRequest`; the swarm route sends exactly `/swarm <swarmRequest>` and never reads `task.prompt`, which holds rendered wake comments, task context and text the Runner adds (handoff, attachments, queued messages). - The swarm turn contract (mode `swarm`, envelope `paperclip.native-model-envelope.v3`, `swarmRequest` of 1 to 16,000 characters) is declared as `antigravitySwarmTurn` in `protocol/provider-schemas/acpx-sidecar.schema.json` and generated into TypeScript, so the pack `contractDigest` covers it (it changes; older image packs are rebuilt rather than reused). Provider profile `commandDigest`s and versions are unchanged, so no saved session is reset. - What the swarm sees of the task: only the request. The title, the description (which other people or agents may have written) and other comments are not part of the prompt; the coordinator can read them through Paperclip's task tools as data if it needs context. - An empty `/swarm` or one over 16,000 characters is refused in the composer, by the comments route (422, nothing posted) and at run selection (plain run failure), so it never runs as ordinary work. - A swarm run never takes queued messages, and Interrupt treats it as already started: it stops the swarm and delivers the queued message as the next ordinary request, before or after the provider accepted the turn. - Retry after Stop, and past the three automatic attempts, counts only when the signed-in user asked for it (their own Retry request on the task after the last attempt). Wake reasons and copied run context are not proof: a recovery that copies the request marker, an automatic retry on the user's behalf, or an agent wake that names `task_retry` stay bounded. - **Runner.** For a swarm turn the Paperclip bridge drops delegation tools (`paperclip_create_task`, `paperclip_create_issue`, hire/assign tools); the instructions also tell the coordinator not to delegate. - **runner-e2e.** `antigravity-swarm` suite, 5 local cells (`two-helpers-and-verifier`, `stop-mid-swarm`, `process-loss-retry`, `follow-up-after-swarm`, `flag-off-refusal`), explicit-only, never in `--all` or CI matrix jobs. There is no automated executor yet: the launcher refuses the cells and points at the live recipe. Catalog counts updated (1392 cells). - **Docs.** `tests/runner-e2e/SUITES.md`, `doc/evals.md`, and the `/swarm` section, ledger row and live recipe in `doc/plans/2026-11-22-antigravity-qualification.md`. ## Verification - `pnpm --filter @paperclipai/server exec vitest run src/services/antigravity-swarm.test.ts`: 2 passed (red first: module missing; Plan mode red then green). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-comment-reopen-routes.test.ts -t swarm`: 3 passed; 2 red against the route without this change. - `pnpm --filter @paperclipai/ui exec vitest run src/components/task-chat/TaskChatComposer.test.tsx`: 164 passed, including 4 new `/swarm` tests (red first). - Runner: `vitest run src/drivers/acpx/antigravity-swarm-*.test.ts`: 69 passed (route tool filter red first). - runner-e2e: `antigravity-swarm.test.ts` (red first) plus the catalog, selector and Antigravity tests: 28 files passed. - Typecheck: server, UI (except generated Storybook files absent from a worktree) and runner: no errors. - Live, real CLI 1.5.15 with the owner's sign-in, through the driver: the receipt verified (pinned identity, task folder, `auto` read back, `gemini-3.8-flash` + `low`). Google then refused the prompt with its 429 quota text; the driver reported it as a typed "out of quota" failure, retired the CLI and nothing was written. - **Not run live yet:** the full Paperclip proof (swarm to Done, Stop, kill and Retry, follow-up, flag off). This PR is merged only after it passes. Recipe: `doc/plans/2026-11-22-antigravity-qualification.md#swarm-live-proof`. ## Risks ### Security notes: the trust boundary Helpers are auto-approved and Paperclip does not sandbox the CLI on a local computer, so the boundary is who asked and what text is sent. Every input that can influence it: **(a) Whether a run is a swarm** - `nativeCommand: "swarm"` on the comment request: accepted only from a signed-in board user; the request record (`issue.antigravity_swarm_requested`, actor = that user, `commentId`) commits in the same transaction as the comment. Paperclip-written. - `antigravitySwarmCommentId` on the wake/run context: set only by the comments route and by run selection. It is a pointer, never trusted alone: selection re-verifies comment id + task + company + human author (no agent author) + a matching record by the same user. - The pending request for marker-less wakes: the task's latest human comment, verified the same way. - Retry inheritance: the run's `retryOfRunId` chain (server-written), bounded to 8 hops on the same task. - Manual vs automatic: a request's first run, or a user's own Retry request (`task_retry` / `retry_failed_run`, requested by a user, not `initiatedBy` automation) after the last attempt. Not the wake reason string. - Instance flag `enableAntigravitySwarm` (admin), the assignee's adapter config (Google Antigravity), execution target (local only), work mode (Standard only: Plan, Ask and any other mode are refused, at comment time and at run time), chat vs task: all Paperclip-owned settings. - Prior attempts on the same request (run status rows): Paperclip-written. **(b) What text and tools the swarm gets** - The prompt: `/swarm ` + `provider.swarmRequest`, which is the recorded comment body minus a leading `/swarm`, trimmed, byte for byte (tested through the production input builder and envelope with a merged wake that contains an agent comment). The verified request. - The system prompt append: only Paperclip-authored text: Paperclip's fixed execution prompt, the run's hand-in values (the server-written completion revision and criterion IDs that `paperclip_finish`/`paperclip_block` require; never a criterion's requirement text), and the fixed swarm rules. **The swarm runs without the agent's own instructions**: the instruction bundle and connection instructions are left out, because an agent with an editable instructions folder can rewrite its instructions in an earlier ordinary run, the helpers act under auto mode, and Paperclip keeps no user-approved copy of those instructions to trust instead. - Tools: only Paperclip's own MCP bridge (any other assigned tool server refuses the swarm), with delegation, hiring, routing and generic API operations removed. Paperclip's permission handler approves a CLI permission request only when its tool name is `mcp_paperclip_<tool>` and `<tool>` is one the run's bridge admits; everything else is refused, and the CLI then ends the turn. Tool descriptions are Paperclip-authored; tool results (for example other comments) are data the coordinator reads, not the request. - Model and mode: the agent's configured model, Antigravity's `auto` mode, both read back and pinned by the receipt. - Not sent: task title, description, wake comments, continuation events, attachments, queued messages, handoff text. Known residual: a Retry or recovery run that has not yet been selected (still preparing) does not carry the request marker, so an Interrupt in that short window keeps the message for the turn boundary instead of stopping the run; the message is delivered after the run ends. - Off by default and local only. With the flag on, helpers act under Antigravity's `auto` mode. **Paperclip does not sandbox them on a local computer**, and their tool calls never reach Paperclip, so helper shell commands can write outside the task folder where the CLI's own sandbox allows (workspace plus temp directories). The settings text, the activity log and the plan doc say so. - On macOS the CLI uses its own Google sign-in from the login keychain, not Paperclip's stored connection. - Google's consumer terms have a clause about third-party tools that access the service. A legal read is pending; this PR does not claim compliance. - `/swarm` as the first word of a composer message is now a swarm request for every agent; for agents other than Google Antigravity the server refuses it with a plain message. To send the literal text, put other text first. - The new runner-e2e cells are attended only and have no automated executor. > 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`. Review round 2 (head |
||
|
|
8c04793a4a |
feat(google): delete content read from Google when access ends (#22836)
Every way a Google connection ends now starts the durable connection content deletion on its own, and Paperclip never resumes a cleaned harness session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
de4b60fc54 |
refactor(test): prune 28 completed migration, prose-grep, and Storybook fixture tests (#22832)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Over recent sprints, the test suite accumulated completed one-time SQL migration backfill tests, brittle static prose-matching guidance tests, and non-production Storybook fixture/prototype/feasibility-probe tests that add compile and CI maintenance cost without testing live behavioral invariants. > - Core database migration guards, active runtime migration services, security/safety static guards, and active adapter suites must stay intact. > - This pull request deletes 28 audited low-value test files (-1,894 LOC), preserves the one genuine schema validation assertion from `chat-communication-guidance.test.ts` inside `packages/shared/src/validators/chat-channels.test.ts`, prunes the 5 deleted server test keys from `scripts/general-server-shard-durations.json`, and refreshes `tests/runner-e2e/source-sdk-public-inputs.json`. > - The benefit is cleaner, higher-signal test coverage with zero lost invariants and synchronized SDK public source pins. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Test suite signal-to-noise ratio and maintenance overhead across `packages/db`, `packages/shared`, `packages/skills-catalog`, `server`, `ui/storybook`, `scripts`, and `tests/speko-voice-proof`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** 28 test files test already-shipped one-time migrations/dead backfills, static markdown/copy wording, non-production Storybook fixtures/prototypes, or a superseded voice feasibility probe. **Proposed behavior** Remove the 28 low-value test files while preserving all core migration integrity suites, active runtime migration services, security static guards, live adapter suites, and the genuine `updateChatEndpointSchema` assertion. ## What Changed - **Completed one-time migrations & dead backfills (3 files deleted, 444 LOC):** - Deleted `packages/db/src/better-auth-account-issuer-migration.test.ts`, `packages/db/src/chat-telegram-draft-ids-migration.test.ts`, and `server/src/__tests__/tool-oauth-legacy-backfill.test.ts` (zero production callers outside barrel re-export). - Retained all core DB migration guards (`check-migration-safety`, `migration-compatibility`, `migration-snapshot-drift`, `check-pr-migration-order`) and active runtime migration/legacy-recovery services. - **Brittle static prose/wording grep tests (9 files deleted, 317 LOC):** - Deleted `packages/shared/src/connection-intent-guidance.test.ts`, `packages/shared/src/telemetry/readme-contract.test.ts`, `packages/skills-catalog/src/release-content-cases-contract.test.ts`, `server/src/__tests__/secret-entry-guidance.test.ts`, `server/src/__tests__/primary-agent-guidance.test.ts`, `server/src/services/chat-communication-guidance.test.ts`, `server/src/services/onboarding-greeting.test.ts`, `ui/src/lib/agent-onboarding-prompt.test.ts`, and `ui/src/lib/grok-bot-setup-prompt.test.ts`. - Moved the one genuine schema validation assertion (`updateChatEndpointSchema` `communicationInstructions`) into `packages/shared/src/validators/chat-channels.test.ts`. - Retained `cli-invocation-safety.test.ts` and all real security/auth/prompt-injection guards. - **Non-production Storybook fixture / prototype / feasibility-probe tests (16 files deleted, 1,182 LOC):** - Deleted 10 Storybook fixture/prototype/mock-API tests, 2 unreferenced Storybook audit script tests, and 4 superseded `tests/speko-voice-proof/*.test.mjs` feasibility probe tests. - **Manifest & SDK pin hygiene:** - Pruned the 5 deleted server test keys and reconciled coverage counts in `scripts/general-server-shard-durations.json`. - Synced `tests/runner-e2e/source-sdk-public-inputs.json` via `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --write` (0 files deleted under `tests/runner-e2e/`). ## Verification - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capabilities aligned) - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (588 nightly suites validated) - `pnpm exec vitest run` on retained suites (`chat-channels`, `telemetry`, `skills-catalog`, `check-migration-safety`, `migration-compatibility`, `migration-snapshot-drift`, `runner-api`) — **15/15 files, 2,532/2,532 PASS** - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` and `vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs` — **PASS (13/13)** - `node --test scripts/typecheck-test-programs.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/storybook-catalog.test.mjs` — **103/103 PASS** - Typecheck (`@paperclipai/shared`, `@paperclipai/db` incl. `check:migrations`, `@paperclipai/skills-catalog`, `node scripts/ci-typecheck-lane.mjs --typecheck-ui`) — **PASS (0 errors)** ## Risks - Low risk: zero production code changed, zero core DB migration or auth/security guards removed, and zero dangling references across `maps/`, `scripts/`, `.github/`, or `tsconfig*.json`. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local test execution (`typecheck-opt`, `verifier`, `ci-pipeline`). ## 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 |
||
|
|
c9edffe605 |
fix(claude-local): label ACP usage rows from the run's AI connection (#20955)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A `claude_local` agent can run on a managed AI connection. The connection supplies the credentials and the routing, for example OpenRouter or a gateway. > - Each run writes usage rows to the cost ledger. The rows carry a provider, a biller, a billing type and a model. > - The ACP lane of the Claude adapter finds the billing identity from the agent environment only. It treats a run as API-billed only when `ANTHROPIC_API_KEY` is set. > - A managed connection with bearer auth sets `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL`. It does not set `ANTHROPIC_API_KEY`. The run is therefore labeled `anthropic` with the subscription billing type, and the ledger records zero cost. > - The ACP bridge also reports its own model alias (for example `opus`) as the current model. The usage row then names that alias, not the model that the endpoint received. > - This pull request resolves the billing identity from the managed AI connection first. It also names the requested model on usage rows for those runs. > - The benefit is that runs on an api_key connection show as metered API usage with the correct provider and model in Costs. ## Linked Issues or Issue Description Refs #18540 This pull request fixes the labels for the ACP lane. The Claude CLI lane (`resolveClaudeBillingType`) and the price estimate stay open. Related pull requests that I found. None of them changes the ACP billing identity: - #12000 (`fix(claude-local): distrust gateway-reported costs`) is open. It touches the Claude CLI lane and the cost estimate. - #11420 (`fix(pi-local): report a real billing type instead of hardcoding unknown`) is open. It fixes the same kind of label problem in the Pi adapter. The report in #18540 also names a second problem. Claude Code estimates the price with Anthropic list prices. This pull request does not change that estimate. ## What Changed - `claude-local/src/server/acp-billing.ts` (new): `resolveManagedApiKeyBilling` reads the managed AI connection. For an `api_key` connection it returns the billing type `metered_api`. The provider and the biller are the connection provider. Bedrock routing bills `aws_bedrock`. `resolveEnvBillingIdentity` holds the existing env-based classification, moved out of `acp.ts` unchanged. This keeps `acp.ts` under 1,000 lines. - `claude-local/src/server/acp.ts`: `resolveClaudeAcpBillingIdentity` tries the managed connection first. Other runs, subscription connections included, keep the env-based result. - `adapter-utils/src/acpx-engine/execute.ts`: the ACPX billing identity gets an optional `preferRequestedModel` flag. The two accounting-model calls pass it on. - `adapter-utils/src/acpx-engine/accounting-model.ts`: `acpxAccountingModel` takes an options argument. With `preferRequested`, it returns the requested model, or `null` when the run requested none. - Tests: `acp.test.ts` covers gateway, OpenRouter, local, Bedrock and subscription connections. `accounting-model.test.ts` covers the new option. `execute.test.ts` checks that the usage row and the result name the requested model with the flag, and the bridge model without it. ## Verification - `corepack pnpm install --frozen-lockfile`: succeeded. - `corepack pnpm vitest run src/acpx-engine/accounting-model.test.ts src/acpx-engine/execute.test.ts` (in `packages/adapter-utils`): 2 files, 271 tests passed. - `corepack pnpm vitest run src/server/acp.test.ts` (in `packages/adapters/claude-local`): 1 file, 46 tests passed. - `corepack pnpm --filter @paperclipai/adapter-utils typecheck`: passed. - `corepack pnpm --filter @paperclipai/adapter-claude-local typecheck`: passed. - I did not run the full repository test suite. I did not run a live run against OpenRouter. ## Risks - Low risk. The new path applies only when the run config has a managed `api_key` connection. All other runs keep their current labels. A test checks the subscription case. - A run on an api_key connection whose config names no model now records no model on its usage row. Before, the row carried the bridge alias. - A connection that projects `ANTHROPIC_API_KEY` resolved to `api` before and resolves to `metered_api` now. `normalizeLedgerBillingType` in `server/src/services/heartbeat/run-state.ts` maps both values to `metered_api`, and the Anthropic and Codex pricing accept both. The ledger result is the same. - Runs on an api_key connection change from `subscription_included` to `metered_api`. Their cost is no longer forced to zero. Claude Code still supplies the cost estimate. For a routed model, that amount can differ from the amount that the provider bills. > 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 - Claude Code (Anthropic) with tool use (shell, file edits, test runs). Claude Fable 5.2 (`claude-fable-5-2`) directed the work. Claude Sonnet 5.5 (`claude-sonnet-5-5`) ported the change to current master and ran the tests. Claude Opus 5.5 (`claude-opus-5-5`) reviewed it. ## 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 - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] 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 |
||
|
|
ecef06d246 |
fix(agents): reject a blank taskKey on reset-session instead of resetting all task state (#19282)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Operators can reset an agent's runtime session with `POST /agents/:id/runtime-state/reset-session` > - A `taskKey` scopes the reset to one task. No key resets all task state. > - The schema accepted a whitespace-only `taskKey`, and the route changed it to `null` > - So a blank key took the full-reset path, and the activity entry recorded `taskKey: null` > - This pull request makes the schema trim the key and reject a blank key with a 400 > - The benefit is that a scoped reset request can never become a full reset by accident ## Linked Issues or Issue Description Fixes #19080 Refs #19005 (the parent issue that #19080 was split out of) I searched open and closed PRs for `19080`, `reset-session` and `resetAgentSessionSchema`. I found no related PR. ## What Changed - `resetAgentSessionSchema.taskKey` is now `z.string().trim().min(1).optional().nullable()`. A blank or whitespace-only key fails validation with a 400. An omitted key or `null` still requests the full reset. - The route uses the parsed `taskKey` directly. The schema already trims it, so the route no longer has its own trim-and-null step. - Added tests in `packages/shared/src/validators/agent.test.ts` for omitted, `null`, trimmed and blank keys. ## Verification - `pnpm exec vitest run packages/shared/src/validators/agent.test.ts`: 16 tests pass. - `pnpm exec vitest run cli/src/__tests__/agent-lifecycle.test.ts`: 4 tests pass. The CLI parses its payload with the same schema. - `pnpm --filter @paperclipai/shared typecheck` passes. - I ran the server `tsc` locally. It reported no errors in `server/src/routes/agents.ts`. My local Windows setup cannot build `@paperclipai/paperclip-runner`, so the full server typecheck depends on CI. ## Risks - Low risk. A client that sends `taskKey: ""` or a whitespace-only key now gets a 400 instead of a full reset. The board UI sends `null` or an issue id, and the CLI omits the key when `--task-key` is not set. Neither caller sends a blank key. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), used through Claude Code with tool use (shell, file editing). It assisted with code reading, the change, tests and this description. I reviewed the change. ## 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 - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
4401962e69 |
feat(google-workspace): run the six launch services on Google's MCP servers again (#22815)
Gmail, Drive, Docs, Sheets, Slides and Calendar go back to google_mcp because of Google's Workspace AI Tools Addendum; the REST tool set stays as the fallback. The REST argument checks that need no request to Google run before each MCP call, a Calendar delete reads the event first and refuses a recurring series, and a refresh that replaces saved REST definitions holds nothing for review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
71ff1c8600 |
fix(runner): read an assigned skill by its short name (#22813)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use saved company skills; on the native runner they read a
skill's files with `read_assigned_skill`
> - The daily QA staging smoke test `saved-skill-use` has been failing:
the agent finishes the task, but no skill read is recorded
> - The private run events show why: the agent called
`read_assigned_skill` with the skill's short name (`qa-saved-skill-…`),
the name the task gives it (`/qa-saved-skill-…`) and the skill's own
frontmatter `name`. The runner matches only the full company key
(`company/<id>/qa-saved-skill-…`) or the runtime name
(`qa-saved-skill-…--<hash>`), so it answered `runner_skill_not_assigned`
for a skill that was assigned. The agent then read the file with bash
> - This pull request lets the runner find an assigned skill by its
short name too
> - The benefit is that agents read saved skills through the verified,
pinned path the first time, instead of falling back to the filesystem
## Linked Issues or Issue Description
**Subsystem affected**
Native runner bridge tools (`read_assigned_skill`).
**Problem or motivation**
In the November 24 QA staging smoke run, `saved-skill-use` failed. Run
events (private QA evidence) show `read_assigned_skill` with
`{"skill":"qa-saved-skill-journey-…","path":"SKILL.md"}` returning
`{"outcome":"failed","code":"runner_skill_not_assigned"}`, followed by a
`bash` read of the same SKILL.md. The skill was in the agent's desired
skills and on disk.
**Proposed solution**
After the exact key/runtime-name match, accept the key's last part (with
or without a leading `/`) when exactly one assigned skill has it.
**Alternatives considered**
- Changing the task text or the test to pass the runtime name: the agent
is told `/short-name`; the product should accept what it tells agents.
- Matching the frontmatter `name`: the short name is already the key's
last part for company skills, and needs no file read before the lookup.
## What Changed
- `server/src/services/native-runtime/runner-bridge-tools.ts`:
`assignedSkillByName` finds an assigned skill by key, runtime name, or
unique short name; `readAssignedSkill` uses it.
- `server/src/services/native-runtime/runner-bridge-tools.test.ts`: the
short name (and `/short-name`) reads the skill; a short name two
assigned skills share names neither; the runtime name still
disambiguates.
## Verification
- `runner-bridge-tools.test.ts`: the new cases fail on master with
`runner_skill_not_assigned` and pass with the fix (red/green); 11
passed.
- Not run locally: server typecheck (this worktree's local
`paperclip-runner` build is stale; unrelated errors in other files). CI
typechecks the change.
- After deploy: the next QA staging smoke run's `saved-skill-use` should
record a native skill read.
## Risks
- Low. Lookup only widens to a unique short name among skills already
assigned to this run; it grants no access to unassigned skills, and
every file read keeps its manifest and digest checks.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, AWS CLI read of the private QA evidence, file edits).
## 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
- [x] 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>
|
||
|
|
94510d7b26 |
fix(github): settle request comments after deliberate waits and refused replies (#22798)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull request threads; each request's comment must end in a real reply or an honest final notice > - After #22672 and #22710, 13 of 85 new review-bot comments on staging still ended as status notices, and 10 old placeholders on merged PRs never settled > - Run data on staging shows two causes: runs that yield on purpose to wait for a response (`external_chat_response_waiting`), and runs whose final reply was refused (`responsePublication.state = failed`) > - The first marked inline threads "ended without publishing" while a later run posted the review; the second looked like presentation still pending, forever > - This pull request makes both settle: link the latest response, wait while the task is open, and use the honest notice only when nothing was published > - The benefit is that every request comment ends in a useful final state ## Linked Issues or Issue Description Refs #22672, #22710 **Describe the bug** - On #22732 the author replied on five review threads at once. Each reply woke its own run; those runs yielded with `external_chat_response_waiting`, and a later run posted the review. Four threads still ended with "This turn ended without publishing a final response." - On #22658 (and the other merged PRs with stuck "Working on this…"), the request's run finished `succeeded`/`committed` with no presentation decision because its final reply publication failed after 6 attempts (`publication_refused`). The settle logic treated that as presentation pending and never settled the thread. **Steps to reproduce** 1. An inline request's run yields with a response-wake continuation; a later run publishes a review. 2. Or: an inline request's run finishes with `responsePublication.state = "failed"` and no presentation decision. 3. The thread says "ended without publishing" (1) or stays "Working on this…" forever (2). **Expected behavior** The thread links the latest published response, waits while the task is still open, and otherwise ends with an honest notice. ## What Changed - `githubLatestTaskResponseUrl`: the latest processed GitHub publication (comment, formal review, assessment) for the task after the request arrived. - `githubResponseExecution`: when the request's run did not reply, link that latest response if any. An inline request whose run deliberately waits keeps waiting while the task is open. A run whose reply was refused says so. The main PR comment keeps its passive-wait cancellation (`mainPullResponse`). - `nativePresentationPending` is false when `responsePublication.state = failed`; new `responsePublicationFailed` column. - Terminal sweep decision version is now `v3`, so requests parked under v2 are read again once. ## Verification - New integration tests (red on master, green here): links a waited thread to a later response; settles a waited thread when the task finishes with no response; settles a thread whose run's reply could not be published. - Updated `keeps per-request fallback outside the main GitHub PR review wait`: waits while the task is open, then settles when done. - `keeps native presentation idle until its committed GitHub outcome` (main PR passive) still passes. - `server/src/services/chat-channels/github/` and response comment tests: 67 passed. GitHub integration group: 538 passed before the main-PR scoping fix; the two affected tests pass after it. - After deploy: re-measure the stuck rate on staging for comments created after the deploy. ## Risks - One extra indexed query per request that settles without its own reply (to find the latest response). Settled requests leave the backlog. - A waited inline thread stays "Working on this…" while its task is open and nothing was published yet; that is the honest state. - Separate, not fixed here: why the native finalizer refuses some final replies (`publication_refused`). ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## 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> |
||
|
|
cffd17e78a |
perf(ci): Phase 3 PR CI under 3m — 4x Runner support, 12x E2E, incremental TS 7 cache, pure-Node postinstall, and rebalanced shards (#22804)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI verifies every change before merge across build, typecheck, server tests, Runner tests, and Playwright E2E shards. > - After Phase 1 (#22679) and Phase 2 (#22729), full-fanout PR CI still takes 9m45s wall-clock on 4-core AWS runners because of five bottlenecks: an unsharded 7m22s `Runner support suite`, stale server/chat/Runner shard duration manifests plus newly landed SSH/soak whales, 28s of `pnpm -r run postinstall` replay on every job, cold server/UI typecheck and single-build overhead, and 3 oversized (>180s) Playwright E2E specs across 8 shards with double-start Postgres template boot. > - Docs-only prose edits under `doc/**` and `docs/**` also fanned out to 66 CI jobs because only three doc paths bypassed global dependencies. > - This pull request shards `Runner support suite` 4 ways with `pool: "threads"`, shards E2E 12 ways after splitting the 3 oversized specs and removing double-start Postgres boot, adds pure-Node workspace postinstall replay, adds read-only master-warmed incremental TS 7 and Runner dist caches, rebalances all server/chat/Runner duration manifests, demotes 48 new non-invariant soak whales to nightly, and routes audited prose docs without triggering 66-job storms. > - The benefit is driving ordinary PR CI toward under 3 minutes wall-clock while preserving every invariant check, cache boundary, and full master/nightly test coverage. ## Linked Issues or Issue Description Refs #22679 Refs #22729 **What existing behavior does this improve?** Pull request CI wall-clock latency across `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`, `.github/actions/setup-ci-dependencies/action.yml`, typecheck orchestration, Vitest/Runner lanes, and Playwright E2E shards. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Full-fanout PR CI takes 9m45s on 4-core runners (run `45440355579`), dominated by `Runner support suite` (7m22s), `e2e shards` (5m02s–6m24s), `General tests (server/chat)` (5m37s–6m01s), `Verify Paperclip Runner (vitest package)` (6m25s on stale manifests), `Typecheck` (4m13s–6m30s), `Build` (~4m), and 28s of `pnpm -r postinstall` per job. Prose edits under `doc/**` trigger 66 jobs. **Proposed behavior** Shard `Runner support suite` (4x) and `e2e_shards` (12x), split the 3 oversized E2E specs, boot disposable E2E Postgres in a single non-durable start, replay workspace `postinstall` in pure Node (<1s), cache prebuilt Runner dist and TS 7 `.tsbuildinfo` from canonical `master` pushes (read-only in PRs), use emit-only server compile in ordinary PR `Build`, rebalance all shard duration manifests, demote 48 new non-invariant soak whales to nightly, and route audited prose docs cleanly. ## What Changed - **Pure-Node postinstall replay (`scripts/replay-workspace-postinstall.mjs`, `.github/actions/setup-ci-dependencies/action.yml`):** Replaces the 28s `pnpm -r --if-present run postinstall && pnpm run postinstall` call on every CI job with a pure-Node parallel runner (~0.84s locally) with fallback for older checkouts. - **4-way sharded `Runner support suite` + `threads` pool (`.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`, `tests/runner-e2e/run-unit.mjs`, `tests/runner-e2e/vitest.config.ts`):** Shards Vitest and `node:test` suites 4 ways (`--shard-index 0..3 --shard-count 4`) and switches `tests/runner-e2e` to `pool: "threads"` with CPU-aware `maxWorkers` while preserving `isolate: true`. - **12-way E2E shards, single-start E2E Postgres boot, and 3 oversized spec splits (`tests/e2e/start-e2e-server.ts`, `tests/e2e/*.spec.ts`, `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/ci-task-matrix.json`):** Boots cold ephemeral E2E Postgres in one `initdb --no-sync` + non-durable `postgresql.conf` start overlapped with server module import; splits `agent-chat-projects`, `chat-adapters-ui-providers`, and `chat-adapters-ui-messaging` cleanly with zero tests removed; balances all 54 specs across 12 shards (6.8s spread). - **Incremental TS 7 typecheck & Runner dist caching (`server/scripts/typecheck-layers.mjs`, `scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/typecheck-test-projects.mjs`, `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`):** Preserves portable `.tsbuildinfo`/`.d.ts` with `layer-map.json` invalidation and stale-declaration pruning, wires read-only `runner-dist-v1` and `typecheck-incremental-v1` restores in `pr-trusted.yml` (zero `actions/cache/save`) paired with canonical-`master`-only guarded writers in `release-verify.yml`, skips redundant Runner Rust `cargo check` on TS-only shared PRs, and uses LPT scheduling with concurrency 3 (4-core) / 4 (8-core). - **Emit-only PR `Build` & audited prose doc routing (`.github/workflows/pr-trusted.yml`, `.github/scripts/ci-inputs.mjs`):** Passes `PAPERCLIP_TSC_EMIT_ONLY=1` on ordinary PR `Build` jobs (full `pnpm build` on `full-ci` / `master`), and classifies audited prose Markdown under `doc/**` and `docs/**` as `guidance` / `historical` while keeping `docs/api/**`, JSON/TS fixtures, `maps/**`, and unknown files fail-closed. - **Rebalanced shard manifests & new soak demotions (`scripts/ci/nightly-only-suites.json`, `scripts/*-shard-durations.json`, `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `packages/paperclip-runner/vitest.config.ts`, `packages/paperclip-runner/scripts/vitest-sequencer.mjs`):** Demotes 48 newly landed/grown non-invariant soak suites (including 4 real-SSH integration suites) to nightly, refreshes all 4 timing manifests from live CI measurements (0.1s–0.6s LPT skew), and scales Runner package Vitest CI `maxWorkers` to 3 on 4-core / 6 on 8-core. ## Verification - `node --test .github/scripts/tests/*.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/runner-vitest-package-lanes.test.mjs scripts/typecheck-test-programs.test.mjs scripts/check-test-budget.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/test-selection-timings.test.mjs` — **973/973 PASS** - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (`609` nightly suites validated, zero protected invariants demoted) - `node scripts/check-maps.mjs` — **PASS** - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs tests/runner-e2e/unit-launcher.test.mjs` — **PASS** - `pnpm --filter @paperclipai/paperclip-runner exec vitest run scripts/vitest-sequencer.test.mjs` — **PASS** - `cd server && node ../node_modules/vitest/vitest.mjs run scripts/typecheck-layers.test.mjs scripts/typecheck-layers-incremental.test.mjs` — **56/56 PASS** (real TS 7.0.2 incremental soundness tests) - `node scripts/run-tsc.mjs -p tests/e2e/tsconfig.json --noEmit && node scripts/run-tsc.mjs -p tests/tsconfig.playwright.json --noEmit && pnpm run test:e2e:runner:typecheck` — **0 errors** - Live Playwright smoke passed across all 6 split E2E spec files on the cold non-durable Postgres boot path (`PAPERCLIP_TEST_POSTGRES_TEMPLATE=0`). - Live sharded `tests/runner-e2e` runs passed under `pool: "threads", maxWorkers: 4` (shard `1/4` 172/172 PASS; shard `2/4` all Vitest + 65/65 `node:test` PASS). ## Risks - **Cache invalidation on incremental typecheck / Runner dist:** Mitigated by exact-key hashing (including `packages/{shared,adapter-utils,plugins/sdk}/src/**` and `packages/paperclip-runner/spec/**`) with no `restore-keys:` on `runner-dist-v1`, SHA-256 self-validation inside `prepare-runner-vendor.mjs`, `layer-map.json` invalidation + stale `.d.ts` pruning in `typecheck-layers.mjs`, and read-only PR restores (only canonical `master` pushes save caches). - **Shard rebalancing & soak demotions:** All demoted suites remain in `nightly-only-suites.json` and run on `full-ci` / `master` / nightly; `check-test-budget.mjs` enforces zero protected invariants are demoted. - **Workflow security boundaries:** `ci-routing.yml`, `pr.yml`, `CODEOWNERS`, and all `runs-on:` expressions are unchanged; `pr-trusted.yml` performs zero `actions/cache/save` calls. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local code/test execution across 6 parallel worker roles (`ci-pipeline`, `vitest-runner`, `server-prune`, `e2e-opt`, `typecheck-opt`, `verifier`). ## 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 |
||
|
|
3ca9b6d471 |
refactor(plugin-sdk): remove archivedState from the resume result (#22443)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native Runner sessions can run in a remote environment task that a plugin provider owns > - A provider can relaunch a parked Runner as the next run, and it reports the result to Core > - The resume result could carry `archivedState`, so Core could check that the park was a settled cut > - #22442 makes the provider the authority on the park, and Core stops reading `archivedState` > - This pull request removes the field from the SDK result schema > - The benefit is a smaller provider contract with no unused fields ## Linked Issues or Issue Description Refs #22442 **What existing behavior does this improve?** The environment task resume result contract in the plugin SDK. **Subsystem affected** `packages/plugins/sdk` (environment tasks), and the tests in `server/src/services/native-runtime` that build resume results. **Current behavior** After #22442, a resumed relaunch result can carry an optional `archivedState`. Core accepts it and does not read it. **Proposed behavior** The resume result has no `archivedState` field. The strict schema refuses it. **Reason and benefit** The field has no reader. Removing it keeps the contract to the fields that Core uses. **Breaking changes** A provider that still sends `archivedState` on a resume result fails the schema check, and the relaunch fails. Deploy this with or after the provider change that stops sending the field. **Additional context** Stacked on #22442. ## What Changed - SDK: removed `archivedState` from the `resume` result schema, and simplified the relaunch check in `parseEnvironmentTaskResult`. - SDK test: a relaunch result with `archivedState` now fails; one without it passes. - `plugin-runner-task.test.ts`: removed the field from the fixtures, and removed the test that checked Core ignores it. - `plugin-runner-release-resume.integration.test.ts`: the fixture provider no longer returns the field. - `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md`: removed the note about the field. ## Verification - `pnpm run typecheck` in `server` (builds all dependent packages): pass. - `pnpm vitest run src/services/native-runtime/plugin-runner-task.test.ts` in `server`: 116 passed. - `pnpm vitest run tests/environment-task-release-resume.test.ts` in `packages/plugins/sdk`: 48 passed. - I did not run the embedded-Postgres integration suite locally. CI runs it. ## Risks - A provider that still sends the field makes the relaunch fail. Deploy this with or after the provider change that stops sending it. It can ship in the same deploy as #22442. - Low risk otherwise: the change removes an unused optional field. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (shell, file edit, code search). Extended thinking on. ## 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 - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0b2acfb956 |
refactor(runner): let the provider decide whether a released Runner relaunches (#22442)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native Runner sessions can run in a remote environment task that a plugin provider owns > - After a turn, the provider can park the Runner, and the next run can relaunch it from the saved state > - Core kept its own local record of each released Runner, and the provider kept its park record too > - Core lost its copy when the local session directory was not durable. Then Core restored from a checkpoint although a park existed, and the turn was slower > - This pull request makes the provider the only authority on the park. Core resumes the source from its durable checkpoint, and the provider answers "resumed" or "unavailable" > - The benefit is fewer missed relaunches, and less code in Core ## Linked Issues or Issue Description **What existing behavior does this improve?** The relaunch of a parked Runner for the next run of a native session. **Subsystem affected** Native runtime: `server/src/services/native-runtime`, the Runner control plane in `packages/paperclip-runner`, and the environment task SDK. **Current behavior** Core writes a released-Runner record (source identity, task id and scope digest) to the local session directory when a release completes. Core relaunches a parked Runner only when that record exists. Core also checks the archived Runner state on the provider's relaunch reply. When the local directory is gone (for example, after the server process restarts on a new host), Core restores from a checkpoint into a fresh task, although the provider still has the park. **Proposed behavior** Core resumes the source identity from its durable controller checkpoint on the lease's current task. The provider decides from its own park record. When no park of that source exists, the provider answers `unavailable`, and Core starts a fresh task from the saved session, as it does today for other unavailable answers. **Reason and benefit** One record for one fact. Core no longer needs local state to relaunch, so more runs relaunch. The change removes about 160 lines. **Breaking changes** A provider must answer `unavailable` when it has no park for the requested source. A provider that answers with an error instead makes the resume fail. The `archivedState` field on a resumed relaunch result becomes optional. Providers can continue to send it; Core does not read it. **Additional context** Reattach to a live Runner process in the same server is not changed. A relaunch after a restart still requires the process configuration to match, because the relaunch reuses the parked launch. A changed configuration starts a fresh task. ## What Changed - Removed the local released-Runner record: its writer, its readers, the scope digest, and the resume and retire callbacks that cleared it. - Derived the relaunch source from the durable Runner identity. Kept the check that the task is the lease's current task. - After a restart, Core takes the released source from the durable identity for every provider that releases tasks: one that relaunches the parked Runner, and one that hands it over. - Added a test that a checkpoint saved with the old released-Runner record still loads. - When a restart recovery resumes a released source and the provider answers `unavailable` with the task stopped and its state saved, Core now starts a fresh task from the saved session, as it does for a relaunch. The fallback finishes the old task's startup context before it inspects the replacement task. An executor test covers this path. - Updated the SDK source pin in `tests/runner-e2e/source-sdk-public-inputs.json`. - Stopped the check of the archived state on the relaunch reply. Removed `isSettledReleasedRunnerCut` and the resume `settled` hook. - SDK: a resumed relaunch result no longer requires `archivedState`. - Updated `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and the tests. ## Verification - `pnpm run typecheck` in `server` (builds all dependent packages): pass. - `pnpm vitest run src/services/native-runtime/plugin-runner-task.test.ts src/services/native-runtime/remote-warm-session-recovery.test.ts` in `server`: 147 passed. - `pnpm vitest run src/services/native-runtime/native-session-executor.test.ts -t "releases settled|accepts only the attached|released|relaunch|warm|unavailable|recover"` in `server`: 594 passed. - `runnerd-codex-transport.test.ts` in `packages/paperclip-runner`: 337 passed. - SDK release and resume tests in `packages/plugins/sdk`: 48 passed. - `runnerd-codex-transport-release-resume.test.ts -t relaunched` in `packages/paperclip-runner`: 3 passed. `pnpm run typecheck` in `packages/paperclip-runner`: pass. - `tests/runner-e2e/source-sdk-public-inputs.test.mjs`: 13 passed. - `plugin-runner-release-resume.integration.test.ts -t "completes claude runs through a retained adopted process"`: pass. I did not run the rest of the two embedded-Postgres integration suites locally. CI runs them. ## Risks - A provider that does not answer `unavailable` for a missing park makes the resume fail. Deploy the provider change first, or in the same deploy before this Core version takes traffic. This PR and #22443 are one stack and can ship in one deploy. - A server restart now relies on the existing unavailable-reuse fallback to start a fresh task. Tests cover this path. - Medium risk overall: the change is in the warm-session path. The cold path is not changed. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (shell, file edit, code search). Extended thinking on. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8b616b949d |
fix(connections): drop MCP wording and the MCP guide link from Google Workspace setup (#22793)
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents use Google Workspace through the built-in Google Workspace connection > - Since #22634, Gmail, Drive, Docs, Sheets, Slides, and Calendar run on Paperclip's own REST tools, not on Google's hosted MCP servers > - The connect screen still showed "Secure MCP sign-in" and a "Review requirements" link to Google's MCP servers guide > - This text is wrong for this connection, it is internal jargon, and Google's OAuth reviewers read this screen > - This pull request removes the MCP wording and the MCP guide link from Google Workspace setup and from its audit details > - The benefit is that users and reviewers see only true, plain text for this connection ## Linked Issues or Issue Description Refs #22634 **What happened?** On a Cloud workspace, the Google Workspace connect page showed the subtitle "Secure MCP sign-in" while the sign-in opened and after it failed to open. The setup page also showed a "Review requirements" link to `developers.google.com/workspace/guides/configure-mcp-servers`. On a self-hosted instance, the "How to set up a Google OAuth client" link went to the same MCP servers guide. Audit details for a Google REST call showed "Transport: mcp_remote" and "MCP method: tools/call". **What did you expect to happen?** The connect page says "Secure sign-in". The Paperclip-managed method on Cloud has no requirements link, because the user has no requirements to review. On a self-hosted instance, the customer-owned client method links to Google's OAuth client guide. Audit details for a Google REST call do not show MCP terms. **Steps to reproduce** 1. Turn on the Google Workspace connector in **Settings → Experimental**. 2. Open **Apps** and choose **Google Workspace**. 3. Start the sign-in, then close or block the sign-in window. 4. Before this change: the header shows "Secure MCP sign-in", and the setup step shows "Review requirements" with a link to Google's MCP servers guide. ## What Changed - `ui/src/features/connections/ConnectionSetupFlow.tsx`: `OAuthConnectStateScreen` shows "Secure sign-in" for a curated app. A server that the user pasted as an MCP server keeps "Secure MCP sign-in". This is generic: there is no Google-specific code. - `packages/shared/src/app-definitions/google-workspace.json`: remove the top-level `docsUrl` (the MCP servers guide). The Paperclip-managed method now has no "Review requirements" link. The customer-owned method's `consoleLinks.docs` is now Google's OAuth client guide (`create-credentials#oauth-client-id`). The "Review requirements" link and the self-hosted "How to set up a Google OAuth client" link both use it. Its guidance text names the Gmail, Drive, Docs, Sheets, Slides, and Calendar APIs instead of "the Google Workspace MCP APIs". This file is a reviewed definition: `scripts/ingest-app-definitions.mjs` copies it as-is, so a regeneration keeps the fix. - `server/src/services/tool-gateway.ts`: an audit record for a Google Workspace REST call no longer has `mcpMethod`. - `ui/src/pages/tools/AuditTab.tsx`: audit details show the connection type label ("Remote HTTP") as "Type" instead of the raw `mcp_remote` value. This uses the same label as the connection's "Connection details". - `doc/connections/GOOGLE-WORKSPACE.md`: the self-hosted section links Google's OAuth client guide. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed pinned inputs. ## Verification - Red first, then green: - `packages/shared/src/google-workspace-setup-links.test.ts`: no Google Workspace method links the MCP servers guide, the managed method has no requirements link, the customer method links the OAuth client guide, and method text has no "MCP". It failed 4/4 before the fix. - `ui/src/features/connections/OAuthConnectStateScreen.google.test.tsx`: in the preparing, opening, and "couldn't open the sign-in window" states, the Google Workspace screen shows "Secure sign-in", no "MCP", and no link to `configure-mcp-servers`. A pasted server keeps "Secure MCP sign-in". It failed 3/4 before the fix. - `server/src/__tests__/google-workspace-rest-transport.test.ts`: the Gmail REST audit record has no `mcpMethod`. It failed without the server change. - `npx vitest run` for shared app definition tests (67 passed), `ui/src/pages/tools` and `ui/src/pages/apps/app-detail` (121 passed), and the server REST transport file (53 passed). - `tsc --noEmit` for `server` and `ui`: no new errors. - `pnpm verify` exits 2 because a doc under `doc/connections` is a global CI input. Required CI supplies the broad coverage. ## Risks - Low risk. Text and link changes only, plus one optional audit field. - Other curated OAuth apps now show "Secure sign-in" instead of "Secure MCP sign-in" on the sign-in state screen. The new text is true for every curated app. - Audit details for all connectors show "Type: Remote HTTP" instead of "Transport: mcp_remote". - Saved Google Workspace connections still show `https://workspacemcp.googleapis.com/mcp/v1` as the address in "Connection details". It is the stored connection identity. This pull request does not change stored data. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Claude Code agent with tool use and code execution. ## 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 - [x] 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> |
||
|
|
4daeab5c76 |
Add count, newest-first and lean run reads to customer-success inspection (#22781)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip Cloud can inspect a tenant stack read-only through the
customer-success inspection API
> - That API can only list rows in id order. It has no totals, and each
run row holds large JSON columns
> - A customer-success agent must page every run of a stack to find the
latest run or the failed-run total
> - That is too slow and too large for a refresh across many stacks
> - This pull request adds a `count` operation, a creation-time `order`
for lists, and a lean `summary` view for runs
> - The benefit is one small read per metric, with the same read-only,
company-scoped rules
## Linked Issues or Issue Description
**Subsystem affected**
Server: the customer-success inspection API (`/api/customer-success/v1`)
and its shared query contract.
**Problem or motivation**
Customer-success inspection reads cannot answer summary questions. To
get the latest run, the run count or the failed-run count, a reader must
page through every run. Each run row can be hundreds of KB, because it
holds the result, usage, context snapshot and runner profile.
**Proposed solution**
Add read-only summary reads to the inspection contract: a `count` that
groups by status, a newest-first or oldest-first `order` for `list`, and
a `summary` view of runs without the large JSON columns.
**Alternatives considered**
Paging all runs with a smaller page size. That still reads every large
row. A new aggregated endpoint outside the reader catalog. That would
skip the existing catalog, permit and transaction rules.
## What Changed
- `packages/shared/src/customer-success.ts`: add the `count` operation,
`order` (`newest`/`oldest`, `list` only), `view` (`summary`, `runs`
list/get only), `InspectionCount`, and `inspectionReadPath()`. The
parser rejects these fields where they do not apply.
- `server/src/services/customer-success-inspection.ts`: `count` returns
`{total, byStatus}` (grouped by the reader's `status` column, or
`byStatus: null`). `order` sorts by `createdAt`, then id. `view:
"summary"` selects the `RUN_SUMMARY_COLUMNS` allowlist and adds
`durationMs`. All reads stay in the same read-only, repeatable-read
transaction and keep the existing run redaction.
- `server/src/routes/customer-success.ts`: serve the same handler on
`/read` and the new `/read-v2`. `/read` refuses queries that use the new
features. A tenant without `/read-v2` answers 404, so Cloud fails closed
with `tenant_inspection_version_unsupported`.
- `server/src/__tests__/customer-success.test.ts`: tests for counts,
company scope, newest-first paging, the summary allowlist and duration,
parser bounds, and the path split.
- `server/src/__tests__/customer-success-cloud.test.ts`: the registry
double now has the batch reads (`getStacks`, `getAccounts`) that the
current Cloud broker uses. The test also runs a count and a newest-first
summary read end to end.
- `server/src/__tests__/openapi-routes.test.ts`: list `/read-v2` with
the other inspection protocol routes.
- `doc/CUSTOMER-SUCCESS-INSPECTION.md`: document the summary reads and
the path split.
## Verification
- `cd server && pnpm exec vitest run
src/__tests__/customer-success.test.ts
src/__tests__/openapi-routes.test.ts
src/__tests__/customer-success-run-liveness.test.ts`: 78 tests pass.
- Red check: the new count/order/summary test fails against the previous
service (`Unsupported inspection operation`).
- Coordinated qualification with a local build of the Cloud broker
branch: `PAPERCLIP_INSPECTION_CLOUD_DIST=… pnpm exec vitest run
src/__tests__/customer-success-cloud.test.ts` passes, including the
count and newest-first summary reads over `/read-v2`.
## Risks
- Low risk. The new features are read-only and use the existing catalog,
company boundary, permit check and read-only transaction.
- The summary view is an allowlist. A new run column stays out of the
summary until someone adds it.
- Mixed versions are safe in both orders. An older Cloud never sends the
new fields. A newer Cloud sends them only to `/read-v2`, and an older
tenant answers 404 there.
- No migration.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits) and extended thinking.
## 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: Paperclip <noreply@paperclip.ing>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
0731cd3afc |
perf(ci): Phase 2 PR CI under 4 minutes (dynamic workers, fast E2E boot, typecheck overlap, test-budget gate) (#22729)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Pull-request CI checks run on every commit before maintainers can merge code > - PR #22679 cut PR CI from 15–30+ minutes down toward 4.5–5.5 minutes on 4-core runners > - Remaining wall-clock bottlenecks sit in unsharded `workspaces-b`, serial typecheck preparation, E2E server/UI startup, fixed Vitest worker caps, and remaining soak and duplicated UI tests > - This pull request adds Phase 2 optimizations across server soak triage, typecheck DAG overlap, E2E fast boot and shard balance, dynamic CPU-aware workers, pure-Node workspace link preflight, UI pruning, and permanent test-budget enforcement > - The benefit is ordinary feature PRs finish in ~3.1–3.8 minutes on 4-core runners and scale automatically to ~2.0–3.0 minutes on 8-core runners while keeping core invariants and nightly coverage intact ## Linked Issues or Issue Description Refs #22679 **Problem Statement** After #22679 landed, several PR lanes still took 4.5–6 minutes on 4-core runners (`general-workspaces-b` ran unsharded, `Typecheck + Release Registry` waited on a serial server build before starting UI and test-program checks, E2E shards paid full `cli onboard` + minified UI build overhead, and Vitest worker counts did not scale with runner CPU count). **Proposed Solution** Split `general-workspaces-b` across two duration-balanced shards, overlap typecheck preparation tasks behind a shared runner-vendor node, replace E2E `onboard` with a direct template-PG boot + unminified inline UI build, scale Vitest/Playwright/Typecheck workers dynamically by CPU and RAM, replace `tsx` in workspace-link preflight with pure Node, prune redundant mocked UI tests and additional real-clock server soak suites (still run on `master`, `release-verify`, `cloud-readiness`, and `PAPERCLIP_CI_FULL=1`), and add a permanent test-budget policy check. **Expected Benefit** Brings ordinary PR CI wall-clock down to ~3.1–3.8 minutes on 4-core runners (and ~2.0–3.0 minutes on 8-core runners) with automated guardrails against future test-time regressions. ## What Changed - **Server soak triage & permanent test-budget guardrail (`scripts/ci/nightly-only-suites.json`, `rules/test-budget.mdc`, `.greptile/files.json`, `scripts/check-test-budget.mjs`, `scripts/check-test-budget.test.mjs`, `.github/workflows/pr-trusted.yml`):** Expanded the PR-excluded soak/heavy-integration manifest to 568 genuine heavy suites (preserving 100% of company isolation, authz, checkout, approval, budget, activity-log, security, telemetry, and serialized suites on every PR) and wired `node scripts/check-test-budget.mjs` into the `policy` job. - **Typecheck DAG overlap & CPU/RAM scaling (`scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/__tests__/ci-typecheck-lane.test.mjs`, `scripts/typecheck-test-programs.test.mjs`):** Moved `build server without type checks` and `check server runtime assets` out of serial `prepare` into parallel DAG nodes behind `prepare runner vendor`, added `computeResourceProfile` scaling across 2/4/8-core runners, and added missing UI/Runner consumer routing inputs (`packages/paperclip-runner/` for `@paperclipai/ui`, `packages/adapter-utils/` for Runner test programs). - **E2E fast boot, dynamic workers & 8-shard rebalance (`tests/e2e/start-e2e-server.ts`, `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`):** Added direct throwaway template-PG boot (`fsync=off`), unminified inline Vite fallback build, dynamic parallel workers (`min(4, floor(cpus/2))`), empirical `1.5x` parallel speedup weighting across 8 shards, targeted trims to slowest E2E specs, and hashed workspace `package.json` manifests into the `e2e-ui-dist-v2` cache key. - **Dynamic Vitest workers, 2-shard `workspaces-b`, and pure-Node preflight (`scripts/ci/vitest-workers.mjs`, `scripts/ci/workspaces-b-shard.mjs`, `scripts/ensure-workspace-package-links.mjs`, `scripts/ci-dependency-cache.mjs`, `packages/db/src/test-embedded-postgres.ts`, `.github/ci-task-matrix.json`, `.github/actions/setup-ci-dependencies/action.yml`, `package.json`):** Scaled Vitest workers dynamically (`4→7` general, `3→5` serialized) with `max_connections=300` before PostgreSQL start, split `general-workspaces-b` into 2 duration-weighted shards (backward-compatible unsharded for release workflows), replaced `tsx` workspace-link preflight with pure Node (~29× faster), and parallelized `ci-dependency-cache.mjs` child queries. - **UI Vitest worker scaling, fake timers & E2E-duplicated suite pruning (`ui/vitest.config.ts`, 4 `maps/` files, and UI test suites):** Scaled UI `maxWorkers` dynamically, converted real-clock sleeps in kept suites to fake timers, removed 34 E2E-duplicated mocked jsdom suites, and updated corresponding `maps/` prose references. ## Verification - `node --test .github/scripts/tests/ci-plan.test.mjs .github/scripts/tests/ci-dependency-cache.test.mjs .github/scripts/tests/pr-dependency-cache.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/typecheck-test-programs.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/check-test-budget.test.mjs scripts/ci/test-selection-pr-timings.test.mjs`: **160/160 PASS** - `node scripts/check-test-budget.mjs`: **PASS** (`568` nightly suites validated) - `node scripts/check-maps.mjs`: **PASS** (`35 areas, 192 capability IDs`) - `pnpm --filter @paperclipai/ui typecheck` & `pnpm --filter @paperclipai/db typecheck`: **PASS** - Live CI verification runs on the new `pr-trusted.yml@master` (from #22679) with `profile-ci` enabled to export the full job/step/file waterfall to Honeycomb `paperclip-ci`. ## Risks - Medium CI scope: touches workflow matrix partitioning, E2E startup, and test runners; does not change production app runtime behavior. - All PR-demoted soak suites continue to execute on `master`, `release-verify`, `cloud-readiness`, local `pnpm test:run`, and `PAPERCLIP_CI_FULL=1`. - All new `policy` and `setup-ci-dependencies` commands keep file-existence guards so reruns of older PR branches continue to work. ## Model Used - Google Gemini (Antigravity swarm orchestrating specialized worker agents with shell, file editing, and test execution tools) and Anthropic Claude Opus (verification and optimization sub-agents). ## 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 - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
7d26bdaa42 |
feat(antigravity): verified Antigravity CLI route for native swarm (inert) (#22731)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents run through the Paperclip Runner's ACP driver, on the registry ACP server 1.5.2 > - Google's native `/swarm` (a coordinator that starts helpers and a verifier) exists only in the Antigravity CLI (`agy acp` 1.5.15), which #22728 pinned and provisions > - The CLI is a signed binary, so the registry server's owned admission patch cannot exist there. Paperclip needs another way to verify the session before a billable swarm starts, and a governed way to run, stop and finish it > - This pull request adds that CLI route to the Runner: a verified ACP client, the checks it does in place of the patch receipt, process setup, failure classification and a deterministic fake CLI for tests. Nothing selects the route yet, so this PR does not change behavior > - The benefit is that the next PR only has to add trusted `/swarm` detection and an experimental flag ## Linked Issues or Issue Description Refs #22728, #22701, #22727 **Subsystem affected** Paperclip Runner, ACP driver, Google Antigravity. **Problem or motivation** A user who writes `/swarm <request>` to a Google Antigravity agent should get a real native swarm in the task's workspace. The registry ACP server does not offer `/swarm`. The Antigravity CLI does, but its permission prompts for helpers never reach an ACP client, its model selector groups models into a family plus a thinking level, a turn can end while helpers still run, and some provider refusals arrive as ordinary text that ends the turn "successfully". **Proposed solution** Run a trusted swarm turn on the pinned CLI through a small driver-owned ACP client that verifies every setting it depends on, confines helpers to the task workspace through the CLI's `auto` mode, waits for helpers, checks the workspace after the turn, and reports typed failures in plain language. ## What Changed - `antigravity-swarm-guard.ts`: the checks that replace the registry server's admission receipt. The driver verifies and records: - agent identity and version from `initialize` equal the pinned CLI (`Antigravity ACP Server` 1.5.15), and the CLI accepts `systemPrompt.append`; - the `session/new` request uses the task workspace as `cwd`, carries Paperclip's instructions, and passes exactly one MCP server: the runner-owned Paperclip bridge; - session mode reads back as `auto` after `session/set_mode`; - model family plus thinking level read back as the agent's configured model after `session/set_model` (for example `gemini-3.8-flash` + `low` for `gemini-3.8-flash-low`); - none of those change later in the session; a helper started with workspace `share` or `branch` stops the swarm. Any difference fails closed with a typed error and a plain message. A sign-in without `auto` mode is reported as "swarm not available". - `antigravity-swarm-runtime.ts`: an `AcpxRuntimePort` for the CLI route. - One fresh session per run. It never calls `session/load`, so Retry after a lost process starts a fresh swarm in the same workspace. - Prompts with `/swarm <task>` (the route is reached only through the trusted mode). At most one swarm per run. - Does not settle on the first `end_turn` while helpers may still run: when helpers were started and the coordinator did not wait on the board afterwards, it sends one bounded "wait for the helpers" follow-up (20 min default; timeout is a typed failure). - Lists the task folder before and after the turn (asynchronous, bounded on every visited entry, stopped with the turn, skipping `.git`, `node_modules`, `.venv`, `__pycache__`) and shows the real changes. It never infers required files from what helpers or the coordinator say (helpers can misreport). Done still requires the hand-in through Paperclip's finish tool, which the server's completion contract enforces. - Stops the swarm when a visible tool call would change a path outside the task folder (`antigravity-swarm-paths.ts`): file-tool locations and path arguments, and shell write targets (redirects, `tee`, `cp`/`mv`/`ln` destinations, `rm`, `mkdir`, `touch`, `sed -i`, `dd of=`), resolved relative to the task folder with `..`, `~`, `$HOME` and symlinks of existing parents. This is a best-effort **detector, not a boundary**: it turns visible, unambiguous outside writes into a clear failure, uses a quote-aware lexer, and yields no finding for anything ambiguous (command substitution, heredocs, `eval`, `cd`, interpreters, unknown variables), so it never stops a correct swarm on a guess. It does not prove confinement. - Stop is installed before the first await of a turn and re-checked before every prompt; a Stop during admission retires the CLI at once. A test injects Stop at each await point (launch, initialize, session/new, set_mode, set_model, workspace listing, helper wait). - A saved conversation from the other Antigravity route (swarm ↔ ordinary turn) is refused as `ANTIGRAVITY_SAVED_STATE_INCOMPATIBLE`, the existing typed refusal that makes the server open a fresh conversation instead of showing Retry. So an ordinary follow-up after a swarm, a later second `/swarm`, and Retry after a killed swarm all start a fresh session. - Approves only Paperclip's own tool server at a permission prompt; every other prompt is outside the task folder in `auto` mode, so it is refused and shown as "Blocked: …". Helper actions that the CLI timed out are shown as blocked. - Stop sends `session/cancel`, then retires the CLI's process group and confirms no helper process survives. - Usage is the coordinator's reported total, recorded as soon as each prompt result arrives (also for failed or stopped turns), labelled as including the helpers and not itemised. - A settings change outside a turn becomes a typed failure that fails admission or the next turn and retires the CLI process group; no handler error can escape into the event loop. - Refusals that arrive as text (402 credits, 429 quota, sign-in) become typed provider failures. - `antigravity-swarm-presentation.ts`: turns the coordinator's `swarm` / `read_board` / `post_message` calls into steps such as "Started helper writer-a: Write a.txt …", "Checked on the helpers", and drops terminal-only hints. No raw ids. - `antigravity-swarm-route.ts` and small hooks in `runtime-host.ts`, `acpx-runtime-adapter.ts` and `provider-mode.ts`: the `antigravity` provider mode accepts only `swarm`; for that mode the host installs the pinned CLI (`resolveAntigravityCliLaunch` with `--gemini-dir <run credential home>/antigravity-cli`, the stable endpoint `https://cloudcode-pa.googleapis.com`, `--disable-telemetry`, self-update off), skips the registry credential staging, and refuses API-key connections and unpinned platforms with a plain message. - `test-fixtures/antigravity-cli/fake-agy-acp.mjs`: a deterministic fake `agy acp` that replays the spike's message shapes (success, live helpers at `end_turn`, hang, blocked, misreport, workspace escape, cancel with a real helper process, process death, 402 and 429 refusals as text, identity/mode/model mismatches). ### Host policy inputs on the swarm route | Input the registry route honours | Swarm route | |---|---| | Read-only (Plan mode) task policy | Refused before the CLI starts: "Swarm is not available while planning" | | Saved session / `restoringSession` (resume) | Refused as saved-state-incompatible: the server opens a fresh conversation; a swarm never reloads | | Runner-owned Paperclip tool bridge | Enforced: the only MCP server, verified in `session/new` | | Other assigned tool servers (stdio MCP bindings) | Refused with a plain message, never silently dropped | | Delegation tools | (follow-up PR) removed from the bridge catalog for a swarm turn | | Workspace root (`cwd`), `assertWorkspaceHeld` | Enforced: `cwd` is the task workspace, re-asserted at spawn; helpers must use `inherit` | | Additional directories | Not passed (none are granted) | | Credential/env scoping | Private `--gemini-dir`; registry credentials and API keys removed from the launch environment; macOS HOME is the OS user's home for the keychain sign-in | | Provider-lifetime fence, process group | Enforced: verified command lease with the lifetime fence; Stop and close retire the whole group | | Permission mode | Replaced by the verified `auto` session mode; other prompts are refused and shown as blocked | | Model and thinking level | Enforced and read back (`session/set_model`), checked for later changes | | Abort signal | Honoured during admission and turns | ## Verification - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/acpx/antigravity-swarm-guard.test.ts src/drivers/acpx/antigravity-swarm-presentation.test.ts src/drivers/acpx/antigravity-swarm-runtime.test.ts src/drivers/acpx/antigravity-swarm-route.test.ts`: 36 passed. Each file was red first (module missing); the route-selection tests were also shown red with the hooks reverted (2 failed) and green with them. - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/acpx/`: 117 files, 2017 passed, 9 skipped. - `tsc -p tsconfig.json` and `tsc -p tsconfig.test.json` for the runner package: no errors in the changed files. - `pnpm verify` asked for broader coverage (the fixture is a broad input); required CI supplies it. - Live, no product code: against the real CLI 1.5.15 with the owner's existing sign-in, `session/new` accepted the Paperclip bridge as an HTTP MCP server with a bearer header (it called `initialize` and `tools/list`), and `session/set_model gemini-3.8-flash-low` read back as `gemini-3.8-flash` + `low`. One prompt returned `⚠ RESOURCE_EXHAUSTED (code 429)` as text with `end_turn`; that shape is now a test case. - Not run live: a full swarm through Paperclip. That proof belongs to the follow-up PR, which turns the route on. ## Risks - Inert: no server code sets the `swarm` mode yet, so no turn reaches this route. - When enabled: helpers act under Antigravity's `auto` mode. What confines them is the CLI's own policy: file-tool writes outside the workspace are blocked (60 s timeout, seen in the spike), and its shell sandbox allows the workspace **plus temp directories**. Helper tool calls never reach an ACP client, so Paperclip cannot see or block a helper's shell command, and helper approvals are not possible. - **Paperclip does not confine the CLI process tree on a local computer.** Paperclip's local process sandbox (`adapter-utils/local-process-sandbox.ts`) is used only by the classic Claude and Codex local adapters, not by Runner ACP harnesses, so it does not apply here on macOS or Linux. The outside-path check covers only the coordinator's visible calls. This is why the feature stays experimental, off by default, local only, and why the activity log says helper actions are auto-approved. - On macOS the CLI reads its Google sign-in from the login keychain through the real HOME, so this route uses the sign-in of the CLI on the computer, not Paperclip's stored Google connection. All CLI state stays in the private `--gemini-dir`. - Google's consumer terms have a clause about third-party tools that access the service. A legal read is pending. This PR does not claim compliance. - Usage under-reports nothing that Google reports, but it cannot be split per helper. > 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 - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell, file edit) in Claude Code. ## 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 - [ ] I have updated relevant documentation to reflect my changes (docs and the qualification ledger come with the follow-up PR that enables the route) - [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> |
||
|
|
18aa2b353d |
feat(antigravity): /plan selects Plan mode and keeps Antigravity read-only while planning (#22727)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plan mode lets a person ask an agent for a plan, review it as the task's Plan document, and accept it before any work starts > - People who use Google Antigravity agents type `/plan <request>`, as they do in other agent tools. Paperclip sent that text to the agent, and #22701 correctly neutralised it, so nothing happened > - An Antigravity run in Plan mode was also not read-only: the agent could still edit files and run commands while it "planned" > - This pull request makes a leading `/plan` in the composer select Plan mode, and keeps an Antigravity Plan-mode run read-only at its permission prompt > - The benefit is that `/plan` with an Antigravity agent gives the normal Paperclip plan flow (Plan document, accept, then execution on the same task), and planning cannot change the workspace ## Linked Issues or Issue Description Refs #22701 **What happened?** A person wrote `/plan add greeting.txt` to a Google Antigravity agent. The agent did not plan. In Plan mode the Antigravity agent could still edit files and run commands. **What did you expect?** `/plan <request>` starts Plan mode. The agent researches and proposes a plan in the task's Plan document. It does not change files until the person accepts the plan. **Steps to reproduce** 1. Assign a task to a Google Antigravity agent. 2. Write `/plan Add a file greeting.txt containing hello`. 3. See that the task stays in Auto mode, and that the agent creates the file. ## What Changed - Task composer: a leading `/plan` in a comment or in a new task selects Plan mode and sends the rest of the message without the command. `/plan` alone only switches the mode. The slash menu offers "Plan". A `/plan` anywhere else in the message (quoted, pasted, fenced, mid-sentence) stays ordinary text and does not change the mode. This is the typed form of the existing Plan mode control, so it works the same for every agent. - Antigravity runner (`antigravity-plan-mode.ts`, wired in `acpx-runtime-adapter.ts` and `runtime-host.ts`): when Paperclip runs an Antigravity task in Plan mode (the existing read-only task policy), the permission prompt fails closed. It allows only (a) the 1.5.2 server's built-in research tools (file read, search, directory listing, page read), named by the exact `Run <tool>?` prompt title, when the reported kind also matches that tool, and (b) the tools the runner's own Paperclip bridge registered for this run, on the runner-owned server named `paperclip`. The provider's reported kind alone never grants a read, and no other MCP server is trusted, runner-owned or not. It refuses file edits, terminal commands and everything else. Paperclip's server applies its Plan-mode rules to its own tools, and the agent writes the Plan document through them. - Composer command parsing moved to `ui/src/components/task-chat/composer-commands.ts`. `/goal` and `/plan` both use the shared rule. Both submit paths use one `/plan` decision: a bare `/plan` sends (in Plan mode) only when an attachment can be sent without text; otherwise it only selects Plan mode. A composer without Plan mode (the dashboard chat starter) keeps `/plan` as text. - Follow-up, not in this PR: the Kimi read-only gate (`kimiReadOnlyPermissionAllowed`) trusts every runner-owned MCP server by title prefix. It should get the same binding to the Paperclip bridge's registered tools. - No change to the #22701 guard. Every `/plan`, `/logout` and `/usage` that would reach the Antigravity server is still neutralised. - No change to the Antigravity admission patch, profile or closure digests. No shared contract change. ### Why not the native `/plan` of Antigravity 1.5.2 I checked the pinned 1.5.2 server and SDK sources and ran it live: - The server has no plan session mode (only `default`, `auto_edit`, `yolo`) and no plan config option. Its only route is the `/plan` text command, which it turns into an SDK slash-command object. - Live on 1.5.2 (Google sign-in, `gemini-3.8-flash-low`), a task with `Please /plan this ...` reached the model as `Please/BuiltinSlashCommandName.PLAN this ...`. The SDK sent the enum's string form instead of `plan`, so the harness did not enter planning mode. Over 61 native steps (about 5 minutes) the agent wrote no plan artifact, ran terminal commands, and searched the file system for that unknown name. I stopped the run. - A working native path needs a change inside the runtime (for example in the owned admission patch), which re-pins the closures for every platform and needs re-qualification. This PR does not do that. Paperclip's own Plan mode gives the user-visible result now, with no re-pin. ### Source of trust for slash commands (reused by `/swarm`) - `parseLeadingUserCommand(text, allowlist)` in `packages/shared/src/leading-user-command.ts` is the one rule. It returns `{ command, argument }` or `null`. - Trusted text: only what the signed-in user typed and submitted in the task composer. That is a comment body or the body of a new task. Conversations (chat) do not use it for `/plan`. - Never trusted: agent comments, chat or connector messages, API-posted text, issue text written by someone else, quoted or pasted parts, and every prompt Paperclip builds for an agent. These stay text, and the #22701 guard still neutralises any native command in them. - Inside trusted text, only a command at the very start counts: optional whitespace, `/name`, then whitespace or the end. The name is exact and lower-case and must be in the allowlist. Only `plan` is enabled. Whitespace follows the Antigravity server's Python rules (U+001C-U+001F count; U+FEFF does not). - A recognised command becomes a structured action (here: Plan mode). It never reaches an agent as command text. - Tests cover: leading whitespace and newlines, a command not at the start, quoted, fenced, forwarded and wrapped content, a neutralised command, case, `/planning`, `/plans`, paths and URLs, Python vs JavaScript whitespace, and the allowlist. ## Verification - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/acpx/antigravity-plan-mode.test.ts src/drivers/acpx/acpx-runtime-adapter.test.ts src/drivers/acpx/antigravity-native-commands.test.ts src/drivers/acpx/antigravity-admission.test.ts`: 250 passed. - `pnpm --filter @paperclipai/shared exec vitest run src/leading-user-command.test.ts`: 8 passed (red first: module missing). - `pnpm --filter @paperclipai/ui exec vitest run src/components/task-chat/TaskChatComposer.test.tsx src/components/MarkdownEditor.autocomplete.test.tsx`: all passed (TaskChatComposer 155). - Red before the fix: the adapter test showed an Antigravity Plan-mode run approved a file write and a terminal command (`allow_once`), and the four composer `/plan` tests failed. The negative test (a `/plan` inside the message stays text) passed before and after. - Runner and UI typecheck pass (`tsc --noEmit`; the UI's only errors are the existing ungenerated Storybook catalog files). - `pnpm verify` returned exit 2 (runner files outside the local test graph), so required CI supplies the broad coverage. - Live, on THIS branch: a local instance running this branch, Google sign-in, `gemini-3.8-flash-low`, driven in the browser through the task composer: 1. `/plan Create a file named plan-proof.txt containing the single line OK` in a new task: the task was created in Plan mode with the command removed. Plan run 3 min 34 s, terminal state **succeeded** (the agent handed in through `paperclip_finish`; run result accepted, waiting for plan approval). The Plan document and a Confirm / Request changes card appeared. One `ls -la` was refused by the read-only gate. No file was written. 2. Request changes ("Name the file plan-proof-2.txt instead."): revision run 28 s, succeeded. Plan document revision 2 named the new file; a new Confirm / Request changes card appeared. Still no file. 3. Confirm: execution run 55 s, succeeded; task Done; `plan-proof-2.txt` contains exactly `OK` plus a newline. 4. Normal task whose text contains a pasted `"we usually /plan things like this first"`: created in standard mode, text unchanged; run 68 s, succeeded, Done; `negative-proof.txt` = `NEG`; no refused tool call. 5. Dashboard "Start a chat" box: NOT run live. The box renders only with an experimental instance setting that is off on this instance, and I did not change instance settings. A unit test covers it (a composer without Plan mode keeps `/plan` as text). 6. Stop during a Plan-mode run: the run was cancelled about 1 s after Stop and did not revive (no new run for over 3 min); no file. Killing only the native Antigravity server process mid Plan-mode run: the run failed with a provider error, showed "Continuing automatically", and a continuation run started 36 s later and settled (succeeded, 3 min 17 s, response wake). No duplicate comments; the Plan document has one revision; no file written; the gate refused one shell command in each run. - Found live, NOT fixed here: in the recovered run of step 6 the model settled with "waiting for plan review" but did not open the Confirm card (in steps 1 and 2 it did). Paperclip creates that card automatically only from a harness's own plan proposal (Codex, Claude). For Antigravity it depends on the agent. Recommended follow-up: when a Plan-mode run settles with a new plan revision and no pending plan confirmation, the server opens the card itself. - To be clear: this is not Antigravity's native plan mode. Native plan mode on runtime 1.5.2 does not work (see above). This PR gives Paperclip's Plan mode, started by a trusted `/plan`, with the Antigravity run held read-only. ## Risks - Low to medium. Plan mode for Antigravity now refuses terminal commands, so the agent researches with its file read and search tools. A planner that relied on shell reads must use those tools instead. - Google Workspace accounts whose admin policy lets terminal commands run in a sandbox without a prompt skip the permission prompt for commands. That path cannot be blocked here. Personal Google accounts and API keys always prompt. - `/plan` as the first word of a message now selects Plan mode for every agent. To send the literal text, write `\/plan` or put other text first. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell, file edit, browser automation not used), in Claude Code. ## 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 - [x] 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> |
||
|
|
b6f1b7b4af |
feat(antigravity): pin and provision the Antigravity CLI route (#22728)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner launches native agent harnesses, including Google
Antigravity, from pinned and verified distributions
> - Antigravity's native `/swarm` exists only in Google's Antigravity
CLI (`agy acp`), not in the registry ACP server 1.5.2 that Paperclip
pins today
> - Before a driver can use the CLI, Paperclip needs a pinned, verified
way to install it and to launch exactly those bytes
> - This pull request adds the CLI distribution pin, a setup command and
a launch resolver. It is the first step of a short series. Route
selection, `/swarm` detection and the driver follow in later pull
requests
> - The benefit is that the later driver work starts from a fixed,
digest-checked binary, and the existing Antigravity route does not
change
## Linked Issues or Issue Description
**Subsystem affected**
Runner native provider distributions (`packages/paperclip-runner`) and
the `paperclipai runtime setup` CLI command.
**Problem or motivation**
Google documents `/swarm` for the Antigravity App and the Antigravity
CLI only. The registry ACP server 1.5.2 does not offer it. To make
`/swarm` work, Paperclip must run `agy acp`. The CLI is a signed Go
binary with no patch point, so the owned admission patch cannot apply.
Integrity must come from pinned archive and executable digests. Google
publishes no redistribution licence for the CLI, and the bucket's object
immutability cannot be checked anonymously. So Paperclip must fetch the
CLI from Google at setup time and verify it against digests that are
pinned in the repository.
**Proposed solution**
A sibling declaration, `antigravity-cli-distributions.json`, pins 1.5.15
(build `1.5.15-5514532022517760`) for darwin-arm64, linux-x64 and
linux-arm64. `paperclipai runtime setup antigravity-cli` downloads,
verifies, extracts and installs it beside the existing runtime.
`resolveAntigravityCliLaunch()` returns the launch through the existing
sealed native store.
**Alternatives considered**
- Add the CLI to `antigravity-distributions.json`. That file feeds the
generated profiles, the Rust profile table, release attestations and the
provider pack. A sibling file leaves all of them unchanged.
- Bundle the binary in the provider pack or image. Not cleared: there is
no redistribution licence.
**Roadmap alignment**
This is experimental provider work behind later route selection. It
changes no qualified behavior.
## What Changed
- `packages/paperclip-runner/antigravity-cli-distributions.json`: the
new pin. For each platform it records the Google URL, archive format and
size, archive SHA-512 and SHA-256, the single tar member
(`antigravity`), the executable name (`agy`), the executable SHA-512,
and the closure entry (SHA-256 and size) that the sealed store uses. It
also pins the leading arguments (`acp`) and the environment
`AGY_CLI_DISABLE_AUTO_UPDATE=1`.
- `scripts/materialize-antigravity-cli-distribution.mjs`: reads only the
checked-in declaration and accepts only Google's versioned bucket path.
It enforces the pinned size while it streams the download, refuses
redirects, and checks SHA-512 and SHA-256. It reads a strict one-member
tar (a regular executable, no links, no extra members, zero padding
only) and checks the executable's SHA-256 and SHA-512. It publishes the
directory with an atomic rename. Every failure gives a plain message
that ends "Nothing was installed."
- `scripts/provision-antigravity-cli.mjs`: installs to
`~/.paperclip/runtimes/antigravity-cli/<target>/<closure>`. A re-run
verifies the installed copy in place with no download. A copy that no
longer verifies is retired and replaced from a fresh verified download.
- `scripts/materialize-antigravity-distribution.mjs`: exports its
existing owned-file helpers so the new route reuses them. There is no
behavior change.
- `src/drivers/acpx/antigravity-cli-installation.ts` and
`antigravity-cli-pins.ts`: `resolveAntigravityCliLaunch({ arguments?,
platform?, architecture?, home? })`, exported from the package. It
returns `version`, `build`, `target`, `commandDigest`, the exact
`arguments` (`acp` followed by the driver's), the frozen pinned
`environment`, `environmentFor(base)`, and a `VerifiedAcpxInstallation`
from `verifyNativeAcpxInstallation` (sealed store, per-launch executable
hash, `storeFamily: "antigravity-cli"`). Errors are
`AntigravityCliRuntimeError` with the codes
`ANTIGRAVITY_CLI_UNSUPPORTED_PLATFORM` and
`ANTIGRAVITY_CLI_RUNTIME_MISSING`. Both are permanent. The pins are
compiled in, and a test keeps them equal to the JSON.
- `cli/src/commands/runtime.ts`: adds `paperclipai runtime setup
antigravity-cli` through a small shared resolver and runner for vendored
provisioners.
- The bundle step builds `dist/cli/provision-antigravity-cli.{js,cjs}`
and copies the JSON pin to `dist/`. No binary goes into npm, the
provider pack or an image.
- Docs: a README section on the resolver, and a note in
`doc/plans/2026-11-22-antigravity-qualification.md`. The note says the
CLI route is experimental, is fetched at setup time, and why.
Pinned values (downloaded once from Google into an empty scratch
directory. Each archive matched Google's published manifest. The Linux
binaries were not run):
| Target | Archive URL (under
`https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.15-5514532022517760/`)
| Archive bytes | Archive SHA-512 | Executable bytes | Executable
SHA-256 |
|---|---|---|---|---|---|
| darwin-arm64 | `darwin-arm/cli_mac_arm64.tar.gz` | 86,166,538 |
`b03a841e…` | 229,617,904 | `8097b24d…` |
| linux-x64 | `linux-x64/cli_linux_x64.tar.gz` | 101,464,790 |
`af3f0be5…` | 273,879,752 | `7b004d26…` |
| linux-arm64 | `linux-arm/cli_linux_arm64.tar.gz` | 92,373,221 |
`d64ad759…` | 256,660,144 | `497580a7…` |
The darwin-arm64 executable matches the copy that was already verified
(Developer ID Application: Google LLC, team `EQHXZ8M8AV`). The full
digests are in the JSON.
## Verification
- Red then green: `node --test
packages/paperclip-runner/scripts/materialize-antigravity-cli-distribution.test.mjs`
(9 tests). It uses in-memory tar.gz fixtures and makes no network calls.
It covers the pins, a refused declaration, tar strictness, a verified
install with an idempotent re-run, a tampered archive, truncation, a
wrong-platform archive, an executable digest mismatch, the size
enforcement and redirect refusal of the download path, the repair of a
modified install, and an unsupported host.
- Red then green: `vitest run
src/drivers/acpx/antigravity-cli-installation.test.ts
src/drivers/acpx/antigravity-cli-pins.test.ts`. The resolver spawns a
fixture `agy` from the sealed store with `acp` plus the driver's
arguments and the pinned environment. It also covers a modified install,
a missing install that names the setup command, an unsupported platform,
and invalid arguments.
- Red then green: `cli` `vitest run src/__tests__/runtime-setup.test.ts
src/__tests__/runtime.test.ts`.
- Existing suites: `vitest run src/drivers/acpx/antigravity*
native-distribution-integrity* candidate-admission.antigravity-release
capability-profiles.antigravity-release` and `node --test
scripts/build-verified-provider-entrypoints.test.mjs` (includes the
registry-server materialize and patch tests),
`acpx-release-attestations`, `release-provider-pack`,
`antigravity-provider-pack-smoke`, `installed-package-pack`,
`candidate-provider-pack`. All pass. Under full parallel load, two
existing timing-sensitive tests (`probe-antigravity-metadata` SIGKILL
shutdown, `antigravity-acpx-runtime` model admission) failed once and
passed when run alone. This change does not touch those modules.
- Typecheck: `tsc --noEmit` for `packages/paperclip-runner` and `cli`.
- Real archives, local: materialize succeeded for all three real
archives against the real pins. The Linux binaries were extracted and
hashed only. The darwin build with a linux-x64 archive failed closed
with "Nothing was installed."
- End to end on macOS ARM64 with a scratch `HOME`: the bundled
`dist/cli/provision-antigravity-cli.cjs` downloaded from Google and
installed in 10.7 s. The re-run printed "Verified" with no download.
`resolveAntigravityCliLaunch({ arguments: ["--help"] })` ran the real
`agy acp --help` from the sealed store copy (exit 0, 1.4 s including
first store admission). `codesign --verify --strict` passes on the
installed copy.
- `pnpm verify` returned exit 2 (the README is a broad input). Required
CI supplies the broad coverage.
- Not run: the Linux binaries (no execution on this Mac), a Linux host
setup, and the full local suite.
## Risks
- Low risk. Nothing selects or launches the CLI route yet. The existing
registry-server pins, the admission patch, profile digests and
`acpx-profiles.json` are unchanged.
- The provider pack and the server's vendored Runner now also carry the
small provisioner script and the JSON pin (no binary), like the existing
Antigravity provisioner.
- Bucket immutability is not proven. If Google replaces an object at the
versioned path, setup fails closed on the digest. It does not install
different bytes.
- macOS code-signature team checks are not added. The repository has no
such hook, and the exact executable digest is a stronger pin.
> 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
- Anthropic Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with
tool use (shell, file edits) and extended reasoning.
## 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
- [x] 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>
|
||
|
|
9a04538391 |
perf(ci): cut PR CI under 5 minutes (shared PG, E2E parallelism, routing, test pruning) (#22679)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI verifies every change before merge across typecheck, build, server/DB/UI unit tests, and Playwright E2E shards. > - Today PR CI takes 15–30+ minutes wall-clock on ordinary feature and fix PRs (such as #22626) because every PR runs release/packaging/runner-support bloat, boots 800+ separate embedded Postgres clusters, runs Vitest serialized shards and E2E shards at 1 worker, builds the UI 8 separate times for E2E, emits 52 MB of React `act(...)` stderr spam in UI tests, and runs 61 real-clock soak suites plus hundreds of historical one-time SQL migration and mocked component wiring tests. > - Slow PR CI delays developer feedback, wastes runner capacity, and encourages batching changes instead of shipping small, safe PRs. > - This pull request cuts PR CI across all 6 bottlenecks (pipeline routing/Build bloat, PR-scoped parallel typecheck, shared embedded Postgres + batched/parallel Vitest runner, parallel E2E shards + prebuilt UI cache, historical/soak DB+server pruning with a checked-in nightly manifest, and UI stderr cleanup + low-value test pruning) while preserving all core control-plane invariants and full post-merge/release coverage. > - The benefit is projected PR CI wall-clock drops from 15–30+ minutes to ~3.8–4.4 minutes on ordinary PRs while keeping `master`, `release-verify`, `cloud-readiness`, local `pnpm test:run`, and `full-ci` runs at full coverage. ## Linked Issues or Issue Description Refs #22626. **What existing behavior does this improve?** Trusted pull-request CI wall-clock duration and runner efficiency across `.github/workflows/pr-trusted.yml`, `turbo.json`, `scripts/ci-typecheck-lane.mjs`, `scripts/run-vitest-stable.mjs`, `tests/e2e/`, `packages/db`, `server`, and `ui` test suites. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Ordinary PRs take 15–30+ minutes wall-clock in PR CI: - `Build` (~7.5–8.0m) runs a 231s clean public npm Grok install verifier and a 57s embedded-Postgres boot smoke on every PR. - `Canary Dry Run` (6.2m), `Runner support suite` (7.9m), `Docker context integrity`, `General tests (chat 1–3/3)`, and `Verify Paperclip Runner (vitest package 1–3/3)` fan out on ordinary app PRs due to broad `turbo.json` inputs. - `Typecheck + Release Registry` (7.1m) runs `test:release-registry` (193s), all standalone sandbox provider installs/checks, all untouched `tests/*` projects, and `--singleThreaded` `tsc` on every PR. - `General tests` and `Verify serialized server suites` boot 800+ separate embedded Postgres clusters instead of using `packages/db/src/test-postgres-command.ts`, run 17 serial Vitest invocations in `workspaces-b`, and run `verify_serialized_server` with `--no-file-parallelism --maxWorkers=1`. - `e2e_shards` (8.6m slowest shard) rebuilds the UI 8 separate times and forces `workers: 1` across all 56 specs because 7 specs mutate instance-level flags. - `workspaces-a` (8.3m × 2 shards) emits ~52 MB of React `act(...)` / `IS_REACT_ACT_ENVIRONMENT` stderr spam and executes 992 UI test files (including hundreds of brittle mocked wiring / `renderToStaticMarkup` suites). - `packages/db` and `server` run 43 historical one-time SQL migration replay tests, 12 static prose-grep tests, and 61 real-clock soak/crash/lease-expiry suites (~108.5 CPU-min) on every PR. **Proposed behavior** Ordinary PRs complete in under 5 minutes wall-clock while preserving full control-plane invariant coverage and full `master`/`release-verify`/`cloud-readiness`/`full-ci` verification: - PR `Build` removes the 231s Grok clean-npm verifier (already covered in `release-smoke.yml` and `docker-runner-check.yml`) and gates the 53s boot smoke on `PAPERCLIP_CI_FULL=1` (keeping fast `build:runtime` on every PR). - `turbo.json` and `.github/ci-task-matrix.json` path-gate `Canary Dry Run`, `Runner support suite`, `Docker context integrity`, `general-chat`, `ci:runner-package`, `ci:workspaces-a`, and `ci:db`, and narrow `tests/**` out of `globalDependencies`. - `Typecheck + Release Registry` uses fail-closed PR-mode scoping (`CI_PLAN`, `PAPERCLIP_CI_BASE_SHA`, `PAPERCLIP_CI_FULL`), parallel `typecheck-test-programs.mjs`, and `--checkers` / `GOMAXPROCS=2` within the 15.7 GiB RAM budget. - `run-vitest-stable.mjs` automatically wraps Postgres-backed lanes with one shared embedded Postgres template server (`test-postgres-command.ts`), batches `workspaces-b` and `workspaces-a` into single multi-project Vitest invocations, parallelizes isolated `serialized` shards, and filters `scripts/ci/nightly-only-suites.json` in PR mode (respecting `PAPERCLIP_CI_FULL=1`). - `e2e_shards` restores a read-only exact-key `server/ui-dist` cache written on canonical `master` pushes (`PAPERCLIP_E2E_SKIP_UI_BUILD=1`, inline fallback on UI PRs), isolates the 7 flag-mutating specs onto 2 serial shards while running the other 6 shards at `workers: 3` + `fullyParallel: true`, prunes 5 legacy/screenshot specs, and replaces fixed 20s/30s sleeps with deterministic waits. - `ui/vitest.setup.ts` eliminates >99.9% of stderr spam (`IS_REACT_ACT_ENVIRONMENT = true`, clean localStorage/DOM stubs, targeted `act(...)`/`No queryFn` suppression) and prunes 445 low-value mocked/presentational/screenshot UI tests + slims 2 giant mocked suites (keeping all `ui/src/lib`, `api`, `hooks`, `context`, `adapters`, `features`, `plugins`, and privacy/authz tests). - `packages/db` and `server` prune 43 historical one-time SQL migration tests, 12 static prose-grep tests, and 28 redundant `it.each` cases in `chat-channels.integration.test.ts`, and classify 61 real-clock soak/restart/lease-expiry/workspace-recovery suites (6,510.2s / 108.5 CPU-min) into `scripts/ci/nightly-only-suites.json`. **Reason and benefit** Cuts ordinary PR CI wall-clock from 15–30+ minutes to a projected ~3.8–4.4 minutes and removes ~156,353 LOC of redundant/brittle test code without dropping any core Paperclip invariant (company isolation, authz, atomic checkout, single-assignee, approval gates, budget hard-stop, activity logging). **Breaking changes** None for product runtime behavior. In PR CI, 61 real-clock soak suites listed in `scripts/ci/nightly-only-suites.json` run on `master`, `release-verify`, `cloud-readiness`, local `pnpm test:run`, and PRs with the `full-ci` label (`PAPERCLIP_CI_FULL=1`) instead of every ordinary PR. ## What Changed - **Pipeline & routing (`ci-fast/pipeline`):** - `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`, `.github/ci-task-matrix.json`, `turbo.json`: removed Grok clean-npm verifier from PR `Build`, gated `server-boot-smoke.sh` on `PAPERCLIP_CI_FULL=1`, path-gated `canary_dry_run`, `verify_runner_e2e_support`, `docker_context_integrity`, `general-chat`, `ci:runner-package`, `ci:workspaces-a`, and `ci:db`, forwarded `CI_PLAN` / `PAPERCLIP_CI_BASE_SHA` / `PAPERCLIP_CI_FULL` (keeping `profile-ci` in PR mode), and added exact-key read-only `server/ui-dist` cache restore in `e2e_shards` with a master-only writer in `release-verify.yml`. - Updated `.github/scripts/tests/ci-plan.test.mjs`, `scripts/__tests__/public-install-closure.test.mjs`, and `scripts/__tests__/runner-release-crate-cache.test.mjs`. - **Typecheck lane (`ci-fast/typecheck`):** - `scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/typecheck-test-projects.mjs`, `server/scripts/typecheck-layers.mjs`: added fail-closed PR-mode diff scoping (skipping `test:release-registry`, standalone sandbox providers, demo plugins, and untouched test projects/workspaces on unrelated PRs), concurrent `typecheckTestProgramsAsync`, and `--checkers` / `GOMAXPROCS=2` parallelism within 15.7 GiB RAM. - Updated `scripts/__tests__/ci-typecheck-lane.test.mjs`, `scripts/typecheck-test-programs.test.mjs`, and `server/scripts/typecheck-layers.test.mjs`. - **Vitest runner (`ci-fast/vitest-runner`):** - `scripts/run-vitest-stable.mjs`, `packages/db/src/test-postgres-command.ts`, `scripts/__tests__/run-vitest-stable-shard.test.mjs`: wired automatic shared embedded Postgres template DB (`test-postgres-command.ts` with `fsync=off`), batched `workspaces-b` and `workspaces-a` into single multi-project Vitest runs, parallelized isolated `serialized` shards (`maxWorkers=3`), and added PR-mode filtering for `scripts/ci/nightly-only-suites.json` (honoring `PAPERCLIP_CI_FULL=1`). - **Playwright E2E (`ci-fast/e2e`):** - `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `scripts/__tests__/e2e-shard.test.mjs`, `maps/feature-map/recovery.md`: added `PAPERCLIP_E2E_SKIP_UI_BUILD=1`, isolated the 7 instance-mutating `SERIAL_SPECS` onto dedicated serial shards while running the remaining 44 specs across 6 shards at `workers: 3` + `fullyParallel: true`, pruned 5 legacy/screenshot specs (`-743 LOC`), and replaced fixed 20s/30s sleeps in `disconnect-resilience.spec.ts` and `composer-stop.spec.ts`. - **Server & DB test pruning + nightly soak manifest (`ci-fast/server-prune`):** - Deleted 41 historical one-time SQL migration tests + 5 obsolete fixture SQLs in `packages/db/src`, 2 historical server SQL migration tests, and 12 brittle static prose-guidance tests; trimmed `packages/db/src/client.test.ts` (2,328 → 219 LOC), `packages/db/src/better-auth-account-issuer-migration.test.ts` (167 → 19 LOC), and 2 redundant `it.each` matrices in `server/src/__tests__/chat-channels.integration.test.ts`. - Added `scripts/ci/nightly-only-suites.json` classifying 61 real-clock soak/restart/lease-expiry/workspace-recovery suites (6,510.2s / 108.5 CPU-min). - **UI test log spam fix & pruning (`ci-fast/ui-prune`):** - `ui/vitest.setup.ts`, `ui/vitest.config.ts`: eliminated >99.9% stderr spam (22–52 MB → 3.6 KB) by enabling `IS_REACT_ACT_ENVIRONMENT = true`, adding clean DOM/localStorage stubs, and filtering React `act(...)` / TanStack Query `No queryFn` noise. - Pruned 445 low-value mocked/presentational/screenshot UI test files, slimmed `AgentConfigForm.render.test.tsx` and `Browse.test.tsx` to their privacy/access checks, updated 34 `maps/` files to remove dead test links, and removed the stale `ui/src/pages/NewAgent.test-support.tsx` allowlist entry in `scripts/check-query-error-rendering.mjs`. ## Verification - Combined CI contract & shard test suite (`node --test .github/scripts/tests/ci-plan.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/typecheck-test-programs.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs`): **136/136 PASS** (23.13s). - Full `.github/scripts/tests/*.test.mjs` suite on `ci-fast/pipeline`: **850/850 PASS** + Turbo cached-lane check **1/1 PASS**. - `node scripts/check-query-error-rendering.mjs --enforce --summary` and `node --test scripts/check-query-error-rendering.test.mjs`: **0 findings, 7/7 PASS**. - `node scripts/check-maps.mjs`: **PASS** (`35 areas, 192 capability IDs`). - `pnpm --filter @paperclipai/db typecheck`: **PASS** (`check:migrations` + `tsc --noEmit`). - `pnpm --filter @paperclipai/ui typecheck`: **PASS** (`369 files, 3454 stories` + `run-tsc.mjs -b`). - Component-level benchmarks verified on individual branches prior to merge (`ci-typecheck-lane.mjs` 63.4s simulated PR run; real Playwright 3-worker parallel specs passing; UI suite full run reduced to 3.6 KB stderr). - Live GitHub PR CI run triggered on this draft PR to verify real runner execution and measure before/after timings. ## Risks - **Two-phase CI effect:** Because `.github/workflows/pr.yml` invokes `pr-trusted.yml@master`, the workflow-level changes (removing Grok clean-npm install from PR `Build`, path-gating `Canary Dry Run`/`Runner support suite`/`general-chat`/`ci:runner-package`, passing `CI_PLAN`/`PAPERCLIP_CI_BASE_SHA`/`PAPERCLIP_CI_FULL`, and restoring `e2e-ui-dist`) take full effect only after merging to `master` (and `e2e-ui-dist` warms on the first `master` push; until then `e2e_shards` cleanly falls back to inline UI build). Furthermore, this PR modifies global CI inputs (`turbo.json`, `scripts/**`, `.github/**`), so its own PR CI runs the full matrix. - **Nightly soak demotion:** The 61 real-clock soak suites in `scripts/ci/nightly-only-suites.json` still run on every `master` push (`release-verify.yml`), `cloud-readiness.yml`, local `pnpm test:run`, and `full-ci`-labeled PRs, so regressions are caught post-merge rather than blocking ordinary PRs. - **Duration manifest rebalance:** Post-merge, the weekly `ci-test-durations.yml` refresh will recalibrate shard weights to reflect shared-Postgres timings for optimal LPT balance. - **No product runtime or DB schema changes:** All changes are confined to CI workflows, build/test orchestration scripts, test setup, test suites, and feature-map references. ## Model Used - Google Gemini 4 Neon (`Gemini 4 Neon (High)`), Google DeepMind, with repository tools, code execution, and multi-agent swarm coordination. ## 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 - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
28e2b99e3b |
fix(adapter-utils): allowlist Slack task tools route in callback bridge (#19936)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Remote and sandboxed agents call the Paperclip control plane through the sandbox callback bridge (`DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` and `HTTP2_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` in `packages/adapter-utils/src/sandbox-callback-bridge.ts`) > - While task-bound email routes and company skill routes are allowlisted, the task-bound Slack tool execution route (`POST /api/companies/:companyId/slack/tasks/:taskId/tools`) was missing from `DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` > - Because the callback bridge rejects unlisted routes before forwarding, remote agents cannot use the `slack` skill and receive `403 Route not allowed` > - This pull request adds `POST /api/companies/:companyId/slack/tasks/:taskId/tools` to `DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` while keeping Slack connection and workspace administration routes denied at the bridge > - The benefit is that remote and sandboxed agents can execute task-bound Slack tools over both queue and HTTP/2 callback bridges while the controller continues to enforce company, connection, and task/run authority ## Linked Issues or Issue Description - Fixes: #19925 ## What Changed - Add `POST /api/companies/:companyId/slack/tasks/:taskId/tools` to `DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` in `packages/adapter-utils/src/sandbox-callback-bridge.ts`. - Add positive and negative route authorization test cases for `/api/companies/:companyId/slack/tasks/:taskId/tools` and `/api/companies/:companyId/slack/connections` across queue and HTTP/2 allowlists in `packages/adapter-utils/src/sandbox-callback-context-routes.test.ts`. ## Verification - Verified `packages/adapter-utils/src/sandbox-callback-context-routes.test.ts` across both queue and HTTP/2 callback bridge allowlists. ## Risks - Low risk. Only `POST /api/companies/:companyId/slack/tasks/:taskId/tools` is admitted through the callback bridge; all Slack workspace and connection administration routes remain denied at the bridge, and the controller still enforces company membership, connection ownership, and task/run authority. ## Model Used - Google Gemini 3.1 Pro (Antigravity coding agent, 1M context window, extended thinking, tool use and code execution 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 |
||
|
|
b908678ea3 |
fix(connections): leave no connection behind when a first sign-in is cancelled (#22714)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agents use apps through connections. Most app connections use an OAuth sign-in. > - Paperclip saves a draft connection before it opens the provider sign-in page. > - When the user cancels or abandons that sign-in, the draft stays. The Apps list counts it as a connection that "needs attention". > - The user did not ask for that connection, and the user must not clean it up by hand. > - This pull request hides drafts that never finished their first sign-in and removes the draft when the user clicks Cancel. > - The benefit is that a cancelled sign-in leaves no visible connection, and a retry makes exactly one connection. ## Linked Issues or Issue Description Refs #22634 **What happened?** A workspace has one working "Google Workspace for the organization" connection. The user clicks "Add account", chooses services, and clicks Continue. The page shows "Opening Google Workspace…". The user clicks Cancel before finishing at Google. The Apps page then shows "2 connections · 1 needs attention". **What did you expect to happen?** A cancelled sign-in leaves no visible connection. The same applies when the user closes the page, reloads it, closes the Google tab, or refuses consent at Google. A retry after a cancel makes exactly one connection. A cancelled reconnect of a working connection does not change that connection. **Steps to reproduce** 1. Connect one Google Workspace account. 2. Open Apps, then Google Workspace, then "Add account". 3. Click "Continue to sign in", choose services, and click Continue. 4. On the "Opening Google Workspace" page, click Cancel. 5. Look at the Google Workspace card on the Apps page. ## What Changed - Root cause: `connectApp` saves an OAuth draft (`status: "draft"`) before sign-in (`server/src/services/tool-access.ts`, the connection insert in the connect path). Cancel only navigated away. The Apps list counted every draft as "needs attention" (`ui/src/pages/apps/Browse.tsx`, `connectionState` and the attention count). - New module `server/src/services/tool-access/connections/first-sign-in.ts`. It decides if an OAuth draft never held a credential. It checks for OAuth tokens on the connection and its grants, legacy inline tokens (the removal module's list), a provider consent time, an external credential, and the markers a real connection keeps when it needs a new sign-in. If any check is not clear, the connection counts as real. - The connection list endpoint sets `firstSignInPending: true` on those drafts. The shared `ToolConnection` type has the new field. - New route `POST /tool-connections/:connectionId/sign-in/cancel`. It checks company access and configure permission. It removes the draft with the normal removal teardown (grants, OAuth states, bindings) only if the draft never held a credential. For any other connection it changes nothing and returns `abandoned: false`. A removal writes the activity entry `tool_connection.sign_in_cancelled`. The route is in the OpenAPI registry. - The Apps list does not show connections with `firstSignInPending`, and it does not show an app whose only connections are such drafts. The check is one pass with `Set` lookups. - Cancel works in one transaction: it deletes the pending sign-in states, locks the connection, checks it again, and parks it as `disabled` with the marker `oauth_sign_in_cancelled`. If the connection must stay, the transaction rolls back. Then the normal removal archives the parked draft. Setup never reuses a parked draft, so a retry during the removal gets its own row. - One predicate, `connectionRemovedOrSignInCancelled`, guards authorization start, access finish and machine sign-in. The direct, Cloud and Vercel Connect callbacks and the access finish step lock the connection before they write a grant or activate it, and return 409 `oauth_sign_in_cancelled` for a parked draft. - `docs/api/tool-connections.md` documents the cancel route and the list flag. - The setup page calls the cancel route when the user clicks Cancel on the sign-in screen. It does this only for a draft that this page made. It does not do this for a resume, a reconnect, or a task-linked setup. - Design for abandoned drafts (tab closed, reload, consent refused): they are not listed, and the next attempt reuses them through the existing draft reuse in setup. No background cleanup job is added. ## Verification - `server/src/__tests__/tool-access-cancelled-first-sign-in.integration.test.ts` runs the real routes against embedded Postgres and a local OAuth provider. It covers: a draft is marked and hidden; a provider token exchange held open across Cancel ends in 409; Cancel and a retry at the same time leave exactly one active connection; a parked draft is hidden and refuses a new sign-in start; a legacy draft with an inline token is not cancelled; Cancel removes it, deletes its OAuth state, logs activity, and a late callback fails; a retry after Cancel gives exactly one live connection (organization and personal); Cancel does not change an active connection or a connection that needs a new sign-in; a draft refused at the provider stays hidden and Cancel removes it; another company cannot cancel the draft. - `ui/src/pages/apps/Browse.test.tsx`: a pending draft is not listed and does not add "needs attention". - `ui/src/pages/apps/AppsConnect.test.tsx`: Google Workspace setup, Continue, then Cancel calls the cancel route for the new draft. - Red/green: the new Browse and setup tests fail without the UI change. The server test fails on master because the route and flag do not exist. - Local runs: the new server file, `openapi-routes.test.ts`, `tool-access-oauth-protocol.integration.test.ts`, `Browse.test.tsx`, `AppsConnect.test.tsx`, `activity-format.test.ts`, and `src/features/connections` pass. Server typecheck passes. `pnpm verify` exits 2 because of the pinned inputs file, so CI supplies broad coverage. - Not done: a real browser test against Google. ## Risks - Low risk. The cancel route fails toward no change: it removes nothing that shows any sign of a credential. - Cancel and a late provider callback agree under the connection row lock. If the callback commits first, Cancel changes nothing. If Cancel commits first, the callback returns 409 and saves nothing. This covers the direct, Cloud and Vercel Connect callbacks and the access finish step. - If the removal after Cancel fails, the draft stays parked and hidden, and a second Cancel finishes it. - A connection that was removed before and is now added again keeps its old consent record. If that new sign-in is cancelled, it stays as a visible draft, as it does today. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used in 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 - [x] 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> |
||
|
|
b2a12fab49 |
fix(runner): keep tool catalogs within what a durable run attachment can carry (#22705)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Managed runs start through the Paperclip runner, which records each run's attachment template in a durable control plane > - That template carries the agent's authorized tool catalog, with every tool's JSON schema > - The runner-side catalog check admitted up to 256 tools and 768 KB, but the durable control plane rejects any value over 10,000 canonical JSON nodes, and durable commands cannot exceed about 522 KB > - An agent with Notion and two GitHub connections (about 180 tools) passed the first check and failed every run with `durable_prp_canonical_json_too_large` > - This pull request makes the catalog check honor what the run attachment can carry, and gives controller-built values a node budget that matches the command byte limit > - The benefit is that agents with several large connectors run normally: tools that do not fit move to on-demand search and call instead of blocking the run ## Linked Issues or Issue Description **What happened?** After Notion (77 tools) and two GitHub connections (49 tools each) were connected and installed for the company, every run for an agent failed within seconds with `durable_prp_canonical_json_too_large`, before the model session started. Paperclip retried each run several times. **Expected behavior** An agent with several connectors starts its run. When the full catalog is too large, tools are delivered on demand. **Steps to reproduce** 1. Build an authorized tool catalog that `runnerCodexDynamicToolsFit` admits, for example 250 tools with enum-heavy schemas under 768 KB. 2. Stage it as a run attachment in `DurablePrpControlPlane`. 3. Staging throws `durable_prp_canonical_json_too_large`. ## What Changed - `durable-prp-control-plane.ts`: the canonical JSON node budget is a per-call limit. Runner-sent semantic input keeps 10,000 nodes. Controller-built values (run attachment templates, command digests) use a budget equal to the command byte limit, which already bounds them. New `runAttachToolCatalogFits` checks that a tool catalog canonicalizes and stays within 384 KB, leaving room for the rest of the run attachment. - `runnerd-codex-transport.ts`: `runnerCodexDynamicToolsFit` also requires `runAttachToolCatalogFits`. The server already uses this predicate to choose between direct tools and on-demand tools. - Tests: the densest catalog the fit check admits stages, persists and restores through the control plane; a 180-tool connector catalog under 768 KB no longer fits and moves to on-demand tools. ## Verification - `npx vitest run src/control-plane/durable-prp-control-plane.test.ts` (runner): 232 passed, including the existing runner input `over_node_limit` and `over_depth_limit` cases. - `npx vitest run src/services/native-runtime/assigned-mcp-tools.test.ts` (server): 61 passed. `paperclip-runner-tool-authority.test.ts`: 48 passed. - Red/green: without the change, the control plane test fails with `durable_prp_canonical_json_too_large`, and the server test fails with `expected true to be false` (the oversized catalog was admitted). - `runnerd-codex-transport.test.ts` and `runner-tool-capacity.test.ts` have the same 79 local failures with and without this change (they need built runner binaries). CI runs them. - SDK public input pins: unchanged. ## Risks - Agents whose catalog is between 384 KB and 768 KB now get on-demand tools instead of direct tools. Before this change those runs failed, so no working setup loses direct tools. - Controller-built values get a larger node budget. They are bounded by the command byte limit before they reach the runner, and runner input keeps its strict limit. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code, with tool use. ## 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 - [x] 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> |
||
|
|
298026eadc |
fix(ai-connections): reconnect typed auth failures and stop quota retry countdowns (#22692)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Runs preserve typed provider failures so recovery can select the right next action. > - Authentication repair still recognized only older run error codes. Native typed authentication failures could miss the reconnect request. > - A typed exhausted quota with no reset also produced an estimated one-hour admission hold. Waiting cannot repair that account. > - This pull request uses the existing reconnect and validated adoption flow for authentication. It asks for billing and usage repair for typed quota exhaustion without a reset. > - Rate limits and provider-reported resets keep their existing automatic waits. Account authority, saved-work checks, pauses, and approvals keep their existing gates. ## Linked Issues or Issue Description Refs #15110. That open PR classifies the legacy Claude monthly-spend message. This change does not duplicate its adapter parsing or change older untyped quota recovery. Refs #21351. That open PR changes legacy Claude edge-error classification and repeated-failure latching. This change consumes the typed provider category and retains the existing credential-generation checks. **What happened?** A failed run with `providerFailure.category: authentication` and a generic native error code did not create its reconnect request. A typed `quota_exhausted` failure without a reset produced an estimated provider cooldown, although the account needed attention. Recovery's narrow PostgreSQL result projection also omitted typed native provider failures. **Expected behavior** Ask the responsible person to repair the selected account or explicitly adopt a compatible managed connection. Ask for billing and usage repair when an exhausted allowance has no reported reset. Continue to wait automatically for transient rate limits and reported allowance resets. **Steps to reproduce** Use a failed native run with a typed OpenAI authentication error and a generic native error code. The existing reconnect controller should create one card. Use typed `quota_exhausted` evidence with no reset. The task should offer account review and manual Retry, with no invented reset or automatic provider retry. ## What Changed - Recognize typed authentication failures and the reported `provider_invalid_credentials` run code. Reuse the existing controller-only reconnect request, account freshness checks, durable continuation, and explicit legacy adoption. - Retain typed provider failures in the bounded PostgreSQL recovery projection. - Refresh the reviewed SDK public-source pin for the changed shared interruption type with the repository generator. - Keep typed quota exhaustion without a reset out of provider cooldown, bounded retry, and periodic quota-recovery paths. A newer billing refusal supersedes older reset evidence. Classify a startup billing refusal before the remote exit-confirmed retry branch, and prevent the startup planner from falling back to plain backoff. - Add the derived `provider_billing` task action, an account-review link, and a matching Inbox label. Preserve saved-work recovery and current user gates. - Update the connection documentation for these recovery decisions. ## Verification - Red: five server regressions failed on current master for typed authentication, the invalid-credential code, a false quota cooldown, and the missing billing action. The new task notice regression also failed before the repair. - Green: the first focused set passed 241 tests. The final quota/retry/UI set passed 281 tests. The database-backed reconnect set passed seven selected cases for Claude, OpenAI, method switching, and explicit legacy adoption. Sets overlap; these counts are not additive. - Database tests check current account attribution, refreshed credential generations, bounded result projection, and preservation of reported resets. A quota without a reset must not schedule a successor. Two additional startup regressions failed before the startup repair. The repaired startup suites pass all 45 integration cases and 11 focused classification cases. They check a blocked task, billing presentation, no retry deadline, no resumable claim, and preserved retries for rate limits and reported resets. - `pnpm check:token-gates` and `git diff --check` passed. - The earlier [Runner support failure](https://github.com/paperclipai/paperclip/actions/runs/45263306284/job/138003893674) came from a stale reviewed SDK source pin. The same three SDK evidence files failed locally on `cacdb81`. Regenerating the pin from that committed tree made all 59 tests in those files pass. Only the shared `execution-projection.ts` source hash changed; lock and runtime pins remain unchanged. - `pnpm build` and repository-wide `pnpm -r typecheck` passed for the initial change. The authentication/recovery policy set also passed 99 tests. Server typecheck and build also passed for the startup repair at `cacdb81c26988394e11f934d05531bcbb121c7a2`. The full local `pnpm test:run` stopped in chat shard 4/6 with 15 failures: fourteen file/database-open failures during `ENFILE` file-table exhaustion and one retry polling timeout. The failed run also reported an unhandled `ENFILE` error. All 40 selected chat cases, including those 15 failures, passed in a fresh process on `06c14a8`. This does not qualify the full local suite. The complete CI workflow passed on the final head, as recorded below. - Local environment: isolated macOS arm64 checkout and disposable PostgreSQL fixtures. The branch was replayed onto master at `32375d302fbc3a233531674aedefa273adee2d97`; that base change touches an unrelated migration test. - Live provider account repair and the original reported credential failure remain unverified. A read-only operational trace confirmed retained runner checkpoint versions, but the reported runtime string was absent from retained onboarding and run logs as well as current Core and available Cloud source refs. Its producer remains unidentified. - [Trusted PR CI, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/45265943006/attempts/2) completed successfully on `06c14a8cbcf2480eb9d2841bebda3337d4248bd6`, including typecheck, build, Runner, serialized server, general test, and browser suites. The previously cancelled serialized suite passed on that attempt. All 59 commit checks are terminal: 56 succeeded and three conditional checks were skipped. The Snyk commit status also passed. - Greptile completed on `06c14a8cbcf2480eb9d2841bebda3337d4248bd6` with 5/5 and no new findings. Both earlier review threads are resolved. ## Risks - A typed exhausted allowance without a reported reset now requires account repair. Older untyped quota errors retain their existing recovery policy; #15110 remains separate. - Authentication repair must follow the recorded account rather than infer an account from a proxy driver's upstream name. Existing generation checks must still protect newer credentials. - No schema migration or provider replay authority is added. Existing stored runs keep their data. The new task action is derived at read time. - Live recovery of the originally reported incident remains unverified; the operational trace did not locate the reported runtime code. ## Model Used OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort, tool use, code editing, and test execution. The harness does not expose the context-window size. ## 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
4b5b9b7807 |
fix(antigravity): keep native slash commands in task text as prose (#22701)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner can run tasks on the native Google Antigravity ACP server
(version 1.5.2)
> - The server turns some prompt text into native slash commands before
the model sees it
> - The admission guard refused only lines that start with "/". The
server runs `/plan` anywhere it follows whitespace, so task text such as
"see /plan for details" could switch the session into plan mode without
Paperclip
> - This pull request makes the guard mirror the server's exact rule for
each advertised command and keeps that text as prose
> - The benefit is that task, comment and pasted text cannot change the
native session mode or sign the account out, and ordinary prose that
mentions a command still runs
## Linked Issues or Issue Description
**What happened?**
The 1.5.2 server builds `_CMD_PATTERN = re.compile(r"(?:\s|^)/(" +
"|".join(...) + r")(?:\s|$)")` (server.py, lines 2071-2075) over its
built-in commands (`plan`) and applies it to every text block in
`_parse_prompt` (server.py, line 2136). The Runner sends the task as one
JSON line. A space before `/plan` survives JSON encoding, so
`{"task":"... then /plan the rollout"}` produced a native plan command.
The old guard did not see it, because no line started with "/".
**Expected behavior**
Task text reaches the model as text. Native commands that change the
session (`/plan`) or the account (`/logout`) never run from task
content.
**Paperclip version or commit**
`master` at the base of this branch, with the Antigravity ACP server
1.5.2 and its owned admission patch `1.5.2-paperclip.2`.
**Steps to reproduce**
1. Send a managed Antigravity prompt whose text contains ` /plan ` after
other words.
2. The old guard admits it unchanged.
3. The server's `_CMD_PATTERN.split` returns a `plan` command for that
text.
The other two advertised commands match only the whole prompt: `/logout`
when all text joined and stripped equals `/logout` (logout.py, lines
29-36), and `/usage` when that text starts with `/usage` and whitespace
or the end, case-insensitively (usage.py, lines 29-36). Python's
`str.strip()` also strips characters that JavaScript does not treat as
whitespace (U+001C..U+001F, U+0085), so `"\u001c/logout"` passed the old
guard and is a logout to the server.
## What Changed
- Add `antigravity-native-commands.ts`. It transcribes the server's
three matchers, with Python's exact whitespace set, and a neutraliser
that puts a word joiner (U+2060) before each slash that the server would
act on. The model still reads the same words. Text that the server
treats as prose is sent unchanged.
- The admission guard now rewrites the outbound `session/prompt` text
with the neutraliser instead of refusing every line that starts with
"/". If a native command still matches afterwards, the guard refuses the
prompt.
- The guard fails closed if the runtime advertises a native command
outside `plan`, `logout`, `usage`, so a future server command cannot
pass silently.
- Text blocks keep their other fields when the guard rewrites them.
- The server advertises exactly `plan`, `logout` and `usage` (server.py,
lines 6289-6299: the SDK's built-in commands, which are only `plan`,
plus the logout and usage entries).
- No change to the native admission patch, so the owned patch version
and closure digests stay the same.
## Verification
- Red first: the new admission tests failed on the old guard (19 failed:
`/plan` mid-line, in the JSON envelope, after a newline, inside quoted
text, after a tab, `"\u001c/logout"`, a command split across blocks, and
benign text the old guard refused).
- Green: `npx vitest run antigravity` in `packages/paperclip-runner` (14
files, 202 tests). `tsc --noEmit -p packages/paperclip-runner` passes.
- Cross-check against the server: I ran the server's own regular
expression and the `is_logout_prompt` / `is_usage_prompt` logic in
Python on 40,000 generated multi-block inputs. The TypeScript matcher
agreed on every input (998 plan, 1,423 logout, 2,941 usage matches).
After neutralisation, the server matched no command, and only word
joiners changed.
- `pnpm verify` exits 2 (the changed test files are outside the resolved
test graphs), so required CI supplies the broad coverage.
- Not run live: no prompt was sent to a real Antigravity session,
because the only available Gemini key is refused. The evidence is the
unit-level reproduction against the guard plus the quoted server source.
## Risks
- Low risk. The guard changes only prompt text that the server would run
as a command, and only by inserting an invisible word joiner. If the
model copies `/plan` from such text into a shell command, the word
joiner could come with it. This applies only to `/plan` followed by
whitespace.
- Prompts with lines that start with "/" (for example a path such as
`/usr/bin/x`) are no longer refused. The server does not treat them as
commands.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.
## 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
- [x] 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>
|
||
|
|
8c6e5cbbb8 |
fix(connections): offer Paperclip's Google sign-in on Paperclip Cloud only (#22699)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use Google Workspace through a connection. A connection can
use Paperclip's own Google sign-in ("Connect with Paperclip") or the
customer's own Google OAuth client
> - Paperclip's own Google sign-in goes through the Paperclip Cloud
broker with Paperclip's verified Google client
> - Google's restricted-scope verification and security assessment cover
only the servers that Paperclip operates
> - The owner decided on 2026-11-23: Paperclip's own Google sign-in is
for Paperclip Cloud workspaces only. Self-hosted instances use their own
Google OAuth client
> - This pull request hides and refuses Paperclip's own Google sign-in
on self-hosted instances, keeps saved connections working, and gives
clear guidance
> - The benefit is that restricted-scope Google tokens stay on servers
that Paperclip operates, and self-hosted users always see a path that
works
## Linked Issues or Issue Description
Refs #22635
**What happened?**
A self-hosted Paperclip instance offered "Connect with Paperclip" for
Google Workspace and other Google apps. That sign-in uses Paperclip's
verified Google client. It sends restricted-scope Google tokens to a
server that Paperclip does not operate. A self-hosted instance also
offered Paperclip Cloud enrollment only to use that sign-in.
**What did you expect to happen?**
Paperclip's own Google sign-in is available only on Paperclip Cloud
workspaces. A self-hosted instance shows only "Use your own Google OAuth
app", with a short reason and a link to a setup guide. Saved Google
connections on a self-hosted instance keep working until a sunset date
that the owner sets on the Paperclip Cloud broker. After that date, the
connection tells the user to reconnect with their own Google client.
Paperclip Cloud workspaces do not change.
**Steps to reproduce**
1. Run Paperclip without Paperclip Cloud markers (self-hosted).
2. Turn on the Google Workspace connector in **Settings →
Experimental**.
3. Open **Apps** and choose **Google Workspace** or **Gmail**.
4. Before this change: setup offers "Connect with Paperclip" or asks to
connect the instance to Paperclip Cloud first.
## What Changed
- `packages/shared/src/google-sign-in-deployment.ts`: new
`appDefinitionForDeployment` and `isCloudOnlyConnectionMethod`. On a
self-hosted instance they remove every Paperclip-managed Google method.
Other providers do not change. New shared message
`GOOGLE_SIGN_IN_CLOUD_ONLY_MESSAGE`.
- `server/src/services/google-sign-in-availability.ts`:
`paperclipGoogleSignInAvailable()` returns `isCloudManagedInstance()`.
This is the existing single Cloud check. No new environment variable.
- `appWithPaperclipCloudConnectorAvailability` (gallery and setup
validation) uses that check. A self-hosted gallery and setup do not show
managed Google methods.
- `authorization-start.ts`: a self-hosted instance refuses to start a
managed Google authorization before it calls Paperclip Cloud (`422`,
code `google_sign_in_cloud_only`). A broker refusal with
`PROVIDER_CLOUD_ONLY` maps to the same message, also on a Cloud
instance.
- `paperclip-cloud-connector.ts`: `PROVIDER_CLOUD_ONLY` is a known
broker reason.
- `grant-refresh.ts`: when the broker refuses a refresh with
`PROVIDER_CLOUD_ONLY` (after the sunset), the grant is marked for
reconnection. The error keeps code `oauth_reauthorization_required`,
adds reason `google_sign_in_cloud_only`, and tells the user to reconnect
with their own Google OAuth client.
- `ConnectionSetupFlow.tsx`: on a self-hosted instance (no `cloud` block
in health), Google setup uses the filtered definition. It never shows
Cloud enrollment for Google. The customer-owned Google client step shows
this note and a link to Google's client guide.
- Docs: `doc/connections/GOOGLE-WORKSPACE.md` ("Who can use Paperclip's
Google sign-in", "Self-hosted instances: use your own Google client")
and a dated decision row in `doc/memory/google-connector-memory.md`.
- `tests/runner-e2e/source-sdk-public-inputs.json`: pins the new shared
files (generated).
## Verification
- Red first, then green:
- `packages/shared/src/google-sign-in-deployment.test.ts` fails without
the new module and passes with it (4 tests).
- With the source files from `origin/master`, these new tests fail: 2 in
`server/src/__tests__/tool-access-service.test.ts` (self-hosted refusal,
refresh guidance and saved-connection refresh; broker refusal mapping),
3 in `server/src/services/paperclip-cloud-connector.test.ts`, and the
self-hosted test in `ui/src/pages/apps/AppsConnect.test.tsx`. With the
change they pass.
- Cloud path proof: "never shows the self-hosted Google notice on
Paperclip Cloud" (UI), "leaves every app unchanged on Paperclip Cloud"
(shared, identity check on every definition), "decides Cloud or
self-hosted from the instance's Cloud markers" (server). All existing
managed Google service tests (515) pass in a Cloud context.
- `npx vitest run src/__tests__/tool-access-service.test.ts` (server):
517 passed.
- `npx vitest run src/services/paperclip-cloud-connector.test.ts`
(server): 71 passed.
- `npx vitest run src/pages/apps/AppsConnect.test.tsx
src/features/connections` (ui): all passed.
- `npx vitest run` for `agent-connection-catalog.integration`,
`tool-gateway-service`, `google-access-removal`,
`connection-management.integration`, `generic-mcp-connection`,
`remote-mcp-connectors` and `plugin-connectors-circleback-parity`
(server): 446 passed, 1 skipped.
- `npx vitest run` in `packages/shared`: 1383 passed.
- `pnpm verify` exits 2 because `doc/connections/GOOGLE-WORKSPACE.md` is
a global CI input. Required CI supplies the broad coverage.
- Not run: no requests to staging, production, or Google. The reconnect
of a saved managed Google connection on a self-hosted instance after the
sunset was not run end to end in a browser.
## Risks
- Behavior change for self-hosted instances: new Paperclip-managed
Google connections stop. Saved ones keep refreshing until the broker
sunset (not set yet).
- The decision uses `isCloudManagedInstance()`. If a Cloud workspace
does not have its Cloud markers, it shows the self-hosted path. Cloud
stacks always have the tenant token, so the risk is low.
- Works with old and new brokers. An old broker does not refuse. The app
check still hides and refuses the method. A new broker refuses
self-hosted instances, and the app maps the refusal to the same
guidance.
- Deploy order: the broker change (paperclip-cloud) and this change can
deploy in any order.
> 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
- Claude Opus 5.5 (`claude-opus-5-5`) in 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
- [x] 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>
|
||
|
|
a00e31967b |
feat(connections): live setup progress from the person's own agent (#22626)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Several setup screens offer "Set it up with your agent": a prompt the person pastes into their own agent (Claude Code, Codex) to do the setup on their computer. AWS role setup is the newest > - Once the prompt is copied, the setup page goes quiet: the person cannot see what their agent is doing or when it is done, and has to switch windows to find out > - The agent already runs commands, so it can report its progress back if we give it a safe place to send it > - This pull request adds a live checklist the agent fills in: the page creates it, the prompt gives the agent curl commands with a token, and the page shows every update as it happens > - The benefit is a setup that shows its own progress, and a reusable piece any "Set it up with your agent" screen can use ## Linked Issues or Issue Description Refs #22233 (the AWS setup screen this extends). **Subsystem affected** Connections (agent-guided setup), live updates, a new public agent API, UI. **Problem or motivation** After a person copies a setup prompt into their own agent, Paperclip shows nothing until they come back and paste a result. There is no way for the agent to say what it is doing. **Proposed solution** A setup checklist a person's own agent writes to, shown live on the setup page. The agent's requests need no Paperclip sign-in, so they carry a narrow, expiring bearer token. Paperclip Cloud needs no front-door change: it already forwards `/api` requests that carry an `Authorization` header to the workspace without Cloud identity (its machine-request lane), and these always do. **Alternatives considered** - Polling the page instead of live events: slower and adds load to every open setup page. The page uses the existing live-event channel, with a 20-second backup refresh while the agent works. - Putting the token in the URL: URLs end up in logs. The token goes in the `Authorization` header. - Letting the agent set the role ARN itself: the person still pastes it (as decided for #22233). The agent's finish summary shows the ARN to copy. ## What Changed - `packages/db`: new `agent_setup_progress` table (company-scoped, purpose and subject, token hash, items, status, summary, update count, expiry). Migration `0501` is idempotent. - `packages/shared`: `agent-setup-progress` types, limits and validators; new live event type `agent_setup_progress.updated`. - `server`: - `agentSetupProgressService`: create (random `pcsp_` token, only its SHA-256 kept), read, and the agent's set-checklist, update-item and finish. Tokens are compared in constant time; a write is refused after expiry (6 hours) or 300 updates, and concurrent writes are guarded by the update counter. Finishing `done` ticks off open steps. - Routes: board-only `POST /api/companies/{companyId}/agent-setup-progress` and `GET /api/agent-setup-progress/{id}`; agent routes `PUT …/checklist`, `POST …/items/{key}` and `POST …/finish` mounted with the other public routes. Activity entries for created, started and finished. - Each agent write publishes `agent_setup_progress.updated`; the live-events socket forwards it with only the checklist ID. - OpenAPI entries for all five routes. - `ui`: - Reusable `ui/src/components/AgentSetupProgress.tsx`: `useAgentSetupProgress` (creates one checklist per setup and follows it), `agentSetupProgressInstructions` (the prompt section with the agent's curl commands) and `AgentSetupProgressPanel` (waiting, working, done and failed states, using the task status glyphs). - `LiveUpdatesProvider` refreshes the checklist on its live event. - AWS role step: one step (no numbering) with the prompt, the live checklist and the Role ARN field. The prompt starts with the progress instructions and asks the agent to put the role ARN in its finish summary. - Docs: `docs/api/agent-setup-progress.md` (API and how to add it to another page) and the AWS setup section. - Storybook: AWS step in waiting, working, done and failed states, and the panel on its own. ## Verification - `server/src/__tests__/agent-setup-progress.test.ts` (real routes, embedded Postgres): set, update and finish with the prompt's token; only the hash is stored; four live events carry the checklist ID; activity entries. Refusals: missing token, wrong token, another checklist's token (401), bad key (400), unknown item (404), update limit (429), expired (410). Company boundary: another company's member gets 403 on read and create. - `live-events-toast.test.ts`: the socket delivers the event with only `{ progressId }`. It failed before the socket fix (red/green), which an end-to-end run found. - `AgentSetupProgress.test.tsx`: the prompt section's exact commands; the hook creates one checklist and the panel follows waiting → working → done on live refreshes. - `AwsRoleSetup.test.tsx`: the step creates the checklist for its connection, waits for the agent, and the prompt leads with progress reporting. - Totals: shared 1362, server (new, OpenAPI, live events, AWS) 101, UI (components, connections, apps, live updates) 1469. Typecheck clean for db, shared, server and UI (except Storybook's generated catalog, not built in this worktree). - End to end on a local instance: Playwright opened the real AWS setup step, read the prompt, sent the agent's requests with its token, and the page showed each update within 1.5 seconds (inside the 20-second backup refresh, so from live events) through "Your agent set up AWS" with the role ARN summary. No page errors. - Not run yet: Paperclip Cloud staging (after deploy) and an agent running the prompt on its own. ## Risks - New anonymous routes. The token is the only credential: 32 random bytes, stored as a hash, scoped to one checklist, six hours, 300 updates. Text from the agent is shown as plain text (no links or markup), so the worst a leaked token can do is change one checklist's wording until it expires. - One new table and migration (idempotent). - Live delivery is per server process, like every other live event; the 20-second refresh covers a missed event. > 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 - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, Storybook and Playwright screenshots, the in-app browser against a local dev server). ## 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 - [x] 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> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
0aaf946227 |
fix(connections): keep retrying when Google does not confirm a revoked grant (#22669)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Cloud can manage the Google sign-in for a Google Workspace connection. The app keeps the refresh token. Cloud keeps no token. > - When a user removes the connection, the app asks Cloud to end the access at Google (#22065). > - Before this change, the app deleted the token after that call, whatever Cloud answered. If Google or Cloud could not be reached, the access stayed open at Google, and no retry was possible. > - The owner decided on 2026-11-23: the app keeps the token in a pending record and retries until Google answers. Cloud still never stores a provider token. > - This pull request adds that pending record and a background retry. It also covers company deletion and a Cloud-removed instance. > - The benefit is that a removed Google connection does not keep access at Google because of a short outage, and the user does not need to do anything. ## Linked Issues or Issue Description Refs #22065 **What happened?** A managed Google connection was removed while Paperclip Cloud or Google was unavailable. The removal result was `not_ended`, and the refresh token was deleted. Paperclip could not try again, so Google access stayed open. **What did you expect?** Paperclip keeps the token only for the retry, and retries automatically until Google confirms or gives a final answer. The user sees that Paperclip keeps trying, and does not need to act. **Steps to reproduce** 1. Connect Gmail through Paperclip Cloud. 2. Make the broker revoke fail (Cloud unavailable, or Google 5xx). 3. Remove the connection. The token is deleted and nothing retries. ## What Changed - New table `google_pending_revocations` (migration `0502`, additive, `CREATE TABLE` only). It has `company_id` with no foreign key, so a row outlives a deleted company. It stores the token as the same `local_encrypted` material as the connection secret version. It never stores plaintext. It is not a company secret: it is not listed, an agent cannot bind it, and no route reads it. - `google-access-removal.ts`: before the broker call, the app copies the sent token version into a pending row (lease 2 minutes, so a restart during the call resumes). A final outcome deletes the row. A retryable outcome (`provider_revocation_failed`, `revocation_in_progress`, `broker_unavailable`, `broker_error`, `unexpected_error`) keeps it, and the result is the new `retrying`. If the connection secret is still live after the conditional delete (for example, the user signed in again during the call), the row is deleted. - New worker on the `google-pending-revocation` delivery queue (`registerDeadlineWork`; it registers the real next deadline and has no deadline when the table is empty). Each attempt takes a lease on the row and calls the broker with a 15-second timeout. Backoff is 1, 2, 4 ... minutes, up to 6 hours. The hard stop is 30 days. The worker stops without a call if a live company secret holds the same token. - When a retry ends, the worker writes a `connection.google_access_retry` audit event and a `tool_connection.google_access_ended` or `tool_connection.google_access_not_ended` activity entry (labels added to the activity feed). For a deleted company, it writes only a log line. - Company deletion queues every managed Google token of the company inside the delete transaction, before the secrets are deleted (`reason = company_deleted`). - When the Cloud connection status check finds the instance `removed`, the app queues every managed Google token (`reason = instance_removed`), then deletes each connection secret. - `ManagedGoogleAccessRemoval.result` gets `retrying` (shared type and OpenAPI schema). The removal message for `retrying`: "Google didn't confirm that Paperclip's access has ended yet. Paperclip will keep trying automatically." It has no link and asks for no action. - Docs: `doc/connections/GOOGLE-WORKSPACE.md` ("Pending revocation"), `docs/api/tool-connections.md`, the help page `docs/guides/board-operator/deleting-connection-data.md`, and a dated decision row in `doc/memory/google-connector-memory.md`. - `tests/runner-e2e/source-sdk-public-inputs.json` refreshed for the changed shared type, as `pnpm verify` asks. ## Verification - `npx vitest run src/__tests__/google-managed-connection-removal.test.ts` (embedded Postgres): 46 pass. Without the fix, 15 fail (red), with the fix all pass (green). New cases: - an unconfirmed token is kept only in the pending row, encrypted, not in the secrets list; the worker retries and deletes the row when Google confirms; audit and activity are written; - the row exists during the broker call, so a fresh worker after a restart revokes it; - `binding_not_known`, `other_connections_remain` and `provider_revocation_disabled` stop the retry; - backoff 1 minute to 6 hours, and give-up at 30 days with a final audit and activity entry; - a live secret with the same token stops the retry without a call; - an older broker's `403 INSTANCE_SUSPENDED` is retried; - company deletion queues the token and the worker revokes it after the company is gone; - a removed instance queues every token, drops the secrets, does not queue again, and the worker revokes. - `npx vitest run src/__tests__/paperclip-cloud-connector-status.test.ts`: the removed-instance hook runs only for `removed`, and a failure does not change the status. - `ui`: `npx vitest run src/features/connections/googleAccessRemoval.test.ts` (7 pass, the new `retrying` case is red without the change). - Also passed: `tool-connection-content-deletion`, its canary, `delivery-work-coordinator`, `idle-local-work`, `packages/db` tests; `server` `tsc --noEmit`. - `pnpm verify` exits 2 (global doc input changed), so required CI supplies the broad coverage. - Not verified: any call to a real broker or to Google. No request was sent to staging, production or Google. ## Risks - Migration is additive (`CREATE TABLE` and indexes on the new table): `online_compatible`. - Paperclip now holds an encrypted token for at most 30 days after removal when Google did not confirm. The token is never usable for tool calls: no grant or connection refers to the row. - Instance removal deletes the managed Google connection secrets. Those connections then need a reconnect after a new enrollment. They could not refresh anyway, because Cloud refuses a removed instance. - Deploy order: either order is safe. With the current production broker, a removed instance's revoke gets `403` and the app retries until the hard stop. The Cloud broker change that accepts it is a separate PR in the private Cloud repository. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) through Claude Code, with tool use (shell, file edits, embedded Postgres tests), standard reasoning. ## 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 - [x] 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> |
||
|
|
2821af0b52 |
fix(db): fail PR CI on a requires_staging migration without an override (#22628)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip Cloud deploys a new release while the previous release still serves the same database > - Core classifies every new migration as `online_compatible`, `requires_staging`, or `unknown`, and the pull-request guard checks the migrations a PR adds > - The guard fails an `unknown` migration without an override, but it only prints a notice for a `requires_staging` migration > - A `requires_staging` release is refused by every stack that serves two releases at once, so continuous deploy stalls until somebody runs a maintenance deploy > - This pull request makes the guard fail a `requires_staging` migration unless the file carries a justified `requires_staging` override > - The benefit is that a migration that forces a maintenance window cannot merge by accident. The author must split it or accept the maintenance deploy in writing. ## Linked Issues or Issue Description Refs #20913 (the classifier and the guard). Refs #22513 (the migration that stalled deploys). **What existing behavior does this improve?** The pull-request migration guard in `packages/db/src/migration-compatibility.ts` and `.github/scripts/check-pr-migration-order.mjs`. **Current behavior** A new migration classified `requires_staging` passes the guard with a `::notice`. Nothing stops it from merging. Stacks that deploy with overlap then refuse the release. **Proposed behavior** A new `requires_staging` migration fails the guard unless the file starts with `-- paperclip:migration-compat requires_staging: <justification>`. The error lists the reasons and tells the author to split the migration into expand and contract steps, or to add the override and accept a maintenance deploy. A justified override passes with a notice that says the release ships with a maintenance deploy. **Reason and benefit** On 2026-11-22 a `requires_staging` migration merged. Continuous deploy to the overlap-deploy staging stacks stalled for about 4.5 hours, and a manual maintenance deploy took 38 stacks offline for a median of about 2.5 minutes each. An explicit decision in the migration file makes this cost visible at review time. **Breaking changes** None for existing migrations. The guard judges only the migrations that a PR adds. A PR that adds a `requires_staging` migration must now add the override or split the migration. ## What Changed - `checkNewMigrationCompatibility` returns an error for a `requires_staging` migration without an override. The error lists the `requires_staging` and `unknown` reasons and the two ways forward. - A `requires_staging` migration with a valid override passes with a notice. It reuses the existing in-file directive and its minimum justification length. There is no new mechanism. - `doc/DATABASE.md` ("Migration compatibility with the running release") says that `requires_staging` fails the PR and when to use the override. - Doc comments in the CI script and the `--check` CLI usage now name both blocking classes. The CLI success line says "none blocked". - Red/green tests in `packages/db/src/migration-compatibility.test.ts` and `.github/scripts/tests/check-pr-migration-order.test.mjs`: `requires_staging` without an override fails, with a justified override passes, with an empty justification fails, and `online_compatible` passes. ## Verification - Red: with the old guard, the new tests failed (vitest: 3 failed of 116; node test: 3 failed of 14). - Green: `cd packages/db && pnpm exec vitest run src/migration-compatibility.test.ts` passes 116 of 116. - Green: `node --test .github/scripts/tests/check-pr-migration-order.test.mjs` passes 14 of 14. - `pnpm --filter @paperclipai/db typecheck` passes, including `check:migrations`. - `pnpm verify` exits 2 because a global CI input changed (`.github/scripts/check-pr-migration-order.mjs`). Required CI supplies the broad coverage. ## Risks - Low risk. The change affects only the PR guard for new migrations. Deployers and the cloud migrator manifest do not change. - An open PR that adds a `requires_staging` migration fails the guard after it rebases. The error says how to fix it. - Note: migration `0500_funny_malcolm_colcord.sql` from #22513 already has a justified `requires_staging` override. This guard passes it with a notice. To stop such a migration at review time, a further policy is necessary, for example a required reviewer for the override. > 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 - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), in Claude Code with tool use (shell, file edits) and extended reasoning. ## 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 - [x] 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> |
||
|
|
7906db1ac9 |
fix(apps): title the Google AI connector "Google Antigravity and Gemini" (#22673)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Connectors page lists the services and model providers that a
company can connect
> - The Google model-provider connector has the title "Google"
> - That title does not tell people that this connector is for Google
Antigravity sign-in and Gemini API keys. It is easy to confuse with the
Google Workspace connectors
> - This pull request changes the connector title to "Google Antigravity
and Gemini"
> - The benefit is that people can find the correct connector for their
Google AI accounts
## Linked Issues or Issue Description
**What existing behavior does this improve?**
The title of the Google model-provider connector on the Connectors page.
**Subsystem affected**
UI: the Connectors page (`/<company>/apps`) and the shared app
definition for `google`.
**Current behavior**
The connector title is "Google". The title does not name the products
that it connects, and people can confuse it with the Google Workspace
connectors.
**Proposed behavior**
The connector title is "Google Antigravity and Gemini".
**Reason and benefit**
People can find the correct connector for Google Antigravity sign-in and
Gemini API keys.
**Breaking changes**
None. The provider id, the app slug, and all stored values stay the
same.
## What Changed
- Change the `name` of the `google` app definition
(`packages/shared/src/app-definitions/google.json`).
- Before: `Google`
- After: `Google Antigravity and Gemini`
- These texts read the name, so they also change:
- Card heading: `Google` -> `Google Antigravity and Gemini`
- Card button accessible name: `Connect Google` -> `Connect Google
Antigravity and Gemini`. The visible button text stays `Connect`.
- Setup screen heading: `Connect Google` -> `Connect Google Antigravity
and Gemini`
- The service name that new connection requests show to agents and in
chat cards.
- Add a Connectors page test that checks the new card title,
description, and button name.
- Resync `tests/runner-e2e/source-sdk-public-inputs.json`, because the
app definition is a pinned input.
Not changed, on purpose:
- The provider id `google`, the app slug `google`, and all stored
values. Existing application rows are found by their
`app-gallery:google` key, not by name.
- The short provider name `Google` in
`ui/src/components/ai-connections/model.ts` and
`packages/shared/src/ai-connections.ts`. Sentences such as "Your Google
default" and default account names such as "My Google API account" use
this name. Account names are stored when people create them, and the
long title makes these sentences awkward.
- The `Google` choice in the model provider picker, next to `OpenAI`,
`Anthropic`, and `xAI`. Its description already says "Antigravity
sign-in or Gemini API key".
- The Google Workspace and Search Console connectors.
## Verification
- Red/green: `cd ui && npx vitest run src/pages/apps/Browse.test.tsx -t
"Antigravity and Gemini"` fails with the old name and passes with the
new name.
- `cd ui && npx vitest run src/pages/apps/Browse.test.tsx` passes (119
tests).
- `cd ui && npx vitest run src/components/ai-connections
src/pages/apps/AppsConnect.test.tsx` passes (362 tests).
- `cd packages/shared && npx vitest run src/app-definitions` passes (50
tests).
- `pnpm verify` exits 2 because the pinned-input registry changed.
Required CI supplies the broad coverage.
## Risks
- Low risk. This is a display text change.
- Old chat cards keep the service name that they stored when they were
created ("Google"). This is only display text.
- The Connectors page matches aggregator apps by slug and name. The slug
`google` does not change, so the match does not change.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in 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
- [x] 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>
|
||
|
|
427d13c38c |
fix(connections): clean up audit-only task traces and wait without rescanning content (#22658)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - #22636 removes connection content (for example Google results) when a task or a company is deleted > - Review on #22636 found two more gaps after it merged > - A task whose only connection trace is an audit entry (for example a denied call) got no cleanup job, so the argument preview stayed after the task was deleted > - A cleanup job that waits for open runs re-ran all content steps on every recheck, which is wasted database work > - This pull request queues a job for audit-only tasks and adds a `waiting` phase that only counts open work > - The benefit is that no audit preview of a deleted task is left behind, and a waiting job stays cheap ## Linked Issues or Issue Description Refs #22636 **Problem** 1. Deleting a task whose only connection trace is a `tool_access_audit_events` row with the task's ID creates no cleanup job, so its argument preview stays. 2. While a task cleanup job waits for open runs or approvals, every recheck runs the six content steps again from the start. **Expected behavior** 1. The audit preview is cleared after the task is deleted. 2. A waiting job only checks whether work is still open, and runs the content steps once when the work settles. **Steps to reproduce** 1. Write a denied policy audit entry with the task's ID and no call or call event. Delete the task. The preview stays. 2. Delete a task while one of its runs is working. Each recheck scans every content table of the task again. ## What Changed - `issue-content-deletion.ts`: when the task has no recorded runs, calls or call events, check for an audit entry with the task's ID. If one exists, queue the job. The audit step already matches by task ID. - `content-deletion.ts`: new `waiting` phase. After a content pass with open work, the job moves to `waiting` instead of restarting. Each recheck counts open runs, open calls, open approvals and open wakes with results for the task. When the count is zero, or after the one-day bound, the job runs the content steps once more and finishes. - Moved the pure JSON cleaning helpers to `content-cleaning.ts` to keep `content-deletion.ts` under 1,000 lines. No behaviour change. - Two canary tests: a task with only an audit entry, and a waiting job that leaves new content alone on a recheck and clears it after the open run settles. Both failed before the fix. - The working memory note is updated. ## Verification - `cd server && npx vitest run src/__tests__/tool-connection-content-deletion-canary.test.ts src/__tests__/tool-connection-content-deletion.test.ts src/__tests__/server-startup-feedback-export.test.ts` (156 tests pass). The two new tests failed before the fix. - `cd server && pnpm typecheck` passes. ## Risks - Task deletion with no other connection trace runs one more query on `tool_access_audit_events` for the company, with `limit 1`. That table has no index on the task ID in its details. - No schema change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edit, test runs). Extended reasoning on. ## 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 - [x] 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> |
||
|
|
c294f21a34 |
fix(claude-local): join every row of a hard-wrapped setup-token URL (#22653)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - People connect a Claude subscription from "Connect a model". Paperclip runs `claude setup-token` in a terminal and reads the sign-in link from the output > - When the CLI prints the link as plain text, the terminal hard-wraps it over several rows. `reassembleUrl` joins the rows and validates the result > - It returns the first join that validates. `state` is the last query key and needs only 16 characters, so a join that stops inside `state` can validate one row early > - The leftover row then sits where the prompt should be. Prompt binding returns null, and the sign-in dialog hangs. No truncated URL gets out, because the parser fails closed > - This pull request uses the wrap shape: every row but the last has the same width, so the parser joins until a row is shorter than the first row > - The benefit is that the plain-text path works at every terminal width, not only at the widths where the break misses `state` ## Linked Issues or Issue Description Refs #19949 (the plain-text path section). The fix follows the change that @aron-intframe proposed and measured in the first comment on that issue. The login-method line defect from the same issue is in a separate pull request, as the triage comment asks. Refs #20050 (PTY window size). ## What Changed - `setup-token-parse.ts`: `reassembleUrl` no longer returns at the first join that validates. If the first row validates on its own, the URL is unwrapped, and the parser stops there as before. Otherwise it joins until a row is shorter than the first row, and it returns the last join that validated. - Tests: the 64-column `claude.com` wrap from #19949, a sweep of every width from 40 to 200 columns for both accepted URLs, and a test that a two-row wrap with a valid first row still fails closed. ## Verification - `pnpm exec vitest run packages/adapters/claude-local/src/server/`: 391 passed, 2 skipped. - The 64-column test and the width sweep fail on `master` and pass with this change. - `pnpm --filter @paperclipai/adapter-claude-local typecheck` passes. - With a 385-character URL like the one in #19949, `master` fails at 49 of 161 widths from 40 to 200. This branch passes at all 161. ## Risks - Low risk. Each existing test passes, including the code-like value after the URL, the repeated OSC 8 rows, and the hostile line between fragments. - One gap stays: a two-row wrap whose first row already holds 16 or more `state` characters. One row gives no width to compare, so the parser fails closed as it does today. A 200-column PTY (#20050) avoids this for current URL lengths. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with shell, file edit, and code execution 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
2181df544c |
fix(claude-local): skip the setup-token login-method line (#22652)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - People connect a Claude subscription from "Connect a model". Paperclip runs `claude setup-token` in a terminal and reads the sign-in link from the output > - `parseSetupTokenPrompt` binds the link only when the browser-code prompt follows the URL block. It skips repeated URL rows and the copy hint, and it fails closed on any other line > - Claude Code 2.1.306 prints a new line, `Login method pre-selected: Subscription Plan (Claude Pro/Max)`, between the copy hint and the prompt > - The parser returns null for that layout, and the runner waits for the 5-minute timeout. The dialog stays on "Preparing browser sign-in…", and the log says only "timed out" > - This pull request skips the login-method line with a bounded pattern and logs one fixed line when the prompt is on screen but the parser does not bind it > - The benefit is that Claude subscription sign-in works on Claude Code 2.1.306, and the next layout change shows up in the log at once ## Linked Issues or Issue Description Fixes #19949 Refs #19958 (the same fix by @adity982, written before #19211 changed the copy-hint check; this pull request ports it onto `master` and widens the pattern to other method names). Refs #19211, #15550 (earlier copy-hint fixes). Refs #20050 (PTY window size, a separate fix). Refs #22520 (the 2.1.330 short link, a separate fix in the URL validator). The plain-text URL reassembly defect from the same issue is in a separate pull request, as the triage comment asks. ## What Changed - `setup-token-parse.ts`: add `LOGIN_METHOD_LINE_RE`. `findBrowserCodePrompt` skips a line that matches it. The method name is 1 to 80 characters of prose with no `:`, so a URL or a `code:value` cannot hide in it. Any other unknown line still returns null. - `setup-token-parse.ts`: add `hasSetupTokenPromptLine`. It returns true when the output holds the prompt line. It binds no value. - `setup-token-runner.ts`: when the prompt line is on screen and `parseSetupTokenPrompt` still returns null, log one fixed line: `Setup-token login: the browser-code prompt is on screen, but the parser did not recognize the sign-in screen.` The line holds no input bytes, and the runner logs it at most one time per run. - Tests: the 2.1.306 layout (OSC 8 link per row, CHA-spaced words, copy hint, login-method line, prompt), the login-method line without a copy hint, four malformed login-method lines that must fail closed, and two runner tests for the new log line. ## Verification - `pnpm exec vitest run packages/adapters/claude-local/src/server/`: 396 passed, 2 skipped. - The two positive parser tests fail on `master` and pass with this change. - `pnpm --filter @paperclipai/adapter-claude-local typecheck` passes. - I ran the parser on a synthetic 2.1.306 screen built from the output in #19949. `master` returns null. This branch returns the full URL. - Not run: a live `claude setup-token` sign-in on 2.1.306. ## Risks - Low risk. The change adds one allowlisted line shape. The parser keeps its fail-closed contract for every other line. - A future CLI can print another new line. The parser then still returns null, but the new log line names the cause. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with shell, file edit, and code execution 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
d28becf0f5 |
fix(server): run person-opened gateway sessions as their opener for personal connection grants (#22643)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The tool gateway lets an agent run call connected apps through a short-lived session > - A person on the board can also open a gateway session for a running agent > - Such a session resolved credentials for the run's responsible person, not for the person who opened it > - A member could therefore use another member's personal connection grant through that member's running agent > - This pull request limits personal grants in a person-opened session to the grant owner and requires permission to act on the agent > - The benefit is that a personal connection is used only by its owner or by the owner's own agent runs ## Linked Issues or Issue Description Refs #22635 **What happened?** `POST /api/tool-gateway/sessions` let any non-viewer member open a session for any running agent in the company. Tool calls in that session used the personal grant of the run's responsible person. **What did you expect to happen?** A person who opens a session can use a personal (user-owned) grant only when they own it. The person needs permission to act on the agent. Company-shared connections and agent-opened sessions work as before. **Steps to reproduce** Two members are in one company. Member A has a personal grant on a connection that agent X uses. While a run of X is active, member B opens a gateway session for that run and calls a tool on that connection. The new route test covers this case. **Impact** Access-control hardening for personal connection grants. ## What Changed - Add the nullable column `tool_gateway_sessions.created_by_user_id` (migration `0502`, which also adds `tool_mcp_tasks.created_by_user_id`). The route sets it when a person (not a local implicit board) opens a session. - Grant resolution for such a session acts as the person who opened it. That person's own personal grant is used, or a connect card is addressed to that person. Another member's personal grant is never selected, and that member gets no card. - The opener is recorded on the tool invocation (server-written `policyExplanation.sessionOpenedByUserId`) and restored when an approved action runs. An approved call from that session therefore uses the same person's grant. - A guard after grant resolution refuses a user-owned grant of another person with `403` and `reasonCode: personal_grant_owner_required`, as defense in depth. - Saved-call replay is scoped to the opener: idempotency keys get an opener suffix for such sessions, and approval replay matches only invocations recorded with the same opener. The lookup of keys saved before this change still runs: a saved call that can be attributed to the same person replays, one attributed to another person does not, and one that cannot be attributed returns the existing `legacy_tool_idempotency_unverifiable` conflict instead of running the write again. - Long-running provider tasks (`tool_mcp_tasks`) record the opener in a new `created_by_user_id` column (same migration) and restore it on each background poll, so the task keeps the opener's grant and is attributed to the opener. - Managed GitHub identity selection uses the opener, in the first and the fallback selection. - A call attaches to an existing long-running provider task only when the task uses the same grant the call resolves to. On a personal grant it must also be the same person (an agent session matches only tasks with no opener; the grant owner may also collect a legacy task with no opener). On a shared grant any person may collect. The wake for a finished task now carries the task id, so the agent's continuation resolves the opener's grant and collects the result instead of calling the provider again. - `POST /api/tool-gateway/sessions` checks the existing `agent:wake` permission for a board caller, the same check as invoking the agent. - Agent-opened sessions do not set the column, so agent runs and the recovery of interrupted runs do not change. - Document the rule in `doc/MCP-ACCESS-GOVERNANCE.md`. - I checked the sibling routes. Named gateway tokens minted by a person need `tools:admin` and carry no responsible person. Board test calls and MCP app view calls already run as the caller. Stored MCP task continuations stay pinned to the grant they started with. ## Verification - New route tests in `server/src/__tests__/tool-gateway.test.ts`: - Three members, two with personal grants, on a run that belongs to the first. A session opened by the second member uses only that member's credential. The run owner's session and an agent-opened session use the run owner's credential. A member with no grant gets `409 user_authorization_required`, the card is addressed to that member, and the remote server gets no request. A reviewed call from the second member's session, once approved, runs with that member's credential. The same write from two people's sessions runs once for each person, and only the same person's retry replays. - A pre-upgrade saved write retried by the same person replays (or conflicts when it cannot be attributed) and never reaches the provider twice; another person's identical write runs. - `mcp-tasks.test.ts`: a person-started task keeps the opener's grant through a background poll; an agent retry never receives that task's result and keeps its own task; the continuation after a wake collects once with no new provider call; on a shared grant another person collects the task, including a task started before openers were recorded. - `tool-gateway-service.test.ts`: an opener with their own managed GitHub grant uses it; an opener without one is refused and the run owner's grant is never used. - A viewer cannot open a session for the agent. - Before the fix, the second member's session used the run owner's credential, and the viewer got `201`. Both tests pass now. - `npx vitest run src/__tests__/tool-gateway.test.ts src/__tests__/connection-management.integration.test.ts src/__tests__/mcp-tasks.test.ts`: with `tool-access-service.test.ts` and the policy tests, 833 tests pass. - `tsc --noEmit` for `server` passes. - `pnpm verify` exits 2 because a global CI input (a doc) changed. Required CI gives the broad coverage. ## Risks - A person who opened a session for another member's run used that member's personal grants before. Now the session uses the opener's own grants. This was not an intended flow. Shared connections and agent runs do not change. - A person-opened session that repeats exactly the same side-effecting call an agent session already made in the same run gets a `409` conflict instead of a second write, because that earlier call has no recorded opener. Use a new explicit idempotency key for an intentional repeat. - The migration only adds nullable columns. Sessions and review requests created before this change have no opener record and keep the previous behavior until they expire (15 to 60 minutes). - Follow-up, out of scope: in the experimental MCP Tasks path, a call with a new explicit idempotency key and the same arguments still attaches to the same person's open task under the same grant. That is the existing de-duplication for every caller and does not depend on the opener rule. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use and code execution. ## 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 - [x] 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> |
||
|
|
b865dd112b |
feat(google-workspace): run Gmail, Drive, Docs, Sheets, Slides and Calendar on Paperclip's REST tools (#22634)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The built-in Google Workspace connector gives agents Gmail, Drive, Docs, Sheets, Slides and Calendar actions through one connection > - Google's hosted Workspace MCP servers are a Developer Preview, so Paperclip cannot offer them to the public > - Paperclip has its own REST tool set for all 36 allowlisted actions, but every service still sent its calls to Google's MCP servers > - The owner decided on 2026-11-23 to launch all six services on REST now and to live-test on the staging tester after deploy > - This pull request switches the six services to `paperclip_rest` and fixes what the switch breaks > - The benefit is that the connector no longer depends on Developer Preview servers, and agents get all 36 actions, including the two Gmail actions Google's live server did not offer ## Linked Issues or Issue Description Refs #22016 (the transport switch), #22000, #22014, #22017, #22027, #22028, #22029 (the REST tool set). **Subsystem affected** Built-in Google Workspace connector (`google-workspace`, `workspace.all`): transport setting, catalog publication, tests and docs. **Problem or motivation** All six launch services used Google's hosted MCP servers. These servers are a Developer Preview and are not available to the public. Google's live Gmail MCP server also did not offer `gmail__list_threads` and `gmail__search_messages`. **Proposed solution** Set Gmail, Drive, Docs, Sheets, Slides and Calendar to `paperclip_rest` in `GOOGLE_WORKSPACE_TOOL_TRANSPORT`. Keep Chat, People and Search on `google_mcp`. Fix the catalog refresh so that an existing connection keeps its actions active after the switch. **Alternatives considered** Switch one service at a time after a live test (the Nov 17 rule). The owner replaced this rule on Nov 23: switch all six now and fix forward. **Roadmap alignment** This is the planned launch step for the Google Workspace connector. It does not overlap other core work. ## What Changed - `packages/shared/src/google-workspace-connectors.ts`: set `gmail`, `drive`, `docs`, `sheets`, `slides` and `calendar` to `paperclip_rest`. `chat`, `people` and `search` stay `google_mcp`. - Connections saved before the switch keep Google's MCP definitions in their catalog. Two changes make them work with no user action: - New resolver `paperclipDefinedTool(connection, toolName)` in `server/src/services/connectors/paperclip-defined-tools.ts` (typed result). It is the one place that says which tools are Paperclip-defined; for a `google-workspace` connection it calls `googleWorkspaceRestToolDefinition` in the dispatch adapter, which returns the REST definition when the service is on `paperclip_rest`. - `server/src/services/tool-gateway.ts`: when the gateway lists a connection's tools, it takes the input schema, output schema, description and annotations of a Paperclip-defined tool from the resolver, not from the saved row. Routing and the advertised definition read the same transport setting in the same process. This is an in-memory lookup, so it adds no request to the turn start. Example: an agent gets the REST `docs__update_doc` schema, where `writeControl.requiredRevisionId` is required, not Google's schema, where it is optional. - `server/src/services/tool-access/catalog/publication.ts`: catalog publication asks the same resolver. It never holds a Paperclip-defined action for review, and it clears the review hold (`quarantined`, `pending_review`) of an action held only because a remote definition changed. Clearing the hold does not count the action as new, so it is never added to the profile: Off stays Off and Ask first stays, also for a held action. Only actions the connection never had (Gmail `list_threads` and `search_messages`) get the default for new actions. Before this fix, a refresh after the switch put every action of an existing managed connection into `pending_review` (10 of 10 in the regression test). - `server/src/__tests__/google-workspace-rest-transport.test.ts`: the fake Google now answers the Docs, Sheets and Slides REST hosts and the Drive and Calendar paths. New tests: - The transport map has exactly the six launch services on `paperclip_rest`. - A full read and write grant lists exactly the 36 allowlisted actions (with `gmail__list_threads` and `gmail__search_messages`) and sends no MCP request. A read-only grant lists the 23 read actions. Gmail, Drive and Calendar group grants list exactly their actions. - One read and one write per service run through the real `executeTool` path on REST with the default policy (no approval request). Each call records the invocation and the `call_completed` event with the connection ID (the "Delete data" bookkeeping keys), and audits the protocol `Google Workspace REST` with the service endpoint. - Injected instructions in Docs, Sheets, Slides, Drive and Calendar REST results are blocked. - An existing connection discovered over MCP keeps its actions active after the switch and can call the new Gmail actions. - Migration without refresh: a connection saved with Google's MCP schemas (`update_doc` with `writeControl` optional) advertises the REST schemas after the switch with no refresh, and `read_doc` then `update_doc` with the revision succeed over REST. - The first refresh after the switch releases an action held for `pending_review`, keeps an Off action unlisted and keeps Ask first (`approval_required`). - An action that is both Off and held stays Off, and one that is both Ask first and held stays Ask first, after the switch and after two refreshes. - The MCP-path test pins Gmail and Docs to `google_mcp` explicitly. - `server/src/__tests__/helpers/google-workspace-transport.ts`: new helper `useGoogleMcpTransport()`. Tests whose fixtures act as Google's MCP servers use it (`tool-access-service`, `tool-gateway-service`) or pin the transport in `beforeAll` (`google-workspace-injection-screening`). These tests still cover the MCP path, which stays available for Chat, People, Search and a switch back. - `packages/shared/src/google-workspace-connectors.test.ts`: assert the new transport map. - Docs: `doc/connections/GOOGLE-WORKSPACE.md` and the REST folder `README.md` say that the six services run on REST. `doc/memory/google-connector-memory.md` has three dated Nov 23 decisions (all six switched to REST, writes default to Allowed, image-by-URL inserts allowed), and the two items are removed from "Still open". ## Verification - Red: after the flip, 50 tests failed in four files because their fixtures act as Google's MCP servers. These are fixture assumptions, not product bugs. - Red: without the gateway change, the migration test gets Google's saved schema; without the publication change, the held action stays `quarantined`; without excluding released rows from the new-action default, the Off and held action comes back. All green with the fixes. - Red: the new test "keeps an existing connection's actions usable when its services move from Google's MCP servers to REST" failed before the `publication.ts` fix: 10 catalog entries were `quarantined` with `pending_review`. Green after the fix. - `cd server && npx vitest run src/__tests__/google-workspace-rest-transport.test.ts src/__tests__/google-workspace-injection-screening.test.ts src/__tests__/tool-gateway-service.test.ts src/__tests__/tool-access-service.test.ts src/services/google-workspace-rest-dispatch.test.ts src/google-workspace-rest-tools`: with `connection-management.integration.test.ts` added: 60 files, 2232 tests pass. `google-workspace-rest-transport.test.ts`: 52 tests pass. - `cd packages/shared && npx vitest run src/google-workspace-connectors.test.ts`: 14 tests pass. - `npx tsc -p server/tsconfig.json --noEmit`: no errors. - Trace of a read (`gmail__get_message`) and a write (`gmail__create_draft`) through `executeTool` in `server/src/services/tool-gateway.ts`: policy decision and invocation record (13723, 13731), approval gate (13820), `call_allowed` audit (13885), dispatch to `executeRemoteHttpTool` (13915), prompt-injection screening of the result (13964), `call_completed` event and audit (14022, 14044), failure audit (14187). In `executeRemoteHttpTool` the grant scope check (8172) runs before the REST branch (8276), which rechecks the current grant and returns before any MCP session, MCP Task or elicitation code. The REST adapter (`google-workspace-rest-dispatch.ts`) calls `google-http.ts` only through the gateway's guarded fetch. - Not verified: calls against real Google. The live test on the staging tester runs after deploy. ## Risks - Real Google answers can differ from the fixtures. The REST tools are not yet run against real Google. The live test on the staging tester runs after this deploys, and problems are fixed forward. - The OAuth client on the staging tester is marked for AI agents and was only used through MCP. If Google refuses REST calls from that client, all six services fail on the tester until the client changes. - Existing connections keep their stored MCP schemas until a catalog refresh, but agents receive the REST definitions at once. The stored risk level of the four update actions stays `write` until that refresh, then becomes `destructive`. The two new Gmail actions appear after a refresh. - Input differences between Google's MCP schemas and the REST tools are listed in the REST folder `README.md` ("Input differences an agent meets after a switch"). Agents receive the REST schemas, so these differences are visible to them. No `tools/list` from Google's servers is recorded, so the check uses Google's published references. - Accepted risk (owner decision, 2026-11-23): Docs and Slides edits may insert an image from any public web address. Google, not Paperclip, fetches the address, and Paperclip's own requests still go only to the allowed Google hosts. The residual risk is that an agent could put data in the address it chooses. Links to Drive or Docs files stay refused. - Update actions (`update_doc`, `update_presentation`, `update_spreadsheet`, `update_event`) are labelled destructive on REST, as decided on Nov 17. This does not add an approval step: write actions stay Allowed by default. - A switch back to `google_mcp` stays possible with a one-line change. The MCP path tests still run. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through 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 - [x] 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> |
||
|
|
ba1b0585bc |
fix(server): send deployment OAuth client secrets only to the token endpoint they are configured for (#22649)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - App connections sign in with OAuth, and an operator can set a deployment-wide OAuth client with `PAPERCLIP_TOOL_OAUTH_*` variables > - The server picked that client by a provider name, and a connection's own settings could set both the provider name and the token URL > - So a deployment client secret could go to a token URL that the deployment did not choose > - A deployment secret must go only to the endpoint of the app it was set up for > - This pull request pins each deployment client to the token endpoint that its app definition fixes, and fails closed for any other endpoint > - The benefit is that member-entered or custom endpoints get only a member-entered client ## Linked Issues or Issue Description Refs #22635 **What happened?** `configuredOAuthClientForConnection` returned the deployment client for any connection whose provider name matched, or the unsuffixed client for any connection. The token exchange then sent that client secret to the connection's token URL. **What did you expect to happen?** A deployment client goes only to the token endpoint that its app definition fixes. A custom endpoint needs a client that the member adds. **Steps to reproduce** Set a provider-specific deployment client. Create a custom connection that names that provider and a different token URL, and start sign-in. The new unit tests cover this case. **Impact** Secret-handling hardening for deployment OAuth clients. ## What Changed - `configuredOAuthClientForConnection` now takes the token URL that the caller will post to. It returns a deployment client only when the connection comes from a real app definition, the provider is that app, the method lists `customer` ownership, and the token URL equals the method's `defaults.tokenEndpoint` (or, when the method fixes no token endpoint, is on the exact host of its fixed server, discovery, metadata or authorization URL). - A pasted (custom) server never gets a deployment client, including the unsuffixed one. It needs a client of its own, or CIMD or dynamic registration. - The token URL is required at every call site: start, callback, connection refresh and grant refresh. - When a deployment client exists but the endpoint does not match, and the connection has no client of its own, sign-in fails with `oauth_instance_client_endpoint_mismatch` and a clear message. - Pin `defaults.tokenEndpoint` in the Asana and Railway definitions, whose token endpoints are on another host than their MCP servers. - Update `doc/connections/GENERIC-REMOTE-MCP.md` and `doc/connections/CONNECTOR-PLAYBOOK.md`. ## Verification - New `server/src/services/tool-access/oauth/client-settings.test.ts` (16 tests): other hosts, a path that resolves elsewhere, plain HTTP, vendor subdomains, another port, a missing URL, empty or padded gallery markers, colliding host names, a custom connection that names a provider, the unsuffixed client on a custom connection, and a connection that names another app's provider all get no deployment client. Slack's fixed endpoint, Notion's server host and the pinned Asana and Railway endpoints still get it. These cases failed before the fix and pass now. - `server/src/__tests__/generic-mcp-connection.test.ts` and the machine-to-machine test in `tool-access-service.test.ts` now check that a pasted server never receives the deployment client or secret. Both failed before the fix. Two other pasted-server tests now use a client of their own. - A positive test sends the Slack deployment client to Slack's pinned token endpoint, with its secret, and nowhere else. - The connect route keeps the draft and returns `manualClientRequired` with a plain reason when a deployment client cannot be used (route and UI tests). - `npx vitest run` on the OAuth service and connection tests: 686 tests pass. Shared app-definition tests pass. `tsc --noEmit` for `server` passes. - `pnpm verify` exits 2 because a global CI input (a doc) changed. Required CI gives the broad coverage. ## Risks - A self-hosted deployment that used `PAPERCLIP_TOOL_OAUTH_*` for a pasted server must add a client to that connection. Sign-in shows a clear error instead of sending the secret. - A gallery app with `customer` ownership whose token endpoint is on another host than its fixed URLs needs `defaults.tokenEndpoint` to keep using a deployment client. Asana and Railway are pinned here. Box, Notion, PostHog, Sentry and Xero rely on the same-host rule: if their discovery returns a token endpoint on another host, a deployment-wide client is refused until the endpoint is pinned, and a client added to the connection always works. A test lists these apps by name, so a new app must choose. Gallery apps with a fixed token endpoint (Slack, Linear, Google) do not change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use and code execution. ## 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 - [x] 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> |