mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 18:35:33 +01:00
627d59c5aa1dd6fe20a8b3fcb577c4807d7fdd19
4638
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
627d59c5aa |
fix(inbox): group repeated provider failures and clear recovered tasks (#22846)
## Thinking Path > - Paperclip helps people manage work that agents do. > - The inbox tells a person which tasks need a decision. > - A provider usage limit can stop several attempts on one task or affect several tasks. > - Separate failure cards made it hard to tell which tasks still needed attention. > - This change groups failures using the account, reset time, or retry links that Paperclip can verify. > - A person can now see which task to retry, which tasks are waiting, and which ones recovered. ## Linked Issues or Issue Description **What existing behavior does this improve?** It improves the Coordinator inbox when a provider limits usage. **Current behavior** Repeated run failures can fill the inbox. Resolved failures can still appear beside open decisions. **Proposed behavior** Show personal actions in Needs you, automatic retries and snoozes in Waiting, and past events in History. Keep an archived retry chain hidden during automatic attempts. Return it to Needs you when a person must act. **Additional context** Related work includes #18020 on completed tasks, #9704 on archive behavior, and #21570 on usage limits in chat. ## What Changed - Group verified account and reset windows. When that evidence is missing, count linked attempts per task and show the tasks in a collapsible group. - Separate the reported reset time from each task’s retry schedule. Keep unresolved ownership recoveries visible after task closure. Use persisted native retry requests to preserve the original archive and increment the attempt count. - Keep personal archive in the card menu. Put decision receipts and run logs in History. - Align inbox filters, tabs, and history. Share empty-state artwork and placement across Inbox, Goals, Routines, and Secrets. - Index run-history pages and resumed-work lookups, and rate-limit history requests per company and viewer. Add synthetic fixtures for both grouping paths and a manual walkthrough. ## Verification - The author and a human tester completed the synthetic retry-chain walkthrough. Chromium also verified archive, repeat failure, exhaustion, and recovery. - The 64 focused server tests and the UI and server typechecks passed before rebasing. See `doc/testing/coordinator-inbox-test-drive.md` to repeat the manual checks. - The shared SDK input check and all 64 focused server tests passed after rebasing. The OpenAPI suite (59 tests), API catalog suite (2,309 tests), and both demo seed paths passed locally after the CI fixes. - The affected inbox and native-runtime suites passed locally after merging the upstream conformance test fix in #22854. The browser access-denial scenarios passed three runs each for 403 and 404. - The migration checks and 79 focused tests passed, including an index-plan regression with 5,000 unrelated runs. The migration and query plan were reverified after renumbering. [Full CI on `cf52b80161`](https://github.com/paperclipai/paperclip/actions/runs/45529834793) passed after rerunning a timed-out server shard. ## Risks The attention feed reads retry ancestry. Long chains can increase query cost. Task and company checks bound the traversal, and cycle detection stops repeated visits. Providers that omit the reset time leave the card with an unknown reset. Migration 0508 adds two indexes concurrently. Each run-history page returns at most 100 records. ## Model Used OpenAI Codex, GPT-6 family, with repository editing, local test execution, and browser verification. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
0c3ed144cb | Label opt-in traces with the public instance hostname (#22856) | ||
|
|
12944919c6 |
feat(google): keep Google Technical Information at most 30 days and keep Google data out of training exports (#22842)
Adds a durable, sleep-aware 30-day sweep for Google Technical Information, keeps Google results out of decision training and shared feedback traces, and deletes the remaining copies of a cleaned run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3ad8f00192 |
feat(antigravity): trusted /swarm from the task composer, behind an experimental flag (#22733)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` (a coordinator, helpers and a verifier) only on the Antigravity CLI > - #22731 adds a verified CLI route to the Runner, but nothing selects it yet > - A swarm must start only when the signed-in user asks for it, only when an admin turned the experimental feature on, and never silently run as an ordinary request when it cannot run > - This pull request adds the trusted `/swarm` request in the task composer, the server checks and run selection behind an experimental flag, removes Paperclip delegation tools from a swarm turn, and adds the attended catalog cells, docs and ledger > - The benefit is that a user can start a native swarm from a task, and gets one plain message when it is not available ## Linked Issues or Issue Description Refs #22731, #22727, #22728, #22701 **Subsystem affected** Task composer (UI), issue comments API, run selection (server), Paperclip Runner tool bridge, runner-e2e catalog, docs. **Problem or motivation** A user who writes `/swarm <request>` to a Google Antigravity agent should get a real native swarm in the task folder. Today `/swarm` is neutralised text, and the task runs as an ordinary request. **Proposed solution** Read a leading `/swarm` with the shared rule from #22727 in the composer, send it as a structured request, check it on the server, and select the CLI route from #22731 for that run only. ## What Changed - **Trusted start (UI).** `parseSwarmCommand` in `composer-commands.ts` uses `parseLeadingUserCommand` (the one rule from #22727). A leading `/swarm` in the task composer sends the request text with `nativeCommand: "swarm"`; a bare `/swarm` asks for a request; `/swarm` with an assignee change is refused; `/swarm` anywhere else stays text. A resent draft keeps the structured request. - **Contract.** `addIssueCommentSchema` gains `nativeCommand: "swarm"`. `instance.experimental.enableAntigravitySwarm` (feature catalog, settings page, server defaults), off by default. No Cloud policy in Core. - **Server (`services/antigravity-swarm.ts`, comments route, runtime selection).** - The comments route accepts `nativeCommand` only from a signed-in board user. When a swarm cannot run it answers 422 with one plain message and posts nothing: flag off, not a Google Antigravity assignee, a chat, Plan mode. - An accepted request is recorded in the activity log (`issue.antigravity_swarm_requested`, server-written) and the assignee's wake carries the comment id. Comment text is never read as a command. - Run selection makes the run a swarm only when that activity record exists. It refuses a remote or cloud environment and Plan mode with a plain run failure, so a swarm is never run as an ordinary request. It logs `issue.antigravity_swarm_started` in plain language: helper actions are auto-approved, Paperclip does not sandbox the helpers and cannot see their shell commands, and usage is one total. - The native execution input sets the Antigravity provider mode `swarm` for that run only, and carries the verified request in its own field, `provider.swarmRequest` (the Runner contract accepts it only with that mode and requires it there, 1 to 16,000 characters). The Runner copies it into the model envelope as `swarmRequest`; the swarm route sends exactly `/swarm <swarmRequest>` and never reads `task.prompt`, which holds rendered wake comments, task context and text the Runner adds (handoff, attachments, queued messages). - The swarm turn contract (mode `swarm`, envelope `paperclip.native-model-envelope.v3`, `swarmRequest` of 1 to 16,000 characters) is declared as `antigravitySwarmTurn` in `protocol/provider-schemas/acpx-sidecar.schema.json` and generated into TypeScript, so the pack `contractDigest` covers it (it changes; older image packs are rebuilt rather than reused). Provider profile `commandDigest`s and versions are unchanged, so no saved session is reset. - What the swarm sees of the task: only the request. The title, the description (which other people or agents may have written) and other comments are not part of the prompt; the coordinator can read them through Paperclip's task tools as data if it needs context. - An empty `/swarm` or one over 16,000 characters is refused in the composer, by the comments route (422, nothing posted) and at run selection (plain run failure), so it never runs as ordinary work. - A swarm run never takes queued messages, and Interrupt treats it as already started: it stops the swarm and delivers the queued message as the next ordinary request, before or after the provider accepted the turn. - Retry after Stop, and past the three automatic attempts, counts only when the signed-in user asked for it (their own Retry request on the task after the last attempt). Wake reasons and copied run context are not proof: a recovery that copies the request marker, an automatic retry on the user's behalf, or an agent wake that names `task_retry` stay bounded. - **Runner.** For a swarm turn the Paperclip bridge drops delegation tools (`paperclip_create_task`, `paperclip_create_issue`, hire/assign tools); the instructions also tell the coordinator not to delegate. - **runner-e2e.** `antigravity-swarm` suite, 5 local cells (`two-helpers-and-verifier`, `stop-mid-swarm`, `process-loss-retry`, `follow-up-after-swarm`, `flag-off-refusal`), explicit-only, never in `--all` or CI matrix jobs. There is no automated executor yet: the launcher refuses the cells and points at the live recipe. Catalog counts updated (1392 cells). - **Docs.** `tests/runner-e2e/SUITES.md`, `doc/evals.md`, and the `/swarm` section, ledger row and live recipe in `doc/plans/2026-11-22-antigravity-qualification.md`. ## Verification - `pnpm --filter @paperclipai/server exec vitest run src/services/antigravity-swarm.test.ts`: 2 passed (red first: module missing; Plan mode red then green). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-comment-reopen-routes.test.ts -t swarm`: 3 passed; 2 red against the route without this change. - `pnpm --filter @paperclipai/ui exec vitest run src/components/task-chat/TaskChatComposer.test.tsx`: 164 passed, including 4 new `/swarm` tests (red first). - Runner: `vitest run src/drivers/acpx/antigravity-swarm-*.test.ts`: 69 passed (route tool filter red first). - runner-e2e: `antigravity-swarm.test.ts` (red first) plus the catalog, selector and Antigravity tests: 28 files passed. - Typecheck: server, UI (except generated Storybook files absent from a worktree) and runner: no errors. - Live, real CLI 1.5.15 with the owner's sign-in, through the driver: the receipt verified (pinned identity, task folder, `auto` read back, `gemini-3.8-flash` + `low`). Google then refused the prompt with its 429 quota text; the driver reported it as a typed "out of quota" failure, retired the CLI and nothing was written. - **Not run live yet:** the full Paperclip proof (swarm to Done, Stop, kill and Retry, follow-up, flag off). This PR is merged only after it passes. Recipe: `doc/plans/2026-11-22-antigravity-qualification.md#swarm-live-proof`. ## Risks ### Security notes: the trust boundary Helpers are auto-approved and Paperclip does not sandbox the CLI on a local computer, so the boundary is who asked and what text is sent. Every input that can influence it: **(a) Whether a run is a swarm** - `nativeCommand: "swarm"` on the comment request: accepted only from a signed-in board user; the request record (`issue.antigravity_swarm_requested`, actor = that user, `commentId`) commits in the same transaction as the comment. Paperclip-written. - `antigravitySwarmCommentId` on the wake/run context: set only by the comments route and by run selection. It is a pointer, never trusted alone: selection re-verifies comment id + task + company + human author (no agent author) + a matching record by the same user. - The pending request for marker-less wakes: the task's latest human comment, verified the same way. - Retry inheritance: the run's `retryOfRunId` chain (server-written), bounded to 8 hops on the same task. - Manual vs automatic: a request's first run, or a user's own Retry request (`task_retry` / `retry_failed_run`, requested by a user, not `initiatedBy` automation) after the last attempt. Not the wake reason string. - Instance flag `enableAntigravitySwarm` (admin), the assignee's adapter config (Google Antigravity), execution target (local only), work mode (Standard only: Plan, Ask and any other mode are refused, at comment time and at run time), chat vs task: all Paperclip-owned settings. - Prior attempts on the same request (run status rows): Paperclip-written. **(b) What text and tools the swarm gets** - The prompt: `/swarm ` + `provider.swarmRequest`, which is the recorded comment body minus a leading `/swarm`, trimmed, byte for byte (tested through the production input builder and envelope with a merged wake that contains an agent comment). The verified request. - The system prompt append: only Paperclip-authored text: Paperclip's fixed execution prompt, the run's hand-in values (the server-written completion revision and criterion IDs that `paperclip_finish`/`paperclip_block` require; never a criterion's requirement text), and the fixed swarm rules. **The swarm runs without the agent's own instructions**: the instruction bundle and connection instructions are left out, because an agent with an editable instructions folder can rewrite its instructions in an earlier ordinary run, the helpers act under auto mode, and Paperclip keeps no user-approved copy of those instructions to trust instead. - Tools: only Paperclip's own MCP bridge (any other assigned tool server refuses the swarm), with delegation, hiring, routing and generic API operations removed. Paperclip's permission handler approves a CLI permission request only when its tool name is `mcp_paperclip_<tool>` and `<tool>` is one the run's bridge admits; everything else is refused, and the CLI then ends the turn. Tool descriptions are Paperclip-authored; tool results (for example other comments) are data the coordinator reads, not the request. - Model and mode: the agent's configured model, Antigravity's `auto` mode, both read back and pinned by the receipt. - Not sent: task title, description, wake comments, continuation events, attachments, queued messages, handoff text. Known residual: a Retry or recovery run that has not yet been selected (still preparing) does not carry the request marker, so an Interrupt in that short window keeps the message for the turn boundary instead of stopping the run; the message is delivered after the run ends. - Off by default and local only. With the flag on, helpers act under Antigravity's `auto` mode. **Paperclip does not sandbox them on a local computer**, and their tool calls never reach Paperclip, so helper shell commands can write outside the task folder where the CLI's own sandbox allows (workspace plus temp directories). The settings text, the activity log and the plan doc say so. - On macOS the CLI uses its own Google sign-in from the login keychain, not Paperclip's stored connection. - Google's consumer terms have a clause about third-party tools that access the service. A legal read is pending; this PR does not claim compliance. - `/swarm` as the first word of a composer message is now a swarm request for every agent; for agents other than Google Antigravity the server refuses it with a plain message. To send the literal text, put other text first. - The new runner-e2e cells are attended only and have no automated executor. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. Review round 2 (head |
||
|
|
ff0f395579 |
Fix managed environment reconciliation and qualify runtimes before deployment (#22734)
## Thinking Path > - Paperclip manages AI agents and the environments where they run. > - Deployments can supply managed environment rows and preinstalled runtimes. > - A new instance can have a managed row before it has a company binding. > - A later configuration update must update that row without taking ownership of a tenant row. > - Release builders also need to check sandbox compatibility before deployment. > - This pull request fixes reconciliation and exposes the same runtime compatibility check as an offline command. > - Deployment failures can then hold a candidate release while current instances continue to start. ## Linked Issues or Issue Description **What happened?** A platform-managed sandbox row can become stale before the instance has its first company. The row has an ownership marker but no company binding, so the old drift check treats it as an operator edit. Separately, release builders have no standalone way to run the compatibility check used at task startup. **Expected behavior** Update a platform-owned row when managed configuration changes. Preserve tenant-owned rows and deliberate archives. Allow a release builder to check the exact candidate image and an observed sandbox installation before deployment. **Steps to reproduce** 1. Apply a fully managed environment to an instance without companies. 2. Change its snapshot and apply the configuration again. 3. Observe that the old implementation leaves the original snapshot in place. Refs #22835. That change refreshes stale lease qualification proofs at runtime. This PR checks release compatibility before deployment and fixes the managed row update. ## What Changed - Reconcile explicitly platform-owned rows before a company binding exists. Preserve row identity, tenant environment values, and archive safeguards. - Extract the existing pure provider-pack compatibility check. Task startup and the offline command use this same function. - Add `server/dist/qualify-sandbox-runtime.js`. It reads expected artifacts from the candidate image and observed installation data from standard input. It checks all packaged providers by default. Compatible publication hashes may differ. - Return exit status 0 for compatible, 2 for incompatible, and 1 for invalid or unavailable evidence. - Document the observation and integrity requirements. Keep existing startup fallback and degraded startup behavior. No convergence flag or new startup gate is added. ## Verification - 128 tests passed across the command, runtime compatibility, environment service, and managed environment suites. - `pnpm exec tsc --noEmit -p server/tsconfig.json` passed. - All current-head CI checks passed, including the full selected server, chat, serialized, runner, build, typecheck, and e2e suites. - `pnpm verify --base origin/master` selected 2,376 files conservatively. The redundant local sweep was stopped after CI completed; no full local-sweep pass is claimed. - The initially failed comment-reload browser case passed 3 local repetitions and the failed CI jobs passed on rerun without source changes. - The command test launches a real offline subprocess and checks compatible, incompatible, and invalid input outcomes. - Added-line secret and PII scan passed. No deployment or workspace repair was performed. ## Risks The command trusts remote observations supplied by its caller. The caller must verify installed files and prove the installation is protected before asserting `immutable: true`. This is release evidence, not a signed authorization. The runner binary must match; provider-pack compatibility uses the existing interface rules. No schema migration is required. Startup continues with the existing fallback if later runtime conditions change. ## Model Used OpenAI Codex, `gpt-6.1-sol`, xhigh reasoning, with tool use and code execution. ## Checklist - [x] I searched for similar PRs and linked related work. - [x] Thinking path and issue description included - [x] Model specified - [x] Focused tests and server typecheck passed - [x] Tests and documentation updated - [x] No internal instance links or identifiers included - [x] All required CI gates are green on the current head - [x] Greptile is 5/5 with no unresolved findings --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
535d04edb3 |
fix(workspaces): exclude named pipes from workspace snapshots like sockets (#22817)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A hosted server can move a workspace's files into a portable snapshot archive, for example when the server moves to volume-free storage > - The archive already skips Unix sockets, because a socket is a runtime IPC endpoint with no file contents, and records the skipped path > - A named pipe (FIFO) is the same kind of runtime IPC endpoint, but capture refused the whole workspace with `remote_workspace_archive_unsupported_entry` > - One leftover pipe in a workspace therefore blocked a whole server's move, with no way to settle it > - This pull request treats a named pipe like a socket: record it as excluded and keep the files beside it > - The benefit is that workspaces holding a stray pipe can be saved and moved, with the skipped path still visible in the archive manifest ## Linked Issues or Issue Description Follow-up to #19159, which excluded sockets and kept the existing refusal of named pipes. **What happened?** An offline move of a server to volume-free storage rolled back. The recorded refusal was `remote_workspace_archive_unsupported_entry` on one workspace. The only entry types that still reach that refusal are named pipes and device files. **Expected behavior** A named pipe has no portable contents, like a socket, so capture should record it as excluded and save everything else. **Steps to reproduce** 1. Create a workspace folder with a file and a named pipe (`mkfifo pipe`). 2. Capture a snapshot archive of it. 3. See capture fail with `remote_workspace_archive_unsupported_entry`. ## What Changed - `remote-workspace-snapshot-archive.ts`: a named pipe is recorded in the archive's excluded paths, like a socket, instead of failing the capture. The same function also builds the serialized remote capture script, so both paths change together. - `remote-workspace-readonly-inventory.ts`: the read-only inventory excludes named pipes the same way, so its fingerprint matches what capture saves. - Device entries and unsafe links are still refused. - The test that asserted pipe refusal now asserts the new behavior: the pipe stays in place, adjacent work restores, and the archive manifest lists the pipe as excluded. ## Verification - Red: with the source change reverted, the new test `records a named pipe as excluded and preserves the files beside it` fails. - Green: `npx vitest run src/services/remote-workspace-snapshot-archive.test.ts src/services/remote-workspace-readonly-inventory*.test.ts` (in `server/`): 3 files, 130 tests pass, using a real `mkfifo` pipe. ## Risks - A pipe is not recreated on restore, exactly as for sockets. Its path is visible in the existing exclusion manifest. A process that expected the pipe to exist recreates it as it would after any restart. - No new archive entry type, dependency, or background work. ## 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 - [ ] 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f913a4f1b8 |
Drop the stale external-chat refusal from the control-plane port test (#22854)
## Thinking Path - Core master's Cloud readiness has failed `server (9/10)` on every commit since 23:30Z, which blocks the master Docker image and every production rollout. - The failing test is `paperclip-control-plane-port.test.ts` › "persists a delayed final answer and replay…". It fails deterministically, including when run alone. - #22807 intentionally changed recovery so that an ordinary task woken by an external chat gets its accepted final reply posted, as on the live path. This test still asserted the old rule (`externalChatContinuation` → recovery refuses). - It went unnoticed because the suite ran only nightly until #22831 moved it into regular CI. ## What Changed - Removed the stale `externalChatContinuation` refusal step. #22807's `agent-chat-response-recovery.test.ts` cases already cover external-chat recovery (`done` and `needs_review`). - The test still checks that recovery refuses while the issue comment is skipped, and that the presentation worker posts the final reply exactly once. ## Verification - `paperclip-control-plane-port.test.ts`: 1 failed / 108 before, all pass after. - Together with `agent-chat-response-recovery.test.ts`: 181 passed. - Reproduced the CI failure locally first with `pnpm test:run:general -- --group general-server-without-chat-or-native-runner --shard-index 8 --shard-count 10` (same assertion). ## Risks - Test-only. No product change. ## Checklist - [x] I have searched GitHub for duplicate or related PRs and linked them above (related: #22807, #22831; companion master fix #22852) ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8c04793a4a |
feat(google): delete content read from Google when access ends (#22836)
Every way a Google connection ends now starts the durable connection content deletion on its own, and Paperclip never resumes a cleaned harness session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ba63f4f8b2 |
perf(test): split chat-channels monolith into 16 suites and shrink PR chat shards 5 -> 2 (#22838)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - `server/src/__tests__/chat-channels.integration.test.ts` had grown into an 86,498-LOC single-file monolith (~1,815s total CPU across 5 serialized line-sharded PR runners) that forced special-case line sharding in `scripts/run-vitest-stable.mjs`, prevented `general-chat` from participating in file-level test selection, and pinned 5 PR CI shards even for single-provider chat edits. > - This pull request splits the monolith into 16 provider- and domain-scoped integration suites plus 4 `<1,000`-LOC shared harness helpers (`harness.ts`, `providers.ts`, `github-harness.ts`, `retry-fixtures.ts`), optimizes redundant setup/polling overhead (`-41.8%` net LOC, `-70.9%` CPU-min: `1,815.3s -> 528.4s` with every original assertion and matrix case preserved), switches `general-chat` to file-level duration-balanced LPT sharding (`265.1s / 263.3s` across 2 shards), wires `general-chat` into `test-selection` and `local-verify`, and shrinks the PR matrix from 5 chat shards to 2 (`general_tests`: `30 -> 27`). > - Every provider (GitHub, Discord, Slack, Teams, Telegram) and shared core behavior retains full assertion coverage while ordinary chat edits now select only affected provider suites instead of all 5 shards. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Test execution time, maintainability, and incremental test selection for `server/src/__tests__/chat-channels/**`, `scripts/run-vitest-stable.mjs`, and `.github/workflows/pr-trusted.yml`. **Subsystem affected** server/ — chat-channels integration tests & CI test runner/matrix **Current behavior** `server/src/__tests__/chat-channels.integration.test.ts` is an 86,498-LOC monolith requiring custom source-line sharding across 5 PR CI jobs (`chat (1/5)`..`chat (5/5)`) and bypassed by file-level test selection. **Proposed behavior** Replace the monolith with 16 focused provider/domain suites + 4 shared harness modules, use standard file-level duration-balanced LPT sharding with `scripts/chat-shard-durations.json`, include `general-chat` in incremental test selection (`select-tests.mjs`, `test-selection-plan.mjs`, `local-verify/plan.mjs`), and run `general-chat` on 2 PR shards (`chat (1/2)`, `chat (2/2)`). ## What Changed - **Split & optimized `chat-channels.integration.test.ts` (`86,498 LOC` → 16 provider/domain suites + 4 `<1,000`-LOC harness modules, `-37,314` net LOC / `-70.9%` CPU-min):** - Shared harnesses: `harness.ts` (957 LOC), `providers.ts` (857 LOC), `github-harness.ts` (817 LOC), `retry-fixtures.ts` (905 LOC). - 16 integration suites covering Board/Core (1), Discord (2), GitHub (4), Slack (4), Teams (2), and Telegram (3), totaling `528.4s` CPU (down from `1,815.3s`), preserving all 20 stopped-workspace-cleanup and 28 response-maintenance GitHub matrix cases. - **File-level LPT sharding & test selection for `general-chat`:** - Updated `scripts/run-vitest-stable.mjs` (947 LOC), `scripts/chat-shard-durations.json`, `scripts/ci/refresh-chat-shard-durations.mjs`, `scripts/ci/select-tests.mjs`, `scripts/ci/test-selection-manifest.mjs`, `scripts/ci/test-selection-plan.mjs`, `scripts/local-verify/plan.mjs`, and `scripts/general-server-shard-durations.json`. - Updated `maps/agent-access-map/chat-channels.md`, `maps/feature-map/{chat-channels,connection-setup,recovery}.md`, `server/scripts/benchmark-response-presentation.mjs` (including `../../services/native-runtime/...` relative baseline import), and `server/scripts/test-slack-sync-protocol.mjs`. - **Shrank PR `general-chat` matrix from 5 shards to 2 (`general_tests`: `30 -> 27`):** - Updated `.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml` fallback matrix, and `.github/scripts/tests/ci-plan.test.mjs` (`30 -> 27`). - Kept `release-verify.yml` at 3 chat shards (LPT-balanced). ## Verification - `node --test .github/scripts/tests/ci-plan.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/local-verify.test.mjs scripts/__tests__/release-verify-workflow.test.mjs scripts/ci/test-selection*.test.mjs` — **197/197 PASS** - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capability IDs aligned) - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (105 nightly suites validated, 17 test files checked) - `node server/scripts/typecheck-layers.mjs` — **0 errors** across all 7 layers - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/chat-channels/github-review-workflow.integration.test.ts` — **89/89 PASS** (`171.27s`) - Live shard execution (`node scripts/run-vitest-stable.mjs --mode general --group general-chat --shard-index 0 --shard-count 2`) — **8/8 files, 455/455 tests PASS in 104.0s** ## Risks - Low risk: all 16 split suites preserve full PostgreSQL-backed integration assertions across every chat provider, `general-chat` file sharding gracefully handles arbitrary shard counts (including `release-verify.yml`'s 3 shards and over-sharded empty shards), and full CI validates all chat suites live before merge. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local test execution (`ui-prune-2`, `vitest-runner`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
0733a01c8d |
fix: Restore icon and appearance when rolling back an agent config revision (#19244)
> [!NOTE] > Opened by Prospector's automated issue-fix pipeline. A maintainer reviews and decides; nothing here merges on its own. ## Thinking Path - Issue #19081 reports a defect in paperclipai/paperclip. - Root cause, as the fixing agent read it: configPatchFromSnapshot built the rollback patch without icon or appearance, so a rollback kept the agent's newer values and recorded that mixed state as the new revision. - This pull request: Restore icon and appearance when rolling back an agent config revision ## What Changed - `server/src/lib/agent-records.ts`: configPatchFromSnapshot now adds icon (string or null) and appearance (only if agentAppearanceSchema.safeParse succeeds). It leaves each field out when the snapshot value is missing or invalid, so older revisions don't clear the agent's current values. ## Verification - Reproducing test(s), added in this PR: `server/src/__tests__/agent-config-snapshot-patch.test.ts`, `server/src/__tests__/agent-persona-persistence.test.ts` - They fail on the base commit and pass with the fix, each twice in a fresh sandbox. - 3 independent attempts wrote 3 reproductions; this fix passes every one of them. - The repository's compile command passes with the fix applied. - 1 existing test file(s) near the change passed. - The full test suite passes except for the 13 file(s) that already fail on the base commit. ## Risks - Written by an automated pipeline, not a person: review it as you would an outside contribution. - Risk tier of the touched paths: 2. ## Model Used - codex:gpt-6.1-sol, opus, sonnet (Anthropic Claude, via Claude Code; OpenAI, via the Codex CLI), writing and checking the change in an isolated sandbox. - opus (Anthropic Claude, via Claude Code), reviewing it independently. ## Linked Issues Fixes #19081 A search of paperclipai/paperclip's open and closed pull requests found no other pull request that names #19081. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with 'Fixes: #' / 'Closes #' / 'Refs #' OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub '#NNN' / 'github.com/paperclipai/paperclip' URLs) - [ ] My branch name describes the change (e.g. 'docs/...', 'fix/...') and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge <!-- prospector:issue-fix v1 issue=19081 base=6452e964a363 report=e4e8f7064467f854 --> Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com> |
||
|
|
5ea18a811a |
fix: Match originKindPrefix as a literal prefix by escaping LIKE wildcards (#19197)
> [!NOTE] > Opened by Prospector's automated issue-fix pipeline. A maintainer reviews and decides; nothing here merges on its own. ## Thinking Path - Issue #19120 reports a defect in paperclipai/paperclip. - Root cause, as the fixing agent read it: All three originKindPrefix predicates in server/src/services/issues.ts (the issue list, the issue count and blockedInboxIssueConditions) put the raw value into a LIKE pattern, so '%', '_' and '\' acted as pattern syntax instead of literal characters. The route casts req.query to string without checking it, so a repeated query parameter reaches the service as an array, and escaping has to convert t - This pull request: Match originKindPrefix as a literal prefix by escaping LIKE wildcards ## What Changed - `server/src/services/issues.ts`: Adds originKindPrefixCondition, which applies escapeLikePattern, and uses it at all three predicates so the rule is defined once. String(prefix) keeps the existing comma-joined result for repeated query parameters; without it those requests no longer return 200, and all three repeated-parameter route tests fail. ## Verification - Reproducing test(s), added in this PR: `server/src/__tests__/issues-origin-kind-prefix.test.ts` - They fail on the base commit and pass with the fix, each twice in a fresh sandbox. - The repository's compile command passes with the fix applied. - 9 existing test file(s) near the change passed. - The full test suite passes except for the 14 file(s) that already fail on the base commit. ## Risks - Written by an automated pipeline, not a person: review it as you would an outside contribution. - Risk tier of the touched paths: 2. - The scope reviewer found it also changes, beyond the report: Missing, undefined, null, empty-string, false, zero, or NaN prefixes passed at runtime - The scope reviewer found it also changes, beyond the report: Ordinary nonempty prefixes, whitespace, repeated parameters without pattern characters, and stringifiable malformed values without pattern characters ## Model Used - opus (Anthropic Claude, via Claude Code), writing and checking the change in an isolated sandbox. - opus (Anthropic Claude, via Claude Code), reviewing it independently. ## Linked Issues Fixes #19120 A search of paperclipai/paperclip's open and closed pull requests found no other pull request that names #19120. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with 'Fixes: #' / 'Closes #' / 'Refs #' OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub '#NNN' / 'github.com/paperclipai/paperclip' URLs) - [ ] My branch name describes the change (e.g. 'docs/...', 'fix/...') and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge <!-- prospector:issue-fix v1 issue=19120 base=a19416601759 report=771e573dddc44281 --> --------- Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com> |
||
|
|
4553c2396b |
refactor(test): prune 483 redundant nightly soak test suites (keep 105 canonical) (#22831)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Over recent sprints, `scripts/ci/nightly-only-suites.json` accumulated 588 real-clock soak, recovery, lease, and maintenance test files totaling ~326k LOC and ~307 CPU-minutes on `master`, `release-verify`, and `full-ci` runs. > - Most of those files are overlapping single-PR regression soaks whose failure modes are already covered by canonical suites, driving up maintenance cost, typecheck load, and post-merge verification runtime without adding distinct coverage. > - Following `.agents/skills/test-audit/SKILL.md`, this pull request prunes 483 redundant/overlapping soak files (`-158,485` net LOC, ~180 CPU-min saved) while retaining 105 canonical, high-signal nightly suites covering every distinct failure mode and 100% of suites referenced by CI workflows, benchmarks, Slack eval manifests, lifecycle inventories, or tsconfigs. > - All timing manifests and feature/agent-access maps are updated cleanly to remove stale references. > - The benefit is a ~59% reduction in nightly soak CPU time and ~158.5k fewer lines of duplicate test code to compile, typecheck, and maintain while preserving full invariant and canonical soak coverage. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Test suite maintainability, typecheck scope, and nightly/post-merge/full-CI runtime across `scripts/ci/nightly-only-suites.json` and `server/src/`. **Subsystem affected** server/ — REST API & orchestration services **Current behavior** `scripts/ci/nightly-only-suites.json` contains 588 standalone soak test files (~307 CPU-min total), with hundreds of overlapping one-PR recovery, lease, and idle-maintenance soak suites duplicating canonical coverage. **Proposed behavior** Retain 105 canonical high-signal nightly suites covering every distinct failure mode and every hard-referenced suite, delete 483 redundant soak files, and keep `nightly-only-suites.json`, `general-server-shard-durations.json`, and `maps/` 100% synchronized. ## What Changed - **Pruned 483 redundant nightly soak files (`-158,916 / +431` LOC = `-158,485` net LOC, ~59% of nightly soak CPU):** - Retained **105 canonical high-signal nightly suites** covering every distinct failure mode and 100% of hard-referenced suites (`scripts/run-vitest-stable.mjs`, `runner-chaos-evals.yml`, `ci-work-benchmark.yml`, `tests/lifecycle-baseline/inventory.mjs`, `stress-workflow-traceability.json`, `packages/plugins/examples/slack/evals/cases.json`, and `tsconfig*.json`), including the 6 focused suites restored after review (`idle-database-backup-sync`, `isolated-remote-workspace-source-lock`, `agent-chat-response-recovery`, `chat-slack-receipts`, `heartbeat-slack-invitation`, `ephemeral-migration-service`). - **Updated manifests and maps:** - `scripts/ci/nightly-only-suites.json`: 588 → 105 suites (0 missing, 0 duplicates, 0 protected invariants demoted). - `scripts/general-server-shard-durations.json`: 2,138 → 1,655 entries (`coverage: { measured: 1573, withSetup: 1573, inventory: 1655 }`, pruned all 483 deleted paths). - Updated all affected `maps/{agent-access-map,feature-map}/*.md` files with zero dangling references. ## Verification - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (105 nightly suites validated, 0 invariant violations) - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capability IDs aligned) - `node packages/plugins/examples/slack/evals/run-regressions.mjs --list` — **PASS** - `node --test scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/check-test-budget.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/test-selection-timings.test.mjs tests/lifecycle-baseline/report.test.mjs .github/scripts/tests/ci-plan.test.mjs` — **102/102 PASS** - Repo-wide scan confirmed 0 test-to-test imports and 0 dangling references in `scripts/`, `.github/`, `maps/`, `tsconfig*.json`, `packages/plugins/examples/slack/evals/cases.json`, or `tests/lifecycle-baseline/inventory.mjs`. ## Risks - Low risk: every deleted file was already nightly-only (not running on ordinary PRs) and every distinct failure mode plus every core control-plane invariant remains covered by PR suites and the 105 retained canonical nightly suites. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local test execution (`server-prune`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
fb900bf0fe |
fix(runner): re-qualify a stale sandbox snapshot proof instead of blocking runs (#22835)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Runner on a Daytona sandbox pins the snapshot that a saved qualification proof measured. > - The proof goes stale when the snapshot, the config or a captured image changes. It also goes stale when a qualification probe stops before it finishes. > - Lease admission then failed every run with `sandbox_snapshot_qualification_required`. Only a person who selected Run test could clear it. > - Recovery must work without a person. A config change or a deploy must not leave runs that need a click. > - This pull request makes lease admission run the same qualification probe by itself, then pin the newly qualified snapshot. > - The benefit is that runs continue after an image change. A run still never starts on an unpinned snapshot name. ## Linked Issues or Issue Description **What happened?** On a hosted staging instance, every Paperclip Runner run on the managed "Paperclip Sandbox" environment failed at setup for about 40 minutes. The error was `sandbox_snapshot_qualification_required: The snapshot qualification is missing or stale. Open the agent's Harness / Runtime page and select Run test`. Three agents were blocked. The run was not retried. The failures stopped only after a person selected Run test. **Expected behavior** A stale saved proof is re-checked automatically. The run continues on the qualified snapshot. No person needs to select Run test. **Steps to reproduce** 1. Use a Daytona snapshot environment that has a saved v2 snapshot proof. 2. Change the snapshot, or interrupt a qualification probe, so that the proof is stale or invalidated. 3. Make sure the managed-image bypass does not apply. For example, a managed row whose provider is not in the live managed config `environments` section. 4. Start a Paperclip Runner run. Before this fix, admission throws `sandbox_snapshot_qualification_required` and does not try again. Root cause: The managed row's saved proof was from 2026-10-28, when a person last selected Run test. The fleet snapshot changed several times after that, so the proof was stale. That had no effect while `usesManagedCloudSandboxImage` returned true. When that check returned false, the stale proof became a hard stop. The check needs the live managed config to list the provider, with no active captured image. The existing `unowned-marker` test shows that this stops the run. I could not read the server environment to confirm which input changed at that time. This fix therefore covers the whole class: a stale proof is re-qualified, whatever made it stale. Refs #18066, Refs #17445 ## What Changed - `acquireRunLease` no longer fails when a saved snapshot proof is stale or invalidated. It runs the same probe as the agent's Run test (`probeEnvironment` with `acquireSandboxRuntimeLease`). It then reads the recorded proof again and pins the qualified snapshot ID. - Only one re-qualification runs for each environment and company at a time in a server process. The in-flight probes are shared by all runtime instances. Admission reads the saved proof again before it probes, so a run that comes after a successful re-check does not probe again. - A failed re-check answers later runs for the same saved config for two minutes. A queue of runs behind a broken snapshot starts one probe sandbox, not one for each run. A config change starts a new probe at once. - If the re-check cannot prove the snapshot, the run still fails before it gets a run lease. The run error uses only controlled text. Raw provider error text, which can contain credentials, stays out of the run error. The message does not tell a person to fix the sandbox. - Tests: a new regression test reproduces the staging case. It also starts a second run through a different runtime while the probe is held open, and checks that only one probe lease starts. A second new test checks that a provider error with a token does not reach the run error, and that two runs one after the other start only one probe after a failure. The `unowned-marker` and `changed-base`/`changed-runtime` cases now check that the only provider lease is the qualification probe (`resolveSnapshotIdentity: true`). No run lease uses an unpinned name. ## Verification - Red/green: the new test `re-qualifies a stale snapshot proof by itself instead of blocking the run until someone selects Run test` fails on master with the exact staging error. It passes with this fix. - `npx vitest run src/__tests__/environment-runtime.test.ts src/__tests__/environment-probe.test.ts src/__tests__/agent-runner-qualification-routes.test.ts src/services/agent-runner-selection.test.ts`: 505 passed on the first commit. `environment-runtime.test.ts`: 217 passed on the final head, two runs in a row. - The single-probe and failure-reuse tests fail when the shared map or the failure reuse is removed. - `tsc --noEmit -p server/tsconfig.json` passes. - After deploy, I will check staging: Paperclip Runner runs on the managed sandbox reach a lease without anyone selecting Run test. ## Risks - When a proof is stale, the first run after the change waits for one extra probe sandbox (boot, `uname`, release) before its own lease. This happens once for each environment and company until the snapshot changes again. Runs with a valid proof, and runs on the managed-image bypass, do not change. - A probe that fails still stops the run with `sandbox_snapshot_qualification_required`. The pinning guarantee does not change. - For two minutes after a failed re-check, runs for that environment fail without a new probe. After that, the next run checks again. - Server replicas do not share in-flight probes. Each replica can start at most one probe, and the first success records the proof for all of them. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, browser for staging forensics). ## 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> |
||
|
|
de4b60fc54 |
refactor(test): prune 28 completed migration, prose-grep, and Storybook fixture tests (#22832)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Over recent sprints, the test suite accumulated completed one-time SQL migration backfill tests, brittle static prose-matching guidance tests, and non-production Storybook fixture/prototype/feasibility-probe tests that add compile and CI maintenance cost without testing live behavioral invariants. > - Core database migration guards, active runtime migration services, security/safety static guards, and active adapter suites must stay intact. > - This pull request deletes 28 audited low-value test files (-1,894 LOC), preserves the one genuine schema validation assertion from `chat-communication-guidance.test.ts` inside `packages/shared/src/validators/chat-channels.test.ts`, prunes the 5 deleted server test keys from `scripts/general-server-shard-durations.json`, and refreshes `tests/runner-e2e/source-sdk-public-inputs.json`. > - The benefit is cleaner, higher-signal test coverage with zero lost invariants and synchronized SDK public source pins. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Test suite signal-to-noise ratio and maintenance overhead across `packages/db`, `packages/shared`, `packages/skills-catalog`, `server`, `ui/storybook`, `scripts`, and `tests/speko-voice-proof`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** 28 test files test already-shipped one-time migrations/dead backfills, static markdown/copy wording, non-production Storybook fixtures/prototypes, or a superseded voice feasibility probe. **Proposed behavior** Remove the 28 low-value test files while preserving all core migration integrity suites, active runtime migration services, security static guards, live adapter suites, and the genuine `updateChatEndpointSchema` assertion. ## What Changed - **Completed one-time migrations & dead backfills (3 files deleted, 444 LOC):** - Deleted `packages/db/src/better-auth-account-issuer-migration.test.ts`, `packages/db/src/chat-telegram-draft-ids-migration.test.ts`, and `server/src/__tests__/tool-oauth-legacy-backfill.test.ts` (zero production callers outside barrel re-export). - Retained all core DB migration guards (`check-migration-safety`, `migration-compatibility`, `migration-snapshot-drift`, `check-pr-migration-order`) and active runtime migration/legacy-recovery services. - **Brittle static prose/wording grep tests (9 files deleted, 317 LOC):** - Deleted `packages/shared/src/connection-intent-guidance.test.ts`, `packages/shared/src/telemetry/readme-contract.test.ts`, `packages/skills-catalog/src/release-content-cases-contract.test.ts`, `server/src/__tests__/secret-entry-guidance.test.ts`, `server/src/__tests__/primary-agent-guidance.test.ts`, `server/src/services/chat-communication-guidance.test.ts`, `server/src/services/onboarding-greeting.test.ts`, `ui/src/lib/agent-onboarding-prompt.test.ts`, and `ui/src/lib/grok-bot-setup-prompt.test.ts`. - Moved the one genuine schema validation assertion (`updateChatEndpointSchema` `communicationInstructions`) into `packages/shared/src/validators/chat-channels.test.ts`. - Retained `cli-invocation-safety.test.ts` and all real security/auth/prompt-injection guards. - **Non-production Storybook fixture / prototype / feasibility-probe tests (16 files deleted, 1,182 LOC):** - Deleted 10 Storybook fixture/prototype/mock-API tests, 2 unreferenced Storybook audit script tests, and 4 superseded `tests/speko-voice-proof/*.test.mjs` feasibility probe tests. - **Manifest & SDK pin hygiene:** - Pruned the 5 deleted server test keys and reconciled coverage counts in `scripts/general-server-shard-durations.json`. - Synced `tests/runner-e2e/source-sdk-public-inputs.json` via `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --write` (0 files deleted under `tests/runner-e2e/`). ## Verification - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capabilities aligned) - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (588 nightly suites validated) - `pnpm exec vitest run` on retained suites (`chat-channels`, `telemetry`, `skills-catalog`, `check-migration-safety`, `migration-compatibility`, `migration-snapshot-drift`, `runner-api`) — **15/15 files, 2,532/2,532 PASS** - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` and `vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs` — **PASS (13/13)** - `node --test scripts/typecheck-test-programs.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/storybook-catalog.test.mjs` — **103/103 PASS** - Typecheck (`@paperclipai/shared`, `@paperclipai/db` incl. `check:migrations`, `@paperclipai/skills-catalog`, `node scripts/ci-typecheck-lane.mjs --typecheck-ui`) — **PASS (0 errors)** ## Risks - Low risk: zero production code changed, zero core DB migration or auth/security guards removed, and zero dangling references across `maps/`, `scripts/`, `.github/`, or `tsconfig*.json`. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local test execution (`typecheck-opt`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
96eb00e98f |
fix(routines): prefer X-Hub-Signature-256 on app_webhook triggers (#18581)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Routines can start from public webhook triggers > - The `app_webhook` signing mode reads a signature from `X-Hub-Signature` or `X-Hub-Signature-256` > - Some senders, such as GitHub, can send both headers on one delivery > - The code reads `X-Hub-Signature` first, and `verifyAppWebhook` accepts only `sha256=` values > - So a SHA-1 value in `X-Hub-Signature` causes a 401, even when the SHA-256 signature is valid > - This pull request reads `X-Hub-Signature-256` first > - The benefit is that senders that send both headers can use `app_webhook` triggers ## Linked Issues or Issue Description Fixes #18565 Related, not duplicates: #16781, #1892. ## What Changed - `firePublicTrigger` now prefers `X-Hub-Signature-256` over `X-Hub-Signature` in `app_webhook` mode. - Added tests for both headers, each header alone, an invalid SHA-256 header, and a SHA-1 header alone. ## Verification - Codex ran these checks in its cloud sandbox. - Run from `server/`: `../node_modules/.bin/vitest run src/__tests__/routines-service.test.ts` - Result: 85 tests passed, 0 failed, 0 skipped. Embedded Postgres ran. - With the fix reversed, 2 of the 5 new tests failed. With the fix restored, all 5 passed. - The server TypeScript check passed. - The full workspace typecheck did not finish because `cargo` was not installed in the test environment. - The full build and the repository-wide tests were not run. CI must confirm them. ## Risks - Low risk. The change affects only `app_webhook` mode. - Behavior change: a delivery with a valid `sha256=` value in `X-Hub-Signature` and an invalid `X-Hub-Signature-256` value was accepted before. It now gets a 401. - SHA-1 signatures stay rejected. This is an interoperability fix, not a security fix. ## Model Used - Implementation and tests: OpenAI Codex (cloud). The session did not show the exact model ID, context window, or reasoning mode. - Review and pull request text: Anthropic Claude Opus 5.5 (`claude-opus-5-5`), with tool use. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [ ] 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 (targeted suite only, in the Codex sandbox, see Verification) - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes (not needed, the existing docs stay correct) - [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 - [ ] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
ecef06d246 |
fix(agents): reject a blank taskKey on reset-session instead of resetting all task state (#19282)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Operators can reset an agent's runtime session with `POST /agents/:id/runtime-state/reset-session` > - A `taskKey` scopes the reset to one task. No key resets all task state. > - The schema accepted a whitespace-only `taskKey`, and the route changed it to `null` > - So a blank key took the full-reset path, and the activity entry recorded `taskKey: null` > - This pull request makes the schema trim the key and reject a blank key with a 400 > - The benefit is that a scoped reset request can never become a full reset by accident ## Linked Issues or Issue Description Fixes #19080 Refs #19005 (the parent issue that #19080 was split out of) I searched open and closed PRs for `19080`, `reset-session` and `resetAgentSessionSchema`. I found no related PR. ## What Changed - `resetAgentSessionSchema.taskKey` is now `z.string().trim().min(1).optional().nullable()`. A blank or whitespace-only key fails validation with a 400. An omitted key or `null` still requests the full reset. - The route uses the parsed `taskKey` directly. The schema already trims it, so the route no longer has its own trim-and-null step. - Added tests in `packages/shared/src/validators/agent.test.ts` for omitted, `null`, trimmed and blank keys. ## Verification - `pnpm exec vitest run packages/shared/src/validators/agent.test.ts`: 16 tests pass. - `pnpm exec vitest run cli/src/__tests__/agent-lifecycle.test.ts`: 4 tests pass. The CLI parses its payload with the same schema. - `pnpm --filter @paperclipai/shared typecheck` passes. - I ran the server `tsc` locally. It reported no errors in `server/src/routes/agents.ts`. My local Windows setup cannot build `@paperclipai/paperclip-runner`, so the full server typecheck depends on CI. ## Risks - Low risk. A client that sends `taskKey: ""` or a whitespace-only key now gets a 400 instead of a full reset. The board UI sends `null` or an issue id, and the CLI omits the key when `--task-key` is not set. Neither caller sends a blank key. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), used through Claude Code with tool use (shell, file editing). It assisted with code reading, the change, tests and this description. I reviewed the change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
dc8cf1e5d0 |
fix(documents): return the new body only after a document update or restore (#21036)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents and board users keep plans and specs as issue documents, and
they change them through the documents API
> - An update (`PUT /api/issues/{id}/documents/{key}`) and a revision
restore return the saved document
> - The service builds that result from the row it read before the
write, so the result also carries the old `latestBody`
> - A client that reads `latestBody` from the response gets the previous
revision's text, next to the new `latestRevisionId` and
`latestRevisionNumber`
> - This pull request removes the stale field from the update and
restore results, so they have the same shape as a document read
> - The benefit is that a write response never shows old text as the
latest text
## Linked Issues or Issue Description
I searched open and closed issues and pull requests for this bug and
found no match. The related work below touches the same service, but not
this bug:
- Refs #18277 (open: locks the document row during upsert and restore;
it does not change the result shape)
- Refs #18171 and #12015 (plugin upsert drops `baseRevisionId`; a
different bug)
**What happened?**
`PUT /api/issues/{id}/documents/{key}` on an existing document returned
200. The response had the new `body`, `latestRevisionId` and
`latestRevisionNumber`. It also had a `latestBody` field with the text
of the previous revision. A `GET` on the same document right after
returned only the new body. A restore (`POST
/api/issues/{id}/documents/{key}/revisions/{revisionId}/restore`) has
the same problem.
**Expected behavior**
The update and restore responses have the same document shape as `GET
/api/issues/{id}/documents/{key}` (the shared `IssueDocument` type).
That type has `body` and no `latestBody`. No field in the response holds
text from an older revision.
**Steps to reproduce**
1. Create an issue document with body `A`.
2. Update it with body `B` and `baseRevisionId` set to the current
revision.
3. Read the response: `body` is `B`, but `latestBody` is `A`.
4. Restore revision 1. The response `latestBody` is `B`, the body before
the restore.
**Paperclip version or commit**
Seen on a current npm release. Reproduced on `master` at
|
||
|
|
0f257fe67f |
fix(recovery): stop re-waking a blocked task whose dependency runs keep failing (#22818)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A blocked task waits on other tasks. When all its blockers are done, Paperclip wakes the assignee. A periodic backstop does this when the normal event is missed. > - The backstop deduplicates wakes with a key that includes the blocked cycle (`blockedTransitionAt`). > - A woken run that fails can leave the task blocked again. That starts a new cycle, so the next sweep sees a new key and wakes the task again. > - When the failure is deterministic, this never stops. One hosted task ran more than 11,000 failed runs in five days, about one every 20 seconds. > - This pull request adds a circuit breaker to the backstop: after each failed attempt, the next dependency wake waits longer (1m, 5m, 25m, ... up to 24h). > - The benefit is that a setup failure can no longer become thousands of automatic runs. ## Linked Issues or Issue Description **What happened?** A blocked task had all blockers done. The issue graph liveness backstop woke its agent with `issue_blockers_resolved`. Each run failed in setup (`durable_prp_canonical_json_too_large`). The task returned to `blocked` with a new `blockedTransitionAt`. The backstop then emitted another wake with a new idempotency key. The activity log of the task had 11,215 `issue.blockers_resolved_wake_emitted` rows, each with a different key, and 11,621 failed runs. **Expected behavior** A wake that did not help is not repeated without limit. Paperclip waits longer after each failure, and then probes again. A newer blocker result, an edit of the blocker set, or a run that does not fail starts a fresh attempt. **Steps to reproduce** 1. Create a blocked task with one done blocker and an agent assignee. 2. Record three `issue_blockers_resolved` wakes for the task, each with a failed run and a different blocked-cycle key. 3. Run `reconcileResolvedDependencyWakes()`. 4. Before this change, the backstop emits a fourth wake. Refs #22705, #22707 (the underlying setup size failure and its retry classification). Those changes stop scheduled retries for that one error. The backstop loop is a separate path and accepts any failure class, so it needs its own breaker. ## What Changed - New `server/src/services/recovery/dependency-wake-circuit-breaker.ts`. It reads this agent's terminal runs on the task (any wake reason), newest first. It reads runs through `heartbeat_runs.issue_id` (indexed). It counts consecutive `failed` or `timed_out` runs that finished after the latest blocker change: blocker completion, succeeded workspace finalize, an added blocker relation, or an `issue.blockers_updated` edit. Each run counts once. A run that did not fail ends the streak. `interrupted` runs (restart, deploy) are neutral. - The wait before the next dependency wake is 1 minute after one failure, then multiplied by 5 per failure, capped at 24 hours. After the wait, one wake probes again, so a fix that ships later is picked up. - `reconcileResolvedDependencyWakeBackstop` calls the breaker before it enqueues a wake. A skipped wake reports its retry time through `onDeferredDeadline`. New counter: `failedWakeBackoffSkipped`. When a task has three or more consecutive failures, the sweep logs one warning with the task ids. - Tests: backstop regressions (production shape, backoff elapsed, reset by a later successful run, reset by a newer blocker result, reset by a blocker-set edit) and unit tests for the policy (duplicate receipts, interrupted runs, capped probe). ## Verification - `cd server && npx vitest run src/__tests__/heartbeat-issue-liveness-escalation.test.ts src/services/recovery/dependency-wake-circuit-breaker.test.ts src/services/workspace-recovery-dependency-finalize.test.ts src/__tests__/issue-blocker-stall-wakeups.test.ts`: all pass. - Red/green: with the backstop hook reverted, the production-shape test fails (`expected 1 to be 0`: the backstop wakes the task again). With the hook, it passes. - Existing backstop tests (self-blocked, same-cycle dedup, blocker completion) still pass. ## Risks - A task whose dependency runs keep failing is woken less often, at most once a day after about six failures. The failed run still shows its own error and action. Before this change the same task ran without limit. - The breaker adds one run read per candidate that passes all earlier checks (four small aggregate reads more only when a recent run failed). It does not run for tasks that are not ready or already have a wake. - No schema change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, browser, file edits). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
137bd29531 |
fix(heartbeat): a provider usage-limit hold applies only to the account that reported it (#22800)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents run on an AI connection: a connected provider account (a
connection grant), or the host's own account
> - When a provider reports an exhausted allowance, Paperclip holds new
work for that agent until the reported reset (`provider_limit_wait`),
and schedules one recheck at the reset
> - The hold was keyed by agent only. After a user connected a
different, working account and the agent moved to it, every new run was
still cancelled with the old account's reset time. A reply on the task
did not recheck the wait. Only a manual "Check now" got work moving
> - A usage limit belongs to the account that reported it. When that
account is gone or replaced, the hold must be gone too, and waiting work
must start without manual repair
> - The banner's "Check now" button also failed here. It answered 409
"Issue has no scheduled monitor", because the button calls the
issue-monitor route and this task has a scheduled retry, not a monitor
> - This pull request scopes the hold to the credential, releases
waiting work when the account changes or is revoked, makes a reply
recheck the wait, and makes "Check now" recheck a waiting retry
> - The benefit is that fixing the account fixes the task. The same
account stays held, so an exhausted account is not called again
## Linked Issues or Issue Description
No public issue exists. Bug report:
**What happened?**
An agent's connected provider account ran out of quota, with a reset
about six days away. Paperclip held the agent's work ("Pool exhausted",
runs cancelled with `provider_limit_wait`, one recheck scheduled 24
hours later). The user then connected a different, paid account. The old
account became revoked, and the agent was moved to the new account. The
agent's connection test passed. But every new run was still cancelled at
once with the old account's reset time. A new comment on the task did
not start a run, although the composer said "Sending a reply wakes the
agent now". The task stayed in `todo`. Pressing "Check now" on the "Pool
exhausted" banner did nothing: `POST /issues/:id/monitor/check-now`
answered 409, because the task has no issue monitor
(`triggerIssueMonitor` throws "Issue has no scheduled monitor").
**Expected behavior**
A limit reported on account A must not hold a run that uses account B.
When account A is revoked, removed or replaced on the agent, the hold
stops. Work that waited on it starts promptly. While the agent still
uses account A, the hold stays, with the plain message. A reply does
what the composer says.
**Steps to reproduce**
1. Bind an agent to connected account A.
2. Let a run fail with `quota_exhausted` and a reported reset days away.
The next wake is cancelled with `provider_limit_wait`, and a recheck is
scheduled about 24 hours later.
3. Connect account B and move the agent to it, or revoke account A.
4. Wake the agent on the task, or reply on the task. Before this change,
the run is cancelled with `provider_limit_wait` again, and the reply
does not recheck.
## What Changed
- `server/src/services/native-runtime/native-startup-retry.ts`: limit
evidence now comes only from runs on the checked credential. A run
records its grant in `contextSnapshot.aiConnection.grantId`. A run with
no recorded grant used the host's own account. Evidence from a revoked,
expired or removed grant never applies. A later success on another
account no longer clears this account's limit. New helpers resolve the
credential of an agent's next run from its saved binding
(`shared`/`delegated`: the bound grant; `responsible_user`: that user's
default grants for the provider).
- `server/src/services/heartbeat/provider-limit-wait.ts`: the
pre-dispatch hold checks the agent's current credential, and records the
limited grant on `providerLimitWait.grantId`. New
`releaseProviderLimitWaits` makes waiting usage-limit retries due now,
notifies retry dispatch in the same transaction, and logs
`issue.scheduled_retry_retry_now` activity with `source:
provider_limit_recheck`. The recheck goes through normal dispatch. It
reads saved evidence only, so a still-limited account is held again with
no provider work.
- `server/src/services/agent-configuration.ts`: a change to an agent's
`runtimeConfig.aiConnection` releases that agent's waits, in the same
transaction as the change.
- `server/src/services/tool-access/connections/grants.ts` and
`removal.ts`: revoking or removing an account releases the waits whose
limit was reported on it (after commit, best effort; the evidence rule
alone already stops the hold).
- `server/src/services/heartbeat/queue.ts`: a user's wake that is folded
into a usage wait (comment or other user wake) rechecks it at once.
Agent and system wakes keep the scheduled time, so they cannot loop.
- `server/src/routes/issues.ts`: `POST /issues/:id/monitor/check-now` on
a task with no monitor and a waiting scheduled retry now starts that
retry (the same path as "retry now"). The retry rechecks availability
before any work. It logs `issue.scheduled_retry_retry_now` with `source:
monitor_check_now`. If the check cannot start, the 409 has a plain
reason. Tasks with a monitor keep the old behavior.
- `ui/src/components/IssueMonitorBanner.tsx`: for a usage wait, the
composer now says "Sending a reply checks usage again now. The agent
starts as soon as usage is available." The banner says work also resumes
when the agent uses a different account.
- Upgrade safety: holds are derived from saved run evidence, so old
holds resolve by the new rule after deploy. A wait saved before this
change has no `grantId`; the release finds its account from the run that
reported the limit (`providerLimitWait.sourceRunId`).
- `queue.ts` was already far above 1,000 lines. This change adds one
small helper beside the two coalescing paths that need it, rather than a
new module for one call.
## Verification
- Red first: the new tests ran against the `origin/master` sources and 6
of them failed (hold on account A blocked a run on account B; revoked
account still held; rebind and reply did not release the 24-hour retry;
old-shape release missing). The shared-account test passed on master
too, as intended: it guards that the hold stays.
- Check now: a route test covers a `todo` task with no monitor and a
waiting retry (200, the retry starts, the monitor path is not called,
activity is logged) and a refused check (409 with a plain reason). An
integration test covers the exact saved state: `todo` task, cancelled
`provider_limit_wait` run, `scheduled_retry` successor, agent already
moved to another account. "Check now" starts the retry, and it is not
held again.
- Green: `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/heartbeat-provider-limit-wait.test.ts
src/services/native-runtime/native-provider-limit-cooldown.integration.test.ts
src/services/native-runtime/native-startup-retry.integration.test.ts`
passes (58 tests), and
`src/__tests__/issue-execution-policy-routes.test.ts`.
- UI: `ui/src/components/IssueMonitorBanner.test.tsx` passes (2 tests).
- `npx tsc --noEmit -p server` passes.
- `pnpm verify` exited 2 ("broader verification required"; its graph
worker was killed under machine load). I ran the focused checks above
and rely on required CI for broad coverage.
- New tests cover: same account still held with the plain message; agent
moved to another connected account starts; revoked account stops
holding; rebind releases the pending retry and logs activity; a wait
saved in the old shape is released when its account is revoked, and not
when another account is revoked; two agents on one account both stay
held when one agent moves away; a user reply rechecks at once and holds
again (keeping the reply) while the account is still limited, and an
agent's comment does not.
- Not run live: I did not reproduce this on a running instance. I read
the evidence from a local instance where the bug happened, and I did not
change that instance. Live confirmation of the release after deploy is
still to do.
## Risks
- Behavior change: a limit no longer carries over to a different
account. If two accounts share one provider-side quota, the agent can
make one call on the new account before that account gets its own hold.
- A `responsible_user` agent whose user has no saved default cannot
resolve its account before the run. In that case only the revoked-grant
rule applies, as before.
- A user reply on a still-limited account makes one cancelled recheck
run and a new scheduled wait. This is cheap (no workspace or provider
work) and is bounded by the number of user replies.
- No schema change and no new background worker.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, agentic coding 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
- [ ] 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>
|
||
|
|
4401962e69 |
feat(google-workspace): run the six launch services on Google's MCP servers again (#22815)
Gmail, Drive, Docs, Sheets, Slides and Calendar go back to google_mcp because of Google's Workspace AI Tools Addendum; the REST tool set stays as the fallback. The REST argument checks that need no request to Google run before each MCP call, a Calendar delete reads the event first and refuses a recurring series, and a refresh that replaces saved REST definitions holds nothing for review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
71ff1c8600 |
fix(runner): read an assigned skill by its short name (#22813)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use saved company skills; on the native runner they read a
skill's files with `read_assigned_skill`
> - The daily QA staging smoke test `saved-skill-use` has been failing:
the agent finishes the task, but no skill read is recorded
> - The private run events show why: the agent called
`read_assigned_skill` with the skill's short name (`qa-saved-skill-…`),
the name the task gives it (`/qa-saved-skill-…`) and the skill's own
frontmatter `name`. The runner matches only the full company key
(`company/<id>/qa-saved-skill-…`) or the runtime name
(`qa-saved-skill-…--<hash>`), so it answered `runner_skill_not_assigned`
for a skill that was assigned. The agent then read the file with bash
> - This pull request lets the runner find an assigned skill by its
short name too
> - The benefit is that agents read saved skills through the verified,
pinned path the first time, instead of falling back to the filesystem
## Linked Issues or Issue Description
**Subsystem affected**
Native runner bridge tools (`read_assigned_skill`).
**Problem or motivation**
In the November 24 QA staging smoke run, `saved-skill-use` failed. Run
events (private QA evidence) show `read_assigned_skill` with
`{"skill":"qa-saved-skill-journey-…","path":"SKILL.md"}` returning
`{"outcome":"failed","code":"runner_skill_not_assigned"}`, followed by a
`bash` read of the same SKILL.md. The skill was in the agent's desired
skills and on disk.
**Proposed solution**
After the exact key/runtime-name match, accept the key's last part (with
or without a leading `/`) when exactly one assigned skill has it.
**Alternatives considered**
- Changing the task text or the test to pass the runtime name: the agent
is told `/short-name`; the product should accept what it tells agents.
- Matching the frontmatter `name`: the short name is already the key's
last part for company skills, and needs no file read before the lookup.
## What Changed
- `server/src/services/native-runtime/runner-bridge-tools.ts`:
`assignedSkillByName` finds an assigned skill by key, runtime name, or
unique short name; `readAssignedSkill` uses it.
- `server/src/services/native-runtime/runner-bridge-tools.test.ts`: the
short name (and `/short-name`) reads the skill; a short name two
assigned skills share names neither; the runtime name still
disambiguates.
## Verification
- `runner-bridge-tools.test.ts`: the new cases fail on master with
`runner_skill_not_assigned` and pass with the fix (red/green); 11
passed.
- Not run locally: server typecheck (this worktree's local
`paperclip-runner` build is stale; unrelated errors in other files). CI
typechecks the change.
- After deploy: the next QA staging smoke run's `saved-skill-use` should
record a native skill read.
## Risks
- Low. Lookup only widens to a unique short name among skills already
assigned to this run; it grants no access to unassigned skills, and
every file read keeps its manifest and digest checks.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, AWS CLI read of the private QA evidence, file edits).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
84e39b7096 |
fix(plugins): give agents the installed plugin's current connector tool schema (#22811)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Plugins can provide connectors; a connection saves each tool's
definition from the plugin manifest when it is connected
> - The gateway advertised those saved definitions to agents, and its
freshness check only compared tool name and risk
> - So a plugin upgrade that changed a tool's input schema never reached
existing connections until someone refreshed the catalog by hand
> - This pull request treats a plugin connection's static tools as
Paperclip-defined, so the gateway reads their schema from the installed
plugin
> - The benefit is that plugin upgrades reach every existing connection
at once, with no manual step
## Linked Issues or Issue Description
**What happened?**
An upgraded connector plugin added a `count` operation and `order` and
`view` inputs to one tool. On a stack that had connected before the
upgrade, the agent's tool still rejected `count` ("must be one of the
allowed values") and `order` ("must NOT have additional properties"),
even though the installed manifest declared them. A manual catalog
refresh fixed that one connection.
**Expected behavior**
After a plugin upgrade, agents see the installed plugin's current tool
definitions on every existing connection.
**Steps to reproduce**
1. Install a connector plugin and connect it for an agent.
2. Upgrade the plugin so a tool's `parametersSchema` gains a property.
3. List the agent's session tools: the old schema is still advertised.
## What Changed
- `server/src/services/plugin-connector-runtime.ts`:
`pluginConnectionToolDefinition` returns the installed manifest's
definition of one static tool, built with the same descriptor the
catalog uses.
- `server/src/services/connectors/paperclip-defined-tools.ts`: the
Paperclip-defined tool registry now also covers plugin connections with
a static tool list, and its definition callback receives the connection.
- `server/src/__tests__/plugin-connector-tool-definitions.test.ts`: an
upgrade that adds an input is visible in the agent's session without a
catalog refresh.
## Verification
- New test passes; without the registry change it fails with `expected {
type: 'object' } to match object { properties: { order: ... } }`.
- `npx vitest run src/__tests__/plugin-connector-*.test.ts
src/__tests__/plugin-connectors-*.test.ts` plus catalog publication
tests: 42 passed, 1 skipped.
## Risks
- Low. Only plugin connections with a static tool list change. Dynamic
plugin catalogs and other connectors are unchanged. Catalog publication
already treats Paperclip-defined tools as trusted, so a plugin's own
updated definitions are not held for review.
## 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>
|
||
|
|
496efd201f |
fix(native-runtime): recover external-chat task replies skipped by copy-back failure (#22807)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A native agent run ends with an accepted final reply. Paperclip posts that reply on the task. > - The live completion path posts the reply. If a post-result step fails (for example, workspace copy-back), a background presentation worker recovers and posts the accepted reply later. > - The recovery path did not accept a task whose run was woken by an external chat message, such as a GitHub review comment. The worker found the run, recovery refused it, and after 6 attempts the reply was marked failed and lost. > - The live path posts these replies normally, so the recovery rule was stricter than the live rule for no reason. > - This pull request lets recovery post a `done` or `needs_review` reply for a non-conversation task that an external chat woke, with the same authorization and source rules as the live path. > - The benefit is that the agent's real answer reaches the task even when copy-back fails after the result is accepted. ## Linked Issues or Issue Description Refs #22798 **What happened?** On a hosted instance, some native runs finished `succeeded` with a committed result, but their final reply never appeared on the task. The run's `responsePublication` ended with `state: "failed"` and `lastReason: "publication_refused"` after 6 attempts. Every affected run had `source: "chat:github"`, a `done` result, and a `native.post_result_failure` event with `retryReasonCode: "workspace_sync_out_failed"`. Runs on the same task that did not hit the copy-back failure posted their reply on the live path. **Expected behavior** When the live path is skipped after the result is accepted, recovery posts the accepted final reply once, as the live path would. **Steps to reproduce** 1. Wake a native agent on an ordinary (non-conversation) task from an external chat message, so the run context has `source: "chat:..."`. 2. Let the agent report `done` with a final agent message. 3. Make workspace copy-back fail after the result is accepted, so the live completion path does not post the reply. 4. The presentation worker finds the run, but `recoverCommittedNativeChatResponse` returns `false`. The worker records `publication_refused` until it gives up. **Additional context** In `recoverCommittedNativeChatResponseInScope`, `ordinaryTaskReply` required `!isExternalChatPresentationContext(...)`. An external-chat `done` reply then fell through to the `response_wake` branch, which returns `false` for anything other than `yielded`. The candidate query in `native-response-presentation-query.ts` has no such exclusion, so the worker kept selecting a run that recovery always refused. ## What Changed - `native-run-finalizer.ts`: recovery now treats a `done` or `needs_review` reply on a non-conversation task that an external chat woke as an ordinary task reply. - That reply uses the authorization that `resolveChatRunPresentationAuthorizationReason` resolves, as the live path does. GitHub-origin replies resolve to `internal_agent_write`, so they stay a local task comment. Other chat providers keep their normal provider-visible reply. - That reply prefers the final agent message over an existing run comment, as the live path does for external chat (`preferFinalResponseOverExistingComment`). - Conversation tasks keep their current rules. Blocked replies, governed review replies, and `response_wake` replies are unchanged. - `agent-chat-response-recovery.test.ts`: new red/green regression cases for `chat:github` + `done`, `chat:github` + `needs_review`, and `externalChatContinuation: true` + `done`. Each case checks that the reply posts once, the run records `committed_task_response_recovered`, and a second recovery does not post again. ## Verification - Red: before the fix, all 3 new cases failed. `work.check` returned a retry entry (the `publication_refused` path), the same outcome as on the hosted instance. - Green: `npx vitest run src/services/native-runtime/agent-chat-response-recovery.test.ts` passes 67/67. - `npx tsc --noEmit -p server` is clean. - `pnpm verify` selected 2374 of 2737 test files (the finalizer is widely imported) and did not finish in 25 minutes locally. The 2 failures it reached are unrelated load-timing tests. Required CI supplies the broad coverage. - After deploy: confirm on staging that a new external-chat task run with a copy-back failure posts its reply, and that no new `issue.response_publication_failed` activity appears for this pattern. ## Risks - Low risk. The change only widens recovery for non-conversation tasks woken by external chat, and only for `done` and `needs_review` replies that the candidate query already selects. - For a non-GitHub chat provider, the recovered reply goes to the provider, as it does on the live path. Recovery runs only when the run has no recorded presentation decision or comment, so it does not post a second reply. - Runs that already ended as `responsePublication.state: "failed"` before this change stay failed. This change does not backfill them. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with tool use (shell, file edits, browser reads of the staging API). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
94510d7b26 |
fix(github): settle request comments after deliberate waits and refused replies (#22798)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull request threads; each request's comment must end in a real reply or an honest final notice > - After #22672 and #22710, 13 of 85 new review-bot comments on staging still ended as status notices, and 10 old placeholders on merged PRs never settled > - Run data on staging shows two causes: runs that yield on purpose to wait for a response (`external_chat_response_waiting`), and runs whose final reply was refused (`responsePublication.state = failed`) > - The first marked inline threads "ended without publishing" while a later run posted the review; the second looked like presentation still pending, forever > - This pull request makes both settle: link the latest response, wait while the task is open, and use the honest notice only when nothing was published > - The benefit is that every request comment ends in a useful final state ## Linked Issues or Issue Description Refs #22672, #22710 **Describe the bug** - On #22732 the author replied on five review threads at once. Each reply woke its own run; those runs yielded with `external_chat_response_waiting`, and a later run posted the review. Four threads still ended with "This turn ended without publishing a final response." - On #22658 (and the other merged PRs with stuck "Working on this…"), the request's run finished `succeeded`/`committed` with no presentation decision because its final reply publication failed after 6 attempts (`publication_refused`). The settle logic treated that as presentation pending and never settled the thread. **Steps to reproduce** 1. An inline request's run yields with a response-wake continuation; a later run publishes a review. 2. Or: an inline request's run finishes with `responsePublication.state = "failed"` and no presentation decision. 3. The thread says "ended without publishing" (1) or stays "Working on this…" forever (2). **Expected behavior** The thread links the latest published response, waits while the task is still open, and otherwise ends with an honest notice. ## What Changed - `githubLatestTaskResponseUrl`: the latest processed GitHub publication (comment, formal review, assessment) for the task after the request arrived. - `githubResponseExecution`: when the request's run did not reply, link that latest response if any. An inline request whose run deliberately waits keeps waiting while the task is open. A run whose reply was refused says so. The main PR comment keeps its passive-wait cancellation (`mainPullResponse`). - `nativePresentationPending` is false when `responsePublication.state = failed`; new `responsePublicationFailed` column. - Terminal sweep decision version is now `v3`, so requests parked under v2 are read again once. ## Verification - New integration tests (red on master, green here): links a waited thread to a later response; settles a waited thread when the task finishes with no response; settles a thread whose run's reply could not be published. - Updated `keeps per-request fallback outside the main GitHub PR review wait`: waits while the task is open, then settles when done. - `keeps native presentation idle until its committed GitHub outcome` (main PR passive) still passes. - `server/src/services/chat-channels/github/` and response comment tests: 67 passed. GitHub integration group: 538 passed before the main-PR scoping fix; the two affected tests pass after it. - After deploy: re-measure the stuck rate on staging for comments created after the deploy. ## Risks - One extra indexed query per request that settles without its own reply (to find the latest response). Settled requests leave the backlog. - A waited inline thread stays "Working on this…" while its task is open and nothing was published yet; that is the honest state. - Separate, not fixed here: why the native finalizer refuses some final replies (`publication_refused`). ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7a9f099cc4 |
fix(maintenance): report an owner's exact offline migration refusal (#22801)
## Thinking Path
- Paperclip Cloud moves a hosted instance off its volume with an offline
maintenance process (`server/src/maintenance/ephemeral-migration*.ts`).
Each data owner either migrates its records or refuses with a fixed
code; the maintenance receipt reports that code to the Cloud enrollment
driver, which rolls back and records it.
- The workspace owner refuses as
`remote_workspace_migration_blocked:<reason,reason>` (for example
`...:workspace_recovery_unresolved` or
`...:archived_git_source_unavailable,local_source_unsafe_or_missing`).
- The receipt only accepted bare `[a-z_]` codes, so every workspace
refusal collapsed to `owner_migration_failed`, and the process logged
nothing. Two hosted enrollments rolled back with only
`owner_migration_failed`, leaving the admin unable to see which owner
refused or why.
- This change lets the owner's fixed reason list through (still
lowercase codes only, never free text) and logs the blocked phase and
code so the deployment log carries it too.
## Linked Issues or Issue Description
No existing issue; described in-PR per the bug report template. Related:
paperclipai/paperclip-cloud#1777 (Cloud side of the same fix).
### What happened?
Offline (maintenance) enrollment of two hosted instances rolled back.
The recorded reason was only `failure: "owner_migration_failed"` (Cloud
showed `phase: "unreported"`), and the maintenance deployment log
contained no refusal at all.
### Expected behavior
The receipt and the deployment log name the refusing owner and its fixed
reason codes, e.g.
`remote_workspace_migration_blocked:workspace_recovery_unresolved`.
### Steps to reproduce
Start `startEphemeralMigrationService` with a `migrate` that throws
`remote_workspace_migration_blocked:archived_git_source_unavailable,local_source_unsafe_or_missing`
(what `reserveMigration` throws for a blocked workspace); `GET /status`
reports `owner_migration_failed` and nothing is logged. The new test in
this PR does exactly this.
### Paperclip version or commit
|
||
|
|
cffd17e78a |
perf(ci): Phase 3 PR CI under 3m — 4x Runner support, 12x E2E, incremental TS 7 cache, pure-Node postinstall, and rebalanced shards (#22804)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI verifies every change before merge across build, typecheck, server tests, Runner tests, and Playwright E2E shards. > - After Phase 1 (#22679) and Phase 2 (#22729), full-fanout PR CI still takes 9m45s wall-clock on 4-core AWS runners because of five bottlenecks: an unsharded 7m22s `Runner support suite`, stale server/chat/Runner shard duration manifests plus newly landed SSH/soak whales, 28s of `pnpm -r run postinstall` replay on every job, cold server/UI typecheck and single-build overhead, and 3 oversized (>180s) Playwright E2E specs across 8 shards with double-start Postgres template boot. > - Docs-only prose edits under `doc/**` and `docs/**` also fanned out to 66 CI jobs because only three doc paths bypassed global dependencies. > - This pull request shards `Runner support suite` 4 ways with `pool: "threads"`, shards E2E 12 ways after splitting the 3 oversized specs and removing double-start Postgres boot, adds pure-Node workspace postinstall replay, adds read-only master-warmed incremental TS 7 and Runner dist caches, rebalances all server/chat/Runner duration manifests, demotes 48 new non-invariant soak whales to nightly, and routes audited prose docs without triggering 66-job storms. > - The benefit is driving ordinary PR CI toward under 3 minutes wall-clock while preserving every invariant check, cache boundary, and full master/nightly test coverage. ## Linked Issues or Issue Description Refs #22679 Refs #22729 **What existing behavior does this improve?** Pull request CI wall-clock latency across `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`, `.github/actions/setup-ci-dependencies/action.yml`, typecheck orchestration, Vitest/Runner lanes, and Playwright E2E shards. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Full-fanout PR CI takes 9m45s on 4-core runners (run `45440355579`), dominated by `Runner support suite` (7m22s), `e2e shards` (5m02s–6m24s), `General tests (server/chat)` (5m37s–6m01s), `Verify Paperclip Runner (vitest package)` (6m25s on stale manifests), `Typecheck` (4m13s–6m30s), `Build` (~4m), and 28s of `pnpm -r postinstall` per job. Prose edits under `doc/**` trigger 66 jobs. **Proposed behavior** Shard `Runner support suite` (4x) and `e2e_shards` (12x), split the 3 oversized E2E specs, boot disposable E2E Postgres in a single non-durable start, replay workspace `postinstall` in pure Node (<1s), cache prebuilt Runner dist and TS 7 `.tsbuildinfo` from canonical `master` pushes (read-only in PRs), use emit-only server compile in ordinary PR `Build`, rebalance all shard duration manifests, demote 48 new non-invariant soak whales to nightly, and route audited prose docs cleanly. ## What Changed - **Pure-Node postinstall replay (`scripts/replay-workspace-postinstall.mjs`, `.github/actions/setup-ci-dependencies/action.yml`):** Replaces the 28s `pnpm -r --if-present run postinstall && pnpm run postinstall` call on every CI job with a pure-Node parallel runner (~0.84s locally) with fallback for older checkouts. - **4-way sharded `Runner support suite` + `threads` pool (`.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`, `tests/runner-e2e/run-unit.mjs`, `tests/runner-e2e/vitest.config.ts`):** Shards Vitest and `node:test` suites 4 ways (`--shard-index 0..3 --shard-count 4`) and switches `tests/runner-e2e` to `pool: "threads"` with CPU-aware `maxWorkers` while preserving `isolate: true`. - **12-way E2E shards, single-start E2E Postgres boot, and 3 oversized spec splits (`tests/e2e/start-e2e-server.ts`, `tests/e2e/*.spec.ts`, `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/ci-task-matrix.json`):** Boots cold ephemeral E2E Postgres in one `initdb --no-sync` + non-durable `postgresql.conf` start overlapped with server module import; splits `agent-chat-projects`, `chat-adapters-ui-providers`, and `chat-adapters-ui-messaging` cleanly with zero tests removed; balances all 54 specs across 12 shards (6.8s spread). - **Incremental TS 7 typecheck & Runner dist caching (`server/scripts/typecheck-layers.mjs`, `scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/typecheck-test-projects.mjs`, `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`):** Preserves portable `.tsbuildinfo`/`.d.ts` with `layer-map.json` invalidation and stale-declaration pruning, wires read-only `runner-dist-v1` and `typecheck-incremental-v1` restores in `pr-trusted.yml` (zero `actions/cache/save`) paired with canonical-`master`-only guarded writers in `release-verify.yml`, skips redundant Runner Rust `cargo check` on TS-only shared PRs, and uses LPT scheduling with concurrency 3 (4-core) / 4 (8-core). - **Emit-only PR `Build` & audited prose doc routing (`.github/workflows/pr-trusted.yml`, `.github/scripts/ci-inputs.mjs`):** Passes `PAPERCLIP_TSC_EMIT_ONLY=1` on ordinary PR `Build` jobs (full `pnpm build` on `full-ci` / `master`), and classifies audited prose Markdown under `doc/**` and `docs/**` as `guidance` / `historical` while keeping `docs/api/**`, JSON/TS fixtures, `maps/**`, and unknown files fail-closed. - **Rebalanced shard manifests & new soak demotions (`scripts/ci/nightly-only-suites.json`, `scripts/*-shard-durations.json`, `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `packages/paperclip-runner/vitest.config.ts`, `packages/paperclip-runner/scripts/vitest-sequencer.mjs`):** Demotes 48 newly landed/grown non-invariant soak suites (including 4 real-SSH integration suites) to nightly, refreshes all 4 timing manifests from live CI measurements (0.1s–0.6s LPT skew), and scales Runner package Vitest CI `maxWorkers` to 3 on 4-core / 6 on 8-core. ## Verification - `node --test .github/scripts/tests/*.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/runner-vitest-package-lanes.test.mjs scripts/typecheck-test-programs.test.mjs scripts/check-test-budget.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/test-selection-timings.test.mjs` — **973/973 PASS** - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (`609` nightly suites validated, zero protected invariants demoted) - `node scripts/check-maps.mjs` — **PASS** - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs tests/runner-e2e/unit-launcher.test.mjs` — **PASS** - `pnpm --filter @paperclipai/paperclip-runner exec vitest run scripts/vitest-sequencer.test.mjs` — **PASS** - `cd server && node ../node_modules/vitest/vitest.mjs run scripts/typecheck-layers.test.mjs scripts/typecheck-layers-incremental.test.mjs` — **56/56 PASS** (real TS 7.0.2 incremental soundness tests) - `node scripts/run-tsc.mjs -p tests/e2e/tsconfig.json --noEmit && node scripts/run-tsc.mjs -p tests/tsconfig.playwright.json --noEmit && pnpm run test:e2e:runner:typecheck` — **0 errors** - Live Playwright smoke passed across all 6 split E2E spec files on the cold non-durable Postgres boot path (`PAPERCLIP_TEST_POSTGRES_TEMPLATE=0`). - Live sharded `tests/runner-e2e` runs passed under `pool: "threads", maxWorkers: 4` (shard `1/4` 172/172 PASS; shard `2/4` all Vitest + 65/65 `node:test` PASS). ## Risks - **Cache invalidation on incremental typecheck / Runner dist:** Mitigated by exact-key hashing (including `packages/{shared,adapter-utils,plugins/sdk}/src/**` and `packages/paperclip-runner/spec/**`) with no `restore-keys:` on `runner-dist-v1`, SHA-256 self-validation inside `prepare-runner-vendor.mjs`, `layer-map.json` invalidation + stale `.d.ts` pruning in `typecheck-layers.mjs`, and read-only PR restores (only canonical `master` pushes save caches). - **Shard rebalancing & soak demotions:** All demoted suites remain in `nightly-only-suites.json` and run on `full-ci` / `master` / nightly; `check-test-budget.mjs` enforces zero protected invariants are demoted. - **Workflow security boundaries:** `ci-routing.yml`, `pr.yml`, `CODEOWNERS`, and all `runs-on:` expressions are unchanged; `pr-trusted.yml` performs zero `actions/cache/save` calls. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local code/test execution across 6 parallel worker roles (`ci-pipeline`, `vitest-runner`, `server-prune`, `e2e-opt`, `typecheck-opt`, `verifier`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
3ca9b6d471 |
refactor(plugin-sdk): remove archivedState from the resume result (#22443)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native Runner sessions can run in a remote environment task that a plugin provider owns > - A provider can relaunch a parked Runner as the next run, and it reports the result to Core > - The resume result could carry `archivedState`, so Core could check that the park was a settled cut > - #22442 makes the provider the authority on the park, and Core stops reading `archivedState` > - This pull request removes the field from the SDK result schema > - The benefit is a smaller provider contract with no unused fields ## Linked Issues or Issue Description Refs #22442 **What existing behavior does this improve?** The environment task resume result contract in the plugin SDK. **Subsystem affected** `packages/plugins/sdk` (environment tasks), and the tests in `server/src/services/native-runtime` that build resume results. **Current behavior** After #22442, a resumed relaunch result can carry an optional `archivedState`. Core accepts it and does not read it. **Proposed behavior** The resume result has no `archivedState` field. The strict schema refuses it. **Reason and benefit** The field has no reader. Removing it keeps the contract to the fields that Core uses. **Breaking changes** A provider that still sends `archivedState` on a resume result fails the schema check, and the relaunch fails. Deploy this with or after the provider change that stops sending the field. **Additional context** Stacked on #22442. ## What Changed - SDK: removed `archivedState` from the `resume` result schema, and simplified the relaunch check in `parseEnvironmentTaskResult`. - SDK test: a relaunch result with `archivedState` now fails; one without it passes. - `plugin-runner-task.test.ts`: removed the field from the fixtures, and removed the test that checked Core ignores it. - `plugin-runner-release-resume.integration.test.ts`: the fixture provider no longer returns the field. - `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md`: removed the note about the field. ## Verification - `pnpm run typecheck` in `server` (builds all dependent packages): pass. - `pnpm vitest run src/services/native-runtime/plugin-runner-task.test.ts` in `server`: 116 passed. - `pnpm vitest run tests/environment-task-release-resume.test.ts` in `packages/plugins/sdk`: 48 passed. - I did not run the embedded-Postgres integration suite locally. CI runs it. ## Risks - A provider that still sends the field makes the relaunch fail. Deploy this with or after the provider change that stops sending it. It can ship in the same deploy as #22442. - Low risk otherwise: the change removes an unused optional field. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (shell, file edit, code search). Extended thinking on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0b2acfb956 |
refactor(runner): let the provider decide whether a released Runner relaunches (#22442)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native Runner sessions can run in a remote environment task that a plugin provider owns > - After a turn, the provider can park the Runner, and the next run can relaunch it from the saved state > - Core kept its own local record of each released Runner, and the provider kept its park record too > - Core lost its copy when the local session directory was not durable. Then Core restored from a checkpoint although a park existed, and the turn was slower > - This pull request makes the provider the only authority on the park. Core resumes the source from its durable checkpoint, and the provider answers "resumed" or "unavailable" > - The benefit is fewer missed relaunches, and less code in Core ## Linked Issues or Issue Description **What existing behavior does this improve?** The relaunch of a parked Runner for the next run of a native session. **Subsystem affected** Native runtime: `server/src/services/native-runtime`, the Runner control plane in `packages/paperclip-runner`, and the environment task SDK. **Current behavior** Core writes a released-Runner record (source identity, task id and scope digest) to the local session directory when a release completes. Core relaunches a parked Runner only when that record exists. Core also checks the archived Runner state on the provider's relaunch reply. When the local directory is gone (for example, after the server process restarts on a new host), Core restores from a checkpoint into a fresh task, although the provider still has the park. **Proposed behavior** Core resumes the source identity from its durable controller checkpoint on the lease's current task. The provider decides from its own park record. When no park of that source exists, the provider answers `unavailable`, and Core starts a fresh task from the saved session, as it does today for other unavailable answers. **Reason and benefit** One record for one fact. Core no longer needs local state to relaunch, so more runs relaunch. The change removes about 160 lines. **Breaking changes** A provider must answer `unavailable` when it has no park for the requested source. A provider that answers with an error instead makes the resume fail. The `archivedState` field on a resumed relaunch result becomes optional. Providers can continue to send it; Core does not read it. **Additional context** Reattach to a live Runner process in the same server is not changed. A relaunch after a restart still requires the process configuration to match, because the relaunch reuses the parked launch. A changed configuration starts a fresh task. ## What Changed - Removed the local released-Runner record: its writer, its readers, the scope digest, and the resume and retire callbacks that cleared it. - Derived the relaunch source from the durable Runner identity. Kept the check that the task is the lease's current task. - After a restart, Core takes the released source from the durable identity for every provider that releases tasks: one that relaunches the parked Runner, and one that hands it over. - Added a test that a checkpoint saved with the old released-Runner record still loads. - When a restart recovery resumes a released source and the provider answers `unavailable` with the task stopped and its state saved, Core now starts a fresh task from the saved session, as it does for a relaunch. The fallback finishes the old task's startup context before it inspects the replacement task. An executor test covers this path. - Updated the SDK source pin in `tests/runner-e2e/source-sdk-public-inputs.json`. - Stopped the check of the archived state on the relaunch reply. Removed `isSettledReleasedRunnerCut` and the resume `settled` hook. - SDK: a resumed relaunch result no longer requires `archivedState`. - Updated `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and the tests. ## Verification - `pnpm run typecheck` in `server` (builds all dependent packages): pass. - `pnpm vitest run src/services/native-runtime/plugin-runner-task.test.ts src/services/native-runtime/remote-warm-session-recovery.test.ts` in `server`: 147 passed. - `pnpm vitest run src/services/native-runtime/native-session-executor.test.ts -t "releases settled|accepts only the attached|released|relaunch|warm|unavailable|recover"` in `server`: 594 passed. - `runnerd-codex-transport.test.ts` in `packages/paperclip-runner`: 337 passed. - SDK release and resume tests in `packages/plugins/sdk`: 48 passed. - `runnerd-codex-transport-release-resume.test.ts -t relaunched` in `packages/paperclip-runner`: 3 passed. `pnpm run typecheck` in `packages/paperclip-runner`: pass. - `tests/runner-e2e/source-sdk-public-inputs.test.mjs`: 13 passed. - `plugin-runner-release-resume.integration.test.ts -t "completes claude runs through a retained adopted process"`: pass. I did not run the rest of the two embedded-Postgres integration suites locally. CI runs them. ## Risks - A provider that does not answer `unavailable` for a missing park makes the resume fail. Deploy the provider change first, or in the same deploy before this Core version takes traffic. This PR and #22443 are one stack and can ship in one deploy. - A server restart now relies on the existing unavailable-reuse fallback to start a fresh task. Tests cover this path. - Medium risk overall: the change is in the warm-session path. The cold path is not changed. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (shell, file edit, code search). Extended thinking on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8b616b949d |
fix(connections): drop MCP wording and the MCP guide link from Google Workspace setup (#22793)
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents use Google Workspace through the built-in Google Workspace connection > - Since #22634, Gmail, Drive, Docs, Sheets, Slides, and Calendar run on Paperclip's own REST tools, not on Google's hosted MCP servers > - The connect screen still showed "Secure MCP sign-in" and a "Review requirements" link to Google's MCP servers guide > - This text is wrong for this connection, it is internal jargon, and Google's OAuth reviewers read this screen > - This pull request removes the MCP wording and the MCP guide link from Google Workspace setup and from its audit details > - The benefit is that users and reviewers see only true, plain text for this connection ## Linked Issues or Issue Description Refs #22634 **What happened?** On a Cloud workspace, the Google Workspace connect page showed the subtitle "Secure MCP sign-in" while the sign-in opened and after it failed to open. The setup page also showed a "Review requirements" link to `developers.google.com/workspace/guides/configure-mcp-servers`. On a self-hosted instance, the "How to set up a Google OAuth client" link went to the same MCP servers guide. Audit details for a Google REST call showed "Transport: mcp_remote" and "MCP method: tools/call". **What did you expect to happen?** The connect page says "Secure sign-in". The Paperclip-managed method on Cloud has no requirements link, because the user has no requirements to review. On a self-hosted instance, the customer-owned client method links to Google's OAuth client guide. Audit details for a Google REST call do not show MCP terms. **Steps to reproduce** 1. Turn on the Google Workspace connector in **Settings → Experimental**. 2. Open **Apps** and choose **Google Workspace**. 3. Start the sign-in, then close or block the sign-in window. 4. Before this change: the header shows "Secure MCP sign-in", and the setup step shows "Review requirements" with a link to Google's MCP servers guide. ## What Changed - `ui/src/features/connections/ConnectionSetupFlow.tsx`: `OAuthConnectStateScreen` shows "Secure sign-in" for a curated app. A server that the user pasted as an MCP server keeps "Secure MCP sign-in". This is generic: there is no Google-specific code. - `packages/shared/src/app-definitions/google-workspace.json`: remove the top-level `docsUrl` (the MCP servers guide). The Paperclip-managed method now has no "Review requirements" link. The customer-owned method's `consoleLinks.docs` is now Google's OAuth client guide (`create-credentials#oauth-client-id`). The "Review requirements" link and the self-hosted "How to set up a Google OAuth client" link both use it. Its guidance text names the Gmail, Drive, Docs, Sheets, Slides, and Calendar APIs instead of "the Google Workspace MCP APIs". This file is a reviewed definition: `scripts/ingest-app-definitions.mjs` copies it as-is, so a regeneration keeps the fix. - `server/src/services/tool-gateway.ts`: an audit record for a Google Workspace REST call no longer has `mcpMethod`. - `ui/src/pages/tools/AuditTab.tsx`: audit details show the connection type label ("Remote HTTP") as "Type" instead of the raw `mcp_remote` value. This uses the same label as the connection's "Connection details". - `doc/connections/GOOGLE-WORKSPACE.md`: the self-hosted section links Google's OAuth client guide. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed pinned inputs. ## Verification - Red first, then green: - `packages/shared/src/google-workspace-setup-links.test.ts`: no Google Workspace method links the MCP servers guide, the managed method has no requirements link, the customer method links the OAuth client guide, and method text has no "MCP". It failed 4/4 before the fix. - `ui/src/features/connections/OAuthConnectStateScreen.google.test.tsx`: in the preparing, opening, and "couldn't open the sign-in window" states, the Google Workspace screen shows "Secure sign-in", no "MCP", and no link to `configure-mcp-servers`. A pasted server keeps "Secure MCP sign-in". It failed 3/4 before the fix. - `server/src/__tests__/google-workspace-rest-transport.test.ts`: the Gmail REST audit record has no `mcpMethod`. It failed without the server change. - `npx vitest run` for shared app definition tests (67 passed), `ui/src/pages/tools` and `ui/src/pages/apps/app-detail` (121 passed), and the server REST transport file (53 passed). - `tsc --noEmit` for `server` and `ui`: no new errors. - `pnpm verify` exits 2 because a doc under `doc/connections` is a global CI input. Required CI supplies the broad coverage. ## Risks - Low risk. Text and link changes only, plus one optional audit field. - Other curated OAuth apps now show "Secure sign-in" instead of "Secure MCP sign-in" on the sign-in state screen. The new text is true for every curated app. - Audit details for all connectors show "Type: Remote HTTP" instead of "Transport: mcp_remote". - Saved Google Workspace connections still show `https://workspacemcp.googleapis.com/mcp/v1` as the address in "Connection details". It is the stored connection identity. This pull request does not change stored data. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Claude Code agent with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4daeab5c76 |
Add count, newest-first and lean run reads to customer-success inspection (#22781)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip Cloud can inspect a tenant stack read-only through the
customer-success inspection API
> - That API can only list rows in id order. It has no totals, and each
run row holds large JSON columns
> - A customer-success agent must page every run of a stack to find the
latest run or the failed-run total
> - That is too slow and too large for a refresh across many stacks
> - This pull request adds a `count` operation, a creation-time `order`
for lists, and a lean `summary` view for runs
> - The benefit is one small read per metric, with the same read-only,
company-scoped rules
## Linked Issues or Issue Description
**Subsystem affected**
Server: the customer-success inspection API (`/api/customer-success/v1`)
and its shared query contract.
**Problem or motivation**
Customer-success inspection reads cannot answer summary questions. To
get the latest run, the run count or the failed-run count, a reader must
page through every run. Each run row can be hundreds of KB, because it
holds the result, usage, context snapshot and runner profile.
**Proposed solution**
Add read-only summary reads to the inspection contract: a `count` that
groups by status, a newest-first or oldest-first `order` for `list`, and
a `summary` view of runs without the large JSON columns.
**Alternatives considered**
Paging all runs with a smaller page size. That still reads every large
row. A new aggregated endpoint outside the reader catalog. That would
skip the existing catalog, permit and transaction rules.
## What Changed
- `packages/shared/src/customer-success.ts`: add the `count` operation,
`order` (`newest`/`oldest`, `list` only), `view` (`summary`, `runs`
list/get only), `InspectionCount`, and `inspectionReadPath()`. The
parser rejects these fields where they do not apply.
- `server/src/services/customer-success-inspection.ts`: `count` returns
`{total, byStatus}` (grouped by the reader's `status` column, or
`byStatus: null`). `order` sorts by `createdAt`, then id. `view:
"summary"` selects the `RUN_SUMMARY_COLUMNS` allowlist and adds
`durationMs`. All reads stay in the same read-only, repeatable-read
transaction and keep the existing run redaction.
- `server/src/routes/customer-success.ts`: serve the same handler on
`/read` and the new `/read-v2`. `/read` refuses queries that use the new
features. A tenant without `/read-v2` answers 404, so Cloud fails closed
with `tenant_inspection_version_unsupported`.
- `server/src/__tests__/customer-success.test.ts`: tests for counts,
company scope, newest-first paging, the summary allowlist and duration,
parser bounds, and the path split.
- `server/src/__tests__/customer-success-cloud.test.ts`: the registry
double now has the batch reads (`getStacks`, `getAccounts`) that the
current Cloud broker uses. The test also runs a count and a newest-first
summary read end to end.
- `server/src/__tests__/openapi-routes.test.ts`: list `/read-v2` with
the other inspection protocol routes.
- `doc/CUSTOMER-SUCCESS-INSPECTION.md`: document the summary reads and
the path split.
## Verification
- `cd server && pnpm exec vitest run
src/__tests__/customer-success.test.ts
src/__tests__/openapi-routes.test.ts
src/__tests__/customer-success-run-liveness.test.ts`: 78 tests pass.
- Red check: the new count/order/summary test fails against the previous
service (`Unsupported inspection operation`).
- Coordinated qualification with a local build of the Cloud broker
branch: `PAPERCLIP_INSPECTION_CLOUD_DIST=… pnpm exec vitest run
src/__tests__/customer-success-cloud.test.ts` passes, including the
count and newest-first summary reads over `/read-v2`.
## Risks
- Low risk. The new features are read-only and use the existing catalog,
company boundary, permit check and read-only transaction.
- The summary view is an allowlist. A new run column stays out of the
summary until someone adds it.
- Mixed versions are safe in both orders. An older Cloud never sends the
new fields. A newer Cloud sends them only to `/read-v2`, and an older
tenant answers 404 there.
- No migration.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits) and extended thinking.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
28aa32e7d7 |
fix(plan-mode): open the plan review card when a Plan-mode run settles without one (#22732)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Plan mode makes an agent write a plan document. The user then
approves the plan or requests changes on a review card. After approval,
the agent does the work on the same task.
> - For Codex and Claude, the agent session reports the plan as a
provider event. Paperclip opens the review card from that event.
> - Google Antigravity and other ACPX agents have no such event. They
write the plan with a tool, and they must open the review card with
another tool.
> - When the agent does not open the card, the run settles as "waiting
for a response" and the task shows no action. This happened in a live
run: the Antigravity process was stopped during a Plan-mode run, and the
automatic continuation wrote a new plan revision but did not open the
card.
> - This pull request makes the server open the review card when a
Plan-mode run settles with a plan revision that has no review card. It
does this for every harness.
> - The benefit is that a Plan-mode task always shows the user the next
action, also after a crash or restart.
## Linked Issues or Issue Description
Refs #22727
**What happened?**
A Google Antigravity agent ran a task in Plan mode. The agent process
was stopped during the run. Paperclip continued the run automatically.
The new run wrote a new plan revision and finished with "waiting for
plan review". It did not open the Approve / Request changes card. The
task stayed in progress with no action for the user.
**Expected behavior**
When a Plan-mode run settles with a new plan revision, the user sees
exactly one review card for that revision. Retries, restarts and
duplicate settles do not add more cards. A Plan-mode run that produces
no plan does not leave the task waiting with no action.
**Steps to reproduce**
1. Assign a task to an Antigravity agent in Plan mode.
2. Stop the agent process while the run is in progress.
3. Let Paperclip continue the run automatically.
4. See that the continuation writes the plan but no review card opens.
**Paperclip version or commit**
master at
|
||
|
|
9a04538391 |
perf(ci): cut PR CI under 5 minutes (shared PG, E2E parallelism, routing, test pruning) (#22679)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI verifies every change before merge across typecheck, build, server/DB/UI unit tests, and Playwright E2E shards. > - Today PR CI takes 15–30+ minutes wall-clock on ordinary feature and fix PRs (such as #22626) because every PR runs release/packaging/runner-support bloat, boots 800+ separate embedded Postgres clusters, runs Vitest serialized shards and E2E shards at 1 worker, builds the UI 8 separate times for E2E, emits 52 MB of React `act(...)` stderr spam in UI tests, and runs 61 real-clock soak suites plus hundreds of historical one-time SQL migration and mocked component wiring tests. > - Slow PR CI delays developer feedback, wastes runner capacity, and encourages batching changes instead of shipping small, safe PRs. > - This pull request cuts PR CI across all 6 bottlenecks (pipeline routing/Build bloat, PR-scoped parallel typecheck, shared embedded Postgres + batched/parallel Vitest runner, parallel E2E shards + prebuilt UI cache, historical/soak DB+server pruning with a checked-in nightly manifest, and UI stderr cleanup + low-value test pruning) while preserving all core control-plane invariants and full post-merge/release coverage. > - The benefit is projected PR CI wall-clock drops from 15–30+ minutes to ~3.8–4.4 minutes on ordinary PRs while keeping `master`, `release-verify`, `cloud-readiness`, local `pnpm test:run`, and `full-ci` runs at full coverage. ## Linked Issues or Issue Description Refs #22626. **What existing behavior does this improve?** Trusted pull-request CI wall-clock duration and runner efficiency across `.github/workflows/pr-trusted.yml`, `turbo.json`, `scripts/ci-typecheck-lane.mjs`, `scripts/run-vitest-stable.mjs`, `tests/e2e/`, `packages/db`, `server`, and `ui` test suites. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Ordinary PRs take 15–30+ minutes wall-clock in PR CI: - `Build` (~7.5–8.0m) runs a 231s clean public npm Grok install verifier and a 57s embedded-Postgres boot smoke on every PR. - `Canary Dry Run` (6.2m), `Runner support suite` (7.9m), `Docker context integrity`, `General tests (chat 1–3/3)`, and `Verify Paperclip Runner (vitest package 1–3/3)` fan out on ordinary app PRs due to broad `turbo.json` inputs. - `Typecheck + Release Registry` (7.1m) runs `test:release-registry` (193s), all standalone sandbox provider installs/checks, all untouched `tests/*` projects, and `--singleThreaded` `tsc` on every PR. - `General tests` and `Verify serialized server suites` boot 800+ separate embedded Postgres clusters instead of using `packages/db/src/test-postgres-command.ts`, run 17 serial Vitest invocations in `workspaces-b`, and run `verify_serialized_server` with `--no-file-parallelism --maxWorkers=1`. - `e2e_shards` (8.6m slowest shard) rebuilds the UI 8 separate times and forces `workers: 1` across all 56 specs because 7 specs mutate instance-level flags. - `workspaces-a` (8.3m × 2 shards) emits ~52 MB of React `act(...)` / `IS_REACT_ACT_ENVIRONMENT` stderr spam and executes 992 UI test files (including hundreds of brittle mocked wiring / `renderToStaticMarkup` suites). - `packages/db` and `server` run 43 historical one-time SQL migration replay tests, 12 static prose-grep tests, and 61 real-clock soak/crash/lease-expiry suites (~108.5 CPU-min) on every PR. **Proposed behavior** Ordinary PRs complete in under 5 minutes wall-clock while preserving full control-plane invariant coverage and full `master`/`release-verify`/`cloud-readiness`/`full-ci` verification: - PR `Build` removes the 231s Grok clean-npm verifier (already covered in `release-smoke.yml` and `docker-runner-check.yml`) and gates the 53s boot smoke on `PAPERCLIP_CI_FULL=1` (keeping fast `build:runtime` on every PR). - `turbo.json` and `.github/ci-task-matrix.json` path-gate `Canary Dry Run`, `Runner support suite`, `Docker context integrity`, `general-chat`, `ci:runner-package`, `ci:workspaces-a`, and `ci:db`, and narrow `tests/**` out of `globalDependencies`. - `Typecheck + Release Registry` uses fail-closed PR-mode scoping (`CI_PLAN`, `PAPERCLIP_CI_BASE_SHA`, `PAPERCLIP_CI_FULL`), parallel `typecheck-test-programs.mjs`, and `--checkers` / `GOMAXPROCS=2` within the 15.7 GiB RAM budget. - `run-vitest-stable.mjs` automatically wraps Postgres-backed lanes with one shared embedded Postgres template server (`test-postgres-command.ts`), batches `workspaces-b` and `workspaces-a` into single multi-project Vitest invocations, parallelizes isolated `serialized` shards, and filters `scripts/ci/nightly-only-suites.json` in PR mode (respecting `PAPERCLIP_CI_FULL=1`). - `e2e_shards` restores a read-only exact-key `server/ui-dist` cache written on canonical `master` pushes (`PAPERCLIP_E2E_SKIP_UI_BUILD=1`, inline fallback on UI PRs), isolates the 7 flag-mutating specs onto 2 serial shards while running the other 6 shards at `workers: 3` + `fullyParallel: true`, prunes 5 legacy/screenshot specs, and replaces fixed 20s/30s sleeps with deterministic waits. - `ui/vitest.setup.ts` eliminates >99.9% of stderr spam (`IS_REACT_ACT_ENVIRONMENT = true`, clean localStorage/DOM stubs, targeted `act(...)`/`No queryFn` suppression) and prunes 445 low-value mocked/presentational/screenshot UI tests + slims 2 giant mocked suites (keeping all `ui/src/lib`, `api`, `hooks`, `context`, `adapters`, `features`, `plugins`, and privacy/authz tests). - `packages/db` and `server` prune 43 historical one-time SQL migration tests, 12 static prose-grep tests, and 28 redundant `it.each` cases in `chat-channels.integration.test.ts`, and classify 61 real-clock soak/restart/lease-expiry/workspace-recovery suites (6,510.2s / 108.5 CPU-min) into `scripts/ci/nightly-only-suites.json`. **Reason and benefit** Cuts ordinary PR CI wall-clock from 15–30+ minutes to a projected ~3.8–4.4 minutes and removes ~156,353 LOC of redundant/brittle test code without dropping any core Paperclip invariant (company isolation, authz, atomic checkout, single-assignee, approval gates, budget hard-stop, activity logging). **Breaking changes** None for product runtime behavior. In PR CI, 61 real-clock soak suites listed in `scripts/ci/nightly-only-suites.json` run on `master`, `release-verify`, `cloud-readiness`, local `pnpm test:run`, and PRs with the `full-ci` label (`PAPERCLIP_CI_FULL=1`) instead of every ordinary PR. ## What Changed - **Pipeline & routing (`ci-fast/pipeline`):** - `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`, `.github/ci-task-matrix.json`, `turbo.json`: removed Grok clean-npm verifier from PR `Build`, gated `server-boot-smoke.sh` on `PAPERCLIP_CI_FULL=1`, path-gated `canary_dry_run`, `verify_runner_e2e_support`, `docker_context_integrity`, `general-chat`, `ci:runner-package`, `ci:workspaces-a`, and `ci:db`, forwarded `CI_PLAN` / `PAPERCLIP_CI_BASE_SHA` / `PAPERCLIP_CI_FULL` (keeping `profile-ci` in PR mode), and added exact-key read-only `server/ui-dist` cache restore in `e2e_shards` with a master-only writer in `release-verify.yml`. - Updated `.github/scripts/tests/ci-plan.test.mjs`, `scripts/__tests__/public-install-closure.test.mjs`, and `scripts/__tests__/runner-release-crate-cache.test.mjs`. - **Typecheck lane (`ci-fast/typecheck`):** - `scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/typecheck-test-projects.mjs`, `server/scripts/typecheck-layers.mjs`: added fail-closed PR-mode diff scoping (skipping `test:release-registry`, standalone sandbox providers, demo plugins, and untouched test projects/workspaces on unrelated PRs), concurrent `typecheckTestProgramsAsync`, and `--checkers` / `GOMAXPROCS=2` parallelism within 15.7 GiB RAM. - Updated `scripts/__tests__/ci-typecheck-lane.test.mjs`, `scripts/typecheck-test-programs.test.mjs`, and `server/scripts/typecheck-layers.test.mjs`. - **Vitest runner (`ci-fast/vitest-runner`):** - `scripts/run-vitest-stable.mjs`, `packages/db/src/test-postgres-command.ts`, `scripts/__tests__/run-vitest-stable-shard.test.mjs`: wired automatic shared embedded Postgres template DB (`test-postgres-command.ts` with `fsync=off`), batched `workspaces-b` and `workspaces-a` into single multi-project Vitest runs, parallelized isolated `serialized` shards (`maxWorkers=3`), and added PR-mode filtering for `scripts/ci/nightly-only-suites.json` (honoring `PAPERCLIP_CI_FULL=1`). - **Playwright E2E (`ci-fast/e2e`):** - `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `scripts/__tests__/e2e-shard.test.mjs`, `maps/feature-map/recovery.md`: added `PAPERCLIP_E2E_SKIP_UI_BUILD=1`, isolated the 7 instance-mutating `SERIAL_SPECS` onto dedicated serial shards while running the remaining 44 specs across 6 shards at `workers: 3` + `fullyParallel: true`, pruned 5 legacy/screenshot specs (`-743 LOC`), and replaced fixed 20s/30s sleeps in `disconnect-resilience.spec.ts` and `composer-stop.spec.ts`. - **Server & DB test pruning + nightly soak manifest (`ci-fast/server-prune`):** - Deleted 41 historical one-time SQL migration tests + 5 obsolete fixture SQLs in `packages/db/src`, 2 historical server SQL migration tests, and 12 brittle static prose-guidance tests; trimmed `packages/db/src/client.test.ts` (2,328 → 219 LOC), `packages/db/src/better-auth-account-issuer-migration.test.ts` (167 → 19 LOC), and 2 redundant `it.each` matrices in `server/src/__tests__/chat-channels.integration.test.ts`. - Added `scripts/ci/nightly-only-suites.json` classifying 61 real-clock soak/restart/lease-expiry/workspace-recovery suites (6,510.2s / 108.5 CPU-min). - **UI test log spam fix & pruning (`ci-fast/ui-prune`):** - `ui/vitest.setup.ts`, `ui/vitest.config.ts`: eliminated >99.9% stderr spam (22–52 MB → 3.6 KB) by enabling `IS_REACT_ACT_ENVIRONMENT = true`, adding clean DOM/localStorage stubs, and filtering React `act(...)` / TanStack Query `No queryFn` noise. - Pruned 445 low-value mocked/presentational/screenshot UI test files, slimmed `AgentConfigForm.render.test.tsx` and `Browse.test.tsx` to their privacy/access checks, updated 34 `maps/` files to remove dead test links, and removed the stale `ui/src/pages/NewAgent.test-support.tsx` allowlist entry in `scripts/check-query-error-rendering.mjs`. ## Verification - Combined CI contract & shard test suite (`node --test .github/scripts/tests/ci-plan.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/typecheck-test-programs.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs`): **136/136 PASS** (23.13s). - Full `.github/scripts/tests/*.test.mjs` suite on `ci-fast/pipeline`: **850/850 PASS** + Turbo cached-lane check **1/1 PASS**. - `node scripts/check-query-error-rendering.mjs --enforce --summary` and `node --test scripts/check-query-error-rendering.test.mjs`: **0 findings, 7/7 PASS**. - `node scripts/check-maps.mjs`: **PASS** (`35 areas, 192 capability IDs`). - `pnpm --filter @paperclipai/db typecheck`: **PASS** (`check:migrations` + `tsc --noEmit`). - `pnpm --filter @paperclipai/ui typecheck`: **PASS** (`369 files, 3454 stories` + `run-tsc.mjs -b`). - Component-level benchmarks verified on individual branches prior to merge (`ci-typecheck-lane.mjs` 63.4s simulated PR run; real Playwright 3-worker parallel specs passing; UI suite full run reduced to 3.6 KB stderr). - Live GitHub PR CI run triggered on this draft PR to verify real runner execution and measure before/after timings. ## Risks - **Two-phase CI effect:** Because `.github/workflows/pr.yml` invokes `pr-trusted.yml@master`, the workflow-level changes (removing Grok clean-npm install from PR `Build`, path-gating `Canary Dry Run`/`Runner support suite`/`general-chat`/`ci:runner-package`, passing `CI_PLAN`/`PAPERCLIP_CI_BASE_SHA`/`PAPERCLIP_CI_FULL`, and restoring `e2e-ui-dist`) take full effect only after merging to `master` (and `e2e-ui-dist` warms on the first `master` push; until then `e2e_shards` cleanly falls back to inline UI build). Furthermore, this PR modifies global CI inputs (`turbo.json`, `scripts/**`, `.github/**`), so its own PR CI runs the full matrix. - **Nightly soak demotion:** The 61 real-clock soak suites in `scripts/ci/nightly-only-suites.json` still run on every `master` push (`release-verify.yml`), `cloud-readiness.yml`, local `pnpm test:run`, and `full-ci`-labeled PRs, so regressions are caught post-merge rather than blocking ordinary PRs. - **Duration manifest rebalance:** Post-merge, the weekly `ci-test-durations.yml` refresh will recalibrate shard weights to reflect shared-Postgres timings for optimal LPT balance. - **No product runtime or DB schema changes:** All changes are confined to CI workflows, build/test orchestration scripts, test setup, test suites, and feature-map references. ## Model Used - Google Gemini 4 Neon (`Gemini 4 Neon (High)`), Google DeepMind, with repository tools, code execution, and multi-agent swarm coordination. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
3cd1370141 |
fix(github): re-read parked response requests after the settle decision changes (#22710)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull requests, and a background sweep settles each request's status comment once its run finishes > - The sweep parks a request it cannot progress yet with a wait key, and a broad rebuild skips it until that key changes > - #22672 changed how requests settle, but requests parked by the older code kept the same key after the deploy > - So the new code never read them: 11 inline "Working on this…" comments stayed open on staging after #22672 deployed > - This pull request puts a decision version at the start of the wait key > - The benefit is that a deploy which changes the settle decision re-reads every parked request once, so old stuck comments settle ## Linked Issues or Issue Description Refs #22672 **Describe the bug** After #22672 deployed to staging, 5 of 16 stuck inline "Working on this…" review comments settled, but 11 did not. Their tasks had no new activity, so their wait keys did not change, and the sweep kept skipping them. **Steps to reproduce** 1. A request is parked by the terminal response sweep with a wait key from older code. 2. Deploy code that changes when such a request settles. 3. Nothing on the task changes, so the key stays the same and the request is never read again. **Expected behavior** A deploy that changes the settle decision re-reads every parked request once. ## What Changed - `GITHUB_TERMINAL_RESPONSE_DECISION_VERSION` ("v2") now starts the terminal sweep's wait key. Keys written before this change never match, so each parked request is read once by the current decision. - New test: requests parked with the old key, whose own run finished before a newer run, are all settled after the sweep starts. ## Verification - `reads requests parked by an older decision once after a deploy`: red without the version (0 of 120 acknowledged), green with it (120 of 120). - `server/src/services/chat-channels/github/` tests: 65 passed. - After deploy: the 11 open "Working on this…" comments on staging-reviewed PRs should settle within a sweep pass. ## Risks - One extra read of every parked request right after deploy (one batched page read per 100 rows, then they park again under the new key). Low risk. ## 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> |
||
|
|
d1339f1fe4 |
fix(tools): show agents the stable code of a connected tool's own error (#22723)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents call connected tools (plugin connectors and remote MCP servers) through the tool gateway, and the runner reports a failed call back to the model > - The runner keeps only a leading stable error code from a failed tool result and drops free text and 5xx errors, so internal diagnostics never reach the model > - The gateway raised every error a connected tool reported about itself as a 502 with the code buried in free text, and stringified an MCP error's content array as "[object Object]" > - So an agent saw only "Paperclip semantic operation failed" for a rate limit, a concurrency refusal or a validation error, and retried blindly > - This pull request re-raises a tool's own error as a 4xx whose message starts with the tool's stable code > - The benefit is that agents see why a tool refused (for example `read_concurrency_limit` or `validation_error`) and can wait or fix their input ## Linked Issues or Issue Description **What happened?** An agent refreshing a tracker ran reads in parallel. The Customer success connector refused all but two at a time with `read_concurrency_limit`, and Notion refused some queries with validation errors. The agent saw "Paperclip semantic operation failed" for every one. Cloud recorded 299 concurrency refusals against 10 completed reads before the run gave up. **Expected behavior** The agent sees the tool's stable error code, for example `Paperclip semantic operation failed: read_concurrency_limit`. **Steps to reproduce** 1. Have an assigned connected tool fail with a tool-reported error (the gateway raises `ToolGatewayHttpError(502, "... (code: read_concurrency_limit, retryable)", "tool_error")`). 2. Call it through the runner's assigned tools. 3. The model receives only the generic failure text. ## What Changed - `server/src/services/native-runtime/assigned-mcp-tools.ts`: a `tool_error` from the gateway, or an `isError` result, is re-raised as a 422 `tool_error` whose message starts with the tool's stable code. The code comes from a plugin's `(code: ...)`, a JSON `"code"` field, or a leading `code:` prefix, with `assigned_tool_error` as the fallback. The message carries no provider free text. - `server/src/services/tool-gateway.ts`: tool error messages use the text of MCP content items instead of `String(array)`. - Tests for each code source and the fallback; the old tests that expected the raw 502 object now cover approval and revocation only. ## Verification - `npx vitest run src/services/native-runtime/assigned-mcp-tools.test.ts`: 63 passed. - The runner's ACPX feedback already keeps a leading `code:` prefix from a failed tool result's text (existing Rust tests), and the Codex driver passes a thrown error's message as that text. ## Risks - Low. Only errors that a connected tool reported about itself change. Approval, revocation and gateway failures are unchanged. The reason code stays `tool_error`. ## 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> |
||
|
|
92e3ad1de9 |
Fix plugin SDK issues.list double-applying offset/limit (#16327)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugins get a scoped host SDK (`ctx.issues.list`, etc.) so they can read company data without full server access > - The `issues.list` handler already asks the issue service to paginate at the SQL level, but then re-slices the already-paginated result a second time with the same offset/limit > - That means any page past the first (`offset >= limit`) always returns `[]`, silently — a plugin paginating a large company's issues loses every row past page 0 > - This pull request removes the redundant second windowing step so `issues.list` paginates correctly on every page > - The benefit is that plugins (e.g. a Home Assistant integration scanning >200 issues) stop silently losing data past page 1 ## Linked Issues or Issue Description Fixes #16290. Related prior art: #14654 attempted nearly the same fix on 2026-09-30 but was withdrawn by its own author minutes later as an accidental branch push, never reviewed. #14673 (nagoodman) is an active, independently-equivalent fix open since 2026-09-30 — see the maintainer-review coordination note below. ## What Changed - Removed the redundant `applyWindow` re-slice in the plugin-SDK `issues.list` handler (`server/src/services/plugin-host-services.ts`); the normalized `limit`/`offset` now pass straight into the `issues.list(companyId, …)` service call, which already paginates at the SQL level. - Added an explicit `limit === 0` short-circuit to `[]`: the service's own clamp is `Math.max(1, floor(limit))`, so passing `0` straight through would otherwise incorrectly yield 1 row instead of 0. - **Follow-up fix (2026-10-16, per reviewer feedback from @BichengWang):** the `limit === 0` short-circuit originally returned before `issues.list` ran at all, which skipped that service's filter validation (e.g. a malformed `assigneeAgentId` silently returned `[]` instead of the expected 422). Fixed by always running the query (floored to `limit: 1` when the caller asked for `0`) and discarding the rows only after it succeeds, so validation errors still surface. Added a regression test for the malformed zero-limit case. - Confirmed the no-limit case is unaffected: the query path skips `.limit()` entirely when `limit === undefined`, matching the prior "no limit → return all from offset" behavior. - Audited every other `applyWindow` call site in the same file (`companies.list`, `projects.list`, `agents.list`, `goals.list`): none forward `params` into their underlying service call, so `applyWindow` is their only windowing step — no double-apply there. Only `issues.list` had the bug. ## Maintainer review coordination @BichengWang flagged (2026-10-16) that #14673 is an active, independently-equivalent fix for the same bug that already preserves the zero-limit validation path this PR initially missed. Both PRs now cover the same ground; whichever lands first should supersede the other. No preference from us — happy to close this one if a maintainer prefers #14673. ## Verification - New regression test in `server/src/__tests__/plugin-orchestration-apis.test.ts`: seeds 5 issues and asserts 3 full pages — including page 2 (`offset=4`) — return their expected slices instead of `[]`, plus `limit=0` and past-the-end cases, plus (new) a malformed-filter-at-zero-limit case that must still reject with 422. - Run locally with `pnpm exec vitest run --project @paperclipai/server server/src/__tests__/plugin-orchestration-apis.test.ts`. ### Local verification - Commit: `9d776d12a` (rebased on current `origin/master`) - Negative control: reverted just the service-file fix, kept the new test — confirms it fails (`[]` returned instead of rejecting) without the fix, passes with it. - tier1/tier2 gate: in progress on this commit as of 2026-10-16T16:xx UTC; will update once it reports pass/fail. - Previous head `6a0279174`: tier1+tier2 both GATE PASSED, live GitHub 56/56 checks green, Greptile 5/5. - Not run locally: docker-context, e2e (no Docker/Chrome on host) ## Risks - Behavior-only change to one plugin-SDK list handler; no schema or migration changes. Low risk. - Revert is a clean single-commit revert of this PR. ## Model Used Claude (Claude Agent SDK), Sonnet 5 (`claude-sonnet-5`), agentic tool use with repository read/write and 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 (#14654 withdrawn, #14673 active/overlapping) - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes (none needed — internal plugin-SDK behavior, no user-facing docs reference this handler) - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green (re-gating after the follow-up fix; previous head was 56/56) - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups (re-review pending on the new commit) - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
d2bdad4ae5 |
fix(plugins): report WORKER_UNAVAILABLE when no worker is registered for a bridge call (#19286)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugin UIs call their workers through the bridge routes `bridge/data` and `bridge/action` > - `mapRpcErrorToBridgeError` turns a worker call failure into a bridge error code for the client > - For a plugin with no registered worker, the worker manager rejects with `PluginWorkerUnavailableError` and the message `No worker registered for plugin "<id>"` > - The mapper matched only the substrings `not running` and `not registered`, so this case became `UNKNOWN` > - This pull request makes the mapper recognize the typed error that the worker manager already throws > - The benefit is that clients get `WORKER_UNAVAILABLE` for every "no live worker" case, and the result does not depend on message wording ## Linked Issues or Issue Description Fixes #19092 Refs #19007 (the parent issue that #19092 was split out of) I searched open and closed PRs for `19092`, `mapRpcErrorToBridgeError` and `WORKER_UNAVAILABLE`. I found no related PR. ## What Changed - `mapRpcErrorToBridgeError` in `server/src/routes/plugins.ts` returns `WORKER_UNAVAILABLE` when `findPluginWorkerUnavailableError(err)` finds a `PluginWorkerUnavailableError`, including one wrapped in a `cause` chain. The existing substring checks stay as a fallback. - Added a route test in `server/src/__tests__/plugin-routes-authz.test.ts`. The worker manager mock rejects with the same error and message that `plugin-worker-manager.ts` produces when no worker is registered. The test expects a 502 with `code: "WORKER_UNAVAILABLE"`. ## Verification - `pnpm exec vitest run server/src/__tests__/plugin-routes-authz.test.ts --testTimeout=60000`: 38 of 39 tests pass, including the new test. - The one failure is `lists bundled monorepo plugin packages`. It fails the same way on unmodified `master` on my Windows machine, because the postinstall step could not create the plugin SDK symlinks there. It is not related to this change. - Without the fix, the new test receives `code: "UNKNOWN"`. ## Risks - Low risk. Only errors that the worker manager already classifies as worker-unavailable change their bridge code, from `UNKNOWN` to `WORKER_UNAVAILABLE`. The HTTP status stays 502. Nothing is dispatched to a worker in this case, before or after the change. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), used through Claude Code with tool use (shell, file editing). It assisted with code reading, the change, tests and this description. I reviewed the change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
dd6db295a3 |
fix(workspaces): move a managed folder online when its records name a repository that is not there (#22722)
## 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 > - The online pass moves a managed folder with no repository as an ordinary folder: it copies the files under the folder's source locks > - On staging, two stacks keep 33 workspaces blocked with `workspaces:source_scope_not_git_source` > - Those records carry a repository URL or branch, so the ordinary path skips them, but their folder holds no repository, so the Git path refuses them too > - The offline move copies the same folder as files > - This pull request lets the ordinary path prove a managed folder whose records name a repository that is not there > - The benefit is that these workspaces move online exactly as they move offline, with the same fence as every other ordinary folder ## Linked Issues or Issue Description Refs #22644 **What happened?** After repeated online passes on staging (Core |
||
|
|
f144bdee34 |
fix(workspaces): name the overlap and missing-Git cases that keep a workspace from moving online (#22718)
## 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 stack moves only when the online pass reports no blockers, so each blocker must name its exact cause > - On staging, one stack reports `workspaces:overlapping_workspace_requires_maintenance` x6 with no detail code, and two stacks report `workspaces:source_scope_not_git_source` x33 > - The overlap code has no detail when the workspace does not need a proven source scope, and `not_git_source` joins two different cases > - This pull request names how the paths overlap, why the source scope is unproven, and which of the two Git cases applies > - The benefit is that the next pass on each blocked stack shows which rule applies, so the matching fix can follow ## Linked Issues or Issue Description Refs #22644, #22696 **What happened?** After repeated online passes on staging (Core |
||
|
|
2b8ae371d3 |
perf(budgets): read only the needed run columns under the run lock (#20130)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Before a run is dispatched, `reserveRunBudget` reserves budget under the company accounting lock, the same lock that charges and policy changes use > - Inside that transaction it read the full `heartbeat_runs` row `FOR UPDATE`, including `context_snapshot` and the log columns > - Admission and native Stop recovery read only a few of those columns > - On one instance 5 to 8 waiters queued on the company lock while this query took up to 1.3 s; `context_snapshot` was 28 kB on average and up to 2.8 MB > - This pull request selects only the columns that the reservation path reads, with the same row lock > - The benefit is that the large columns are not detoasted or sent while the company lock is held, so the lock is held for a shorter time ## Linked Issues or Issue Description No issue exists. Related, but a different part of budget admission: #17966 (skip the accounting lock for admission that cannot block) and #18928 (queue accounting transactions). **What happened?** Run dispatch waited on the company accounting lock. The lock holder was the `SELECT * ... FOR UPDATE` on `heartbeat_runs` in `reserveRunBudget`, which read large `context_snapshot` values. **What did you expect?** The reservation reads only the columns it needs while it holds the company lock. **Steps to reproduce** 1. Create a company with a budget policy and runs with large context snapshots. 2. Start many runs at the same time. 3. Look at `pg_stat_activity` or the query log. The `heartbeat_runs` row read in `reserveRunBudget` returns all columns while other transactions wait on the company lock. **Paperclip version** `master` at the time of this PR. ## What Changed - `server/src/services/budget-reservations.ts`: a new `RESERVATION_RUN_COLUMNS` with `id`, `companyId`, `agentId`, `nativeIssueId`, `status`, `costAccountedAt`, `resultJson`, `runtimeMode` and `usageJson`. `reserveRunBudget` selects these columns `FOR UPDATE` instead of the full row. These are the fields that admission and `readClaimedNativeStopRecovery` read. - `server/src/__tests__/budget-enforcement-scoping.test.ts`: a new test checks that the locked query selects only these columns. ## Verification - `cd server && npx vitest run src/__tests__/budget-enforcement-scoping.test.ts`: passes, including the new test. - `pnpm --filter @paperclipai/server typecheck`: passes. The type of `run` is now the narrow select, so a later use of a column that is not selected fails the typecheck. ## Risks - Low risk. The row lock, the filter and the logic do not change. If a future change in this function needs another column, it has to be added to `RESERVATION_RUN_COLUMNS`; the typecheck shows this. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, git, 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> |
||
|
|
724693f635 |
fix(workspaces): move a managed folder online when another record names it by a different path (#22721)
## 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 > - An ordinary managed folder can move online when every task record that points at it is fenced by the folder's source locks > - On staging, one stack keeps 26 workspaces blocked with `workspaces:source_scope_ordinary_member_locator_mismatch` > - The check compares the text of each record's path with the folder's physical path, so a record that names the same folder through a symlink or with a trailing slash is refused > - The source locks already come from the physical path, so writers through either spelling take the same lock > - This pull request compares physical paths, and names a record that encloses the folder separately > - The benefit is that these workspaces move online exactly as they move offline, with the same fence ## Linked Issues or Issue Description Refs #22644 **What happened?** After repeated online passes on staging (Core |
||
|
|
f0bbd4ada9 |
fix(workspaces): let one online source scope hold as many locks as its alias bound admits (#22724)
## 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 Git workspace moves online only while one transaction holds the source lock of every task and project that can write its repository > - On staging, one stack keeps 46 workspaces blocked with `workspaces:source_scope_source_keys_exceeded` > - The proof refuses a scope above 128 lock keys, but the same proof admits up to 256 alias records, and each record adds a task key > - The fence must hold every key at the same time, so it cannot page across passes: a writer that took a released key could change the repository during the capture > - This pull request raises the key bound to 512 in one shared constant, and makes the capture's Git source root bound follow it > - The benefit is that a repository shared by many tasks moves online with the same fence as a small one ## Linked Issues or Issue Description Refs #22644 **What happened?** After repeated online passes on staging (Core |
||
|
|
6a642a9316 |
fix(cloud): name why a native session or controller source stays blocked in the move (#22717)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Hosted stacks move from a volume to volume-free storage, and the
move reports a code for each blocked item
> - Three native codes each cover several unrelated conditions
> - An operator or a fix agent cannot tell from the code which condition
holds, so stuck stacks stay stuck
> - This pull request names the exact condition next to each code,
without changing what either path accepts
> - The benefit is that the next pass says what to fix
## Linked Issues or Issue Description
**What happened?**
A stack reports
`workspaces:native_workspace_migration_identity_unproven`,
`native_controllers:artifact_unproven` and
`native_controllers:archive_source_unsettled` on every pass. Each code
is thrown from a check with up to eleven separate conditions, so the
report cannot say which saved state blocks the move.
**Expected behavior**
Each blocked item names the failing condition, and the online and
offline paths accept the same data as before.
**Steps to reproduce**
1. Save a paperclip_runner session whose resume run has no workspace
sync descriptor, then migrate its workspace.
2. Or archive a failed controller online while its coordinator holds a
lease.
3. Before this change, the reports are only
`native_workspace_migration_identity_unproven` or
`archive_source_unsettled`.
**Paperclip version or commit**
master at
|
||
|
|
cbf67dba0a |
fix(cloud): record a selected harness backup whose source is gone instead of blocking the move (#22716)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Hosted stacks move from a volume to volume-free storage, offline in
maintenance or online with no outage
> - A stack moves only when no local native harness backup obligation
remains
> - A selected session can carry a backup stamp whose files are no
longer on the volume
> - Offline and online both refuse that stack forever, because nothing
can copy files that are gone
> - This pull request records "backup source was gone" for that session,
the same way offline and online, after a locked recheck
> - The benefit is that the stack moves, and the gone backup is recorded
instead of silently forgotten
## Linked Issues or Issue Description
**What happened?**
An online durable-data pass reports
`native_harness:selected_source_absent` on every pass for a stack. The
selected session has a v2 backup stamp, but `failover-backups/current`
for that scope is not on disk. The offline maintenance path also fails:
`native_harness_backups_require_migration` stays true because
`migrateNativeHarnessBackups` only visits sources on disk. The stack can
never move.
**Expected behavior**
When the backup files are already gone and the session is settled, both
paths record that the backup source was gone and stop counting it as an
obligation. A session that is still active, or a backup that the
expiration service is rotating, stays blocked with a name.
**Steps to reproduce**
1. Create a selected `paperclip_runner` session whose last run is
settled and whose environment lease has a v2 backup stamp.
2. Remove `<state base>/<scope digest>`.
3. Run `prestageNativeHarnessBackups` or `migrateNativeHarnessBackups`.
4. Before this change, `selected_source_absent` repeats and
`hasLocalNativeHarnessObligations` stays true.
**Paperclip version or commit**
master at
|
||
|
|
451c09bfbe |
fix: Correct OpenAPI access metadata for board-only agent session routes (#21024)
> [!NOTE] > Opened by Prospector's automated issue-fix pipeline. A maintainer reviews and decides; nothing here merges on its own. ## Thinking Path - Issue #20942 reports a defect in paperclipai/paperclip. - Root cause, as the fixing agent read it: The three session operations were missing from BOARD_ONLY_OPERATIONS, so OpenAPI defaulted to board_or_agent access and included AgentBearerAuth despite the handlers requiring board access. - This pull request: Correct OpenAPI access metadata for board-only agent session routes ## What Changed - `server/src/routes/openapi.ts`: Classify all three operations as board-only while preserving existing handler permissions. - `server/src/__tests__/openapi-routes.test.ts`: Add regression cases for board security, authorization metadata, and forbidden responses on each route. All three failed before the fix; all 48 OpenAPI tests and the typecheck pass afterward. ## Verification - Reproducing test(s), added in this PR: `server/src/__tests__/openapi-routes.test.ts` - They fail on the base commit and pass with the fix, each twice in a fresh sandbox. - 3 independent attempts wrote 3 reproductions; this fix passes every one of them. - The repository's compile command passes with the fix applied. - 9 existing test file(s) near the change passed. - The full test suite passes except for the 17 file(s) that already fail on the base commit. ## Risks - Written by an automated pipeline, not a person: review it as you would an outside contribution. - Risk tier of the touched paths: 2. - The scope reviewer found it also changes, beyond the report: search_api pagination using a cursor generated from the previous catalog, for any query ## Model Used - codex:gpt-6.1-sol, opus, sonnet (Anthropic Claude, via Claude Code; OpenAI, via the Codex CLI), writing and checking the change in an isolated sandbox. - opus (Anthropic Claude, via Claude Code), reviewing it independently. ## Linked Issues Fixes #20942 A search of paperclipai/paperclip's open and closed pull requests found no other pull request that names #20942. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with 'Fixes: #' / 'Closes #' / 'Refs #' OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub '#NNN' / 'github.com/paperclipai/paperclip' URLs) - [ ] My branch name describes the change (e.g. 'docs/...', 'fix/...') and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge <!-- prospector:issue-fix v1 issue=20942 base=156212cfd58a report=0d14759e2b96f394 --> Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com> |
||
|
|
362e3bb4e3 |
fix(daytona): accept regional toolbox proxy hosts such as proxy.app-eu.daytona.io (#20075)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Daytona connection lets agents create sandboxes and run toolbox actions in them through the tool gateway > - Before Paperclip forwards a toolbox call with the Daytona key, it checks the sandbox toolbox proxy host against a list of known Daytona hosts > - The check accepts only `proxy.app.daytona.io` and `proxy-<name>.app.daytona.io` > - Daytona returns `proxy.app-<region>.daytona.io` for sandboxes in other regions. For example, EU sandboxes use `proxy.app-eu.daytona.io` > - So every toolbox call for an EU sandbox fails with `daytona_proxy_invalid`, and sandbox create, list and delete still work > - This pull request lets the host check accept one optional region suffix on `app`, and it keeps the check anchored > - The benefit is that organizations in non-default Daytona regions can use the toolbox actions, and the key still goes only to Daytona hosts ## Linked Issues or Issue Description Fixes #20073 ## What Changed - `server/src/services/daytona.ts`: the toolbox proxy host pattern now accepts `app` or `app-<region>`. The new pattern is `^proxy(?:-[a-z0-9-]+)?\.app(?:-[a-z0-9]+)?\.daytona\.io$`. - `server/src/__tests__/daytona-connection.test.ts`: a new test forwards a toolbox call to `proxy.app-eu.daytona.io`. The test also makes sure that these look-alike hosts are rejected before Paperclip forwards the key: `proxy.app-eu.daytona.io.attacker.example`, `proxy.app-eu.attacker.io` and `proxy.app-.daytona.io`. - No documentation change is necessary. `doc/connections/DAYTONA.md` says that toolbox calls accept only reviewed Daytona cloud proxy hostnames, and that statement stays correct. ## Verification - `pnpm exec vitest run server/src/__tests__/daytona-connection.test.ts server/src/__tests__/daytona-http-boundary.test.ts`: 2 files and 24 tests pass, and this includes the new test. I ran only these two Daytona files, not the full `pnpm verify` suite. - With the old pattern back in place, the new test fails with `Daytona returned an unrecognized toolbox address`. So the test covers the bug. - Manual check on a self-hosted Paperclip `2026.1106.0` instance with the same one-line change in `dist/services/daytona.js` and a Daytona organization in the `eu` region: - Before the change, `daytona_toolbox_execute_command` returned HTTP 502 `daytona_proxy_invalid`. - After the change, the same call ran `node -v` in a new EU sandbox and returned exit code 0. The sandbox was then deleted. - Pattern check: the new pattern accepts `proxy.app.daytona.io`, `proxy-us.app.daytona.io` and `proxy.app-eu.daytona.io`. It rejects `proxy.app-eu.daytona.io.attacker.example`, `proxy.app-eu.attacker.io`, `proxy.app-.daytona.io`, `proxy.app-eu-.daytona.io` and `xproxy.app.daytona.io`. ## Risks - Low risk. The change only widens the host pattern to Daytona-owned `app-<region>.daytona.io` subdomains. The protocol, port, path, credential and organization checks do not change. The DNS-pinned egress guard still applies to every request. - If Daytona adds a region host in a different shape, the check will still reject it. That case needs a separate change. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), run as a Claude Code agent with tool use (shell, git, GitHub CLI and the Daytona connection). The model found the cause, wrote the change and the test, and ran the checks. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge Co-authored-by: Heron Agents <7084258+aalfath@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
30dc924dc9 |
fix(server): reuse one pino-pretty transport per process (#12987)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The server logs through pino, and outside production it writes
through a `pino.transport` pretty-printer
> - `pino.transport` starts a worker thread and returns no handle the
caller can close
> - `server/src/middleware/logger.ts` calls it at module scope, so each
extra evaluation of that module leaks one worker thread for the life of
the process
> - A server evaluates the module once, but 46 server test files reset
the module registry in `beforeEach`, so those suites evaluate it once
per test
> - This pull request keeps one transport per process, in a cache that a
module-registry reset cannot discard
> - The benefit is that a 50-test server suite stops holding 50 dead
worker threads and about 280 MB of unused memory
## Linked Issues or Issue Description
No existing issue covers this. The problem, in the bug-report shape:
**What happened?**
`server/src/middleware/logger.ts` calls `pino.transport` at module
scope:
```ts
export const logger = isProduction
? pino({ ... })
: pino({ ... }, pino.transport({ target: "pino-pretty", ... }));
```
`pino.transport` starts a thread-stream worker. The module keeps no
handle to
it, so nothing can close it. Each evaluation of the module starts one
more.
A server process evaluates the module once. The tests do not. 46 files
under
`server/src/__tests__` call `vi.resetModules()` in `beforeEach` and then
re-import a module that reaches the logger, usually to rebuild an
express app
against fresh mocks. Those suites evaluate the module once per test, so
each
test adds one worker thread, one MessagePort and one V8 isolate that
live until
the process exits.
**Expected behavior**
One pretty-print transport per process. Re-evaluating the module must
not start
another worker.
**Steps to reproduce**
Add this to any server test file on `master` and run it:
```ts
const ports = () => process.getActiveResourcesInfo().filter((r) => r === "MessagePort").length;
it("leaks a worker per evaluation", async () => {
await vi.importActual("../middleware/logger.js");
const before = ports();
for (let i = 0; i < 10; i += 1) {
vi.resetModules();
await vi.importActual("../middleware/logger.js");
}
console.log(ports() - before); // 10 on master, 0 with this PR
});
```
The count rises by exactly one per evaluation. The test this PR adds is
that
check, written as an assertion.
**Measurements**
| Transports in one process | Threads | RSS |
| --- | --- | --- |
| 0 (baseline) | 8 | 60 MB |
| 100 | 108 | 276 MB |
| 200 | 208 | 1.38 GB |
| 400 | 407 | 1.68 GB |
A 50-test suite therefore carries roughly 280 MB of dead workers.
`server/vitest.config.ts` pins `maxWorkers: 1`, so these suites run one
at a
time on one runner and each pays the whole cost.
**Paperclip version or commit**
Reproduces on `master` at `856813ba3`.
**Deployment mode**
Test and CI only. A running server evaluates the module once, so it
never had
more than one transport.
**Related pull requests**
- #10865 (closed) — a different bug in the same file. It fixed unbounded
thread-stream *send buffer* growth from prettifying `req`/`res` on the
file
target. This PR is about the *number of workers*, not the size of one
worker's buffer. That PR was closed because the `targets` array it
patched no
longer exists on `master`; the call this PR changes does still exist.
- #8323 (open, last updated 2026-06-19) — makes the log format
configurable and
edits the same lines. It looks unmaintained. If it is revived, the cache
here
moves into whichever branch builds the transport.
## What Changed
- `server/src/middleware/logger.ts`: `pino.transport` now runs behind
`prettyTransport()`, which caches the stream on `globalThis`. The cache
is on
`globalThis` on purpose — a module-scoped variable is discarded by the
very
module-registry reset this guards against. Production behaviour does not
change: a server evaluates the module once, so it built one transport
before
and builds one now.
- `server/src/__tests__/logger-pretty-transport-reuse.test.ts` is new.
It
asserts that 10 re-evaluations add no MessagePorts, and that every
module
instance shares one transport object.
## Verification
```bash
pnpm --filter @paperclipai/server exec vitest run src/__tests__/logger-pretty-transport-reuse.test.ts
```
- With the cache: 2 passed.
- With the cache defeated (`??=` changed to `=`), both tests fail:
`AssertionError: expected 10 to be less than or equal to 2`, and the
identity
check fails on two different transport objects.
Nothing else changes behaviour, so the surrounding suites are the
regression
check:
```bash
pnpm --filter @paperclipai/server exec vitest run \
src/__tests__/instance-settings-routes.test.ts \
src/__tests__/http-log-redaction.test.ts \
src/__tests__/health.test.ts
node --test scripts/__tests__/run-vitest-stable-shard.test.mjs
```
69 passed and 13 passed. `tsc --noEmit` reports no error in either
changed file.
The new suite joins the general-server group and needs no
duration-manifest
entry: the staleness check requires 50% coverage and one new file does
not
cross it.
## Risks
Low.
- A server process evaluates the module once, so the cache never engages
there.
The only behaviour it changes is that several module instances in one
process
now share one pretty-print stream, which is what a single instance
already
did.
- The `globalThis` key is namespaced (`__paperclipPinoPrettyTransport`)
and read
only by this module and its test.
- Merge risk sits with #8323, which edits the same lines. See the note
above.
## Model Used
Claude Opus 5 (`claude-opus-5`), via Claude Code, with extended
thinking, tool
use and code execution.
## Checklist
Verified on `8391a138b` (2026-09-08): 31 checks pass, 1 skipped
(`Storybook visual
regression`, not exercised by this diff), merge state `CLEAN`. Greptile
scored 5/5
— "safe to merge" — with no inline comments and no open findings.
- [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
- [x] My branch name describes the change 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 <noreply@anthropic.com>
Co-authored-by: kronik187 <david@teasoftware.io>
|
||
|
|
fe93b402ac |
fix(companies): delete a company when a late activity entry commits during the delete (#22719)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A board user can delete a company. `deleteCompany` removes the company rows in one transaction. > - The transaction removes activity entries early. It then removes many other rows, and it removes the company row last. > - The transaction holds only a `NO KEY UPDATE` lock on the company row. This lock does not stop the `KEY SHARE` lock that a foreign key check takes. A background writer can add an activity entry for the company while the delete runs. > - The delete itself starts such a writer. It terminates the company's agents first. Termination wakes stranded-task recovery, which marks the agent's open task as blocked and writes an `issue.updated` activity entry. > - When that entry commits after the early sweep, the final delete fails on `activity_log_company_id_companies_id_fk`, and the user gets a 500 error. > - This pull request locks the company row `FOR UPDATE` just before the final delete, and then removes the activity entries again. > - The benefit is that company deletion works when a background writer adds an activity entry during the delete. ## Linked Issues or Issue Description Refs #22714 **What happened?** `DELETE /api/companies/:id` sometimes returned 500. The log showed: `update or delete on table "companies" violates foreign key constraint "activity_log_company_id_companies_id_fk" on table "activity_log"`. The e2e test `tests/e2e/plan-task-fixture.spec.ts` failed this way 8 times in CI between 2026-11-20 and 2026-11-23 (for example on #22714). Each time, a rerun passed. The failures started before #22636 and #22669, so those changes did not cause it. **What did you expect to happen?** Company deletion succeeds every time. A background writer for the company does not make the delete fail. **Steps to reproduce** 1. Create a company with two agents that use the `process` adapter, and pause both agents. 2. Create a task that is assigned to one of the agents. 3. Wait 300 to 1000 ms, then delete the company. 4. Repeat. On a local server, 2 of 80 deletes failed with the error above. The failed company still had an `issue.updated` entry from `recovery.reconcile_stranded_assigned_issue`. ## What Changed - `server/src/services/company-deletion.ts`: three named steps lock rows `FOR UPDATE` immediately before the `DELETE` of the same rows, and then remove the company's activity entries again: - `lockRunsAndSweepLateActivity` before the company's runs are deleted, - `lockAgentsAndSweepLateActivity` before the company's agents are deleted, - `lockCompanyAndSweepLateActivity` before the company row is deleted. Each lock waits for writers that hold `KEY SHARE` on those rows and blocks new ones. So a late activity entry that names the company, a run or an agent cannot make the next `DELETE` fail. - The existing comment at the start of the transaction now explains both kinds of lock: why the first lock stays `NO KEY UPDATE`, and why the later `FOR UPDATE` locks are safe. - New test `server/src/__tests__/company-deletion-concurrent-activity.test.ts` (embedded Postgres). A second connection adds an activity entry while the delete runs. Case 1: the writer commits after the first sweep. Cases 2 to 4: the writer keeps its transaction open, with an entry that names the company, a run, or an agent. The test polls `pg_stat_activity` until the delete waits on a lock, and then releases the writer. There is no fixed sleep. The release is in a `finally` block. ## Verification - Red: without the fix, the tests fail with `activity_log_company_id_companies_id_fk`, the same error as in CI. - Each lock was removed in turn. Without the run and agent locks, the run and agent cases fail with `activity_log_run_id_heartbeat_runs_id_fk` and `activity_log_agent_id_agents_id_fk`. Without the company lock, the company case fails with `activity_log_company_id_companies_id_fk`. The other cases still pass each time. - Green: `cd server && npx vitest run src/__tests__/company-deletion-concurrent-activity.test.ts` passes (4 tests). - Related suites pass (413 tests): `git-restore-point-ledger`, `tool-connection-content-deletion-canary`, `agent-observability`, `decision-target-work`, `google-managed-connection-removal`, `task-workspace-binding`, `tool-gateway-service` and the new test. - `cd server && npx tsc --noEmit -p .` passes. - Local server reproduction (the steps above, API calls only, first commit of this PR): before the fix 2 of 80 deletes failed. After the fix 0 of 280 deletes failed, and the server log had no foreign key errors. ## Risks - Low risk. Each new `FOR UPDATE` lock is taken immediately before a `DELETE` of the same rows. That `DELETE` already takes a lock that conflicts with `KEY SHARE`. So the change adds no new wait and no new deadlock path. The first lock on the company stays `NO KEY UPDATE`, so a native save that holds a child row is not blocked early. - A writer that adds an activity entry after the delete commits gets a foreign key error in its own transaction, as before. Stranded-task recovery and the Google retry worker check that the company exists or catch the error. In the reproduction, no worker logged an error. - Not changed: the `activity_log` foreign keys. Only activity entries are swept again. A late row in another table that has no cascade can still conflict with a delete. No CI log showed that case. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edit, embedded Postgres tests, local 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> |
||
|
|
506211b917 |
fix(run-logs): archive a finalized log that a later attempt extended (#22709)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Hosted stacks move from a volume to volume-free storage, and the durable-data migration must move every run log first > - Some finalized run logs grew after their size and SHA-256 were recorded, because a later attempt of the same run appended to the same local file > - Both the online and offline migration refused these logs as `legacy_length_or_digest_mismatch`, so the stack could never leave its volume > - This pull request archives such a log when the recorded proof matches a prefix of the file, and names the real corruption case distinctly > - The benefit is that these stacks can move without deleting or hiding any bytes, and real corruption still blocks the move ## Linked Issues or Issue Description **What happened?** Durable-data migration blocks a run log with `legacy_length_or_digest_mismatch` when the local file is longer than the size and SHA-256 recorded at finalize. The run log store never truncates, so a later attempt that shares the run id appends to the finalized file. The stack then cannot move to volume-free storage. **Steps to reproduce** 1. Finalize a run log so that the run records its size and SHA-256. 2. Append more output to the same local file. 3. Run the online or offline durable-data migration. 4. See the log blocked as `legacy_length_or_digest_mismatch`. **Expected behavior** When the recorded size and SHA-256 match a prefix of the file, the migration keeps every current byte, records both proofs, and lets the stack move. When the recorded proof matches no prefix, the log stays blocked under a distinct name. ## What Changed - `server/src/services/run-evidence-migration.ts`: before it claims the object journal, the migration checks if the recorded size and SHA-256 match a prefix of a longer file. If yes, it archives every current byte as a read-only `s3_archive` log in the `<run>.archive` journal. - The publish sets the run's size and SHA-256 to the archived bytes. In the same transaction it writes a `run.historical_log_archived` activity entry with the original prefix proof (`recorded`) and the new size and SHA-256. - A log whose recorded size and SHA-256 match no prefix (a different longer file, a shorter file, or a same-size file with different bytes) stays blocked as `legacy_recorded_log_not_a_prefix`. Nothing is uploaded or published for a longer file that fails the prefix check. - The extended log must come from the local file. A longer mirror copy stays blocked as `mirror_completeness_unproven`, because a matching prefix does not prove that the mirror holds the whole file. - While the run still has a pending or leased attempt (a native finalization with `next_attempt_at`, a lease owner, or a phase other than `committed` or `terminal_failure`), the log stays blocked as `legacy_writer_retry_pending`. The publish `WHERE` rechecks this condition, so a later attempt of the same run never finds a read-only archive. - Both archive publications (settled native history and extended logs) share one helper that publishes and writes the activity entry in one transaction. - `legacy_length_or_digest_mismatch` stays for the other cases: a source that changed while it was read, and a run that recorded only one of size or SHA-256. - The online path (`migrateRunEvidencePage`) and the offline path (`preserveHistoricalFiles`) use the same code, so the rule is the same for both. - `doc/run-evidence-storage.md` describes the new rule. ## Verification - New test `server/src/services/run-evidence-migration-appended.test.ts` uses embedded PostgreSQL, real local files and an in-memory object store: - online and offline: a log with appended output is archived, the run row has the new size and SHA-256, the archive reads back every byte after the local file is deleted, and one activity entry holds both proofs. - online and offline: a longer file, a shorter file and a same-size file whose bytes differ stay blocked as `legacy_recorded_log_not_a_prefix`, keep their local reference, and write no activity. - online and offline: an extended log whose run has a pending attempt stays blocked as `legacy_writer_retry_pending`, unchanged and with no activity. - a longer mirror copy (local file missing) stays blocked as `mirror_completeness_unproven`. - Red: the first 3 tests fail on master (`legacy_length_or_digest_mismatch`). The pending-attempt and mirror tests fail on the first commit. Green: all 5 pass with this change. - `npx vitest run src/services/run-evidence-migration-appended.test.ts src/services/run-evidence-migration-page.test.ts src/services/online-durable-data-migration.test.ts`: 40 passed. - `npx tsc --noEmit -p server`: clean. - I did not run the opt-in S3 integration suite (`run-evidence-migration.integration.test.ts`), because it needs an external S3 endpoint. Its `wrong-digest` case records only a SHA-256, so it keeps `legacy_length_or_digest_mismatch`. ## Risks - An archived log is read-only. This is the same as the existing historical archives. The publish requires a settled run with no writer lease, so no attempt can still be writing. - The prefix check reads the recorded prefix (not the whole file) one more time before the copy. This happens only when the file is longer than the recorded size. It lets a non-prefix file fail before anything is uploaded. - Low risk otherwise: logs whose bytes match their recorded proof follow the same path 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 Related: #22697 (archived workspaces whose files are gone) and #22698 (skills whose remote source is gone) settle the other two cases that block the same move. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2e229c311f |
fix(skills): settle unreachable remote skill sources when storage moves (#22698)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Hosted stacks move from a disk volume to volume-free storage, and
the durable-data migration must move every skill installation first
> - A remote skill (GitHub, skills.sh or URL) with no local files, no
complete saved version and an unreachable source blocks the move with
`skills:remote_source_unavailable`
> - Both the online and the offline migration refuse it today, so real
stacks stay on volumes forever
> - This pull request settles that case the same way in both paths:
rebuild the skill from its saved instructions, or keep it present but
unavailable until it is reinstalled
> - The benefit is that the move can finish without deleting any bytes
that still exist, and each outcome is logged
## Linked Issues or Issue Description
**What happened?**
A hosted stack could not move to volume-free storage. Two skill
installations had no local files, no complete saved version, and a
remote source that did not answer. The online and offline durable-data
migrations both reported `skills:remote_source_unavailable` and kept the
stack on its volume.
**Expected behavior**
Recovery works without manual repair. If the stored skill instructions
exist, the migration saves them as a new version and marks that version
as rebuilt. If no instructions are stored, the skill stays in the
library, is marked unavailable, is not offered to agents until it is
reinstalled, and does not block the move. The activity log records both
outcomes.
**Steps to reproduce**
1. Create a `github` skill with a pinned commit, an installed inventory
of `SKILL.md` and `reference.md`, and no saved version.
2. Make the remote source return 404.
3. Run the skill installation conversion. It reports `blocked` with code
`remote_source_unavailable`.
**Paperclip version or commit**
`master` at
|
||
|
|
eddaf14504 |
fix(workspaces): move an archived workspace whose files are already gone (#22697)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Hosted stacks move from a volume to volume-free storage, and Core must move every local workspace before the stack can move > - Some archived workspaces have no files left on the volume and no local repository that can rebuild them > - Both the offline and the online migration refuse these workspaces with `archived_git_source_unavailable` and `local_source_unsafe_or_missing`, so the stack stays on its volume forever > - Nothing can ever move those files, because the files do not exist > - This pull request records a "files gone" outcome for such a workspace and moves the record without a snapshot > - The benefit is that the stack can move, the record stays, and a later reopen tells the user plainly that the files were not available ## Linked Issues or Issue Description **What happened?** An archived workspace whose folder and whose possible git sources are all absent blocks the durable-data migration. The online pass reports `workspaces:archived_git_source_unavailable` and `workspaces:local_source_unsafe_or_missing` on every cycle. The offline maintenance pass fails. Two archived workspaces on one staging stack are in this state. **Expected behavior** A workspace whose files are provably gone does not block the move. The workspace record stays. Reopen says that its files were not available at migration time. A workspace whose files may still exist stays blocked. **Steps to reproduce** 1. Archive a local workspace. 2. Delete its folder (and any local repository it was made from). 3. Run the online or offline durable-data migration. 4. See the workspace deferred with the two codes on every pass. ## What Changed - `inspect` in `remote-workspace-migration.ts` marks a workspace as "files gone" only when all of these are true: the workspace is archived, it has no saved file reference (no `gitCacheRestoration` and no task-directory retention record), its folder does not exist (`ENOENT`, not a symlink or file), no retained restore point or archived git source exists, the restore point did not expire or fail validation, and every possible local source for its files is absent (the folder, the provider path, the private repository source, the managed project caches, a `file:` repository, and the project workspace folder). - For such a workspace, the two codes leave the blocker list. Every other blocker (writers, recovery, runtime leases, task binding) still applies. - `reserveMigration` then writes a remote authority with `snapshotId: null` and no location, a `workspaceFilesUnavailable` record with the old local path and time, and a `workspace.files_unavailable_at_migration` activity log entry in the same company-scoped transaction. No snapshot or operation journal is created. Cohorts, resumed journals, native continuity and recovery sources keep the workspace blocked. - `inspectRemoteWorkspacePersistence` (used by reopen) returns a plain message for this record: "This workspace's files were not available when it moved to new storage, so they cannot be restored. Continue the task in a new workspace." - `cleanupRemoteWorkspaceAllocation` treats such a record with no allocation as already clean. - The online pass counts these workspaces as moved and also as `workspacesFilesUnavailable`. The offline pass uses the same owner, so the rule is the same for both. - Stays blocked with the existing codes: a folder that exists but is a symlink or a file, an active or idle workspace with a missing folder, and an archived workspace whose repository or cache still exists on disk. ## Verification - `cd server && npx vitest run src/services/remote-workspace-migration.test.ts src/services/online-durable-data-migration.test.ts` (254 passed, embedded Postgres, real files). - `cd server && npx vitest run remote-workspace-lifecycle remote-workspace-migration-concurrency remote-workspace-cohort-migration` (pass). - Red/green: a fifth test moves an archived project task workspace whose managed repository cache is also gone (the archived Git check fails with a git command error there); it fails before and passes now. - Red/green: a fourth test keeps a workspace with a broken saved Git or task-directory reference blocked; it fails on the first commit and passes now. - Red/green: the two new "files are already gone" tests fail on `origin/master` (the migration throws the two codes) and pass with this change. The "files may still exist" guard test passes before and after. - `cd server && npx tsc --noEmit -p .` passes. ## Risks - The proof is conservative. If any possible source path exists, the workspace stays blocked, so some archived workspaces may still need another fix. - The move is not reversible by the migration. It deletes no bytes, because it acts only when nothing exists on disk. - A reopen of such a workspace now fails with the plain message. Before this change, the workspace could not move at all. > 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, agentic coding with tool use (shell, file edits, test runs) 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> |