Commit Graph
8535 Commits
Author SHA1 Message Date
DottaandClaude Opus 5.5 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>
2026-11-24 14:21:17 -06:00
DottaandClaude Opus 5.5 9502a12252 design(ui): show Antigravity swarm events in a task (inventory and stories) (#22803)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - A task can run Google's Antigravity CLI as a swarm: one coordinator
and several helpers work in the task folder.
> - Today the task shows the swarm only as a flat list of step titles,
such as "Started helper writer-a".
> - Antigravity's own Swarm UI shows a goal, threads, helpers with their
state and current step, and a numbered message board.
> - We did not know which of these facts Paperclip actually receives. We
also did not know how the facts could look in a task.
> - This pull request records what Paperclip receives, from real
recorded runs. It also adds design-proposal stories that show three
directions, built only from those facts.
> - The benefit is a grounded design decision. The next step is clear:
read the swarm's own files and fix one driver bug.

## Linked Issues or Issue Description

Refs #22731 (the swarm driver). Refs #22733 (the `/swarm` command).

**Subsystem affected**
Task chat and run activity for the Antigravity CLI swarm turn
(`packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-*`).
Storybook design proposals.

**Problem or motivation**
During a swarm, the user sees only short step titles. The user cannot
see which helper does what, which helper is blocked, or how far the work
is. Antigravity's own UI shows all of this. We did not know if Paperclip
can get the same data.

**Proposed solution**
Record the evidence in
`doc/plans/2026-11-24-antigravity-swarm-events.md`. The short answer is
"partly":

- Over ACP, Paperclip gets everything the coordinator does. This
includes the swarm title, each helper's name and brief, a
goal/task/thread plan, the coordinator's own messages, finish and stop,
and one usage total.
- Paperclip gets nothing that the helpers do over ACP. The results of
`swarm status` and `read_board` are not forwarded.
- The CLI writes the board, the roster and each helper's steps as
structured JSON in its private `--gemini-dir`. Paperclip already owns
that folder.

Then show three directions in Storybook, built only from this data. Each
element has a tag that tells where its data comes from.

**Alternatives considered**
- Show only the facts that come over ACP. With this choice, the task
cannot show helper state, the current step or helper messages.
- Ask the coordinator to post summaries. This costs tokens, and the
summaries are still prose.
- Wait for Google to expose more. The work graph, a Google review state
and the narrator overview are not available today. The stories show them
only in a variant with the label "Needs Google".

**Additional context**
The inventory found a driver bug. The coordinator writes its plan to
`<state-dir>/antigravity-cli/brain/<session>/.system_generated/swarm/plan.json`,
because its built-in `swarm_pane` skill tells it to.
`antigravityOutsideChange` thinks that this is a write outside the task
folder, so the driver stops the swarm. This happened in 3 of 7 recorded
swarm turns. This PR does not fix it. The fix is to exempt that one
folder, with a red/green test.

## What Changed

- `doc/plans/2026-11-24-antigravity-swarm-events.md`: the inventory. It
lists each element of the reference UI, where the data comes from (ACP
update, tool input or file), samples, timing and risk.
- `ui/storybook/fixtures/antigravity-swarm.sample.json`: redacted events
from one real 4-helper swarm run (CLI 1.5.15, auto mode, isolated state
folder). It holds the ACP updates and the swarm files.
- `ui/storybook/support/design-proposals/swarm-activity/`: turns the
fixture into a view model (helpers, state, current step, messages,
progress, threads) and adds the state variants. It also holds
presentational parts that reuse shipped primitives: the runner header,
the activity group, the subagent tree, `StatusGlyph`, `Tabs`, `Badge`
and `Button`.
- `ui/storybook/stories/design-proposals/swarm-activity.stories.tsx`
(`design-antigravity-swarm-activity`) adds 16 stories:
  - Compare directions.
  - Today: the step titles from the current driver.
  - Direction 1 · Inline helpers (running, helper blocked, finished).
  - Direction 2 · Swarm panel (overview, helpers, messages).
  - Direction 3 · Summary card (collapsed, expanded).
- The states starting, running, helper blocked, stopping, stopped,
failed, not available and finished.
  - A long swarm with 11 helpers and 25 messages.
  - Narrow width.
  - "Would need Google to expose".
- No product code changes. Nothing is connected to live pages.

## Verification

- `node scripts/storybook-catalog.mjs --check`: pass (371 files, 3480
stories).
- `node --test scripts/storybook-catalog.test.mjs`: 13/13 pass.
- `node scripts/check-token-gates.mjs`: all gates clean.
- `cd ui && npx tsc -p tsconfig.json --noEmit`: 0 errors.
- `pnpm build-storybook`: pass. A headless Playwright run opened each of
the 16 stories in light and dark at 1440 px (390 px for the narrow
story) and saved screenshots. No story scrolls horizontally.
- Evidence for the inventory: 7 recorded swarm turns and 1 new real run,
about 3 minutes and 180k coordinator tokens.

## Risks

- Low risk. The change adds Storybook files and a doc only.
- The design depends on files that the CLI does not document. A future
reader must pin to the CLI version and use fixture tests. The doc tells
this.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with
tool use (shell, file edit, headless browser).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable (stories only; no
behavior to test)
- [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>
2026-11-24 13:53:29 -06:00
DottaandClaude Opus 5.5 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>
2026-11-24 13:36:30 -06:00
DottaandClaude Opus 5.5 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

7d26bdaa (deployed) and origin/master 4daeab5c76; the maintenance files
are identical.

### Deployment mode

Hosted (Cloud-managed), offline maintenance entry
`server/dist-runtime/ephemeral-migration.mjs`.

## What Changed

- `server/src/maintenance/ephemeral-migration-service.ts`: new
`ownerRefusalCode`. A bare `[a-z_]` code passes as before. Only an
allowlisted reason-list owner (`remote_workspace_migration_blocked`) may
carry `:reason,reason`; each reason must be a fixed lowercase code, a
malformed list keeps just the owner code, and more than 32 reasons keep
the first 31 plus `more_reasons_truncated`. Anything else reports
`owner_migration_failed`. Logs `{event: "ephemeral_migration_blocked",
phase, failure}` to stderr when blocked.
- `server/src/maintenance/ephemeral-migration-service.test.ts`: receipt
and log for a structured refusal with a workspace phase; sanitized log
for an arbitrary error; allowlist, malformed and truncation cases.

## Verification

- Red: new test failed on origin/master (`failure:
"owner_migration_failed"`).
- Green: `cd server && npx vitest run
src/maintenance/ephemeral-migration-service.test.ts` (16/16). `npx tsc
-p server/tsconfig.json --noEmit` clean.
- `pnpm verify` selected a broad server shard; stopped it after 30 min
per AGENTS.md section 7 and rely on CI for broad coverage.
- Not run: a live enrollment.

## Risks

- Low. Diagnostics only; migration and blocking behavior are unchanged.
The accepted shape cannot carry paths, URLs, secrets or stack text.
Rollback: revert.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in 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>
2026-11-24 13:36:00 -06:00
DottaandPaperclip 1a36a8f3c0 fix(e2e): wait for agreeing dependency run observations (#22802)
## Thinking Path

> - Paperclip lets people manage AI agents and their work.
> - A blocked task must start once after its blocker is complete.
> - The dependency journey checks this through task and agent run reads.
> - These independent reads can see the same run at different stages of
completion.
> - The collector can stop while the agent read still says `running`.
> - This pull request waits for both reads to agree before it saves the
finished and reopened points.
> - The test can then measure the completed work with the existing
strict rules.

## Linked Issues or Issue Description

**What happened?**

The dependency journey can report `dependency_one_automatic_resume`
after one correct automatic run. Its completion wait accepts the task
run as `succeeded` while the agent run read still says `running`. A
later read agrees, but the saved finished point remains split.

**Expected behavior**

Wait for matching task and agent run facts within the existing campaign
deadline. Keep the two observations independent. Fail if they never
agree.

**Steps to reproduce**

Use the flow fixture to return a completed task run and a lagging agent
run detail. Run the new `agent detail still running after task detail
completed` case against the old collector. It fails with
`dependency_one_automatic_resume`.

**Paperclip version or commit**

Base: `3ca9b6d471e100fe248c650f30453db4d3bc55fb`.
Related: #21732 added valid wake producers. That repair is already
present and does not address this read timing error.

## What Changed

- Compare task and agent run facts with the same normalized facts used
by the grader.
- Require agreement before the collector ends its completion wait and
after it reopens the result.
- Tag fixture projections explicitly, with separate agent lag counters
before and after reopening.
- Share the full settled predicate between both waits; agreeing stale
reads cannot count as completion.
- Add temporary and permanent cases for agent lag, task-only and
agreeing stale run views, task status, missing document, active locks
and native phase.
- Document the completion wait. Keep the grader, run budget and deadline
unchanged.

## Verification

- Red: the new lagging-read regression fails on the base collector with
`dependency_one_automatic_resume`.
- Green: three focused dependency suites pass, 126 tests. This includes
permanent disagreement, duplicate or unrelated runs, early execution,
history and output checks.
- Command: `node /tmp/pap5740-test-tools/node_modules/vitest/vitest.mjs
run --config /tmp/pap5740-test-tools/vitest.config.mjs`. The temporary
config selects
`tests/runner-e2e/product-journeys/task-dependency-resume*.test.ts`.
Tools: Vitest 5.0.3, Playwright 1.62.1 and Zod 4.
- `pnpm verify` could not run: the managed Git storage guard rejects
`git ls-files` with `paperclip_git_storage_limit`. CI must supply
broader checks.
- No new paid journey was run. Staging acceptance remains open. No
reviewed harness pin was changed.
- Follow-up commit: `16bb94c256769fe76b014e865259b742b35773ea`. The
reopened-only regression fails on the prior commit with
`dependency_one_automatic_resume`; it passes after this repair.
- Second follow-up: `45d60118fb36fd1f426e088f263d04c91484cfee`. Ten of
twelve new stale-state cases fail on `16bb94c`; all pass after sharing
the settled predicate.
- Exact finished-run binding:
`24d7b2f67a9f51ac6d996211f651a92772ff2a55`. Both reopened projections
must match the normalized saved finished-run facts. Two additional
agreeing-but-different run-facts cases fail before this change and pass
afterward.
- CI and Greptile passed on `16bb94c`; reviews also cleared `45d6011`.
Fresh CI and reviews are pending on `24d7b2f`.

## Risks

Low risk. A mismatch now uses the remaining campaign wait rather than
reaching the grader early. Permanent disagreement still fails at the
deadline. This change does not start another agent run, alter production
state, replace either independent read, or relax the grader.

## Model Used

OpenAI GPT-6 through Codex, with reasoning and code execution. The
runtime did not expose a more specific model ID.

## 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-24 13:34:14 -06:00
096060598d Add project pinning to the Coordinator sidebar (#22805)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Operators use projects to organize and review related tasks.
> - The Coordinator sidebar provides quick access to pinned items.
> - Project pins were available from Recents after a project visit.
> - This PR makes each project pinnable directly from More → Projects.
> - Pinned project rows expand in place so operators can open a recent
task from the sidebar.

## Linked Issues or Issue Description

**What existing behavior does this improve?**

Project navigation in the Coordinator workspace.

**Subsystem affected**

The board UI, specifically the Projects list and the left sidebar.

**Current behavior**

Users who review work by project must visit a project before they can
pin it from Recents. Project rows use a separate expand control. Hidden
sidebar controls also reserve space that can truncate project and task
names.

**Proposed behavior**

Give each Coordinator project row a pin action. Let users click the
sidebar project row to open or close its recent tasks, and give labels
the full available width while row controls are hidden.

**Reason and benefit**

Users can set up several project shortcuts from one page and reach the
tasks they review regularly from the sidebar.

## What Changed

- Add pin and unpin actions to Coordinator Projects rows using the
existing per-user browser preference.
- Make pinned and recent project rows expand and collapse their tasks.
Show closed and open folder icons for the two states.
- Match nested task spacing to adjacent navigation items and give nested
tasks a small indent.
- Reserve sidebar label space for controls when they are visible. Keep
the project icon and text centered in the Projects list.
- Scope project star and join or leave controls to Classic mode.

## Verification

- Run `pnpm --filter @paperclipai/ui typecheck`.
- Run the focused workspace preference, project query, and pinned
navigation Vitest files.
- Run `tests/e2e/project-pinning.spec.ts` in Chromium to verify pinning,
persistence, label width, expansion, and task navigation.
- In Chromium, open More → Projects and pin a project. Reload and
confirm the shortcut persists. Expand it using the mouse or keyboard,
open a nested task, reorder pins, and unpin from either the list or the
sidebar.
- Check label widths at rest and with hover, keyboard focus, and touch
controls. Check that Classic mode shows the star and membership
controls.

- GitHub Actions passed on `e96959bffe`, including build, typecheck, and
all eight browser shards. Two server shards passed on retry. [CI
run](https://github.com/paperclipai/paperclip/actions/runs/45466386598)
- Greptile gave the same commit 5/5 with no open review threads.
[Review](https://github.com/paperclipai/paperclip/pull/22805#issuecomment-7141648518)

## Risks

- Clicking a project row in the Coordinator sidebar now opens its task
list in place. Users can still open the full project from the Projects
page.
- This UI change reuses the existing browser preference and project task
query. It requires no database migration.

## Model Used

OpenAI Codex with GPT-6.2-Sol. Used local code execution, Chromium, and
GitHub CLI.

## 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>
2026-11-24 11:31:38 -08:00
Dotta 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
2026-11-24 13:25:46 -06:00
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>
2026-11-24 10:25:32 -08:00
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>
2026-11-24 10:25:32 -08:00
DottaandClaude Opus 5.5 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>
2026-11-24 12:01:21 -06:00
d01d3c40ad fix(ui): defer the Connectors announcement until a return visit (#22790)
## Thinking Path

> - People use Paperclip to manage AI agents at work.
> - New users now meet their agent in chat after setup.
> - The Connectors card previously checked for an open onboarding task.
> - Chat-first onboarding creates no such task, so the card could appear
three seconds into a first visit.
> - This change holds that promotion until the person returns after 30
minutes of inactivity.

## Linked Issues or Issue Description

Refs: #19514, #22077

**What happened?**

On master at `11cfe0910d`, a new user could see the Connectors card in
their first agent chat.

**Expected behavior**

The card stays hidden through the first visit and can appear when the
user returns after a 30-minute gap in activity.

**Steps to reproduce**

With the Connectors announcement active, finish chat-first onboarding in
a fresh browser profile and wait for the announcement delay.

## What Changed

- Track the first visible board visit per account in browser storage.
Local input and visits in other tabs extend the first session. After the
first qualifying return, the browser remembers eligibility and stops
tracking input.
- Apply this rule to the published Connectors announcement ID. The
existing checks for dismissal, open dialogs, and legacy onboarding tasks
still apply.
- Exercise the onboarding chat, reload, idle return, account isolation,
and activity in another tab.

## Verification

- Before the fix, the Vitest regression displayed
`2026-09-14-connectors` on the first visit.
- The announcement and workspace identity Vitest suites passed locally
(28 tests). The UI typecheck passed.
- Chromium passed all four tests in `announcement-first-session.spec.ts`
and `announcement-placement.spec.ts` against a local test server.
- A second red-green regression covers dismissal in another browser
while the first tab sits idle. The return triggers a fresh check and
keeps the card hidden until it succeeds.
- At `8fab1932fa`, GitHub reported 73 successful checks and three
skipped checks. [CI
run](https://github.com/paperclipai/paperclip/actions/runs/45449353624)

## Risks

A new browser profile or cleared site data starts the visit history
again. Storage failures keep the Connectors card hidden. Existing users
start accumulating visit history when they first use this version.

## Model Used

OpenAI Codex, GPT-6.2 Astra (`gpt-6.2-astra`), with shell, Vitest, and
Playwright.

## 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>
2026-11-24 09:57:37 -08:00
DottaandClaude Opus 5.5 6385c171fa fix(connections): show only the privacy policy link in the Google Workspace picker (#22795)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The built-in Google Workspace connection lets agents use Gmail,
Drive (with Docs, Sheets and Slides) and Calendar
> - Before Google consent, the user chooses services in the "Connect
Google Workspace" picker
> - On Nov 17, #21998 added two text sections to this picker: "What
agents can do" and "How your data is used"
> - On Nov 24, the owner decided that this screen must show only the
privacy policy link and no other explanatory text
> - This pull request removes the two sections and keeps the privacy
policy link directly under the service rows
> - The benefit is a short picker that matches the owner decision, for
new setup and reconnect, in the Apps flow and the task-hosted flow

## Linked Issues or Issue Description

Refs #22634

**What happened?**
The "Connect Google Workspace" picker shows a "What agents can do"
section and a "How your data is used" section with bullet sentences. The
text changes with the selected services. The owner does not want this
text on the screen.

**What did you expect to happen?**
The picker shows the title, the three service rows (each with its access
select and switch), the privacy policy link, and Cancel / Continue. It
shows no other explanatory text for any selection.

**Steps to reproduce**
1. Open Apps and start a Google Workspace connection, or reconnect an
existing one.
2. Look at the service picker with all services on, with read only, and
with one service on.
3. See the two text sections above the footer.

## What Changed

- `ui/src/features/connections/GoogleWorkspaceServices.tsx`: remove the
`DataUseDisclosure` block. The privacy policy link ("Read our privacy
policy, including how we meet Google's Limited Use requirements",
`https://paperclip.ing/privacy`, new tab) now sits directly under the
service rows for every selection, including no selection. The "Select at
least one service to continue." status stays. The screen-reader
description "Choose the Google services to connect." stays. The URL
constant `GOOGLE_WORKSPACE_PRIVACY_POLICY_URL` moves into this file.
- `ui/src/features/connections/googleWorkspaceDisclosure.ts`: deleted.
Nothing else used the copy builder.
- `ui/src/features/connections/GoogleWorkspaceServices.test.tsx` (new;
the earlier suite was removed in #22729): for all services read & write,
all read only, one service, and no service, the dialog has no section
headings, no lists and none of the removed sentences. The link has its
text, href and new-tab target. The dialog keeps its accessible
description. Continue stays disabled with no service and submits the
chosen services.
-
`ui/storybook/stories/connection-setup/google-workspace-services.stories.tsx`:
the `ProductionPickerReadOnly` play test now checks that the removed
text is absent and the link is present.
- Docs: `doc/memory/google-connector-memory.md` gets a dated Nov 24
decision row with the risk.
`doc/plans/2026-11-17-google-workspace-production-checklist.md` no
longer claims a disclosure in the picker.
`doc/plans/2026-11-17-google-workspace-code-fixes.md` item 1 records the
removal.

The dialog now contains, from top to bottom: the Google Workspace logo
and the title "Connect Google Workspace"; Gmail, Drive ("Docs, Sheets,
and Slides") and Calendar rows, each with a "Read only / Read & write"
select and a switch; the privacy policy link; the empty-selection status
(only with no service on); Cancel and Continue in one footer row.

## Verification

- Red first: the new test ran against the old picker and 4 of 5 tests
failed (removed text present; link absent with no selection). After the
change all 5 pass.
- `cd ui && npx vitest run src/features/connections
src/pages/apps/AppDetail.test.tsx src/pages/apps/AppsConnect.test.tsx`:
8 files, 55 tests pass.
- `cd ui && node ../scripts/run-tsc.mjs -b`: no errors.
- `node scripts/check-token-gates.mjs`: all gates clean. `node
scripts/check-test-budget.mjs --files
ui/src/features/connections/GoogleWorkspaceServices.test.tsx`: pass.
`node scripts/storybook-catalog.mjs`: pass.
- `pnpm verify` exits 2 (a global CI input changed:
`doc/memory/google-connector-memory.md`). Required CI supplies the broad
coverage.
- Headless Playwright against Storybook dev, `ProductionPicker` at
1280x900 (dark and light) and `ProductionPickerMobile` at 375x812: the
dialog text is only the title, the rows, the link, and Cancel /
Continue. No horizontal scroll at 375 px. The link sits under the last
row with the normal dialog gap, and the footer follows it.
- Before: see the screenshots in #21998. After: the same dialog without
the two text sections.

## Risks

- Policy risk: Google's user data policy may expect a disclosure inside
the product, before consent, that says what data the app uses and how. A
privacy policy link alone may not satisfy a Google reviewer. This is a
recorded owner decision. If a reviewer asks, restore a short statement
above the link. The memory doc and the production checklist record this
risk.
- Low code risk. The change is UI-only. Selection, requested scopes,
OAuth and saved state do not change.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with
tool use (shell, file edits, headless browser).

## 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>
2026-11-24 11:47:32 -06:00
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>
canary/v2026.1124.0-canary.852300
2026-11-24 11:41:16 -06:00
DottaandClaude Opus 5.5 11cfe0910d fix(connections): keep a finished setup checklist on screen when the app refreshes queries (#22715)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - "Set it up with your agent" screens give the person's own agent a
setup checklist to fill in, shown live on the page (#22626, AWS role
setup first)
> - Testing it end to end on staging, the agent's updates appeared
within 0.3–0.6 seconds and the page showed "Your agent set up AWS" with
the role ARN, then a few seconds later replaced it with a blank new
checklist
> - When the live connection reconnects or the tab becomes visible
again, the app refreshes every query on screen. The checklist's handoff
query refetched, found no checklist in storage (a finished one is
removed so it is never reused), and created a new one
> - This pull request makes a refetch keep the checklist the page
already has; only Start again, or a finished checklist from an earlier
visit, makes a new one
> - The benefit is that a finished setup stays on screen with its
summary until the person moves on

## Linked Issues or Issue Description

Refs #22626 (the setup checklist this fixes).

**Subsystem affected**
Connections (agent-guided setup), UI.

**Problem or motivation**
On paperclip.staging, after the agent finished, the AWS setup step
showed "Your agent set up AWS" and the role ARN to paste, then about 7
seconds later went back to "Paste the prompt into your agent" with a
new, empty checklist. The page's network log showed a second `POST
/api/companies/{companyId}/agent-setup-progress`. The person loses the
role ARN they were about to copy.

**Proposed solution**
The handoff query's fetch returns the handoff already in the cache
unless the page asked to replace it (`renew`). Creating a checklist
stays a deliberate action.

**Alternatives considered**
- Excluding the handoff key from the live reconcile
(`LIVE_EVENT_FREE_QUERY_KEYS`): covers that one caller but not any other
broad invalidation. Guarding the fetch covers them all.
- Keeping a finished checklist in storage: it would then be reused by a
later visit, which #22626 deliberately avoids (a finished checklist
takes no more updates).

## What Changed

- `ui/src/components/AgentSetupProgress.tsx`: the handoff query's
`queryFn` returns the cached handoff unless `renew` set a one-shot
`replacing` flag.
- `ui/src/components/AgentSetupProgress.test.tsx`: regression test. A
checklist finishes, then every active query is invalidated (as the live
reconcile does); the checklist is created once and "Your agent set up
AWS" with the role ARN stays.

## Verification

- New test fails on master (`create` called twice) and passes with the
fix (red/green).
- `AgentSetupProgress.test.tsx` and `AwsRoleSetup.test.tsx`: 26 passed.
UI typecheck clean.
- Staging reproduction (before this fix), paperclip.staging on 980caf1:
the agent's requests with only the prompt's token (no Paperclip sign-in)
were accepted through the Cloud front door: 401 without the token, 200
for set/update/finish, 409 for an update after finishing. The page
showed each update 603 ms, 567 ms and 326 ms after the request, then
replaced the finished checklist about 7.5 s later. To re-run on staging
after deploy.

## Risks

- Low. One query's fetch function; creation paths (first open, Start
again, earlier-visit renewal, another account) keep their tests.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, Claude in Chrome against paperclip.staging).

## 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>
2026-11-24 11:17:27 -06:00
Dotta 0731cd3afc perf(ci): Phase 2 PR CI under 4 minutes (dynamic workers, fast E2E boot, typecheck overlap, test-budget gate) (#22729)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Pull-request CI checks run on every commit before maintainers can
merge code
> - PR #22679 cut PR CI from 15–30+ minutes down toward 4.5–5.5 minutes
on 4-core runners
> - Remaining wall-clock bottlenecks sit in unsharded `workspaces-b`,
serial typecheck preparation, E2E server/UI startup, fixed Vitest worker
caps, and remaining soak and duplicated UI tests
> - This pull request adds Phase 2 optimizations across server soak
triage, typecheck DAG overlap, E2E fast boot and shard balance, dynamic
CPU-aware workers, pure-Node workspace link preflight, UI pruning, and
permanent test-budget enforcement
> - The benefit is ordinary feature PRs finish in ~3.1–3.8 minutes on
4-core runners and scale automatically to ~2.0–3.0 minutes on 8-core
runners while keeping core invariants and nightly coverage intact

## Linked Issues or Issue Description

Refs #22679

**Problem Statement**
After #22679 landed, several PR lanes still took 4.5–6 minutes on 4-core
runners (`general-workspaces-b` ran unsharded, `Typecheck + Release
Registry` waited on a serial server build before starting UI and
test-program checks, E2E shards paid full `cli onboard` + minified UI
build overhead, and Vitest worker counts did not scale with runner CPU
count).

**Proposed Solution**
Split `general-workspaces-b` across two duration-balanced shards,
overlap typecheck preparation tasks behind a shared runner-vendor node,
replace E2E `onboard` with a direct template-PG boot + unminified inline
UI build, scale Vitest/Playwright/Typecheck workers dynamically by CPU
and RAM, replace `tsx` in workspace-link preflight with pure Node, prune
redundant mocked UI tests and additional real-clock server soak suites
(still run on `master`, `release-verify`, `cloud-readiness`, and
`PAPERCLIP_CI_FULL=1`), and add a permanent test-budget policy check.

**Expected Benefit**
Brings ordinary PR CI wall-clock down to ~3.1–3.8 minutes on 4-core
runners (and ~2.0–3.0 minutes on 8-core runners) with automated
guardrails against future test-time regressions.

## What Changed

- **Server soak triage & permanent test-budget guardrail
(`scripts/ci/nightly-only-suites.json`, `rules/test-budget.mdc`,
`.greptile/files.json`, `scripts/check-test-budget.mjs`,
`scripts/check-test-budget.test.mjs`,
`.github/workflows/pr-trusted.yml`):** Expanded the PR-excluded
soak/heavy-integration manifest to 568 genuine heavy suites (preserving
100% of company isolation, authz, checkout, approval, budget,
activity-log, security, telemetry, and serialized suites on every PR)
and wired `node scripts/check-test-budget.mjs` into the `policy` job.
- **Typecheck DAG overlap & CPU/RAM scaling
(`scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`,
`scripts/__tests__/ci-typecheck-lane.test.mjs`,
`scripts/typecheck-test-programs.test.mjs`):** Moved `build server
without type checks` and `check server runtime assets` out of serial
`prepare` into parallel DAG nodes behind `prepare runner vendor`, added
`computeResourceProfile` scaling across 2/4/8-core runners, and added
missing UI/Runner consumer routing inputs (`packages/paperclip-runner/`
for `@paperclipai/ui`, `packages/adapter-utils/` for Runner test
programs).
- **E2E fast boot, dynamic workers & 8-shard rebalance
(`tests/e2e/start-e2e-server.ts`, `tests/e2e/playwright.config.ts`,
`scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`,
`.github/workflows/pr-trusted.yml`,
`.github/workflows/release-verify.yml`):** Added direct throwaway
template-PG boot (`fsync=off`), unminified inline Vite fallback build,
dynamic parallel workers (`min(4, floor(cpus/2))`), empirical `1.5x`
parallel speedup weighting across 8 shards, targeted trims to slowest
E2E specs, and hashed workspace `package.json` manifests into the
`e2e-ui-dist-v2` cache key.
- **Dynamic Vitest workers, 2-shard `workspaces-b`, and pure-Node
preflight (`scripts/ci/vitest-workers.mjs`,
`scripts/ci/workspaces-b-shard.mjs`,
`scripts/ensure-workspace-package-links.mjs`,
`scripts/ci-dependency-cache.mjs`,
`packages/db/src/test-embedded-postgres.ts`,
`.github/ci-task-matrix.json`,
`.github/actions/setup-ci-dependencies/action.yml`, `package.json`):**
Scaled Vitest workers dynamically (`4→7` general, `3→5` serialized) with
`max_connections=300` before PostgreSQL start, split
`general-workspaces-b` into 2 duration-weighted shards
(backward-compatible unsharded for release workflows), replaced `tsx`
workspace-link preflight with pure Node (~29× faster), and parallelized
`ci-dependency-cache.mjs` child queries.
- **UI Vitest worker scaling, fake timers & E2E-duplicated suite pruning
(`ui/vitest.config.ts`, 4 `maps/` files, and UI test suites):** Scaled
UI `maxWorkers` dynamically, converted real-clock sleeps in kept suites
to fake timers, removed 34 E2E-duplicated mocked jsdom suites, and
updated corresponding `maps/` prose references.

## Verification

- `node --test .github/scripts/tests/ci-plan.test.mjs
.github/scripts/tests/ci-dependency-cache.test.mjs
.github/scripts/tests/pr-dependency-cache.test.mjs
scripts/__tests__/run-vitest-stable-shard.test.mjs
scripts/__tests__/run-vitest-stable-pr-mode.test.mjs
scripts/__tests__/ci-typecheck-lane.test.mjs
scripts/typecheck-test-programs.test.mjs
scripts/__tests__/e2e-shard.test.mjs scripts/check-test-budget.test.mjs
scripts/ci/test-selection-pr-timings.test.mjs`: **160/160 PASS**
- `node scripts/check-test-budget.mjs`: **PASS** (`568` nightly suites
validated)
- `node scripts/check-maps.mjs`: **PASS** (`35 areas, 192 capability
IDs`)
- `pnpm --filter @paperclipai/ui typecheck` & `pnpm --filter
@paperclipai/db typecheck`: **PASS**
- Live CI verification runs on the new `pr-trusted.yml@master` (from
#22679) with `profile-ci` enabled to export the full job/step/file
waterfall to Honeycomb `paperclip-ci`.

## Risks

- Medium CI scope: touches workflow matrix partitioning, E2E startup,
and test runners; does not change production app runtime behavior.
- All PR-demoted soak suites continue to execute on `master`,
`release-verify`, `cloud-readiness`, local `pnpm test:run`, and
`PAPERCLIP_CI_FULL=1`.
- All new `policy` and `setup-ci-dependencies` commands keep
file-existence guards so reruns of older PR branches continue to work.

## Model Used

- Google Gemini (Antigravity swarm orchestrating specialized worker
agents with shell, file editing, and test execution tools) and Anthropic
Claude Opus (verification and optimization sub-agents).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
canary/v2026.1124.0-canary.852100
2026-11-24 10:53:19 -06:00
DottaandClaude Opus 5.5 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 18aa2b353d.

## What Changed

- New `server/src/services/native-runtime/native-plan-review-card.ts`.
It opens the Plan-mode review card for the current plan revision, unless
an explicit plan review already covers it. Only a card bound to the plan
revision is a plan review: the server card, the Codex/Claude card, or an
agent card opened with the plan target. A confirmation without a plan
target is an ordinary request: it never covers a revision, never starts
execution and is never withdrawn by this logic. Per state of the
revision's card: pending is the gate; accepted, rejected, or withdrawn
by the user count as the user's decision (the agent is asked once to
revise); withdrawn by an agent or the system, expired or failed get a
fresh card. The idempotency key is bound to the revision (and to the
card it replaces), so concurrent settles open one card. Cards bound to
an older revision are withdrawn after re-reading the plan under a lock.
One card builder serves this and the Codex/Claude plan cards. A revision
that a person wrote is not put up for review. The call that inserts the
card logs it in the activity log.
- `heartbeat/task-markdown.ts`: the native Plan-mode directive says
Paperclip asks the user to approve the saved plan, so the agent does not
open its own card. This keeps the common case at one card.
- `native-run-finalizer.ts`: when a Plan-mode run settles successfully
and does not report done, the finalizer calls the new function before it
reads the governance gate. If the card cannot be opened, the run still
settles (the error is logged) and the recovery pass opens the card
later. The new card then becomes the gate, and the task waits in review
on it (`governed_response_waiting`), as for Codex and Claude.
- `plan-mode-status.ts` + `status-arbiter.ts`: a Plan-mode run (assigned
or started by a comment) that yields a response wait with no plan to
review (no plan, or the current revision already answered) no longer
settles as a silent wait. The agent gets one continuation that asks it
to save its plan. If that also fails, the task keeps its status and gets
a recovery action with a plain-language next step
(`plan_mode_plan_not_produced`). This uses the existing bounded
incomplete-report path.
- `issue-thread-interactions.ts`: a new `afterInsertInTransaction`
create option runs only when the call inserted the card (not on an
idempotent replay).
- `recovery/service.ts`: the existing stranded-task pass opens the card
for a Plan-mode task that an older release left in this state. No new
background worker.

## Verification

- `pnpm vitest run server/src/__tests__/native-plan-review-card.test.ts
server/src/__tests__/native-plan-review-card-finalizer.test.ts`
- Red on master, green on this branch:
- Finalizer: a recovered Plan-mode run with a new revision and no card
now gets exactly one card and waits in review (master: no card,
`response_wake_waiting_for_input`).
- Finalizer: a Plan-mode run with no plan gets the bounded "save your
plan" continuation (master: silent wait).
- Recovery pass: a task an older release left without a card gets one
card, also on a second pass, with no agent wake (master: no card).
- Table-driven tests: every way a Plan-mode run can settle (no plan;
plan with no card; agent card; current, historical and dismissed
questions; each governed card kind and status; a card by someone else;
Request changes with and without a new revision) leaves at most one plan
review card, or the "save your plan" continuation, and a repeat settle
changes nothing. Arbiter table: assigned and comment-started runs, with
and without a card, and the second miss.
- Also covered: an agent-opened card means no second card; concurrent
and repeated settles from several runs give one card; after Request
changes, the next revision gets a new card and the rejected card stays
rejected; a pending card for an older revision is expired and cannot be
accepted; Standard-mode response waits are unchanged; the card that
Codex and Claude open from their plan event stays the only card; a
person's own plan edit is not put up for review.
- `pnpm verify` passed for the selected suites.
- Not run live. The local Antigravity instance runs older code and was
not restarted for this change.

## Risks

- Low to medium. The change only acts on tasks in Plan mode. Standard,
Ask and conversation turns are not changed, except that the card
function can also run for a Plan-mode conversation run that has an
unreviewed plan.
- A Plan-mode run that reports done is not changed.
- An agent card without a document target is treated as covering the
revision when it was created after the revision. A plan card from Codex
or Claude has a target and is matched on that.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with tool use
(shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [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>
2026-11-24 00:32:12 -06:00
DottaandClaude Opus 5.5 7d26bdaa42 feat(antigravity): verified Antigravity CLI route for native swarm (inert) (#22731)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Google Antigravity agents run through the Paperclip Runner's ACP
driver, on the registry ACP server 1.5.2
> - Google's native `/swarm` (a coordinator that starts helpers and a
verifier) exists only in the Antigravity CLI (`agy acp` 1.5.15), which
#22728 pinned and provisions
> - The CLI is a signed binary, so the registry server's owned admission
patch cannot exist there. Paperclip needs another way to verify the
session before a billable swarm starts, and a governed way to run, stop
and finish it
> - This pull request adds that CLI route to the Runner: a verified ACP
client, the checks it does in place of the patch receipt, process setup,
failure classification and a deterministic fake CLI for tests. Nothing
selects the route yet, so this PR does not change behavior
> - The benefit is that the next PR only has to add trusted `/swarm`
detection and an experimental flag

## Linked Issues or Issue Description

Refs #22728, #22701, #22727

**Subsystem affected**
Paperclip Runner, ACP driver, Google Antigravity.

**Problem or motivation**
A user who writes `/swarm <request>` to a Google Antigravity agent
should get a real native swarm in the task's workspace. The registry ACP
server does not offer `/swarm`. The Antigravity CLI does, but its
permission prompts for helpers never reach an ACP client, its model
selector groups models into a family plus a thinking level, a turn can
end while helpers still run, and some provider refusals arrive as
ordinary text that ends the turn "successfully".

**Proposed solution**
Run a trusted swarm turn on the pinned CLI through a small driver-owned
ACP client that verifies every setting it depends on, confines helpers
to the task workspace through the CLI's `auto` mode, waits for helpers,
checks the workspace after the turn, and reports typed failures in plain
language.

## What Changed

- `antigravity-swarm-guard.ts`: the checks that replace the registry
server's admission receipt. The driver verifies and records:
- agent identity and version from `initialize` equal the pinned CLI
(`Antigravity ACP Server` 1.5.15), and the CLI accepts
`systemPrompt.append`;
- the `session/new` request uses the task workspace as `cwd`, carries
Paperclip's instructions, and passes exactly one MCP server: the
runner-owned Paperclip bridge;
  - session mode reads back as `auto` after `session/set_mode`;
- model family plus thinking level read back as the agent's configured
model after `session/set_model` (for example `gemini-3.8-flash` + `low`
for `gemini-3.8-flash-low`);
- none of those change later in the session; a helper started with
workspace `share` or `branch` stops the swarm.
Any difference fails closed with a typed error and a plain message. A
sign-in without `auto` mode is reported as "swarm not available".
- `antigravity-swarm-runtime.ts`: an `AcpxRuntimePort` for the CLI
route.
- One fresh session per run. It never calls `session/load`, so Retry
after a lost process starts a fresh swarm in the same workspace.
- Prompts with `/swarm <task>` (the route is reached only through the
trusted mode). At most one swarm per run.
- Does not settle on the first `end_turn` while helpers may still run:
when helpers were started and the coordinator did not wait on the board
afterwards, it sends one bounded "wait for the helpers" follow-up (20
min default; timeout is a typed failure).
- Lists the task folder before and after the turn (asynchronous, bounded
on every visited entry, stopped with the turn, skipping `.git`,
`node_modules`, `.venv`, `__pycache__`) and shows the real changes. It
never infers required files from what helpers or the coordinator say
(helpers can misreport). Done still requires the hand-in through
Paperclip's finish tool, which the server's completion contract
enforces.
- Stops the swarm when a visible tool call would change a path outside
the task folder (`antigravity-swarm-paths.ts`): file-tool locations and
path arguments, and shell write targets (redirects, `tee`,
`cp`/`mv`/`ln` destinations, `rm`, `mkdir`, `touch`, `sed -i`, `dd
of=`), resolved relative to the task folder with `..`, `~`, `$HOME` and
symlinks of existing parents. This is a best-effort **detector, not a
boundary**: it turns visible, unambiguous outside writes into a clear
failure, uses a quote-aware lexer, and yields no finding for anything
ambiguous (command substitution, heredocs, `eval`, `cd`, interpreters,
unknown variables), so it never stops a correct swarm on a guess. It
does not prove confinement.
- Stop is installed before the first await of a turn and re-checked
before every prompt; a Stop during admission retires the CLI at once. A
test injects Stop at each await point (launch, initialize, session/new,
set_mode, set_model, workspace listing, helper wait).
- A saved conversation from the other Antigravity route (swarm ↔
ordinary turn) is refused as `ANTIGRAVITY_SAVED_STATE_INCOMPATIBLE`, the
existing typed refusal that makes the server open a fresh conversation
instead of showing Retry. So an ordinary follow-up after a swarm, a
later second `/swarm`, and Retry after a killed swarm all start a fresh
session.
- Approves only Paperclip's own tool server at a permission prompt;
every other prompt is outside the task folder in `auto` mode, so it is
refused and shown as "Blocked: …". Helper actions that the CLI timed out
are shown as blocked.
- Stop sends `session/cancel`, then retires the CLI's process group and
confirms no helper process survives.
- Usage is the coordinator's reported total, recorded as soon as each
prompt result arrives (also for failed or stopped turns), labelled as
including the helpers and not itemised.
- A settings change outside a turn becomes a typed failure that fails
admission or the next turn and retires the CLI process group; no handler
error can escape into the event loop.
- Refusals that arrive as text (402 credits, 429 quota, sign-in) become
typed provider failures.
- `antigravity-swarm-presentation.ts`: turns the coordinator's `swarm` /
`read_board` / `post_message` calls into steps such as "Started helper
writer-a: Write a.txt …", "Checked on the helpers", and drops
terminal-only hints. No raw ids.
- `antigravity-swarm-route.ts` and small hooks in `runtime-host.ts`,
`acpx-runtime-adapter.ts` and `provider-mode.ts`: the `antigravity`
provider mode accepts only `swarm`; for that mode the host installs the
pinned CLI (`resolveAntigravityCliLaunch` with `--gemini-dir <run
credential home>/antigravity-cli`, the stable endpoint
`https://cloudcode-pa.googleapis.com`, `--disable-telemetry`,
self-update off), skips the registry credential staging, and refuses
API-key connections and unpinned platforms with a plain message.
- `test-fixtures/antigravity-cli/fake-agy-acp.mjs`: a deterministic fake
`agy acp` that replays the spike's message shapes (success, live helpers
at `end_turn`, hang, blocked, misreport, workspace escape, cancel with a
real helper process, process death, 402 and 429 refusals as text,
identity/mode/model mismatches).

### Host policy inputs on the swarm route

| Input the registry route honours | Swarm route |
|---|---|
| Read-only (Plan mode) task policy | Refused before the CLI starts:
"Swarm is not available while planning" |
| Saved session / `restoringSession` (resume) | Refused as
saved-state-incompatible: the server opens a fresh conversation; a swarm
never reloads |
| Runner-owned Paperclip tool bridge | Enforced: the only MCP server,
verified in `session/new` |
| Other assigned tool servers (stdio MCP bindings) | Refused with a
plain message, never silently dropped |
| Delegation tools | (follow-up PR) removed from the bridge catalog for
a swarm turn |
| Workspace root (`cwd`), `assertWorkspaceHeld` | Enforced: `cwd` is the
task workspace, re-asserted at spawn; helpers must use `inherit` |
| Additional directories | Not passed (none are granted) |
| Credential/env scoping | Private `--gemini-dir`; registry credentials
and API keys removed from the launch environment; macOS HOME is the OS
user's home for the keychain sign-in |
| Provider-lifetime fence, process group | Enforced: verified command
lease with the lifetime fence; Stop and close retire the whole group |
| Permission mode | Replaced by the verified `auto` session mode; other
prompts are refused and shown as blocked |
| Model and thinking level | Enforced and read back
(`session/set_model`), checked for later changes |
| Abort signal | Honoured during admission and turns |

## Verification

- `pnpm --filter @paperclipai/paperclip-runner exec vitest run
src/drivers/acpx/antigravity-swarm-guard.test.ts
src/drivers/acpx/antigravity-swarm-presentation.test.ts
src/drivers/acpx/antigravity-swarm-runtime.test.ts
src/drivers/acpx/antigravity-swarm-route.test.ts`: 36 passed. Each file
was red first (module missing); the route-selection tests were also
shown red with the hooks reverted (2 failed) and green with them.
- `pnpm --filter @paperclipai/paperclip-runner exec vitest run
src/drivers/acpx/`: 117 files, 2017 passed, 9 skipped.
- `tsc -p tsconfig.json` and `tsc -p tsconfig.test.json` for the runner
package: no errors in the changed files.
- `pnpm verify` asked for broader coverage (the fixture is a broad
input); required CI supplies it.
- Live, no product code: against the real CLI 1.5.15 with the owner's
existing sign-in, `session/new` accepted the Paperclip bridge as an HTTP
MCP server with a bearer header (it called `initialize` and
`tools/list`), and `session/set_model gemini-3.8-flash-low` read back as
`gemini-3.8-flash` + `low`. One prompt returned `⚠ RESOURCE_EXHAUSTED
(code 429)` as text with `end_turn`; that shape is now a test case.
- Not run live: a full swarm through Paperclip. That proof belongs to
the follow-up PR, which turns the route on.

## Risks

- Inert: no server code sets the `swarm` mode yet, so no turn reaches
this route.
- When enabled: helpers act under Antigravity's `auto` mode. What
confines them is the CLI's own policy: file-tool writes outside the
workspace are blocked (60 s timeout, seen in the spike), and its shell
sandbox allows the workspace **plus temp directories**. Helper tool
calls never reach an ACP client, so Paperclip cannot see or block a
helper's shell command, and helper approvals are not possible.
- **Paperclip does not confine the CLI process tree on a local
computer.** Paperclip's local process sandbox
(`adapter-utils/local-process-sandbox.ts`) is used only by the classic
Claude and Codex local adapters, not by Runner ACP harnesses, so it does
not apply here on macOS or Linux. The outside-path check covers only the
coordinator's visible calls. This is why the feature stays experimental,
off by default, local only, and why the activity log says helper actions
are auto-approved.
- On macOS the CLI reads its Google sign-in from the login keychain
through the real HOME, so this route uses the sign-in of the CLI on the
computer, not Paperclip's stored Google connection. All CLI state stays
in the private `--gemini-dir`.
- Google's consumer terms have a clause about third-party tools that
access the service. A legal read is pending. This PR does not claim
compliance.
- Usage under-reports nothing that Google reports, but it cannot be
split per helper.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell,
file edit) in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes (docs
and the qualification ledger come with the follow-up PR that enables the
route)
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1124.0-canary.851900 nightly/v2026.1124.0-nightly.0
2026-11-23 23:37:57 -06:00
DottaandClaude Opus 5.5 18aa2b353d feat(antigravity): /plan selects Plan mode and keeps Antigravity read-only while planning (#22727)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Plan mode lets a person ask an agent for a plan, review it as the
task's Plan document, and accept it before any work starts
> - People who use Google Antigravity agents type `/plan <request>`, as
they do in other agent tools. Paperclip sent that text to the agent, and
#22701 correctly neutralised it, so nothing happened
> - An Antigravity run in Plan mode was also not read-only: the agent
could still edit files and run commands while it "planned"
> - This pull request makes a leading `/plan` in the composer select
Plan mode, and keeps an Antigravity Plan-mode run read-only at its
permission prompt
> - The benefit is that `/plan` with an Antigravity agent gives the
normal Paperclip plan flow (Plan document, accept, then execution on the
same task), and planning cannot change the workspace

## Linked Issues or Issue Description

Refs #22701

**What happened?**
A person wrote `/plan add greeting.txt` to a Google Antigravity agent.
The agent did not plan. In Plan mode the Antigravity agent could still
edit files and run commands.

**What did you expect?**
`/plan <request>` starts Plan mode. The agent researches and proposes a
plan in the task's Plan document. It does not change files until the
person accepts the plan.

**Steps to reproduce**
1. Assign a task to a Google Antigravity agent.
2. Write `/plan Add a file greeting.txt containing hello`.
3. See that the task stays in Auto mode, and that the agent creates the
file.

## What Changed

- Task composer: a leading `/plan` in a comment or in a new task selects
Plan mode and sends the rest of the message without the command. `/plan`
alone only switches the mode. The slash menu offers "Plan". A `/plan`
anywhere else in the message (quoted, pasted, fenced, mid-sentence)
stays ordinary text and does not change the mode. This is the typed form
of the existing Plan mode control, so it works the same for every agent.
- Antigravity runner (`antigravity-plan-mode.ts`, wired in
`acpx-runtime-adapter.ts` and `runtime-host.ts`): when Paperclip runs an
Antigravity task in Plan mode (the existing read-only task policy), the
permission prompt fails closed. It allows only (a) the 1.5.2 server's
built-in research tools (file read, search, directory listing, page
read), named by the exact `Run <tool>?` prompt title, when the reported
kind also matches that tool, and (b) the tools the runner's own
Paperclip bridge registered for this run, on the runner-owned server
named `paperclip`. The provider's reported kind alone never grants a
read, and no other MCP server is trusted, runner-owned or not. It
refuses file edits, terminal commands and everything else. Paperclip's
server applies its Plan-mode rules to its own tools, and the agent
writes the Plan document through them.
- Composer command parsing moved to
`ui/src/components/task-chat/composer-commands.ts`. `/goal` and `/plan`
both use the shared rule. Both submit paths use one `/plan` decision: a
bare `/plan` sends (in Plan mode) only when an attachment can be sent
without text; otherwise it only selects Plan mode. A composer without
Plan mode (the dashboard chat starter) keeps `/plan` as text.
- Follow-up, not in this PR: the Kimi read-only gate
(`kimiReadOnlyPermissionAllowed`) trusts every runner-owned MCP server
by title prefix. It should get the same binding to the Paperclip
bridge's registered tools.
- No change to the #22701 guard. Every `/plan`, `/logout` and `/usage`
that would reach the Antigravity server is still neutralised.
- No change to the Antigravity admission patch, profile or closure
digests. No shared contract change.

### Why not the native `/plan` of Antigravity 1.5.2

I checked the pinned 1.5.2 server and SDK sources and ran it live:

- The server has no plan session mode (only `default`, `auto_edit`,
`yolo`) and no plan config option. Its only route is the `/plan` text
command, which it turns into an SDK slash-command object.
- Live on 1.5.2 (Google sign-in, `gemini-3.8-flash-low`), a task with
`Please /plan this ...` reached the model as
`Please/BuiltinSlashCommandName.PLAN this ...`. The SDK sent the enum's
string form instead of `plan`, so the harness did not enter planning
mode. Over 61 native steps (about 5 minutes) the agent wrote no plan
artifact, ran terminal commands, and searched the file system for that
unknown name. I stopped the run.
- A working native path needs a change inside the runtime (for example
in the owned admission patch), which re-pins the closures for every
platform and needs re-qualification. This PR does not do that.
Paperclip's own Plan mode gives the user-visible result now, with no
re-pin.

### Source of trust for slash commands (reused by `/swarm`)

- `parseLeadingUserCommand(text, allowlist)` in
`packages/shared/src/leading-user-command.ts` is the one rule. It
returns `{ command, argument }` or `null`.
- Trusted text: only what the signed-in user typed and submitted in the
task composer. That is a comment body or the body of a new task.
Conversations (chat) do not use it for `/plan`.
- Never trusted: agent comments, chat or connector messages, API-posted
text, issue text written by someone else, quoted or pasted parts, and
every prompt Paperclip builds for an agent. These stay text, and the
#22701 guard still neutralises any native command in them.
- Inside trusted text, only a command at the very start counts: optional
whitespace, `/name`, then whitespace or the end. The name is exact and
lower-case and must be in the allowlist. Only `plan` is enabled.
Whitespace follows the Antigravity server's Python rules (U+001C-U+001F
count; U+FEFF does not).
- A recognised command becomes a structured action (here: Plan mode). It
never reaches an agent as command text.
- Tests cover: leading whitespace and newlines, a command not at the
start, quoted, fenced, forwarded and wrapped content, a neutralised
command, case, `/planning`, `/plans`, paths and URLs, Python vs
JavaScript whitespace, and the allowlist.

## Verification

- `pnpm --filter @paperclipai/paperclip-runner exec vitest run
src/drivers/acpx/antigravity-plan-mode.test.ts
src/drivers/acpx/acpx-runtime-adapter.test.ts
src/drivers/acpx/antigravity-native-commands.test.ts
src/drivers/acpx/antigravity-admission.test.ts`: 250 passed.
- `pnpm --filter @paperclipai/shared exec vitest run
src/leading-user-command.test.ts`: 8 passed (red first: module missing).
- `pnpm --filter @paperclipai/ui exec vitest run
src/components/task-chat/TaskChatComposer.test.tsx
src/components/MarkdownEditor.autocomplete.test.tsx`: all passed
(TaskChatComposer 155).
- Red before the fix: the adapter test showed an Antigravity Plan-mode
run approved a file write and a terminal command (`allow_once`), and the
four composer `/plan` tests failed. The negative test (a `/plan` inside
the message stays text) passed before and after.
- Runner and UI typecheck pass (`tsc --noEmit`; the UI's only errors are
the existing ungenerated Storybook catalog files).
- `pnpm verify` returned exit 2 (runner files outside the local test
graph), so required CI supplies the broad coverage.
- Live, on THIS branch: a local instance running this branch, Google
sign-in, `gemini-3.8-flash-low`, driven in the browser through the task
composer:
1. `/plan Create a file named plan-proof.txt containing the single line
OK` in a new task: the task was created in Plan mode with the command
removed. Plan run 3 min 34 s, terminal state **succeeded** (the agent
handed in through `paperclip_finish`; run result accepted, waiting for
plan approval). The Plan document and a Confirm / Request changes card
appeared. One `ls -la` was refused by the read-only gate. No file was
written.
2. Request changes ("Name the file plan-proof-2.txt instead."): revision
run 28 s, succeeded. Plan document revision 2 named the new file; a new
Confirm / Request changes card appeared. Still no file.
3. Confirm: execution run 55 s, succeeded; task Done; `plan-proof-2.txt`
contains exactly `OK` plus a newline.
4. Normal task whose text contains a pasted `"we usually /plan things
like this first"`: created in standard mode, text unchanged; run 68 s,
succeeded, Done; `negative-proof.txt` = `NEG`; no refused tool call.
5. Dashboard "Start a chat" box: NOT run live. The box renders only with
an experimental instance setting that is off on this instance, and I did
not change instance settings. A unit test covers it (a composer without
Plan mode keeps `/plan` as text).
6. Stop during a Plan-mode run: the run was cancelled about 1 s after
Stop and did not revive (no new run for over 3 min); no file. Killing
only the native Antigravity server process mid Plan-mode run: the run
failed with a provider error, showed "Continuing automatically", and a
continuation run started 36 s later and settled (succeeded, 3 min 17 s,
response wake). No duplicate comments; the Plan document has one
revision; no file written; the gate refused one shell command in each
run.
- Found live, NOT fixed here: in the recovered run of step 6 the model
settled with "waiting for plan review" but did not open the Confirm card
(in steps 1 and 2 it did). Paperclip creates that card automatically
only from a harness's own plan proposal (Codex, Claude). For Antigravity
it depends on the agent. Recommended follow-up: when a Plan-mode run
settles with a new plan revision and no pending plan confirmation, the
server opens the card itself.
- To be clear: this is not Antigravity's native plan mode. Native plan
mode on runtime 1.5.2 does not work (see above). This PR gives
Paperclip's Plan mode, started by a trusted `/plan`, with the
Antigravity run held read-only.

## Risks

- Low to medium. Plan mode for Antigravity now refuses terminal
commands, so the agent researches with its file read and search tools. A
planner that relied on shell reads must use those tools instead.
- Google Workspace accounts whose admin policy lets terminal commands
run in a sandbox without a prompt skip the permission prompt for
commands. That path cannot be blocked here. Personal Google accounts and
API keys always prompt.
- `/plan` as the first word of a message now selects Plan mode for every
agent. To send the literal text, write `\/plan` or put other text first.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell,
file edit, browser automation not used), in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1124.0-canary.851800
2026-11-23 22:33:09 -06:00
DottaandClaude Opus 5.5 b6f1b7b4af feat(antigravity): pin and provision the Antigravity CLI route (#22728)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner launches native agent harnesses, including Google
Antigravity, from pinned and verified distributions
> - Antigravity's native `/swarm` exists only in Google's Antigravity
CLI (`agy acp`), not in the registry ACP server 1.5.2 that Paperclip
pins today
> - Before a driver can use the CLI, Paperclip needs a pinned, verified
way to install it and to launch exactly those bytes
> - This pull request adds the CLI distribution pin, a setup command and
a launch resolver. It is the first step of a short series. Route
selection, `/swarm` detection and the driver follow in later pull
requests
> - The benefit is that the later driver work starts from a fixed,
digest-checked binary, and the existing Antigravity route does not
change

## Linked Issues or Issue Description

**Subsystem affected**
Runner native provider distributions (`packages/paperclip-runner`) and
the `paperclipai runtime setup` CLI command.

**Problem or motivation**
Google documents `/swarm` for the Antigravity App and the Antigravity
CLI only. The registry ACP server 1.5.2 does not offer it. To make
`/swarm` work, Paperclip must run `agy acp`. The CLI is a signed Go
binary with no patch point, so the owned admission patch cannot apply.
Integrity must come from pinned archive and executable digests. Google
publishes no redistribution licence for the CLI, and the bucket's object
immutability cannot be checked anonymously. So Paperclip must fetch the
CLI from Google at setup time and verify it against digests that are
pinned in the repository.

**Proposed solution**
A sibling declaration, `antigravity-cli-distributions.json`, pins 1.5.15
(build `1.5.15-5514532022517760`) for darwin-arm64, linux-x64 and
linux-arm64. `paperclipai runtime setup antigravity-cli` downloads,
verifies, extracts and installs it beside the existing runtime.
`resolveAntigravityCliLaunch()` returns the launch through the existing
sealed native store.

**Alternatives considered**
- Add the CLI to `antigravity-distributions.json`. That file feeds the
generated profiles, the Rust profile table, release attestations and the
provider pack. A sibling file leaves all of them unchanged.
- Bundle the binary in the provider pack or image. Not cleared: there is
no redistribution licence.

**Roadmap alignment**
This is experimental provider work behind later route selection. It
changes no qualified behavior.

## What Changed

- `packages/paperclip-runner/antigravity-cli-distributions.json`: the
new pin. For each platform it records the Google URL, archive format and
size, archive SHA-512 and SHA-256, the single tar member
(`antigravity`), the executable name (`agy`), the executable SHA-512,
and the closure entry (SHA-256 and size) that the sealed store uses. It
also pins the leading arguments (`acp`) and the environment
`AGY_CLI_DISABLE_AUTO_UPDATE=1`.
- `scripts/materialize-antigravity-cli-distribution.mjs`: reads only the
checked-in declaration and accepts only Google's versioned bucket path.
It enforces the pinned size while it streams the download, refuses
redirects, and checks SHA-512 and SHA-256. It reads a strict one-member
tar (a regular executable, no links, no extra members, zero padding
only) and checks the executable's SHA-256 and SHA-512. It publishes the
directory with an atomic rename. Every failure gives a plain message
that ends "Nothing was installed."
- `scripts/provision-antigravity-cli.mjs`: installs to
`~/.paperclip/runtimes/antigravity-cli/<target>/<closure>`. A re-run
verifies the installed copy in place with no download. A copy that no
longer verifies is retired and replaced from a fresh verified download.
- `scripts/materialize-antigravity-distribution.mjs`: exports its
existing owned-file helpers so the new route reuses them. There is no
behavior change.
- `src/drivers/acpx/antigravity-cli-installation.ts` and
`antigravity-cli-pins.ts`: `resolveAntigravityCliLaunch({ arguments?,
platform?, architecture?, home? })`, exported from the package. It
returns `version`, `build`, `target`, `commandDigest`, the exact
`arguments` (`acp` followed by the driver's), the frozen pinned
`environment`, `environmentFor(base)`, and a `VerifiedAcpxInstallation`
from `verifyNativeAcpxInstallation` (sealed store, per-launch executable
hash, `storeFamily: "antigravity-cli"`). Errors are
`AntigravityCliRuntimeError` with the codes
`ANTIGRAVITY_CLI_UNSUPPORTED_PLATFORM` and
`ANTIGRAVITY_CLI_RUNTIME_MISSING`. Both are permanent. The pins are
compiled in, and a test keeps them equal to the JSON.
- `cli/src/commands/runtime.ts`: adds `paperclipai runtime setup
antigravity-cli` through a small shared resolver and runner for vendored
provisioners.
- The bundle step builds `dist/cli/provision-antigravity-cli.{js,cjs}`
and copies the JSON pin to `dist/`. No binary goes into npm, the
provider pack or an image.
- Docs: a README section on the resolver, and a note in
`doc/plans/2026-11-22-antigravity-qualification.md`. The note says the
CLI route is experimental, is fetched at setup time, and why.

Pinned values (downloaded once from Google into an empty scratch
directory. Each archive matched Google's published manifest. The Linux
binaries were not run):

| Target | Archive URL (under
`https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.15-5514532022517760/`)
| Archive bytes | Archive SHA-512 | Executable bytes | Executable
SHA-256 |
|---|---|---|---|---|---|
| darwin-arm64 | `darwin-arm/cli_mac_arm64.tar.gz` | 86,166,538 |
`b03a841e…` | 229,617,904 | `8097b24d…` |
| linux-x64 | `linux-x64/cli_linux_x64.tar.gz` | 101,464,790 |
`af3f0be5…` | 273,879,752 | `7b004d26…` |
| linux-arm64 | `linux-arm/cli_linux_arm64.tar.gz` | 92,373,221 |
`d64ad759…` | 256,660,144 | `497580a7…` |

The darwin-arm64 executable matches the copy that was already verified
(Developer ID Application: Google LLC, team `EQHXZ8M8AV`). The full
digests are in the JSON.

## Verification

- Red then green: `node --test
packages/paperclip-runner/scripts/materialize-antigravity-cli-distribution.test.mjs`
(9 tests). It uses in-memory tar.gz fixtures and makes no network calls.
It covers the pins, a refused declaration, tar strictness, a verified
install with an idempotent re-run, a tampered archive, truncation, a
wrong-platform archive, an executable digest mismatch, the size
enforcement and redirect refusal of the download path, the repair of a
modified install, and an unsupported host.
- Red then green: `vitest run
src/drivers/acpx/antigravity-cli-installation.test.ts
src/drivers/acpx/antigravity-cli-pins.test.ts`. The resolver spawns a
fixture `agy` from the sealed store with `acp` plus the driver's
arguments and the pinned environment. It also covers a modified install,
a missing install that names the setup command, an unsupported platform,
and invalid arguments.
- Red then green: `cli` `vitest run src/__tests__/runtime-setup.test.ts
src/__tests__/runtime.test.ts`.
- Existing suites: `vitest run src/drivers/acpx/antigravity*
native-distribution-integrity* candidate-admission.antigravity-release
capability-profiles.antigravity-release` and `node --test
scripts/build-verified-provider-entrypoints.test.mjs` (includes the
registry-server materialize and patch tests),
`acpx-release-attestations`, `release-provider-pack`,
`antigravity-provider-pack-smoke`, `installed-package-pack`,
`candidate-provider-pack`. All pass. Under full parallel load, two
existing timing-sensitive tests (`probe-antigravity-metadata` SIGKILL
shutdown, `antigravity-acpx-runtime` model admission) failed once and
passed when run alone. This change does not touch those modules.
- Typecheck: `tsc --noEmit` for `packages/paperclip-runner` and `cli`.
- Real archives, local: materialize succeeded for all three real
archives against the real pins. The Linux binaries were extracted and
hashed only. The darwin build with a linux-x64 archive failed closed
with "Nothing was installed."
- End to end on macOS ARM64 with a scratch `HOME`: the bundled
`dist/cli/provision-antigravity-cli.cjs` downloaded from Google and
installed in 10.7 s. The re-run printed "Verified" with no download.
`resolveAntigravityCliLaunch({ arguments: ["--help"] })` ran the real
`agy acp --help` from the sealed store copy (exit 0, 1.4 s including
first store admission). `codesign --verify --strict` passes on the
installed copy.
- `pnpm verify` returned exit 2 (the README is a broad input). Required
CI supplies the broad coverage.
- Not run: the Linux binaries (no execution on this Mac), a Linux host
setup, and the full local suite.

## Risks

- Low risk. Nothing selects or launches the CLI route yet. The existing
registry-server pins, the admission patch, profile digests and
`acpx-profiles.json` are unchanged.
- The provider pack and the server's vendored Runner now also carry the
small provisioner script and the JSON pin (no binary), like the existing
Antigravity provisioner.
- Bucket immutability is not proven. If Google replaces an object at the
versioned path, setup fails closed on the digest. It does not install
different bytes.
- macOS code-signature team checks are not added. The repository has no
such hook, and the exact executable digest is a stronger pin.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Anthropic Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with
tool use (shell, file edits) and extended reasoning.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1124.0-canary.851700
2026-11-23 22:19:03 -06:00
Dotta 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
canary/v2026.1124.0-canary.851600
2026-11-23 21:11:57 -06:00
DottaandClaude Opus 5.5 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>
2026-11-23 20:35:17 -06:00
DottaandClaude Opus 5.5 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>
2026-11-23 20:34:27 -06:00
calvindomenicoandPaperclip 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>
2026-11-23 20:26:57 -06:00
Oke Iyanuoluwa Enoch 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
2026-11-23 20:24:29 -06:00
DottaandClaude Opus 5.5 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 4434d12e), one stack
reports `source_scope_not_git_source` x30 (29 of them also
`overlapping_workspace_requires_maintenance`), and another reports it
x3.

**Expected behavior**
The online move accepts what the offline move accepts for the same data,
with a fence that is checked again under lock at publication. Offline
copies a folder with no repository as files, whatever its records say
about Git.

**Steps to reproduce**
1. Create a managed project folder with three task records that point at
it.
2. Set `repoUrl` and `branchName` on the records. Do not create a
repository in the folder.
3. Run `inventoryRemoteWorkspaceMigration` online. It reports
`online_workspace_source_scope_unproven` with `not_git_source`.

**Why it is safe**
- The source locks come from the folder's physical path, not from the
record's Git fields. Writers to the folder take the same project or task
lock.
- The ordinary capture runs with `requireNoGit`. If a `.git` entry
appears during the capture, the capture fails and nothing is published.
- The ordinary proof still checks every member: provider, task binding,
strategy, status, restoration state, foreign aliases. The publication
checks the scope again under lock.
- The published source keeps the record's repository URL and base ref,
the same as offline.

## What Changed

- `explainOnlineOrdinarySource` no longer skips a `local_fs` record
because it has `repoUrl` or `branchName`. It still skips such a record
when the folder has a `.git` entry, so real checkouts keep the Git path
and its cost does not change.
- `ordinaryMemberUnproven` accepts a `local_fs` member with `repoUrl` or
`branchName`. Non-`local_fs` members are still `ordinary_member_git`.
- A member with an unfinished Git cache expiration is now
`member_git_expiration_pending` on the ordinary path too. The Git path
already refuses it.

## Verification

- Rebased onto `origin/master` after #22718 and #22721. Both behaviours
are kept: members are compared by physical path (#22721), and a
`local_fs` member may carry Git fields when the folder has no repository
(this PR).
- Red on `origin/master` (b908678ea3): the never-cloned folder reports
`not_git_source` and is not eligible. The expiration guard test also
reports `not_git_source`.
- Green with the fix. The never-cloned folder is eligible, its source is
`ordinary` with all three records, and the migration publishes. The
published source is `{ kind: "git", repoUrl, ref: "main" }`. The
restored archive holds the saved file, and the local folder is
unchanged. The member with an unfinished expiration stays blocked with
no workspace operation.
- `cd server && npx vitest run
src/services/remote-workspace-migration.test.ts
src/services/remote-workspace-online-source.test.ts
src/services/remote-workspace-cohort-migration.test.ts
src/services/remote-workspace-migration-concurrency.test.ts
src/services/online-durable-data-migration.test.ts
src/services/remote-workspace-snapshot-archive.test.ts`: 6 files, 532
tests passed after the rebase (embedded PostgreSQL).
- `cd server && pnpm typecheck`: passed.

## Risks

- Medium. More folders become movable online. The fence and the capture
are the same ones that ordinary folders already use.
- A folder with a `.git` entry that is not a repository still goes to
the Git path and stays blocked.
- A `local_fs` record at an unmanaged folder with no repository now
reports `ordinary_root_unmanaged` instead of `git_checkout_missing`
(#22718), because the unmanaged root is the reason it stays blocked. A
`git_worktree` record in the same state still reports
`git_checkout_missing`. The test covers both.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 20:06:05 -06:00
DottaandClaude Opus 5.5 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 4434d12e), one stack
reports `overlapping_workspace_requires_maintenance` x6 with no
`source_scope_*` code. Two other stacks report
`source_scope_not_git_source` x30 and x3.

**Expected behavior**
Each blocked workspace names the exact cause. An overlap names how the
paths overlap and why the source scope is unproven. A missing Git source
says if the directory has a `.git` entry that is not a repository, or no
repository at all.

**Steps to reproduce**
1. Create a workspace at an unmanaged path, and a second task workspace
in a subfolder of it.
2. Run `inventoryRemoteWorkspaceMigration` online for either workspace.
3. The result has only `overlapping_workspace_requires_maintenance`. It
has no detail and no `sourceScopeUnproven`.

**Why no detail was emitted**
The inventory reported `sourceScopeUnproven` only when the workspace
needs a proven source scope (`requiresOnlineWorkspaceSource`). A non-Git
directory outside the managed roots does not need one. The overlap check
then blocks it, and nothing names the cause.

## What Changed

- `workspaceMigrationLayoutBlockers` returns a state with each overlap:
`same_directory`, `nested_workspace`, `enclosing_workspace` or
`imported_child_unrecorded`. The inventory adds it as
`overlapping_workspace_requires_maintenance:<state>` in `details`. The
online pass already reports details as `workspaces:<reason>:<state>`.
- The inventory now reports `sourceScopeUnproven` also when the
workspace is blocked by an overlap. Example: `ordinary_root_unmanaged`.
- `not_git_source` is now one of two codes:
- `git_marker_not_repository`: the directory has a `.git` entry that is
not a readable repository.
- `git_checkout_missing`: the record says Git (repository URL, branch or
worktree strategy), but the directory has no repository.
- The `reasons` list does not change. No rule changes: every case that
was blocked stays blocked.

## Verification

- Red on `origin/master` (b908678ea3): the four new or changed
assertions fail. The overlap result has no `details` and no
`sourceScopeUnproven`. The Git fragment and the declared Git record
report `not_git_source`.
- Green with the fix: `cd server && npx vitest run
src/services/remote-workspace-migration.test.ts
src/services/remote-workspace-online-source.test.ts
src/services/remote-workspace-cohort-migration.test.ts
src/services/online-durable-data-migration.test.ts
src/services/remote-workspace-migration-concurrency.test.ts`: 5 files,
392 tests passed (embedded PostgreSQL).
- `cd server && pnpm typecheck`: passed.

## Risks

- Low risk. Only names change. The set of blocked workspaces and the
`reasons` list do not change.
- The online pass reports one more deferral key per overlapping
workspace
(`workspaces:overlapping_workspace_requires_maintenance:<state>`). This
is the same form that #22696 uses.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1124.0-canary.851000
2026-11-23 19:42:00 -06:00
HisarWebandClaude Opus 5.5 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>
2026-11-23 19:41:25 -06:00
DottaandClaude Opus 5.5 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 4434d12e), one stack
reports `source_scope_ordinary_member_locator_mismatch` x26.

**Expected behavior**
A managed folder moves online when every record that points at it is
fenced. The offline move captures the same folder for each record. The
online move must accept the same data, never more.

**Steps to reproduce**
1. Create a managed project folder with three task records that point at
it.
2. Change one record's `cwd` and `providerRef` to a symlink to the
folder, or add a trailing slash.
3. Run `inventoryRemoteWorkspaceMigration` online for another record. It
reports `ordinary_member_locator_mismatch`.

**Why it is safe**
- The online proof already finds members by physical path
(`physicalPath`, which resolves symlinks).
- `workspaceSourceIdentities` takes source lock keys from the canonical
path. A writer that uses the other spelling takes the same project or
task lock.
- Each member's lifecycle lock is still held. The publication still
checks the source scope again under lock, so a retargeted symlink
changes the scope and blocks the move.

## What Changed

- `ordinaryMemberUnproven` compares the physical `cwd` and `providerRef`
of each overlapping record with the folder:
  - inside the folder: `ordinary_member_nested` (unchanged);
- a parent of the folder: new code `ordinary_member_encloses_root`
(still blocked);
- the same folder by any spelling: accepted, with all other member
checks unchanged;
- a record without `cwd`, or with a locator that points somewhere else:
`ordinary_member_locator_mismatch` (unchanged).
- Only member records change. The migrating workspace's own path must
still be canonical.

## Verification

- Red on `origin/master` (b908678ea3): the trailing slash and symlink
tests report `ordinary_member_locator_mismatch`. The enclosing test
reports `ordinary_member_locator_mismatch` instead of
`ordinary_member_encloses_root`.
- Green with the fix. Both spellings are eligible and the migration
publishes. The other record stays local and the folder's files stay in
place. An enclosing record and a locator elsewhere stay blocked, with no
workspace operation.
- `cd server && npx vitest run
src/services/remote-workspace-migration.test.ts
src/services/remote-workspace-online-source.test.ts
src/services/remote-workspace-cohort-migration.test.ts
src/services/remote-workspace-migration-concurrency.test.ts`: 4 files,
368 tests passed (embedded PostgreSQL).
- `cd server && pnpm typecheck`: passed.

## Risks

- Low to medium. More ordinary folders become movable online. The fence
does not change: path-derived source locks, each member's lifecycle
lock, and the scope recheck under lock at publication.
- A record that encloses the folder stays blocked. Its own move would
need a scope that covers the larger folder. Offline captures each record
separately.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 19:41:03 -06:00
DottaandClaude Opus 5.5 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 4434d12e), one stack
reports `source_scope_source_keys_exceeded` x46.

**Expected behavior**
A source scope that the alias bound admits (256 records) can take all of
its source locks. The offline move has no lock bound, because all
writers are stopped.

**Steps to reproduce**
1. Create a managed Git checkout with 133 task records that point at it.
2. Run `inventoryRemoteWorkspaceMigration` online. It reports
`source_keys_exceeded`.

**Is 128 a safety bound or a budget?**
- It cannot be a budget that pages across passes. The keys fence writers
only while one transaction holds all of them. Each pass releases its
locks.
- It bounds the advisory locks that one transaction takes. Each key is
one entry in the PostgreSQL shared lock table. That table holds
`max_locks_per_transaction` (default 64) times `max_connections`
entries, which is 6,400 with the defaults. 512 keys are 8% of that, and
one server runs one workspace migration at a time.
- The capture's Git source root bound (384) was three roots per key at
the old bound, and it would refuse the larger scope. It is now three
roots per key at the new bound.

## What Changed

- New `workspace-source-key-limit.ts` exports
`WORKSPACE_SOURCE_KEY_LIMIT = 512`.
- `withWorkspaceSourceLocks` (new scope and joined scope) and the online
proof (`source_keys_exceeded`) use the constant.
- The capture's Git source root bound is 1536 (three roots per key). The
capture code runs in a worker from its own source text and cannot import
the constant. A test ties the two values together.

## Verification

- Red on `origin/master` (b908678ea3):
  - 512 keys in one scope throw `workspace_source_scope_limit`.
  - A 133-record Git closure reports `source_keys_exceeded`.
- A capture with 1536 owned Git source roots fails with
`online_source_git_requires_shared_fence`.
- Green with the fix:
- 512 keys are held at once (`pg_locks` shows 512 advisory locks), and
513 are refused before a connection is reserved.
- The 133-record closure is eligible, its scope has 133 task keys, the
migration publishes, and the files stay in place.
  - The capture accepts 1536 roots and refuses 1537.
- `cd server && npx vitest run
src/services/remote-workspace-migration.test.ts
src/services/remote-workspace-online-source.test.ts
src/services/remote-workspace-cohort-migration.test.ts
src/services/remote-workspace-migration-concurrency.test.ts
src/services/remote-workspace-snapshot-archive.test.ts
src/services/isolated-remote-workspace-source-lock.test.ts` (embedded
PostgreSQL): 6 files, 493 tests passed.
- `cd server && pnpm typecheck`: passed.

## Risks

- Low to medium. A large scope holds up to 512 advisory locks in one
transaction. This is within the default lock table with a wide margin,
and only one workspace migration runs at a time per server.
- Lock acquisition takes one round trip per key, so a 512-key scope adds
roughly half a second at 1 ms per round trip.
- Scopes above 256 alias records are still refused (`members_exceeded`).

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in Claude Code.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 19:39:56 -06:00
DottaandClaude Opus 5.5 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 b2a12fab49.

## What Changed

- `inspectNativeWorkspaceMigration` throws
`native_workspace_migration_identity_rebound`, `_unsynced`,
`_other_workspace` or `_path_invalid` instead of one code. The online
pass and offline maintenance both see the same named code.
- `assertSettledControllerArchiveSource` throws
`NativeControllerArchiveSourceUnsettled` with a state
(`coordinator_missing`, `coordinator_leased`,
`coordinator_retry_scheduled`, `coordinator_unsettled`,
`coordinator_changed`, `finalization_busy`, `task_active`,
`session_selection_changed`, `run_changed`, `turn_active`,
`resume_source_changed`, `controller_files_changed`,
`controller_fingerprint_missing`). The message stays
`native_controller_archive_source_unsettled`.
- `prestageNativeControllers` keeps the existing outcome and count, and
also reports `archive_source_unsettled:<state>`. For `artifact_unproven`
it also reports `artifact_unproven:<run status>_run`, the same
`code:state` form that workspace details use.
- Previous-release story: no persisted state changes. Only error names
and report details change.

## Verification

- Red: on master the new unit test
(`native-workspace-migration.test.ts`, 4 cases) and the archive and
artifact assertions in `native-controller-migration.integration.test.ts`
fail.
- Green: `npx vitest run
src/services/native-runtime/native-workspace-migration.test.ts
src/services/native-runtime/native-controller-migration.integration.test.ts
src/services/native-runtime/native-harness-filesystem-independence.integration.test.ts
src/services/remote-workspaces.integration.test.ts` (297 passed).
- `pnpm typecheck` in `server` passes.

## Risks

- Low. Acceptance rules do not change. A dashboard that matches the
exact text `native_workspace_migration_identity_unproven` sees the new
names instead.

## 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>
2026-11-23 19:39:13 -06:00
DottaandClaude Opus 5.5 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 b2a12fab49.

## What Changed

- Add `recordNativeHarnessBackupSourceAbsence`. In one transaction it
locks the selected session row, the run's finalization advisory lock,
the last run row and the finalization row. It requires a settled run
(terminal, no controller lease, no live execution control, no
finalization owner, no lease owner or scheduled retry on the
coordinator), no queued or running turn on the task or session, no
current durable backup for the scope, and stamped leases for the scope.
Then it rechecks the disk. If `current` is back, it records nothing. If
a `.retiring-*` backup exists, it returns `selected_source_retiring`. If
any other entry remains (for example `previous` from an interrupted
publish), it returns `selected_source_unsettled`. Only a scope with no
entries besides `.expired-*` trash counts as gone. Otherwise it writes
`nativeHarnessBackupSourceAbsent` on the last run (scope digest to
stamped manifest digests) and logs
`native_harness_backup_source_gone_recorded`.
- A lock timeout during the recheck returns `selected_source_busy` for
this pass instead of failing the harness phase.
- The obligation query excludes a scope only when the selected session's
last run records that exact scope and that exact stamped manifest
digest. A new turn changes the last run, and a new stamp changes the
manifest, so the obligation comes back.
- The online pass (`prestageNativeHarnessBackups`) and the offline pass
(`migrateNativeHarnessBackups`) both call the same recorder for the
obligations they could not copy. The online pass counts
`nativeHarnessBackupSourcesGone` and does not defer it.
- Previous-release story: the new key is additive run state. No resume
path reads it. A session behaves after the move exactly as it does on
the volume today without its backup. A previous release ignores the key
and still reports the obligation.

## Verification

- Red: the new tests fail on master. Online still reports
`selected_source_absent`, offline still has an obligation (`expected
true to be false`), and the retiring case is not named.
- Green: `npx vitest run
src/services/native-runtime/native-harness-online-preservation.integration.test.ts
src/services/native-runtime/native-harness-backup-obligations.integration.test.ts
src/services/online-durable-data-migration.test.ts` (62 passed,
including busy-row and previous-backup cases).
- Neighbors: `ephemeral-server-startup-run-state`,
`ephemeral-server-runtime-skill-startup`,
`native-harness-prestage(-runtime)`,
`native-harness-filesystem-independence`,
`native-harness-backup-storage` (218 passed).
- `pnpm typecheck` in `server` passes.

## Risks

- Medium. A gone backup stops blocking the move. The recorder writes
only after a locked recheck that the run is settled, no turn is active,
and the files are still absent. A backup that is rotating stays blocked.
- The record changes the last run's `runnerProfileJson`.
Filesystem-independence facts include that profile. The recorder writes
only when no valid independence receipt exists, so no existing receipt
changes.
- No schema migration.

## 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>
2026-11-23 19:38:30 -06:00
commitperclip[bot] 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>
2026-11-23 19:37:58 -06:00
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>
2026-11-23 19:35:59 -06:00
Mahmoud ElNeMR 28e2b99e3b fix(adapter-utils): allowlist Slack task tools route in callback bridge (#19936)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Remote and sandboxed agents call the Paperclip control plane through
the sandbox callback bridge
(`DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` and
`HTTP2_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` in
`packages/adapter-utils/src/sandbox-callback-bridge.ts`)
> - While task-bound email routes and company skill routes are
allowlisted, the task-bound Slack tool execution route (`POST
/api/companies/:companyId/slack/tasks/:taskId/tools`) was missing from
`DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST`
> - Because the callback bridge rejects unlisted routes before
forwarding, remote agents cannot use the `slack` skill and receive `403
Route not allowed`
> - This pull request adds `POST
/api/companies/:companyId/slack/tasks/:taskId/tools` to
`DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` while keeping Slack
connection and workspace administration routes denied at the bridge
> - The benefit is that remote and sandboxed agents can execute
task-bound Slack tools over both queue and HTTP/2 callback bridges while
the controller continues to enforce company, connection, and task/run
authority

## Linked Issues or Issue Description

- Fixes: #19925

## What Changed

- Add `POST /api/companies/:companyId/slack/tasks/:taskId/tools` to
`DEFAULT_SANDBOX_CALLBACK_BRIDGE_ROUTE_ALLOWLIST` in
`packages/adapter-utils/src/sandbox-callback-bridge.ts`.
- Add positive and negative route authorization test cases for
`/api/companies/:companyId/slack/tasks/:taskId/tools` and
`/api/companies/:companyId/slack/connections` across queue and HTTP/2
allowlists in
`packages/adapter-utils/src/sandbox-callback-context-routes.test.ts`.

## Verification

- Verified
`packages/adapter-utils/src/sandbox-callback-context-routes.test.ts`
across both queue and HTTP/2 callback bridge allowlists.

## Risks

- Low risk. Only `POST
/api/companies/:companyId/slack/tasks/:taskId/tools` is admitted through
the callback bridge; all Slack workspace and connection administration
routes remain denied at the bridge, and the controller still enforces
company membership, connection ownership, and task/run authority.

## Model Used

- Google Gemini 3.1 Pro (Antigravity coding agent, 1M context window,
extended thinking, tool use and code execution enabled)

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-11-23 19:33:55 -06:00
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>
canary/v2026.1124.0-canary.850100
2026-11-23 19:30:40 -06:00
DottaandClaude Opus 5.5 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>
2026-11-23 19:26:22 -06:00
DottaandClaude Fable 5.2 37cbad2cd5 docs(connections): record the reviewer decision and the live REST results on the staging tester (#22725)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The built-in Google Workspace connector is going through Google
approval
> - `doc/memory/google-connector-memory.md` holds the decisions and
environment state for that work
> - On November 23 the six services moved to Paperclip's own REST tools,
and the staging tester was tested live against Google
> - The doc still says the reviewer destination is undecided and that
the REST tools were never run against Google
> - This pull request records the decisions, the tester state, the live
results and the open items
> - The benefit is that the next session starts from the true state

## Linked Issues or Issue Description

Refs #22634, #22706, #22714.

**What happened?**
The working memory and the production checklist are out of date after
the work of November 23.

**What did you expect to happen?**
The docs show the current decisions, the tester state and what is still
open.

**Steps to reproduce**
1. Read "Still open" and "Environments" in
`doc/memory/google-connector-memory.md` on master.
2. Compare them with the merged pull requests of November 23.

## What Changed

- `doc/memory/google-connector-memory.md`: four decision rows (reviewers
get the staging tester; the recommended security lab; tools refuse
unknown arguments; a cancelled sign-in leaves no connection), the tester
state, the live results, new open items and new next steps.
- `doc/plans/2026-11-17-google-workspace-production-checklist.md`:
ticked the reviewer destination and the revoke-at-Google items; noted
the lab recommendation.

## Verification

- Docs only. No code or tests changed.
- Checked that the diff has no client ids, project ids, stack ids,
passwords, codes or keys.

## Risks

- Low. Docs only. The memory doc is temporary and is deleted when the
connector is released.

## Model Used

- Anthropic Claude Fable 5.2 (`claude-fable-5-2`), in Claude Code with
tool use and browser control.

## 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 Fable 5.2 <noreply@anthropic.com>
2026-11-24 01:26:05 +00:00
TonioandPaperclip d1207c31d4 Left-align wrapped Inbox filters with search (#22720)
## Thinking Path

> - Paperclip helps people manage agents and tasks.
> - The Inbox toolbar lets people search and filter decisions.
> - Its dropdowns wrap when the sidebar leaves too little room.
> - An automatic margin pushes the wrapped row away from Search.
> - This change distributes space between controls on the same row and
aligns wrapped controls with Search.

## Linked Issues or Issue Description

Refs #22675.

**What happened?**

At intermediate widths, Inbox filters wrapped onto a second row and left
a large blank space at its start.

**Expected behavior**

The first wrapped button lines up with Search.

**Steps to reproduce**

Open Inbox and narrow the content area until the filters wrap below
Search.

## What Changed

Use flexbox space distribution on the Inbox toolbar and clear the filter
group's automatic start margin.

## Verification

All 38 CoordinatorNeedsYou tests passed at 536c7385ce. Local browser
measurements during development confirmed aligned left edges at 320px
and 890px and a right-aligned filter group at 1200px.

## Risks

The layout depends on Search and the filter group being the toolbar's
two direct children.

## Model Used

OpenAI Codex (GPT-6), with code 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
- [ ] 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1124.0-canary.849800
2026-11-23 17:05:27 -08:00
DottaandClaude Opus 5.5 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>
2026-11-23 18:32:00 -06:00
DottaandClaude Opus 5.5 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 8ce422e45d.

## What Changed

- `skillInstallationMaintenance().installations` takes a new
`settleUnavailableSources` option. The online and offline migrations
pass it. Direct calls keep the old blocking behavior, so a transient
remote failure outside a storage move never rebuilds a skill.
- Only a source that is gone counts as unavailable: a 404 or 410
response for an installed file. The capture path throws a typed
`RemoteSkillSourceUnavailableError` for these. Other failures (network
errors, 5xx, 429, unpinned revision, blocked scripts, package limits)
keep the `remote_source_unavailable` block.
- When the source is gone and the option is set, the migration rebuilds
the files from the saved incomplete version (if any) plus the stored
`SKILL.md` instructions. It publishes them as a version labelled
"Rebuilt from saved instructions", records
`reconstructedFromStoredContent` (time and missing files) in the skill
metadata, and writes a `company.skill_reconstructed_from_stored_content`
activity entry in the same transaction as the new version. The rebuilt
version is always a new version, never a reuse of the old one.
- When there are no stored instructions either, the migration sets the
existing `missingSource` marker with reason `remote_source_unavailable`
and writes a `company.skill_source_unavailable` activity entry. The
update is conditional on the row being unchanged. Later passes report
`source_unavailable` without calling the remote again.
- Runtime resolution returns `missing` for a marked skill unless a run
explicitly pinned a saved version, which stays usable. Otherwise it
shows with a plain message: the files could not be recovered when
Paperclip moved the company to new storage, and the user can reinstall
the skill. A reinstall replaces the metadata, which clears the marker.
- Eligibility reports `source_unavailable` for a marked skill. The data
contract and the offline skill phases accept it. The version check does
not fail the marked skill's incomplete current version, and it reports
`source_unavailable` for that version when it is an empty or incomplete
database-only snapshot (its bytes are in the database, so nothing stays
on the volume). Package-backed versions keep every check.
- The online migration counts `skillInstallationsReconstructed` and
`skillInstallationsSourceUnavailable` instead of deferring them.
- Other skill blockers (unsafe local source, catalog origin missing,
saved version incomplete without a remote failure, and so on) keep their
existing codes.

## Verification

- Red/green: with the service files from `master`, the three first tests
fail. The three review follow-up tests (503 stays blocked, empty saved
version verifies, pinned version stays available) fail on the first
commit of this PR and pass now. With this change they pass.
- `cd server && npx vitest run
src/__tests__/managed-skill-content.test.ts
src/services/online-durable-data-migration.test.ts` passes (embedded
PostgreSQL, real files, fetch mocked to 404).
- `npx vitest run src/__tests__/company-skills*.test.ts
src/__tests__/agent-runtime-skills.test.ts
src/__tests__/heartbeat-runtime-skills.test.ts`: all pass except two
`project workspace skill discovery` cases in `company-skills.test.ts`.
These fail identically on `master` in this macOS temp-dir checkout, so
they are not related to this change.
- `npx vitest run src/__tests__/ephemeral-server-data.test.ts` passes.
Its new test fails against the `master` data contract.
- `pnpm --filter @paperclipai/server typecheck` passes.
- `src/__tests__/ephemeral-migration.test.ts` needs an S3 endpoint and
was skipped locally. CI covers it.

## Risks

- A rebuilt skill keeps only the files that could be recovered. The
missing file names go to the metadata and the activity log. The old
version rows and the original remote source fields are kept, so a later
update or reinstall can fetch the exact files again.
- A 404 or 410 during a storage move is treated as final. The skill
stays recoverable through a reinstall if the source comes back. Network
errors and 5xx keep the block, so a stack with an outage at move time
waits for the next pass.
- No schema change.
- The marker guard and type now live in `company-skills.ts`, and the
maintenance module imports them.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used in Claude Code
with tool use (shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 18:31:16 -06:00
DottaandClaude Opus 5.5 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>
2026-11-23 18:30:33 -06:00
DottaandClaude Opus 5.5 b908678ea3 fix(connections): leave no connection behind when a first sign-in is cancelled (#22714)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents use apps through connections. Most app connections use an
OAuth sign-in.
> - Paperclip saves a draft connection before it opens the provider
sign-in page.
> - When the user cancels or abandons that sign-in, the draft stays. The
Apps list counts it as a connection that "needs attention".
> - The user did not ask for that connection, and the user must not
clean it up by hand.
> - This pull request hides drafts that never finished their first
sign-in and removes the draft when the user clicks Cancel.
> - The benefit is that a cancelled sign-in leaves no visible
connection, and a retry makes exactly one connection.

## Linked Issues or Issue Description

Refs #22634

**What happened?**

A workspace has one working "Google Workspace for the organization"
connection. The user clicks "Add account", chooses services, and clicks
Continue. The page shows "Opening Google Workspace…". The user clicks
Cancel before finishing at Google. The Apps page then shows "2
connections · 1 needs attention".

**What did you expect to happen?**

A cancelled sign-in leaves no visible connection. The same applies when
the user closes the page, reloads it, closes the Google tab, or refuses
consent at Google. A retry after a cancel makes exactly one connection.
A cancelled reconnect of a working connection does not change that
connection.

**Steps to reproduce**

1. Connect one Google Workspace account.
2. Open Apps, then Google Workspace, then "Add account".
3. Click "Continue to sign in", choose services, and click Continue.
4. On the "Opening Google Workspace" page, click Cancel.
5. Look at the Google Workspace card on the Apps page.

## What Changed

- Root cause: `connectApp` saves an OAuth draft (`status: "draft"`)
before sign-in (`server/src/services/tool-access.ts`, the connection
insert in the connect path). Cancel only navigated away. The Apps list
counted every draft as "needs attention"
(`ui/src/pages/apps/Browse.tsx`, `connectionState` and the attention
count).
- New module
`server/src/services/tool-access/connections/first-sign-in.ts`. It
decides if an OAuth draft never held a credential. It checks for OAuth
tokens on the connection and its grants, legacy inline tokens (the
removal module's list), a provider consent time, an external credential,
and the markers a real connection keeps when it needs a new sign-in. If
any check is not clear, the connection counts as real.
- The connection list endpoint sets `firstSignInPending: true` on those
drafts. The shared `ToolConnection` type has the new field.
- New route `POST /tool-connections/:connectionId/sign-in/cancel`. It
checks company access and configure permission. It removes the draft
with the normal removal teardown (grants, OAuth states, bindings) only
if the draft never held a credential. For any other connection it
changes nothing and returns `abandoned: false`. A removal writes the
activity entry `tool_connection.sign_in_cancelled`. The route is in the
OpenAPI registry.
- The Apps list does not show connections with `firstSignInPending`, and
it does not show an app whose only connections are such drafts. The
check is one pass with `Set` lookups.
- Cancel works in one transaction: it deletes the pending sign-in
states, locks the connection, checks it again, and parks it as
`disabled` with the marker `oauth_sign_in_cancelled`. If the connection
must stay, the transaction rolls back. Then the normal removal archives
the parked draft. Setup never reuses a parked draft, so a retry during
the removal gets its own row.
- One predicate, `connectionRemovedOrSignInCancelled`, guards
authorization start, access finish and machine sign-in. The direct,
Cloud and Vercel Connect callbacks and the access finish step lock the
connection before they write a grant or activate it, and return 409
`oauth_sign_in_cancelled` for a parked draft.
- `docs/api/tool-connections.md` documents the cancel route and the list
flag.
- The setup page calls the cancel route when the user clicks Cancel on
the sign-in screen. It does this only for a draft that this page made.
It does not do this for a resume, a reconnect, or a task-linked setup.
- Design for abandoned drafts (tab closed, reload, consent refused):
they are not listed, and the next attempt reuses them through the
existing draft reuse in setup. No background cleanup job is added.

## Verification

-
`server/src/__tests__/tool-access-cancelled-first-sign-in.integration.test.ts`
runs the real routes against embedded Postgres and a local OAuth
provider. It covers: a draft is marked and hidden; a provider token
exchange held open across Cancel ends in 409; Cancel and a retry at the
same time leave exactly one active connection; a parked draft is hidden
and refuses a new sign-in start; a legacy draft with an inline token is
not cancelled; Cancel removes it, deletes its OAuth state, logs
activity, and a late callback fails; a retry after Cancel gives exactly
one live connection (organization and personal); Cancel does not change
an active connection or a connection that needs a new sign-in; a draft
refused at the provider stays hidden and Cancel removes it; another
company cannot cancel the draft.
- `ui/src/pages/apps/Browse.test.tsx`: a pending draft is not listed and
does not add "needs attention".
- `ui/src/pages/apps/AppsConnect.test.tsx`: Google Workspace setup,
Continue, then Cancel calls the cancel route for the new draft.
- Red/green: the new Browse and setup tests fail without the UI change.
The server test fails on master because the route and flag do not exist.
- Local runs: the new server file, `openapi-routes.test.ts`,
`tool-access-oauth-protocol.integration.test.ts`, `Browse.test.tsx`,
`AppsConnect.test.tsx`, `activity-format.test.ts`, and
`src/features/connections` pass. Server typecheck passes. `pnpm verify`
exits 2 because of the pinned inputs file, so CI supplies broad
coverage.
- Not done: a real browser test against Google.

## Risks

- Low risk. The cancel route fails toward no change: it removes nothing
that shows any sign of a credential.
- Cancel and a late provider callback agree under the connection row
lock. If the callback commits first, Cancel changes nothing. If Cancel
commits first, the callback returns 409 and saves nothing. This covers
the direct, Cloud and Vercel Connect callbacks and the access finish
step.
- If the removal after Cancel fails, the draft stays parked and hidden,
and a second Cancel finishes it.
- A connection that was removed before and is now added again keeps its
old consent record. If that new sign-in is cancelled, it stays as a
visible draft, as it does today.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used in Claude Code
with tool use (shell, file edits, test runs).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 18:16:28 -06:00
DottaandClaude Opus 5.5 6a07420f26 fix(google-workspace): refuse unknown tool arguments; list_threads filters by query (#22706)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents use Google Workspace through Paperclip's own REST tools for
Gmail, Drive, Docs, Sheets, Slides and Calendar (#22634).
> - In a live test on staging, an agent called `gmail__list_threads`
with `query` and `q`. The tool did not have these arguments.
> - The tool ignored them and returned threads that did not match. The
agent read mail that it did not ask for.
> - Google reviews this connector for restricted scopes. A tool that
ignores a filter and reads too much data is a data-minimisation defect.
> - This pull request makes every tool refuse an argument that is not in
its input schema, before it sends a request to Google. It also adds
`query` to `list_threads`.
> - The benefit is that a filter can never be ignored. An agent gets a
clear error that names the bad argument and lists the correct arguments.

## Linked Issues or Issue Description

Refs #22634

**What happened?**
On staging, against real Google, an agent called `gmail__list_threads`
with `query` (and `q`) to list only threads with a marker. These
arguments are not in the tool's input schema. The tool dropped them and
returned unfiltered threads (5 shown, estimate 201).

**What did you expect to happen?**
The tool refuses an argument that it does not know, names it, and sends
nothing to Google. `list_threads` accepts a Gmail search query, as
`search_threads` does.

**Steps to reproduce**
1. Connect Google Workspace with Gmail read access.
2. Call `gmail__list_threads` with `{ "query": "subject:marker" }`.
3. See that the result contains threads that do not match the query.

## What Changed

- `defineTool` in `server/src/google-workspace-rest-tools/tool.ts`
checks the arguments of all 36 tools against the advertised input schema
before the zod parse. It checks the top level and structured inputs (for
example `attendees[0]`, `writeControl`). An unknown argument gives a
tool error and no request goes to Google. Example: `Invalid arguments
for list_threads: unknown argument "q". Accepted arguments: pageSize,
pageToken, query, labelIds, includeTrash, view. Nothing was sent to
Google.`
- `defineTool` sets `additionalProperties: false` on each object in the
advertised input schema that lists `properties`. Agents get the schema
from code, so existing connections see it with no reconnect and no
refresh.
- Google's batchUpdate request objects stay pass-through:
`docs__update_doc`, `slides__update_presentation` and
`sheets__update_spreadsheet` `requests[]`. The request-kind checks stay
the same.
- `gmail__list_threads` has a new optional `query`. It goes to Gmail as
`q`, with the same name and meaning as in `search_threads`. It works
together with `labelIds`. The draft and spam exclusions use the same
shared function (`queryWithExclusions`) as `search_threads`. The page
size stays default 20, maximum 50.
- The README has a new "Unknown arguments" section, a new row in the
input-differences table, a "Filters on list tools" decision list
(`search_messages` and `list_drafts` already have `query`;
`list_labels`, `list_calendars` have no REST filter; `list_events` uses
`fullText`; Drive `list_recent_files` stays without `query`, and
`search_files` is the Drive filter tool), and an updated `list_threads`
design note.
- `sheets/get-values.test.ts` expected that an unknown
`valueRenderOption` was ignored. It now expects a refusal.

## Verification

- `cd server && npx vitest run src/google-workspace-rest-tools` passes:
55 files, 1,400+ tests.
- New `strict-arguments.test.ts` makes one case for each of the 36 tools
from the tool list. Each case calls the tool with an unknown argument
and expects the exact error and zero HTTP requests. It also checks
`additionalProperties: false` on each closed object, the exact list of
pass-through paths, and that the zod schema of each tool validates the
same fields as its JSON schema. Red first: with the old `tool.ts`, 39 of
42 cases failed.
- `gmail/list-threads.test.ts`: `{ query: "x" }` reaches Google as
`q=(x) -in:draft`; `{ q: "marker" }` is refused with zero requests.
- `src/__tests__/google-workspace-rest-transport.test.ts` (embedded
Postgres, `executeTool` path): a connection with an older saved
`list_threads` schema (no `query`, no `additionalProperties`) gets the
new schema with no refresh and no Google request. A `query` call sends
the right `q`. A `q` call fails as `tool_error` with the readable
message, makes no Google request, and is recorded as a failed invocation
and one `call_failed` audit event.
- All Google-related server test files pass: 61 files, 1,542 tests. The
allowlist and boundary tests pass.
- `pnpm verify` exited 2 (the README is a broad input). Required CI
gives the broad coverage.
- Not checked against Google's servers. No request was sent to staging,
production or Google.

## Risks

- An agent that sent extra arguments before now gets an error, not a
silent drop. This is the intended change. The error lists the accepted
arguments, so the agent can correct the call at once.
- If a tool's JSON schema and zod schema do not agree, a valid argument
could be refused. A new test checks that they agree for all 36 tools.
- What Google's own MCP servers do with unknown arguments is not
recorded. We chose to refuse.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), through 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: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1124.0-canary.849300
2026-11-23 17:37:09 -06:00
DottaandClaude Opus 5.5 b2a12fab49 fix(runner): keep tool catalogs within what a durable run attachment can carry (#22705)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Managed runs start through the Paperclip runner, which records each
run's attachment template in a durable control plane
> - That template carries the agent's authorized tool catalog, with
every tool's JSON schema
> - The runner-side catalog check admitted up to 256 tools and 768 KB,
but the durable control plane rejects any value over 10,000 canonical
JSON nodes, and durable commands cannot exceed about 522 KB
> - An agent with Notion and two GitHub connections (about 180 tools)
passed the first check and failed every run with
`durable_prp_canonical_json_too_large`
> - This pull request makes the catalog check honor what the run
attachment can carry, and gives controller-built values a node budget
that matches the command byte limit
> - The benefit is that agents with several large connectors run
normally: tools that do not fit move to on-demand search and call
instead of blocking the run

## Linked Issues or Issue Description

**What happened?**
After Notion (77 tools) and two GitHub connections (49 tools each) were
connected and installed for the company, every run for an agent failed
within seconds with `durable_prp_canonical_json_too_large`, before the
model session started. Paperclip retried each run several times.

**Expected behavior**
An agent with several connectors starts its run. When the full catalog
is too large, tools are delivered on demand.

**Steps to reproduce**
1. Build an authorized tool catalog that `runnerCodexDynamicToolsFit`
admits, for example 250 tools with enum-heavy schemas under 768 KB.
2. Stage it as a run attachment in `DurablePrpControlPlane`.
3. Staging throws `durable_prp_canonical_json_too_large`.

## What Changed

- `durable-prp-control-plane.ts`: the canonical JSON node budget is a
per-call limit. Runner-sent semantic input keeps 10,000 nodes.
Controller-built values (run attachment templates, command digests) use
a budget equal to the command byte limit, which already bounds them. New
`runAttachToolCatalogFits` checks that a tool catalog canonicalizes and
stays within 384 KB, leaving room for the rest of the run attachment.
- `runnerd-codex-transport.ts`: `runnerCodexDynamicToolsFit` also
requires `runAttachToolCatalogFits`. The server already uses this
predicate to choose between direct tools and on-demand tools.
- Tests: the densest catalog the fit check admits stages, persists and
restores through the control plane; a 180-tool connector catalog under
768 KB no longer fits and moves to on-demand tools.

## Verification

- `npx vitest run src/control-plane/durable-prp-control-plane.test.ts`
(runner): 232 passed, including the existing runner input
`over_node_limit` and `over_depth_limit` cases.
- `npx vitest run
src/services/native-runtime/assigned-mcp-tools.test.ts` (server): 61
passed. `paperclip-runner-tool-authority.test.ts`: 48 passed.
- Red/green: without the change, the control plane test fails with
`durable_prp_canonical_json_too_large`, and the server test fails with
`expected true to be false` (the oversized catalog was admitted).
- `runnerd-codex-transport.test.ts` and `runner-tool-capacity.test.ts`
have the same 79 local failures with and without this change (they need
built runner binaries). CI runs them.
- SDK public input pins: unchanged.

## Risks

- Agents whose catalog is between 384 KB and 768 KB now get on-demand
tools instead of direct tools. Before this change those runs failed, so
no working setup loses direct tools.
- Controller-built values get a larger node budget. They are bounded by
the command byte limit before they reach the runner, and runner input
keeps its strict limit.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code, with tool use.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:27:47 -06:00
DottaandClaude Opus 5.5 1363b557b9 fix(runs): stop retrying a run whose setup is too large to start (#22707)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - When a managed run fails, Paperclip classifies the failure to decide
whether to retry it
> - A run whose setup exceeded the runner's durable limits failed with
`durable_prp_canonical_json_too_large`, which was classified as an
interrupted session
> - Paperclip retried it three times and then continued the task in a
fresh session that failed the same way: one agent produced 20 failed
runs in a few minutes, and the task showed a raw internal code
> - This pull request classifies oversized run setups as a permanent
failure with a plain-language action
> - The benefit is no pointless retries, and the user learns what to
change

## Linked Issues or Issue Description

**What happened?**
An agent's run setup was larger than the runner's durable control plane
accepts. Each attempt failed in seconds with
`durable_prp_canonical_json_too_large`. Paperclip scheduled retries and
fresh-session continuations that could never succeed, and the task
showed the raw code.

**Expected behavior**
A failure that the same input will always repeat is not retried. The
user sees what to change.

**Steps to reproduce**
1. Classify `new Error("durable_prp_canonical_json_too_large")` with
`nativeSessionFailureSourceCode`.
2. The disposition is `retryable_failure` with
`native_session_interrupted`.

## What Changed

- New `native-run-payload-too-large.ts`: the
`native_run_payload_too_large` code, its user-facing action, and the
matcher for `durable_prp_canonical_json_too_large` and
`command_payload_too_large`.
- `native-session-executor.ts`: classify those errors as
`native_run_payload_too_large`, treat it as permanent, and show the
action.
- `heartbeat/retries.ts`: do not schedule a retry for it.
- `native-sandbox-disk-full.ts`: a full disk does not relabel this code.
- Tests for classification, disposition and retry scheduling.

## Verification

- `npx vitest run
src/services/native-runtime/native-run-payload-too-large.test.ts
src/__tests__/heartbeat-retry-scheduling.test.ts`: 75 passed.
- Red/green: without the change, 4 of the new assertions fail.
- The underlying size mismatch is fixed separately in
paperclipai/paperclip#22705. This change makes any future deterministic
size failure stop at once instead of looping.

## Risks

- Low. Only these two deterministic size errors change classification.
All other failures keep their existing retry behavior.

## 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>
2026-11-23 17:27:29 -06:00
Devin FoleyandPaperclip bda1bf7b52 fix(ci): respect GitHub quota resets during image publication (#22690)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Its image workflow builds immutable images and requires proof for
the exact source.
> - GitHub API quota failures can stop metadata generation and
verification reads.
> - Short retries before the quota reset consume requests without
restoring progress.
> - This pull request removes metadata API reads and makes quota retries
respect server timing and job budgets.
> - The benefit is fewer API requests and clear quota errors without
weakening release proof.

## Linked Issues or Issue Description

Refs #22677, which adds conditional requests for unchanged Actions
polls. This change retains that cache and extends quota recovery.

**What happened?**

[Docker run
45215585951](https://github.com/paperclipai/paperclip/actions/runs/45215585951)
failed in both Docker metadata steps with an installation API rate-limit
error. [Run
45210434846](https://github.com/paperclipai/paperclip/actions/runs/45210434846)
built both architectures but failed during source verification reads.
The reader retried quota-proven HTTP 403 responses after seconds and
then failed with a generic HTTP error. It ignored the primary reset time
and could shorten Retry-After below the server requirement.

**Expected behavior**

Metadata generation should need no GitHub API request. Quota recovery
should wait until GitHub permits another request, within the caller
deadline. Exhausted budgets should identify the quota failure and safe
response-header details. Permission failures must remain immediate.
Missing source, migrator, or attestation proof must still block
publication.

**Steps to reproduce**

1. Return HTTP 403 with zero remaining requests and a reset two minutes
away to the Actions reader.
2. Observe the old reader retry after seconds and exhaust its attempts
before the reset.
3. Return an hour-long Retry-After value. Observe the old reader retry
after its one-minute cap.

**Version**

Master after #22677.

**Deployment mode**

GitHub Actions image publication and release verification.

## What Changed

- Honor primary reset times and Retry-After seconds or dates. Use a
minute-long exponential fallback for secondary throttling without timing
headers.
- Bound the entire wait by a per-read budget and the caller deadline.
Keep permission-denied 403s immediate and preserve ETag caching and
transport retries.
- Emit a typed quota error with allowlisted token-source, resource,
limit, remaining, and reset diagnostics. Do not log tokens, response
bodies, or request URLs.
- Share the Docker observer's 40-minute deadline with its reader. Bound
final proof rechecks to five minutes. Add an explicit `github.token`
source hint beside workflow-issued token bindings.
- Generate Docker tags and OCI labels from checkout and workflow inputs.
Keep release-lane and immutable SHA tags. Feed metadata JSON explicitly
to manifest publication. Stop fetching the GitHub repository
description; keep local license and migration labels.
- Add regression tests and run them in the trusted PR and
source-verification workflows. Document retry budgets and metadata
inputs.

## Verification

- Final acceptance: [CI attempt
3](https://github.com/paperclipai/paperclip/actions/runs/45263398107/attempts/3)
succeeded on `302da8c`. All 68 reported checks are complete, with no
pending or failing checks. Greptile reviewed that exact commit at 5/5
and both review threads are resolved. The voice timeout recovered
without code changes; its earlier cause remains unconfirmed. Prior
failures and local reproduction limits remain below.

- [CI attempt
2](https://github.com/paperclipai/paperclip/actions/runs/45263398107/attempts/2)
recovered the interrupted checks. Its only remaining test failure is
server shard 2/12: `voice-session-store.integration.test.ts`, “retains
both spoken sides once on the public call task and preserves
quarantine,” exceeded 15 seconds on both Vitest attempts. The `ci /
verify` failure is its aggregate. The voice test file is byte-identical
to master and absent from this PR diff; its cause is not established as
an infrastructure fault. A focused local attempt could not start
PostgreSQL because the macOS binary lacks `libzstd.1.dylib`; no voice
test passed locally. Requesting one bounded retry of the affected shard
without code changes; all earlier failures remain recorded here.

- The automatic runner-loss retry helper for the current run failed on a
GitHub job-log download with HTTP 503 ([helper run
45265762243](https://github.com/paperclipai/paperclip/actions/runs/45265762243)).
Once the PR workflow completed, a manual failed-job retry was requested
successfully for unchanged head `302da8c`. Retry results remain pending;
no interrupted check is treated as passed.

- [CI run
45263398107](https://github.com/paperclipai/paperclip/actions/runs/45263398107)
on `302da8c` lost 25 jobs during verification. Inspected the logs for
these 25 jobs: all 25 contain an explicit runner shutdown signal
followed by cancellation, with no additional error records. This
includes Rust, browser, general-server, and serialized-server lanes.
These are interrupted checks and remain unverified until retried.
Greptile reviewed this exact commit at 5/5 with no new findings.

- Combined focused release/metadata and PR policy suite: **1,008 tests
passed**, zero failures. Command: `node --test
scripts/github-actions-rate-limit.test.mjs
scripts/docker-image-metadata.test.mjs
scripts/cloud-source-verification.test.mjs
scripts/cloud-readiness-runner-loss.test.mjs
scripts/standard-image-contract.test.mjs
scripts/reuse-canary-image.test.mjs scripts/merge-group-image.test.mjs
scripts/__tests__/release-verify-workflow.test.mjs
.github/scripts/tests/*.test.mjs`.
- `pnpm exec vitest run
server/src/services/online-durable-data-migration.test.ts --project
@paperclipai/server`: **32 tests passed** after incorporating upstream
#22686. The final PR diff includes no migration test or runtime change.
- In `packages/paperclip-runner`, `pnpm exec vitest run
src/drivers/acpx/cursor-mode.test.ts
src/drivers/acpx/grok-native-session-options.test.ts --maxWorkers 1`:
**26 tests passed**. This local pass does not explain the earlier CI
timeouts.
- New tests first reproduced ignored primary reset timing, early
Retry-After retries, missing service-error waits, and older-checkout
failures. CLI tests confirm quota exhaustion produces a safe annotation,
no verified output, and no cancellation request. Workflow tests cover
neither, either, and both new test files being present.
- Initial policy CI failed two assertions that expected the old metadata
action and single-file proof test command. Updated them to check both
local metadata steps, the full-SHA tag, and all proof tests. Initial
Greptile findings about service Retry-After and older checkouts are
fixed and resolved.
- [CI attempt
1](https://github.com/paperclipai/paperclip/actions/runs/45259240827/attempts/1)
lost the Build runner and server shards 1, 7, and 12 within four
seconds. Logs explicitly record shutdown signals followed by
cancellation; Build reported no compiler error. Runner lane 2/3 hit
five-second Cursor and Grok test timeouts. E2E shard 2/8 failed document
visibility after outage/reload and the cached-task 404 assertion. Those
test failures are not assumed to be infrastructure faults. Their
aggregate checks also failed. They remain merge blockers until fresh CI
passes.
- Server shard 9 also found a deterministic, pre-existing
blocker-enumeration test failure. Reproduced it on unchanged base
`427d13c38c63`: the source scanner omitted helper-declared blockers.
Upstream #22686 fixes that test. Incorporated its version when updating
from master and removed the duplicate fix from the final diff. A
failed-job retry was accepted after attempt 1 finished; the updated
branch now needs fresh CI.
- Local setup: filtered frozen-lockfile installation changed no
lockfile. Initial server-test startup lacked built plugin SDK output;
`pnpm --filter @paperclipai/plugin-sdk ensure-build-deps` supplied it
before the passing run. Local tests used macOS and Node 25.6.1; CI
checks Linux and its configured Node version.
- `pnpm verify` initially could not start because the fresh worktree
lacked `cli/node_modules/tsx`. The underlying `node
scripts/local-verify.mjs` returned exit 2: workflow changes require
broad CI. No full local Vitest or Docker build was run. Required CI
supplies broad coverage.
- No credentials were changed and no live publication or deployment was
requested. CI retries do not authorize image publication or bypass
proof.

## Risks

- A reset outside the allowed wait still fails closed. Shared repository
quota pressure from other workflows can still delay publication.
- Attestation and source/migrator proof remain required. This change
does not add a privileged token or bypass a check.
- OCI labels now use checkout inputs. The remote repository description
is omitted; source, revision, version, creation time, license, and
schema labels remain available.
- Revert this PR to restore the previous reader and metadata action. No
database or runtime application changes are required.

## Model Used

OpenAI gpt-6.1-sol with xhigh reasoning, through Codex in T3 Code. Used
code editing, GitHub log and upstream action-source inspection, and
local 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] This is a CI reliability fix; it does not change planned product
scope
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have described the issue in-PR following the bug template
- [x] I have not referenced internal or instance-local issues or links
- [x] My branch name describes the change
- [x] I have run focused tests locally and they pass; the broad
verification limitation is recorded
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation
- [x] I have considered and documented risks
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1123.0-canary.849000
2026-11-23 14:39:14 -08:00
fe2db1c32b feat(ui): show the Cloud Slack invitation in the workspace sidebar (#22702)
## Thinking Path

> - Teams use Paperclip to manage agents and their work.
> - Hosted teams can have a private Slack channel with the Paperclip
team.
> - A workspace member needs to know whether they can open the channel
or still need the owner's invitation.
> - Cloud supplies that information for the selected organization.
> - This change puts a Slack button in the sidebar footer. It opens a
dialog with the next action.

## Linked Issues or Issue Description

**Subsystem affected**

Workspace sidebar and the Cloud onboarding browser journey.

**Problem or motivation**

After setup, a user can lose track of the invitation to their
organization's private feedback channel.

**Proposed solution**

Show the invitation status in a dialog. Offer a channel link when Cloud
confirms the connection.

**Roadmap alignment**

This extends the existing hosted workspace navigation. The roadmap has
no separate item for this shortcut.

## What Changed

- Both sidebar variants use the existing portfolio request to show the
Slack shortcut when Cloud supplies invitation details.
- The icon uses grayscale at rest and brand colors on hover or keyboard
focus. The button has an accessible name and a tooltip.
- The Cloud onboarding journey selects Codex and confirms feedback
intent when the first-account welcome appears.
- Storybook covers pending and connected channels.

## Verification

- The sidebar suite passed 36 tests. The Cloud onboarding journey suite
passed 10 tests covering both the current and previous gateway layouts.
- The Storybook catalog regenerated successfully.
- In a local browser run, a fresh user completed signup, connected a
test model, hired an agent, opened its chat, and opened and dismissed
the Slack invitation. The test used a local Slack fixture.
- The incremental verifier selected broad CI coverage for the runner
journey change.

All applicable checks passed on `ea9779abda`. A GitHub runner shut down
during a server test shard. The shard and final verification gate passed
on retry. [CI
run](https://github.com/paperclipai/paperclip/actions/runs/45276376121/attempts/2)
· [Greptile review
(5/5)](https://github.com/paperclipai/paperclip/pull/22702#issuecomment-7115303606)

## Risks

An older Cloud service can omit the optional feedback field. In that
case, the sidebar keeps the existing layout. Cloud controls the channel
destination and the invitation state.

## Model Used

OpenAI GPT-6 in Codex, with repository tools 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 <1504818+scotttong@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-23 14:38:55 -08:00
Devin FoleyandPaperclip 63e6e56407 fix(onboarding): disable unsupported browser sign-in (#22695)
## Thinking Path

> - Paperclip lets people manage AI agents and connect their AI
accounts.
> - Onboarding connects the first agent to a provider account.
> - Some execution environments cannot start browser sign-in.
> - The wizard showed this limitation but left Connect enabled.
> - This pull request uses that same state to block Connect and keyboard
submission.
> - Users get a clear reason and can go back to use an API key or
another model.

## Linked Issues or Issue Description

**What happened?**

Onboarding showed that browser sign-in was unsupported. Connect remained
enabled when no saved subscription was available. Repeated clicks could
test a connection that the user could not establish.

**Expected behavior**

Disable Connect and keyboard submission while browser sign-in is
unsupported and no saved subscription is available. Show the reason.
Keep saved subscriptions and API-key connections usable.

**Steps to reproduce**

1. Open the onboarding Connect step in an environment without browser
sign-in support.
2. Select Claude or OpenAI with subscription authentication and no saved
subscription.
3. Observe the unsupported sign-in notice and press Connect or
Cmd/Ctrl+Enter.

**Paperclip version or commit**

Reproduced in component tests on master at
`8ce422e45d0c47ede1c8ea905575b93879c1854b`.

**Deployment mode**

Authenticated setup with a sandbox provider that reports
`supportsLoginPty: false`. Tests use the real wizard with simulated API
responses.

Related: #19336 fixes shared sign-in actions and retry behavior. #17615
addresses a platform-specific login transport error. This change guards
the onboarding submission action when browser sign-in is unavailable.

## What Changed

- Use one unsupported sign-in state for the notice and the Connect
submission guard.
- Block mouse and keyboard submission before connection testing or
hiring.
- Keep saved subscriptions and API-key authentication available.
- Add regressions for Claude, Codex, saved subscriptions, and returning
to API-key setup.
- Give existing hire tests usable authentication fixtures and document
the behavior.

## Verification

- Baseline on unchanged master: both unsupported-sign-in regressions
fail because Connect is enabled. Both alternate-authentication tests
pass.
- Patched focused run: 4 tests pass with `pnpm exec vitest run
ui/src/components/OnboardingWizard.test.tsx -t 'browser sign-in is
unsupported'`.
- Full onboarding component group: 290 tests pass across the wizard,
step, adapter, and variant suites.
- `pnpm -r typecheck` passes for all workspace packages.
- `pnpm build` passes for all workspace packages.
- `pnpm test:run` stopped in the chat integration shard: 315 passed, 5
failed, 1,633 skipped, and one unhandled error. The failures include
`ENFILE: file table overflow` and SQLite database-open errors. The
server, packages, and test-runner sources match the base commit. The
focused rerun below passes; this full-suite attempt is still not a pass.
- Token gates and `git diff --check` pass.
- Focused chat-failure check: 67 tests pass, including all five
failures, without source changes. Command: `pnpm exec vitest run
server/src/__tests__/chat-channels.integration.test.ts -t 'retains HTTP
Retry under the endpoint authorization row lock|retries the newer saved
github request instead of the failed request after a budget hold'
--maxWorkers=1`. This establishes recovery in isolation, not completion
of the full local suite.
- CI attempt 1: [serialized server suites
(1/9)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011142554),
[Runner Vitest package
(3/3)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011141444),
[server tests
(7/12)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011143258),
and [server tests
(9/12)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011143086)
stopped after their runners received shutdown signals. The repository
runner-loss workflow retried these jobs once after the attempt
completed. The interrupted first-attempt jobs are not passes.
- [Automatic CI
recovery](https://github.com/paperclipai/paperclip/actions/runs/45268368345)
confirmed that all four failed jobs lost their runners and requested
their rerun. The initial aggregate `ci / verify` failed because a
dependency was cancelled. [CI attempt
2](https://github.com/paperclipai/paperclip/actions/runs/45265381027/attempts/2)
passed for `b92ea53b5322e2d32bf8235db96ce94087fffde4`. The current PR
has 58 successful checks, 3 skipped checks, no failures or pending
checks, and no merge conflicts.
- [Greptile
review](https://github.com/paperclipai/paperclip/pull/22695#issuecomment-7113951912):
5/5 on `b92ea53b5322e2d32bf8235db96ce94087fffde4`, with no actionable
issues.
- No live provider sign-in or browser acceptance is claimed.

## Risks

- The gate must keep saved credentials usable. Regression tests cover
saved subscriptions and API keys.
- Authentication and environment capability reads keep their existing
behavior. This change adds no API, schema, or deployment-policy changes.

## Model Used

- OpenAI `gpt-6.1-sol` through the Codex harness in T3 Code, with xhigh
reasoning effort, code execution, and tool use. The harness does not
expose the context-window size.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-23 14:38:00 -08:00
Devin FoleyandPaperclip 298026eadc fix(ai-connections): reconnect typed auth failures and stop quota retry countdowns (#22692)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Runs preserve typed provider failures so recovery can select the
right next action.
> - Authentication repair still recognized only older run error codes.
Native typed authentication failures could miss the reconnect request.
> - A typed exhausted quota with no reset also produced an estimated
one-hour admission hold. Waiting cannot repair that account.
> - This pull request uses the existing reconnect and validated adoption
flow for authentication. It asks for billing and usage repair for typed
quota exhaustion without a reset.
> - Rate limits and provider-reported resets keep their existing
automatic waits. Account authority, saved-work checks, pauses, and
approvals keep their existing gates.

## Linked Issues or Issue Description

Refs #15110. That open PR classifies the legacy Claude monthly-spend
message. This change does not duplicate its adapter parsing or change
older untyped quota recovery.

Refs #21351. That open PR changes legacy Claude edge-error
classification and repeated-failure latching. This change consumes the
typed provider category and retains the existing credential-generation
checks.

**What happened?**

A failed run with `providerFailure.category: authentication` and a
generic native error code did not create its reconnect request. A typed
`quota_exhausted` failure without a reset produced an estimated provider
cooldown, although the account needed attention. Recovery's narrow
PostgreSQL result projection also omitted typed native provider
failures.

**Expected behavior**

Ask the responsible person to repair the selected account or explicitly
adopt a compatible managed connection. Ask for billing and usage repair
when an exhausted allowance has no reported reset. Continue to wait
automatically for transient rate limits and reported allowance resets.

**Steps to reproduce**

Use a failed native run with a typed OpenAI authentication error and a
generic native error code. The existing reconnect controller should
create one card. Use typed `quota_exhausted` evidence with no reset. The
task should offer account review and manual Retry, with no invented
reset or automatic provider retry.

## What Changed

- Recognize typed authentication failures and the reported
`provider_invalid_credentials` run code. Reuse the existing
controller-only reconnect request, account freshness checks, durable
continuation, and explicit legacy adoption.
- Retain typed provider failures in the bounded PostgreSQL recovery
projection.
- Refresh the reviewed SDK public-source pin for the changed shared
interruption type with the repository generator.
- Keep typed quota exhaustion without a reset out of provider cooldown,
bounded retry, and periodic quota-recovery paths. A newer billing
refusal supersedes older reset evidence. Classify a startup billing
refusal before the remote exit-confirmed retry branch, and prevent the
startup planner from falling back to plain backoff.
- Add the derived `provider_billing` task action, an account-review
link, and a matching Inbox label. Preserve saved-work recovery and
current user gates.
- Update the connection documentation for these recovery decisions.

## Verification

- Red: five server regressions failed on current master for typed
authentication, the invalid-credential code, a false quota cooldown, and
the missing billing action. The new task notice regression also failed
before the repair.
- Green: the first focused set passed 241 tests. The final
quota/retry/UI set passed 281 tests. The database-backed reconnect set
passed seven selected cases for Claude, OpenAI, method switching, and
explicit legacy adoption. Sets overlap; these counts are not additive.
- Database tests check current account attribution, refreshed credential
generations, bounded result projection, and preservation of reported
resets. A quota without a reset must not schedule a successor. Two
additional startup regressions failed before the startup repair. The
repaired startup suites pass all 45 integration cases and 11 focused
classification cases. They check a blocked task, billing presentation,
no retry deadline, no resumable claim, and preserved retries for rate
limits and reported resets.
- `pnpm check:token-gates` and `git diff --check` passed.
- The earlier [Runner support
failure](https://github.com/paperclipai/paperclip/actions/runs/45263306284/job/138003893674)
came from a stale reviewed SDK source pin. The same three SDK evidence
files failed locally on `cacdb81`. Regenerating the pin from that
committed tree made all 59 tests in those files pass. Only the shared
`execution-projection.ts` source hash changed; lock and runtime pins
remain unchanged.
- `pnpm build` and repository-wide `pnpm -r typecheck` passed for the
initial change. The authentication/recovery policy set also passed 99
tests. Server typecheck and build also passed for the startup repair at
`cacdb81c26988394e11f934d05531bcbb121c7a2`. The full local `pnpm
test:run` stopped in chat shard 4/6 with 15 failures: fourteen
file/database-open failures during `ENFILE` file-table exhaustion and
one retry polling timeout. The failed run also reported an unhandled
`ENFILE` error. All 40 selected chat cases, including those 15 failures,
passed in a fresh process on `06c14a8`. This does not qualify the full
local suite. The complete CI workflow passed on the final head, as
recorded below.
- Local environment: isolated macOS arm64 checkout and disposable
PostgreSQL fixtures. The branch was replayed onto master at
`32375d302fbc3a233531674aedefa273adee2d97`; that base change touches an
unrelated migration test.
- Live provider account repair and the original reported credential
failure remain unverified. A read-only operational trace confirmed
retained runner checkpoint versions, but the reported runtime string was
absent from retained onboarding and run logs as well as current Core and
available Cloud source refs. Its producer remains unidentified.

- [Trusted PR CI, attempt
2](https://github.com/paperclipai/paperclip/actions/runs/45265943006/attempts/2)
completed successfully on `06c14a8cbcf2480eb9d2841bebda3337d4248bd6`,
including typecheck, build, Runner, serialized server, general test, and
browser suites. The previously cancelled serialized suite passed on that
attempt. All 59 commit checks are terminal: 56 succeeded and three
conditional checks were skipped. The Snyk commit status also passed.
- Greptile completed on `06c14a8cbcf2480eb9d2841bebda3337d4248bd6` with
5/5 and no new findings. Both earlier review threads are resolved.

## Risks

- A typed exhausted allowance without a reported reset now requires
account repair. Older untyped quota errors retain their existing
recovery policy; #15110 remains separate.
- Authentication repair must follow the recorded account rather than
infer an account from a proxy driver's upstream name. Existing
generation checks must still protect newer credentials.
- No schema migration or provider replay authority is added. Existing
stored runs keep their data. The new task action is derived at read
time.
- Live recovery of the originally reported incident remains unverified;
the operational trace did not locate the reported runtime code.

## Model Used

OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh
reasoning effort, tool use, code editing, and test execution. The
harness does not expose the context-window size.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-23 14:37:16 -08:00
DottaandClaude Opus 5.5 4b5b9b7807 fix(antigravity): keep native slash commands in task text as prose (#22701)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner can run tasks on the native Google Antigravity ACP server
(version 1.5.2)
> - The server turns some prompt text into native slash commands before
the model sees it
> - The admission guard refused only lines that start with "/". The
server runs `/plan` anywhere it follows whitespace, so task text such as
"see /plan for details" could switch the session into plan mode without
Paperclip
> - This pull request makes the guard mirror the server's exact rule for
each advertised command and keeps that text as prose
> - The benefit is that task, comment and pasted text cannot change the
native session mode or sign the account out, and ordinary prose that
mentions a command still runs

## Linked Issues or Issue Description

**What happened?**
The 1.5.2 server builds `_CMD_PATTERN = re.compile(r"(?:\s|^)/(" +
"|".join(...) + r")(?:\s|$)")` (server.py, lines 2071-2075) over its
built-in commands (`plan`) and applies it to every text block in
`_parse_prompt` (server.py, line 2136). The Runner sends the task as one
JSON line. A space before `/plan` survives JSON encoding, so
`{"task":"... then /plan the rollout"}` produced a native plan command.
The old guard did not see it, because no line started with "/".

**Expected behavior**
Task text reaches the model as text. Native commands that change the
session (`/plan`) or the account (`/logout`) never run from task
content.

**Paperclip version or commit**
`master` at the base of this branch, with the Antigravity ACP server
1.5.2 and its owned admission patch `1.5.2-paperclip.2`.

**Steps to reproduce**
1. Send a managed Antigravity prompt whose text contains ` /plan ` after
other words.
2. The old guard admits it unchanged.
3. The server's `_CMD_PATTERN.split` returns a `plan` command for that
text.

The other two advertised commands match only the whole prompt: `/logout`
when all text joined and stripped equals `/logout` (logout.py, lines
29-36), and `/usage` when that text starts with `/usage` and whitespace
or the end, case-insensitively (usage.py, lines 29-36). Python's
`str.strip()` also strips characters that JavaScript does not treat as
whitespace (U+001C..U+001F, U+0085), so `"\u001c/logout"` passed the old
guard and is a logout to the server.

## What Changed

- Add `antigravity-native-commands.ts`. It transcribes the server's
three matchers, with Python's exact whitespace set, and a neutraliser
that puts a word joiner (U+2060) before each slash that the server would
act on. The model still reads the same words. Text that the server
treats as prose is sent unchanged.
- The admission guard now rewrites the outbound `session/prompt` text
with the neutraliser instead of refusing every line that starts with
"/". If a native command still matches afterwards, the guard refuses the
prompt.
- The guard fails closed if the runtime advertises a native command
outside `plan`, `logout`, `usage`, so a future server command cannot
pass silently.
- Text blocks keep their other fields when the guard rewrites them.
- The server advertises exactly `plan`, `logout` and `usage` (server.py,
lines 6289-6299: the SDK's built-in commands, which are only `plan`,
plus the logout and usage entries).
- No change to the native admission patch, so the owned patch version
and closure digests stay the same.

## Verification

- Red first: the new admission tests failed on the old guard (19 failed:
`/plan` mid-line, in the JSON envelope, after a newline, inside quoted
text, after a tab, `"\u001c/logout"`, a command split across blocks, and
benign text the old guard refused).
- Green: `npx vitest run antigravity` in `packages/paperclip-runner` (14
files, 202 tests). `tsc --noEmit -p packages/paperclip-runner` passes.
- Cross-check against the server: I ran the server's own regular
expression and the `is_logout_prompt` / `is_usage_prompt` logic in
Python on 40,000 generated multi-block inputs. The TypeScript matcher
agreed on every input (998 plan, 1,423 logout, 2,941 usage matches).
After neutralisation, the server matched no command, and only word
joiners changed.
- `pnpm verify` exits 2 (the changed test files are outside the resolved
test graphs), so required CI supplies the broad coverage.
- Not run live: no prompt was sent to a real Antigravity session,
because the only available Gemini key is refused. The evidence is the
unit-level reproduction against the guard plus the quoted server source.

## Risks

- Low risk. The guard changes only prompt text that the server would run
as a command, and only by inserting an invisible word joiner. If the
model copies `/plan` from such text into a shell command, the word
joiner could come with it. This applies only to `/plan` followed by
whitespace.
- Prompts with lines that start with "/" (for example a path such as
`/usr/bin/x`) are no longer refused. The server does not treat them as
commands.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1123.0-canary.848600
2026-11-23 16:20:43 -06:00