mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 05:47:10 +01:00
a00e31967b3833f9afc25745feb9ef63ded5cd7b
8483
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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> |
||
|
|
ec8c1d2102 |
docs(antigravity): record that /swarm is not available over the 1.5.2 ACP server (#22700)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip runs Google Antigravity through Google's ACP server, pinned at 1.5.2 > - Google Antigravity has a `/swarm` command that runs a coordinator, workers and a verifier > - The qualification plan said only that the ACP layer has no "Orchestrator mode", which mixes two features > - This pull request records what `/swarm` is, that the pinned server does not offer it, and what Paperclip does with it > - The benefit is that the owner can decide how to support `/swarm` from facts, not from a guess ## Linked Issues or Issue Description **What is the issue?** The Antigravity qualification plan does not say whether `/swarm` works through Paperclip. It names only "Orchestrator mode", which is a different feature. **Where is it?** `doc/plans/2026-11-22-antigravity-qualification.md`. **What should it say?** It should separate the Orchestrator model from the `/swarm` command. It should record the upstream facts, the live server advertisement, the result of a live `/swarm` task, and the options for support. Refs #22591 ## What Changed - Add a "Swarm (`/swarm`) and Orchestrator" section with upstream facts and sources ([Swarm](https://antigravity.google/docs/swarm), [Slash commands](https://antigravity.google/docs/slash-commands)). - Record the live 1.5.2 advertisement: commands `plan`, `logout`, `usage`; modes `default`, `auto_edit`, `yolo`; config options `model`, `thinking_level`, `mode`. - Record that the bundled SDK has no swarm slash command and no swarm tools, so `/swarm` reaches the model as plain text. - Record the local `/swarm` task result: the agent hired three agents and made three subtasks with Paperclip tools. No native swarm started. - Add a ledger row for `/swarm` and an entry in the excluded list. - Replace the "Orchestrator mode" open decision with options and a recommendation for `/swarm`. ## Verification - `pnpm verify`: no product inputs changed; passed. - Live probe of the installed 1.5.2 closure (`1.5.2-paperclip.2`, darwin-arm64): `initialize`, `authenticate` (`gemini-api-key`) and `session/new`. The probe captured the advertisement above. - One live `/swarm` task on a local instance (Gemini 3.8 Flash, Google sign-in). The parent task finished after five successful runs across four agents. ## Risks - Low risk. The change is documentation only. - `agy acp` (the Antigravity CLI ACP server) is not verified. The text says so. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), 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 - [ ] 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> |
||
|
|
8957941656 |
fix(ui): keep AI accounts compatible with harness selection (#22691)
Clear incompatible managed AI accounts when a saved agent changes harness. Filter account choices by saved routing metadata and the selected model. Keep supported Pi accounts before model selection and preserve heartbeat and debug edits in connection saves. Make managed OpenCode and Pi accounts optional. Preserve harness sign-in through setup saves and reopening. Put Connect beside missing-default errors and cover managed versus host-auth model selection. Supersedes #17411. Fixes #14078. Co-Authored-By: Luri Darmawan <luri@carik.id> Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
b0d2500a63 |
test(server): split the Cloud SSH workspace heartbeat runs into per-harness files (#22629)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Each pull request runs CI, and the slowest check sets the time until a reviewer sees a result > - The server tests run in 12 shards, and the slowest shard sets that time > - In PR run [45186146272](https://github.com/paperclipai/paperclip/actions/runs/45186146272), the slowest check was **General tests (server (3/12))** at **872s** > - One file in that shard, `server/src/services/ssh-remote-workspace.integration.test.ts`, took **317s** on one worker, because its 11 heartbeat runs against a real SSH server ran one after another > - This pull request moves the shared setup into a fixture and divides the heartbeat runs into four files that can run in parallel > - The benefit is a shorter slowest server shard and more even shards ## Linked Issues or Issue Description No public issue exists. This is the problem: **Problem / motivation** The file `ssh-remote-workspace.integration.test.ts` took 317s in CI (`PAPERCLIP_TEST_TIMING`). The next slowest file in the same shard took 206s. The slowest files in the other shards took about 110s or less. The file was also over the 180s limit for oversized test files. Most of the time came from the 11 `it.each` heartbeat runs. Each run does a full heartbeat and a follow-up against a real SSH server. **Proposed solution** Move the shared embedded-Postgres and SSH setup and the heartbeat-run body into a fixture. Divide the heartbeat runs into one file for each large harness family, and one catch-all file for the other harnesses. **Alternatives considered** Increase the shard count. That makes every server shard pay the setup cost again and does not make the 317s file shorter. Run the `it.each` cases concurrently in one file. That puts many heartbeat runs on one shared SSH server and one database, which can cause flaky tests. ## What Changed - `__tests__/ssh-remote-workspace-fixture.ts` now holds the shared embedded-Postgres/SSH setup (`useSshWorkspaceFixture`), the harness table, and the heartbeat-run body (`describeSshHeartbeatRuns`). The body was moved without changes. - `ssh-remote-workspace.integration.test.ts` keeps its two durable-workspace tests and uses the shared fixture. - The heartbeat runs are now in four files: - `ssh-remote-workspace-heartbeat-claude` (2 runs) - `ssh-remote-workspace-heartbeat-codex` (2 runs) - `ssh-remote-workspace-heartbeat-gemini` (2 runs) - `ssh-remote-workspace-heartbeat-cli` (5 runs). This file uses `exclude`, so it runs every harness that does not have its own file. A new harness gets coverage automatically. - Each file gets its own Postgres, temporary root and sshd. Company `issuePrefix` values still come from the global run index, so they stay unique. **Expected savings:** The largest single file goes from about 317s to about 60–120s. After the timing-weighted balancer has data for the new files, shard 3/12 should go from about 872s to the level of the other server shards (about 790–855s). That is about **20–80s off the slowest server shard**. The PR critical path gets the same saving when this shard is the last to finish. ## Verification - Run `pnpm --filter @paperclipai/server exec vitest run src/services/ssh-remote-workspace` on a machine with sshd. Locally with sshd and embedded Postgres: **5 files passed, 13 tests passed** (2 + 11, the same count as before), 210s wall time with the files in parallel. - CI on this PR: all server shards, the serialized suites and typecheck passed. - Compare the timing of the new files in the CI timing output of a later run. ## Risks - Low risk. The change only affects test files. Product code does not change. - Each new file starts its own embedded Postgres and sshd. This adds a small setup cost per file, but the files run on different workers. - If a harness is added to the `claude`, `codex` or `gemini` include lists but is not added to the `exclude` list of the catch-all file, it runs twice. It is not skipped. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), by 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: devinfoley <139239+devinfoley@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4e1d49067c |
Align Inbox, Tasks and Audit toolbar controls (#22675)
## Thinking Path
> - Paperclip helps people manage agents and tasks.
> - Operators switch between Tasks, Inbox, and Audit to review work.
> - Inconsistent menus and shifting controls make those pages harder to
use.
> - Shared dropdown components keep the controls familiar.
> - This change aligns the menus and keeps room for both Audit
descriptions.
## Linked Issues or Issue Description
**What happened?**
Inbox used native dropdowns. Menus could touch the edge of a phone
screen. The Audit scope control moved when its description wrapped.
**Expected behavior**
Menus keep at least 8px of clearance. Switching Audit scope preserves
the control position.
**Steps to reproduce**
Open each Inbox filter and the Tasks view and filter menus at 320px and
390px. Switch between Activity and Agent Actions on Audit.
## What Changed
- Use Tasks-style menus and shorter filter labels in Inbox.
- Give Inbox and Tasks menus 8px of collision padding.
- Align Audit segments and reserve space for the taller scope
description.
## Verification
- All 129 tests across the Inbox, Audit feed, Tasks page and filter
suites passed after rebase at
|
||
|
|
92cf446fb6 |
fix(native): keep an accepted finish as the outcome after a transient provider refusal (#22676)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Native harness runs end with a result from the agent's finish tool
and a provider terminal
> - A provider can refuse a later request in the same turn after the
finish was accepted (Antigravity 1.5.2 streams its final reply after the
finish)
> - Paperclip counted that run as failed and retried it, so the agent
did the work again and posted the same reply again
> - The product rule is that recovery is automatic and that finished
work is never repeated visibly
> - This pull request makes an accepted done report the run's outcome
when the only later failure is a transient provider refusal (capacity or
rate limit), for every native harness
> - The benefit is one reply per task and no retry for work that is
already done
## Linked Issues or Issue Description
**What happened?**
In a local run of Google Antigravity 1.5.2 (Google sign-in,
`gemini-3.8-flash-low`), Google refused 10 of 17 runs with 503 "No
capacity available". In two runs the agent's finish was already accepted
when the refusal came. Paperclip failed those runs and scheduled the
capacity retry. One task got the same answer three times.
**Expected behavior**
When the agent's done report was accepted and the only later failure is
a transient provider refusal, the run succeeds, the task closes as for
any done report, and no retry starts. A real failure (model not
available, exhausted allowance, rejected sign-in, untyped failure,
cancelled run, no accepted finish) stays a failure.
**Steps to reproduce**
1. Run a native task whose finish tool is accepted.
2. Make the provider fail the same turn afterwards with a typed
`overloaded` or `rate_limit` failure (or Codex `serverOverloaded`).
3. See that the run fails and a capacity retry is scheduled.
**Agent adapter(s) involved**
Not adapter-specific (core bug). Observed with Google Antigravity; the
same path applies to Codex and other native harnesses.
## What Changed
- `native-provider-failure.ts`: the rule
`nativeAcceptedResultOutlivesProviderFailure`. It reads only the
committed terminal and its typed failure. It is true only for a failed
turn with an accepted `done` report and a transient `overloaded` or
`rate_limit` failure (or the classified Codex overload). Other accepted
dispositions keep the bounded capacity retry.
- `native-accepted-outcome.ts` (new): the decision is made once, when
`PaperclipControlPlanePort.completeRun` accepts the result, and saved as
`acceptedOutcome` beside the raw terminal in
`native_run_results.result_json`. The raw terminal does not change,
because it is part of the accepted result's integrity digest. No
migration: the field is optional JSON, and a row saved by an older
release keeps its raw terminal as before.
- Every reader of the run outcome uses that saved value: the executor's
adapter result, the finalizer, the projection repair pass
(`native-run-projection.ts`, also in SQL), accepted-result settlement,
and the run's saved `prpRunTerminalState` (read by the exhausted and
superseded finalization paths).
- The run records a closed diagnostic
`providerFailureAfterAcceptedResult: { provider, category }` and no
provider text. Its warm provider session stays open
(`nativeRetainsWarmSession`): the refusal came from the remote model
service and the turn ended cleanly, so closing it would only cold-start
the next message.
- `doc/plans/2026-11-22-antigravity-qualification.md`: records the first
completed prompts on 1.5.2 and the open decisions below.
## Verification
-
`server/src/services/native-runtime/native-provider-overload.integration.test.ts`
(embedded Postgres, executor and finalizer, replayed twice):
- New: accepted finish, then a typed capacity refusal, a typed rate
limit, or Codex `serverOverloaded`: the run succeeds, the task is done,
no successor run, no failure report. Red before the fix (3 failed),
green after.
- New: after the finalizer commits, a restart that leaves the run
`running` is settled by the projection repair pass as succeeded, with no
failure report; the saved `prpRunTerminalState` is `succeeded`. Red
before the stored outcome (projection flipped the run to failed).
- New: a row saved without the accepted outcome (older release) stays
failed through finalizer and projection.
- New guards: accepted finish, then model unavailable, exhausted
allowance, rejected sign-in or an untyped failure: the run still fails
and the task is not done.
- Existing capacity-retry cases (accepted `needs_review` result) still
retry after one and two minutes, then block.
- `server/src/services/native-runtime/native-provider-failure.test.ts`:
new unit cases with the real Antigravity observation (503 and 429
outlive the finish; model, quota, sign-in, unknown retryability,
timeout, `needs_review` and cancelled do not). 70/70 pass.
- `tsc --noEmit` for `server`: clean.
- 40 neighbouring test files that import the port, projection,
settlement or finalizer: 4,193 passed, 10 failed. The same 10 fail with
the base source (missing local bundled skill file and a runnerd fixture
directory), so they are local-environment failures.
- `pnpm verify` selected 2,980 of 3,857 test files (core native-runtime
modules changed), which is a full-suite run. I stopped it after its
first group (4 files, 85 tests) passed and left the broad suite to
required CI, as AGENTS.md section 7 says.
- Not run live: the fixed behavior has not been re-run against Google.
The evidence came from a local instance before this change. Daytona and
the API-key route were not run.
## Risks
- Behavior change for every native harness: a failed turn with an
accepted done report and a transient refusal now ends as success. A done
report still goes through the same completion policy, deliverable
evidence check and review stages as any done report.
- A run whose result was saved by the previous release and finalized by
this one keeps its raw failed terminal (old behavior), consistently in
the finalizer and the projection (tested).
- Not fixed here, open for an owner decision:
- A capacity refusal before any accepted result takes the saved-work
replacement path (about 30 s, task shown as blocked meanwhile). One
after an accepted result takes the bounded capacity retry. The
Antigravity classifier already types both as `overloaded`/`transient`;
the split is by path. Moving the first kind to the capacity retry skips
the replacement's stop proof and unconfirmed-action check.
- Antigravity 1.5.2 streams the provider's error text as agent text
before it ends the turn, so the live transcript shows it like a reply. A
fix belongs in the runner driver.
- Follow-ups seen in the same evidence, not fixed here: the finish tool
once refused a reply that cited a workspace-only file before the agent
registered a deliverable.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, local 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>
|
||
|
|
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> |
||
|
|
4434d12e2f |
fix(setup-token): back off cleanup retries after failed sweeps (#19446)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A setup-token login keeps a durable cleanup record. The setup-token reaper releases its provider lease and removes the record > - A sweep that fails keeps the record and retries on the next 30-second tick, for as long as the failure lasts > - During a provider outage, that is a steady stream of provider calls and log lines with no recovery benefit > - This pull request backs off consecutive failed sweeps from 30 seconds to 30 minutes and resets after a successful sweep > - The benefit is less load and log noise during outages, with the same recovery once the provider is back ## Linked Issues or Issue Description Refs #14777 (fixed by #15200 and #22667; this pull request adds the retry backoff that the report also asked about). This pull request was rebased onto `master` and reduced to the backoff. #15200 already makes a blank lease lookup return null, and #22667 already logs the failure class and code and covers a restart with a PostgreSQL test. The earlier redacted-message logging is removed, because the reaper now logs no error message. **What happened?** When a setup-token cleanup sweep fails, for example because the sandbox provider is down, the cleanup worker retries every 30 seconds until the failure ends. Each retry calls the provider again and logs again. **Expected behavior** Repeated failures back off. A successful sweep returns to the normal interval. **Steps to reproduce** 1. Make `releaseById` fail for a reapable setup-token record. 2. Watch the setup-token cleanup worker. It retries the release every 30 seconds without a limit. ## What Changed - `setup-token-reaper.ts`: count consecutive failed sweeps (a sweep with a failed record, or a sweep that throws). `retryDelayMs()` returns 30 s, 60 s, 120 s and so on up to 30 min, and 0 after a successful sweep. - `login-cleanup-work.ts` and `index.ts`: the setup-token cleanup duty passes `retryDelayMs` to the shared scheduler. The next run waits for the larger of the configured interval and the backoff delay. - `setup-token-session.ts`: skip the provider call for a reapable record with no lease id and remove the record directly. - `index.ts`: the sweep log line says "cleared records", because a record without a lease is cleared with no release. - `setup-token-session.ts`: the failure log line says "a cleanup failed", because a failure can now come from removing the record as well as from the provider release. - `doc/heartbeat-internals.md`: document the retry behavior. - Tests: backoff to the cap and reset (`setup-token-reaper.test.ts`), backoff after a thrown sweep, removal of records without a lease, and the scheduler honoring the backoff across notifications for both a sweep with failed records and a sweep that throws (`login-cleanup-work.test.ts`). ## Verification - `pnpm exec vitest run server/src/services/setup-token-reaper.test.ts server/src/__tests__/login-cleanup-work.test.ts server/src/services/setup-token-session.test.ts`: 3 files, 98 tests passed. - The seven new tests fail without the source changes. - `pnpm --filter @paperclipai/server typecheck` passes. ## Risks - The backoff applies to the whole setup-token cleanup worker. While one record keeps failing, new cleanup can wait up to 30 minutes. Records stay in the database, so nothing is lost. - The failure count lives in memory and resets on restart. The retained rows rebuild the cleanup work. ## Model Used - Original change by the pull request author. Rebased and reduced by 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 |
||
|
|
8ce422e45d |
fix(github): keep published reviews and settle every status comment (#22672)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull requests through one shared main PR comment and one comment per inline request > - Paperclip writes status notices into these comments: "Work is paused", "This turn ended without publishing a final response", "Working on this…" > - On recent PRs these notices replaced finished reviews, and many never changed again, even after the task was done > - People then see a stale status instead of the review, and work that waits on the review slows down > - This pull request keeps published reviews in place and makes every status comment settle > - The benefit is that the PR always shows the latest real review, and no placeholder stays open after the task is idle ## Linked Issues or Issue Description **Describe the bug** Review bot comments on GitHub pull requests show "Work is paused. Your request is saved." or "This turn ended without publishing a final response." after the review finished. The comment never updates. Inline replies stay at "Working on this…". **Steps to reproduce** 1. A review agent publishes a review in the main PR comment. 2. Two more review requests arrive. The task becomes blocked for a short time, or the run for a request ends without a reply. 3. The main PR comment now shows the status notice. The review is gone. 4. Separately: request A's run ends and request B's run starts a few seconds later. A's inline comment stays "Working on this…" forever. **Expected behavior** A status notice for one request never replaces a published review in the shared main PR comment. Every request comment settles once the run that woke for it is finished and the task is idle. **Evidence** GitHub edit history shows the overwrite on all six settled stuck comments across #22528, #22591, #22611, #22626 (two bots) and #22635. Example: on #22626 the "Ponytail Paperclip Review — 3/5" body was replaced by "Work is paused" at 14:28 and again at 14:56; Feynman's reply was replaced and then patched nine times in four minutes. The task ran 15 back-to-back runs about 3 seconds apart, so the old "latest run only" check never matched the earlier requests. ## What Changed - `writeGitHubResponseComment` takes a `status` flag. In the shared main PR comment, a status notice never replaces a published reply or a newer response. That request settles as final against the existing comment (`published_response_kept` / `status_superseded`) instead of throwing and retrying. - Status notices carry a `paperclip-response-kind:status` marker. Known status texts posted before this change count as status too, so a later status may still replace them. - `readGitHubResponseRun` / `readGitHubResponseRuns` return `finishedRequestRunId`: the latest finished run that woke for the request. It is part of the same statement, so the batched sweep keeps its statement budget. - `githubResponseExecution` settles a request from that run once the task's latest run is finished, the latest run belongs to another request, and the task is not blocked. - `processTerminalResponses` selects a request when any finished run woke for it, not only the latest run. ## Verification - New red/green integration tests in `server/src/__tests__/chat-channels.integration.test.ts`: - `keeps the published review in the main GitHub PR comment when a later request has only a status: ended_without_reply / paused` (red before: body became the status text) - `settles a GitHub working comment whose run finished just before another request's run started` (red before: body stayed "Working on this…") - Updated older tests that asserted the old rule (status replaces the review) to assert the review stays and the request settles final. - `response-run-state.test.ts` equivalence reference now also computes the finished request run; passes over the randomized fixture. - `terminal-response-work.test.ts` statement budget passes (the first fallback did one query per row; it now reads in the same statement). - Local: all GitHub tests in the integration file passed (536) before the batching refactor; after it, the targeted tests plus `server/src/services/chat-channels/github/` and related files pass (438). `tsc --noEmit` for server is clean. CI covers the full suite. ## Risks - Behavior change: when a newer request is paused or ends without a reply, the main PR comment keeps the earlier review instead of showing the status. The status stays visible in the Paperclip task. - A request whose run finished without a reply now settles to "ended without publishing a final response" once the task is idle, even if a later continuation run covered it in another thread. - No migration. ## 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>canary/v2026.1123.0-canary.847500 |
||
|
|
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> |
||
|
|
32375d302f |
test(cloud): read durable-data blocker names from the check() calls (#22686)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The online durable-data migration pass names every blocker that the volume-free readiness check can report > - A test reads the blocker names from `ephemeral-server-contract.ts` with a regex, and checks that the pass names each one > - #22641 added that test. It looks for `blockers.push("...")` > - #22646 merged at about the same time. It moved each check into a `check(area, blocker, inspect)` helper, so the regex now finds no names > - The test fails on master, in `ci / General tests (server (8/12))`, on every pull request > - This pull request changes the regex to read the blocker name from each `check(...)` call > - The benefit is that shard 8/12 is green again, and the test again covers every blocker ## Linked Issues or Issue Description Refs #22641 (added the test). Refs #22646 (changed the source the test reads). Refs #22682 (blocked by this failure). **What happened?** `server/src/services/online-durable-data-migration.test.ts > names every durable-data blocker that readiness can report` fails on master `b865dd112b`: ``` - Expected + Received - ArrayContaining [ "workspaces_require_migration", "local_instruction_copies_require_settlement", "external_agent_instructions" ] + [ "runtime_skill_assets_require_migration" ] ``` **Why?** The regex `/blockers\.push\("([a-z_]+)"\)/g` matched nothing after #22646. Only the constant that the test adds by hand stayed in the list. **Expected behavior** The test finds the 10 blocker names (9 from the source, plus `RUNTIME_SKILL_ASSETS_BLOCKER`) from the `check(...)` calls and checks each one. ## What Changed - Change the scan regex in the test to `/(?:blockers\.push\(|check\(\s*"[a-z_]+",)\s*"([a-z_]+)"/g`. It reads the blocker name from each `check(area, blocker, ...)` call, also when the call spans lines. It still reads the old `blockers.push("...")` form. - No product code changes. ## Verification - `cd server && npx vitest run src/services/online-durable-data-migration.test.ts` - On master: 1 failed, 31 passed (the failure above). - With this change: 32 passed. - The existing `arrayContaining` check still fails if a later refactor makes the scan find nothing again. ## Risks - Low risk. Only one test regex changes. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>canary/v2026.1123.0-canary.847300 |
||
|
|
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> |
||
|
|
ff68490d03 |
fix(ai-connections): say why a local sign-in attempt ended (#22668)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Onboarding and the agent setup screen connect a subscription account
with local sign-in (`useLocalAiLogin`) when the login environment is
local and the server supports it
> - A local sign-in attempt lasts 30 minutes. The client polls `POST
/companies/:id/ai-connections/local/check`
> - The check answers `{ status: "expired" }` whenever the attempt is no
longer waiting for the user, not only after the deadline
> - So a cancelled attempt, an attempt that "Start sign-in again"
replaced, and an attempt that already connected the account all show
"This sign-in attempt expired"
> - This pull request keeps the status and adds the real reason as the
error text that the sign-in panel already shows
> - The benefit is that people see why sign-in stopped, and support can
tell an expiry from a replacement
## Linked Issues or Issue Description
**What happened?**
A person saw "This sign-in attempt expired. Start sign-in again." during
subscription sign-in, well inside the 30-minute attempt window. In
`localAiLoginService().check`, any attempt whose status is not
`waiting_for_user` answers `{ status: "expired" }`. That includes
`cancelled` (a cancel, or a replacement by "Start sign-in again" in
another tab or step), an attempt whose cancel is still in progress, and
`authenticated` (already connected).
**Expected behavior**
"Expired" appears only when the 30-minute deadline has passed. A
cancelled, replaced or completed attempt says what happened.
**Steps to reproduce**
1. Start local sign-in for an account.
2. Choose "Start sign-in again" (or cancel the attempt).
3. Check the first attempt. It answers `{ status: "expired" }`, and the
panel shows "This sign-in attempt expired".
**Paperclip version or commit**
`master` at `5f5ac154368`.
**Deployment mode**
Any deployment where local sign-in is available, including onboarding.
## What Changed
- `local-ai-login.ts` `check()`: an attempt that is `authenticated` or
has a connection answers `{ status: "expired", error: "This sign-in
already connected the account." }`. An attempt that is `cancelled`, or
whose cancel is still in progress, answers `{ status: "expired", error:
"This sign-in attempt was cancelled or replaced by a newer one. Start
sign-in again." }`. An attempt past its deadline or `timed_out` still
answers `{ status: "expired" }`.
- The `LocalAiLoginStatus` type and the client do not change.
`useLocalAiLogin` already shows a server `error` before its default
expiry text.
- Test: `ai-legacy-compatibility.test.ts` covers a replaced attempt, a
cancelled attempt, and a completed attempt.
## Verification
- `pnpm exec vitest run
server/src/__tests__/antigravity-local-ai-login.test.ts
server/src/__tests__/ai-connections.test.ts
server/src/__tests__/ai-legacy-compatibility.test.ts`: 3 files, 186
tests passed.
- The new test fails on `master`.
- `pnpm --filter @paperclipai/server typecheck` passes.
## Risks
- Low risk. The status values stay the same, so client logic does not
change. Only the error text changes for cancelled, replaced and
completed attempts.
- A completed attempt still answers `expired`, so the panel offers
"Start sign-in again". Answering `ready` would let the client reconnect
the same attempt, but it would also start the client's connect flow
again, so this change keeps the existing status.
## 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
|
||
|
|
7f343549db |
fix(ai-connections): tell people why an API key could not be verified (#22666)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - During onboarding, a person can connect a model with a provider API
key. Paperclip checks the key with one request to the provider before it
stores it
> - `validateAiApiKey` returns "The provider rejected this API key."
only for 401 and 403. Every other answer, and every network error,
returns "The provider could not verify this account. Try again."
> - The server does not log the upstream status, so nobody can tell
later what the provider said
> - A person whose key is valid but whose account has no credit, is
rate-limited, or hits a provider outage cannot know what to fix
> - This pull request gives each case its own code and message, and logs
the status and the provider's error type without the key
> - The benefit is that people can fix the real problem, and support can
see the provider's answer in the logs
## Linked Issues or Issue Description
**What happened?**
During onboarding, a person entered a Claude API key and saw "Could not
store the API key: The provider could not verify this account. Try
again." They then switched to a Claude subscription. The server log did
not show which status the provider returned.
**Expected behavior**
The person learns whether the key is wrong, the account has no credit,
the provider is limiting requests, or the provider is down. The server
logs the upstream status.
**Steps to reproduce**
1. Call `validateAiApiKey("anthropic", key, request)` with a `request`
stub that returns 400, 402, 429 or 500.
2. Observe that all four throw `ai_connection_verification_failed` with
the same message.
**Paperclip version or commit**
`master` at `5f5ac154368`.
**Deployment mode**
Hosted onboarding. Self-hosted installs use the same check.
Refs #12675 (related: server-owned user-secret definitions for
onboarding API keys).
## What Changed
- `ai-api-key-failures.ts` (new): one code and message for each result.
The codes are `ai_connection_api_key_rejected` (unchanged),
`ai_connection_billing_required`, `ai_connection_rate_limited`,
`ai_connection_provider_unavailable`,
`ai_connection_verification_timeout`,
`ai_connection_provider_unreachable`, and
`ai_connection_verification_failed` (unchanged, for all other answers).
- `ai-api-key-test.ts`: map 401/403 to rejected (unchanged); 402, or the
error type `billing_error`, `insufficient_quota` or
`insufficient_credits`, to billing; 429 to rate limited; 5xx (including
Anthropic's 529) to provider unavailable. A `TimeoutError` maps to
timeout, and other network errors map to unreachable.
- Log the provider, the HTTP status, the provider's error type and the
result code. The error type comes from `error.type`, `error.code` or
`error.status` in at most 8 KiB of the error body. It is used and logged
only when it is on a closed list of documented provider error types
(Anthropic, OpenAI and xAI, Google, OpenRouter). Any other value is
ignored. The key and the response text are never logged. 401/403 bodies
are not read.
- `adapters/registry.ts` and `agent-environment-test.ts`: keep the
specific code in the environment check instead of collapsing it to
rejected or failed.
- The billing check looks at `error.type`, `error.code` and
`error.status` together, so a 429 with `type: invalid_request_error` and
`code: insufficient_quota` is a billing problem, not a rate limit.
- `tests/runner-e2e`: the connection harness keeps every new code in
`creationFailure` instead of saving it as `connection_request_rejected`.
One shared list feeds `connection-flow.ts`, `connection-evidence.ts` and
`result-validation.ts`, and a test keeps it equal to the server's codes.
- Tests: `ai-api-key-test.test.ts` (17 tests) and
`connection-support.test.ts`.
**The user-facing text needs a person's review.** The new messages are a
first draft. They read after the onboarding prefix "Could not store the
API key:":
| Code | Message |
|---|---|
| `ai_connection_billing_required` | The provider account for this API
key has no credit or billing set up. Add credit with the provider, then
try again. |
| `ai_connection_rate_limited` | The provider is limiting requests for
this account right now. Wait a minute, then try again. |
| `ai_connection_provider_unavailable` | The provider is having problems
right now. Try again in a few minutes. |
| `ai_connection_verification_timeout` | The provider did not answer in
time. Try again. |
| `ai_connection_provider_unreachable` | Paperclip could not reach the
provider. Check this server's network connection, then try again. |
## Verification
- `pnpm exec vitest run server/src/services/ai-api-key-test.test.ts`: 17
passed. On `master`, 11 of the original 15 fail.
- Callers: `ai-connections.test.ts`, `adapters/registry.test.ts`,
`agent-environment-test-status.test.ts` and
`agent-test-environment-routes.test.ts` with the new file: 5 files, 331
tests passed.
- `pnpm --filter @paperclipai/server typecheck` passes.
- Not run: a live check against each provider. The billing mapping uses
the documented error types (`billing_error` for Anthropic,
`insufficient_quota` for OpenAI, 402 for OpenRouter). The models
endpoint may not report a billing problem for every provider.
## Risks
- Low risk. The HTTP status of the store request stays 422, and 401/403
behavior does not change.
- An answer that does not match a known case still returns
`ai_connection_verification_failed`, as before.
- A code that consumers compare by value can now be one of five new
values. No UI code compares these codes, and the server callers now pass
them through.
## 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
|
||
|
|
eada94a6d2 |
fix(storage): answer storage throttling with 503 and retry skill archive uploads (#22664)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - First-agent setup saves the agent's skill packages to object storage (S3 on hosted installs) > - S3 can answer an upload with `503 SlowDown` when it limits the request rate > - The S3 provider retries a throttled upload, but when the retries run out the error reaches the HTTP error handler unclassified > - The person then sees "Internal server error", and the server reports a handler crash for a transient storage condition > - This pull request answers a storage-unavailable error with 503 and retry guidance, and makes the skill archive upload always use the retryable file-source path > - The benefit is that a throttle is retried, persistent throttling gives a clear retryable answer, and crash reports stay for real faults ## Linked Issues or Issue Description **What happened?** During first-agent setup, a skill package upload hit S3 request-rate throttling (`SlowDown`, HTTP 503). The person saw "Internal server error". The server logged `error.handler_crash` with `error_code=SlowDown`. A retry soon after got "This skill package is being saved. Retry after its upload settles." on a build before #22477. **Expected behavior** A transient throttle is retried. Persistent throttling answers with a retryable status and guidance. The same person can retry at once. **Steps to reproduce** 1. Use S3 storage and make the bucket answer `PUT` with `503 SlowDown` until the provider's retries run out. 2. Start first-agent setup, or call `skillPackageStore().prepare` for a new package. 3. The request fails with 500, and the error handler reports a crash. **Paperclip version or commit** `master` at `5f5ac154368`. **Deployment mode** Hosted (S3 storage). Self-hosted installs with S3-compatible storage behave the same way. Refs #22477 (failed upload claims expire at once, so an immediate retry no longer gets 409). Refs #22404 (throttle backoff for small uploads without a source file). ## What Changed - `error-handler.ts`: a recorded storage-unavailable error (throttling, 5xx, timeouts, network failures, as `isStorageUnavailableError` already defines) answers `503` with `Retry-After: 30` and code `storage_unavailable`. The response text is fixed. The handler logs the fixed-shape storage diagnostics (operation, error code, HTTP status, request id) as a warning, not as a crash. Storage credential rejections still report as server faults. - `error-handler.ts`: the client-abort shortcut (`aborted` with `ECONNRESET`, answered as 499) no longer catches a recorded storage failure. A storage read that the backend reset now answers 503 while the caller is still connected. - `storage-unavailable.ts`: add the response text and `recordedStorageFailureDiagnostics`. - `skill-package-store.ts`: pass the staged archive as `sourceFile`. The S3 provider then re-reads the file on each attempt, so it can resend the archive after a throttle even when the shared upload buffer is full. The upload also gets a Content-MD5 check. - The claim behavior from #22477 does not change: a failed attempt's claim expires at once, its exact keys go to the deletion outbox, and a retry uses fresh keys. - New test `storage-unavailable-error-handler.test.ts`: a storage connection reset answers 503, and a storage credential rejection still reports as a server fault. - New test `skill-package-storage-throttle.test.ts` (real PostgreSQL, the real S3 provider, and a local S3 stand-in): a transient `SlowDown` is resent and the package publishes; persistent throttling answers 503 with no crash report, and an immediate retry by the same caller succeeds. ## Verification - `pnpm exec vitest run server/src/__tests__/skill-package-storage-throttle.test.ts`: 2 passed. Both tests fail on `master` (no Content-MD5 on the archive upload; 500 instead of 503). - Related suites (skill package store and upload, error handler, sandbox outage handler, storage-unavailable, S3 throttle and backoff): 17 files, 175 tests passed. - `pnpm --filter @paperclipai/server typecheck` passes. ## Risks - Other routes that fail on a storage outage now answer 503 instead of 500 and do not send a crash report. This is the intent, but storage outages are now visible only as warning logs, not as crash reports. - The archive upload now hashes the archive for Content-MD5 before it sends it. Skill archives are small, so the cost is low. - This change does not explain why one company's prefix hit the S3 request-rate limit. That needs a separate operations check. ## 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 |
||
|
|
0bff5abd04 |
fix(setup-token): log why a reaper release fails and guard restart cleanup (#22667)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A Claude subscription login in a sandbox environment runs `claude setup-token` and keeps a durable cleanup row with the session and its provider lease > - The setup-token reaper releases the lease and removes the row when the session is terminal, past its deadline, or consumed > - #14777 reports a reaper that failed to release the same leases every 30 seconds forever after a restart, and logged no cause > - #15200 later fixed the cause: a session with no lease had a blank lease id, and the UUID lookup for it failed on every sweep > - The reaper still discards the error, so the next permanent failure will be just as hard to diagnose, and no test covers the restart case > - This pull request logs the error class and code, and adds a PostgreSQL regression test for the reported restart case > - The benefit is that operators can see why a release fails, and the restart cleanup stays fixed ## Linked Issues or Issue Description Fixes #14777 Refs #15200 (the blank lease id fix). Overlapping open pull requests for the same issue: #15363 (logs the full error message), #16663, #18706, #19446, #18088, #14236. ## What Changed - `setup-token-session.ts`: when a lease release fails, the reaper logs `Cause: <error class> (<code>)` for the error and up to three of its causes, for example `DrizzleQueryError > PostgresError (22P02)`. It does not log the error message, because a database or provider message can quote input values. A thrown value that is not an `Error` logs `unknown error`. The record stays retryable, as before. - `setup-token-reaper.test.ts`: three tests for the log line, including a database error wrapped by the query layer. They check that the message text is not logged. - `login-cleanup-work.test.ts`: a PostgreSQL test with the production reaper. A restart left two sandbox setup-token sessions in `submitting` past their deadline, one with no lease and one with a lease. One sweep releases both, the lease goes through the environment driver, and the next sweep finds nothing. With the #15200 guard removed, this test fails with `{ released: 1, failed: 1 }`, which is the reported symptom. What the issue reported, and where it stands on `master`: | Report | State | |---|---| | Release fails every 30 s forever | Fixed by #15200. This PR adds the regression test. | | Reaper swallows the cause | Fixed here. | | Cancel answers `200 {}` and cancels nothing after a restart | The route now falls back to a durable cancel for `starting` and `awaiting_code`. A `submitting` session is not cancellable on purpose (a credential write may be in progress), and the route keeps its uniform `200` answer. Such a session leaves `/active` when its 5-minute deadline passes, and the next sweep releases it. | | No cancel in the UI | The UI now calls the cancel route. | | Local subscription logins | They now use a separate flow (`local-ai-login.ts`). This reaper skips `local_subscription` rows. | ## Verification - `pnpm exec vitest run server/src/services/setup-token-session.test.ts server/src/services/setup-token-reaper.test.ts server/src/__tests__/login-cleanup-work.test.ts`: 3 files, 90 tests passed. - The two log tests fail on `master`. The restart test fails when the #15200 guard is removed. - `pnpm --filter @paperclipai/server typecheck` passes. ## Risks - Low risk. The change adds a log field and tests. - This pull request does not add a startup sweep that ends every live session at boot. In a rolling deploy, an old process can still be completing a login while the new one starts, so the 5-minute deadline stays the recovery path. ## 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 |
||
|
|
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> |
||
|
|
e856a607ed |
fix(cloud): name why an online workspace source scope is unproven (#22644)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server moves each local workspace to shared storage in bounded online passes while it serves work > - Before a Git or managed workspace moves online, the server must prove which tasks and projects can write its files > - Staging stacks stay blocked with many `online_workspace_source_scope_unproven` workspaces after repeated passes > - The proof has more than 30 separate checks, and the pass does not say which check failed > - This pull request names the failed check for each workspace > - The benefit is that the next pass on a blocked stack shows the exact cause, so the right fix can follow ## Linked Issues or Issue Description Refs #22270, #22294 **What happened?** After repeated online passes, staging stacks report `workspaces:online_workspace_source_scope_unproven` for 26 to 49 workspaces each. The code does not say which part of the source proof failed. Most of the same workspaces also report `overlapping_workspace_requires_maintenance`, because a workspace without a proven scope cannot treat its Git siblings as one unit. **Expected behavior** The pass names the part of the source proof that failed for each workspace. **Steps to reproduce** 1. Create a nested Git wrapper workspace with a linked worktree. 2. Remove the linked worktree directory without `git worktree prune`. 3. Run the online inventory. It reports only `online_workspace_source_scope_unproven`. ## What Changed - `explainOnlineWorkspaceSource` and `explainOnlineOrdinarySource` return `{ unproven: <code> }` for each failed check. `inspectOnlineWorkspaceSource` and `inspectOnlineOrdinarySource` keep their old `null` result. - Inventory returns `sourceScopeUnproven` with the code. The `reasons` list does not change. - The online pass reports the code as `workspaces:source_scope_<code>` next to `workspaces:online_workspace_source_scope_unproven`. - The linked-worktree reader throws `workspace_git_link_stale` when a registered worktree directory is gone, and `workspace_git_links_exceeded` above 256 links. Both still reject the proof. - Codes include `git_link_stale`, `git_link_unregistered`, `git_links_unreadable`, `member_status_unsupported`, `member_task_binding_missing`, `member_locator_mismatch`, `member_git_expiration_pending`, `source_keys_exceeded`, `members_exceeded`, `foreign_alias`, `companion_recovery_unresolved`, `companion_copyback_unresolved`, `ordinary_member_nested` and others. ## Verification - `cd server && npx vitest run src/services/remote-workspace-migration.test.ts src/services/remote-workspace-online-source.test.ts src/services/remote-workspace-cohort-migration.test.ts src/services/workspace-git-source-roots.test.ts src/services/online-durable-data-migration.test.ts src/services/online-durable-data-migration-postgres.test.ts src/services/finalized-workspace-recovery-migration.test.ts` (embedded PostgreSQL): 7 files, 407 tests passed. - Red/green: the linked-worktree test now checks the code for five cases (unregistered, wrong backlink, wrong pointer, symlinked backlink, stale). On `origin/master` the result has no `sourceScopeUnproven` field. The new pass test fails on `origin/master` because the pass has no `source_scope_` key. - `pnpm --filter @paperclipai/server typecheck`: passed. ## Risks - Low risk. No proof accepts more than before. Each check returns the same accept or reject result. Only the reported code is new. - The pass result gets new `workspaces:source_scope_<code>` keys. Readers that count deferral keys see more keys. > 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 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> |
||
|
|
348749305c |
fix(connections): keep managed sign-in when Paperclip Cloud is busy or unreachable (#22662)
<!-- 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 > - On Cloud workspaces, connectors such as GitHub use managed sign-in through Paperclip Cloud > - Paperclip asks the Cloud connector broker which sign-ins this instance has and whether its registration is active > - When the broker rate-limits or fails that check, Paperclip treats the failure as "no Cloud sign-ins" and "not registered" > - The GitHub card then says "Add key", and the connect screen offers self-hosted Cloud registration, which cannot succeed on a Cloud workspace > - This pull request keeps the last answer Cloud confirmed when the broker does not answer, and shows a retry instead of registration > - The benefit is that a busy or unreachable broker no longer changes what the user sees, or sends them into a setup flow that cannot work ## Linked Issues or Issue Description **What happened?** On a production Cloud workspace, the GitHub card on the Connectors page said "Add key" instead of "Connect". On the GitHub connect screen, "Connect with Paperclip" failed with "Paperclip Cloud enrollment could not be started". On another production workspace, "Continue to GitHub" failed with "Internal server error". **Steps to reproduce** 1. Open Connectors on a Cloud workspace while the Cloud connector broker returns 429 to the workspace's signed requests. 2. Look at the GitHub card. It says "Add key". 3. Open Connect GitHub. The self-hosted registration card shows. Its button fails. **Expected behavior** The card says "Connect". A broker that is busy or unreachable gives a retry, not a registration flow that cannot succeed. **Root cause** The broker rate-limited signed requests from production stacks (`429 RATE_LIMITED`; Sentry shows it from 8 production stacks in 7 days, and none on staging). The fix for that is in paperclipai/paperclip-cloud#1751. In this repository, `getCapabilities()` mapped every error to an empty list and cached it for 60 seconds. The enrollment status check mapped every error to `unverified`, and the connect screen treated `unverified` like "not registered". Refs paperclipai/paperclip-cloud#1751 ## What Changed - `paperclip-cloud-connector.ts`: a 429, a 5xx, or an unreachable broker is now a "no verdict" failure (`isTransientPaperclipCloudConnectorError`). - On a "no verdict" failure, capability and instance-status checks return the last answer Cloud confirmed for this connector identity. `invalidatePaperclipCloudConnectorCapabilities()` clears those saved answers. - `paperclipCloudConnectorCapabilitiesFromEnv` keeps an unanswered check for only 5 seconds, not 60. Gallery reads soon ask Cloud again, but a failing broker does not get one request per read. - `paperclip-cloud-connector-status.ts`: when Cloud does not answer the status check (429, 5xx, or network), the status is the new `unreachable`. Incomplete managed settings now report `misconfigured`: the connect screen and the Connections banner tell the user to ask their administrator, because registration cannot run there. `unverified` stays for a saved identity that belongs to another broker, which keeps the registration step. - `Connections.tsx`: the Cloud banner shows a message without the Enable button for `unreachable` and `misconfigured`. - A Cloud rejection, or a confirmed removed or suspended registration, clears the saved sign-ins and the gallery's cached list. An unreadable answer (a non-JSON body) or a 408 counts as no verdict. An answer from a request that started before an invalidation is not saved. - `ConnectionSetupFlow.tsx`: when the Cloud status is `unreachable`, the screen shows "Paperclip couldn’t reach Paperclip Cloud to start GitHub sign-in. Try again in a moment." with a Try again button. It no longer offers registration. Try again reloads both the gallery and the Cloud status. ## Verification - New file `server/src/services/paperclip-cloud-connector-saved-answers.test.ts` (7 tests): the last confirmed sign-ins and status are kept through 429 and 503 responses; a busy broker with no earlier answer gives no verdict; a rejection or removal is not undone by a later 429; a late answer does not replace a newer one; a 429 capability check is kept for only 5 seconds; `unreachable` and `unverified` are reported separately. They fail without this change and pass with it. - `ui/src/pages/apps/AppsConnect.test.tsx`: an `unreachable` status shows the retry and not "Connect with Paperclip"; an `unverified` status still shows registration. - Server connector tests (saved-answers, connector, enrollment): 94/94 pass. Cloud-related AppsConnect tests: 4/4 pass. - `pnpm verify` selected a broad set of server tests and was stopped (exit 143) under machine load. The Cloud-floor tests that it reported as failing pass when run alone (`company-cloud-floor.test.ts` 3/3). CI covers the full suite. ## Risks - Low risk. The saved answers live in memory and are cleared by the existing invalidation and by a restart. A workspace whose Cloud registration was removed still sees that on the next confirmed answer: a 401 maps to `removed` as before. - A saved `active` status can stay in use while the broker keeps failing. This is intended: a failure gives no new information. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, browser, Sentry reads). ## 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> |
||
|
|
f3a5367b41 |
fix(ui): show readable connector action names in the Activity feed (#22659)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Connectors let agents use outside apps, such as Google Workspace.
The company Activity page records each connector event.
> - #22630 gave Google Workspace actions readable names on the Review
and Permissions tabs.
> - The Activity page still showed internal names. A Gmail call read
"used mcp google workspace 7f3c2a10 gmail get message on". The short ID
in that text comes from the connection ID.
> - Some connector rows also showed raw event names or entity types,
such as "tool connection content deleted" or "tool_application".
> - Users must not see internal names or IDs. Google's app reviewers
will also look at this page.
> - This pull request makes these Activity rows use the same readable
action name as the other pages, and plain sentences for connection
events.
> - The benefit is that people and reviewers can read what each
connector event did.
## Linked Issues or Issue Description
Refs #22630
**What happened?**
On the company Activity page (Apps & tools filter), connector rows
showed internal names. A Google tool call read "used mcp google
workspace 7f3c2a10 gmail get message on". An app removal read "tool
application archived tool_application". Stored content deletion read
"tool connection content deletion requested". Connection removal did not
say what happened to Google access.
**Expected behavior**
Each row reads as a plain sentence. Google actions use the readable name
from the Permissions page, for example "used Gmail: Get message on the
connection". No row shows a `service__tool` name, an underscore name or
an ID in its main text.
**Steps to reproduce**
1. Connect Google Workspace and let an agent read a Gmail message.
2. Remove the connection.
3. Open Activity and pick "Apps & tools".
**Paperclip version or commit**
master at
|
||
|
|
fd6317de23 |
fix(cloud): name a retained runtime skill run whose bundle left the disk and keep saving the runs after it (#22648)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server copies the runtime skill bundles that retained runs still need to shared storage before it moves to a volume-free shape > - The online pass copies them a page at a time with `migrateRuntimeSkillAssets` > - The page fails at the first run whose bundle is no longer on the disk, so the later runs on that page are never saved and the pass names only the first failure > - The offline migration continues past such a run, collects it as unsaved, and refuses at the end > - This pull request gives the online page the same behavior and names each unsaved run > - The benefit is that the pass saves every bundle it can and reports each one it cannot ## Linked Issues or Issue Description Refs #22190, #22294, #22641 **What happened?** On staging, one stack reports `runtime_skill_assets_require_migration`. Its passes showed `runtime_skill_assets:runtime_skill_source_absent:missing` as a whole-page failure: the runs after the first missing bundle were not visited. **Expected behavior** The page saves every run whose bundle is on the disk and names each run whose bundle is gone. **Steps to reproduce** 1. Keep two retained native runs with unversioned skill bundles. Remove the bundle of the first run from the disk. 2. Run `migrateRuntimeSkillAssets` with `apply`. 3. See that it throws `runtime_skill_source_absent:missing` and does not save the second run. **Additional context** #22641 already makes every blocker in the pass result carry a code. This pull request was reduced to the runtime skill page after #22641 merged. ## What Changed - `migrateRuntimeSkillAssets` returns `{ status: "unsaved", code: "runtime_skill_source_absent:<reason>" }` for a run whose bundle is not on this disk, and continues. Other errors still stop the page, as in the offline migration. - The result type is a discriminated union, so `unsaved` always carries a code. - The online pass reports each unsaved run as `runtime_skill_assets:<code>`. - `migrate-skill-packages --phase=runtime-assets` prints the unsaved rows and exits 1 when any run stays unsaved. ## Verification - Red: `cd server && npx vitest run src/services/online-durable-data-migration.test.ts src/__tests__/runtime-skill-preservation.test.ts` failed 2 new tests: the real page (embedded PostgreSQL, real bundle files) threw `runtime_skill_source_absent:missing` before it saved the next run, and the pass had no code for unsaved runs. - Green: the same files and `online-durable-data-migration-postgres.test.ts` pass (42 tests). - `pnpm --filter @paperclipai/server typecheck` passes. - Local `pnpm verify` selects most of the suite for this change (2,979 of 3,855 files). Required CI supplies that coverage. ## Risks - No migration rule changes. A run whose bundle is gone still blocks the move, online and offline. - The maintenance command now exits 1 when a run stays unsaved, as it did before when the page threw. > 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 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> |
||
|
|
949bc3765c |
fix(cloud): preserve a settled harness backup whose session is not selected, as offline does (#22647)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server copies its Runner harness backups to shared storage before it moves to a volume-free shape > - The online pass copies a settled backup only when exactly one task session selects the backup's native session > - Some stacks stay blocked with `native_harness:source_session_not_selected`, but the offline migration publishes the same backup > - A selected session whose backup source is not on the disk is reported with no code at all > - This pull request applies the offline outcome online with a selection fence, and names the missing-source case > - The benefit is that these stacks can move, and the native harness blocker always says why it remains ## Linked Issues or Issue Description Refs #19715, #22294 **What happened?** On staging, two stacks stay ineligible with `native_harness_backups_require_migration`. Each online pass defers one backup as `native_harness:source_session_not_selected`. That code means that no task session, or more than one, points at the backup's native session. **Expected behavior** The online pass gives a settled backup the same outcome as the offline migration. The offline migration publishes the backup whether or not a session selects it. **Steps to reproduce** 1. Keep a sealed backup of a failed native run with a settled coordinator and a verified lease stamp. 2. Delete the task session that selects it (or add a second one for the same native session). 3. Run the online pre-copy. It defers the backup as `source_session_not_selected`. The offline migration publishes it. **Additional context** The selection check exists so that publication does not race a change of the selected session. It does not need exactly one selection for that. ## What Changed - The settled-source owner records the exact set of task sessions that select the native session: none, one or several. Publication rechecks the same set under a share lock. A changed selection keeps the source local (`source_changed`), as before. The `session_not_selected` reason is removed. - The run, coordinator, task, lease, finalization lock and payload checks do not change. - After the source walk, the pre-copy lists the selected sessions that still need a backup. A selected scope with no source on this disk is reported as `selected_source_absent`. Before, it produced no outcome. ## Verification - Red (embedded PostgreSQL, real files): `cd server && npx vitest run src/services/native-runtime/native-harness-online-preservation.integration.test.ts` failed 4 new tests: unselected and ambiguous sources were deferred, and a missing selected source produced no outcome. - Green: the same file passes (20 tests). New tests show that an unselected or ambiguous source publishes, the run and task sessions do not change, the backup restores the exact bytes, and a selection that appears before publication keeps the receipt pending. - `native-harness-backup-storage.integration.test.ts`: the former `source_session_not_selected` expectation now expects publication by the settled-source owner (activity `native_harness_backup_preserved`), not by the offline owner. - `npx vitest run` of all 8 files that use these owners (startup gate, prestage command, filesystem independence, obligations, storage, online preservation): 240 tests pass. - `pnpm --filter @paperclipai/server typecheck` passes. - `pnpm verify` result is in a comment below. ## Risks - A settled backup of an unselected session now moves to shared storage online. The offline migration already does this, and the source files stay on the disk. - The pre-copy now runs the obligation scan once after the source walk. This is the same scan that the eligibility read runs. - Pass deferral codes change: `native_harness:source_session_not_selected` is gone, and `native_harness:selected_source_absent` is new. > 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 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> |
||
|
|
574448e910 |
fix(server): apply the issue interaction resolution policy to direct tool review decisions (#22656)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - When an agent's tool call needs review, Paperclip creates a tool action request and an approval card on the task > - A person can decide it on the card (the issue thread path) or through `POST /api/tool-gateway/action-requests/:id/approve|decline` > - The issue thread path applies the interaction resolution policy, but the direct routes checked only company membership > - So the two paths could give different answers for the same review, for example in another member's private chat > - This pull request puts the human rule for tool reviews in one shared function and applies it to every human decision on a pending review > - The benefit is that the direct routes and the card always agree on who can decide a tool review ## Linked Issues or Issue Description Refs #22635 **What happened?** The direct approve and decline routes for tool action requests skipped the issue-interaction resolution policy. A member could decide a tool review that the issue thread path refuses, for example a review in a chat conversation that another member owns. **What did you expect to happen?** Both paths use the same policy and give the same result. **Steps to reproduce** Open a chat conversation as one member, let the agent request a reviewed tool call, then approve it through the direct route as a different member. The new test covers this case. **Impact** Access-control hardening for tool reviews. ## What Changed - Add `evaluateHumanToolReviewResolution`, `assertHumanToolReviewResolution` and `conversationInteractionResponderAllowed` to `server/src/services/issue-thread-interaction-resolution.ts`. The rule applies the personal-conversation visibility rule, the conversation owner rule and the existing audience evaluator (`evaluateIssueThreadInteractionResolverAudience`, as a governed action). - `commitToolActionReview` applies this rule inside its decision transaction, on the issue and interaction rows it already locks. Both the issue thread path and the direct routes reach it, so one rule decides for both. - The direct approve and decline routes call the same rule function first, for pending and settled reviews, before any state change or detail is returned (for example a cancelled request after a signature failure, expiry, or formal approval details). The in-transaction check stays the authoritative one. - A settled request with no task or interaction can be read only by the person who requested it; others get `404`. Only the explicit internal recovery flag skips the check. - A decision with no user identity is refused with `human_review_required`; the code no longer substitutes a placeholder identity. - The issue thread route uses `conversationInteractionResponderAllowed` for its existing conversation owner check. - Recovery of an already approved review passes an explicit internal flag and skips the human check, so interrupted executions still resume with no user action. ## Verification - New table test in `server/src/__tests__/tool-gateway.test.ts` mounts the real issue routes and the gateway routes on one database, for a chat owned by one member, a personal dashboard conversation and an ordinary task. For approve and decline it compares both paths for the owner and another member. It also checks settled reviews through the direct route, the recovery of an approved review, that a non-owner cannot cancel a review with an unverifiable signature or see expiry details, that a decision without a user is refused, and that a detached settled request is visible only to its requester. Before the fix the direct route let the other member approve a chat review and the action ran (`200`, `executed`). After the fix both paths refuse the other member for chats (`403`) and personal dashboards (`404`), both allow the other member for ordinary tasks, and both allow the owner. - `npx vitest run` on `tool-gateway`, `issue-thread-interaction-routes`, `agent-conversations`, `connection-management.integration`, `mcp-tasks` and `prompt-injection-gateway`: 497 tests pass. - `tsc --noEmit` for `server` passes. ## Risks - A member who is not the owner of a private chat can no longer approve or decline its tool reviews through the direct routes. The card already refused this. - Low risk otherwise. Ordinary task reviews have no addressee and stay open to non-viewer members, as before. ## 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> |
||
|
|
ffb300e22a |
fix(cloud): name a failed durable-data check instead of answering the eligibility read with 500 (#22646)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server moves from a volume to a volume-free shape without an outage > - Before the move, Cloud reads `GET /api/instance/ephemeral-enrollment/eligibility`, and the stack moves only when the read has no blockers > - On two staging stacks the read answers HTTP 500, so Cloud shows only "eligibility unavailable: HTTP 500" > - Each durable-data check in the read can throw, and one throw fails the whole read without a reason > - This pull request makes each check that throws report a named blocker with the owner's code > - The benefit is that a stack that cannot move always says which check stopped it and why ## Linked Issues or Issue Description Refs #22240, #22294, #22337 **What happened?** On current Core, the eligibility read answers HTTP 500 for some hosted stacks. The online durable-data pass also fails, because it reads the same eligibility at the end of each pass. **Expected behavior** The read always answers. When a check cannot finish, the read reports a named blocker, and the move stays blocked. **Steps to reproduce** 1. Keep a failed Runner run whose session is selected and whose local controller file has a second hard link (or another source that the controller check refuses, such as an execution input that no longer parses). 2. Call `readOnlineEphemeralEnrollmentEligibility`. 3. See that it throws `native_controller_migration_unsafe_source`. The route answers 500. **Additional context** Every check in `readEphemeralServerDataEligibility` can throw: the native controller scan reads files and parses saved execution input, the harness scan reads files, and the other checks query the database. The controller scan is the first one that throws on old Runner state. ## What Changed - `readEphemeralServerDataEligibility` runs each check through one guard. A check that throws adds `<area>_check_failed`, plus `:<code>` when the error message is a code such as `native_controller_migration_unsafe_source`. The guard logs the error. - The same blockers reach the startup gate, the offline migration and online preparation. Each of them still refuses, as before, but now with the named blocker instead of the raw error. ## Verification - Red: `cd server && npx vitest run src/services/native-runtime/native-controller-migration.integration.test.ts -t eligibility_unreadable` failed with `Error: native_controller_migration_unsafe_source` thrown from `readEphemeralServerDataEligibility` (embedded PostgreSQL, real controller file with a second hard link). - Green: the same test passes. The read returns `native_controllers_check_failed:native_controller_migration_unsafe_source`, the online read returns `eligible: false` with that blocker, and the controller file is unchanged. - `npx vitest run src/__tests__/ephemeral-server-data.test.ts src/services/ephemeral-enrollment.test.ts src/__tests__/runtime-skill-preservation.test.ts` and the `volume_free_owner` controller scenario pass. - `pnpm --filter @paperclipai/server typecheck` passes. - `pnpm verify` result is in a comment below. ## Risks - Low risk. A check that throws still blocks the move, the startup gate and the offline migration. Only the shape of the refusal changes: a named blocker instead of an exception. - Cloud receives new blocker names of the form `<area>_check_failed[:code]`. Cloud shows unknown blockers as they are and does not move the stack. > 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 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> |
||
|
|
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> |
||
|
|
7b4f4c81e0 |
fix(ci): make unchanged GitHub Actions polls free with conditional requests (#22677)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - CI on master builds the Docker image that deploys staging. The
release and readiness watchers in those workflows poll the GitHub
Actions API every 30 seconds, for up to 40 or 90 minutes.
> - The watchers use the workflow `GITHUB_TOKEN`. On the GitHub Team
plan, that token has one shared quota of 1,000 requests per hour for all
jobs in this repository.
> - One release watcher poll makes about 8–13 reads, so one watcher can
use most of the hour's quota. On busy days the quota runs out, and
unrelated calls fail with "API rate limit exceeded for installation". On
2026-11-23 this failed `docker/metadata-action` in two Docker builds,
and staging did not deploy for hours.
> - Most of these reads return the same data as the last poll. GitHub
does not count a `304 Not Modified` response against the quota.
> - This pull request makes the shared Actions reader send the last ETag
for each path and reuse the cached body on a 304.
> - The benefit is that an unchanged poll costs nothing. The watchers
use about 80% less quota, and the poll interval stays the same, so
releases are not slower.
## Linked Issues or Issue Description
**What happened?**
On 2026-11-23, Docker push builds on master failed with `API rate limit
exceeded for installation` in `docker/metadata-action`.
`actions/setup-node` also could not fetch its version manifest. The
repository's shared `GITHUB_TOKEN` quota was exhausted. Staging stayed
on one commit for several hours.
**Expected behavior**
Long-running CI watchers do not use up the repository's shared API
quota, so other jobs can make their API calls.
**Steps to reproduce**
1. Merge several pull requests to master in one hour.
2. Each Docker and readiness run starts watchers
(`scripts/watch-release-source.mjs`,
`scripts/cloud-source-verification.mjs`). Each watcher reads the Actions
API about 8–13 times every 30 seconds.
3. When the hourly quota is used up, other steps that call the API fail.
**Paperclip version or commit**
`master` at
|
||
|
|
6efa3eb2d2 |
chore(lockfile): refresh pnpm lockfiles (#22678)
## Thinking Path > - Paperclip uses a dependency lock for reproducible builds. > - Dependency changes on master need matching lock entries. > - Paid eval reports also pin a reviewed offline correction. > - Reports must install before paid model work starts. > - This automated PR keeps the lock and report proof together. ## Linked Issues or Issue Description **What happened?** Dependency manifests on master changed after the last committed lock refresh. **Expected behavior** Frozen installs must match those manifests. Eval reports must retain matching offline lock proof. **Steps to reproduce** Run a frozen install before and after this lock refresh. ## What Changed - Refresh the dependency lock from the manifests on master. - Refresh the sandbox provider lockfiles from their manifests on master. - Include the matching offline report correction and hashes. - Resync the SDK public source proof's lock pins from the refreshed lock. ## Verification - Pinned pnpm resolution completed with lifecycle scripts disabled. - The report proof refresh accepted the reviewed committed baseline. - The workflow rejected changes outside the lock and report proof files. ## Risks The lockfile bot merges this PR without CI or review when it verifies every added version on npm and all versions outside the harness allowlist are at least 3 days old. Otherwise the PR waits for a maintainer, and the daily refresh tries again. The bot merges only the exact commit this workflow generated from manifests already reviewed on master. Unknown report lock baselines remain blocked. This update changes no permissions or paid enable gates. ## Model Used None — generated by pnpm and the deterministic report-lock updater. ## Checklist - [x] Thinking path and problem description included - [x] Generated lock and matching report proof included - [x] Release-age gate decides between bot merge and maintainer review Co-authored-by: lockfile-bot <lockfile-bot@users.noreply.github.com> |
||
|
|
27af8e5c0c |
feat(telemetry): report custom connector domains and aggregator app requests (#22665)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use tools through connectors: catalog connectors, custom MCP
servers, and aggregator gateways (Composio, Arcade, Executor) that reach
many apps
> - Connector telemetry sends every custom MCP connector as
`connector_key: "custom"`, and it sends nothing about apps behind an
aggregator
> - The team cannot see which services people add as custom servers, or
which aggregator apps people try to connect and which ones they finish
> - This pull request adds a reduced `server_domain` to the connection
events for custom connectors, and two aggregator app events
> - The benefit is a privacy-safe view of connector demand: no URL, no
subdomain, and no provider-controlled string leaves the installation
## Linked Issues or Issue Description
No issue exists. This follows the feature request template
(`.github/ISSUE_TEMPLATE/feature_request.yml`).
**Subsystem affected**
Server connector telemetry
(`server/src/services/connector-telemetry.ts`), the aggregator app sync
and setup paths
(`server/src/services/tool-access/catalog/aggregator-accounts.ts`), the
tool gateway, and the shared telemetry contract
(`packages/shared/src/telemetry`).
**Problem or motivation**
Connector telemetry sends every connector outside the first-party
catalog as `connector_key: "custom"`, and every app behind Composio as
the `composio` connector. Arcade and Executor apps are hidden the same
way. This hides which servers and apps people actually connect to. It
also hides what they try to connect and fail to connect. The team cannot
use telemetry to decide which connectors to add to the catalog or where
setup fails.
**Proposed solution**
For custom connectors only, send the registrable domain of the server
(`server_domain`), with IP, private, and local hosts reduced to
`private` and stdio servers to `stdio`. Send `connection.app_requested`
when a person or agent asks an aggregator to add an app, with the
result, and `connection.app_linked` when that app becomes connected. The
app is a slug from the checked-in aggregator catalog, or `other`. No
user-controlled string leaves the process.
**Alternatives considered**
Sending the full host was rejected: subdomains can name a customer or
tenant. Hashing the host was rejected: it cannot be read in an insight,
and short domains are easy to reverse. Sending the provider's toolkit
name was rejected: Executor and custom integrations use names that
people choose.
## What Changed
- Sync the generated telemetry contract. The telemetry backend registers
`server_domain` and the two new events first, so nothing is dropped as
unregistered.
- `server/src/services/connector-telemetry.ts`:
- `serverDomainForUrl()` reduces a configured address to its registrable
domain (ICANN public suffix plus one label, from `tldts`).
`mcp.smithery.ai/sse?token=…` becomes `smithery.ai`. IPs, loopback,
single-label hosts, non-ICANN or special-use suffixes (`.local`,
`.internal`, `.home.arpa`, `.onion`), non-HTTP schemes, and unparsable
values become `private`. A final pattern check makes sure nothing
URL-shaped can pass.
- `server_domain` goes on `connection.created`, `connection.updated`,
and `connection.invoked` only when `connector_key` is `custom`. Local
stdio servers send `stdio`. A remote connection with no address yet
omits it.
- `aggregatorAppTelemetrySlug()` returns a slug from the shared
aggregator catalog, or `other`. This is the same rule as
`connector_key`.
- `newlyLinkedToolkits()`, `emitAggregatorAppsLinked()`,
`emitAggregatorAppsRequested()`, and
`emitAggregatorAppRequestsFromToolCall()`. All are best-effort and never
throw.
- `aggregator-accounts.ts`: the Composio list check and the
Arcade/Executor inventory sync read the previous snapshot status before
the write. They send `connection.app_linked` only for a change to
`connected`. The Composio check sends it right after each saved row, so
a later app that fails in the same check does not lose it, and it
updates the stored status after each write, so an app named twice in one
check sends one event. The Composio upsert now returns its row, so a
write that loses to a newer observation sends nothing. App setup `start`
and account `add` send `connection.app_requested` (`origin: user`) with
`succeeded`, `needs_auth`, or `failed`.
- `tool-gateway.ts`: one call after the remote MCP response is parsed.
An agent's `COMPOSIO_MANAGE_CONNECTIONS` call with `add` sends one
`connection.app_requested` (`origin: agent`) per app.
`composioAddOutcomes()` parses the response once and reads each app's
own result node: connected is `succeeded`, its own sign-in link is
`needs_auth`, an error or no node is `failed`. A sibling's link never
counts; the response-wide link counts only when one app was added. An
Arcade tool call that answers with an authorization step sends
`needs_auth`.
- `connection-methods.ts`: `remoteEndpointValue()` shares the `url` →
`endpoint` → `remoteUrl` order with `remoteEndpoint()`.
- `server/package.json`: add `tldts` 7.4.10 as a direct dependency. It
is already in the lockfile through `tough-cookie`. The lockfile is left
to CI.
- Shared telemetry: typed helpers `trackConnectionAppLinked` and
`trackConnectionAppRequested`, `server_domain` on the three connection
helpers, retention class `operational_enum_count` for the new events,
and a "Connector Events" section in the telemetry README.
## New Dependency
`tldts` 7.4.10 (MIT) is added to `server/package.json`.
- Why: `server_domain` must be the registrable domain (eTLD+1), so
`mcp.example.co.uk` gives `example.co.uk` and not `co.uk`. That needs
the Public Suffix List. No runtime dependency in the repo parses it.
`new URL()` and `node:net` give only the hostname and IP detection.
Splitting on the last two labels is wrong for multi-part suffixes such
as `co.uk` and would leak or merge domains.
- Already in the tree: `tldts` 7.4.10 is in `pnpm-lock.yaml` through
`jsdom` → `tough-cookie`, a dev-only path. This PR makes it a direct
server dependency at the same version, so no new package is downloaded.
- Size: about 125 KB minified (`dist/index.cjs.min.js`), with one
dependency, `tldts-core` (same author). It bundles the suffix list, so
it does no network or file reads at run time.
- Maintenance: actively maintained (latest release this month), widely
used (it is the suffix parser in `tough-cookie`), with typed exports.
## Verification
- `pnpm exec vitest run src/services/connector-telemetry.test.ts`
(server): 65 pass, including a sibling's link, a top-level link with
several apps, and the one-app fallback. New cases cover domain reduction
(paths with tokens, userinfo, ports, uppercase, trailing dot, IDN,
`github.io` and `vercel.app` subdomains dropped), `private` for IPv4,
IPv6, loopback, `.local`, `.internal`, `.home.arpa`, `.onion`,
single-label, unknown suffix, `ftp:`, and non-strings, a payload check
that no part of a secret-bearing URL appears in any of the three events,
catalog-or-`other` for every provider, a check that every catalog slug
matches the registered `app` pattern, and the transition rule.
- `pnpm exec vitest run src/__tests__/composio-app-setup.test.ts
src/__tests__/aggregator-app-sync.test.ts` (embedded Postgres): 36 pass,
including an app named twice in one check (fails without the fix).
Composio: setup `start` sends one `needs_auth` request; refreshes while
the account is only initiated send nothing; activation sends exactly one
`app_linked` over three refreshes and a `complete`; an app saved before
a later app fails in the same check keeps its `app_linked`; an
unconfirmed `add` sends `failed`. Executor: two syncs send one
`app_linked`; a disconnect sends nothing. Agent requests: mixed per-app
results give `succeeded`, `needs_auth`, and `failed` separately.
- Red check: with the previous-status check or the domain reduction
removed, 13 of these tests fail.
- `pnpm exec vitest run src/telemetry` (shared): 46 pass, including the
real client sending `server_domain` and both new events.
- Related suites still pass: connector telemetry for tool access and the
gateway, Circleback parity, aggregator fallback, connection intents, MCP
protocol versions, MCP tasks, remote MCP connectors, remote MCP pending
(265 tests).
- `tsc --noEmit` reports no errors in the changed files.
- `tests/runner-e2e/source-sdk-public-inputs.json` is regenerated with
`node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --write`,
because it pins the shared telemetry files. `--check` and
`source-sdk-public-inputs.test.mjs` (13) pass.
- CI note: on
canary/v2026.1123.0-canary.845200
|
||
|
|
45221a17ea |
test(native): give the repeated-bytes provider pack tests a 60s timeout (#22663)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Every pull request runs the server test suite in 12 CI shards > - #22241 added tests that build and stage a provider pack with three 2 MiB copies of one file > - Two of these tests take 6 to 7 seconds on a fast laptop and more than the 15-second server `testTimeout` on CI runners. They also time out on the automatic retry > - The `General tests (server (5/12))` shard now fails on unrelated pull requests, for example #22653 and the `fix/gateway-session-personal-grant-owner` branch > - This pull request gives the two tests the 60-second per-test timeout that other native-runtime tests use > - The benefit is that the shard passes again and unrelated pull requests can merge ## Linked Issues or Issue Description Refs #22241 (added the two tests). Refs #22652, #22653 (blocked by this shard). **What happened?** `server/src/services/native-runtime/provider-pack-archive.test.ts` fails on CI with `Test timed out in 15000ms` in two tests: - `stores repeated bytes once, from an image file under another path, without transferring them` - `transfers repeated bytes when no image has them, and does not reuse a changed twin` Each test also fails on the automatic retry (about 35 seconds in total). **Expected behavior** The `General tests (server (5/12))` shard passes on a pull request that does not touch the native runtime. **Steps to reproduce** 1. Open a pull request based on `master` after #22241. 2. Wait for `ci / General tests (server (5/12))`. 3. The two tests above time out. ## What Changed - `provider-pack-archive.test.ts`: add a 60-second timeout to the two tests above. No test logic changes. ## Verification - `pnpm exec vitest run server/src/services/native-runtime/provider-pack-archive.test.ts`: 52 passed. - On a fast laptop the two tests take 6.1 s and 6.2 s. The other tests in the file that use the same fixture take less than 2.3 s. - The CI shard for this pull request is the real check. ## Risks - Low risk. The change affects only the time limit of two tests. - The change does not explain why these two tests are slower than the similar test in the same file. The author of #22241 can make them faster later. ## 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 mergecanary/v2026.1123.0-canary.845100 |
||
|
|
70d4b6524c |
fix(antigravity): offer the cloud candidate in the agent picker for linux-x64 environments (#22655)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity is a native Runner harness (#22591). Its profile is still pending, so only a company with an operator grant can see or run it > - A grant can name the cloud target (linux-x64), and save, Test and execution already accept it for a cloud environment > - The agent picker computed the candidate only for the local target, so a company with a valid cloud grant never saw the harness for a cloud environment > - This pull request binds the picker to the selected environment's target, in the Antigravity-owned module > - The benefit is that a granted company can pick Antigravity for the linux-x64 cloud environments that can run it, and still sees nothing anywhere else ## Linked Issues or Issue Description Refs #22591 **What happened?** `GET /api/adapters?companyId=…&environmentId=…` returned `candidateHarnesses` only when the environment target was `local`. A company with a valid linux-x64 Antigravity grant got no candidate for a Core sandbox or SSH environment. **What did you expect?** The picker offers the candidate for a linux-x64 cloud environment when the company holds a grant for that target, the same way save, Test and the executor admit it. **Steps to reproduce** 1. Set a candidate grant that names linux-x64 for a company and exact model. 2. Request the adapter list for that company with a linux-x64 sandbox environment. 3. `paperclip_runner` has no `candidateHarnesses`. ## What Changed - `antigravityCandidateForRunnerTarget` (in `antigravity-release.ts`) decides the picker candidate per environment target: - local: unchanged. - Core sandbox or SSH that is linux-x64, or the managed cloud image: only a grant that names linux-x64 and its patched closure. - plugin Runner-task environment, unknown or other platform, unavailable Computer: none. - released profile: none. - `GET /api/adapters` uses it for every resolved target. Expired or mismatched grants stay quiet; malformed grants still log one warning. - The qualification plan notes the picker rule and records, as an open decision, why plugin Runner-task environments cannot run Antigravity yet. ### Not in this PR: plugin Runner-task environments Paperclip Cloud's warm Agent Computer runs agents only as plugin Runner tasks. Antigravity cannot run there yet, and the fix is outside Core alone: - The plugin task credential contract (`environmentTaskCredentialSchema`) has no Gemini API key type. - The plugin prepares the provider launch from `launch-requirements.v1`, which carries no candidate grant. The ACPX sidecar refuses a pending profile without one. - The Cloud plugin's harness table lists only Codex, Claude and OpenCode. Kimi, Copilot and Pi do not run there either. - Antigravity Test refuses the Runner-task path. The picker therefore offers nothing for those environments until that work lands. ## Verification - Red, then green: `server/src/__tests__/adapter-routes.test.ts` "offers a cloud environment the candidate only for the company's linux-x64 grant" failed before the fix and passes after it. - New unit tests in `antigravity-release.test.ts` run the real grant resolver: cloud grant offered, other company / arm64 / Runner-task / expired / host grant refused, released profile offers none. - `npx vitest run src/__tests__/adapter-routes.test.ts src/services/native-runtime/antigravity-release.test.ts src/services/native-runtime/acpx-qualification.test.ts src/services/native-runtime/antigravity-candidate-admission.test.ts`: 98 passed. - Server `tsc --noEmit`: clean. `pnpm verify`: see the CI checks for the final revision. - Not run live: no Antigravity prompt has completed in any environment yet, and the only available Gemini key is free tier. No paid runner E2E workflow was dispatched. ## Risks - Low risk. The change is read-only catalog output. Save, Test and execution keep their strict admission checks. - A company that holds a linux-x64 grant now sees Antigravity for linux-x64 sandbox and SSH environments. Those paths already accept that grant. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell, file edits) 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 - [ ] 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> |
||
|
|
5f5ac15436 |
fix(cloud): name every durable-data blocker in the online pass result (#22641)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server moves its durable data to shared storage in bounded online passes while it serves work > - Each pass reports the remaining eligibility blockers and a code for each item it left behind > - The pass keeps its place between calls, but each result only lists the codes of the phases that this call visited > - A pass that finishes a round after an earlier call ran the workspace phase reports `workspaces_require_migration` with no workspace code > - This pull request carries each phase's codes from its latest visit, and names a blocker that no visit explains > - The benefit is that every data blocker in a pass result names a cause ## Linked Issues or Issue Description Refs #22270, #22294 **What happened?** A staging stack ran repeated online durable-data passes. The pass result reported `workspaces_require_migration`, but the `deferred` map had no `workspaces:` code. **Expected behavior** Every data blocker in the pass result names at least one code. **Steps to reproduce** 1. Run a pass whose budget ends right after the workspace phase. The result shows the workspace codes. 2. Run the next pass. It resumes after the workspace phase and completes the round. 3. See that the completed result reports `workspaces_require_migration` with no workspace code. ## What Changed - The pass keeps the codes of the latest visit of each phase. A new visit of a phase replaces its earlier codes. - When a data blocker has no code from this call, the result includes the codes from the latest visit of the matching phases. - When no visit explains a data blocker, the result names `<phase>:pending_inspection`. For example, a workspace created after the workspace phase ran shows `workspaces:pending_inspection`. - Instruction blockers also get a code: `local_instruction_copies_require_settlement` reports `agent_files:instruction_copy_unsettled` and `external_agent_instructions` reports `agent_instructions:external_instructions_configured` when no agent-file code explains them. - One table maps each phase to its code prefixes and each data blocker to its phases and fallback code. A test reads every blocker that readiness can push and checks that each one gets a code. ## Verification - `cd server && npx vitest run src/services/online-durable-data-migration.test.ts src/services/online-durable-data-migration-postgres.test.ts`: 31 passed. - Red/green: the three new tests fail on `origin/master` (3 failed, 24 passed) and pass with this change. - `pnpm verify` (see the PR comments for the result). ## Risks - Low risk. The change only adds keys to the `deferred` map of the pass result. It does not change what the pass moves or when a stack is eligible. - A carried code can describe a state from an earlier call in the same round. The next visit of that phase replaces it. > 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 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> |
||
|
|
571b4bcae9 |
fix(workspaces): move a workspace with only a task warning online, as offline already does (#22650)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server moves each local workspace to shared storage in bounded online passes while it serves work > - A task can carry a recovery warning that is only about the task, for example a stranded assignment or a missing disposition > - The offline move keeps such a warning unchanged and moves the files. The online move with a source proof does the same > - The online move without a source proof refuses the workspace with `workspace_recovery_unresolved`, for example an archived workspace that is kept as a restore point > - Staging stacks stay blocked by this code (scott-test10 reports only this code, for 15 workspaces) > - This pull request gives the online move without a source proof the same result as the other two paths > - The benefit is fewer workspaces that block an online move, with no change to the warning or the files ## Linked Issues or Issue Description Refs #22270, #22294 **What happened?** Repeated online passes on staging stacks leave workspaces blocked with `workspaces:workspace_recovery_unresolved`. For a workspace without an online source proof, any active recovery action on its task blocks the online move, also a warning that is only about the task. **Expected behavior** A task-only warning does not block the online move, the same as in the offline move and in the online move with a source proof. The warning stays unchanged. Warnings that are about files or a run still block. **Steps to reproduce** 1. Create a local workspace for a task. Add an active `stranded_assigned_issue` recovery action to the task. 2. Run `migrateRemoteWorkspace` online (without `writersStopped`). 3. See that it fails with `workspace_recovery_unresolved`. The offline move of the same workspace succeeds. ## What Changed - `isTaskDispositionRecovery` names the existing task-only rule: kind `stranded_assigned_issue`, `configuration_validation`, `missing_disposition` or `deliberate_wait_without_target`, no workspace export cause, and no file or run evidence. The proven online hold uses it, with no change in behavior. - The online move without a source proof records such a warning as an online recovery hold with its fingerprint, as the proven path does. Publication locks the action row and checks that the fingerprint did not change. - All other recovery actions still block the online move without a source proof. ## Verification - `cd server && npx vitest run src/services/remote-workspace-migration.test.ts src/services/remote-workspace-online-source.test.ts src/services/remote-workspace-cohort-migration.test.ts src/services/online-remote-workspace-recovery-hold.test.ts src/services/online-legacy-workspace-recovery.test.ts src/services/finalized-workspace-recovery-migration.test.ts` (embedded PostgreSQL): 6 files, 410 tests passed. - Red/green: the four new online cases of "preserves a task-only warning" fail on `origin/master` and pass with this change. The online case checks that the warning row is unchanged and that the restored archive has the saved file. - New tests: a task warning that gets file evidence during the online upload still blocks publication. A `workspace_validation`, an `active_run_watchdog` and an export-cause action still block the online move. - `pnpm --filter @paperclipai/server typecheck`: passed. ## Risks - The online move now proceeds for a workspace whose task has only a task-only warning. A run that the warning wakes is still fenced by the existing `active_execution` and `task_writer_bound` checks at reservation and at publication, the same as for an idle workspace with no warning. - If the warning changes during the upload, publication refuses and the workspace stays local. > 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 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> |
||
|
|
9a6e61cf36 |
fix(connectors): show Anthropic as "Anthropic (Claude)" so a Claude search finds it (#22631)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Connectors catalog shows each provider as a card with a name and
a short description.
> - The Anthropic card shows the name "Anthropic". People who search for
"Claude" do not find it.
> - The card description says "Use Anthropic APIs with a restricted
key." This text describes an obsolete REST setup. The connector now
offers only a Claude subscription or a Claude API key.
> - This pull request changes the card name to "Anthropic (Claude)" and
the description to "Connect to Claude with Anthropic."
> - The benefit is that a search for "Claude" finds the connector, and
the description matches what the connector does.
## Linked Issues or Issue Description
No public issue exists. This is an enhancement.
**What existing behavior does this improve?**
The Anthropic card in the Connectors catalog. The card name and the card
description change.
**Subsystem affected**
UI: the Connectors catalog (Apps). Shared: the Anthropic app definition.
**Current behavior**
The Connectors catalog shows the Anthropic connector as "Anthropic" with
the description "Use Anthropic APIs with a restricted key." A search for
"claude" in the Connectors search box does not show the Anthropic card.
**Proposed behavior**
The card shows the name "Anthropic (Claude)" and the description
"Connect to Claude with Anthropic." The slug stays `anthropic`.
**Reason and benefit**
Most people know the product as Claude. They search for "Claude" and do
not find the connector. The old description refers to a "restricted
key", which the connector does not use. After this change, a search for
"Claude" finds the connector, and the description is correct.
**Breaking changes**
None. The slug, the setup links, the saved connections, and the AI
provider bindings do not change.
## What Changed
- `packages/shared/src/app-definitions/anthropic.json`: Change `name` to
"Anthropic (Claude)". Change `description` to "Connect to Claude with
Anthropic."
- `scripts/ingest-app-definitions.mjs`: Make the same change in the
generator source. A regeneration now gives the same `anthropic.json`.
- `ui/src/pages/apps/Browse.test.tsx`: Add a test. The test searches the
Connectors catalog for "claude". It checks that the Anthropic card shows
the new name and description, and that the "Connect Anthropic (Claude)"
button is present.
- `tests/ai-connections-app/app.spec.ts`: Update the opt-in browser test
to find the "Connect Anthropic (Claude)" button. The test now escapes
the provider name for the regular expression.
- `tests/runner-e2e/source-sdk-public-inputs.json`: Refresh the pinned
hash of `anthropic.json` with `node
tests/runner-e2e/source-sdk-public-inputs.mjs <sha> --write`.
## Verification
- `cd ui && npx vitest run src/pages/apps/Browse.test.tsx`: 118 passed.
The new test fails on the old definition and passes on the new
definition.
- `cd ui && npx vitest run src/pages/apps/AppsConnect.test.tsx
src/pages/apps/AppDetail.test.tsx
src/pages/apps/app-connect-policy.test.ts
src/pages/apps/app-detail/AdvancedPanel.render.test.tsx`: 369 passed.
- `npx vitest run packages/shared/src/app-definitions.test.ts
packages/shared/src/connection-instructions.test.ts
packages/shared/src/app-definitions-url.test.ts`: 59 passed.
- `node --test scripts/app-definition-overrides.test.mjs`: 3 passed.
- `cd server && npx vitest run
src/__tests__/connection-intents-service.test.ts -t "obsolete Anthropic
tool requests"`: 1 passed. Agent connection search for "Anthropic" still
finds the connector through the `anthropic` slug.
- `node scripts/ingest-app-definitions.mjs --definitions-only` in a
temporary copy: the generated `anthropic.json` is the same as the
committed file.
- `pnpm verify` asks for broad CI coverage because
`scripts/ingest-app-definitions.mjs` is a global CI input. CI supplies
that coverage.
## Risks
- Low risk. The change is display text only.
- The slug stays `anthropic`. Saved connections, setup links, and AI
provider bindings do not change.
- Connection request cards and setup headers that use the connector name
now show "Anthropic (Claude)". This is the intended result.
- The AI method labels ("Claude subscription", "Claude API key") do not
change.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, file edit, test 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>
canary/v2026.1123.0-canary.844700
|
||
|
|
98fd412851 |
fix(apps): show readable Google Workspace action names on Review and Permissions (#22630)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Connectors let agents use outside apps. The Google Workspace
connector gives agents Gmail, Calendar, Drive, Docs, Sheets and Slides
actions.
> - Each connection has a Review tab and a Permissions tab. People
approve actions and turn actions on or off there.
> - Google Workspace actions had no human title. These tabs showed the
internal tool name, for example `gmail__get_message` and
`calendar__list_events`.
> - Users must not see internal names. Google's app reviewers will also
look at these screens.
> - This pull request gives every Google Workspace action a readable
name, such as "Gmail: Read a message", for both tool transports.
> - The benefit is that people and reviewers see what each action does,
in plain words.
## Linked Issues or Issue Description
**What happened?**
On the Review tab and the Permissions tab of a Google Workspace
connection, action rows showed internal tool names. Examples:
`gmail__get_message` in the "Review new actions" list and the action
list, and "Calendar Create Event" in the "Waiting for your OK" list.
**Expected behavior**
Each row shows a readable action name, for example "Gmail: Read a
message" or "Calendar: List events". No row shows a `service__tool` name
or a raw ID.
**Steps to reproduce**
1. Connect Google Workspace.
2. Open Connectors, then the connection, then Permissions. Look at the
action list.
3. Open Review. Look at "Review new actions" and "Waiting for your OK".
**Paperclip version or commit**
master at
|
||
|
|
624a78fd5d |
fix(logging): keep tool-call arguments out of failed request logs (#22635)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents call connected tools, such as Gmail, Google Drive and Google Docs, through the tool gateway > - The HTTP logger writes the request body for every response with status 400 or higher > - The logger removes only keys with credential names, so tool arguments stay in the log > - Tool calls often return 4xx for normal outcomes, such as 409 when an action needs approval > - So email recipients, email bodies and document text go into server logs > - This pull request removes the request body from the logs of the tool-call routes > - The benefit is that user content from connected accounts does not go into log storage ## Linked Issues or Issue Description Refs #22010 (stored connection data). No existing issue; the issue is described here. **What happened?** A failed or held tool call wrote its arguments to the server log. For example, a Gmail draft that waited for approval (HTTP 409) logged the recipients and the full message body. **What did you expect to happen?** The log keeps the route, the status and the error. The log does not keep the tool arguments. **Steps to reproduce** 1. Start an HTTP logger with the default redaction. 2. Send `POST /api/tool-gateway/tools/call` with tool parameters, and make the route answer with 409. 3. Read the log line. The `reqBody` field contains the parameters. ## What Changed - Add `isPrivateToolCallHttpRequest` in `server/src/middleware/http-log-policy.ts`. It matches these routes: - `/api/tool-gateway/tools/call` - `/api/tool-gateway/gateways/:gatewayId/mcp` - `/mcp/gateways/:gatewayPublicId` - `/mcp/native-runs/:runId` - `/mcp/runtime-tools` - `/mcp/runner` - `/api/mcp/project-tools` - `/api/issues/:issueId/mcp-app-views/:viewId/tool-calls` - `/api/tool-connections/:connectionId/test-calls` - In `server/src/middleware/logger.ts`, set `reqBody` to `[REDACTED]` for these routes when the status is 400 or higher. The log keeps the route path, the parameters and the redacted error context. - Add tests in `server/src/__tests__/http-log-redaction.test.ts` for statuses 400, 403, 409, 429 and 500, and a test that other routes keep their body. ## Verification - Red: the new test failed for all 5 statuses before the fix. The log contained the canary recipient, body and document text. - Green: `npx vitest run src/__tests__/http-log-redaction.test.ts src/__tests__/sentry.test.ts` (from `server/`): 2 files passed, 114 tests passed. - `pnpm verify` selected 2,977 of 3,852 test files (full-suite scope), so required CI supplies broad coverage. `tsc --noEmit` for `server` passed. ## Risks - Low risk. The change affects only log output for the five tool-call routes. - Failed tool calls no longer show their arguments in the log. To debug a call, use the tool invocation record, which stores a redacted summary. > 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 edit, 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 - [ ] 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> |
||
|
|
a3af1ac6db |
fix(connections): remove connection content when a task or company is deleted (#22636)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents call connected apps, such as Google Workspace, and Paperclip keeps parts of the results in tool-call records, approvals, run transcripts and files > - #22010 added "Delete data" on a connection. It removes that content for one connection. > - Deleting a task or a company did not run the same cleanup. Task deletion set the task link to null on tool calls, approvals and runs, so their previews and transcripts stayed. Company deletion removed the rows but left run logs and files in storage. > - Google's restricted-scope review requires that users can delete the Google data we hold, and that the policy matches the product > - This pull request runs the "Delete data" steps when a task is deleted, and removes a deleted company's run logs and files from storage in the background > - The benefit is that deleting a task or a company removes every copy of connection content, and a canary test makes sure that a new store cannot skip these paths ## Linked Issues or Issue Description Refs #22010 **Problem** Deleting a task leaves connection content in tool-call previews, audit history, approval requests, results passed to later runs, run transcripts (events, excerpts, result text and the run log in every copy) and saved tool results over 500,000 bytes. Deleting a company leaves run logs (object journal, archive, local file, S3 mirror) and all stored files, including attachments and saved tool results. "Delete data" on a connection also left saved tool results over 500,000 bytes in storage. **Expected behavior** Deleting a task removes the connection content of the task's runs and calls. Deleting a company removes its run logs and files from storage, not only its rows. "Delete data" removes saved tool results of the runs whose transcripts it deletes. **Steps to reproduce** 1. Let an agent call a connection on a task, so that the run has a log, events and a saved tool result. 2. Delete the task, or delete the company. 3. Look in `tool_invocations`, `heartbeat_runs`, `heartbeat_run_events` and object storage. The content is still there. ## What Changed - New table `issue_connection_content_deletions`. Task deletion records, in the same transaction and before the task row goes, the task's runs that used a connection or are still working, the task's calls without a run, and the task's call events that belong to neither. Audit entries are matched by run, call or task. The background worker then runs the existing "Delete data" steps for that scope. Runs of the task that are still working are recorded too, even if they have not used a connection yet, so a connection call they make after the deletion is also cleared. The job rechecks every 1 to 5 minutes while runs or approvals are open and finishes as soon as they settle, for up to a day. It writes an `issue.connection_content_deleted` activity entry with counts only, and only when it deleted something. - New table `stored_object_deletions`. Company deletion records every run log and every file of the company before the rows go. The table has no foreign key to the company, so the removal continues after the company is gone. Each object is retried with backoff until storage confirms the deletion. Task deletion also records the task's attached files here, so a failed best-effort delete in the route is retried. - `content-deletion.ts` stays the one owner of "remove connection content". Each job table has its own typed store (load, save, finish, activity, failure), so no per-table column can compile against the other table. The storage ledger is in `stored-object-deletion.ts`, and the task request is in `issue-content-deletion.ts`. The steps now take a scope (one connection, or the runs and calls of one deleted task). The connection path behaves as before. - "Delete data" and task deletion now also delete saved tool results over 500,000 bytes (`runner-api` assets) of each run whose transcript they delete: the object in storage and the asset row. Files attached to a task, a case or a company logo are not touched. - The canary test scans every text and JSON column and every storage copy (object journal, legacy mirror, local files and file storage) after a connection deletion, a task deletion and a company deletion. It also checks that another task and another company keep their content. - Docs: the store inventory in `doc/memory/google-connector-memory.md` has columns for task and company deletion. The production checklist, the code-fixes plan, the connector playbook and the user help page `docs/guides/board-operator/deleting-connection-data.md` are updated. ## Verification - `cd server && npx vitest run src/__tests__/tool-connection-content-deletion-canary.test.ts` (12 tests). Before the fix, the new task and company tests failed: the scan found the marker in run logs, the legacy mirror, local files, saved results and attachments. The connection test also failed on the saved tool result file. - `cd server && npx vitest run src/__tests__/tool-connection-content-deletion.test.ts src/__tests__/google-managed-connection-removal.test.ts src/__tests__/git-restore-point-ledger.test.ts src/__tests__/agent-observability.test.ts` (85 tests pass). - Nine more suites that delete tasks or companies pass (456 tests), for example `decision-target-work`, `approval-retention-work`, `cleanup-removal-service` and `tool-gateway-service`. - `pnpm --filter @paperclipai/db typecheck` passes, including the migration compatibility guard (`0501` is `online_compatible`: two new tables and their indexes). - `cd server && pnpm typecheck` passes. - `pnpm verify` exits 2 because a global CI input changed. Required CI supplies the broad coverage. ## Risks - Migration: two new tables only. The previous release does not read them, so it keeps working during the overlap deploy. - Task deletion runs three more indexed queries in its transaction. It creates a job only when the task used a connection. - Company deletion inserts one ledger row per run log and per file in its existing transaction. The storage work is batched in the background, 50 objects at a time. - Company deletion now removes all of the company's files and run logs from storage. Before, they stayed in storage with no row that pointed to them. - `stored_object_deletions` keeps `company_id` without a foreign key, like `execution_workspace_restore_points`, so that removal can finish after the company is gone. It holds object keys only, no content. - A task deletion creates a job when the task used a connection or still has a run that is working. While runs or approvals are open, the job rechecks every 1 to 5 minutes. It stops waiting one day after the deletion. It then writes `issue.connection_content_deletion_incomplete` with the counts of what was still open, and that content stays. A job that deleted nothing and left nothing open writes no activity entry. - A run of the deleted task that was still working is in the scope. If it calls a connection after the task is deleted, the job waits for it and clears that content too. - Not changed: deleting a company does not ask Google to revoke the grant. Raw provider traces still expire on their own. ## 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>canary/v2026.1123.0-canary.844400 |
||
|
|
ad163d0e36 |
fix(ui): open and link only http(s) or same-origin URLs from user and agent content (#22639)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board UI shows content that agents and people write: comments, tool results, work products, approval cards and runtime links > - Some of this content becomes a link, an image or a new window > - Some of these places did not limit the URL scheme, and the chat image click opened the URL without `noopener` > - A URL with a script scheme must never open or navigate from the board, because it would run with the board origin > - This pull request adds one URL helper and routes the content-fed link, image-click and window sinks through it > - The benefit is that only http(s) or same-origin URLs can open from user or agent content, and new windows never get an opener ## Linked Issues or Issue Description **What happened?** The issue-reference parser accepted a URL with any scheme when its path contained an issue path. The markdown renderer trusted that match and kept the URL. The chat image click then gave the URL to `window.open` with no scheme check and no `noopener`. Several other components had their own copies of a scheme check, and some links used content URLs with no check. **What did you expect?** The board opens or links only http(s) URLs and same-origin paths from user or agent content. New windows open with `noopener,noreferrer`. **Steps to reproduce** Render markdown with an image whose URL uses a non-http scheme and an issue path, then click the image. The new unit tests cover this case. **Impact** Defense-in-depth hardening of the board UI against unsafe URLs in stored content. ## What Changed - Add `ui/src/lib/safe-url.ts` with `safeNavigableUrl` (http(s) or same-origin), `safeExternalHttpUrl` (absolute http(s) only) and `openSafeUrl` (opens with `noopener,noreferrer`). - `parseIssueReferenceHref` in `packages/shared` now accepts only relative paths and http(s) URLs. - `MarkdownBody` keeps the issue-reference shortcut only for safe URLs. The image click handler gets only a safe URL. - The task chat image click, the work products panel and MCP app links open through `openSafeUrl`. - The plugin bridge does a top-level navigation only to an http(s) URL. - Replace the local scheme checks in the task chat thread, protocol activity row, transcript adapter, MCP app host, workspace detail pages and artifact cards with the shared helper. - Apply the helper to artifact rows, rich artifact source and download links, approval result links, request-confirmation target links, attachment links in chat bubbles, provider source links, action test result links and runtime service links. - Refresh `tests/runner-e2e/source-sdk-public-inputs.json` for the changed shared files. ## Verification - `ui/src/lib/safe-url.test.ts`: one table of hostile inputs (script, data, file, blob, about and custom schemes, whitespace and control-character variants, non-string values) runs against each helper. It also checks that `openSafeUrl` uses `noopener,noreferrer`. - `ui/src/components/MarkdownBody.interaction.test.tsx`: an image with an unsafe URL never reaches the click handler. An http image still does. This test failed before the fix (the unsafe URL reached the handler) and passes now. - `packages/shared/src/issue-references.test.ts`: non-http schemes with an issue path return `null`. These cases failed before the fix and pass now. - A headless Chromium check confirmed the risk of the old call: a script URL opened with `window.open(url, "_blank")` ran with access to the opener. With `noopener,noreferrer` it did not reach the opener. - `npx vitest run` on the affected UI folders: 116 files, 2119 tests pass. `tsc --noEmit` for `ui` has no errors in `src`. - `pnpm verify` exits 2 because the pinned-input registry changed. Required CI gives the broad coverage. ## Risks - Low risk. A link from content with a non-http scheme (for example `mailto:` in an artifact source link) no longer renders as a link in the changed components. Markdown links keep the existing `react-markdown` URL rules. - Mention chips with their own schemes (agent, project, user, skill, routine) 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> |
||
|
|
b7dea0f070 |
fix(native): store repeated provider pack bytes once in each workspace (#22241)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native agents run in managed sandboxes, and each workspace needs the provider pack (Node, provider CLIs and provider assets) before the provider can start > - The fleet sandbox image has an older provider pack in `/opt`, so the server stages its own pack into each workspace and reuses image files with the same bytes by copying them > - The staged pack is about 3.0 GB of a 10 GiB sandbox disk, and agent tasks on large repositories filled the disk > - About 0.5 GB of that pack is the same bytes stored again under other paths: one OpenCode binary in three packages, one Node binary in two provider runtimes > - This pull request stores repeated bytes once, as hardlinks to one private copy, and copies a path that the image does not have from the same bytes under another image path instead of transferring it > - The benefit is about 550 MB more free disk per workspace, one less large layer to transfer, and a faster staging step ## Linked Issues or Issue Description **What happened?** On staging, agent tasks on the Paperclip monorepo filled their 10 GiB managed sandboxes. In a live fleet sandbox, the workspace's `.paperclip-runtime/paperclip-runner/provider-pack` used 3.0 GB (`node_modules` 1.4 GB, `provider-assets` 1.6 GB). **Expected behavior** A staged pack stores each large file's bytes once. **Steps to reproduce** 1. Use a fleet sandbox whose image pack is older than the server's pack. 2. Start a native run in it. 3. In the staged pack, compare the three OpenCode binaries (`opencode-ai`, `opencode-linux-x64`, `opencode-linux-x64-baseline`) and the Pi and Kimi `node` binaries. They have the same bytes and different inodes. **Paperclip version or commit** `e4b119440e` (master on 2026-11-18). Related: #16493 added the layered reuse. #21784 reuses an image pack that differs only in build provenance. ## What Changed - `provider-pack-layers.ts` (remote reuse step): - A large file whose bytes were already copied privately for another path in this pack is a hardlink to that private copy. - A large file that the image does not have under its own path is copied from an image file with the same bytes under another path, and hashed, instead of being transferred. - Every staged file stays a physical file inside the pack. The image is never linked, because the runner requires pack files and provider asset folders to be physical paths inside the pack (OpenCode launch files, Kimi and Pi installers). ## Verification - `pnpm vitest run src/services/native-runtime/provider-pack-archive.test.ts` (server): 50 passed, with real GNU tar and zstd. New tests: - repeated bytes are one private inode (`nlink` 3), not the image's inode; a path the image lacks comes from an image twin; only the overlay is transferred; the image is unchanged - when the image twin has different bytes, every repeated path is transferred and has the correct bytes - Red/green: the first new test fails on master's code and passes with this change. The second is a safety test and passes on both. - Replay on real fleet sandboxes. I created fresh Daytona sandboxes from the staging fleet snapshot `fleet-sbx-6d5b52eaeeb7`. I used the real file list (paths, sizes, SHA-256) of the current server pack, taken from a live staging workspace. Each replay ran the reuse step, the overlay extraction and the verifier's tree walk. - Disk per workspace, including the layers that are still transferred: 3,033 MB before, 2,484 MB after (−549 MB). - Transfer: the Kimi Node binary layer (126 MB uncompressed) is no longer transferred. - Staging time, same sandbox, alternating order (s): before 5.78, 5.84, 7.39, 7.61; after 5.13, 5.40, 7.04, 6.73. After is faster in all 4 pairs. The reuse step alone: before 2.42–3.59 s, after 1.85–2.99 s. - `pnpm verify`: see the comment below. ## Risks - Repeated bytes share one inode inside the pack. A process that writes one of these binaries also changes its twins. Provider binaries are not written at runtime. - The image is only read, never linked or changed. - No migration, API, or configuration change. ## Model Used Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used in Claude Code with tool use and code execution (shell, Daytona API, local 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> |
||
|
|
06d488b430 |
fix(telemetry): report every Paperclip runner harness as its own adapter_type (#22637)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The server sends `agent.task_run` and `agent.task_completed`
telemetry. Each event has an `adapter_type` dimension with a fixed enum
in the generated telemetry contract.
> - #22324 made a Paperclip runner agent report its underlying harness
as `adapter_type`.
> - Seven harnesses that the runner can resolve to are not in the enum:
Copilot, Antigravity, AWS AgentCore, Claude Managed, Grok Bot, Muse and
OpenAI Dot. Delivery normalizes them to `other`, on open source and on
Cloud.
> - Thus, the adapter breakdown in analytics still has an `other` bucket
that no build can fix.
> - This pull request syncs the telemetry contract, which now lists the
seven harnesses, and sends Copilot as `copilot_runtime`.
> - The benefit is that every runner harness has its own `adapter_type`
value in analytics.
## Linked Issues or Issue Description
Refs #22324
**What happened?**
A Paperclip runner agent that uses Copilot, Antigravity, AWS AgentCore,
Claude Managed, Grok Bot, Muse or OpenAI Dot sends an `adapter_type`
value that is not in the generated contract enum. The value is
normalized to `other`. Copilot also sends `acpx:copilot`, which is not a
contract-style name.
**Expected behavior**
Each runner harness reports its own `adapter_type` value. Copilot
reports `copilot_runtime`, which is the name
`agentRuntimeSettingsHarness()` already uses.
**Steps to reproduce**
1. Create a Paperclip runner agent with `provider: "acpx"` and
`acpxAgent: "antigravity"` (or `"copilot"`).
2. Let the agent finish a run.
3. Look at the `agent.task_run` event. `adapter_type` is `other`.
**Paperclip version or commit**
`master` at
|
||
|
|
8f20961d20 |
fix(claude-local): accept every copy hint key in the setup-token prompt parser (#19211)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The "Connect a model" step signs in to a Claude subscription. The
server runs `claude setup-token` in a PTY. The parser reads the output
for the authorization URL.
> - Claude Code prints a copy hint between the URL and the code prompt.
The key in the hint depends on the host terminal. The server passes its
environment to the child, so the terminal that started Paperclip decides
the hint.
> - The parser accepts only `Hold Shift while selecting…` on one line.
Claude Code also prints `Fn`, `Option`, and `Shift (Option in iTerm2, Fn
in Terminal.app)`. The long hint wraps across two rows.
> - For these hints the parser returns `null`. The UI stays on
"Preparing browser sign-in…" with no error until the 5-minute timeout.
> - This pull request accepts the four key phrases and joins a hint that
wraps.
> - The benefit is that sign-in works on macOS, over SSH, and in tmux,
screen, or zellij. The parser still fails closed for all other text.
## Linked Issues or Issue Description
Refs #17868. The macOS comment on that issue shows this symptom:
`local/check` returns `sign_in_required` with no `authorizationUrl`.
This PR fixes the copy hint part of that issue. It does not fix the
token parse part (#17276).
Related PRs. I searched all open PRs that change `setup-token-parse.ts`:
- #15550 (merged) added the one-line `Shift` hint.
- #16988 and #18560 (open) accept a `Shift` hint only. A comment on
#16988 reports the long `Shift (Option in iTerm2, Fn in Terminal.app)`
hint under tmux on WSL2. Neither PR accepts that hint, and neither
accepts `Fn` or `Option`.
- #17276 (open) reads the token from the rendered screen. That is the
next step after this one. The two changes do not overlap, and both are
necessary. With this PR alone, the sign-in link shows, but the token
step can still fail (see Verification).
**What happened?**
On macOS, the connect step shows "Preparing browser sign-in…" and never
shows the sign-in link. The `claude setup-token` child is alive. It
prints the URL and the code prompt.
**Root cause**
Claude Code 2.1.317 selects the hint key with this logic (paraphrased
from the CLI bundle):
| Condition | Key in the hint |
|---|---|
| `TERM_PROGRAM=Apple_Terminal` | `Fn` |
| `TERM_PROGRAM=iTerm.app`, `LC_TERMINAL=iTerm2`, or VS Code/Cursor on
macOS | `Option` |
| a known terminal such as xterm, kitty, or WezTerm | `Shift` |
| other: SSH session (`SSH_CONNECTION`), multiplexer (`TMUX`, `STY`,
`ZELLIJ`), or macOS | `Shift (Option in iTerm2, Fn in Terminal.app)` |
`findBrowserCodePrompt` returns `null` when the first non-blank line
after the URL is not the prompt and not the `Shift` hint.
**Steps to reproduce**
1. On macOS, start Paperclip from Terminal.app, from iTerm2, or from a
shell with no `TERM_PROGRAM`.
2. Open onboarding. Select Connect a model → Claude (Subscription).
3. The UI stays on "Preparing browser sign-in…".
**Paperclip version or commit**
`master` at
|
||
|
|
78b10a43ce |
fix(customer-success): fit oversized inspection list pages instead of failing (#22625)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip Cloud can do audited, read-only customer-success inspection of a stack through `/api/customer-success/v1/read` > - The tenant rejects any inspection response over 2 MB with 422 > - Run rows are large, so a 25-row `runs` page is often over 2 MB on a busy stack > - Cloud reports the 422 to the agent as a refused read, so the agent cannot tell that a smaller page works > - This pull request makes an oversized list page return the largest prefix of rows that fits, with `nextOffset` at the first omitted row > - The benefit is that list reads succeed at any page size, and normal pagination gets the rest ## Linked Issues or Issue Description **What happened?** A customer-success agent listed `runs` with `limit` 25 on 9 stacks. Each read failed as refused. The same reads with `limit` 3 and `limit` 1 succeeded. A `tasks` list with `limit` 25 on the same stack succeeded. **Expected behavior** A list read returns rows and a `nextOffset`. The size limit must not fail the whole page when fewer rows fit. **Steps to reproduce** 1. Seed a company with 25 tasks that each have a 200 KB description. 2. Send a valid inspection permit for `list tasks` with `limit` 25. 3. The response is 422 "Inspection response is too large". ## What Changed - `server/src/routes/customer-success.ts`: add `fitInspectionResponse`. When a list response is over 2 MB, it does a binary search for the largest row prefix that fits. It sets `nextOffset` to `offset + count`. A single row that cannot fit still gives 422. - `server/src/__tests__/customer-success.test.ts`: add a route test with 25 large tasks and a unit test for the helper. ## Verification - `npx vitest run src/__tests__/customer-success.test.ts src/__tests__/customer-success-cloud.test.ts`: 12 passed, 1 skipped. - Red/green: with the old size check, the new route test fails with `expected 422 to deeply equal 200`. With the fix it passes. - On a staging stack, `runs` with `limit` 25 failed and `limit` 3 succeeded, which matches the cause. ## Risks - Low. Only responses that already failed with 422 change. A page can now hold fewer rows than `limit`. Callers already follow `nextOffset`. ## 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>canary/v2026.1123.0-canary.843900 |
||
|
|
30881e6aa9 |
fix(ui): keep the tasks the user opened in the saved read cache ahead of preloaded ones (#22627)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board UI saves a read cache in local storage. Since #21671 it also saves the first chat frame of the 20 most recently opened tasks, so a hard load of such a task shows its chat at once. > - The 20-task limit ranks tasks by when this page opened them, or else by when their data was read. > - Task lists and the sidebar's Recents preload the chat of their top rows in the background. Those reads land after the user opens a task, so preloaded tasks rank above the opened one. > - On staging, more than 20 preloaded tasks pushed out the task the user had opened (PAP-4463): neither its record nor its chat was saved, so it never opened from the saved chat. > - This pull request ranks opened tasks first and saves the time each task was last opened with the record, so the order also holds on the next load. > - The benefit is that the tasks the user actually opens are the ones that open instantly next time. ## Linked Issues or Issue Description **Describe the bug** After a hard load of a task, the saved read cache often does not contain that task. Tasks that a list or Recents only preloaded take the 20 slots. **Steps to reproduce** 1. On staging, open a task (for example PAP-4463) while the sidebar Recents and a task list preload other tasks. 2. Read `paperclip:query-cache:v1:<user>:<company>` in local storage after the page settles. 3. The record holds the chat of up to 20 preloaded tasks, and not the opened task. **Expected behavior** The tasks the user opened rank first for the 20-task limit, also after a reload. **Actual behavior** Preloaded tasks have newer read times than the opened task's visit, so they rank first and push it out. Refs #21671. ## What Changed - `ui/src/lib/persisted-query-cache.ts`: the 20-task limit ranks tasks that the user opened before tasks that were only read in the background. Opened tasks are ordered by their latest open, the others by their read time. An open is recorded by the task page (`recordTaskOpen`), keyed by the task's id, so a task row or link never counts and any ref spelling ranks the same. Each company record saves the open times of its saved tasks (`visits`, an optional field), and a restore reads them back. Older records without `visits` still load. Open times are cleared on sign-out, on an account change and for a refused task. - `ui/src/pages/IssueDetail.tsx`: records the open once the task has loaded. - `ui/src/lib/saved-task-chat.test.ts`: a task opened before 25 newer preloads (with mounted detail observers) keeps its record and chat, also after a reload that preloads 25 more; a task opened by a lowercase identifier ranks as opened; another user's record never receives the open times; a refused task's open time is dropped. - `doc/ui-internals.md`: the read-cache rules state the ranking. ## Verification - `cd ui && npx vitest run src/lib/saved-task-chat.test.ts`: 25 passed. With the ranking change reverted, the new case fails. With only the restore of saved visit times disabled, it fails at the after-reload assertion. - `src/lib/persisted-query-cache.test.ts` and `src/lib/restored-task-chat-bootstrap.test.ts` also pass (91 tests across the three files). `pnpm --filter @paperclipai/ui typecheck` passes. - Staging evidence (build `cb4129a91`): the saved company record held chat for preloaded tasks (1.38 MB, 234 entries) and did not contain PAP-4463, whose whole chat is about 105 KB. ## Risks - Low risk. Only the order in which tasks fill the 20 slots changes. The saved data, the bounds, expiry and revocation do not change. The visit times are timestamps under keys that the record already contains. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, browser automation). ## 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: Claude Opus 5.5 <noreply@anthropic.com>canary/v2026.1123.0-canary.843800 |
||
|
|
78e4f4f130 |
feat(runner): Antigravity on ACP 1.5.2 with Linux, API-key auth and Gemini 4 Neon (still pending) (#22591)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The native Runner starts each agent harness and owns its lifecycle, credentials and recovery > - Google Antigravity is Google's only first-party coding harness, and it is the harness for Gemini 4 Neon > - The Runner had an Antigravity integration, but only as a pending candidate: ACP server 1.4.3, macOS ARM64 only, Google sign-in only, closed unless an operator opened it for one company and one model > - Cloud sandboxes run Linux and use API keys, so the candidate could not run there, and it had one attended test cell > - This pull request moves the integration to ACP server 1.5.2, makes it run on Linux and with a Gemini API key, adds the tests the other ACPX harnesses have, and removes the code paths that would block recovery after release > - The benefit is that the release of Antigravity becomes a small declaration change after the live suites pass. The profile stays `pending` in this pull request. ## Linked Issues or Issue Description Refs #98 Refs #6559 Refs #8523 Refs #21121 (a separate legacy-style `agy_local` adapter that uses the CLI print protocol; this pull request does not replace or include it) ## What Changed **Runtime** - Pin Antigravity ACP server 1.5.2 (was 1.4.3). Owned admission patch is `1.5.2-paperclip.2`. - Verified patched closures for `darwin-arm64`, `linux-x64` and `linux-arm64`. `darwin-x64` stays inventory-only. - The patcher reads Mach-O and ELF builds. It signs macOS output only. One admission source serves all platforms. - Platform gates in TypeScript, Rust, the sidecar schema and the server admit each host that has a verified closure. **Auth and models** - Gemini API-key auth reaches an exact-model session receipt. Admission accepts a model only when the base model and the thinking level both match the requested ID. - API-key connections get a model list on local and cloud environments. The list is generated at build time from the pinned runtime. The server starts no process to read it. - Gemini 4 Neon, Carbon, Argon and Hydrogen are selectable. The picker marks them "needs a paid Gemini API plan" for API-key connections. - One shared module maps model ID to family and thinking level. - `google/gemini-4-neon` is added to the OpenCode model list. A new model audit is in `doc/adapter-model-audit-2026-11-22.md`. **Lifecycle and failures** - A provider error no longer completes the turn. The driver classifies it: overloaded, rate limit, quota, auth rejected, model unavailable. - Overload retries are bounded (3 attempts, about 14 seconds). - A refused session reload maps to incompatible saved state, so the automatic replacement conversation applies. - Server gates that refused restart recovery, remote targets and shared state for Antigravity now apply only while the profile is pending. - A Google sign-in connection with a cloud environment is refused at save and at Test, with a plain message. - A released profile rejects candidate grants in TypeScript and in Rust. **Launch cost and integrity (all native ACPX providers)** - Each closure is verified one time into a sealed read-only store. Later launches check file identities and hash the exact executable they start. - Remote provider-pack verification is recorded per sandbox lease. Later runs check kernel identity and fall back to the full hash on any difference. - Superseded stores are removed in the background after a launch. **Provider pack and image** - The provider pack carries Antigravity for `linux-x64` as a candidate provider. It becomes an ordinary provider from the profile status alone. - The Daytona image build accepts the candidate. A credential-free smoke runs in the build. **Tests and CI** - New `antigravity-qualification` suite: 24 cells, local and Daytona. - New model lineup suites: 14 API-key cells and 14 Gemini 4 cells. Each cell requires the exact model in the Runner receipt. - Antigravity can run the `chat-features` cases with `--profile runner-acpx-antigravity`. - `runner-full-stack-e2e.yml` passes `GEMINI_API_KEY` for the new profile and derives candidate providers from the selected Daytona cells. **Docs** - `doc/plans/2026-11-22-antigravity-qualification.md` is the current release contract, acceptance ledger and operator recipe. ## Verification Commands that passed on the final revision: - `pnpm build` - Typecheck for all packages, including the runner-e2e test projects - `pnpm test:e2e:runner:unit`: 11,665 Vitest tests passed, 25 skipped; 386 node tests passed - `cargo test -p paperclip-runner-core -- --test-threads=4`: 1,199 passed, 2 failed. The 2 failures are Codex transport timing tests that pass alone and on `master`. - `cargo fmt --check`, `check:acpx-profiles`, `check:protocol-types`, `node scripts/check-maps.mjs` - Native patch tests: 9 of 9 on `darwin-arm64` and 9 of 9 on `linux-x64` - UI picker tests: 397 of 397 Known failures that also fail on `master`: - 11 runner package script tests (browser, Pi and package-boundary checks) - 6 `runtime-selection` tests that read an untracked local skill file Live evidence, without a prompt: - Clean provisioning on `darwin-arm64` and on `linux-x64` in a Daytona sandbox. The closure digests reproduce. A changed or missing file is rejected. - `initialize` reports 1.5.2. An API-key session returns a receipt for exactly `gemini-3.8-flash-low` and the exact instruction bytes, on both platforms. - All 28 model IDs (14 Gemini 3, 14 Gemini 4) return an exact receipt under an API key. - A session survives a process kill and resumes in a new process with exact receipts, on both platforms. - The server's remote path verifies the provider pack in a Daytona sandbox. - Run start to native `initialize`: 3.45 s to 1.46 s on macOS, 3.65 s to 1.74 s on Linux x64, before the per-launch executable hash was restored (about 60 ms on macOS; not measured on Linux). - Remote pack verification on a reused sandbox lease: about 4.3 s to about 0.25 s. Live evidence, with a prompt, on an already-released harness: - Pi native, `pi-native.runner-acpx-pi.local.agent-files-fresh-run`, on `darwin-arm64` at `427e9b088b`: 1 of 1 passed, 14 of 14 checks, both native runs succeeded (25.5 s and 25.7 s). The process started from the new launch store with no fallback warning. - The same cell and `native-pending-controller-restart` failed in the paid workflow on this branch and on `master` in the same way, before any native start. The workflow does not install the Pi runtime for local cells, so the agent setup check fails. That is a workflow gap, not part of this change. **Not run.** No Antigravity prompt completed on 1.5.2 on any platform. The only Gemini key available is on the free tier, and Google returned 503 or 429 for each attempt on two days. These gates are open: - All 24 `antigravity-qualification` cells - Both model lineup suites, including inference on Gemini 4 Neon - The attended Google sign-in journey on 1.5.2 - The chat cases under Antigravity - Image pull time and startup time on a published image - A native start on `linux-arm64` - A live provider-death cell for Kimi, Pi or Copilot on the new launch store (one ordinary Pi cell passed live; see above) ## Risks - **The launch store changes how every native ACPX provider starts** (Kimi, Copilot, Cursor, Pi), not only Antigravity. A review found two defects in the first version (an executable swap was possible, and Pi launches broke). Both are fixed with tests. One live Pi cell passed on this branch on macOS. No live provider-death cell and no Linux cell ran for those providers. - The profile digest changes. Saved Antigravity candidate sessions and existing candidate grants stop working. The new release refuses old state by name and starts a replacement conversation. - The Linux provider pack and the Daytona image grow by about 834 MB (about 274 MB compressed) when Antigravity is included. - The pack verification record is in server memory. The first run after a server restart pays the full hash again. - Antigravity 1.5.2 reads the workspace `GEMINI.md` and `AGENTS.md` as user rules. This is deliberate and matches Codex. Any other rule file is refused. - Orchestrator mode is not available. ACP server 1.5.2 does not expose it. - Antigravity stays `pending`. Normal users cannot run it until a later change removes the pending status. ## Model Used - Claude Fable 5.2 (`claude-fable-5-2`) planned, briefed and integrated the work, with tool use. - Claude Opus 5.5 (`claude-opus-5-5`) subagents wrote the code and ran the tests, 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
17ccf6bd2e |
fix(runner-tests): stop the host-control test wrapper from aborting at exit (#22624)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The paperclip-runner package has a live test that starts the native
runner through a Python wrapper, `test/support/private-host-control.py`
> - The wrapper has a daemon thread that reads frames from stdin. This
thread stays blocked in `readline` after the native child exits
> - At interpreter shutdown, Python must close stdin. The blocked thread
holds the stdin buffer lock, so Python aborts with "could not acquire
lock ... at interpreter shutdown, possibly due to daemon threads"
(SIGABRT)
> - On macOS, each abort opens a "Python quit unexpectedly" dialog. Long
unattended agent sessions run this test many times and leave tens of
dialogs (59 crash reports on one machine)
> - This pull request makes the wrapper exit with `os._exit` after it
flushes its receipts
> - The benefit is a clean wrapper exit and no crash dialogs on
developer machines
## Linked Issues or Issue Description
**What happened?**
Each run of `src/live/runnerd-codex-transport-release-resume.test.ts`
aborts its Python wrapper with SIGABRT at exit. On macOS each abort
opens a crash dialog. The crash reports show `_enter_buffered_busy` in
`_io__Buffered_close` during `_Py_Finalize`, with a `forward` thread
blocked in `_buffered_readline`.
**Expected behavior**
The wrapper exits with code 0 and no crash report after it emits the
`exited` receipt.
**Steps to reproduce**
1. On macOS or Linux, start `python3
test/support/private-host-control.py /bin/sh -c "sleep 0.3"` in a new
process group with stdin as an open pipe.
2. Keep stdin open after the child exits.
3. The wrapper ends with SIGABRT.
**Paperclip version or commit**
master at
|
||
|
|
50cee0cb8f |
fix(recovery): do not hold a task for a retry cancelled before it started (#22262)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The heartbeat service holds a task for reconciliation when a legacy run stops and Paperclip cannot tell which of its actions took effect > - A task moved to backlog while its automatic retry still waited for its scheduled time. The control plane cancelled that retry before anyone claimed it > - The cancelled retry had no start time, stage, process, lease or execution events. It still got an "unknown outcome" hold, because its chain had already spent two failure retries > - After that, every wake was refused with `execution_reconciliation_required`, and Retry could not clear the hold. The rule is that a Retry button that is shown must work > - This pull request treats an unclaimed control-plane cancellation like the other never-started dispatch cancellations > - The benefit is that the task continues on its next wake or Retry, and tasks that are already stuck recover without manual work ## Linked Issues or Issue Description Refs #20752 (related: it hardens the `queued` cancel marker; it does not cover a cancelled `scheduled_retry`) **What happened?** A task had a pending scheduled retry (status `scheduled_retry`, never started). The task moved to backlog, and the control plane cancelled the retry (`errorCode: "cancelled"`, cancellation `source: control_plane`, `expected: true`, initiator `system`). The chain had `executionRetryAccounting.failureRetries = 2`. Terminalization recorded a `legacy_execution_requires_reconciliation` hold with automatic replay blocked. When the task moved back to todo, each new run was cancelled before it started with `execution_reconciliation_required`. The task showed `canRetry: false`, and a Retry press did not start a run or clear the hold. **Steps to reproduce** 1. Give a legacy-runtime agent a task with a pending `scheduled_retry` run whose chain has spent two failure retries. 2. Move the task to backlog. The control plane cancels the pending retry with `expectedStatus: "scheduled_retry"`. 3. Move the task to todo, then press Retry. **Expected behavior** The cancelled retry never ran, so there is nothing to reconcile. The next wake or Retry starts a fresh run. **Actual behavior** The task stays held. Every wake is refused, and Retry does not start a run. ## What Changed - Root cause 1: cancelling a never-started run stamps "no provider work" evidence only when its status was `queued`, not `scheduled_retry`. - Root cause 2: `legacyExecutionNeedsReconciliation` returns "hold" when the chain has two or more failure retries, before it reads any no-provider-work evidence. - `neverStartedDispatchCancellationPredicate` (and its synchronous pre-check in `isPreDispatchReviewWaitVerified`) now also accepts an expected system `control_plane` cancellation with `errorCode = "cancelled"`. It requires the same retained-execution proof as the dispatch-gate cancellations. A retry also needs a settled predecessor (`settledRetryPredecessorPredicate`). Terminalization records a reconciliation hold on a predecessor whose outcome is unknown, and the scheduler does not retry such a run. So the predecessor must exist and carry no effective or superseded reconciliation hold. A row with retry metadata whose predecessor was deleted fails closed. Workspace-wait chains keep their dedicated proof. The candidate check reads the cancellation with `readRunCancellation`; the SQL predicate in `pre-dispatch-execution-evidence.ts` is the single proof. - The same predicate is used at terminalization (no new hold) and in `executionBlockerPredicate` (a hold that an earlier release recorded no longer blocks). Tasks that are already stuck therefore recover on their next wake or Retry. The audit row is kept. - `doc/heartbeat-internals.md` documents the rule. ## Verification - New `server/src/__tests__/never-started-retry-cancellation-hold.test.ts`: - backlog cancel of a pending retry (real `cancelRun` with `expectedStatus: "scheduled_retry"`) → no hold → todo → Retry queues a fresh run, and the dispatch gate sees no blocker; - a hold recorded by an earlier release plus a refused todo run → Retry queues a fresh run, and the blocker clears; - the hold stays when the cancelled retry shows a start time, a process, a stage, an execution event, or an unexpected cancellation, or when its predecessor is held or was deleted. The main case runs with three real chains: a transient failure before provider work, an `ai_connection_busy` wait, and an environment wait after a succeeded run. - Red/green: without the fix, the first two cases fail (the blocker shows `canRetry: false` and "Automatic recovery stopped…"). With the fix, all 11 cases pass (4 fail without it). - Related suites pass: `explicit-native-continuation`, `task-retry`, `legacy-execution-recovery`, `heartbeat-undispatched-execution-wait`, `issue-scheduled-retry-routes`, `execution-blocker-read`, `legacy-continuation-authority` (728 tests across 8 suites). - `pnpm typecheck` in `server/` passes. - Note: 7 tests in `chat-channels.integration.test.ts` ("reconciled chat retry delivery ownership") fail locally when the full file runs, on unmodified `master` too. A continuation from an earlier test in the shared database leaks into their global delivery sweep. They pass when run alone. This change does not cause them. ## Risks - Low risk. The exemption needs all of these: a legacy run; `cancelled` status with `errorCode = "cancelled"`; an expected system `control_plane` cancellation; no retained execution evidence (start, stage, controller, process, session, lease, finalization or execution events); and, for a retry, a predecessor that still exists and has no reconciliation hold. Operator Stops, failed predecessors and runs with any execution evidence keep today's behavior. - No migration. Historical holds are kept as audit rows. They only stop blocking. - Not covered here: a retry cancelled while its predecessor failed with unknown outcomes keeps its hold. That case needs a separate decision about where Retry should anchor. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, test runs) 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>canary/v2026.1123.0-canary.843500 |
||
|
|
cb4129a918 |
test(restart-chaos): record why each hosted request failed and split gate D health failures into client-side and server-side (#22611)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The restart-chaos harness has a hosted mode. Its gate D requires 0
failed health probes across 10 consecutive releases on a hosted test
stack.
> - The harness runs on a home Mac over Wi-Fi. Three classes of failed
probe occurred: isolated 503s from the cloud idle sweep (a real bug, now
fixed), timeouts while the Mac slept with the lid closed, and `fetch
failed` errors during a Wi-Fi access point change.
> - The records keep only the status, the duration and `fetch failed`.
Each failure needs a manual investigation, and a client-side network
fault fails the gate the same way as a server outage.
> - This pull request records the evidence for every failed request and
gives each failure a class: client-side, server-side or unclassified.
> - The benefit is that a gate D failure explains itself, and only
server-side or unclassified failures fail the gate.
## Linked Issues or Issue Description
**What happened?**
Gate D failed on health probes that the stack did not cause. On
2026-11-23 at 02:28Z, the Mac slept: a 10 s abort fired after 18.5 s,
and the 2 s probe loop had a 16 s gap. At 08:05:35Z and 08:05:55Z,
undici reported `fetch failed` after 42 ms and 1240 ms, during a Wi-Fi
access point change. The saved records showed only `{status, ms, error:
"fetch failed"}`.
**Expected behavior**
Each failed request records why it failed: undici's error cause, the
socket, the connection reuse, the answer headers and body, the client
clock, and a control probe to a neutral endpoint. Gate D counts only
server-side and unclassified failures. Client-side failures stay visible
in `SUMMARY.md` as information.
**Steps to reproduce**
Run hosted gate D from a laptop on Wi-Fi, and sleep the laptop or change
the access point during the run. Before this change, the gate fails with
a bare `fetch failed` record.
## What Changed
- New `tests/restart-chaos/hosted-diagnostics.ts`:
- A fresh-connection client for the health probe (`node:https` with
`agent: false` and `connection: close`). Each probe opens and closes its
own connection, so a keep-alive race cannot look like an outage. It
records DNS, connect, TLS and first-byte times and the remote address.
- A connection tracker on undici's diagnostics channels. It tags each
API request's socket as new or reused, with the remote address, connect
time and time to first byte.
- Error-cause capture: `code`, `errno`, `syscall`, `hostname`,
`address`, `port`, message, and the socket's addresses and byte counts
for `UND_ERR_SOCKET`.
- Answer evidence for a non-2xx answer: status, the listed headers only
(`x-paperclip-status`, `retry-after`, `server`, `via`,
`x-railway-request-id`, `x-railway-edge`, `cf-ray`, `date`,
`content-type`, `cache-control`, `connection`), the first 512 bytes of
the body, and the parsed `error` and `statusPage.code`.
- Client clock: `timerLagMs` (elapsed minus timeout when an abort
fires), wall clock against monotonic clock, `monitorEventLoopDelay`
maximum, and the pause before each health probe.
- The classifier (`classifyFailure`) and the summary lines for
`SUMMARY.md`.
- `hosted-api.ts`: every failed request runs one control probe to
`https://www.cloudflare.com/cdn-cgi/trace` and, for a GET that did not
time out, one immediate retry of the same URL (2 s limit). The failure
is recorded at once; the control and retry outcomes are attached in the
background, and `settleDiagnostics()` waits for them before grading and
before `requests.jsonl` is saved. Concurrent failures share one control
probe per second. The control probe and the retry are not counted as
requests. The retry logic of the API client does not change. Only the
live entry point sets `live: true`, which turns on the fresh-connection
health client and the control probe; unit tests never reach the network.
- The fresh-connection client follows up to 3 same-origin redirects. A
cut-short answer keeps its status, headers and partial body beside the
error. A retry whose body cannot be read is recorded as failed.
- `hosted-gate.ts`: the health-probe check counts `server +
unclassified` from one class summary built from each failure's stored
class. The check line shows the three counts. Without class evidence,
every failure counts as unclassified.
- `hosted-release.ts`: release detection skips client-side failures, so
a client-side failure in a swap gap does not make a release
stop-then-start.
- `hosted-main.ts`: a failed probe's line is written to `health.jsonl`
when its evidence is complete, with a `hosted_health_failure_classified`
timeline event.
- `hosted-grade.ts` and `hosted-main.ts`: `SUMMARY.md` lists each health
probe failure with its class, reason and evidence. Client-side failures
are marked as information. The request breakdown lines show the class
counts. The timeline's `hosted_health_failed` event carries the class
and reason.
- Classes:
- Server-side: any HTTP answer that is not a readable 2xx; a reset or
refused connection while the control probe succeeded; a timeout while
the control probe succeeded and the client did not stall.
- Client-side: a `client_stall` (abort more than 1 s late, clock jump
over 1 s, event-loop delay over 1 s, or a pause before the probe longer
than twice the interval); a failed control probe; a client DNS failure
(`EAI_AGAIN`, or an `ENOTFOUND` that the immediate retry does not
repeat).
- Unclassified: all other failures. They fail gate D.
- The macOS Wi-Fi BSSID and RSSI capture is not included. On current
macOS it needs `sudo wdutil` or location permission, so it is not
simple.
- README: a "Failure evidence" paragraph and the new gate D health rule.
## Verification
- `npx vitest run --config tests/restart-chaos/vitest.config.ts`: 74
files, 939 tests pass.
- `node scripts/typecheck-test-projects.mjs tests/restart-chaos`:
passes.
- New tests in `tests/restart-chaos/hosted-diagnostics.test.ts`:
- `counts a reset as server-side when the control probe to the neutral
endpoint succeeded`
- `counts a reset as client-side when the control probe failed too`
- `counts a stalled client timer as client-side even when the control
probe succeeded`
- `counts a client DNS failure as client-side`
- `leaves a failure without enough evidence unclassified, and gate D
fails on it`
- `passes gate D with only client-side failures and keeps them visible
as informational lines`
- `records the 503's status, headers, body excerpt, parsed error and
statusPage code, and counts it server-side`
- `records undici's error cause and socket for a reset, and classifies
it by the control probe`
- `does not repeat a failed non-GET request as the immediate retry`
- `passes the gap before each probe to the health check`
- `opens a fresh connection for every health probe and records its
phases`
- `tags an API request's socket as new or reused`
- `reports a reset on a fresh connection with the socket's addresses and
byte counts`
- A manual smoke run against the control endpoint recorded `reused:
false`, the remote address, and DNS, connect, TLS and first-byte times.
An unknown host recorded `ENOTFOUND` with `syscall: getaddrinfo`.
## Risks
- Low risk. The change is in the test harness only. No product code
changes.
- Each failed request now adds one control probe and, for a GET that did
not time out, one retry with a 2 s limit. They run in the background, so
the health probe cadence and the API client's own retries do not wait
for them. The grade waits for them before it classifies; a diagnosis
that is still pending counts as unclassified.
- Each request sends an extra `x-restart-chaos-request` header to the
stack. The server ignores it.
- The client-side rules can hide a real server fault only when the
client also could not reach the neutral endpoint, or when the client
stalled. Every other failure counts against the gate.
- Release detection and the swap-shape check still read every failed
probe. That behavior does not 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
- Provider: Anthropic. Model: Claude Opus 5.5 (`claude-opus-5-5`), run
in Claude Code as an agent with tool use (shell, file edits, test runs).
Standard context window.
## 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: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1123.0-canary.843400
|