Commit Graph
8689 Commits
Author SHA1 Message Date
DottaandPaperclip 3fd66c0e12 fix(ui): surface local and hosted sign-in actions on the primary footer button (#23112)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Operators connect AI subscriptions (such as Google Antigravity,
Claude, and Codex) through `AgentProviderConnection` and
`OnboardingWizard`, which share `FooterNav` for the primary step button
> - The remote sandbox login path (`AdapterLoginPanel`) updates the
primary footer button to `Sign in to <Provider>`, `Retry sign-in`, or
`Connecting`, but the local and hosted sign-in path (`useLocalAiLogin` +
`LocalProviderLoginInstructions`) did not wire into `FooterNav`
> - As a result, the primary footer button stayed disabled and labeled
`Connect` both when sign-in failed/expired and when a sign-in URL was
ready, forcing users to hunt for a small muted inline link (`Start
sign-in again` or `Sign in to Antigravity`)
> - This pull request maps `useLocalAiLogin` state onto the shared
primary footer button in both `AgentProviderConnection` and
`OnboardingWizard` and hides the redundant inline retry link on
failed/expired states when the footer owns it
> - The benefit is that the required next action is always the
prominent, enabled primary button on every connect screen

## Linked Issues or Issue Description

**What happened?**
On the Connect Antigravity subscription screens (and other
`useLocalAiLogin` subscription flows), the bottom-right primary button
remained disabled and labeled `Connect` while the required action was a
small muted link inside the card (`Start sign-in again` on
failed/expired sign-in, or `Sign in to Antigravity` when the OAuth URL
was ready).

**Expected behavior**
- When sign-in fails or expires, the primary footer button should be
enabled and labeled `Start sign in`, and clicking it should restart the
sign-in flow.
- When the sign-in URL is ready, the primary footer button should be
enabled and labeled `Sign in to Antigravity` (or the active provider
name), and clicking it should open the authorization URL in a new tab.
- Once sign-in succeeds, the primary footer button should switch back to
an enabled `Connect` button.

**Steps to reproduce**
1. Open the Antigravity app connection screen
(`/apps/connect?source=antigravity`) in a hosted environment with
subscription mode selected.
2. Observe the sign-in prompt state: the primary bottom-right `Connect`
button is disabled while `Sign in to Antigravity` is only a small
underlined link inside the card.
3. Let the sign-in fail or expire and observe the error state: the
primary bottom-right `Connect` button stays disabled while `Start
sign-in again` is only a small underlined link.

## What Changed

- `ui/src/components/AdapterLoginChrome.tsx`:
- Added `resolveLocalLoginPrimaryAction` to map `useLocalAiLogin` state
(`preparing`, `error`/`expired`, `submitting`, `sign_in_required` with
valid HTTP(S) `authorizationUrl`, and `ready`) to a typed primary CTA
descriptor.
- Added optional `primaryHandlesRetry` and `onSubmittingChange` props to
`LocalProviderLoginInstructions` so hosts that surface `Start sign in`
and `Connecting` on `FooterNav` hide the redundant inline error retry
link while standalone callers keep existing behavior.
- `ui/src/components/new-agent/AgentProviderConnection.tsx`:
- Wired `resolveLocalLoginPrimaryAction` into `FooterNav`
(`primaryLabel`, `primaryDisabled`, `primaryIcon`, `onPrimary`) so
failed/expired states render an enabled `Start sign in` button, ready
authorization URLs render an enabled `Sign in to <Provider>` button that
opens the URL in a new tab, and submitting/preparing states show spinner
feedback.
- `ui/src/components/OnboardingWizard.tsx`:
- Wired `resolveLocalLoginPrimaryAction` into `connectCta` and
`handleConnectStepPrimary` for the matching
`LocalProviderLoginInstructions` branch so onboarding has the same
primary CTA behavior.
- `ui/src/components/AdapterLoginChrome.test.tsx`,
`ui/src/components/new-agent/AgentProviderConnection.test.tsx`,
`ui/src/pages/apps/AppsConnect.test.tsx`:
- Added unit and render tests covering `resolveLocalLoginPrimaryAction`,
`primaryHandlesRetry`, enabled `Sign in to Antigravity` opening the
authorization URL, enabled `Start sign in` restarting failed/expired
sign-in without a redundant inline link, and returning to enabled
`Connect` once ready.

## Verification

- Ran `pnpm --filter @paperclipai/ui typecheck` — passed.
- Ran `pnpm exec vitest run
ui/src/components/AdapterLoginChrome.test.tsx
ui/src/components/new-agent/AgentProviderConnection.test.tsx
ui/src/pages/apps/AppsConnect.test.tsx
ui/src/components/ai-connections/useLocalAiLogin.test.tsx` — 4 test
files, 39 tests passed.

## Risks

- Low risk: UI-only change scoped to the `useLocalAiLogin` branch of
`AgentProviderConnection` and `OnboardingWizard`. Standalone
`LocalProviderLoginInstructions` callers default to `primaryHandlesRetry
= false`, and authorization URLs are validated as `http:` or `https:`
before calling `window.open`.

## Model Used

- Google Gemini (Antigravity agent with tool use, file editing, and
shell 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1127.0-canary.868900
2026-11-27 13:37:22 +00:00
DottaandClaude Opus 5.5 7d850ad65e fix(github): a superseded automatic review finishes instead of asking a person (#23064)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - GitHub review bots run automatic reviews for a specific pull request
head
> - When the head has moved on, the review tools refuse the stale review
and explain why
> - That explanation said "an authorized person can request a manual
review", so an agent can read it as a blocker owned by a person
> - On staging, a review task recovered for an already-merged PR did
exactly that: it marked itself blocked and asked the PR author to
request a review
> - This pull request makes the refusal say the review is no longer
needed and that the task should finish as done
> - The benefit is that stale or merged-PR reviews close cleanly instead
of waiting on a person

## Linked Issues or Issue Description

Refs #23049

**Describe the bug**
A review-bot task for a PR merged three days earlier was continued by
the lost-wait recovery (#23049). Its automatic review targeted the PR's
old head. The review tool refused with "no newer automatic review is
queued for it. An authorized person can request a manual review", and
the agent blocked the task, naming the PR author or a maintainer as
owner.

**Steps to reproduce**
1. An automatic review request targets head A of a pull request.
2. The pull request moves to head B (or is merged) with no newer
automatic review queued.
3. The agent calls a review tool; the refusal tells it a person can
request a manual review, and the agent blocks the task.

**Expected behavior**
The agent finishes the task as done; a merged or closed pull request
needs no review, and nothing waits on a person.

## What Changed

- `server/src/services/chat-github-reviews.ts`:
`supersededAutomaticReview` receives the pull request. For a closed or
merged PR the refusal says no review is needed; otherwise it says the
review is no longer needed (or that a newer automatic review is queued).
In every case it tells the agent to finish the task as done and not to
block it or ask anyone to request a review. The error details add
`pullRequestClosed`.
- Test in `github-review-publications.integration.test.ts` for a closed
and an open pull request whose head moved.

## Verification

- New test (`tells a superseded automatic review to finish instead of
waiting on a person`, closed and open): fails on master (the old message
asks for a person), passes here.
- `github-review-publications` and `github-review-workflow` integration
suites: 39 passed. Server typecheck is clean.
- After deploy: a recovered review for a merged PR should finish as done
instead of blocking.

## Risks

- Wording change for one refusal; the reason code and retryability are
unchanged.

## Model Used

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

## Checklist

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

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1127.0-canary.868800
2026-11-27 12:56:25 +00:00
DottaandPaperclip 2caedfe7b0 feat(voice): support outbound call messages, issue transcripts, and optional setup test for Speko (#23052)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The Speko voice connection lets agents call a person's saved phone
number via `call_my_phone` and receive inbound phone calls that create
or continue tasks.
> - Outbound `call_my_phone` took no parameters, so the agent could not
speak a specific update or question when the person picked up, and
outbound call transcripts were not projected onto the bound issue.
> - Setup also blocked activation behind a mandatory two-turn browser
microphone test and failed with HTTP 400 when a Speko persona used a
cascade-only voice on `runMode: "s2s"`.
> - This pull request adds an optional `message` parameter to
`call_my_phone`, projects outbound and inbound phone call transcripts
onto the bound issue, derives inbound task titles from the caller's
request, falls back to a supported S2S voice on 400, and lets verified
Speko setups finish without a browser microphone test.
> - The benefit is that both agent-initiated phone updates (with
responses recorded in the issue) and inbound phone tasks work end-to-end
with reliable setup and full issue transcript visibility.

## Linked Issues or Issue Description

**What existing behavior does this improve?**
Speko voice connection setup (`POST
/api/chat-endpoints/:endpointId/finish`, `ChatEndpointSetup`), outbound
agent phone callbacks (`call_my_phone`), outbound/inbound phone
transcript projection (`voiceCallReports`), and incoming low-trust task
creation (`voiceInboundService`).

**Subsystem affected**
Cross-cutting (multiple of the above)

**Current behavior**
- `call_my_phone` accepts no arguments (`properties: {}`) and always
opens with `"Hi, this is your Paperclip agent calling as requested. Is
now a good time?"`.
- Outbound `call.pre_call` sets `idleRePrompts` to `"I'm still working
on it."` every 10 seconds.
- `voiceCallReports.projectTranscript` only writes the transcript
document onto issues for `guest_intake` sessions, omitting authenticated
outbound and inbound phone calls.
- Incoming `guest_intake` tasks always use the generic title `"Incoming
phone conversation"`.
- Activating a Speko connection requires completing a two-turn browser
microphone conversation before **Call my phone** and **Incoming calls**
settings become accessible.
- `configureVoiceDefaults` fails with HTTP 400 if the selected Speko
persona uses a cascade-only voice when switching to `runMode: "s2s"`.

**Proposed behavior**
- `call_my_phone` accepts an optional `message` string (1–2000 chars)
while still strictly rejecting recipient/phone arguments. Speko speaks
`message` immediately as `firstMessage` and instructs the voice model to
submit caller replies via `submit_request`.
- Outbound `call.pre_call` uses a 25-second conversational check-in
re-prompt instead of `"I'm still working on it."`.
- `voiceCallReports.projectTranscript` writes `"Outbound phone call
transcript"` / `"Phone conversation transcript"` onto the bound issue
for all phone calls (`outbound_phone` and `inbound_phone`), preserving
quarantine guards for `guest_intake`.
- Incoming `guest_intake` tasks derive a readable title from the
caller's first spoken request.
- Verified Speko connections can finish setup via `POST
/api/chat-endpoints/:endpointId/finish` (**Skip test & finish**) without
requiring a browser microphone test.
- `configureVoiceDefaults` falls back to S2S voice `"marin"` if Speko
returns HTTP 400 on `runMode: "s2s"`.

**Reason and benefit**
Makes both core phone workflows usable in production: agents can call an
opted-in person to deliver a concrete update and capture their spoken
response in the issue, callers can phone an agent to start a titled
task, and operators can complete Speko setup without a microphone or
cascade-voice failure.

**Breaking changes**
None. `message` is optional on `call_my_phone` so `{}` callers remain
compatible; existing recipient restrictions (`additionalProperties:
false`) and quarantine boundaries are preserved.

## What Changed

- Added optional `message` parameter to `call_my_phone` in
`server/src/services/voice/speko-agent-tools.ts`, threaded
`openingMessage` into `voice-session-service.ts`, `voice-prompts.ts`
(`buildOutboundPhoneVoicePrompt`), and `speko-provider.ts`
(`createPhoneSession`), and updated `speko-skill.ts`.
- Extended `voiceCallReports.projectTranscript` in
`server/src/services/voice/voice-call-reports.ts` to project phone call
transcripts onto the bound issue for `outbound_phone` and
`inbound_phone` sessions while keeping `guest_intake` quarantine
enforcement intact.
- Derived readable issue titles from the first `submit_request` text for
incoming `guest_intake` calls and refined outbound `call.pre_call`
`idleRePrompts` in `server/src/services/voice/voice-inbound-service.ts`.
- Added S2S voice fallback (`voice: "marin"`) on HTTP 400 in
`speko-provider.ts` (`configureVoiceDefaults`).
- Enabled optional test skip (`POST
/api/chat-endpoints/:endpointId/finish`) for verified Speko endpoints in
`server/src/services/chat-channels/setup-probes.ts` and added a **Skip
test & finish** button in
`ui/src/pages/apps/chat/ChatEndpointSetup.tsx`.
- Updated `packages/shared/src/app-definitions/speko.json` guidance
copy.
- Added unit and real-Postgres integration regressions in
`server/src/__tests__/speko-provider.test.ts` and
`server/src/__tests__/voice-session-store.integration.test.ts`.

## Verification

- `pnpm --filter @paperclipai/shared build && pnpm --filter
@paperclipai/server typecheck && pnpm --filter @paperclipai/ui
typecheck` — passed (0 errors across server layers and UI).
- `pnpm exec vitest run server/src/__tests__/speko-provider.test.ts
server/src/__tests__/speko-protocol.test.ts
server/src/__tests__/speko-call-report.test.ts
server/src/routes/voice-sessions.auth.test.ts` — 53/53 passed.
- `pnpm exec vitest run
server/src/__tests__/voice-session-store.integration.test.ts` — 133/133
passed (including new `call_my_phone` message + outbound transcript
projection, derived inbound title, and Speko finish-without-test
regressions).
- `pnpm exec vitest run ui/src/api/voiceSessions.test.ts
ui/src/components/voice/ ui/src/lib/voice-call-attempt.test.ts
ui/src/lib/voice-session-controller.test.ts
ui/src/lib/voice-transcript.test.ts
server/src/__tests__/chat-channels/slack-setup-and-registration.integration.test.ts`
— 161/161 passed.
- `pnpm run check:token-gates` — all 4 gates clean.
- Live local verification against Speko API + webhook-only Cloudflare
quick tunnel: verified Speko setup + `/finish` activation, live
`claude_local` MCP discovery of `call_my_phone` with `message`, live
Speko session create/inspect/end + signed `call.status`/`call.report`
callbacks through tunnel, and inbound `call.pre_call` + `submit_request`
creating a titled task.

## Risks

- Low risk. Additive optional schema field on `call_my_phone` (still
rejects unknown keys such as `to`). No database migrations required.
Transcript projection for authenticated calls writes only to the
session's bound issue under the existing per-session advisory lock. Live
PSTN audio still requires real-phone end-to-end confirmation after
staging rollout.

## Model Used

- Google Gemini 4 Neon (High) via Antigravity with tool use and local
code execution.

## Checklist

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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-27 06:52:33 -06:00
9c91c097bd fix(workspaces): run the full-disk read-only inventory's Git reads under the sandbox storage guard (#23095)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - A Cloud sandbox saves the agent's workspace when a run ends. When
the sandbox disk is full, a read-only fallback copies the workspace
without writing to the sandbox (#19465).
> - Before the copy, the fallback runs an inventory of the workspace
inside the sandbox. For each Git repository, the inventory runs `git
rev-parse`. For an untracked `node_modules` or virtual environment, it
also runs `git ls-files`.
> - Cloud sandboxes now put a Git storage guard first on `PATH`. The
guard reads its limits from three environment settings:
`PAPERCLIP_GIT_MIN_FREE_BYTES`, `PAPERCLIP_GIT_MIN_FREE_INODES` and
`PAPERCLIP_GIT_MAX_GROWTH_BYTES`. Without them, it refuses every Git
command as misconfigured (exit 75).
> - The inventory gives Git a minimal environment, and that environment
drops the three settings. Thus the guard refuses the first Git read, and
the inventory refuses every Git workspace as an unsafe source.
> - This pull request keeps the guard's three settings in the
inventory's Git environment. It also records a guard refusal by its own
reason.
> - The benefit is that a full-disk save of a Git workspace can complete
again. If the guard refuses Git below its free-space floor, the recorded
cause says so.

## Linked Issues or Issue Description

Refs #19465, #19619, #22546, #22848

**What happened?**
On staging, full-disk workspace saves fail again on releases since the
sandbox image added the Git storage guard. Nine saves from 2026-11-24 to
2026-11-27 recorded this cause:
`remote_workspace_sandbox_disk_full: ...;
remote_workspace_readonly_capture_failed: stage=inspect
reason=unsafe_source transport=provider_error`.
All of them ran on releases that contain #22546. Thus the earlier
`budget_exceeded` refusal is fixed, and this refusal is the next one.

**Expected behavior**
The read-only inventory runs Git with the same guard settings that
normal capture gets. Normal capture keeps `process.env` for Git, so the
guard is configured there. A Git workspace that normal capture could
save passes the inventory.

**Steps to reproduce**
1. In a Cloud sandbox, put the storage guard first on `PATH`. Set its
three settings in the sandbox environment (the image sets them for the
sandbox process tree).
2. Run `readonlyWorkspaceInventoryScript()` on a Git workspace.
3. On `master`, the script exits 1 with
`remote_workspace_readonly_capture_unsafe`. With this change, it returns
the inventory.

**Relevant logs or output**
`paperclip_git_storage_limit: Git's storage guard is unavailable or
misconfigured; Git did not complete.` The guard writes this message when
its settings are missing.

## What Changed

- `readWorkspaceInventory` copies the three guard settings from
`process.env` into its Git environment when they are set. It copies no
other variable. The Git isolation settings do not change.
- When Git fails and the guard wrote a `paperclip_git_storage_limit:`
line, the inventory reports
`remote_workspace_readonly_capture_git_storage_limit` for a free-space,
inode or growth refusal. It reports
`remote_workspace_readonly_capture_git_storage_guard_unavailable` for
any other guard refusal. All other Git failures still report
`remote_workspace_readonly_capture_unsafe`.
- The sandbox script passes these two fixed tokens through, the same as
the budget token. It still writes no error text or paths.
- `captureReadOnlyWorkspaceArchive` records them as
`reason=git_storage_limit` and `reason=git_storage_guard_unavailable`.
- The sandbox command filter (`READONLY_INVENTORY_FAILURE`) forwards the
two new tokens. Without this, `command()` drops them and the fallback
records `reason=operation_failed`.

## Verification

- New `remote-workspace-readonly-inventory-git-guard.test.ts`: it puts a
stand-in guard on `PATH` that behaves like the sandbox guard. All 3
tests fail on `master` with `remote_workspace_readonly_capture_unsafe`.
All 3 pass with this change.
- New case in `remote-workspace-readonly-capture-cause.test.ts`: a guard
refusal of `ls-files` is recorded as `stage=inspect
reason=git_storage_limit` before any transfer. I could not run this case
locally because the sandbox has no full dependency install. CI verifies
it.
- Real guard check: I ran the inventory script from `master` and from
this branch on a real 857 MB Paperclip workspace (18,849 entries). It
ran through the actual sandbox guard, with the sandbox's own settings in
the environment. `master` refused the workspace with
`remote_workspace_readonly_capture_unsafe`. This branch returned the
inventory.
- A strict TypeScript check of the changed inventory module passes. CI
runs the full typecheck.

## Risks

- Low risk. Only the three guard settings are added to the Git
environment. Git still runs with no system or global configuration, no
hooks, no optional locks and no lazy fetch.
- The guard still applies its free-space floor. Below the floor, it
refuses `ls-files`. Thus a Git workspace with an untracked
`node_modules` or virtual environment can still fail the fallback when
free space is below the floor. The recorded cause now shows
`reason=git_storage_limit` for that case, so a follow-up can use real
evidence.
- Outside a guarded sandbox, the settings are not set and nothing
changes.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution
in a Paperclip agent sandbox.

## Checklist

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

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

---------

Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1127.0-canary.868600
2026-11-27 12:43:54 +00:00
635ed5a364 fix(skills): start skill package transfer deadlines after the I/O queue admits them (#22615)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Before a run starts, Paperclip copies each selected skill version
from skill package storage into a local cache.
> - Skill package reads share small I/O queues for each process. Each
queue has 2 active permits and 32 waiting slots.
> - Each read started its 180-second deadline before it waited for a
permit. A read that waited behind other transfers used up its deadline
in the queue.
> - On a busy host, a run then failed before its agent started with
"Failed to materialize the selected skill version: The operation was
aborted due to timeout". The next run did the same cold read and failed
the same way.
> - This pull request starts each transfer deadline when the queue
grants the permit.
> - The benefit is that a cold skill read under load waits for its turn
and then gets its full transfer deadline.

## Linked Issues or Issue Description

**What happened?**
A staging host had a burst of 21 run failures in 15 minutes. All runs
were in one company, and each failed with "Failed to materialize the
selected skill version: The operation was aborted due to timeout". The
runs woke at the same time after a provider usage limit reset. The skill
cache was cold.

**Expected behavior**
A run that waits for a skill package I/O permit gets the full 180-second
deadline for its own transfer. Time spent in the queue must not count
against that deadline.

**Steps to reproduce**
1. Make the skill package cache cold for three companies.
2. Stall the archive reads of two companies, so that they hold both
storage permits.
3. Resolve the runtime skills of the third company. Its reads now wait
in the queue.
4. Wait longer than the transfer deadline, then release the stalled
reads.
5. On `master`, the third company's skill resolves as missing with the
timeout message. Its own transfer would take milliseconds.

**Paperclip version or commit**
`master` at 7a2ee0da1c.

## What Changed

- `withPackageIo` now creates the transfer deadline after it grants the
permit, and gives the action that signal. A queued wait stops only when
the caller cancels.
- Manifest loads, isolated package reads, warm package materialization,
durable verification, cached version reads and single-file reads no
longer start a deadline before they queue. Each transfer still has the
same 180-second deadline.
- The cold-response permit gets no deadline of its own. That permit only
bounds decoded responses until cleanup. The storage transfer inside it
still has its deadline.
- An isolated read now gives its consumer the transfer signal. The
cached file reads inside that consumer use it.
- Package uploads (`prepare`) are not changed.
- Added the regression test `starts package transfer deadlines after
queued storage waits`.

## Verification

- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/skill-package-store.test.ts -t "starts package transfer
deadlines"`
  - With this change: passes.
- With `master`'s `skill-package-store.ts`: fails. The skill resolves as
missing with "Failed to materialize the selected skill version: The
operation was aborted due to timeout".
- Related suites: `skill-package-store`, `skill-package-upload`,
`skill-version-cache`, `skill-version-retention`, `runtime-skill-cache`,
`company-skills-runtime-concurrency`,
`company-skills-runtime-selection`, `managed-skill-content`,
`skill-repository-package`, `skill-version-cache-lock`,
`skill-package-work`, `skill-package-storage-migration`,
`skill-package-storage-migration-postgres` and `skill-package-recovery`.
235 of 236 tests pass.
- The only failure is `bounds and validates archives, binaries, paths,
executable modes, and corruption`. It also fails on unchanged `master`
in the same sandbox, because the sandbox `umask` is `077`. It is not
related to this change.
- A timing probe with 20 concurrent cold resolves in one company and 4
other cold companies failed on `master` and passed with this change.

## Risks

- A queued read can now wait longer before it fails. The wait is still
bounded, because each queue has at most 32 waiting reads and every
active transfer has its own deadline. A full queue still returns "Skill
package storage is busy; retry shortly." immediately.
- After a cold fill is published, cache trimming is no longer bounded by
the fill's deadline. Trimming keeps its own 10-second limit, and each
storage check inside it has its own transfer deadline.
- If a manifest read times out, the store now tries the saved legacy
contents or the restore recipe before it fails. Before, the timeout
stopped it before those fallbacks. Both fallbacks are already
authoritative sources for the same manifest.
- Low risk otherwise. The change is limited to `skill-package-store.ts`.

## 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
- [ ] 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: #22310 changes `skill-package-runtime.ts` and the same test
file. It does not change these deadlines.

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

Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
nightly/v2026.1127.0-nightly.0 canary/v2026.1127.0-canary.868500
2026-11-27 07:08:10 +00:00
TonioandClaude Fable 5.2 dadbc495b3 feat(ui): move the connection page to the Plugins design (#23029)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Plugins page is where a person connects tools to agents and sets
what those tools can do
> - #22869 and #23005 moved Browse, the plugin page, and Reviews to the
Plugins marketplace design
> - The connection page that opens after a successful connection kept
the old design and an old side rail
> - A person who connects a plugin lands on a page that does not look
like the page they came from, and the plugin page does not show a clear
way back to it
> - This pull request applies the plugin page design to the connection
page and adds a Settings button to each account row on the plugin page
> - The benefit is one consistent path: Plugins, then the plugin, then
the account settings

## Linked Issues or Issue Description

Refs #22869, #23005

**What existing behavior does this improve?**

The connection page at `/apps/:connectionId/permissions` and
`/apps/:connectionId/review`, and the account rows on the plugin page.

**Subsystem affected**

UI, Plugins (Apps catalog) pages.

**Current behavior**

- The connection page shows a second side rail with "All connectors",
Permissions, and Review.
- The page uses a left-aligned column, ruled dividers, bordered chips,
and raw palette colors for the status badge.
- The plugin page opens the connection page only from the account name
and the "⋯" menu.

**Proposed behavior**

- The connection page has no second rail. It shows a back link to the
plugin, the header, and Permissions and Review as tabs in the page. The
Review tab shows the count of waiting items.
- The page uses the centered column, the quiet section labels, and the
rounded grouped surfaces of the plugin page.
- The Read and Write action groups are grouped cards. The control that
sets all actions is in the card header.
- Each account row on the plugin page has a Settings button that opens
the connection page.
- The breadcrumb reads Plugins, plugin, account.

**Reason and benefit**

The page after a connection matches the plugin page. A person can go
from the plugin to its account settings and back with one click.

**Breaking changes**

None. The routes, the labels that assistive technology reads, and the
permission logic do not change.

## What Changed

- `Layout.tsx`, `Layout.production.tsx`: connection routes no longer
mount `AppDetailSidebar`. The page for an app that is not connected
keeps its rail.
- `AppDetail.tsx`: new page shell, a restyled `AppDetailHeader`, an
exported `ConnectionBackLink`, and `ConnectionTabs` with the review
count. The status badge uses status tokens.
- `IdentitiesSection.tsx`, `PermissionsPanel.tsx`,
`AgentConnectionAccess.tsx`: quiet labels and grouped surfaces. No logic
changes.
- `Browse.tsx`: a Settings button on each account row that is not a
draft.
- `AiConnectionPoolConnector.tsx`: a "Plugins" back link, because the
rail that held it is gone.
- `replay-masking.test.tsx`, `connection-pools.spec.ts`: updated for the
new header class and the new back link.

## Verification

- `cd ui && pnpm typecheck`: pass.
- `pnpm run check:token-gates`: all gates clean.
- `node scripts/check-query-error-rendering.mjs`: 0 findings.
- `npx vitest run` on the 11 test files that import the changed
components: 732 passed, 1 skipped.
- `npx playwright test --config tests/e2e/playwright.config.ts
tests/e2e/connection-reviews.spec.ts
tests/e2e/apps-prosumer-mcp-flow.spec.ts
tests/e2e/applications-crud.spec.ts`: 9 passed, 1 skipped.
- Manual check in a local instance, dark theme, with a Context7
connection: the Permissions tab, the Review tab, and the Settings button
on the plugin page.
- Not run: `tests/ai-connections-app/connection-pools.spec.ts`. Not
checked in the browser: the GitHub repositories block, the reconnect
banner, the light theme, and narrow widths.

## Risks

- Low. The change is presentation only for the sections, and the routes
are the same.
- The connection pool page lost the rail. Its only way back is now the
"Plugins" back link and the breadcrumb.
- The page for an app that is not connected still has the old rail. This
is a known inconsistency.

> 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 Fable 5.2 (`claude-fable-5-2`) in Claude Code, with tool use,
code execution, and a browser preview.

## Checklist

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

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

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
canary/v2026.1126.0-canary.868400
2026-11-26 18:25:15 +00:00
DottaandClaude Opus 5.5 1480f716c9 test(recovery): pin the 7-day window for chat setup failures; reattach listSuspects docs (#23063)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The assigned-work sweep now continues a blocked chat-channel task
whose latest run failed in setup before provider work (#23059)
> - Review on #23059 left three non-blocking points: the 7-day run-age
limit had no test, the `listSuspects` doc comment was separated from its
function, and the rule has SQL and TypeScript twins
> - This pull request adds the missing boundary test and restores the
doc placement
> - The benefit is that widening or removing the age limit now fails a
test, and the code reads as it did

## Linked Issues or Issue Description

Refs #23059, #23051

**Describe the bug**
Review follow-up, no user-visible bug. The 7-day limit on how old a
setup failure may be for a chat task to continue automatically had no
test, so a regression that widened or removed it would pass. The
`listSuspects` doc comment was split from `listSuspects` by a new
helper.

**Steps to reproduce**
1. Remove the run-age condition from `latestRunFailedBeforeProviderWork`
and `chatFailedBeforeProviderWork`.
2. The existing tests still pass.

**Expected behavior**
A test fails when the 7-day limit is removed.

## What Changed

- `assigned-work-invariant.test.ts`: a recently blocked chat task whose
setup failure ended 8 days ago is not a sweep suspect and is judged a
conversation wait. The test helper takes an optional `blockedAgoMs` so
the block can be recent while the run is old.
- `assigned-work-sweep.ts`: the `listSuspects` pre-filter doc comment
sits directly on `listSuspects` again; the SQL predicate's comment names
its TypeScript twin and the test that covers both.

## Verification

- `assigned-work-invariant.test.ts`: 35/35 pass. With the age condition
removed from both twins, the chat setup-failure test fails (checked),
then passes again with it restored.
- Server typecheck is clean.

## Risks

- Test and comment changes only; no behavior change.

## Model Used

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

## Checklist

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

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1126.0-canary.868300
2026-11-26 17:21:06 +00:00
DottaandClaude Opus 5.5 4a9ecd3aca fix(recovery): continue blocked chat tasks whose run failed before provider work (#23059)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The assigned-work sweep continues open agent tasks that have nothing
running and do not wait on a person
> - #23051 made a setup failure before provider work continue
automatically. Two review tasks on staging stayed blocked after it was
deployed.
> - Both tasks come from a chat channel (GitHub review bots). The sweep
treats every chat-channel task as "waiting on a person's next message".
It leaves these tasks out of its suspect list and gives them the
`conversation` waiting reason.
> - The agent never got the message, because its only run failed in
setup before provider work. So the task waits on the system, not on a
person.
> - This pull request lets the sweep judge a blocked chat-channel task
like any other task when its latest run failed in setup before provider
work.
> - The benefit is that these review tasks continue without a Retry, and
so do the two tasks on staging.

## Linked Issues or Issue Description

Refs #23051

**What happened?**
After #23051 was deployed to staging, two GitHub review tasks stayed
`blocked` with no new run. The sweeps ran, and other blocked tasks were
continued. Each task's only run was legacy, failed with `setup_failed`
during environment lease acquisition, and recorded `executionRecovery: {
kind: "bootstrap", providerWorkStarted: false }` about 43 hours earlier.
The tasks have `originKind: "chat_channel"`.

**Expected behavior**
The sweep continues a blocked task whose run failed before provider
work, with bounded backoff, also when the task comes from a chat
channel.

**Steps to reproduce**
1. Create a chat-channel task assigned to an agent. Its only run fails
with `setup_failed` before provider work. Block the task, with or
without a board recovery hold.
2. Run the assigned-work sweep.
3. Before this change, `listSuspects` does not return the task.
`evaluateAssignedWork` returns `waiting: conversation`, and no
continuation is queued.

## What Changed

- `server/src/services/recovery/assigned-work-sweep.ts`:
- The suspect pre-filter still leaves chat-channel tasks out, except a
blocked one whose latest run (by its assignee) failed in setup before
provider work within the last 7 days
(`latestRunFailedBeforeProviderWork`).
- The facts loader no longer marks such a task as a conversation
(`chatFailedBeforeProviderWork`, the TS twin). The latest-run read now
also carries `executionRecovery`.
- Agent chat conversations (`conversationAgentId`) are unchanged. Chat
tasks whose agent may have started work still wait for their
conversation.
- Retry limits do not change. The per-task continuation allowance, the
process-wide repair budget, and the company-wide automatic run brake
apply as for every other sweep continuation.

## Verification

- New red/green test in
`server/src/__tests__/assigned-work-invariant.test.ts`: "continues a
chat-channel task blocked by a legacy setup failure before provider
work, with or without a hold". It uses the staging run shape: legacy,
`setup_failed`, the same `resultJson` keys, the only run, about 43 hours
old. Before the fix it failed (the tasks were not sweep suspects). After
the fix, both the held task and the unheld task are continued. A chat
task whose provider work may have started still waits (`conversation`),
and an in-progress chat task is not a suspect.
- In the same test, with the real heartbeat wake queue, the continuation
of a held chat task is admitted as a new `issue_continuation_needed`
run.
- `npx vitest run src/__tests__/assigned-work-invariant.test.ts`: 35/35
pass.
- `tsc --noEmit` for `server` passes.

## Risks

- The sweep now acts on some chat-channel tasks. The scope is narrow:
the task is blocked, its latest run is its assignee's and failed in
setup before provider work, and the run ended in the last 7 days.
Retries stay bounded by the existing per-task allowance and the
company-wide brake.
- After deploy, chat tasks blocked this way in the last 7 days are
continued. The repair budget and the brake pace them.

## Model Used

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

## Checklist

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

> - Paperclip is the open source app people use to manage AI agents for
work
> - Native OpenCode agents run in remote sandboxes. The controller gives
each Runner launch the provider-pack paths of Node, the OpenCode proxy
and the OpenCode executable
> - When exact resume of a provider session fails, Paperclip archives
the old session and opens a replacement session on the same backend
> - The archive drops the restored provider artifacts and their launch
paths. The replacement transport reads its launch inputs when it is
built, before its Runner is staged
> - A session restored from saved artifacts never selects a pack root,
so the replacement had no OpenCode executable. The run failed as
`runner_remote_provider_artifact_incompatible` and the task stayed
blocked. Other replacements launched from the pack root while the saved
receipt named the artifact root, and the next continuation's Runner
rejected that launch
> - This pull request stages the launch inputs again before the
replacement opens, reports a missing launch input as a retryable
controller gap, and continues tasks that older releases blocked this way
> - The benefit is that a GitHub review (or any OpenCode task) that hits
a resume failure continues by itself instead of needing a Retry

## Linked Issues or Issue Description

Refs #22981 (it scoped staged provider assets per provider; it did not
cause or fix this failure)

**What happened?**
An OpenCode review run on a hosted instance failed with
`runner_remote_provider_artifact_incompatible: OpenCode executable is
missing from the provider pack`. The task stayed blocked with no later
run. The run log showed the adopted Runner first refusing `run.attach`
with "OpenCode run.prepare launch does not match the runner-owned
qualified profile". The previous run of the same session had replaced
its provider session after a failed exact resume.

**Expected behavior**
A replaced provider session launches with the same verified OpenCode
inputs as any other launch, and the task continues without a person
pressing Retry.

**Steps to reproduce**
1. Run an OpenCode agent in a remote sandbox with durable harness
storage, so the session restores its provider artifacts.
2. Make exact resume fail, so the backend opens a replacement session.
3. Build the replacement transport. It has no `opencodeCommand`, and the
transport throws "OpenCode executable is missing from the provider
pack".

**Paperclip version or commit**
master at 85ad16b47e

## What Changed

- `native-session-executor.ts`: `openReplacementSession` stages the
remote Runner launch inputs again (`prepareNativeRemoteRunner`) after
the continuity archive and before the replacement session opens. The
replacement now launches from the same verified artifact root that its
saved receipt names.
- `runnerd-codex-transport.ts`: a controller launch that omits
provider-pack inputs (OpenCode executable, proxy, provider Node, ACPX
sidecar, or verified digests) now fails as
`runner_remote_provider_launch_unprepared`. The pack itself was never
judged, so this is not a pack incompatibility.
- `native-session-executor.ts`:
`runner_remote_provider_launch_unprepared` is classified by name and is
not permanent. The run retries with a fresh backend (bounded to three
attempts, 30 s apart), which prepares the inputs again.
- `continuation-cause.ts`, `native-interruption-continuation.ts`: an
active hold left by an older release with cause
`runner_remote_provider_artifact_incompatible` and the exact legacy
"OpenCode executable is missing from the provider pack" error now goes
through the native interruption lane. That lane starts one fresh
continuation, with the existing pacing. Genuine pack incompatibilities
stay held.

Previous-release story (upgrade-safe run state): no persisted shape
changes. A session saved by the previous release with a replacement
launched from the pack root is not resumed in place. The fresh
continuation archives it and launches a new provider session from
verified inputs.

## Verification

- Red/green: `native-session-executor.test.ts` variant
`opencode-continuation-prior-receipt-replacement`. Without the fix, the
replacement transport options have no `opencodeCommand` or
`providerNodeCommand` (the staging failure). With the fix, they name the
artifact root.
- `fresh-continuation-fallback.test.ts`: a task held by the legacy
failure gets exactly one fresh successor. A task held by a real manifest
digest mismatch stays blocked.
- `native-session-executor.test.ts`: the new code is retried in the same
run and exhausts at the third attempt.
- Commands:
- `cd server && npx vitest run
src/services/native-runtime/native-session-executor.test.ts
src/services/fresh-continuation-fallback.test.ts`
- `cd packages/paperclip-runner && npx vitest run
src/live/runnerd-codex-transport.test.ts`
  - `npx tsc --noEmit` in `server` and `packages/paperclip-runner`
- Not verified locally: a live remote sandbox replacement. Staging
verification follows the deploy.

## Risks

- A replacement session now stages the remote Runner and provider pack
again. This adds the normal preparation time only on the replacement
path, which already starts a new provider session.
- If the controller keeps omitting launch inputs for another reason, the
run retries at most three times and then blocks as
`native_session_retry_exhausted`. No retry storm is possible.
- The legacy match is exact on the error text, so other
`runner_remote_provider_artifact_incompatible` failures keep their
current behavior.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell,
code search, test 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.1126.0-canary.868100
2026-11-26 14:12:16 +00:00
DottaandClaude Opus 5.5 50633695e7 fix(native-runtime): keep external chat waits when finalization retries after the run settles (#23049)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Native runs can end by waiting for the next external chat message,
for example a GitHub review agent that waits for the next push
> - The finalizer must prove that the run still owns the task before it
records that wait
> - When the first status commit loses a lock race, the finalizer
retries later. By then the heartbeat has settled the run and released
the task execution
> - The retry then reads "authorization lost", so the task stays
`in_progress` with no run and no registered wait
> - This pull request keeps the wait authority for a settled run whose
own saved result is still being applied, and gives tasks already in this
state one bounded continuation
> - The benefit is that these tasks never sit idle with no next step

## Linked Issues or Issue Description

**What happened?**
A GitHub review agent published a review and yielded with a
`response_wake` continuation. The run ended with
`finalizationReasonCode: external_chat_response_wait_authorization_lost`
and `finalizationFailureCount: 1`. The task stayed `in_progress` with no
run for more than 16 hours. Earlier runs on the same tasks ended with
`external_chat_response_waiting`. Two tasks showed this on staging.

**Expected behavior**
The run records `external_chat_response_waiting`, and the task waits for
the next GitHub event. If the wait truly cannot be registered while chat
access is still allowed, the task gets one continuation instead of an
idle `in_progress` state.

**Steps to reproduce**
1. Start a native external-chat turn that yields with `response_wake`.
2. Hold a row lock that the status committer needs (for example the chat
endpoint) until the finalizer's quick retries end with
`status_cas_exhausted`.
3. Settle the run as `succeeded` and release the task execution, as the
heartbeat does.
4. Let the scheduled finalization retry run. The decision is
`external_chat_response_wait_authorization_lost`.

**Paperclip version or commit**
`master` at 85ad16b47e.

## What Changed

- `resolveExternalChatResponseWaitAuthorizationInTransaction` accepts a
settled owner in addition to a live owner. The check is
`settledRunOwnsResponseWait` in the new
`external-chat-wait-authorization.ts`. A settled owner is a `running` or
`succeeded` run with no other execution or checkout run on the task and
no newer run of the task in any state, and either:
  - its own saved result is still being finalized, or
- its committed decision is
`external_chat_response_wait_authorization_lost`.
The assignee, agent status, inbound message links, and current principal
and destination policy are still checked as before.
- The newer-run check is one shared predicate, `hasNewerIssueRun` in the
new `native-run-ownership.ts`. `readPreservedNativeResultFinalization`
now uses it too, and it compares timestamps in SQL.
- `readPublishedGitHubReviewCompletionContinuationInTransaction` lets
the same authorization decide ownership for a `succeeded` run.
- `EXTERNAL_CHAT_RESPONSE_WAIT_AUTHORIZATION_LOST` moves to
`status-arbiter.ts`, which owns the reason.
- The stranded-task sweep (`continueUnregisteredExternalChatWait`) now
finds a settled external-chat turn whose wait was lost while chat access
is still allowed. It queues one continuation
(`issue.external_chat_wait_recovery`) with `retryOfRunId` set to that
turn. It skips the task when a wake is already queued. The sweep has
already checked the budget at that point. A wait lost because chat
access was revoked stays parked, as before.
- The continuation uses an issue-state guard. Under the issue lock, the
queue checks that the task is still `in_progress` for the same assignee,
and that no wake or run already continues the source run (new
`withoutSuccessorOfRunId`). Overlapping sweeps therefore queue at most
one continuation.
- `chat-attachment-reuse.ts`, `recovery/service.ts` and
`heartbeat/queue.ts` were already over 1,000 lines. The new ownership
check is in its own module. The sweep helper and the queue guard stay
next to the code they extend.

## Verification

- Red, then green: `keeps the response wait when a contended
finalization is retried after the {run settled, execution released, run
settled and execution released}` in
`server/src/services/native-runtime/external-chat-wait.integration.test.ts`.
Before the fix all three cases recorded
`external_chat_response_wait_authorization_lost`.
- Red, then green: `continues a settled task whose response wait was
lost while chat access is still allowed` queues exactly one continuation
over two sweeps. The `revoked` case queues none.
- Red, then green: `queues one continuation for a lost wait when
recovery passes overlap through the real queue`. Without the queue guard
it saved two continuation wakes.
- `re-derives a published review wait when its contended finalization is
retried after the run …`: a settled published-review turn records
`external_chat_response_waiting` in `in_review`; with a newer queued run
it records `external_chat_response_wait_authorization_lost`.
- `authorizes a settled run's lost wait only with …`: another execution
run, another checkout run, a terminal finalization, or a committed
decision with another reason revokes the wait.
- `npx vitest run
src/services/native-runtime/external-chat-wait.integration.test.ts
src/__tests__/issue-list-review-wait-authorization.integration.test.ts
src/__tests__/chat-channels/github-review-response-maintenance.integration.test.ts
src/services/native-runtime/status-arbiter.test.ts` (in `server/`): 389
passed.
- `npx tsc --noEmit -p server/tsconfig.json`.

## Risks

- A settled run can now authorize its wait when no newer run owns the
task. A newer run in any state, another execution or checkout run, or a
run that is not `running` or `succeeded` still revokes the wait.
- Tasks already in this state get one continuation run after deploy. The
sweep skips the task when the budget blocks new work, and it queues at
most one continuation per stranded turn.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), 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-26 14:00:22 +00:00
DottaandClaude Opus 5.5 4bf6a50e9d fix(recovery): continue tasks blocked by a setup failure before provider work (#23051)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Task recovery continues interrupted work so that nobody has to press
Retry
> - A run can fail during setup before any provider work starts. For
example, the environment lease is refused because the sandbox snapshot
qualification is stale.
> - Such a run records the generic `setup_failed` code with
`executionRecovery: { kind: "bootstrap", providerWorkStarted: false }`.
Only the named transient setup codes counted as "continues
automatically", so the board escalation kept the task blocked behind a
manual Retry.
> - On staging, two review tasks stayed blocked this way for days, with
no later run.
> - This pull request makes every setup failure that ended before
provider work continue automatically, under the existing per-task
allowance and the company-wide automatic run brake.
> - The benefit is that a task that never started does not need a
person. Tasks already blocked this way continue after deploy.

## Linked Issues or Issue Description

**What happened?**
Two review tasks on staging failed in their first run with
`setup_failed` ("Failed to acquire lease for environment ...
sandbox_snapshot_qualification_required"). No provider work started.
Each task stayed `blocked` with a system-owned failed interruption and
`canRetry: true`. No automatic continuation followed.

**Expected behavior**
A system-owned setup failure before provider work continues
automatically with bounded backoff. The needed-retry rate is 0%.

**Steps to reproduce**
1. A task's first run fails in setup before dispatch with the generic
`setup_failed` code (for example, a refused environment lease).
2. Generic continuation recovery escalates the task to a board-owned
stranded hold and blocks it.
3. The assigned-work sweep leaves the task to the hold owner
(`left_to_hold_owner`), because `continuesAutomatically` accepted only
the named transient setup codes.

## What Changed

- `continuation-cause.ts`: add `isSetupFailureBeforeProviderWork` and
its SQL twin `setupFailureBeforeProviderWorkSql`. Each matches any
`SETUP_FAILURE_CODES` value, including `setup_failed`, when the run
recorded bootstrap with `providerWorkStarted: false`.
`continuesAutomatically` and `continuesAutomaticallySql` use them for
first-run failures.
- `stranded-hold-continuation.ts`: a stranded hold from such a failure
stays eligible for 7 days (`STRANDED_PRE_PROVIDER_SETUP_MAX_AGE_MS`, the
same as the sweep's `STALE_BLOCK_MS`). Other causes keep the 24-hour
window. Tasks blocked before this release are continued after deploy
without a Retry.
- `assigned-work-sweep.ts`: the suspect pre-filter uses the same longer
window for this failure class.
- Repetition stays bounded by existing mechanisms: the per-task
`continuationAllowance` (2, 4, 8, then 15-minute spacing, at most 6 an
hour), the process-wide repair budget, and the company-wide automatic
run brake. The brake already counts `providerWorkStarted=false` failures
as `failed_before_starting`.

## Verification

- New red/green test in
`server/src/__tests__/assigned-work-invariant.test.ts`: "continues a
task blocked by an environment setup failure before any provider work,
including one blocked days ago". It failed before the fix (the task was
not a sweep suspect). It passes after the fix. A task blocked 40 hours
ago is continued once, and the hold resolves as restored. Work that may
have started, or a run without the bootstrap record, stays with the hold
owner. A block older than 7 days is not touched.
- The existing "temporary setup failure" case now uses an 8-day-old
block for its "old" control, because pre-provider setup failures are now
eligible for 7 days.
- `npx vitest run src/__tests__/assigned-work-invariant.test.ts`: 34/34
pass.
- Related suites: fresh-continuation-fallback, run-completion,
task-retry, task-interruption-presentation, retries, dot-runner,
issue-recovery-actions, recovery-observability,
released-writer-escalation, github retry/recovery integration, and
others. 920 tests pass. Locally, `run-completion.test.ts` reports only
an `afterAll` embedded-Postgres teardown timeout. All of its 263 tests
pass.
- `tsc --noEmit` for `server` passes.

## Risks

- A generic `setup_failed` that is really deterministic is now retried
automatically. The per-task allowance (at most 6 an hour, with backoff)
and the company-wide brake bound this. These are the same bounds that
recovery runs failing with `setup_failed` already use. Person-owned
causes have their own codes and are not affected.
- After deploy, blocked tasks from the last 7 days that match this class
are continued. The process-wide repair budget and the brake pace them.
- The stranded notice text for `setup_failed` still mentions Retry. The
sweep continues the task within the settling grace, and its activity
says that no Retry is needed.

## Model Used

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

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [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-26 13:57:19 +00:00
Dotta 880b0c3a7c perf(ci): reuse verified macOS runtime artifacts from master runs cancelled downstream (#23044)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - `docker.yml` and `docker-merge-group.yml` bundle the native macOS
SSH runtime produced by `macos-runner-runtime.yml`, reusing a cached
artifact by inputs digest when possible
> - `scripts/macos-runner-runtime-cache.mjs` only reused an artifact
when the entire `docker.yml` run concluded `success`
> - Whenever a `master` `docker.yml` run was cancelled downstream (e.g.,
on a flaky post-merge test shard) after both `macos_runner_runtime /
build` and `verify_linux_controller` already passed, the next build
threw away the verified artifact and rebuilt from scratch for ~9.5
minutes on `macos-15` before `build-and-push` could start
> - This pull request checks job-level verification
(`macos_runner_runtime / build` and `macos_runner_runtime /
verify_linux_controller` both `completed` + `success`) on trusted
`master` `docker.yml` runs when the overall run did not conclude
`success`
> - The benefit is that `macos_runner_runtime` stays on its ~1m
cache-hit path instead of repeatedly burning ~9.5m on the `docker.yml`
critical path

## Linked Issues or Issue Description

**What happened?**
`scripts/macos-runner-runtime-cache.mjs` discards already-verified macOS
runtime artifacts from `master` `docker.yml` runs whenever the workflow
is cancelled or fails downstream, causing repeated ~9.5m `macos-15`
rebuilds before `build-and-push` can begin.

**Expected behavior**
Keep the exact trust boundary (`paperclipai/paperclip`,
`.github/workflows/docker.yml`, `event === "push"`, `head_branch ===
"master"`, 40-hex `head_sha`) and reuse the verified artifact either
when the overall run concluded `success` (fast path) or when both
`macos_runner_runtime / build` and `macos_runner_runtime /
verify_linux_controller` concluded `success` in that run.

**Steps to reproduce**
1. Merge a commit to `master` where `macos_runner_runtime / build` and
`macos_runner_runtime / verify_linux_controller` succeed, then an
unrelated downstream check cancels `docker.yml`.
2. Merge the next commit with identical Runner inputs.
3. Observe `Find an identical runtime from a successful master image
build` miss and rebuild the macOS binary and provider pack from scratch
on `macos-15`.

## What Changed

- `scripts/macos-runner-runtime-cache.mjs`: add
`isTrustedMacRuntimeWorkflowRun` and `hasVerifiedMacRuntimeJobs`, check
job-level success on trusted `master` `docker.yml` runs whose overall
conclusion is not `success`, and inspect up to 10 unexpired matching
artifacts.
- `scripts/macos-runner-runtime-cache.test.mjs`: add unit tests
verifying reuse from a master run cancelled downstream when both macOS
jobs succeeded and rejection when either job is incomplete, cancelled,
or failed.

## Verification

- `node --test scripts/macos-runner-runtime-cache.test.mjs
scripts/macos-runner-runtime.test.mjs`: 12/12 passed.

## Risks

- Low risk. Trust boundary stays strictly restricted to canonical
`master` `push` runs of `.github/workflows/docker.yml`, requires both
the macOS build/qualification job and Linux controller verification job
to have succeeded, and the consuming run still verifies the downloaded
artifact in `verify_linux_controller`.

## Model Used

- Google Antigravity agent (Gemini / Antigravity coding harness with
shell execution and 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
- [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
canary/v2026.1126.0-canary.867800
2026-11-26 07:22:17 -06:00
Dotta 8f6d94169a fix(ci): run merge-queue Docker builds on standard runners and skip wait on AWS master (#23043)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The merge-queue Docker workflow
(`.github/workflows/docker-merge-group.yml`) pre-builds the production
image on `merge_group` so `docker.yml` can promote it on `master`
> - #22993 routed `amd64` merge-queue builds to `cloud-release-32`,
which does not admit `docker-merge-group.yml`, leaving every merge-queue
build queued forever
> - While those builds sat queued, `docker.yml` waited 3 minutes in
`Find the merge-queue build of this commit` before falling back to its
fast AWS release runner
> - This pull request moves `docker-merge-group.yml` back to standard
GitHub-hosted `matrix.runner` runners and sets
`MERGE_GROUP_FIND_WAIT_MS=0` when `CORE_RELEASE_AWS_ENABLED=true`
> - The benefit is that merge-queue builds actually execute and promote
when ready, while fast AWS `master` builds never lose 3 minutes waiting
behind slower GitHub-hosted merge-queue legs

## Linked Issues or Issue Description

Refs #22993, Refs #23000

**Describe the bug**
Every `docker-merge-group.yml` run stayed queued forever on `build
(linux/amd64)` because the `cloud-release-32` runner group does not
admit that workflow. In addition, `docker.yml` waited 3 minutes polling
unfinished merge-queue runs even when running on the faster AWS release
fleet (`CORE_RELEASE_AWS_ENABLED=true`).

**Steps to reproduce**
1. Merge a PR through the GitHub Merge Queue on `master`.
2. Inspect the triggered `Docker merge-queue build` run and see `build
(linux/amd64)` queued indefinitely.
3. Inspect the subsequent `Docker` run on `master` and see `Find the
merge-queue build of this commit` spend 3 minutes waiting before falling
back to a source build.

**Expected behavior**
`docker-merge-group.yml` starts on standard GitHub-hosted runners
(`ubuntu-latest` / `ubuntu-24.04-arm`), and `docker.yml` promotes an
already-completed merge-queue build immediately without stalling 3
minutes when running on the AWS release fleet.

## What Changed

- `.github/workflows/docker-merge-group.yml`: restore `runs-on: ${{
matrix.runner }}` for `build` so `amd64` runs on `ubuntu-latest` instead
of queueing on `cloud-release-32`.
- `.github/workflows/docker.yml`: pass `MERGE_GROUP_FIND_WAIT_MS: ${{
vars.CORE_RELEASE_AWS_ENABLED == 'true' && '0' || '180000' }}` to `Find
the merge-queue build of this commit`.
- `scripts/merge-group-image.mjs`: add `resolveFindWaitMs(env)` (clamped
to `[0, 180000]`, defaulting to `180000`) and use it in `find`.
- `server/src/__tests__/docker-runner-workflows.test.ts` &
`scripts/merge-group-image.test.mjs`: add guard tests for standard
runner placement and `resolveFindWaitMs` / `MERGE_GROUP_FIND_WAIT_MS`.

## Verification

- `vitest run server/src/__tests__/docker-runner-workflows.test.ts`:
15/15 passed.
- `node --test scripts/merge-group-image.test.mjs`: 10/10 passed.

## Risks

- Low risk. Restores standard runner placement (matching #23000) and
keeps the exact promotion verification contract unchanged; fail-open
fallback to source build is preserved.

## Model Used

- Google Antigravity agent (Gemini / Antigravity coding harness with
shell execution and 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
2026-11-26 07:18:53 -06:00
DottaandPaperclip 8f542b3c9b fix(ui): show Antigravity and Copilot as first-class harnesses in agent runtime settings (#23042)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Harness / Runtime settings page (`/agents/:id/runtime`) lets
people choose or change an agent's harness, model, AI connection, and
execution environment
> - Qualified native ACPX harnesses (`antigravity_runtime` and
`copilot_runtime`) appeared in the New Agent wizard, but
`AdapterTypeDropdown` in `AgentConfigForm` only listed top-level UI
adapters plus `openai_dot` and `muse`
> - People configuring an agent on `/agents/:id/runtime` could not find
Google Antigravity or GitHub Copilot in the Harness dropdown, and
existing Antigravity agents displayed as `Paperclip Runner` instead of
their own harness and logo
> - This pull request exposes qualified `antigravity_runtime` and
`copilot_runtime` entries directly in `AdapterTypeDropdown`, hides the
redundant inner Runner/ACP pickers when selected, and persists the
native `paperclip_runner` ACPX configuration cleanly
> - The benefit is that people can configure and switch agents to
Antigravity or Copilot directly from `/agents/:id/runtime` across local,
Daytona, and Unikraft environments

## Linked Issues or Issue Description

**What existing behavior does this improve?**
Harness selection and display on the agent Harness / Runtime settings
page (`/agents/:id/runtime`).

**Subsystem affected**
UI: `AgentConfigForm` (`AdapterTypeDropdown`) and `AdapterMark`
(`ui/src/components/`).

**Current behavior**
The Harness dropdown on `/agents/:id/runtime` omits Google Antigravity
(`antigravity_runtime`) and GitHub Copilot (`copilot_runtime`). Existing
Antigravity agents show `Paperclip Runner` with nested `ACP agents`
pickers instead of `Google Antigravity` with its logo.

**Proposed behavior**
Qualified native ACPX harnesses (`Google Antigravity` and `GitHub
Copilot`) appear directly in the Harness dropdown with their logos,
gated by qualification, server adapter disablement, and Cloud
`availableHarnesses` policy. Selecting one persists `adapterType:
"paperclip_runner"` with `{ provider: "acpx", acpxAgent: "antigravity" |
"copilot", lifecycleMode: "per_turn" }`, exposes all supported
environments (including Daytona and Unikraft plugin computers), and
hides redundant inner Runner/ACP pickers.

**Reason and benefit**
Matches the New Agent picker so users configuring an agent from
`/agents/:id/runtime` see consistent harness choices, logos, model
pickers, and environment options without needing the experimental
`enableNativeRunner` flag.

**Breaking changes**
None. Existing `paperclip_runner` agent records keep the same schema and
stored `adapterConfig`.

## What Changed

- Added qualified `antigravity_runtime` and `copilot_runtime` options to
`AdapterTypeDropdown` in `ui/src/components/AgentConfigForm.tsx`,
respecting server `disabledTypes` and Cloud `availableHarnesses` policy
without requiring `enableNativeRunner`.
- Mapped saved `antigravity_runtime` and `copilot_runtime`
`paperclip_runner` agents to display as their dedicated harness in
`AdapterTypeDropdown`, hid redundant inner Runner/ACP pickers
(`hideRunnerHarness`), and guarded against no-op re-selection clearing
the current model.
- Handled selecting `antigravity_runtime` or `copilot_runtime` in create
and edit modes by setting `adapterType: "paperclip_runner"` and `{
provider: "acpx", acpxAgent, lifecycleMode: "per_turn" }`.
- Fixed a latent bug in `adapterPickerDisabledTypes` where
`disabledTypes` (an array from `useDisabledAdaptersSync`) was checked
with `.has(...)` instead of a `Set`.
- Added `copilot_runtime` light/dark brand icons to
`ui/src/components/AdapterMark.tsx`.
- Added render tests in
`ui/src/components/AgentConfigForm.render.test.tsx` covering Antigravity
selection, logo rendering, Daytona/Unikraft environment availability,
native ACPX save payload, and display of existing Antigravity agents.

## Verification

- `pnpm exec vitest run
ui/src/components/AgentConfigForm.render.test.tsx
ui/src/components/AgentConfigForm.test.ts
ui/src/adapters/codex-local/config-fields.test.tsx` — 58/58 passed.
- `pnpm exec vitest run ui/src/` — 578 test files (7,191 tests) passed.
- `pnpm --filter @paperclipai/ui typecheck` — passed (including
Storybook catalog check).

## Risks

- Low risk. UI-only harness selection change; server-side validation,
Cloud `availableHarnesses` enforcement, and stored `adapterConfig`
format remain unchanged.

## Model Used

- Google Gemini (Antigravity agent with tool use and code execution).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] 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.1126.0-canary.867600
2026-11-26 13:12:44 +00:00
dependabot[bot] 85ad16b47e build(deps-dev): bump typescript from 5.9.3 to 7.0.2 in /packages/plugins/sandbox-providers/daytona (#19566)
Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.9.3
to 7.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/microsoft/TypeScript/releases">typescript's
releases</a>.</em></p>
<blockquote>
<h2>TypeScript 7.0.2</h2>
<p><a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/">https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/</a></p>
<p>This tag was originally released at: <a
href="https://github.com/microsoft/typescript-go/releases/tag/typescript%2Fv7.0.2">https://github.com/microsoft/typescript-go/releases/tag/typescript%2Fv7.0.2</a></p>
<h2>TypeScript 6.0.3</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/">release
announcement blog post</a>.</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.0%22">fixed
issues query for TypeScript 6.0.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.1%22">fixed
issues query for TypeScript 6.0.1 (RC)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.2%22">fixed
issues query for TypeScript 6.0.2 (Stable)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.3%22">fixed
issues query for TypeScript 6.0.3 (Stable)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
<h2>TypeScript 6.0</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-6-0/">release
announcement blog post</a>.</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.0%22">fixed
issues query for TypeScript 6.0.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.1%22">fixed
issues query for TypeScript 6.0.1 (RC)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.2%22">fixed
issues query for TypeScript 6.0.2 (Stable)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
<h2>TypeScript 6.0.1 RC</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-6-0-rc/">release
announcement blog post</a>.</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.0%22">fixed
issues query for TypeScript 6.0.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.1%22">fixed
issues query for TypeScript 6.0.1 (RC)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
<h2>TypeScript 6.0 Beta</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-6-0-beta/">release
announcement</a>.</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+6.0.0%22+is%3Aclosed+">fixed
issues query for Typescript 6.0.0 (Beta)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/microsoft/TypeScript/commit/1e4744d68260a7cb91b62b12edc3f6a2187faaf1"><code>1e4744d</code></a>
Merge branch 'main' into ts7-release</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/a5a219c3b5da0db4fa0ecf6c0b1f588c9af9c669"><code>a5a219c</code></a><code>microsoft/typescript-go#4558</code></li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/ecfe30dce91368d52c9a49b6095bb0b673a238f8"><code>ecfe30d</code></a>
Update status localization</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/5de25b5f8fec2ca35eadaed041f1f06d2e214895"><code>5de25b5</code></a>
Hide executable name in TypeScript status</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/d7ce74a75da2b80e8201506a1599c06549432b93"><code>d7ce74a</code></a>
Show bundled TypeScript version for packaged servers</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/29be66a607707f90d7a53103a4469bb3015a4d54"><code>29be66a</code></a>
Correct TS 7 release version to 7.0.2</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/ed2bd1bfa4aac5211ce4bc58fcd1313c7eddc8ff"><code>ed2bd1b</code></a>
Merge branch 'main' into ts7-release</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/887307575c58ea640dbeba3b4e8fdb6347cd3044"><code>8873075</code></a>
Bump the github-actions group across 1 directory with 3 updates
(microsoft/ty...</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/9427131ae2d4e230a90ee8a09daac4e75da3e311"><code>9427131</code></a>
Set up stable / nightly extension split, other prep
(microsoft/typescript-go#...</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/d4eaca5460a1f5f02a829e62706794b0a6fb903e"><code>d4eaca5</code></a><code>microsoft/typescript-go#4549</code></li>
<li>Additional commits viewable in <a
href="https://github.com/microsoft/TypeScript/compare/v5.9.3...v7.0.2">compare
view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a
href="https://www.npmjs.com/~microsoft1es">microsoft1es</a>, a new
releaser for typescript since your current version.</p>
</details>
<br />

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-26 05:22:45 +00:00
dependabot[bot] 97aab772a1 build(deps): bump @daytonaio/sdk from 0.203.0 to 0.232.0 in /packages/plugins/sandbox-providers/daytona (#22604)
Bumps [@daytonaio/sdk](https://github.com/daytona/clients) from 0.203.0
to 0.232.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/daytona/clients/releases">@​daytonaio/sdk's
releases</a>.</em></p>
<blockquote>
<h2>v0.232.0</h2>
<h2>0.232.0 (2026-11-16)</h2>
<h3>🚀 Features</h3>
<ul>
<li><strong>cli:</strong> add install-v0.ps1 to install the 0.x CLI on
Windows (<a
href="https://redirect.github.com/daytona/clients/pull/657">#657</a>)</li>
</ul>
<h3>🩹 Fixes</h3>
<ul>
<li><strong>cli:</strong> name the 0.x Homebrew formula daytona-v0 (<a
href="https://redirect.github.com/daytona/clients/pull/661">#661</a>)</li>
<li><strong>sdk-python:</strong> don't time out build-log streams after
5 minutes (<a
href="https://redirect.github.com/daytona/clients/pull/451">#451</a>, <a
href="https://redirect.github.com/daytona/clients/issues/432">#432</a>)</li>
<li><strong>sdk-ruby:</strong> check the deadline in wait_for_state (<a
href="https://redirect.github.com/daytona/clients/pull/431">#431</a>, <a
href="https://redirect.github.com/daytona/clients/issues/430">#430</a>)</li>
<li><strong>sdk-ruby:</strong> bound the poll requests of state waits by
the deadline (<a
href="https://redirect.github.com/daytona/clients/pull/605">#605</a>)</li>
<li><strong>sdk-ruby,sdk-python,sdk-typescript:</strong> pass pip
packages as operands (<a
href="https://redirect.github.com/daytona/clients/pull/299">#299</a>)</li>
<li><strong>sdk-typescript:</strong> point the
<code>@​daytonaio/sdk</code> deprecation at <code>@​daytona/sdk</code><a
href="https://github.com/0"><code>@​0</code></a> (<a
href="https://redirect.github.com/daytona/clients/pull/658">#658</a>)</li>
</ul>
<h3>Chores</h3>
<ul>
<li>sync go.sum for v0.231.1 (<a
href="https://redirect.github.com/daytona/clients/pull/556">#556</a>)</li>
<li><strong>deps:</strong> batch dependabot updates for release/v0
2026-11-16 (<a
href="https://redirect.github.com/daytona/clients/pull/653">#653</a>)</li>
<li><strong>sdk-go:</strong> bump to v0.232.0 (<a
href="https://redirect.github.com/daytona/clients/pull/663">#663</a>)</li>
</ul>
<h3>❤️ Thank You</h3>
<ul>
<li>Aibek Izhanov <a
href="https://github.com/izhanov"><code>@​izhanov</code></a></li>
<li>daytonaBot</li>
<li>Mirko Džaja <a
href="https://github.com/MDzaja"><code>@​MDzaja</code></a></li>
<li>Mohith Gajjela <a
href="https://github.com/Mohith26"><code>@​Mohith26</code></a></li>
</ul>
<h2>v0.231.1</h2>
<h2>0.231.1 (2026-11-09)</h2>
<h3>🩹 Fixes</h3>
<ul>
<li><strong>sdk:</strong> encode 0.x image exec forms as JSON (<a
href="https://redirect.github.com/daytona/clients/pull/549">#549</a>, <a
href="https://redirect.github.com/daytona/clients/issues/548">#548</a>)</li>
</ul>
<h3>Chores</h3>
<ul>
<li>sync go.sum for v0.231.0 (<a
href="https://redirect.github.com/daytona/clients/pull/531">#531</a>)</li>
<li><strong>deps:</strong> bump nx to 23.3.1 and typescript to 5.9.3 on
release/v0 (<a
href="https://redirect.github.com/daytona/clients/pull/525">#525</a>)</li>
<li><strong>deps:</strong> batch dependabot updates for release/v0
2026-11-09 (<a
href="https://redirect.github.com/daytona/clients/pull/553">#553</a>)</li>
<li><strong>sdk-go:</strong> bump to v0.231.1 (<a
href="https://redirect.github.com/daytona/clients/pull/554">#554</a>)</li>
</ul>
<h3>❤️ Thank You</h3>
<ul>
<li>daytonaBot</li>
<li>Mirko Džaja <a
href="https://github.com/MDzaja"><code>@​MDzaja</code></a></li>
<li>Nikola Radisic</li>
</ul>
<h2>v0.231.0</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/daytona/clients/commit/f7546ecef48db463ab1648168ae9edd954255ea5"><code>f7546ec</code></a>
chore(sdk-go): bump to v0.232.0 (<a
href="https://redirect.github.com/daytona/clients/issues/663">#663</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/d23cce8a33b84caff9354fb3168e313327a55dbe"><code>d23cce8</code></a>
docs(sdk): pin the 0.x install commands below 1 (<a
href="https://redirect.github.com/daytona/clients/issues/662">#662</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/b1539e3b2a669f17266bbde92a9b1aee7aa75d52"><code>b1539e3</code></a>
fix(cli): name the 0.x Homebrew formula daytona-v0 (<a
href="https://redirect.github.com/daytona/clients/issues/661">#661</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/b28b4452bf9a85083857ac6457d2a3f70df2c5c0"><code>b28b445</code></a>
docs(sdk): point the deprecated SDK packages at the 0.x line (<a
href="https://redirect.github.com/daytona/clients/issues/659">#659</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/23411e489b46e9223bd9689e18a2cbe70c39487a"><code>23411e4</code></a>
fix(sdk-typescript): point the <code>@​daytonaio/sdk</code> deprecation
at <code>@​daytona/sdk</code><a
href="https://github.com/0"><code>@​0</code></a> (...</li>
<li><a
href="https://github.com/daytona/clients/commit/cf5ee8d49039a4b94028d409d97be80e7b1cde57"><code>cf5ee8d</code></a>
feat(cli): add install-v0.ps1 to install the 0.x CLI on Windows (<a
href="https://redirect.github.com/daytona/clients/issues/657">#657</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/78aba793c7d0e382032af95189ea8d072829341e"><code>78aba79</code></a>
chore(deps): batch dependabot updates for release/v0 2026-11-16 (<a
href="https://redirect.github.com/daytona/clients/issues/653">#653</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/a690f406a8eb67b8a5752760d41acb6f09a46c3c"><code>a690f40</code></a>
fix(sdk-ruby,sdk-python,sdk-typescript): pass pip packages as operands
(<a
href="https://redirect.github.com/daytona/clients/issues/299">#299</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/21d80f4c14d8f0fa05b474045f6aa7f4c1fa047a"><code>21d80f4</code></a>
fix(sdk-python): don't time out build-log streams after 5 minutes (<a
href="https://redirect.github.com/daytona/clients/issues/451">#451</a>)</li>
<li><a
href="https://github.com/daytona/clients/commit/eae4e16c817111b42ab87ed21ef5661641078f78"><code>eae4e16</code></a>
fix(sdk-ruby): bound the poll requests of state waits by the deadline
(<a
href="https://redirect.github.com/daytona/clients/issues/605">#605</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/daytona/clients/compare/v0.203.0...v0.232.0">compare
view</a></li>
</ul>
</details>
<br />

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
canary/v2026.1126.0-canary.867400 nightly/v2026.1126.0-nightly.0
2026-11-26 04:56:43 +00:00
5a7150be7e test(ai-connections): start the receiver lock-wait deadline after child startup (#23014)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The managed AI connections service refreshes single-use quota
credentials and must handle a receiver process that dies after a token
exchange
> - A server test spawns a real child process to prove this case, but it
fails every time in the server General tests shard 7/8
> - The failure blocks unrelated PRs, for example Dependabot PR #22604
> - The child starts through tsx. Loading `services/ai-connections.ts`
takes about 20–30 seconds on a 4-CPU runner. The test gave the child
only 25 seconds from spawn to reach the advisory lock, so the deadline
ended before the child ran its first line
> - This pull request starts the 25-second lock-wait budget only after
the child reports that its imports are done, and it makes the test setup
safe for a retry
> - The benefit is that the shard passes again and the test still proves
the same behavior

## Linked Issues or Issue Description

Refs #22604

**What happened?**
The test "requires sign-in after the receiver process dies with an
exchanged but unsaved token" in
`server/src/__tests__/ai-connections.test.ts` fails with `expected false
to be true` at `expect(blocked).toBe(true)`. On the vitest retry, it
then fails with `duplicate key value violates unique constraint
"company_memberships_company_principal_unique_idx"`.

**Steps to reproduce**
Run `pnpm vitest run server/src/__tests__/ai-connections.test.ts -t
"receiver process dies"` on a 4-CPU machine. The test fails after 25
seconds. Tracing showed that the child process never ran its first
statement before the deadline. A direct run of the child helper took 32
seconds cold and 21 seconds warm, all in module loading.

**Expected behavior**
The test waits for the child to start, then gives the child 25 seconds
to block on the advisory lock after one provider exchange. A retry does
not collide with rows from the first attempt.

## What Changed

- `helpers/quota-credential-process.ts`: The child writes `ready` to
stdout after its imports finish. It writes no credential data.
- `ai-connections.test.ts`: The test pipes the child stdout and waits up
to 150 seconds for `ready` (or for the child to exit). Then the existing
25-second lock-wait loop starts.
- `ai-connections.test.ts`: The test owner is now unique per attempt
(`quota-receiver-process-loss-<uuid>`), so a retry does not hit the
membership unique index.
- The test timeout increases from 40 seconds to 200 seconds to cover the
startup wait.

## Verification

- Before the fix: `pnpm vitest run
server/src/__tests__/ai-connections.test.ts -t "receiver process dies"`
failed at line 933 (`expected false to be true`), the same as CI.
- After the fix: the same command passes.
- `pnpm vitest run server/src/__tests__/ai-connections.test.ts`: 167 of
167 tests pass.
- CI: the server General tests shard 7/8 must pass on this PR.

## Risks

Low risk. Only test code changes. The assertions about the exchange
count, the saved credential, the recovery journal, and re-authorization
do not change. The test can take longer on a slow runner because startup
now has its own wait.

## Model Used

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

## Checklist

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

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

---------

Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 04:06:08 +00:00
DottaandClaude Opus 5.5 bde164de54 test(server): fix the issue-prefix collision and the shared-role idle timeout that fail Cloud readiness (#23013)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Every master commit must pass Cloud readiness before Docker
publishes it and staging deploys it
> - Two server tests failed there on and off, so master stopped reaching
staging
> - Both failures came from test setup that leaked across suites, not
from product behavior
> - CI runs each shard against one shared PostgreSQL server, and each
suite gets its own database on it
> - This pull request removes both leaks at their cause and adds a guard
for each
> - The benefit is that Cloud readiness no longer fails on these two
tests, and Docker publishing and staging deploys continue

## Linked Issues or Issue Description

**What happened?**
Cloud readiness failed on master in two server test shards.

1. `antigravity-swarm.db.test.ts` failed with `duplicate key value
violates unique constraint "companies_issue_prefix_idx"`.
2. `git-workspace-expiration.test.ts` > "rolls back when new history
appears after capture without changing files" returned `skipReason:
"inspection_failed"` instead of `restore_point_contents_changed`. This
failed on four attempts of one master commit.

**Root cause**
1. The swarm suite and 20 other suites made company issue prefixes from
four random hex characters (65,536 values). The swarm suite seeds about
65 companies in one database, so one run of that file had about a 3%
chance of a collision.
2. `isolated-remote-workspace-source-lock.test.ts` and
`native-workspace-finalizer.test.ts` ran `ALTER ROLE <current_user> SET
idle_in_transaction_session_timeout = '1s'`. In CI all suites in a shard
share one PostgreSQL server and one role. So every new session in every
other suite also got a 1-second idle-in-transaction limit. The
expiration test holds a transaction open while it runs Git commands.
PostgreSQL closed that session, and the expiration recorded
`CONNECTION_CLOSED` as `inspection_failed`. The lock suite never reset
the setting.

**Steps to reproduce**
1. Run the lock suite and then the expiration test on one shared test
server (the same layout CI uses).
2. Before this change, 40 of 40 runs of the expiration test fail with
`CONNECTION_CLOSED`.

**Expected behavior**
A suite's session settings apply only to its own database. Seeded
companies never share an issue prefix.

## What Changed

- Added `uniqueIssuePrefix(tag)`, a shared test helper that adds 48
random bits (12 uppercase hex characters) to a tag.
- Changed all 24 company seeds that used four or fewer random characters
(21 files) to use the helper. Updated one identifier assertion in
`cases-routes.test.ts` for the longer prefix.
- Changed the two suites from `ALTER ROLE ... SET` to `ALTER DATABASE
<current_database()> SET`, so the 1-second limit applies only to their
own disposable database. The finalizer suite still resets it after its
test.
- Added two guard tests: one proves the helper does not repeat across
70,000 prefixes, and one fails if any test file changes a setting for a
whole role.

## Verification

- Deterministic red for the Git expiration failure: one shared test
server, lock suite first, then the expiration test 40 times. Before: 40
of 40 failed with `CONNECTION_CLOSED`. After: 40 of 40 passed, and 40 of
40 passed again with 12 CPU-burning processes running.
- The same failure appeared in PR CI before the fix: with the full suite
on one shared server, 17 runs of the looped expiration test failed with
`CONNECTION_CLOSED`.
- Deterministic red for the prefix generator: the old four-character
generator gives 42,898 distinct prefixes from 70,000 calls. The new
helper gives 70,000.
- `antigravity-swarm.db.test.ts`: 30 of 30 runs passed with 12
CPU-burning processes running.
- All 21 suites that changed seeds pass locally. The two changed lock
suites pass (72 tests).

## Risks

- Low risk. Only test files change. The product code is unchanged.
- Longer test prefixes make test issue identifiers longer. One assertion
that checked a four-character prefix is updated.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, file edits, GitHub CLI) 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.1126.0-canary.867200
2026-11-25 21:42:21 -06:00
DottaandPaperclip 6fab9e8659 fix(apps): key Antigravity connector to antigravity with Antigravity branding and logo (#23012)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Connectors catalog and `/apps/connect` setup page let people
connect AI model providers for their agents
> - The Antigravity model-provider connector still used the `google`
slug, the generic Google "G" icon, and "Google" headings and sign-in
copy on `/apps/connect?source=google`
> - Showing "Google" with the generic Google icon on the Antigravity
connection flow makes it easy to confuse with Google Workspace
connectors and hides the Antigravity product identity
> - This pull request moves the catalog slug to `antigravity`, adds the
official Antigravity vector logo, redirects legacy `source=google` and
`source=google-ai` links to `source=antigravity`, and updates the
Connect page copy and icons to Antigravity while preserving the
underlying `google` AI provider storage contract
> - The benefit is that people see clear Antigravity branding, logo, and
URL routing throughout the Antigravity connection flow without breaking
saved accounts or existing links

## Linked Issues or Issue Description

**What existing behavior does this improve?**
Connector routing, branding, and logo presentation for Antigravity on
the Connectors catalog and `/apps/connect` setup page.

**Subsystem affected**
Shared app definitions (`packages/shared`), app brand assets
(`ui/public/brands/apps`), and UI connection setup pages and components
(`ui/src/pages/apps`, `ui/src/components`).

**Current behavior**
The Antigravity model-provider connector uses `?source=google`, displays
the generic Google logo, and shows "Connect Google", "Google", and "Sign
in to Google" on the Connect page.

**Proposed behavior**
The Antigravity connector keys to `?source=antigravity`, displays the
Antigravity logo, and shows "Connect Antigravity", "Antigravity", and
"Sign in to Antigravity" on the Connect page. Legacy links using
`?source=google` or `?source=google-ai` redirect to
`?source=antigravity` while preserving other query parameters.

**Reason and benefit**
This matches the existing `github` -> `github-copilot` catalog
separation pattern: stored `google` AI connections and Gemini API key
compatibility remain unchanged, while the user-facing catalog entry, URL
key, logo, and Connect page copy consistently reflect Antigravity.

**Breaking changes**
None. The underlying `google` AI provider identifier, credential
storage, and grants do not change, and legacy `source=google` /
`source=google-ai` deep links redirect automatically to
`source=antigravity`.

## What Changed

- Added the official transparent Antigravity vector mark at
`ui/public/brands/apps/antigravity.svg` and registered `antigravity` in
`ui/public/brands/apps/manifest.json` (keeping `google` with
`catalogVisible: false` for Google Workspace branding).
- Mapped `aiConnectionCatalogSlug("google")` to `"antigravity"` and
updated `aiProviderSetupPreset` so `antigravity`, `google`, and
`google-ai` all resolve to `{ provider: "google", label: "Antigravity"
}`.
- Replaced `packages/shared/src/app-definitions/google.json` with
`packages/shared/src/app-definitions/antigravity.json`, added
`scripts/app-definition-overrides/antigravity.json`, updated
`scripts/ingest-app-definitions.mjs`,
`packages/shared/src/app-definitions.ts`, and
`packages/shared/src/app-definitions.generated.ts`, and resynced
`tests/runner-e2e/source-sdk-public-inputs.json`.
- Updated `ui/src/pages/apps/app-connect-policy.ts` and
`ui/src/pages/apps/AppsConnect.tsx` to admit and redirect legacy
`source=google` and `source=google-ai` links to `source=antigravity`
while preserving query parameters.
- Updated `AdapterMark`, `AiProviderSetup`, `AgentProviderConnection`,
`AdapterLoginChrome`, `AiConnectionCredentialStep`, `AiConnectionField`,
`ai-connections/model.ts`, and
`ui/storybook/prototypes/AiConnectorPages.tsx` to show Antigravity
branding and `/brands/apps/antigravity.svg`.
- Updated existing unit tests and added
`ui/src/pages/apps/AppsConnect.test.tsx` covering legacy URL redirects
and Antigravity Connect page rendering.

## Verification

- `pnpm --filter @paperclipai/shared build` — passed.
- `node scripts/check-app-brand-assets.mjs` — passed (`Validated 114
brand identities`).
- `pnpm exec vitest run packages/shared/src/` — 120 test files passed.
- `pnpm exec vitest run ui/src/` — 575 test files (7,178 tests) passed;
`pnpm exec vitest run ui/src/pages/apps/AppsConnect.test.tsx` — 3/3
passed.
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/ai-connections.test.ts
src/__tests__/connection-intents-service.test.ts` — 208/208 passed.
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/ui typecheck && pnpm --filter @paperclipai/server
typecheck` — passed.
- `node --test scripts/app-definition-overrides.test.mjs
scripts/app-brand-validation.test.mjs scripts/check-test-budget.test.mjs
scripts/storybook-catalog.test.mjs` — passed.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse
HEAD) --check` — passed (`changed: false`).

## Risks

- Low risk. The stored AI provider enum (`google`) and database/API
contracts stay unchanged; `aiConnectionSourceSlug` maps previously
stored `google` connections to the `antigravity` catalog entry
automatically.
- Legacy bookmarks or deep links to `/apps/connect?source=google` or
`?source=google-ai` redirect immediately to `?source=antigravity` with
existing query parameters preserved.

## Model Used

- Google Gemini (Antigravity agent with tool use and code execution).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] 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.1126.0-canary.867100
2026-11-26 02:25:12 +00:00
TonioandClaude Fable 5.2 5ea8c99717 fix(ui): close the Plugins review follow-ups and add the Reviews page (#23005)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Plugins page is where a person connects tools to agents and
approves the actions that those tools request
> - #22869 turned Connectors into a Plugins marketplace. Three review
findings stayed open after the merge
> - The page also did not show clearly which account needs attention,
and the Reviews page was a plain queue
> - A person must see what waits for a decision and must be able to
leave a setup step
> - This pull request fixes the three findings, adds a review chip and a
Reviews page with decision cards, marks the account rows that need
attention, and adds a Close button to the chat connection purpose step
> - The benefit is a Plugins page that shows pending work, and
permission controls that do not accept changes on stale data

## Linked Issues or Issue Description

Refs #22869

**What existing behavior does this improve?**

The Plugins marketplace pages under `ui/src/pages/apps`: the plugin
page, the header, the Reviews page, and the chat connection setup.

**Subsystem affected**

UI, Plugins (Apps catalog) pages.

**Current behavior**

- After a failed refresh of the permissions, the menus stay enabled and
work on stale data.
- The plugin page shows a different category from Browse for Composio
and Arcade apps.
- Browse classifies each plugin one time for each category on each
render.
- A chat connection that needs attention shows only text in its row.
- The header shows a count only. The Reviews page shows a plain queue.
- The "Choose how to connect" step has no control to leave the flow.

**Proposed behavior**

- After a failed refresh, the actions stay visible, the menus are
disabled, and a status line offers "Try again".
- The plugin page uses the same category as Browse.
- Browse classifies each plugin one time for each render.
- A chat connection row that needs attention shows a small warning glyph
with a text alternative.
- The header shows the logos of the plugins with pending requests
(maximum four), an "N to review" chip, and a chevron. It opens the
Reviews page.
- The Reviews page shows a back button, a title, a count sentence, and
one decision card for each request with "Decline" and "Allow once".
- The "Choose how to connect" step has a Close button that returns to
Plugins.

**Reason and benefit**

A person sees what waits for a decision and where. Permission changes do
not run on stale data. The render cost of Browse does not grow with the
number of categories.

**Breaking changes**

None. The default layout of the review queue on the app detail page does
not change.

## What Changed

- `plugin-categories.ts`: add `groupPluginsByCategory`, a single pass
that classifies each row one time. `Browse.tsx` uses it.
- `Browse.tsx`: the plugin page reads its category label from the same
function as Browse. Chat connection rows show a warning glyph when
`chatEndpointAttention` returns a reason.
- `PluginPermissions.tsx`: `staleReads` finds the reads with an error.
The menus are disabled while a read is stale, and a status line with
"Try again" refetches the stale queries.
- `useReviewCount.ts`: add `useReviewQueue`, which returns the count and
the application names from the same query.
- `PluginsHeader.tsx`: the review button shows stacked plugin logos, the
count chip, and a chevron.
- `AppsReview.tsx` and `ReviewQueueCard.tsx`: the Reviews page has a
header and a `decisions` layout that reuses the coordinator decision
card parts.
- `ChatEndpointSetup.tsx`: `ChatConnectionPurpose` accepts `onClose` and
shows a Close button.
- `Browse.tsx`, `PluginMarketplace.tsx`, `AssistantConnection.tsx`: the
Installed tab shows the same tiles as the rest of the page. The account
rows stay on the plugin page. Assistant Connection (MCP) has a tile of
its own.
- `ReviewQueueCard.tsx` (review fixes): linked requests use the compact
decision presentation of the interaction card, the fallback card is
masked as a whole, and the agents list is indexed by id one time.
- Specs: `connection-reviews` reads the "Deny" label. `agentmail`,
`ai-connections-app`, and `runner-e2e/connection-flow` open the plugin
page from an Installed tile.

## Verification

These checks ran on the change before the rebase onto current master.
The rebase did not touch `ui/src/pages/apps`.

- `cd ui && pnpm typecheck`: pass.
- `cd ui && npx vitest run src/pages/apps src/features/connections
src/lib/analytics`: 539 tests pass.
- `pnpm run check:token-gates`: pass.
- `node scripts/check-query-error-rendering.mjs`: 0 findings.
- Playwright specs `connection-reviews`, `plugins-browse`, and
`one-click-connect`: 7 tests pass.
- Manual check in a browser with four sample requests: the header chip
and the Reviews page render the logos, the count, and the cards.
- After the Installed tiles change: 478 unit tests in `src/pages/apps`,
`src/lib/analytics`, and the deep-link routing test pass. The
`agentmail`, `plugins-browse`, and `one-click-connect` Playwright specs
pass. A manual check in a browser shows the tiles on the Installed tab.

Not run or not seen:

- The full UI Vitest suite and the Storybook build did not run locally.
CI supplies that coverage.
- The Close button and the row warning glyph were not seen in a browser.
Unit tests cover them.
- The decision card layout has no unit test of its own.
- The stale-permissions state is tested through the `staleReads` helper
only.
- The edits to `tests/ai-connections-app/app.spec.ts` and
`tests/runner-e2e/connection-flow.ts` did not run locally.

## Risks

Low risk. The change is UI only, with no schema or API change.

- The decision cards say "Decline", and the "Always allow" action is in
a menu. This differs from the design exploration, because the product
has no snooze and requests carry no written summary.
- The review chip counts pending requests only. It does not count
accounts that need attention.
- The Installed tab no longer lists account rows. A person opens the
plugin page to manage an account or to set a default model account. The
"Manage connectors" link on an agent opens the Installed tab.
- On an instance without the assistant connection route, the Assistant
Connection tile shows the attention mark.

## Model Used

Claude Fable 5.2 (`claude-fable-5-2`) in Claude Code, with tool use,
code execution, 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)
- [ ] 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
- [ ] 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-26 02:23:18 +00:00
dependabot[bot] ff5e35dd36 build(deps-dev): bump vitest from 4.1.11 to 5.1.1 in /packages/plugins/sandbox-providers/daytona (#22605)
Bumps
[vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest)
from 4.1.11 to 5.1.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/vitest-dev/vitest/releases">vitest's
releases</a>.</em></p>
<blockquote>
<h2>v5.1.1</h2>
<h3>   🚀 Features</h3>
<ul>
<li><strong>cache</strong>: Add fs module cache env variables  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11859">vitest-dev/vitest#11859</a>
<a href="https://github.com/vitest-dev/vitest/commit/708c05da0"><!-- raw
HTML omitted -->(708c0)<!-- raw HTML omitted --></a></li>
</ul>
<h3>   🐞 Bug Fixes</h3>
<ul>
<li>Rerun on file changes after a config restart  -  by <a
href="https://github.com/magurotuna"><code>@​magurotuna</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11772">vitest-dev/vitest#11772</a>
and <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11829">vitest-dev/vitest#11829</a>
<a href="https://github.com/vitest-dev/vitest/commit/289caab9c"><!-- raw
HTML omitted -->(289ca)<!-- raw HTML omitted --></a></li>
<li>Avoid leaking the context expect  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11845">vitest-dev/vitest#11845</a>
<a href="https://github.com/vitest-dev/vitest/commit/3c967a7b7"><!-- raw
HTML omitted -->(3c967)<!-- raw HTML omitted --></a></li>
<li>Report fixture teardown errors once  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11857">vitest-dev/vitest#11857</a>
<a href="https://github.com/vitest-dev/vitest/commit/6b167eb79"><!-- raw
HTML omitted -->(6b167)<!-- raw HTML omitted --></a></li>
<li>Improve diffs for asymmetric matchers  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11855">vitest-dev/vitest#11855</a>
<a href="https://github.com/vitest-dev/vitest/commit/86775420f"><!-- raw
HTML omitted -->(86775)<!-- raw HTML omitted --></a></li>
<li>Apply --shard before the test run starts  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11846">vitest-dev/vitest#11846</a>
<a href="https://github.com/vitest-dev/vitest/commit/e5c80b775"><!-- raw
HTML omitted -->(e5c80)<!-- raw HTML omitted --></a></li>
<li>Reset local expect state between retries for
<code>expect.assertions/hasAssertions</code>  -  by <a
href="https://github.com/hi-ogawa"><code>@​hi-ogawa</code></a> and
<strong>Claude Opus 5.5</strong> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11900">vitest-dev/vitest#11900</a>
<a href="https://github.com/vitest-dev/vitest/commit/50dcdb373"><!-- raw
HTML omitted -->(50dcd)<!-- raw HTML omitted --></a></li>
<li>Sort test files before the seeded shuffle  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11926">vitest-dev/vitest#11926</a>
<a href="https://github.com/vitest-dev/vitest/commit/3aa3045a9"><!-- raw
HTML omitted -->(3aa30)<!-- raw HTML omitted --></a></li>
<li>Tear down fixture contexts one at a time  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11956">vitest-dev/vitest#11956</a>
<a href="https://github.com/vitest-dev/vitest/commit/5712b5fd2"><!-- raw
HTML omitted -->(5712b)<!-- raw HTML omitted --></a></li>
<li>Count merged errors in the error divider  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11955">vitest-dev/vitest#11955</a>
<a href="https://github.com/vitest-dev/vitest/commit/4bc4f86e8"><!-- raw
HTML omitted -->(4bc4f)<!-- raw HTML omitted --></a></li>
<li>Match <code>-</code> and <code>.</code> in <code>noExternal</code>
wildcards  -  by <a
href="https://github.com/hi-ogawa"><code>@​hi-ogawa</code></a> and
<strong>Claude Opus 5.5</strong> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11978">vitest-dev/vitest#11978</a>
<a href="https://github.com/vitest-dev/vitest/commit/efba8cbfe"><!-- raw
HTML omitted -->(efba8)<!-- raw HTML omitted --></a></li>
<li>Give each test attempt a new <code>signal</code>  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11998">vitest-dev/vitest#11998</a>
<a href="https://github.com/vitest-dev/vitest/commit/77a306757"><!-- raw
HTML omitted -->(77a30)<!-- raw HTML omitted --></a></li>
<li>Throw timeout error classes instead of Error  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/12003">vitest-dev/vitest#12003</a>
<a href="https://github.com/vitest-dev/vitest/commit/9b87492f7"><!-- raw
HTML omitted -->(9b874)<!-- raw HTML omitted --></a></li>
<li><strong>ast-collect</strong>:
<ul>
<li>Only collect calls with a name argument  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11853">vitest-dev/vitest#11853</a>
<a href="https://github.com/vitest-dev/vitest/commit/c015ad5a6"><!-- raw
HTML omitted -->(c015a)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>browser</strong>:
<ul>
<li>Scale the iframe for preview without the UI  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11856">vitest-dev/vitest#11856</a>
<a href="https://github.com/vitest-dev/vitest/commit/034d44e54"><!-- raw
HTML omitted -->(034d4)<!-- raw HTML omitted --></a></li>
<li>Fix expect.element with <code>message</code> and remove redundant
<code>[ERROR]</code> in trace steps  -  by <a
href="https://github.com/hi-ogawa"><code>@​hi-ogawa</code></a> and
<strong>Claude Opus 5.5</strong> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11832">vitest-dev/vitest#11832</a>
<a href="https://github.com/vitest-dev/vitest/commit/1d115dcc3"><!-- raw
HTML omitted -->(1d115)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>cache</strong>:
<ul>
<li>Always leave a manifest to the fs module cache  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11858">vitest-dev/vitest#11858</a>
<a href="https://github.com/vitest-dev/vitest/commit/1b2380c88"><!-- raw
HTML omitted -->(1b238)<!-- raw HTML omitted --></a></li>
<li>Watch cached files outside the root  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11860">vitest-dev/vitest#11860</a>
<a href="https://github.com/vitest-dev/vitest/commit/9c044db81"><!-- raw
HTML omitted -->(9c044)<!-- raw HTML omitted --></a></li>
<li>Treat a removed cache file as a miss  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11861">vitest-dev/vitest#11861</a>
<a href="https://github.com/vitest-dev/vitest/commit/f21f224ba"><!-- raw
HTML omitted -->(f21f2)<!-- raw HTML omitted --></a></li>
<li>Allow cache hits in configureServer  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11927">vitest-dev/vitest#11927</a>
<a href="https://github.com/vitest-dev/vitest/commit/a0dfc8b08"><!-- raw
HTML omitted -->(a0dfc)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>cli</strong>:
<ul>
<li>Parse <code>--bail</code> correctly  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11896">vitest-dev/vitest#11896</a>
<a href="https://github.com/vitest-dev/vitest/commit/4f91e76af"><!-- raw
HTML omitted -->(4f91e)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>coverage</strong>:
<ul>
<li>Transform untested files with correct project  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11870">vitest-dev/vitest#11870</a>
<a href="https://github.com/vitest-dev/vitest/commit/832980392"><!-- raw
HTML omitted -->(83298)<!-- raw HTML omitted --></a></li>
<li>V8 to handle sub process script coverages separately  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11890">vitest-dev/vitest#11890</a>
<a href="https://github.com/vitest-dev/vitest/commit/71ad4dfa1"><!-- raw
HTML omitted -->(71ad4)<!-- raw HTML omitted --></a></li>
<li>Derive <code>ignoreNode</code> AST type from installed parser  -  by
<a href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11958">vitest-dev/vitest#11958</a>
<a href="https://github.com/vitest-dev/vitest/commit/cab34bb0e"><!-- raw
HTML omitted -->(cab34)<!-- raw HTML omitted --></a></li>
<li>V8 to ignore more Vite&amp;<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/39">#39</a>;s
CJS import helpers  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11981">vitest-dev/vitest#11981</a>
<a href="https://github.com/vitest-dev/vitest/commit/4e905a1ba"><!-- raw
HTML omitted -->(4e905)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>experimental</strong>:
<ul>
<li>Skip ambiguous <code>expect.poll</code> trace steps in concurrent
tests  -  by <a
href="https://github.com/hi-ogawa"><code>@​hi-ogawa</code></a> and
<strong>Claude Opus 5.5</strong> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11869">vitest-dev/vitest#11869</a>
<a href="https://github.com/vitest-dev/vitest/commit/f6ef4b0ef"><!-- raw
HTML omitted -->(f6ef4)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>mocker</strong>:
<ul>
<li>Keep re-exports of hoisted imports  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11867">vitest-dev/vitest#11867</a>
<a href="https://github.com/vitest-dev/vitest/commit/5f72c3d0d"><!-- raw
HTML omitted -->(5f72c)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>pool</strong>:
<ul>
<li>Shutdown disconnected workers even when <code>testTimeout</code> is
disabled  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11924">vitest-dev/vitest#11924</a>
<a href="https://github.com/vitest-dev/vitest/commit/979118a70"><!-- raw
HTML omitted -->(97911)<!-- raw HTML omitted --></a></li>
<li>Terminate stuck orphaned forks workers  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11939">vitest-dev/vitest#11939</a>
<a href="https://github.com/vitest-dev/vitest/commit/47c87ebb5"><!-- raw
HTML omitted -->(47c87)<!-- raw HTML omitted --></a></li>
<li><code>isolate: false</code> to not re-use workers that failed to
start  -  by <a
href="https://github.com/AriPerkkio"><code>@​AriPerkkio</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11953">vitest-dev/vitest#11953</a>
<a href="https://github.com/vitest-dev/vitest/commit/7e67234a9"><!-- raw
HTML omitted -->(7e672)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>reporter</strong>:
<ul>
<li>Report crashed test files as failed in json  -  by <a
href="https://github.com/magurotuna"><code>@​magurotuna</code></a> in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11965">vitest-dev/vitest#11965</a>
<a href="https://github.com/vitest-dev/vitest/commit/47fb992ca"><!-- raw
HTML omitted -->(47fb9)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>spy</strong>:
<ul>
<li>Use primordials to allow spying on builtins  -  by <a
href="https://github.com/sheremet-va"><code>@​sheremet-va</code></a> in
<a
href="https://redirect.github.com/vitest-dev/vitest/issues/11837">vitest-dev/vitest#11837</a>
<a href="https://github.com/vitest-dev/vitest/commit/d951e63d3"><!-- raw
HTML omitted -->(d951e)<!-- raw HTML omitted --></a></li>
</ul>
</li>
<li><strong>typecheck</strong>:
<ul>
<li>Add env var to hide experimental warning  -  by <a
href="https://github.com/aliamanatali"><code>@​aliamanatali</code></a>
in <a
href="https://redirect.github.com/vitest-dev/vitest/issues/11840">vitest-dev/vitest#11840</a>
<a href="https://github.com/vitest-dev/vitest/commit/5a69e4396"><!-- raw
HTML omitted -->(5a69e)<!-- raw HTML omitted --></a></li>
</ul>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/vitest-dev/vitest/commit/161e25f663a838f6a30890f8a6827ff83ff1b3c7"><code>161e25f</code></a>
chore: release v5.1.1 (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12004">#12004</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/9b87492f77992bcff4356afa4dad91028964c2c1"><code>9b87492</code></a>
fix: throw timeout error classes instead of Error (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/12003">#12003</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/77a306757d6291a0ce6f6adb7142e39886f08ffe"><code>77a3067</code></a>
fix: give each test attempt a new <code>signal</code> (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11998">#11998</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/efba8cbfe94b1402a7ccab8a73994cb389cffa4d"><code>efba8cb</code></a>
fix: match <code>-</code> and <code>.</code> in <code>noExternal</code>
wildcards (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11978">#11978</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/0c502bc72fed7d1c4b9e2e40e8ba9f3657629f73"><code>0c502bc</code></a>
perf(browser): reuse cached modules during vitest run (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11914">#11914</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/47fb992ca8bae91165bf74529fc1e939008170b0"><code>47fb992</code></a>
fix(reporter): report crashed test files as failed in json (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11965">#11965</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/cab34bb0ee23f00676ea895560c8b16399ce40b7"><code>cab34bb</code></a>
fix(coverage): derive <code>ignoreNode</code> AST type from installed
parser (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11958">#11958</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/4bc4f86e8d15d55746718d8277341197825116c2"><code>4bc4f86</code></a>
fix: count merged errors in the error divider (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11955">#11955</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/5712b5fd26f736876291dc13a59de2eefe08a9a0"><code>5712b5f</code></a>
fix: tear down fixture contexts one at a time (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11956">#11956</a>)</li>
<li><a
href="https://github.com/vitest-dev/vitest/commit/7e67234a96a0b4de1af6c75513767f12f154e9ce"><code>7e67234</code></a>
fix(pool): <code>isolate: false</code> to not re-use workers that failed
to start (<a
href="https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest/issues/11953">#11953</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/vitest-dev/vitest/commits/v5.1.1/packages/vitest">compare
view</a></li>
</ul>
</details>
<br />

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-26 02:02:25 +00:00
e1f1252a53 fix(docker): use numeric owner ids for the linked node_modules copy (#23010)
COPY --link builds the layer without the destination image's /etc/passwd, so --chown=node:node failed with 'invalid user index -1' and the master image could not build. Use the production stage's USER_UID/USER_GID build args, which the base stage assigns to the node user. A guard test requires numeric owner ids on every linked copy, in any flag order and instruction case, and equal id defaults in the base and production stages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Devin Foley <devinfoley@users.noreply.github.com>
2026-11-25 20:01:08 -06:00
DottaandClaude Opus 5.5 03d88e4216 fix(runner): wait out a short-lived foreign orphan before refusing a lost runnerd's lineage proof (#23006)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip Runner stops a lost (killed) local runnerd's provider and
tool processes from runnerd's durable process lineage journal
(`paperclip-runnerd reap-lineage`)
> - The reap refuses its proof (`unattributed_orphan`) while a live
orphan (parent PID 1) of this user exists that started after the dead
runnerd's last sample. Ownership of such a process cannot be proven, so
this rule is deliberate
> - The reap refused at the first sight of such an orphan, even when
another program left it and it exited a moment later. On a busy host,
short-lived orphans of the same user are common
> - When the reap refuses, closing the session fails with
`NativeSessionCloseUnrecoverableError: provider_transport_failed: runner
did not durably suspend before checkpoint`, so recovery of a lost
runnerd fails for a reason that has nothing to do with that runnerd
> - This is the intermittent failure of the Runner test "stops a lost
runnerd's provider and escaped tool job from its lineage journal
(journal=true)" in Cloud readiness, which blocks Docker publishing and
staging deploys
> - This pull request makes the reap wait out unattributed orphans until
its deadline, and refuse only if one still lives then
> - The benefit is that a lost runnerd's cleanup is proven on a busy
host, and master's Cloud readiness stops failing on this test

## Linked Issues or Issue Description

**What happened?**

`verify / Verify Paperclip Runner (protocol (3/4))` in the Cloud
readiness workflow failed intermittently on master (for example commits
64bef50be0 and 3f1632c7b7) in `src/live/runnerd-codex-transport.test.ts`
> "stops a lost runnerd's provider and escaped tool job from its lineage
journal (journal=true)". The error was
`NativeSessionCloseUnrecoverableError: provider_transport_failed: runner
did not durably suspend before checkpoint` from `finishClose` in
`runnerd-codex-transport.ts`, with `proofWindowEnd:
"suspend_not_completed"`. The test passed on other attempts and locally.

**Expected behavior**

When a local runnerd is killed, close proves its provider and escaped
tool job stopped from the lineage journal and ends the session as a
crash stop. A process that another program starts and that exits on its
own does not make the proof fail.

**Steps to reproduce**

1. Run the test while short-lived orphan processes of the same user
start on the host, for example `( sleep 0.2 & )` every 0.5 s, with 14
busy loops of CPU load.
2. The reap reports
`{"verified":false,"reason":"unattributed_orphan","signalled":2,"remaining":[...]}`.
The remaining PIDs are the foreign orphans. The test's own provider and
tool job were already stopped.
3. Close throws the same error as CI.

Root cause: `reap_journals` in
`packages/paperclip-runner/runner/crates/runner-core/src/process_lineage/journal.rs`
returned `unattributed_orphan` immediately when a live unattributed
orphan was in the first clean process table read. In CI, other test
files in the same shard leave short-lived orphans of the same user (for
example a fake provider whose runnerd was killed). This is a product
race, not only a test timing issue: on a real host with several agents,
any short-lived orphan of the same user that starts in that window makes
the lost runnerd's recovery fail.

## What Changed

- `reap_journals`: an unattributed orphan no longer refuses the proof at
once. The reap re-reads the process table every 10 ms and refuses with
`unattributed_orphan` only if such an orphan still lives at its
deadline. It still never signals an unattributed process.
- A table read is per process and not atomic, so a parent can exit
during a read and hide its re-parented child. Three rules close that:
- A process whose parent is not alive in the same read counts as an
orphan.
- The reap keeps every unattributed orphan and each process seen under
it (by parent, group or session; PID and start time; never signalled)
across reads, and waits until all of them are gone. It uses the existing
`LineageState` walk, seeded through a new `LineageState::track_roots`.
- Every proof needs `CLEAN_READS_REQUIRED_FOR_A_PROOF` (2) consecutive
clean reads (about 10 ms more).
- The reap reads the table through an injectable reader.
Controlled-table tests cover each rule, and each test fails when its
rule is removed:
`reaping_counts_a_process_whose_parent_exited_during_the_first_read`,
`reaping_keeps_an_orphans_descendants_across_reads`,
`reaping_needs_consecutive_clean_reads_before_a_proof`.
`reaping_follows_an_orphan_tree_through_successive_torn_reads` covers an
orphan A whose child B forks C and exits.
-
`reaping_keeps_a_process_in_an_orphans_group_or_session_after_the_orphan_exits`
fails without group and session membership.
- The `reap_journals` doc describes these rules. The journal tests moved
to `process_lineage/journal/tests.rs`.
- New Rust test
`reaping_waits_out_a_short_lived_orphan_it_cannot_attribute`: an orphan
that lives 0.5 s during the reap. The proof holds, and the orphan is not
signalled.
- `reaping_refuses_an_orphan_born_after_the_last_sample` uses a 1 s
deadline instead of 5 s, because the refusal now waits until the
deadline.
- `runnerd-codex-transport.test.ts`: the lost-runnerd test gets a
`foreignOrphan=true` case. After runnerd is killed (so its journal is
final), the test starts a 1.5 s orphan of the same user. This forces the
CI ordering deterministically. The test asserts the same things as
before: verified report, provider and tool job stopped, no queued
suspend. It also asserts that the orphan exited on its own before close
returned.
- No change to what the reap proves or signals, and no change to the
TypeScript close path.

## Verification

- Deterministic reproduction, before the fix (master `journal.rs`):
`foreignOrphan=true` fails with the CI signature
(`NativeSessionCloseUnrecoverableError ... runner did not durably
suspend before checkpoint`, reap reason `unattributed_orphan`). After
the fix: passes.
- Rust red/green: `cargo test --release -p paperclip-runner-core --lib
reaping_waits_out` fails on master's reap loop and passes with the fix.
All 16 `process_lineage` lib tests pass.
- Repeated runs on macOS (18 cores), 14 busy loops of CPU load plus a
short-lived foreign orphan every 0.5 s, `vitest run
src/live/runnerd-codex-transport.test.ts -t "lineage journal"`, 30 runs
each:
- Before the fix: 0/30 runs passed. The original `journal=true` case
failed in 8 of 30 runs with the CI signature.
- After the fix: 29/30 and 25/30 runs passed. Every remaining failure
ran to the 5 s deadline with only macOS launchd agents left (Spotlight
`mdworker_shared`, `CommCenter`, `IMTransferAgent`). Those are
long-lived processes with parent PID 1 that the reap cannot attribute,
so the refusal is correct. Linux CI hosts do not start such agents.
- `cargo fmt --check` passes.
`tests/runner-e2e/source-sdk-public-inputs.json` is unchanged (checked
with the sync script).

## Risks

- A close that must refuse because of a long-lived unattributed orphan
now takes until the reap deadline (about 4.5 s) instead of returning at
once. The outcome is the same fail-closed result.
- On macOS, launchd agents (for example Spotlight workers) have parent
PID 1 and can still make the reap refuse when one starts during the
proof window. That is the existing deliberate rule and is not changed
here.
- Low risk otherwise. The reap still never signals a process it cannot
attribute.

## Model Used

- 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

Refs #20849

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:39:54 -06:00
DottaandClaude Opus 5.5 2f9dc4a4c6 fix(runner): continue in a fresh provider session after a confirmed lost plugin checkpoint (#23007)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip Runner agents can run on plugin task environments that
keep a warm Runner between turns.
> - PR #22973 changed one recovery case. When the plugin confirms that
the prior task stopped and kept no session state, Core now retires the
settled prior owner instead of refusing the follow-up.
> - The follow-up still asked the new Runner to resume the old provider
session. The new Runner has no saved state for it, so the run failed
with `native_session_recovery_failed: ... PRP provider resume state is
unavailable`.
> - A retry reads the same empty state, so the task cannot continue.
Recovery must work without a person.
> - This pull request lets that follow-up replace the provider session
only when the Runner positively proves the saved state is gone. It
continues in a fresh provider session and records a continuity break.
> - The benefit is that the task continues, and Cloud readiness `verify
/ Verify Paperclip Runner (server-integration)` passes again, which
unblocks the Core Docker image and staging deploys.

## Linked Issues or Issue Description

Refs #22973.

**What happened?**
On master, four tests failed on every run in the Cloud readiness
`server-integration` lane: the "missing state" case of
`plugin-runner-eviction-{claude,codex}-{abrupt,retired}.integration.test.ts`
("4 failed | 439 passed"). The follow-up run failed with
`native_session_recovery_failed:
NativeRunnerResumeStateUnavailableError: PRP provider resume state is
unavailable`. A temporary revert of 71d7f86293 (#22973) made the case
pass again.

**Expected behavior**
When the plugin confirms that the prior task stopped and has no session
state, the follow-up run continues. This is the stated intent of #22973
("retires cleanly into `continuity-breaks` so the new run starts
fresh").

**Steps to reproduce**
Run `pnpm --filter @paperclipai/server exec vitest run
src/services/native-runtime/plugin-runner-eviction-codex-abrupt.integration.test.ts
-t "missing state"` on master.

## What Changed

- `server/src/services/native-runtime/native-session-executor.ts`: state
migration now returns a typed result `{ binding, pluginCheckpointRetired
}`. When Core retired the prior owner because the plugin confirmed a
lost checkpoint, the executor passes
`replaceAfterConfirmedProviderStateLoss` to the runtime.
`providerSessionReplaceableAfterStateLoss` keeps this off for a session
with an unfinished goal and for Antigravity while its release is
pending.
- `packages/paperclip-runner/src/native-session-runtime.ts`: with that
option, the runtime replaces the provider session only on the Runner's
positive proof: `PROVIDER_STATE_INCOMPATIBLE` with
`resumeStateUnavailable`, no restart interruption, no active turn, and
no pending runtime request. The governed-wait path now uses the same
proof (`runnerProvedSavedStateGone`). Every other recovery failure keeps
the named refusal. The checkpoint's saved recovery policy is not
changed.
- `server/src/__tests__/helpers/plugin-runner-eviction.ts`: the "missing
state" case encoded the behavior before #22973 (a refusal). It now
expects the follow-up to succeed. It also checks that Core read the
source checkpoint once and got no state, that the prior owner was
retired, and that a provider continuity break was logged. All other
modes keep their assertions.
- New unit cases: the runtime replaces on the positive proof, and
refuses when Core did not confirm, when the Runner did not prove state
loss, for an unclassified failure, with a turn in flight, and with a
pending runtime request. The executor keeps same-session recovery for
unfinished goals and Antigravity.

## Verification

- Red: with only the test change, the codex abrupt "missing state" case
fails with `NativeProviderStateIncompatibleError:
native_session_recovery_failed: NativeRunnerResumeStateUnavailableError:
PRP provider resume state is unavailable`.
- Green: with the fix, all four files pass locally, one file at a time:
codex-abrupt 10/10, codex-retired 11/11, claude-abrupt 10/10,
claude-retired 11/11.
- `native-session-executor.test.ts -t "plugin checkpoint"`: 94 passed
(includes the #22973 unit cases).
- Each new guard was shown red by removing it: dropping the Runner proof
fails 4 runtime refusal cases; dropping the goal check or the
Antigravity check fails the executor guard case.
- `native-session-runtime.test.ts`: 310 passed.
`native-session-executor.test.ts -t "plugin checkpoint|unfinished
goal"`: 95 passed.
- `tsc --noEmit` for `packages/paperclip-runner` and `server`: clean.

## Risks

- Behavior change is limited to one case: the plugin confirmed the task
stopped with no session state, Core retired its settled owner, and the
Runner proved it holds no saved state with nothing in flight. Such a
follow-up now loses the earlier provider conversation context instead of
failing. It records a continuity break in the run log and trace.
Transient or in-flight recovery failures still refuse.
- Sessions with an unfinished goal and Antigravity sessions keep failing
closed, as before.

## Model Used

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

## Checklist

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

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1126.0-canary.866600
2026-11-25 19:09:02 -06:00
scotttongandScott Tong e45340c0cf Align the default-account note with the onboarding API key field (#23009)
## Thinking Path

> - People use Paperclip to manage agents at work.
> - Onboarding connects the first agent to a model provider.
> - When a user enters a new API key, the form explains which account
becomes the default.
> - The note touched the input border. Its text started to the left of
the placeholder.
> - The field now lays out its own note and exposes it as an accessible
description.

## Linked Issues or Issue Description

**What happened?**

The default-account note touched the lower edge of the API key field.
The input had no accessible description.

**Expected behavior**

The note should sit below the field, align with the input text, and wrap
at narrow widths. Assistive technology should announce it with the
field.

**Steps to reproduce**

1. Start onboarding with a new organization that has no saved provider
keys.
2. Name the agent. Choose **Use API key instead**, then **OpenAI**.
3. Inspect the field and note at desktop width and at 320 px.

**Paperclip version or commit**

Reproduced on `e18fe61c8f`. Related PR #19557 added the note.

## What Changed

- Give the shared onboarding field an optional description. Use the
input's horizontal inset and an 8 px vertical gap.
- Associate the description with its input through `aria-describedby`.
- Pass the existing provider-specific sentence from the new-key form.
Add a regression test for fields with and without a description.

## Verification

- The regression test failed on the original field and passed after the
fix. All 17 focused field and saved-credential tests passed.
- The UI typecheck passed. The selected UI suites passed 3,944 tests,
with one skip.
- In Chrome, verified alignment and wrapping at 1280 × 900 and 320 ×
740. Checked the accessible description, password masking, and the
saved-key path with a disposable database.
- Three local CLI worktree tests could not start native PostgreSQL
clusters because the host exhausted its shared-memory slots. The CLI
telemetry test passed on a separate run using its standard environment.

## Risks

The field also serves sign-in flows. The description is optional. Fields
without one retain their existing input markup.

## Model Used

OpenAI Codex (GPT-6) with local 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
- [ ] 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
- [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: Scott Tong <scott@scotts-mbp-m5-max.local>
2026-11-26 00:44:56 +00:00
scotttongandScott Tong 8aface6cc3 Keep the unselected In Progress status option still (#23008)
## Thinking Path

> - People use Paperclip to manage work with AI agents.
> - The task status picker shows the current status and the other
choices.
> - A spinning ring indicates a task is in progress.
> - The ring also spun when a task was in review and the user opened the
picker.
> - Keep that option still until the user selects In Progress.

## Linked Issues or Issue Description

**What happened?**

The In Progress option rotated while In Review was selected.

**Expected behavior**

Only an active In Progress status should rotate. Reduced motion should
keep the ring still.

**Steps to reproduce**

1. Open a task in review.
2. Open Change status with reduced motion turned off.
3. Watch the blue ring beside In Progress.

**Paperclip version or commit**

Reproduced at `e18fe61c8f`.

Related work includes the shared task glyph mapping in #19329 and the
empty Kanban column case in #15805.

## What Changed

- Apply the static animation class to the unselected In Progress menu
option.
- Add a regression test for the trigger and option with In Review and In
Progress selected.

## Verification

- Ran the focused component test. The inactive row failed on the
baseline. Both cases passed with the fix.
- Used Chromium on the task detail page. The inactive ring went from one
running CSS animation to zero. The selected option and trigger still
rotated with normal motion and stopped with reduced motion.
- Changed the task to In Progress and back to In Review. Both changes
persisted.
- Local affected UI checks had 3,938 passes and one skip. Three CLI
worktree tests failed while initializing embedded PostgreSQL on the
local host. The remaining 534 CLI tests passed.

## Risks

- The visual change is limited to the unused In Progress row in the
status picker. The test covers the selected row and the trigger.

## Model Used

- OpenAI Codex (GPT-6) with local 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
- [ ] 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: Scott Tong <1504818+scotttong@users.noreply.github.com>
2026-11-26 00:41:10 +00:00
scotttongandScott Tong 17f9105a23 fix(ui): open agent chat from the task transcript (#23004)
## Thinking Path

> - People use Paperclip to manage AI agents and their work.
> - A task shows the agent's name and avatar beside its run status.
> - People can use that identity to follow up with the agent.
> - The link opened the agent's settings. This added a second step to
reach the conversation.
> - This change opens the agent's existing one-on-one chat directly from
the task.

## Linked Issues or Issue Description

**What happened?**

Clicking an agent's name beside its run status in a task opened the
agent overview.

**Expected behavior**

The link should open that agent's chat in the same company.

**Steps to reproduce**

Open a task with an agent run. Click the avatar or name beside the run
status. Check the destination and use browser Back to return to the
task.

**Paperclip version or commit**

Reproduced on e18fe61c8f.

Related work: #13283 introduced the shared task and agent chat surface.

## What Changed

- Use the task's agent roster to build the company-scoped chat link. Use
the agent ID for a missing or terminated roster member.
- Keep the link to the agent overview inside direct chat.
- Add a regression test for task and direct chat links.

## Verification

- The Chromium end-to-end test passed against the built UI. It clicks
the company-scoped agent link in the task, opens the saved conversation,
and checks the overview link inside direct chat.

- The focused task thread suite passed 434 tests and skipped one: `pnpm
exec vitest run ui/src/components/TaskChatThread.test.tsx`.
- In Chrome, clicked the named link beside a native run. Verified the
company, agent, existing conversation, and Back navigation. Verified
keyboard activation, the assignee menu, and the settings link from
direct chat.
- All 224 selected UI test files passed locally before adding the
regression test. Three CLI worktree tests could not start their embedded
PostgreSQL instances because the machine was out of shared-memory slots.

## Risks

The task and direct chat share the identity component. The test checks
both destinations to guard against a self-link inside direct chat.

## Model Used

OpenAI GPT-6 via Codex, with local code execution and browser testing.

## 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
- [ ] 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: Scott Tong <scott@scotts-mbp-m5-max.local>
2026-11-26 00:23:21 +00:00
scotttongandScott Tong 67a30c9fad Give Expand feedback when the plan is already visible (#23003)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Task chat shows saved plans as cards.
> - Expand opens the plan in the task side pane.
> - When that plan is already visible, the same action gives no visible
feedback.
> - This pull request gives the visible plan a brief outline and moves
focus to it.
> - The outline points to the plan without changing its size or reading
position.

## Linked Issues or Issue Description

**What happened?**

Clicking Expand on a plan card gave no visible feedback when the same
plan was already selected in the side pane. Keyboard focus stayed on the
plan card.

**Expected behavior**

An already visible plan briefly highlights. Keyboard focus moves to the
plan and the next Tab reaches its comments button.

**Steps to reproduce**

1. Enable Classic Workspace and use the chat-style task interface.
2. Open a task with a saved plan. Click Expand on the plan card to show
the plan in the side pane.
3. Click Expand again while that plan is still visible. Repeat with
Enter on the focused card.

**Paperclip version or commit**

Reproduced on master at `e18fe61c8f`.

**Deployment mode**

Local dev, built from source.

## What Changed

- Recognize explicit activation of a plan card when its target already
occupies the open side pane, including when the plan opened
automatically.
- Move focus to the pane without scrolling and fade the outline over 520
ms. Show a brief static outline with reduced motion.
- Exercise first open, repeated activation, outline clearance, and
keyboard navigation in the Classic Workspace browser test.

## Verification

- Chrome on the real dev app with a saved plan. Confirmed pointer and
Enter activation, fade out, reduced motion, focus after the fade,
ordinary document links, and the full-view deep link.
- Ran the targeted Classic Workspace Playwright regression, the UI
typecheck, and the task side pane and document-link Vitest suites.
- `pnpm verify` delegates broader coverage to CI when an E2E spec
changes.

## Risks

- Low risk. The cue is scoped to explicit activation of a card for the
active plan on desktop. The change affects how focus moves after
activation.

## Model Used

- OpenAI Codex, GPT-6.2 Sol (`gpt-6.2-sol)), 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: Scott Tong <1504818+scotttong@users.noreply.github.com>
2026-11-26 00:09:26 +00:00
DottaandClaude Opus 5.5 3f1632c7b7 fix(workspaces): keep the saved strategy for fresh managed-storage retries (#23002)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Master publishes its Core Docker image only after the "Cloud
readiness" run passes for the same commit
> - Readiness fails on every verified master commit since #22972 and
#22969 merged together, so the Docker image does not publish and staging
cannot deploy
> - Two server tests fail every time. One failure is a real product
regression. One failure is a test that checks a mock call instead of the
real retry decision
> - This pull request fixes the regression and makes the test check the
real scheduler outcome
> - The benefit is that a fresh Retry on a managed-storage project works
again, and master readiness and the Docker publish can pass

## Linked Issues or Issue Description

Refs #22972, Refs #22969

**What happened?**

1. #22972 changed the strategy that heartbeat workspace preparation
sends to a workspace-storage plugin. It sends `project_primary` for
every fresh retry (`fresh || useIsolatedTaskDirectory`), not only for a
private isolated task directory. A storage plugin that declares only
`git_worktree` refuses the fresh retry with "The storage plugin does not
support this workspace mode or strategy". Before #22972, a fresh retry
sent the project's resolved strategy.
2. #22969 added a `hermes_gateway` test. The test expects that
completion does not call `scheduleBoundedRetryForRun` for an ambiguous
`create_run` HTTP 429/5xx failure. But completion always sends a
`transient_upstream` failure to the scheduler (the same test asserts
this call for the shutdown case). The scheduler then refuses with
`legacy_execution_requires_reconciliation`. So no retry happens, but the
mock assertion fails every time.

**Expected behavior**

1. A fresh retry on a managed-storage project keeps the project strategy
(for example `git_worktree`). Only a private isolated task directory
uses `project_primary`.
2. An ambiguous `hermes_gateway` `create_run` failure does not schedule
a retry.

**Steps to reproduce**

1. `pnpm exec vitest run
server/src/services/heartbeat/workspace-preparation.test.ts -t "fresh:
true"` on master fails with "The storage plugin does not support this
workspace mode or strategy".
2. `pnpm exec vitest run
server/src/services/heartbeat/run-completion.test.ts -t "hermes_gateway
shutdown"` on master fails with `expected "vi.fn()" to not be called at
all`.

**Paperclip version or commit**

`origin/master` at `d21ae3724f`. Both failures are deterministic.
Readiness first verified a commit after these merges at `8e8c1b9f4d` and
failed there. The readiness "passes" on `168253f74d`, `e18fe61c8f` and
`a74b4f8196` skipped `verify` at admission, so they did not run these
tests.

## What Changed

- `server/src/services/heartbeat/workspace-preparation.ts`: send
`project_primary` to the storage plugin only when
`useIsolatedTaskDirectory` is set (outside remote authority). A fresh
retry sends the resolved project strategy again. The host workspace
config still uses `project_primary` for fresh retries, as before #22972.
- `server/src/services/heartbeat/run-completion.test.ts`: in the
`hermes_gateway` `create_run` 429/5xx cases, route the scheduler mock to
the real `createHeartbeatRetries` scheduler. Every dependency after the
reconciliation gate throws. The test asserts that each call returns
`not_scheduled` with `legacy_execution_requires_reconciliation`, and
that no retry run exists.

## Verification

- Red on `origin/master` (`d21ae3724f`), local embedded Postgres:
`workspace-preparation.test.ts -t "prepares managed storage"` gives 1
failed, 10 passed (the `fresh: true` case). `run-completion.test.ts -t
"hermes_gateway shutdown"` fails 3 of 3 runs.
- The same two failures occur in master Cloud readiness runs
45705488994, 45709638795, 45710758887 and 45716955324 (General tests
server shards 8/10 and 10/10).
- Green on this branch: `workspace-preparation.test.ts` 160/160 passed.
`run-completion.test.ts` 174/174 passed.
- `pnpm --filter @paperclipai/server typecheck` passed.

## Risks

- Low risk. The product change restores the pre-#22972 strategy for
fresh retries on the storage-plugin path only. The private isolated task
directory path from #22972 does not change.
- The test change does not weaken the safety check. It now checks the
real scheduler decision instead of a mock call.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
shell 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-25 23:59:59 +00:00
DottaandClaude Opus 5.5 d21ae3724f fix(ci): run Runner image amd64 jobs on standard runners again (#23000)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner image workflow (`.github/workflows/runner-image.yml`)
builds the Runner image on each master push that changes Runner inputs
> - The Docker workflow waits for this Runner image before it publishes
the Core image
> - #22992 moved the master `Build and check (amd64)` and `Write the
build cache (amd64)` jobs to the `cloud-release-32` larger runner
> - On master, the amd64 build job stays queued with the
`cloud-release-32` label and never gets a runner. Jobs from other
workflows (for example `cloud-migrator-artifacts.yml`) get runners on
the same label at the same time. The runner group does not admit this
workflow.
> - Because of this, no Core image publishes after #22992, and staging
cannot deploy newer commits
> - This pull request puts the two jobs back on `matrix.runner` (the
runners before #22992). It keeps the parallel provider-pack archiving
from #22992.
> - The benefit is that Runner image and Core image publishing work
again on master

## Linked Issues or Issue Description

Refs #22992

**Describe the bug**
On master, every `Runner image` run after #22992 has its `Build and
check (amd64)` job queued forever with the `cloud-release-32` label. No
runner picks it up. The Docker publish waits on it, so no Core image
publishes.

**Steps to reproduce**
1. Merge any commit to master after #22992.
2. Open the `Runner image` run for that push.
3. See `Build and check (amd64)` queued with no runner for 30+ minutes,
while jobs from other workflows run on `cloud-release-32`.

**Expected behavior**
The amd64 build job starts on a runner, and the Runner image and the
Core image publish.

## What Changed

- `.github/workflows/runner-image.yml`: the `build` and `cache` jobs use
`runs-on: ${{ matrix.runner }}` again. The file is now identical to its
state before #22992. The comment about the larger runner is removed.
- `server/src/__tests__/runner-image-workflow.test.ts`: the guard test
now asserts that the `build` and `cache` jobs use `matrix.runner` and do
not reference `cloud-release-32` or `CORE_PUBLICATION_RUNNER`.
- The parallel archive change in
`scripts/create-provider-pack-archive.mjs` and its test from #22992 do
not change.

To use `cloud-release-32` for this workflow again, an owner must first
let the runner group admit `runner-image.yml`. With the current group
settings, the job never started on that runner. This PR does not change
repository variables, runner groups or organization settings.

## Verification

- `git diff 168253f74d -- .github/workflows/runner-image.yml` is empty.
- `pnpm exec vitest run
server/src/__tests__/runner-image-workflow.test.ts`: 18/18 pass.
- After merge: the master `Runner image` run starts its amd64 job on
`ubuntu-latest`, and the master `Docker` run publishes.

## Risks

- Low risk. This restores the runner placement that worked before
#22992. The master amd64 Runner build goes back to its earlier duration
on the 4-core runner.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Claude Code agent with tool use
and shell 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-25 16:53:08 -06:00
scotttongandScott Tong 854f77efe4 fix(onboarding): preserve model source logo and text proportions during selection (#22999)
## Thinking Path

> - Paperclip helps people manage AI agents.
> - During onboarding, a user selects a model provider.
> - The selected tile moves to the center of the row.
> - Its width can change during this movement when only one provider is
available.
> - The tile's horizontal scale also applies to the logo and text.
> - This change keeps the logo and both labels at their natural size
while the tile moves.

## Linked Issues or Issue Description

**What happened?**

With Codex disabled, selecting Claude stretched the brand mark, provider
name and credential label during the collapse. At 80 ms on desktop, the
provider name grew from 43.69 px to 84.18 px wide.

**Expected behavior**

The logo and both lines of text should stay centered and keep their
resting dimensions throughout the transition.

**Steps to reproduce**

1. Disable the Codex adapter on a disposable instance.
2. Open onboarding, create an organization, and name its first agent.
3. On **Connect a model**, select Claude and inspect an intermediate
animation frame.
4. Repeat with **Use API key instead** and at a narrow viewport.

Related implementation history: #12613 and #18309.

## What Changed

- Give the brand mark and provider name position-only Motion layout
projection.
- Apply the same projection to the credential text inside its existing
fade and slide animation.
- Use the tile's existing transition for all three elements.

## Verification

- Ran the real onboarding wizard in Chrome at 1280 × 800 and 375 × 812.
All eight cases passed, including Claude-only and default
configurations, OpenAI selection, both credential labels, keyboard
input, and reduced motion.
- Measured the image and rendered text ranges every 16 ms through 512
ms. Size and centering stayed within 0.15 CSS px of the expected values.
The tile rectangles matched the baseline on every sampled frame in all
four paired cases.
- Ran `pnpm exec vitest run --project @paperclipai/ui --maxWorkers=4`:
575 files passed, 7,159 tests passed and one skipped.
- An earlier broader local run hit the Mac's PostgreSQL shared-memory
limit in three CLI worktree tests.

## Risks

Low risk. The shared source picker also displays connection choices when
creating an agent. The change is limited to the mark and label spans
inside its existing radio buttons.

## Model Used

OpenAI GPT-6 via Codex with local code editing and browser automation.

## Checklist

- [x] Included the project and subsystem context.
- [x] Specified the model and capabilities used.
- [x] Checked the roadmap for duplicate work.
- [x] I have searched GitHub for duplicate or related PRs and linked
them above.
- [x] Described the bug and reproduction in the issue-template format.
- [x] Used public references.
- [x] Used a descriptive branch name.
- [x] Ran the UI tests and browser checks.
- [x] Added an onboarding Playwright regression that checks both label
bounds and the brand mark during tile movement.
- [x] Documented the risk above.
- [ ] All Paperclip CI gates are green.
- [ ] Greptile is 5/5 with all review findings addressed.
- [x] Will address review findings before merge.

---------

Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local>
2026-11-25 22:51:02 +00:00
DottaandPaperclip 079fb1fe63 fix(secrets): add env-name secret guardrails, collision recovery, and API-access clarity (#22982)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Operators configure agent and environment secrets across Environment
variables and Secret access settings
> - Three common mistakes currently fail poorly or leak credentials:
pasting a token into an environment variable name passes validation and
leaks into run settings and logs, converting a plain environment
variable onto an existing secret name dead-ends with a disabled submit
button, and adding an API-access secret does not clarify that processes
will not see `$NAME` unless it is also bound as an environment variable
> - Secret configuration should prevent credential leaks by default and
recover cleanly from common setup mistakes
> - This pull request rejects and redacts secret-shaped environment
variable names and access aliases across shared, server, and UI layers,
adds "Use existing secret" and "Save as new version" recovery actions on
secret name collisions, and explains API-only vs `$NAME` delivery with
an "Also bind as env var" quick action
> - The benefit is safer secret handling with zero raw token leaks in
errors, settings, or logs and a smoother operator workflow

## Linked Issues or Issue Description

**What happened?**

Three issues occur when operators configure agent and environment
secrets:

1. Pasting a credential token (for example `github_pat_...`, `ghp_...`,
or `sk-...`) into an environment variable Name field passes
`^[A-Za-z_][A-Za-z0-9_]*$` for underscore-based tokens (such as
`github_pat_...` and `ghp_...`) or echoes the raw token in the server
error message for dashed tokens (such as `sk-...`). Existing redactors
also scrub only values, not secret-shaped object keys, so legacy or
rejected payloads leak the token in run settings and logs.
2. Converting a plain environment variable to a secret via
`ConvertToSecretPopover` (or creating a secret via
`CreateSecretPopover`) disables submission with `"A secret with this
name already exists"` whenever the suggested name already exists,
forcing the operator to cancel and switch flows manually.
3. Binding a secret under `Secret access > API access (no env var)` does
not state clearly that agent processes and shell scripts will not see
`$NAME` unless the secret is also bound under Environment variables, and
provides no quick action to add the matching environment variable
binding.

**Expected behavior**

1. Both UI and server reject secret-shaped environment variable names
and access aliases with an actionable error that never echoes the token,
mask accidental token input immediately in the UI, and redact
secret-shaped keys in adapter configs, event payloads, command/text
redaction, and HTTP 4xx/5xx request logs.
2. When a secret name already exists in `CreateSecretPopover` /
`ConvertToSecretPopover`, the popover lets the operator bind the
existing secret directly or save the typed value as a new version
(rotate) without dead-ending.
3. `AgentSecretAccessEditor` clearly explains that API-access secrets
are not injected as `$NAME` in the process environment and offers an
`"Also bind as env var"` quick action for API-only bindings.

**Steps to reproduce**

1. Open an agent's Secrets & variables settings and paste a GitHub
fine-grained PAT (`github_pat_...`) into an environment variable Name
field and save; observe that it is accepted and returned verbatim in
redacted adapter config / logs.
2. Create a company secret named `gh_token`, then add a plain env var
`GH_TOKEN` with a value and click "Store as secret"; observe the
disabled `"Store & bind"` dead end.
3. Bind a secret under `Secret access > API access (no env var)` and
observe that no guidance mentions `$NAME` visibility for
processes/scripts and no quick action exists to also bind it as an
environment variable.

**Paperclip version or commit**

Reproduced on `origin/master` commit
`2d065677959b585065ff3fec8718156a4cf6f41d`.

## What Changed

- **Shared credential-token detection
(`packages/shared/src/validators/secret.ts`,
`packages/shared/src/validators/index.ts`,
`packages/shared/src/index.ts`)**: Exported `ENV_VAR_NAME_RE`,
`looksLikeCredentialToken`, `SECRET_SHAPED_ENV_NAME_ERROR`, and
`SECRET_SHAPED_ACCESS_ALIAS_ERROR` as a single source of truth shared by
`adapter-utils`, `server`, and `ui`. Updated pinned registry
`tests/runner-e2e/source-sdk-public-inputs.json`.
- **Server validation and defense-in-depth redaction
(`server/src/services/secrets.ts`, `server/src/redaction.ts`,
`server/src/middleware/redact-sensitive.ts`,
`packages/adapter-utils/src/command-redaction.ts`)**:
- Rejected credential-shaped env var names and `access.*` aliases in
`normalizeEnvConfig`, `normalizeAdapterConfigForPersistenceInternal`,
`assertSecretBindingConfigPath`, `resolveEnvBindings`, and
`resolveAdapterConfigForRuntime` without echoing the raw token.
- Redacted secret-shaped object keys in `redactAgentAdapterConfig`,
`sanitizeRecord`, and HTTP log `redactSensitive`, and expanded
`command-redaction.ts` / `redaction.ts` token patterns and hints to
cover `github_pat_`, `sk_live_`/`sk_test_`, `rk_live_`/`rk_test_`, Slack
(`xox*-`), AWS (`AKIA`/`ASIA`), Google (`AIza`), and GitLab (`glpat-`)
tokens.
- **UI env-name guardrails
(`ui/src/components/environment-variables-editor/sensitive.ts`,
`model.ts`, `Row.tsx`, `index.tsx`,
`ui/src/components/AgentSecretAccessEditor.tsx`)**:
- Flagged credential-shaped variable names and access aliases
immediately with an inline error, masked the input (`type="password"` +
`ANALYTICS_NO_CAPTURE_CLASS`), redacted credential-shaped names in the
unsaved-changes summary, disabled inline Save while present, and dropped
credential-shaped aliases from emitted access maps.
- **Plain-to-secret collision recovery
(`ui/src/components/environment-variables-editor/CreateSecretPopover.tsx`,
`Row.tsx`, `index.tsx`, `ui/src/components/AgentSecretAccessEditor.tsx`,
`ui/src/components/AgentConfigForm.tsx`,
`ui/src/pages/CompanyEnvironments.tsx`,
`ui/src/components/ProjectProperties.tsx`)**:
- Replaced the dead-end duplicate-name error in `SecretPopoverForm` with
an inline recovery panel offering `"Use existing secret"` and `"Save as
new version"` (when active and rotatable), wired to `secretsApi.rotate`
across agent, environment, and project editors.
- **API-access vs `$NAME` clarity
(`ui/src/components/AgentSecretAccessEditor.tsx`,
`ui/src/lib/secret-delivery.ts`,
`ui/src/components/AgentConfigForm.tsx`)**:
- Clarified under `API access (no env var)` that processes and shell
scripts will not see `$NAME` unless bound under Environment variables
above, and added an `"Also bind as env var"` quick action on API-only
secret summaries wired to `AgentConfigForm`.
- **Tests**: Extended existing owner suites
(`server/src/__tests__/redaction.test.ts`,
`server/src/__tests__/redact-sensitive.test.ts`,
`server/src/__tests__/agents-adapter-config-user-secret.test.ts`,
`ui/src/components/environment-variables-editor/model.test.ts`,
`ui/src/components/environment-variables-editor/EnvironmentVariablesEditor.test.tsx`,
`ui/src/components/AgentSecretAccessEditor.test.tsx`).

## Verification

- `pnpm vitest run
ui/src/components/environment-variables-editor/EnvironmentVariablesEditor.test.tsx
ui/src/components/AgentSecretAccessEditor.test.tsx
ui/src/components/environment-variables-editor/model.test.ts
ui/src/components/environment-variables-editor/sensitive.test.ts
server/src/__tests__/redaction.test.ts
server/src/__tests__/redact-sensitive.test.ts` — 6 files, 149/149
passed.
- `pnpm vitest run --hookTimeout=120000 --testTimeout=120000
server/src/__tests__/agents-adapter-config-user-secret.test.ts` — 1
file, 6/6 passed (embedded Postgres route test verifying HTTP 422
rejection without token echo for `github_pat_`, `ghp_`, and `sk-` env
var names).
- `pnpm vitest run packages/adapter-utils/src/command-redaction.test.ts`
— 1 file, 43/43 passed.
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/adapter-utils typecheck && pnpm --filter
@paperclipai/server typecheck && pnpm --filter @paperclipai/ui
typecheck` — PASS (0 errors, Storybook catalog clean).
- `pnpm check:token-gates` — PASS (all 4 token gates clean).
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/redaction.test.ts
server/src/__tests__/redact-sensitive.test.ts
server/src/__tests__/agents-adapter-config-user-secret.test.ts
ui/src/components/environment-variables-editor/model.test.ts
ui/src/components/environment-variables-editor/EnvironmentVariablesEditor.test.tsx
ui/src/components/AgentSecretAccessEditor.test.tsx` — PASS.
- `pnpm verify --base 2d06567795
--explain` — `source-sdk-public-inputs.json` verified in sync; exited 2
due to broad input (`tests/runner-e2e/source-sdk-public-inputs.json`),
deferring repo-wide matrix to sharded PR CI.

## Risks

- Low risk. `looksLikeCredentialToken` matches only explicit provider
credential prefixes (`gh[pousr]_`, `github_pat_`, `sk-`,
`sk_live_`/`sk_test_`, `rk_live_`/`rk_test_`, `xox[baprs]-`,
`AKIA`/`ASIA`, `AIza`, `glpat-`, `npm_`, `hf_`, `lin_api_`, `sbp_`,
`SG.`, JWTs, PEM headers, `Bearer `) so ordinary uppercase or long env
var names are unaffected.
- Legacy agent or environment records that already stored a
secret-shaped env var key will now have that key masked as
`***REDACTED***` on reads and skipped with a redacted warning at runtime
(preserving existing heartbeats) and rejected on subsequent saves until
removed/renamed.
- No database migrations are required.

## Model Used

- Google Gemini (Antigravity agentic coding assistant with extended
reasoning, tool use, and local command execution)

## Checklist

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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 22:08:28 +00:00
Dottaandlucktastic a74b4f8196 feat(retry): let a board user grant one agent the task Retry (#22988)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - When a run stops in a state that needs board approval, Paperclip
holds the task until a board user presses Retry (`POST
/api/issues/{id}/retry`).
> - Some companies run an operations agent that reviews stopped tasks
and identifies routine Retries, but the route currently rejects every
agent with `403 Board access required`.
> - The only workaround is sharing a board key with the agent, which
grants unrelated board powers and hides which agent requested the Retry.
> - This pull request adds one narrow, opt-in permission key
(`tasks:retry`) that a board user can grant to a named agent so the
agent can call `POST /api/issues/{id}/retry` as that person, under all
existing gates and a per-task daily cap.
> - The benefit is that routine Retries stop waiting on manual clicks
while preserving least privilege, existing pause/budget/hold gates, and
full audit attribution for both the agent and the granting person.

## Linked Issues or Issue Description

- Closes #21633
- Supersedes #21634 (rebased cleanly onto current `master` with synced
SDK public input pins, OpenAPI `429` response documentation, and
additional route integration coverage for pause gates, revoked grants,
inactive grantors, cross-company isolation, and chat tasks)
- Refs #20081 and #18599 (broader delegate proposals; this change stays
narrow to one action, one grant per agent, and a per-task daily cap)

## What Changed

- `packages/shared/src/constants.ts`: add `tasks:retry` to
`PERMISSION_KEYS`. New agents do not receive it by default.
- `server/src/services/agent-task-retry.ts` (new):
- `agentTaskRetryActor`: resolves the agent's unscoped `tasks:retry`
grant and the active same-company board member who saved it. Grants
without a granting user (for example, agent-written rows), grants saved
with a scope, revoked grants, and inactive grantors return `null` and
fail closed. Returns a board actor scoped strictly to the agent's
company with `isInstanceAdmin: false`.
- `agentOwnsRun`: verifies that the supplied run ID is a valid UUID
belonging to the calling agent in the same company.
- `recordAgentTaskRetry`: under a per-task PostgreSQL transaction
advisory lock (`agent-task-retry:{issueId}`), enforces a rolling 24-hour
cap of 3 Retries per agent per task (`429` with `details.code:
"agent_task_retry_cap_reached"`), counts replays of the same
`idempotencyKey` once, and writes `issue.retry_requested_by_agent` to
`activity_log` with the agent, run ID, `grantedByUserId`, and
`idempotencyKey`.
- `server/src/routes/issues.ts` (`POST /issues/:id/retry`; small
+33-line delegation calling into
`server/src/services/agent-task-retry.ts` so the existing >1,000-line
route module does not absorb service logic): for an agent with a valid
`tasks:retry` grant, enforces the agent's own limits first (refuses
scoped `skill_test`/`task_bridge` keys, requires the agent's own run ID,
enforces `issue:read` and actor-class/interaction `issue:mutate`
boundaries), then runs the existing board Retry checks as the granting
person (preserving visibility, `issue:mutate`, pause, budget, hold, and
blocker gates). Refuses chat tasks (`403`) and cross-company tasks
(`404`). Agents without a valid grant keep getting `403`.
- `server/src/routes/openapi.ts`: remove `POST /api/issues/{id}/retry`
from `BOARD_ONLY_OPERATIONS` so granted agents can discover it via API
search, and document `429` in the endpoint responses.
- `doc/agent-permission-defaults.md` and `docs/api/issues.md`: document
`tasks:retry`, its default-off behavior, run/key requirements, daily
cap, and activity attribution.
- `tests/runner-e2e/source-sdk-public-inputs.json`: refresh the pin for
`packages/shared/src/constants.ts`.
- `server/src/__tests__/issue-scheduled-retry-routes.test.ts` and
`server/src/__tests__/issue-agent-mutation-ownership-routes.test.ts`:
add 14 embedded-Postgres route integration tests and 1 mocked-boundary
test covering default refusal, agent-written grant refusal,
board-granted Retry promotion + activity attribution, pause-gate
preservation, grantor visibility gates, revoked grant / suspended
grantor fail-closed, cross-company 404, chat task 403, daily cap 429,
idempotency replay counting, foreign run ID refusal, scoped grant
refusal, low-trust read/write boundary enforcement, and scoped key
refusal.

## Verification

- RED check on base `2d065677959b585065ff3fec8718156a4cf6f41d` before
production changes:
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/issue-scheduled-retry-routes.test.ts -t "agent Retry with
a board user's tasks:retry grant"` failed because granted agents
received `403 Board access required` instead of `202` / `429` / `404`
and logged 0 `issue.retry_requested_by_agent` events.
- GREEN checks on head `14b5591073ea591251f2d24710a32e3c725a090c`:
- `pnpm --filter @paperclipai/shared build && pnpm --filter
@paperclipai/shared typecheck && pnpm --filter @paperclipai/server
typecheck`: passed (0 errors across `@paperclipai/shared` and all 7
`@paperclipai/server` typecheck layers).
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/issue-scheduled-retry-routes.test.ts
src/__tests__/openapi-routes.test.ts
src/__tests__/agent-default-configure-grants.test.ts`: passed (112/112
tests, including all 14 embedded-Postgres `agent Retry with a board
user's tasks:retry grant` tests and default-grant verification).
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/issue-agent-mutation-ownership-routes.test.ts`: passed
(229/229 tests).
- `pnpm exec vitest run --root tests/runner-e2e
source-sdk-public-inputs.test.mjs source-sdk-evidence.test.ts
source-sdk-public-type.test.ts
chat-catalog-domains/identity-accounting.test.ts`: passed (4 files,
98/98 tests).
- `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse
HEAD) --check`: passed (`changed: false`, 578 inputs in sync).
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/issue-scheduled-retry-routes.test.ts
server/src/__tests__/issue-agent-mutation-ownership-routes.test.ts`:
passed (`110 nightly suites validated, 2 test file(s) checked`).
- `pnpm verify --base 2d06567795
--explain`: exited 2 (`Global CI input changed:
doc/agent-permission-defaults.md`); sharded PR CI covers the full suite.

## Risks

- A granted agent acts with the granting board user's authority on `POST
/api/issues/{id}/retry` within the agent's company. Revoking the grant
or deactivating the granting user immediately closes access.
- The per-task daily cap counts `issue.retry_requested_by_agent` rows in
`activity_log`; pruning `activity_log` within 24 hours would reset that
window early.
- Downstream Retry domain records name the granting user; the initiating
agent and run are recorded in the corresponding
`issue.retry_requested_by_agent` activity entry.
- Sandboxed agents using the sandbox callback bridge remain blocked from
this route; this change does not widen the bridge.

## Model Used

- Google Gemini (Antigravity agentic coding assistant with extended
reasoning, shell execution, file editing, and automated test
verification), building on #21634 (originally co-authored by lucktastic
and Claude Opus 5.5).

## 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: lucktastic <13757243+lucktastic@users.noreply.github.com>
2026-11-25 22:06:37 +00:00
DottaandPaperclip e18fe61c8f perf(runner-image): parallelize pack archiving and use cloud-release-32 on master amd64 (#22992)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner image workflow (`.github/workflows/runner-image.yml`)
builds `ghcr.io/paperclipai/paperclip-runner` for `amd64` and `arm64`
whenever Runner inputs change
> - Profiling recent builds showed `Build and check (amd64)` taking ~12
minutes versus ~4m 38s on `arm64`, driven by 4-core CPU saturation
during `create-provider-pack-archive.mjs` (which compressed every large
provider-pack binary serially on a single core) and during OCI tar/gzip
export on `ubuntu-latest`
> - Because `docker.yml` waits for the Runner image whenever Runner
inputs change, slow `amd64` Runner builds sit directly on the release
critical path
> - This pull request parallelizes zstd layer archive creation in
`scripts/create-provider-pack-archive.mjs` with bounded concurrency
while preserving byte-for-byte deterministic output, and routes
canonical `master` `amd64` runs of `.github/workflows/runner-image.yml`
to the larger GitHub-hosted runner (`cloud-release-32`)
> - The benefit is cutting `amd64` Runner image build time substantially
on `master` (and speeding up provider-pack archiving on every PR and
architecture) without weakening the PR/fork security boundary or
changing output bytes

## Linked Issues or Issue Description

**What existing behavior does this improve?**
`scripts/create-provider-pack-archive.mjs` layer compression throughput
and `.github/workflows/runner-image.yml` `amd64` runner sizing on
canonical `master` pushes.

**Subsystem affected**
Cross-cutting (multiple of the above)

**Current behavior**
`createProviderPackLayers` compresses `overlay.tar.zst` and each large
provider-pack file (`0.tar.zst..N.tar.zst`) sequentially on one CPU
core. In `.github/workflows/runner-image.yml`, canonical `master`
`amd64` builds run on 4-core `ubuntu-latest` (~12 minutes total vs ~4m
38s on `arm64`).

**Proposed behavior**
`createProviderPackLayers` compresses `overlay.tar.zst` and the indexed
large-file archives through a bounded worker pool
(`min(availableParallelism(), 8)`), preserving exact file ordering,
archive numbering, and byte-for-byte deterministic zstd frames. In
`.github/workflows/runner-image.yml`, canonical `master` `amd64` pushes
(`paperclipai/paperclip`, `push` to `refs/heads/master`) use
`vars.CORE_PUBLICATION_RUNNER || 'cloud-release-32'`, while all PRs,
forks, schedules, and `arm64` jobs stay on standard GitHub-hosted
runners.

**Reason and benefit**
Eliminates single-core archiving bottlenecks across all environments and
removes the 4-core `amd64` CPU bottleneck on `master` Runner image
publications.

**Breaking changes**
None.

## What Changed

- Updated `scripts/create-provider-pack-archive.mjs` to compress
`overlay.tar.zst` and large-file archives via a bounded worker pool
while preserving exact archive indices, receipt ordering, and
byte-for-byte deterministic output.
- Added `scripts/__tests__/create-provider-pack-archive.test.mjs`
verifying serial (`concurrency: 1`) and parallel (`concurrency: 4`) runs
produce identical receipts and archive bytes.
- Updated `.github/workflows/runner-image.yml` to route canonical
`master` `amd64` pushes to `vars.CORE_PUBLICATION_RUNNER ||
'cloud-release-32'` while keeping PRs, forks, schedules, and `arm64` on
`matrix.runner`.
- Added a workflow guard in
`server/src/__tests__/runner-image-workflow.test.ts` verifying only
canonical `master` `amd64` pushes use the larger GitHub-hosted runner
and never touch self-hosted AWS release fleets.

## Verification

- `node --test scripts/__tests__/create-provider-pack-archive.test.mjs`
(passed)
- Vitest: `server/src/__tests__/runner-image-identity.test.ts` (42/42
passed)
- Vitest: `server/src/__tests__/runner-image-workflow.test.ts` (18/18
passed)
- PR CI also executes the live `Runner image` workflow end-to-end
because both `scripts/create-provider-pack-archive.mjs` and
`.github/workflows/runner-image.yml` are in its PR path filter.

## Risks

- Low risk. Archive bytes and receipt structure are verified identical
between serial and parallel runs. PRs, forks, and schedules remain on
`ubuntu-latest` / `ubuntu-24.04-arm`, and `cloud-release-32` is the same
GitHub-hosted larger runner already used on `master` by `docker.yml` and
`cloud-migrator-artifacts.yml`.

## Model Used

- Gemini 3 Pro (Antigravity agent with tool use, shell execution, and
local test 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
- [ ] 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-25 16:03:05 -06:00
Dotta 168253f74d fix(telemetry): send agent.task_completed when a native run closes a task (#22963)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip sends product telemetry, and the `agent.task_completed`
event counts each task that an agent finishes
> - Only the REST issue update route (`server/src/routes/issues.ts`)
sent `agent.task_completed` when an agent moved a task to `done`
> - Native runs close tasks through `commitNativeStatusDecision` in
`server/src/services/native-runtime/status-decision-committer.ts`, which
bypasses the REST route and therefore sent `agent.task_run` without ever
sending `agent.task_completed`
> - Deployments where agents close tasks through native runs
consequently under-report completed tasks
> - This pull request supersedes #21206 (rebased onto current `master`),
sending `agent.task_completed` once after a committed native transition
into `done` without blocking finalization, with full company/person
telemetry scope and underlying Paperclip runner harness `adapter_type`
resolution
> - The benefit is accurate, deduplicated `agent.task_completed`
telemetry across both API and native completion paths

## Linked Issues or Issue Description

Refs #21206

**What happened?**
A native run closes a task through `commitNativeStatusDecision` in
`server/src/services/native-runtime/status-decision-committer.ts`. The
task moves to `done` and the run sends `agent.task_run`, but no
`agent.task_completed` event is sent because the only sender is
`server/src/routes/issues.ts` and native completion does not go through
that route.

**Expected behavior**
Paperclip sends one `agent.task_completed` event each time an agent
moves a task into `done`, on both the REST issue route and native status
commits. The event carries the same dimensions, runner harness
`adapter_type`, company scope, and person attribution as the issue
route. Replayed commits and tasks that were already `done` send nothing.

**Steps to reproduce**
1. Seed a native run ready to commit a `done` status decision on an
`in_progress` task.
2. Call `commitNativeStatusDecision` (or `finalizeNativeRun`) with a
`done` decision.
3. Observe that the task moves to `done`, while
`trackAgentTaskCompleted` is called 0 times.

**Paperclip version or commit**
`master` at `2d065677959b585065ff3fec8718156a4cf6f41d`.

## What Changed

- `server/src/services/agent-task-run-telemetry.ts`: add
`emitAgentTaskCompleted`. It loads the agent within the task's
`companyId`, resolves the underlying runner harness with
`telemetryAdapterType(agent)`, resolves person attribution with
`resolveTelemetryPerson`, wraps `trackAgentTaskCompleted` in
`withTelemetryActor({ companyId, person }, ...)`, and never throws.
- `server/src/services/native-runtime/status-decision-committer.ts`:
select `originRun.responsibleUserId` alongside `originRun.agentId`,
capture the completion payload only when the committed transaction
transitions `issue.status` from non-`done` to `done` with an origin
agent, and invoke `void emitAgentTaskCompleted(input.db, completedTask)`
after commit when `!committed.replayed` so slow lookups cannot block run
finalization.
-
`server/src/services/native-runtime/native-task-completed-telemetry.test.ts`:
add embedded-Postgres regression tests covering single emission (with
company scope, person attribution, and underlying runner harness
`adapter_type`), no duplicate on replay, non-blocking commit while
telemetry is pending, and no emission when the task was already `done`.
- `server/src/__tests__/agent-task-run-telemetry.test.ts`: add unit/DB
coverage for `emitAgentTaskCompleted` (company/person scope, runner
harness `adapterType`, cross-company agent isolation, and error
swallowing).
-
`server/src/services/native-runtime/native-run-finalizer-telemetry.test.ts`:
add an end-to-end `finalizeNativeRun` integration test verifying a real
native run completion emits `agent.task_completed` once through the real
`trackAgentTaskCompleted` path and emits no duplicates on replay or
reconciliation.

Note: this PR supersedes #21206 (whose fork branch had merge conflicts
with pruned test suites and predated `withTelemetryActor` /
`telemetryAdapterType` on `master`, and whose fork repository did not
allow maintainer pushes from this account).

## Verification

- **RED (before fix on `2d065677959b585065ff3fec8718156a4cf6f41d`):**
`pnpm --dir server exec vitest run
src/services/native-runtime/native-task-completed-telemetry.test.ts`
Result: 1 failed | 1 passed — `sends agent.task_completed once with
company, person, and harness adapter_type when the runner closes a task`
failed with `AssertionError: expected "vi.fn()" to be called 1 times,
but got 0 times`.
- **GREEN (after fix):**
`pnpm --dir server exec vitest run
src/services/native-runtime/native-task-completed-telemetry.test.ts
src/__tests__/agent-task-run-telemetry.test.ts
src/services/native-runtime/native-run-finalizer-telemetry.test.ts
src/__tests__/heartbeat-status-preserving-telemetry.test.ts
src/__tests__/issue-telemetry-routes.test.ts`
Result: **5/5 files, 106/106 tests passed**
(`native-task-completed-telemetry.test.ts` 3/3,
`agent-task-run-telemetry.test.ts` 55/55,
`native-run-finalizer-telemetry.test.ts` 42/42 including end-to-end
`finalizeNativeRun`, `issue-telemetry-routes.test.ts` 5/5,
`heartbeat-status-preserving-telemetry.test.ts` 1/1).
- **Typecheck:** `pnpm --filter @paperclipai/server typecheck` —
**PASS** (0 errors across all layers).
- **Test budget:** `node scripts/check-test-budget.mjs --files
server/src/services/native-runtime/native-task-completed-telemetry.test.ts
server/src/__tests__/agent-task-run-telemetry.test.ts
server/src/services/native-runtime/native-run-finalizer-telemetry.test.ts`
— **PASS** (110 nightly suites validated, 3 test files checked).
- **Broader suite:** `pnpm verify --base
2d06567795 --explain` conservatively
selected 1948/2302 files; PR CI supplies the full sharded server,
runner, typecheck, and build verification.
- **Runtime dependency assumption
(`rules/runtime-dependency-boundaries.mdc`):**
`commitNativeStatusDecision` fires `void emitAgentTaskCompleted(...)`
after transaction commit without awaiting it;
`native-task-completed-telemetry.test.ts` verifies with a
never-resolving promise that run finalization returns immediately even
if the telemetry lookup hangs.

## Risks

- Low risk. Emission runs after transaction commit as fire-and-forget
and catches all errors, so a rolled-back commit sends nothing and a
telemetry fault cannot fail or delay a status commit.
- Deployments where native runs close tasks will see
`agent.task_completed` counts rise to reflect actual completions, which
is the intended fix.

## Model Used

- Google Antigravity (`antigravity`, tool use and code execution),
building on and rebasing #21206 onto `master`.

## 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-25 16:02:12 -06:00
Dotta 702368ffaf feat(github): graduate GitHub review bots out of experimental (#22996)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - GitHub Code Review Bot connects an agent to a dedicated GitHub App
so it reviews pull requests and responds to GitHub mentions
> - The feature was gated behind the default-off
`enableGitHubReviewBots` experimental instance setting, hiding the
catalog card, setup routes, identity links, and channel creation
> - People had to find and flip an instance-level experimental switch
before they could connect a GitHub review agent
> - This pull request graduates GitHub review bots to a normal always-on
feature, keeping `enableGitHubReviewBots` only as a deprecated
compatibility key that always resolves to `true`
> - The benefit is that every Paperclip instance exposes GitHub Code
Review Bot setup, discovery, and management by default without requiring
feature flags

## Linked Issues or Issue Description

**What existing behavior does this improve?**
GitHub Code Review Bot discovery, catalog visibility, setup/management
routes, identity-link endpoints, and Agent Channels visibility
(`enableGitHubReviewBots`).

**Subsystem affected**
Cross-cutting (`packages/shared`, `server/`, `ui/`, Storybook, E2E
specs, docs).

**Current behavior**
GitHub Code Review Bot is hidden from Connectors, `connections_search`,
chat-endpoint creation, identity-link confirmation, and UI
setup/settings routes until an instance admin turns on **Settings →
Experimental → GitHub review bots** (`enableGitHubReviewBots`).

**Proposed behavior**
GitHub Code Review Bot is always available as a standard feature on
every instance (self-hosted and Cloud), matching AgentMail and graduated
features such as Assistant connections (`enablePublicMcp`) and the AWS
connector (`enableAwsConnector`). `enableGitHubReviewBots` stays in
schemas and the feature catalog only as a deprecated compatibility key
that always normalizes to `true`, ignores stored or Cloud-managed
`false` values, and does not reject legacy `false` patches. Experimental
chat providers (Slack, Discord, Microsoft Teams, Telegram, iMessage
Photon, Speko) remain gated by `enableChatConnectors`.

**Reason and benefit**
Users can connect and manage GitHub review agents directly from
Connectors without an admin enabling an experimental flag first, and
Cloud stacks no longer require managed feature-flag overrides to expose
GitHub review bots.

**Breaking changes**
No schema migration or breaking API change. Existing rows, API patches,
and Cloud managed configs that still carry `enableGitHubReviewBots`
continue to parse cleanly, while the effective value is always `true`.
Instances that previously kept `enableGitHubReviewBots` off now display
GitHub Code Review Bot in Connectors and allow authorized managers
(`tools:manage_connections`) to create GitHub review bot endpoints.

## What Changed

- `packages/shared`: marked `enableGitHubReviewBots` as a deprecated
compatibility key in types, Zod defaults (`true`), and
`INSTANCE_FEATURE_CATALOG` (`cloudDefault: true`, `selfHostedDefault:
true`); updated `channelMethodEnabled` in `connector-availability.ts` so
`github` is always enabled alongside `agentmail`.
- `server` instance settings and Cloud staging:
`normalizeExperimentalSettings` always returns `enableGitHubReviewBots:
true`; `applyManagedExperimentalOverlay` and `updateExperimental` ignore
retired `enableGitHubReviewBots` entries so Cloud managed configs cannot
turn it off and legacy `false` patches are not rejected; removed
`enableGitHubReviewBots` from `CLOUD_STAGING_EXPERIMENTAL_KEYS`.
- `server` chat channels, discovery, and OpenAPI: allowed `github` in
`assertChatProviderEnabledForCreate`, `assertIdentityProviderEnabled`,
`assertIdentityLinkAccess`, and `connection-intents` discovery without
experimental flags while keeping `enableChatConnectors` enforcement for
experimental chat providers; updated the OpenAPI endpoint description.
- `ui` and Storybook: removed the **GitHub review bots** Experimental
settings toggle card; simplified `useChatConnectorsEnabled` and
`chatProviderVisible` so `github` and `github-code-review-bot` are
always visible; bypassed experimental loading wait for `provider=github`
in `ChatConnectorsExperimentalGate`; made the classic Agent Detail
Channels tab and `AgentChannelsPanel` empty-state copy always reflect
available agent identities; updated `canEnterAppsConnect`, `Browse`,
`ConnectionSetupFlow`, and `github-connections.stories.tsx`.
- Tests, E2E, runner-e2e, docs, and maps: updated unit, integration,
managed-overlay, runner-e2e, and Playwright E2E specs; refreshed
`tests/runner-e2e/source-sdk-public-inputs.json`; updated
`doc/connections/GITHUB.md`, `doc/connections/GITHUB-REVIEW-BOT.md`, and
`maps/feature-map/chat-channels.md`.

## Verification

- `pnpm --filter @paperclipai/shared build && pnpm --filter
@paperclipai/shared typecheck && pnpm --filter @paperclipai/server
typecheck && pnpm --filter @paperclipai/ui typecheck` — passed.
- `node scripts/check-maps.mjs && node scripts/storybook-catalog.mjs` —
passed.
- `pnpm vitest run packages/shared/src/validators/instance.test.ts
packages/shared/src/connector-availability.test.ts
packages/shared/src/feature-catalog.test.ts
server/src/__tests__/instance-settings-service.test.ts
server/src/__tests__/instance-settings-managed-overlay.test.ts
server/src/__tests__/instance-settings-cloud-defaults.test.ts
server/src/routes/chat-channels.identity.test.ts
server/src/__tests__/connection-intents-service.test.ts
server/src/__tests__/chat-channels/slack-ingress-and-threads.integration.test.ts
server/src/__tests__/chat-channels/github-setup-and-access.integration.test.ts`
— all passed.
- `pnpm vitest run ui/src/pages/apps/app-connect-policy.test.ts
ui/src/components/chat/ExternallyConnectedTaskBanner.test.tsx
ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx` —
3 files, 62 tests passed.
- `pnpm --dir tests/runner-e2e vitest run github-review-journey.test.ts`
— 56 tests passed.
- `pnpm verify --explain` — confirmed
`tests/runner-e2e/source-sdk-public-inputs.json` is current; exited 2
for broad CI coverage (handled by required GitHub CI gates on this PR).

## Risks

- Behavioral shift: instances that had `enableGitHubReviewBots` off now
show GitHub Code Review Bot in Connectors and allow authorized users
with `tools:manage_connections` to configure GitHub review bots.
Existing permission boundaries (`tools:manage_connections`, company
scoping, GitHub App OAuth/installation consent) are unchanged.
- `useIssueChatBinding` now queries `/api/issues/:issueId/chat-binding`
for normal tasks even when `enableChatConnectors` is off so GitHub-bound
task banners remain visible; experimental chat bindings remain filtered
out by `chatProviderVisible` while `enableChatConnectors` is off.
- No database migration is required; stored `enableGitHubReviewBots`
JSON values become inert.

> 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

- Google Gemini (high reasoning) in Antigravity, with tool use (shell,
file edits, test execution).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [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-25 16:01:38 -06:00
Dotta 1a1d436cc5 docs: add GitHub Review Bots setup and architecture guide (#22995)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The GitHub Code Review Bot connector lets any Paperclip agent review
pull requests through a dedicated GitHub App
> - Operators had no public user guide under
`docs/guides/board-operator/`, and the internal connector doc still
instructed users to toggle an experimental flag
> - Users need accurate GA setup steps, clear separation between
triggers and GitHub Rulesets merge checks, and honest self-hosted
sandbox guidance
> - This pull request adds the public GitHub Review Bots operator guide,
registers it in `docs/docs.json`, and updates
`doc/connections/GITHUB-REVIEW-BOT.md` to match GA availability
> - The benefit is that Cloud and self-hosted operators can connect,
configure, and troubleshoot GitHub Review Bots from verified
documentation

## Linked Issues or Issue Description

**Issue type**
Missing documentation

**Where is the issue?**
`docs/guides/board-operator/github-review-bots.md`, `docs/docs.json`,
and `doc/connections/GITHUB-REVIEW-BOT.md`

**What's wrong?**
The public docs site does not include a board operator guide for GitHub
Review Bots, and `doc/connections/GITHUB-REVIEW-BOT.md` still tells
operators to enable a default-off experimental flag before setup.

**Suggested fix**
Publish the GitHub Review Bots setup and architecture guide under
`docs/guides/board-operator/github-review-bots.md`, register it in
`docs/docs.json`, and update `doc/connections/GITHUB-REVIEW-BOT.md` to
reflect GA setup.

## What Changed

- Added `docs/guides/board-operator/github-review-bots.md` covering
Quickstart, the three independent choices (App installation, Paperclip
triggers, opt-in GitHub Rulesets), structured 0–5 assessments and
commit-bound `Paperclip Review` check runs, linked members and sponsored
external contributors, low-trust presets vs. self-hosted runtime
sandboxing, localhost Cloud connector ingress vs. direct HTTPS, bot
avatar branding, and troubleshooting.
- Registered `guides/board-operator/github-review-bots` in
`docs/docs.json` under the Board Operator group.
- Updated `doc/connections/GITHUB-REVIEW-BOT.md` to remove the outdated
experimental-flag toggle instruction from the setup section.

## Verification

- Validated `docs/docs.json` JSON parsing and verified
`docs/guides/board-operator/github-review-bots.md` exists and is
registered.
- Verified `git diff --check` passes cleanly with no trailing whitespace
or formatting issues.
- Docs-only change; no server, UI, or database code modified.

## Risks

- Low risk. Documentation-only change with no runtime or schema impact.

## Model Used

Gemini 3.1 Pro / Gemini 4 Neon (High)
2026-11-25 15:50:20 -06:00
DottaandClaude Opus 5.5 73369c5d46 feat(connections): AWS connector out of experimental; role ARN comes back from the agent (#22994)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The AWS connector lets agents work in an AWS account through AWS's
hosted MCP server, with a per-connection role and short-lived
credentials (#22083, #22195, #22233, #22626)
> - It has been behind the `enableAwsConnector` experimental setting. It
is now proven on paperclip.staging: a connection was set up end to end,
and the daily QA routine's agent uses it to read private test evidence
from S3
> - On the role step, the person still had to paste the role ARN back,
even when their own agent created the role and reported the ARN in its
live checklist
> - This pull request takes the connector out of experimental and has
the page pick up the role ARN from the agent, keeping the field for
people who set the role up by hand
> - The benefit is AWS available to everyone, with a setup that is
"paste a prompt, press Test connection"

## Linked Issues or Issue Description

Refs #22233 (role setup), #22626 (live agent checklist).

**Subsystem affected**
Connections (AWS app definition, role setup UI), instance experimental
settings.

**Problem or motivation**
- The AWS connector works, but is hidden unless an operator turns on an
experimental flag.
- The setup page always showed a Role ARN field, and the person had to
copy the ARN from the agent's summary into it.

**Proposed solution**
- Remove `experimentalFeatureKey` from the AWS app definition.
`enableAwsConnector` becomes a compatibility key: stored and
Cloud-managed values are ignored, and old clients' writes are accepted
(same pattern as `enableMcpAggregators` and `enablePublicMcp`).
- Move the Role ARN field into "Or do it by hand". When the agent
finishes, take the ARN from its finish summary, accepting only an IAM
role ARN for this connection's own role name
(`paperclip-<connectionId>`), so a summary cannot point the connection
at another role. "Test connection" then works with nothing to paste. The
by-hand section opens on its own when a test fails or the agent finished
without a usable ARN.

**Alternatives considered**
- Letting the agent save the ARN through the checklist API: more surface
on a token-only route. Reading it from the finish summary needs no new
API, and the test still proves the role trusts only this connection.
- Removing the field entirely: people who use CloudFormation or IAM by
hand still need it.

## What Changed

- `packages/shared/src/app-definitions/aws.json`,
`scripts/app-definition-overrides/aws.json`: no
`experimentalFeatureKey`.
- `packages/shared/src/feature-catalog.ts`, `validators/instance.ts`:
`enableAwsConnector` is "(compatibility)", default on.
- `server/src/services/instance-settings.ts`: always on; Cloud-managed
values skipped; old clients' writes accepted.
- `ui/src/pages/InstanceExperimentalSettings.tsx`: the AWS toggle is
removed.
- `ui/src/features/connections/aws-role-arn.ts` (new): the role ARN rule
and `roleArnFromAgentSummary`.
- `ui/src/features/connections/AwsRoleSetup.tsx`: Role ARN under "Or do
it by hand", auto-filled from the agent's summary, with copy updated
("hands back the role when it finishes", "the Role ARN field below").
- `doc/connections/AWS.md`: no longer described as experimental.

## Verification

- Server: `aws-mcp-connector.test.ts` (connects even with a stored
`enableAwsConnector: false`),
`instance-settings-managed-overlay.test.ts` (stays on with stored and
Cloud-managed false; an old client's false write is accepted),
`instance-settings-service.test.ts`: 68 passed. The 4 new flag tests
fail against master's source (red/green).
- Shared: `app-definitions.test.ts` 43 passed;
`scripts/app-definition-overrides.test.mjs` 3 passed.
- UI: `aws-role-arn.test.ts` 3 passed (this connection's ARN from a
summary, including role paths and a trailing period; another role, a
longer name, a short account and no ARN are rejected). UI typecheck
clean.
- Storybook (headless Playwright, current branch): the default view has
no Role ARN field; "agent done" shows "Your agent's role is ready. Test
the connection to finish." with Test connection enabled; "test failed"
opens "Or do it by hand" with the field at its end. No page errors.
- Live: the connector was set up end to end on paperclip.staging (Test
connection passed) and is in daily use by the QA routine. To re-check
after deploy without the flag.

## Risks

- Every instance now shows the AWS connector. It was already proven on
staging; access is per connection and read-only connections are capped
by AWS's `ReadOnlyAccess`.
- The ARN auto-fill trusts only an ARN naming this connection's own
role, and Test connection still verifies AWS accepts it, so a wrong or
foreign ARN cannot be saved silently.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, Storybook with headless Playwright, the live staging
instance).

## 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-25 15:44:59 -06:00
Dotta 8e8c1b9f4d fix(sandbox): scope staged provider-pack assets per provider and default Daytona disk to 20 GiB (#22981)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Native agents run inside remote Daytona sandboxes that require a
verified Runner provider pack
> - When a sandbox stages the provider pack into its workspace,
Paperclip copies, transfers, and verifies every
`provider-assets/<provider>` closure (~1.6 GB across pi, cursor,
copilot, kimi, and antigravity) even when the run only uses Claude,
Codex, OpenCode, or one provider
> - New image-backed Daytona sandbox environments also default to a 10
GiB disk, which leaves too little headroom for repository installs and
tests
> - This pull request stages and verifies only the
`provider-assets/<provider>` tree needed by the active run and raises
the Daytona plugin default disk size from 10 GiB to 20 GiB
> - The benefit is significantly more free workspace disk space, smaller
pack transfers, and safer default disk sizing without changing the
provider-pack archive format or breaking multi-provider workspace reuse

## Linked Issues or Issue Description

- Fixes: #19367
- Refs #19484
- Related: #19500 (ENOSPC fail-fast and full-sandbox recovery already
merged in #22068, #22239, #22383, #22466, and #22837), #22241
(deduplicated repeated bytes in staged packs)

## What Changed

- `server/src/services/native-runtime/provider-pack-compatibility.ts`:
add `requiredProviderAssetNames`, `isProviderAssetPathIncluded`, and
`providerAssetExcludeArgs` helpers that resolve the required
`provider-assets/<provider>` subset for a `PackProvider` (returning
unfiltered behavior when `provider` is omitted).
- `server/src/services/native-runtime/provider-pack-layers.ts`: filter
large layer entries by required provider assets before running the
remote reuse script and transferring missing layers, preserve
cross-provider image-twin reuse so core files can still reuse identical
bytes from excluded provider paths in the base image, and pass
`--exclude` flags to GNU `tar` for `overlay.tar.zst`.
- `server/src/services/native-runtime/provider-pack-archive.ts` and
`provider-pack-upload.ts`: forward `provider` and `manifest` into v1 and
v2 archive staging and exclude unused `provider-assets/*` during
extraction.
-
`server/src/services/native-runtime/remote-provider-pack-verification.ts`:
scope candidate asset tree digest checks to the active provider when
`provider` is passed and include `requiredAssets` in the verification
seal key so a pack verified for one provider cannot satisfy a seal check
for a different provider.
- `server/src/services/native-runtime/native-session-executor.ts` and
`server/src/services/kimi-connection-probe.ts`: pass the active
`PackProvider` to `prepareRemoteProviderPackOnTarget` and
`verifyRemoteProviderPackIdentity`.
- `packages/plugins/sandbox-providers/daytona/src/manifest.ts` and
`package.json`: raise the default `disk` allocation from `10` to `20`
GiB and bump the plugin version from `0.1.10` to `0.1.11` so
bundled-plugin boot reconciliation refreshes persisted manifests.
- Added unit and end-to-end tests in
`packages/plugins/sandbox-providers/daytona/src/plugin.test.ts`,
`server/src/services/native-runtime/provider-pack-archive.test.ts`,
`server/src/services/native-runtime/remote-provider-pack-verification.test.ts`,
and updated `server/src/__tests__/kimi-connection-probe.test.ts`.

## Verification

- **RED (before production edits):**
- `cd packages/plugins/sandbox-providers/daytona && npx vitest run
--config vitest.config.ts -t "bumps the plugin version|pre-fills
sizing|validates and passes the default 20 GiB"` — 3 failed (`0.1.10 !==
0.1.11`, `10 !== 20`).
- `cd server && npx vitest run
src/services/native-runtime/provider-pack-archive.test.ts -t "omits all
provider-assets|stages only the selected provider"` — 2 failed (unused
`provider-assets` staged on disk).
- `cd server && npx vitest run
src/services/native-runtime/remote-provider-pack-verification.test.ts -t
"verifies only the selected provider"` — 1 failed (`candidate_digest`
rejected Claude when `provider-assets/` was absent).
- **GREEN (after fix):**
  - `cd server && npx tsc --noEmit -p tsconfig.json` — passed.
- `cd server && npx vitest run
src/services/native-runtime/provider-pack-archive.test.ts` — **56/56
passed**, including an end-to-end upload+verify test proving unfiltered
staging writes >= 6 MiB of provider assets, Claude staging omits all 6
MiB (< 256 KiB total) and verifies cleanly, and switching the same
workspace to Cursor rejects the Claude seal (`candidate_digest`) and
re-stages only Cursor (2 MiB, excluding Kimi and Pi).
- `cd server && npx vitest run
src/services/native-runtime/remote-provider-pack-verification.test.ts
src/services/native-runtime/remote-provider-pack.test.ts
src/services/native-runtime/retained-provider-pack-source.test.ts
src/__tests__/kimi-connection-probe.test.ts` — all passed
(`remote-provider-pack-verification.test.ts` 34/34,
`remote-provider-pack.test.ts` 60/60, `kimi-connection-probe.test.ts`
39/39, `retained-provider-pack-source.test.ts` all passed).
- `cd packages/plugins/sandbox-providers/daytona && pnpm typecheck &&
npx vitest run --config vitest.config.ts` — typecheck passed; all 15
offline test files passed (641 passed, 8 live tests skipped;
`archive-stream-window.test.ts` timed out once during parallel CPU
contention and passed in 6.17s when re-run).
- `node scripts/check-test-budget.mjs --files
server/src/services/native-runtime/provider-pack-archive.test.ts
server/src/services/native-runtime/remote-provider-pack-verification.test.ts
server/src/__tests__/kimi-connection-probe.test.ts` — passed (110
nightly suites validated, 3 test files checked).
- `pnpm verify --base 2d06567795
--explain` exited 2 because
`packages/plugins/sandbox-providers/daytona/package.json` is a global CI
input; focused suites and package typechecks ran locally and sharded PR
CI supplies broad coverage.
- **Not run locally:** Live Daytona sandbox provisioning (requires
`DAYTONA_API_KEY`). Managed Cloud snapshot disk sizing is updated
separately in the Cloud repository.

## Risks

- Low risk. Archive schema v1 and v2 remain unchanged, so existing
Docker images and retained OCI release packs work without rebuilding.
- If a reusable workspace previously staged a pack for one provider (for
example Claude) and a later run on the same workspace uses a provider
with native assets (for example Cursor), the provider-scoped
verification seal misses, `verifyStaged` fails with `candidate_digest`,
and `prepareRemoteProviderPackOnTarget` cleanly re-stages with the
needed provider assets.
- Raising the Daytona plugin default `disk` to 20 GiB only affects new
image-backed environments created with the form default; existing saved
environments and snapshot-backed environments keep their existing
configuration.

> 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

- Google Gemini (Antigravity agent) with shell, file editing, and local
test execution tools.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [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-25 15:33:44 -06:00
87fadcb108 feat(annotations): one-tap reactions on artifact comments (#22989)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - People review agent artifacts (plans, documents, routine
descriptions, and case documents) with inline annotation comments
> - Today a person must type a full reply to say "done", "checked",
"looks good", or "I have a question"
> - This slows down quick review feedback, and a question inside a reply
does not automatically bring the assignee back
> - This pull request adds four one-tap reactions to each annotation
comment: Done, Check, Thumbs up, and Question
> - A person's first Question reaction on an open task saves a durable
wake receipt and wakes the task's assignee in a dedicated follow-up run
to reply in that comment's thread (respecting chat ownership and wake
rate limits)
> - The benefit is fast review feedback without extra typing, while
agents can read and set the same reactions through the API

## Linked Issues or Issue Description

Refs #21637 (supersedes on current `master` with renumbered Drizzle
migration, OpenAPI/experimental route contracts, durable wake receipts,
chat ownership and rate-limit hardening, and current UI test suite)
Refs #9336 (agent wake notifications for document annotation threads)
Refs #9674 (agents cannot read inline document review comments)

**What problem does this solve?**
A reviewer cannot quickly acknowledge or question an annotation comment
on an artifact. A short answer requires a typed reply, and nothing tells
the agent that a person has a question about a comment.

**Proposed solution**
Add four fixed reactions per annotation comment: `done`, `check`,
`thumbs_up`, and `question`. One tap adds a reaction and a second tap
removes it. Each person or agent can add each reaction once per comment.
A person's first `question` reaction on an open task commits a durable
wake receipt in the same transaction and wakes the assignee once in a
dedicated follow-up turn, with the comment included in the wake context.

**Alternatives considered**
Free-form emoji reactions. Fixed named reactions keep the API contract
stable for agents and avoid storing arbitrary emoji strings on the
server.

## What Changed

- `packages/db`: Added `document_annotation_comment_reactions` table
(`company_id`, `comment_id`, `reaction`, `actor_type`, `actor_id`,
`created_at`, `removed_at`) with check constraints, cascade delete on
comment deletion, and unique `(comment_id, reaction, actor_type,
actor_id)` index. Generated online-compatible migration
`0510_clear_speedball.sql`, refreshed Drizzle snapshot
`0510_snapshot.json`, and pruned `0505_snapshot.json`.
- `packages/shared`: Added `DOCUMENT_ANNOTATION_COMMENT_REACTIONS`,
`DocumentAnnotationCommentReactionName`,
`DocumentAnnotationCommentReactionActor`,
`DocumentAnnotationCommentReactionSummary`, optional `reactions` on
`DocumentAnnotationComment`, and
`documentAnnotationCommentReactionSchema`.
- `server`: Added `setCommentReaction` in `document-annotations.ts`
using soft-delete (`removed_at`) and upsert revival (`(xmax = 0)` for
`firstAdd`), and attached reaction summaries (`count`, `actors`,
`reactedByMe`) to thread/comment reads.
- `server` routes & contracts: Added `PUT` and `DELETE
.../annotations/:threadId/comments/:commentId/reactions/:reaction` for
issues, routines, and cases, registered them in `openapi.ts`,
`experimental-api-metadata.ts`, and `experimental-api-paths.ts`, and
logged activity (`*.document_annotation_comment_reaction_added` /
`_removed`) only when a row changes.
- `server` durable wake, chat ownership, rate limits &
`packages/adapter-utils`:
- A person's first `question` reaction on an open assigned issue inserts
a recoverable `deferred_issue_execution` receipt in
`agent_wakeup_requests` in the same DB transaction
(`annotation-question-reaction:<id>`), passes `executionWaitRequestId`
to `heartbeat.wakeup` (`reason: "issue_commented"`, `allowRunCoalescing:
false`), resumes via `resumeDeferredExecutionReceipts` if immediate wake
fails, and defers behind busy turns without duplicating receipts.
- Recognized human annotation question reactions
(`isHumanAnnotationQuestionWake`) as an independent wake cause for idle
waiting agent chats while strictly enforcing chat ownership
(`!conversationAgentId || conversationUserId === actorId`) across
service, route, wake preflight, locked admission, and recovery queries.
- Bounded distinct-comment question wakes under `issues ... FOR UPDATE`
to at most 1 pending/in-flight wake per `(companyId, issueId, agentId)`
and at most 3 original question receipts (`idempotency_key LIKE
'annotation-question-reaction:%'`) per `(companyId, issueId, user)` in a
rolling 10-minute window.
- `renderPaperclipWakePrompt` instructs the agent to answer the question
in the annotation thread.
- `ui`: Added four one-tap reaction buttons (`✅`, `✔️`, `👍`, `❓`) under
each non-optimistic annotation comment in `DocumentAnnotationPanel` /
`DocumentAnnotationPopover`, with counts, `aria-pressed`, hover tooltips
naming actors, optimistic updates, client-scoped write serialization
across panel/popover remounts (`WeakMap<QueryClient, Map<string,
TargetReactionState>>`), live-update refetch overlay preservation,
deferred invalidation while writes are pending, and updated Storybook
fixture.
- `docs/api` & `tests/runner-e2e`: Documented the reaction endpoints and
wake bounds in `docs/api/issues.md` and `docs/api/routines.md`, and
refreshed `tests/runner-e2e/source-sdk-public-inputs.json`.

## Verification

- `pnpm --filter @paperclipai/db run check:migrations` and
`migration-compatibility.ts`: `0510_clear_speedball.sql` classified
`online_compatible`.
- `pnpm --filter @paperclipai/db exec vitest run
src/migration-snapshot-drift.test.ts
src/migration-compatibility.test.ts`: passed (117/117).
- `pnpm --filter @paperclipai/adapter-utils exec vitest run
src/server-utils.test.ts -t "question reaction"`: passed.
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/document-annotations-service.test.ts` (20/20, embedded
Postgres — covering durable wake recovery, idle waiting-chat wake,
busy-turn deferral, non-owner chat wake denial, and rolling-window +
pending-backlog wake bounds across full queue admission),
`src/__tests__/document-annotation-routes.test.ts` (20/20),
`src/__tests__/routine-document-annotation-routes.test.ts`,
`src/modules/wake-queue/application/issue-wake-admission.test.ts`
(15/15), and `src/modules/wake-queue/domain/policy.test.ts`: all passed.
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/openapi-routes.test.ts`: passed (59/59).
- `pnpm --filter @paperclipai/ui exec vitest run
src/hooks/useDocumentAnnotationMutations.test.tsx`: passed (9/9,
covering optimistic updates, serialized writes across remounts,
live-update refetch preservation, deferred invalidation across comments,
and rendered `ThreadCard` DOM buttons/toggles).
- Package typechecks (`@paperclipai/shared`, `@paperclipai/db`,
`@paperclipai/adapter-utils`, `@paperclipai/server` all 7 layers,
`@paperclipai/ui` + Storybook catalog): all passed.
- `pnpm check:token-gates`, `node scripts/check-module-boundaries.mjs`,
and `node scripts/check-test-budget.mjs`: all passed.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse
HEAD) --check`: in sync (`inputs: 579, changed: false`).
- Full-stack Playwright verification against a throwaway local server +
embedded PostgreSQL: created a task, `plan` document, and annotation
thread; verified invalid reaction returns `400`; clicked `thumbs_up` and
`question` in the real document viewer; reloaded to prove PostgreSQL
persistence; toggled `thumbs_up` off and reloaded to verify removal
persisted.
- PR CI on `4d892c8067`: 83/83 executed checks passing (including `ci /
verify`, `ci / e2e` + all 16 E2E shards, all General/Serialized server
shards, `Build`, `Typecheck + Release Registry`, `Verify Paperclip
Runner`, `Superagent Security Scan`, and `Greptile Review` 5/5 with 0
unresolved threads).

## Risks

- Low risk. Migration `0510_clear_speedball.sql` only creates a new
table and its indexes (`online_compatible`), so running releases are
unaffected.
- `reactions` is optional on `DocumentAnnotationComment`, preserving
backward compatibility for existing clients.
- Question wakes are bounded by soft-delete revival (`firstAdd`), chat
ownership enforcement, single pending/in-flight wake per `(companyId,
issueId, agentId)`, and at most 3 original question wakes per
`(companyId, issueId, user)` per 10-minute window.

> 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

- Google Gemini (`gemini-3-pro` / Antigravity agentic coding environment
with shell execution, file editing, embedded PostgreSQL, and Playwright
verification), rebasing and extending prior work originally authored
with Claude Opus 5.5 in #21637.

## 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: lucktastic <13757243+lucktastic@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 15:33:38 -06:00
DottaandPaperclip 0f52d90993 fix(github): detect writes outside GitHub App installations and stop advising Refresh access (#22978)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents use managed GitHub App connections through the tool gateway
to open issues, post comments, and perform approved writes on GitHub
repositories.
> - A GitHub App user-to-server token can write only to repositories
inside accounts where the Paperclip GitHub App is installed; even on a
public third-party repository, GitHub rejects writes with `403 Resource
not accessible by integration`.
> - Previously, Paperclip did not check the App's installed accounts
before posting an approval card, mapped every `403 Resource not
accessible by integration` to `github_access_denied`, and told both the
user ("Manage GitHub access") and the agent ("select Refresh access") to
repair access through a flow that cannot reach third-party
organizations.
> - This wastes human approvals on doomed writes and sends operators
into a dead-end permission refresh loop.
> - This pull request adds a pre-check before posting approval cards for
managed GitHub App writes outside installed accounts, distinguishes
`github_repo_outside_app_installations` and
`github_app_installation_suspended` from `github_access_denied` across
server classification, MCP routes, and continuation delivery, and
renders accurate UI guidance without a misleading "Manage GitHub access"
link for external repositories.
> - The benefit is that unreachable external-org writes fail immediately
with actionable alternatives (post directly on GitHub, use a PAT
connection, or have an org admin install the App and refresh access),
suspended installations get explicit unsuspend guidance, and missing
repository grants on installed organizations keep the existing "Manage
GitHub access" and "Refresh access" repair flow.

## Linked Issues or Issue Description

No public issue exists. Refs #19315, #19655, #20141.

**What happened?**
When an agent requested an approval-gated GitHub write targeting a
public repository owned by an external organization where the Paperclip
GitHub App was not installed, Paperclip posted a normal approval card.
After the user approved it, GitHub returned `403 Resource not accessible
by integration`, and both the failed approval card and agent
continuation instructions advised clicking "Manage GitHub access" and
"Refresh access", which cannot grant write access to a third-party
organization.

**Expected behavior**
Paperclip should check managed GitHub App write targets against the
grant's installed accounts before posting an approval card, fail
unreachable external-organization writes cleanly without wasting an
approval, preserve suspended installations separately with unsuspend
guidance, keep incomplete webhook-invalidated snapshots on
`github_access_denied` until refreshed, and present accurate
alternatives in both the UI card and agent continuation instructions.

**Steps to reproduce**
1. Connect GitHub via the managed GitHub App installed on one
organization (for example `acme`), with an approval policy on GitHub
writes.
2. Ask an agent to run `create_issue` or `add_issue_comment` targeting a
repository in an external organization where the App is not installed
(for example `external-org/public-repo`).
3. Previously, Paperclip posted an approval card, executed it upon
approval, received `403 Resource not accessible by integration`, and
showed "GitHub access needed" / "Manage GitHub access" plus "Refresh
access" instructions.

**Paperclip version or commit**
`2d065677959b` (`master`, merged cleanly with `331e1a9fd3`)

**Deployment mode**
Local / Paperclip Cloud managed GitHub App connection

## What Changed

- `server/src/services/tool-access/github-access-discovery.ts`,
`packages/db/src/schema/tool_access.ts`,
`packages/shared/src/types/tool-access.ts`,
`packages/shared/src/validators/tool-access.ts`: Preserved suspended
installation owner logins separately in optional
`suspendedInstallationOwnerLogins` so active `installationOwnerLogins`
stays unchanged while suspended orgs are distinguishable from
uninstalled orgs. Added `github_repo_outside_app_installations` to
`ToolAccessReasonCode` and updated
`tests/runner-e2e/source-sdk-public-inputs.json`.
- `server/src/services/tool-access/github-access-errors.ts`: Added
`github_repo_outside_app_installations`,
`github_app_installation_suspended`, `isGitHubAccessErrorCode`,
`extractGitHubTarget` (`owner`+`repo`, `repository: "owner/repo"`,
`organization`/`org`, `fork_repository` destination-only handling, and
GitHub API URL fallback), `suspendedManagedGitHubOwner`,
`findUnreachableManagedGitHubTarget`,
`githubOutsideAppInstallationsInstructions`,
`githubSuspendedInstallationInstructions`, and
`githubAccessErrorInstructions`. Webhook-invalidated/incomplete
snapshots (`bindingSync` set or `installationIds` ahead of
`installationOwnerLogins` with `repositories` cleared) skip pre-check
blocking and stay on `github_access_denied` on runtime `403` until
access is refreshed.
- `server/src/services/tool-access-policy.ts` and
`server/src/services/tool-gateway.ts`: Reused the already-resolved
remote tool context from `resolveGovernedToolCall` (avoiding redundant
connection/grant lookups for non-GitHub providers), routed unreachable
approval-requiring managed GitHub writes through the canonical policy
denial path with `{ claimIdempotencyKey: false }` (inserting
`idempotencyKey: null` atomically in the single `INSERT` so retries
after installing the App are never falsely replayed), and propagated
`github_repo_outside_app_installations` /
`github_app_installation_suspended` (HTTP 403) without echoing raw
provider text into trusted instructions.
- `server/src/routes/tool-gateway.ts`,
`server/src/services/tool-action-delivery.ts`,
`server/src/services/continuation-cause.ts`,
`server/src/services/agent-task-run-telemetry.ts`: Treated all GitHub
access error codes as MCP `tools/call` `isError: true` results, routed
continuation wakes through `githubAccessErrorInstructions`, and
registered `github_repo_outside_app_installations` and
`github_app_installation_suspended` as person-owned `missing_access`
failure codes.
- `ui/src/components/IssueThreadInteractionCard.tsx` and
`ui/storybook/stories/questions-and-approvals/connection-reviews.stories.tsx`:
Added dedicated alert states for `github_repo_outside_app_installations`
("Repository outside GitHub App access", omitting dead-end "Manage
GitHub access") and `github_app_installation_suspended` ("GitHub App
installation suspended", with unsuspend guidance and "Manage GitHub
access"), using existing design tokens only, while keeping "GitHub
access needed" for `github_access_denied`.
- `doc/connections/GITHUB.md`: Documented pre-check, suspended
installation, incomplete webhook snapshot, and error classification
behavior.
- Added unit, UI component, and embedded-Postgres integration tests in
`server/src/services/tool-access/github-access-errors.test.ts`,
`server/src/__tests__/github-grant-metadata.test.ts`,
`server/src/__tests__/tool-gateway.test.ts`,
`server/src/__tests__/tool-gateway-action-approvals.test.ts`, and
`ui/src/components/IssueThreadInteractionCard.test.tsx`.

## Verification

- `pnpm vitest run
server/src/services/tool-access/github-access-errors.test.ts
server/src/services/tool-access/github-default-owner.test.ts
server/src/__tests__/github-grant-metadata.test.ts
ui/src/components/IssueThreadInteractionCard.test.tsx`: 4 files, 140/140
passed.
- `pnpm vitest run server/src/__tests__/tool-gateway.test.ts -t
"GitHub"`: 13/13 passed (covers pre-check blocking with atomic
`idempotencyKey: null`, installed-org missing-repo
`github_access_denied`, direct + MCP HTTP route `isError: true`,
approved-card runtime 403 URL classification, post-install retry,
suspended installation `github_app_installation_suspended`, and
webhook-invalidated `bindingSync` snapshot pass-through).
- `pnpm vitest run
server/src/__tests__/tool-gateway-action-approvals.test.ts -t "tells the
agent how to recover from"`: 9/9 passed (including
`github_repo_outside_app_installations` and
`github_app_installation_suspended` continuation wakes).
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/db typecheck && pnpm --filter @paperclipai/server typecheck
&& pnpm --filter @paperclipai/ui typecheck`: passed (0 errors across all
7 server layers, shared, db migration safety/compatibility, and UI +
Storybook catalog).
- `pnpm check:token-gates`: all 4 gates clean.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs
6714ad6b68 --check`: passed (`changed:
false`, 578 inputs).
- `node scripts/check-test-budget.mjs --files
server/src/services/tool-access/github-access-errors.test.ts
server/src/__tests__/github-grant-metadata.test.ts
server/src/__tests__/tool-gateway.test.ts
server/src/__tests__/tool-gateway-action-approvals.test.ts
ui/src/components/IssueThreadInteractionCard.test.tsx`: PASS (`113
nightly suites validated, 5 test file(s) checked`).
- PR CI on `6714ad6b68`: 81/81 executed checks passed (`0 failing, 0
pending, 0 cancelled, 6 skipped`), including `ci / verify`, `ci / e2e` +
all 16 E2E shards, all General tests, all 9 Serialized server shards,
all Verify Paperclip Runner lanes, `Build`, `Typecheck + Release
Registry`, `Superagent Security Scan`, `Socket Security`, `Contributor
trust`, `commitperclip`, `Snyk`, and `Greptile Review` (5/5, 0
unresolved threads).
- Not tested against a live GitHub App installation.

## Risks

- Low risk. No SQL database migration is required
(`suspendedInstallationOwnerLogins` is an optional property inside the
existing `connection_grants.provider_tenant` JSONB column, and
`errorCode` is already an open string field).
- Pre-check blocking only activates for approval-requiring non-read
writes on managed GitHub connections that have a complete, populated
grant snapshot (`login` and non-empty `installationOwnerLogins`, without
`bindingSync` invalidation). PAT connections, legacy/empty/incomplete
snapshots, installed organizations, suspended installations, the user's
own personal account, read tools, and upstream `fork_repository` source
repos retain their existing behavior.
- Pre-check denials insert `idempotencyKey: null` atomically so retrying
the same write after an org admin installs the App and access is
refreshed never hits a stale denial replay.

## Model Used

- Google Gemini (Antigravity agent) with tool use and local code/test
execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [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-25 15:33:31 -06:00
Dotta 38e3a71669 fix(connections): use Slack MCP user OAuth flow and surface OAuth errors in setup UI (#22976)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Apps and Connections let operators connect external providers
through remote MCP servers and OAuth.
> - Slack's curated `mcp-oauth` method pins Slack's bot install
endpoints (`oauth/v2/authorize` and `oauth.v2.access`) while sending
user-only scopes (`search:read.public`, `search:read.private`, etc.) in
`scope`, so Slack rejects sign-in with `"Invalid permissions
requested"`.
> - In addition, when OAuth fails or returns an error for a
customer-owned OAuth app like Slack, `ConnectionSetupFlow`'s `KeyStep`
drops `oauthError` completely, hiding the failure banner, and
`OAuthClientFields` hides the method's `guidanceMd` prerequisites.
> - This pull request switches Slack's `mcp-oauth` method to Slack's
documented MCP user OAuth endpoints (`oauth/v2_user/authorize` and
`oauth.v2.user.access`), propagates allowlisted RFC OAuth
`providerError` codes without reflecting untrusted provider prose,
displays OAuth errors and popup fallback links on `KeyStep`, and renders
setup prerequisites (`guidanceMd`) beside customer OAuth fields.
> - The benefit is that customer-owned Slack MCP sign-in succeeds
(including when resuming pre-fix drafts) and any OAuth error or Slack
MCP prerequisite is clearly shown to the user.

## Linked Issues or Issue Description

Fixes: #13935
Refs #17258
Refs #14037

Builds on #17258 (`fix/slack-mcp-user-oauth-flow`) and adds the missing
customer-OAuth error surface and setup guidance in
`ConnectionSetupFlow`.

## What Changed

- Updated `packages/shared/src/app-definitions/slack.json` and
`scripts/ingest-app-definitions.mjs` so Slack's `mcp-oauth` method uses
`https://slack.com/oauth/v2_user/authorize` and
`https://slack.com/api/oauth.v2.user.access`, and added Slack MCP
prerequisites (`User Token Scopes`, callback URL, and `Model Context
Protocol`) to `guidanceMd`.
- Updated `server/src/routes/tool-access.ts` to propagate allowlisted
RFC `providerError` codes (`normalizeOAuthProviderError`, excluding
`unrecognized`) via `provider_error` on OAuth recovery redirects and
connection-intent postMessages, while continuing to never read or
reflect untrusted `error_description` or `error_uri`.
- Updated `ui/src/features/connections/ConnectionSetupFlow.tsx` and
`ui/src/lib/oauthWindowOutcome.ts` so:
- `KeyStep` renders `oauthError` (not only `connectMutation.error`) and
the `"Open sign-in in a new tab"` fallback link when popups are blocked.
- `oauthCallbackErrorMessage` and `oauthFailureMessage` map allowlisted
`providerError` values (such as `invalid_scope`, `invalid_redirect_uri`,
`invalid_client`) and Paperclip failure codes (including
`slack_mcp_access_disabled`) to actionable Paperclip-authored copy.
- Opener popup polling reads same-origin failure `code` and
`provider_error` details from the returned callback URL.
- `OAuthClientFields` renders `method.guidanceMd` for required
customer-owned OAuth apps whose client secret is optional.
- Updated `tests/runner-e2e/source-sdk-public-inputs.json` for the
changed `@paperclipai/shared` sources.
- Updated Slack OAuth test fixtures in
`server/src/__tests__/tool-access-service.test.ts` and
`server/src/services/tool-access/oauth/client-settings.test.ts`, and
added regressions in `packages/shared/src/app-definitions.test.ts`,
`server/src/__tests__/tool-access-service.test.ts`,
`ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts`, and
`ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx`.

## Verification

- Shared, UI, and OAuth client-settings unit + DOM tests (95/95 passed):
- `pnpm exec vitest run packages/shared/src/app-definitions.test.ts
ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts
ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx
ui/src/features/connections/ConnectionSetupFlow.architecture.test.ts
server/src/services/tool-access/oauth/client-settings.test.ts`
- Embedded-Postgres server OAuth start + legacy-draft upgrade + callback
error redirect + redaction tests:
- `pnpm exec vitest run server/src/__tests__/tool-access-service.test.ts
-t "uses Slack user OAuth endpoints even for legacy drafts|starts OAuth
from|refreshes|personal|slack"` (33 passed)
- `pnpm exec vitest run
server/src/__tests__/generic-mcp-connection.test.ts -t "returns browser
denials|denied and cancelled callbacks|redacts"` (9 passed)
- Typechecks & guardrails:
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/server typecheck && pnpm --filter @paperclipai/ui
typecheck` (all passed)
- `node scripts/check-test-budget.mjs --files
packages/shared/src/app-definitions.test.ts
server/src/__tests__/tool-access-service.test.ts
server/src/services/tool-access/oauth/client-settings.test.ts
ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts
ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx`
(PASS)
- `pnpm verify --base 2d06567795
--explain` (exit 2 due to `scripts/ingest-app-definitions.mjs` being a
global CI input; `tests/runner-e2e/source-sdk-public-inputs.json`
verified in sync; sharded PR CI supplies broad repo coverage).

## Risks

- Low risk. The endpoint change applies only to Slack's `mcp-oauth` tool
method; Slack chat-channel setup and Slack search OAuth retain their
existing bot/user flows.
- Resuming a pre-fix Slack MCP draft automatically re-resolves the
updated `v2_user` endpoints from the catalog definition during
`startOAuth` and overwrites the stored bot URLs.
- Only allowlisted RFC OAuth error codes (`normalizeOAuthProviderError`)
are forwarded in `provider_error`; untrusted provider
`error_description` and `error_uri` values are never read or echoed.

## Model Used

- Claude Opus 4.6 by Anthropic (in Antigravity with tool use, shell
execution, and file editing). Used for root-cause analysis, test-driven
implementation, and local 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
2026-11-25 15:33:26 -06:00
f9ee58c214 feat(ui): filter the Tasks list by when tasks were updated (#22965)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Tasks page lists tasks and provides a Filters panel for status,
assignee, project, and other fields
> - The panel has no time filter, so users cannot limit the list to
tasks updated in a recent time window or date range
> - Users need a quick way to find recent work (such as the last 3 days)
or inspect a custom date range across both desktop and mobile views
> - This pull request supersedes #21822 on current `master` and adds an
"Updated" section to all Tasks filter panels (Any time, Last 24 hours,
Last 3 days, Last 7 days, Last 30 days, and Custom range), keeps the
filter in the URL, aligns "Last updated" display and sort with the
filter timestamp, and adds an optional `updatedBefore` server list bound
> - The benefit is that users can filter tasks by update time window and
share filtered links cleanly across all Tasks views

## Linked Issues or Issue Description

Refs #21822 (rebased onto current `master` with merge conflicts and
post-pruning test updates resolved).

**What existing behavior does this improve?**
The Tasks list filters (`CoordinatorTasks`, Classic `IssuesList`, and
`LegacyIssuesList`) and the company issue list API (`GET
/api/companies/:companyId/issues`). The Filters panel had status,
responsible, project, creator, and label filters, but no time filter.

**Subsystem affected**
UI (Tasks list filters, sorting, and URL sync) and Server (`GET
/api/companies/:companyId/issues`).

**Current behavior**
Users cannot limit the Tasks list to tasks updated within a recent time
window or custom date range. They must scan rows manually to find recent
activity.

**Proposed behavior**
Add an "Updated" section to the Tasks filter panels with options: Any
time (default), Last 24 hours, Last 3 days, Last 7 days, Last 30 days,
and Custom range (start and end local calendar day). Filter on the same
timestamp shown on each row (`lastActivityAt ?? lastExternalCommentAt ??
updatedAt`), count it as 1 active filter, reset it on Clear, persist it
in the page URL (`updated`, `updatedFrom`, `updatedTo`), and send an
optional `updatedBefore` upper bound to the server for custom ranges.

**Reason and benefit**
Users can narrow large task lists to recent work or a specific date
window in one click, including on phones, and share filtered URLs that
open with the same filter applied.

**Breaking changes**
None. The filter defaults to Any time, and `updatedBefore` is an
optional query parameter.

## What Changed

- `server/src/routes/issues.ts`, `server/src/services/issues.ts`,
`docs/api/issues.md`: add the optional `updatedBefore` query parameter
(`issues.updatedAt < updatedBefore`) with `400` validation matching
`updatedSince`, apply both `updatedSince` and `updatedBefore` in
`blockedInboxIssueConditions` so `attention=blocked` enforces the same
bounds, and document both parameters.
- `ui/src/api/issues.ts`: add optional `updatedBefore` to
`IssueListFilters` and `issueListSearchParams`.
- `ui/src/lib/issue-filters.ts`,
`ui/src/hooks/useIssueUpdatedFilterNow.ts`: add `updatedWithin`,
`updatedFrom`, and `updatedTo` to `IssueFilterState`, plus
`issueUpdatedWithinOptions`, `issueUpdatedWithinPatch`,
`issueUpdatedTime`, `issueUpdatedTimeRange`,
`nextIssueUpdatedFilterExpiryMs`, `issueUpdatedServerBefore`,
`readIssueUpdatedParams`, and `writeIssueUpdatedParams`. Reject
impossible calendar dates (such as `2026-02-31`), swap reversed custom
ranges, count Updated as 1 active filter, filter in `applyIssueFilters`
on the row time, and schedule a single deadline timer when a relative
window (`24h`/`3d`/`7d`/`30d`) is active so tasks age out automatically
across task and inbox lists.
- `ui/src/components/IssueUpdatedRangeInputs.tsx`,
`ui/src/components/IssueFilterPanel.tsx`,
`ui/src/components/IssueFiltersPopover.tsx`: add the "Updated" section
and native date inputs (`text-base md:text-xs` to prevent mobile Safari
focus zoom) across refreshed, streamlined, and legacy filter panels.
- `ui/src/components/IssueColumns.tsx`,
`ui/src/components/TaskList.tsx`, `ui/src/lib/issue-sort.ts`,
`DESIGN.md`: align `TaskList` "Last updated" display and sort with
`issueUpdatedTime`, compute each task's sort key once before sorting
(`O(N)` context reads), and update `DESIGN.md` to document the shared
timestamp rule.
- `ui/src/components/IssuesList.tsx`,
`ui/src/components/LegacyIssuesList.tsx`, `ui/src/pages/Issues.tsx`,
`ui/src/pages/CoordinatorTasks.tsx`: sync `updated`, `updatedFrom`, and
`updatedTo` with the page URL, queue multiple URL filter writes in the
same event so Clear resets filters together, pass `updatedBefore` for
custom ranges while preserving `archiveQueryScope` as the final
`issuesQuery.queryKey` segment for `placeholderData`, and forward
`updatedBefore` to `CoordinatorTasks` and `Issues` `searchFilters`.
- `server/src/__tests__/issue-list-updatedsince-filter-routes.test.ts`,
`ui/src/lib/issue-filters.test.ts`, `ui/src/lib/issue-sort.test.ts`,
`ui/src/lib/inbox.test.ts`,
`ui/src/components/IssueFiltersPopover.updated.test.tsx`: add
embedded-Postgres route tests for `updatedBefore` (strict bound,
combined range, `400` validation), unit tests for time windows/custom
ranges/local time zone/invalid dates/URL params/sort key caching, and
component tests across `legacy`, `streamlined`, and `refreshed` panels.

## Verification

- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/issue-list-updatedsince-filter-routes.test.ts`: **1 file,
6/6 tests pass** (embedded Postgres, including `attention=blocked` with
`updatedBefore` and `updatedSince`).
- `pnpm --filter @paperclipai/server typecheck`: **pass** (0 errors
across all server layers).
- `pnpm --filter @paperclipai/ui exec vitest run
src/lib/issue-filters.test.ts src/lib/issue-sort.test.ts
src/lib/inbox.test.ts
src/components/IssueFiltersPopover.updated.test.tsx
src/pages/Issues.test.tsx`: **5 files, 94/94 tests pass** (including
fake-timer relative window expiration and a 500-task bounded
timestamp-read render-cost test).
- `pnpm --filter @paperclipai/ui typecheck`: **pass** (0 errors,
Storybook catalog clean).
- `node scripts/check-token-gates.mjs`: **pass** (all 4 token gates
clean).
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/issue-list-updatedsince-filter-routes.test.ts
ui/src/lib/issue-filters.test.ts ui/src/lib/issue-sort.test.ts
ui/src/lib/inbox.test.ts
ui/src/components/IssueFiltersPopover.updated.test.tsx`: **pass** (110
nightly suites validated, 5 test files checked).
- `pnpm verify --base 2d06567795
--explain`: exited `2` because `DESIGN.md` is a global CI input; focused
server and UI verification ran locally and full PR CI supplies repo-wide
coverage.

## Risks

- Low risk. The Updated filter is off by default (`Any time`), and
`updatedBefore` is optional.
- `IssueFiltersPopover` is shared by Inbox and agent work panels; those
views use `applyIssueFilters`, so the Updated section works consistently
there as well.
- The refreshed `TaskList` "Last updated" column now displays and sorts
by latest activity (`lastActivityAt ?? lastExternalCommentAt ??
updatedAt`), matching the Classic row and the Updated filter.
- Relative windows filter loaded pages in the browser (like other Tasks
filters); because the server sorts by update time descending, recent
tasks load first.

> 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

- Google Gemini (`gemini-3-pro` / Antigravity agentic coding environment
with tool use, shell execution, and embedded Postgres testing), building
on original work from #21822 authored with Anthropic Claude Opus 5.5
(`claude-opus-5-5`).

## 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: lucktastic <13757243+lucktastic@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 15:33:20 -06:00
fa6086facb fix(chat): let agents message each other in a person's chats (#22961)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agent Chat gives each person one standing chat with each agent.
> - Agents work for the same person, so one agent often must tell
another agent something in that person's chats.
> - The shared comment boundary refused every agent message in a chat
unless the chat's own agent wrote it, and `resume`/`reopen` flags turned
chat posts into 409 conflicts.
> - So one agent could not pass a person's decision to another agent in
that person's chat. The person had to relay it by hand.
> - This pull request rebases #21232 onto current `master` and lets an
agent post in another agent's chat while it acts for the chat's person,
preserving source-task privacy, credential binding, and company
boundaries.
> - The benefit is that agents can talk with each other in the person's
chats, the chat's agent wakes and answers there, and the person sees the
exchange where it happens.

## Linked Issues or Issue Description

**Subsystem affected**

Server (comment-write boundary, comment route, chat directive,
fresh-session handoff), UI (chat transcript adapter), and documentation.

**Problem or motivation**

A person asked one agent to pass a decision to another agent. The first
agent posted the decision in the person's chat with the second agent.
Paperclip refused the post with `"Only this conversation's agent can
post agent messages"`, or returned HTTP 409 when `resume` or `reopen`
was set. The person then had to carry the message by hand.

**Proposed solution**

Rebase and supersede #21232 (whose fork branch is conflicting with
`master` and could not be pushed directly due to fork repository
permissions). Let another agent post in a chat through the ordinary
comment route when it posts from its own running, unrevoked, task-bound
run in the same company, while both the run's responsible person and the
authenticated credential's responsible person match the chat's person,
and the source task passes the company-visible privacy check. Keep every
other guard. Wake the chat's agent through the normal comment wake. Tell
the chat's agent that another agent's message is colleague input, not
the person's authority.

**Alternatives considered**

A destination parameter on `send_chat_message` would add a second
delivery path and new routing authority. The ordinary comment route
already carries attribution, comment permissions, per-run cross-task
limits, and the comment wake, so this change reuses it.

**Roadmap alignment**

This extends the shipped Agent Chat capability in `ROADMAP.md`.
Supersedes #21232 (rebased cleanly onto current `master` with expanded
isolation and handoff tests). Refs #18374, which added the comment
boundary for proactive chat messages. Refs #14143, which asks for
broader group discussions between agents and people; this change does
not add group chats.

## What Changed

- `server/src/services/issues.ts` (+20 net lines; edits remain in the
existing >1,000-line owning `addComment` write boundary rather than
splitting a shared transaction guard): allow a peer agent to post in
another agent's chat only from its own running, unrevoked, task-bound
run in the same company, when both `run.responsibleUserId` and
`actor.onBehalfOfUserId` (when set) match `current.conversationUserId`,
and when the source task passes `canActorReadIssuePrivacy(dbOrTx, {
type: "none" }, source)`. Keep proactive chat delivery and the session
fence restricted to the chat's own agent.
- `server/src/routes/issues.ts` (+0 net lines; edits remain in the
existing >1,000-line owning comment route): ignore `reopen` and `resume`
flags on conversations (`!isConversation(issue)`) because ordinary
comment wakes always reach the chat's agent.
- `server/src/services/agent-conversations.ts`: update
`AGENT_CHAT_DIRECTIVE` to state that another agent's comment is
colleague input (never the person's approval, decision, or instruction
authority) and document how to find and write to another agent's chat
for the same person.
- `server/src/services/native-runtime/native-session-handoff.ts`: label
comments authored by another agent as `other_agent` in fresh-session
history so a fresh session distinguishes them from the chat agent's own
`agent` replies.
- `ui/src/components/task-chat/transcript-adapter.ts` (+5 net lines;
edits remain in the existing >1,000-line owning transcript adapter): add
`sameTurnAgent` so `coalesceSettledTurns` and `attachSettledTurns` match
settled turns to agent bubbles by `agent.id` when both IDs are known,
falling back to display name.
- Tests:
- `server/src/__tests__/agent-chat-peer-messages.test.ts`: real
embedded-Postgres + Express route/service suite covering task-search
chat discovery, comment delivery + wake admission with `resume: true`,
run/agent/status/cancellation/proactive/credential checks, restricted
source tasks (private task, private project, private ancestor, unscoped
run), session fence + both `canReceiveCommentsFromAgents` and
`canCommentOnOtherTasks` permissions, cross-company isolation +
credential `onBehalfOfUserId` mismatch through the HTTP route, and
`buildNativeSessionHandoff` `other_agent` labeling.
- `server/src/__tests__/agent-conversations.test.ts`: verifies the new
peer-chat directive text.
- `server/src/__tests__/agent-chat-messages.test.ts`: updates the
expected denial message for an agent acting for a different person.
- `server/src/services/native-runtime/native-session-handoff.test.ts`:
preserves the fast unit suite on `master` and verifies
`renderNativeSessionHandoff` retains `author: "other_agent"` and
`authorAgentId`.
- `ui/src/components/task-chat/transcript-adapter.test.ts`: covers
ID-based turn coalescing and attachment when runs carry no display name.
- Docs and maps: updated `doc/PRODUCT.md`,
`doc/plans/2026-09-10-agent-chat.md`,
`docs/guides/agent-developer/comments-and-communication.md`, and
`maps/agent-access-map/agent-chat.md`.

## Verification

RED before fix on base `2d065677959b585065ff3fec8718156a4cf6f41d`:
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/agent-chat-peer-messages.test.ts`: **3 failed | 2 passed
(5)**:
- `delivers the message to the chat's agent as the sending agent's
message` failed with HTTP `409` (`"Issue is not resumable through
comment follow-up intent"`).
- `requires the sending agent's own running run, acting for the chat's
person` failed with `"Only this conversation's agent can post agent
messages"`.
- `refuses content from a restricted or missing source task` failed with
`"Only this conversation's agent can post agent messages"`.

GREEN after rebase and fix on head
`64ee873ad760ab0b53e2eaa161c5e83e7b1e9ad9`:
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/agent-chat-peer-messages.test.ts`: **7 passed (7)** (real
embedded Postgres + real Express `issueRoutes` + real `issueService` +
real `agentWakeupRequests` + real `buildNativeSessionHandoff`).
- `pnpm --filter @paperclipai/server exec vitest run
--no-file-parallelism src/__tests__/agent-chat-peer-messages.test.ts
src/__tests__/agent-conversations.test.ts`:
`agent-conversations.test.ts` **73 passed (73)**.
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/agent-chat-messages.test.ts
src/services/native-runtime/native-session-handoff.test.ts`: both files
**passed** (`native-session-handoff.test.ts`: **4 passed (4)**;
`agent-chat-messages.test.ts`: all tests passed).
- `pnpm --filter @paperclipai/ui exec vitest run
src/components/task-chat/transcript-adapter.test.ts`: **119 passed
(119)**.
- `pnpm --filter @paperclipai/server typecheck`: **passed**.
- `pnpm --filter @paperclipai/ui typecheck`: **passed**.
- `node scripts/check-maps.mjs`: **passed** (35 areas, 192 capability
IDs; references and contract fields valid).
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/agent-chat-peer-messages.test.ts
server/src/__tests__/agent-chat-messages.test.ts
server/src/__tests__/agent-conversations.test.ts
server/src/services/native-runtime/native-session-handoff.test.ts
ui/src/components/task-chat/transcript-adapter.test.ts`: **PASS** (110
nightly suites validated, 5 test files checked).
- `pnpm verify --base 2d06567795
--explain`: exited `2` (global CI input
`maps/agent-access-map/agent-chat.md` changed; broad verification
delegated to required PR CI).

Not run locally:
- Full repository `pnpm test:run` and Playwright browser E2E suites
(covered by PR CI).
- Live provider-backed two-agent run (the embedded-Postgres integration
test exercises the real HTTP route, comment boundary, privacy guards,
wake admission, and fresh-session handoff up to provider dispatch).

## Risks

- Behavior change: other agents can now post in a person's chat with an
agent, waking that chat's agent. Existing controls remain enforced:
`canCommentOnOtherTasks`, `canReceiveCommentsFromAgents`, per-run
cross-task write limits, run cancellation, credential/run
responsible-user match, source-task privacy, and company boundaries.
- Prompt injection: another agent's text reaches a chat turn. Owner-only
paths still require the person's own message/outbox, fresh-session
history labels peer comments `other_agent`, and the chat directive
states peer comments never carry the person's approval or instruction
authority.
- Delivery & loops: peer chat messages use ordinary best-effort comment
wakes (not the durable human outbox). Budgets, cross-task write limits,
and directive guidance bound back-and-forth chatter.
- No schema, migration, or API contract change.

## Model Used

- Rebase, conflict resolution, additional boundary/handoff tests, and
verification: Google Gemini via Google Antigravity with tool use, shell
execution, and extended reasoning.
- Original implementation and design from #21232: Claude Opus 5.5
(`claude-opus-5-5`, Anthropic, via 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
- [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: marshall <13757243+lucktastic@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 15:33:14 -06:00
Dotta 5e6bfe698d fix(heartbeat): guarantee queued interrupt receipt coalescing on admission (#22984)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - When an agent is busy on a chat or task, a person's follow-up
message parks as a `deferred_issue_execution` wake and can be sent
immediately via Interrupt (`queued-comment-interrupt:<queueId>`)
> - At claim time, `explicitOperatorRunIdentity` requires that
`<queueId>` was atomically coalesced into the replacement run (`status =
'coalesced'`, `runId = run.id`), or it rejects the claim with `403
Queued-message interrupt authority is unavailable`
> - Three admission paths still allowed a replacement wake or run to be
written without coalescing `<queueId>`: `/new` conversation resets
bypassed `readBlocker` but not `readCommentCandidates`,
`admitFreshIssueRun` inserted the primary wake and queued run even when
`readCommentCandidates` returned `[]` under an execution blocker, and
resuming an interrupt behind an active conversation run fell through to
`admitBusy` and inserted a duplicate deferred wake carrying
`queued-comment-interrupt:<queueId>`
> - This pull request aligns execution-blocker checks between admission
and candidate adoption, aborts fresh admission before creating a wake or
run when a required resumed receipt cannot be adopted, and stops
already-deferred interrupt/retry receipts from duplicating behind an
active execution run
> - The benefit is that queued messages sent while an agent is busy
coalesce cleanly with valid operator interrupt authority, while
legitimate execution blockers continue to hold non-reset work safely

## Linked Issues or Issue Description

Refs #14865, #20698

**What happened**

Even after #14857 and #20698 (card-answer interrupts), queued chat
interrupts can still leave their interrupt receipt uncoalesced (`status
= 'deferred_issue_execution'`, `runId = null`) while creating a
replacement wake/run carrying `idempotencyKey =
queued-comment-interrupt:<queueId>`:

1. A verified `/new` chat interrupt passes `readBlocker` (which forwards
`conversationResetCommentId`), but `readCommentCandidates` called
`getExecutionBlocker(tx, companyId, issueId)` without
`conversationResetCommentId`, returned `candidates: []`, and still
inserted a queued run whose claim immediately failed with `403
Queued-message interrupt authority is unavailable`.
2. If any execution blocker (including a concurrent `READ COMMITTED`
lease/recovery hold or multiple pre-boundary `restoreHold` rows) made
`readCommentCandidates` return `[]`, `admitFreshIssueRun` still inserted
both the primary wake request and a doomed queued run without coalescing
`queuedCommentInterruptId`.
3. When `resumeQueuedCommentInterrupt` entered `enqueueWakeup` while
`activeExecutionRun` held the issue on a conversation
(`allowRunCoalescing: false`), it fell through to `admitBusy` and
inserted a second `deferred_issue_execution` wake with `idempotencyKey =
queued-comment-interrupt:<queueId>`; once promoted after the active run
finished, that duplicate run failed claim with `403 Queued-message
interrupt authority is unavailable`.

**Expected behavior**

A queued interrupt run is only created when its interrupt receipt is
atomically coalesced into that run in the same transaction; otherwise
admission defers cleanly without inserting a duplicate wake or doomed
run. Legitimate execution blockers continue to hold non-reset messages.

## What Changed

- `server/src/modules/wake-queue/application/recovery-admission.ts` &
`server/src/services/heartbeat/queue.ts`: expose
`conversationResetCommentId` from `prepareRecovery` and pass it into
`admitFresh`, so `readCommentCandidates` applies the same verified
`/new` reset policy as `readBlocker`.
- `server/src/modules/wake-queue/adapters/postgres.ts`: forward optional
`conversationResetCommentId` to `getExecutionBlocker` in
`readCommentCandidates` (preserving the 3-argument call when absent),
and add `FreshIssueAdmissionRollbackError` handling in
`withIssueAdmission`.
- `server/src/modules/wake-queue/application/fresh-issue-run.ts` &
`server/src/modules/wake-queue/index.ts`: read comment candidates before
inserting the primary wake receipt for non-promoted fresh runs; if a
required resumed receipt (`queuedCommentInterruptId`,
`queuedCommentRequestId`, or `boardRetryReceiptId`) is not adopted,
return `undefined` without creating a wake or run (and roll back the
transaction if `explicitContinuationRunId` already wrote recovery
state).
- `server/src/services/heartbeat/queue.ts`: return `{ kind: "deferred"
}` immediately under `if (activeExecutionRun)` when resuming an
already-deferred `queuedCommentInterruptId`, `queuedCommentRequestId`,
or `taskRetryRequestId`, preventing `admitBusy` from folding it into
another run or inserting a duplicate deferred wake.
- `server/src/services/explicit-native-continuation.ts`: include
`restoreHoldPredicate()` in the conversation-boundary recovery action
query so multiple pre-boundary restore holds are resolved together
rather than leaving a residual hold for `readCommentCandidates`.
- `server/src/__tests__/heartbeat-queued-run-claim-isolation.test.ts` &
`server/src/modules/wake-queue/adapters/postgres.test.ts`: add
embedded-Postgres regression tests covering queued `/new` interrupts
under an active ownership hold, interrupt resumes racing an active chat
run (no duplicate `queued-comment-interrupt:` wakes and clean delivery
once the run ends), `admitFresh` aborting before creating a doomed run
when a blocker hides a required interrupt receipt, and confirming
non-reset ordinary chat messages still remain held behind an active
ownership blocker until released.

## Verification

- **RED (before production edits on
`2d065677959b585065ff3fec8718156a4cf6f41d`):**
- `cd server && npx vitest run
src/__tests__/heartbeat-queued-run-claim-isolation.test.ts`: failed on
queued `/new` interrupt (`receipt.status` stayed
`"deferred_issue_execution"` instead of `"coalesced"`) and on
active-chat interrupt race (`duplicateInterruptWakes` contained a newly
inserted duplicate wake instead of `[]`).
- `cd server && npx vitest run
src/modules/wake-queue/adapters/postgres.test.ts -t "checks execution
holds only when the scoped saved receipt exists"`: failed with
`AssertionError: expected { status: "queued", ... } to be undefined`
because `admitFresh` inserted a queued run despite
`readCommentCandidates` returning `[]`.
- **GREEN (after fix):**
- `pnpm --filter @paperclipai/server typecheck`: PASS (0 errors across
all 7 layers).
  - `node scripts/check-module-boundaries.mjs`: PASS.
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/heartbeat-queued-run-claim-isolation.test.ts
server/src/modules/wake-queue/adapters/postgres.test.ts`: PASS (`110
nightly suites validated, 2 test file(s) checked`).
- `cd server && npx vitest run --no-file-parallelism
src/__tests__/heartbeat-queued-run-claim-isolation.test.ts
src/modules/wake-queue/application/recovery-admission.test.ts
src/modules/wake-queue/adapters/postgres.test.ts`: **3/3 files, 148/148
passed**.
- `cd server && npx vitest run src/__tests__/run-identity.test.ts
src/__tests__/heartbeat-responsible-user-invariant.test.ts`: **all
passed**.
- `cd server && npx vitest run --no-file-parallelism
src/__tests__/issue-queued-comments-dispatch-routes.test.ts
src/services/heartbeat/queue.test.ts`: **158/158 test assertions
passed** (`issue-queued-comments-dispatch-routes.test.ts` 40/40 passed;
`queue.test.ts` 118/118 tests passed, with only its `afterAll`
embedded-Postgres shutdown hitting the 30s default hook timeout on a
loaded host).
- `pnpm verify --base 2d06567795
--explain`: selects 1,947/2,301 Vitest files (shared hub `queue.ts`);
focused suites passed locally and PR CI supplies full sharded coverage.

## Risks

- Low risk. Legitimate execution blockers (including active ownership
holds and unresolved reconciliation holds on non-reset messages) are
preserved and explicitly covered by a new regression test.
- Moving `readCommentCandidates` before `saveReceipt` only applies to
non-promoted fresh runs; promoted durable chat wakes keep their existing
promote-before-read order so they cannot be re-adopted as secondary
candidates.
- No database migrations or schema changes.

## Model Used

- Google Gemini (Antigravity agent with tool use and local code/test
execution).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [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-25 15:32:47 -06:00
DottaandPaperclip 1299d1d776 fix(google-workspace): keep approved tools active when only Paperclip's display title changed (#22980)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use Google Workspace through a connection whose catalog rows
store each action's definition, and a catalog refresh holds a changed
definition for review
> - #22630 replaced each launch Google Workspace action's discovered
title with Paperclip's own readable display label (for example, `Gmail:
Read a message`), and #22874 exempted transitions from Paperclip's
shipped REST schemas back to Google's MCP servers
> - Catalog publication still hashes `descriptor.title` into
`versionHash`, so refreshing a Google Workspace MCP connection whose
rows were saved before #22630 (with a `null` title or Google's raw
title, including after the 30-day technical-information strip) or after
a local display-title copy edit quarantines every approved Gmail and
Workspace action even though Google changed nothing
> - This pull request recognizes Paperclip-authored display titles for
the six REST-defined Google Workspace services and skips quarantine when
`schemaHash` is unchanged and `versionHash` matches the exact discovered
description, input schema, annotations, and risk level under the
previously saved or raw upstream title
> - The benefit is that catalog refreshes keep approved Gmail and Google
Workspace tools working without false review holds, while upstream
description, schema, annotation, risk-level, and non-Paperclip title
mutations still quarantine for review

## Linked Issues or Issue Description

Refs #22630
Refs #22874

**What happened?**

Refreshing a managed Google Workspace connection (`POST
/api/tool-connections/:id/catalog/refresh` or the automatic 15-minute
`listCatalog` refresh) puts previously approved Gmail and Workspace read
actions into `quarantined` (`pending_review`) when the saved catalog
rows carry a `null` title, Google's raw title (pre-#22630 MCP
connections, including rows stripped by the 30-day Google Technical
Information sweep), or an earlier Paperclip display title. Because
`discovery.ts` substitutes Paperclip's local display title
(`googleWorkspaceCatalogToolTitle`) before `publication.ts` computes
`descriptorHash`, `existing.versionHash !== hash` fires even when
Google's upstream definition did not change at all.

**Expected behavior**

Catalog refresh keeps already-approved Google Workspace actions `active`
(preserving `reviewedAt`, `reviewedByUserId`, Off, and Ask first
settings) when only Paperclip's own display title changed, while still
quarantining any upstream change to `description`, `inputSchema`,
`annotations`, `riskLevel`, or any title change on tools whose title is
provider-controlled. Already-quarantined rows stay held for human
review.

**Steps to reproduce**

1. Connect Google Workspace on Google's MCP servers with Gmail
permissions enabled and approve all read actions.
2. Have saved catalog rows from before #22630 (where `title` is `null`
or Google's raw title such as `"Get Message"` and `versionHash` was
computed with that title), or from an earlier Paperclip display title.
3. Run `refreshCatalog` against Google's MCP server returning the exact
same `description`, `inputSchema`, `annotations`, and `riskLevel`.
4. Observe that all 9 Gmail actions move to `status: "quarantined"`
(`quarantineReason: "pending_review"`) and disappear from agent
sessions.

**Paperclip version or commit**

`2d065677959b585065ff3fec8718156a4cf6f41d`

## What Changed

- `server/src/services/google-workspace-rest-dispatch.ts`: added
`googleWorkspacePaperclipToolTitle(toolName)` returning Paperclip's
static display title only for the six REST-defined Google Workspace
services (`gmail`, `drive`, `docs`, `sheets`, `slides`, `calendar`), and
reused it in `googleWorkspaceCatalogToolTitle`.
- `server/src/services/connectors/paperclip-defined-tools.ts`: exposed
`paperclipAuthoredToolTitle(connection, toolName)` on the narrow
connector contract so `publication.ts` stays connector-agnostic.
- `server/src/services/tool-access/catalog/descriptors.ts` &
`discovery.ts`: carried the raw upstream title as an in-memory-only
`upstreamTitle` field on `McpToolDescriptor` when Google Workspace
discovery replaces `title` with Paperclip's local display title (needed
when the 30-day Google Technical Information sweep has cleared
`existing.title` to `null`).
- `server/src/services/tool-access/catalog/publication.ts`: skipped
quarantine when `existing.schemaHash === schemaHash`,
`paperclipAuthoredToolTitle` equals `descriptor.title` (non-null), and
`descriptorHash` with `existing.title ?? null` or
`descriptor.upstreamTitle ?? null` matches `existing.versionHash`.
Already-quarantined rows remain quarantined, and any change to
`description`, `inputSchema`, `annotations`, `riskLevel`, or
non-Paperclip titles still quarantines.
- `server/src/__tests__/google-workspace-mcp-transport.test.ts`,
`server/src/services/google-workspace-rest-dispatch.test.ts`, and
`server/src/__tests__/connector-tool-policy.test.ts`: added
embedded-Postgres and unit regression tests covering all four
Paperclip-title-only refresh cases, plus security negative tests
confirming description/annotation/schema mutations on Gmail and upstream
title mutations on non-Paperclip connectors still quarantine.

## Verification

- Red before fix (on base `2d065677959b585065ff3fec8718156a4cf6f41d`):
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/google-workspace-mcp-transport.test.ts -t "keeps approved
Gmail read tools active on refresh when only Paperclip|still quarantines
approved Gmail read tools when Google mutates"` -> `4 failed | 1 passed`
(`AssertionError: expected 9 to be +0` quarantined on all 4 title-only
cases).
- Green after fix:
- `pnpm --filter @paperclipai/server exec vitest run
src/services/google-workspace-rest-dispatch.test.ts
src/__tests__/google-workspace-mcp-transport.test.ts
src/__tests__/connector-tool-policy.test.ts` -> **3 files, 77 passed
(77)** (including 34/34 embedded-Postgres Google Workspace MCP transport
tests, 21/21 REST dispatch tests, and 22/22 connector policy tests).
- `pnpm --filter @paperclipai/server exec vitest run
src/google-workspace-rest-tools/boundary.test.ts` -> **1 file, 2 passed
(2)**.
- `pnpm --filter @paperclipai/server typecheck` -> **PASS** (all 7
server typecheck layers).
- `node scripts/check-test-budget.mjs --files
server/src/services/google-workspace-rest-dispatch.test.ts
server/src/__tests__/google-workspace-mcp-transport.test.ts
server/src/__tests__/connector-tool-policy.test.ts` -> **PASS** (`110
nightly suites validated, 3 test file(s) checked`).
- `pnpm verify --base 2d06567795
--explain` selected 1947/2301 test files (>50); focused affected suites
and server typecheck ran locally while sharded PR CI supplies broad
coverage.

## Risks

- Low risk. No schema migration, no API contract change, and no
relaxation of security boundaries.
- Only tools whose displayed title is unconditionally replaced by
Paperclip's static `googleWorkspacePaperclipToolTitle` (the 36 launch
Google Workspace tools) can match `paperclipTitleOnlyChange`, and only
when SHA-256 proves `name`, `description`, `inputSchema`, `annotations`,
and `riskLevel` are all identical to the saved row.
- Already-quarantined rows (including pre-#22874 switch holds) remain
held for human review, matching #22874's safety invariant.

## Model Used

- Google Gemini (Antigravity agentic coding assistant) with tool use,
shell execution, and embedded-Postgres integration testing.

## 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-25 15:32:39 -06:00
Dotta 227c2f794f fix(runner): align request_human_input title and prompt limits with server (#22977)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents ask humans for answers or approvals with the runner's
`request_human_input` tool, which creates an interaction card on the
active task
> - The runner tool schema advertised `title` up to 300 characters and
`prompt` up to 10,000 characters
> - The server's `createIssueThreadInteractionSchema` enforces `title`
at most 240 characters and `summary` / `payload.prompt` at most 1,000
characters across all five interaction kinds
> - An agent that sends a 241–300 character title or a 1,001–10,000
character prompt passes the runner tool schema but fails server
validation, causing wasted retries
> - Open PR #20134 addressed the mismatch on an older base, but
conflicted with `master` and left `native-execution-seeded.json` and
`protocol/manifest.json` stale
> - This pull request defines shared constants inside
`packages/paperclip-runner`, aligns both runner tool catalogs to 240 /
1,000, regenerates every derived catalog and manifest file, and adds
cross-package parity tests for all five interaction kinds
> - The benefit is that agents receive the exact server limits in the
tool schema before calling `request_human_input`, preventing avoidable
validation failures and retries

## Linked Issues or Issue Description

Supersedes #20134 (rebased cleanly onto `master`, resolves catalog
conflicts, regenerates `native-execution-seeded.json` and
`protocol/manifest.json`, and tests all five interaction kinds).
Refs #19405

**What happened?**
An agent called `request_human_input` with a `prompt` longer than 1,000
characters (or a `title` longer than 240 characters). The call passed
the runner's advertised schema (`title` max 300, `prompt` max 10,000),
but failed server validation in `createIssueThreadInteractionSchema`
(`title <= 240`, `summary <= 1000`, `payload.prompt <= 1000`).

**What did you expect to happen?**
The runner's `request_human_input` schema should advertise the exact
character limits that the server accepts (`title` max 240, `prompt` max
1,000), so invalid inputs fail at the tool schema boundary instead of
failing server validation.

**Steps to reproduce**
1. Inspect
`capabilitySemanticToolDescriptor("request_human_input").inputSchema`
and `paperclipSemanticAction("request_human_input").inputSchema`.
2. Build an interaction input at the advertised `title.maxLength` and
`prompt.maxLength` and validate it with
`createIssueThreadInteractionSchema.safeParse(...)`.
3. Before this fix, all five interaction kinds fail server validation
with `too_big` (`maximum: 240` on `title`, `maximum: 1000` on `summary`
and `payload.prompt`).

## What Changed

- Exported `REQUEST_HUMAN_INPUT_TITLE_MAX_LENGTH = 240` and
`REQUEST_HUMAN_INPUT_PROMPT_MAX_LENGTH = 1000` from
`packages/paperclip-runner/src/protocol-actions/request-human-input.ts`
and updated its live descriptor to use them.
- Reused those constants in
`packages/paperclip-runner/src/catalog/semantic-action-catalog.ts` so
both runner catalogs share one source of truth.
- Regenerated
`packages/paperclip-runner/generated/semantic-action-catalog.json`,
`packages/paperclip-runner/generated/capability/semantic-tool-contracts.json`,
`packages/paperclip-runner/protocol/fixtures/evals/native-execution-seeded.json`,
and `packages/paperclip-runner/protocol/manifest.json`.
- Added a runner catalog parity test in
`packages/paperclip-runner/src/catalog/semantic-action-catalog.test.ts`
and a cross-package contract test in
`server/src/__tests__/request-human-input-bounds.test.ts` covering all
five interaction kinds (`ask_user_questions`, `request_confirmation`,
`request_checkbox_confirmation`, `request_item_verdicts`,
`suggest_tasks`) at `max` and `max + 1`.

## Verification

- `pnpm exec vitest run
server/src/__tests__/request-human-input-bounds.test.ts` (failed 5/6
before the fix with `too_big` 240/1000; passed 6/6 after the fix)
- `pnpm --filter @paperclipai/paperclip-runner exec vitest run
src/catalog/semantic-action-catalog.test.ts
src/catalog/protocol-action-contracts.test.ts
src/protocol-actions/core-contracts.test.ts
src/contracts/tool-input-variants.test.ts
src/evals/native-execution.test.ts
src/semantic-tools/semantic-tools.test.ts` (passed)
- `pnpm --filter @paperclipai/paperclip-runner run build` and `pnpm
--filter @paperclipai/paperclip-runner run check:static` (passed;
confirmed generated contracts, seeded catalog digest, and protocol
manifest match)
- `pnpm --filter @paperclipai/server typecheck` and `pnpm --filter
@paperclipai/paperclip-runner run typecheck:typescript` (passed)
- `pnpm exec vitest run
server/src/services/native-runtime/paperclip-runner-tool-authority.test.ts
-t "advertised (choice|text|mixed) question|checkbox interactions"` (4/4
embedded-Postgres tests passed)
- `cargo test --manifest-path
packages/paperclip-runner/runner/Cargo.toml --locked -p
paperclip-runner-core acpx_tool_failure_feedback` and `cargo test
--manifest-path packages/paperclip-runner/runner/Cargo.toml --locked -p
paperclip-runner-core --test acpx_provider_resolutions` (7 unit + 12
integration tests passed, confirming field-level Zod validation feedback
reaches the agent cleanly)
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/request-human-input-bounds.test.ts` (passed)

## Risks

- Low risk. Narrowing the runner schema matches the trimmed character
limits that the server already enforces (`title` <= 240, `prompt` <=
1,000); raw inputs padded with extra leading or trailing whitespace that
exceed those raw lengths are conservatively rejected at the tool schema
boundary.
- Agents that need longer body text in a question card should put it in
`payload.questionSet.description` (up to 100,000 characters) or
`detailsMarkdown` on confirmation/checkbox/item-verdict payloads (up to
20,000 characters).

## Model Used

- Claude Opus 4.6 (`claude-opus-4-6`), Anthropic, with extended
thinking, tool use, and code execution in an agent harness.

## 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
- [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-25 15:32:32 -06:00
Dotta 4ff7fb8dc4 fix(dot): renew 24h event subscriptions, request offline_access, and stop retry loops (#22975)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - OpenAI Dot connects to Paperclip through a dedicated agent OAuth
grant and a signed MCP Events subscription
(`paperclip.dot.mailbox_updated`).
> - Three compounding bugs broke paired Dot connections: (1) event
subscriptions expire after 24 hours with no renewal instructions and an
unclear "required" UI state that pushed operators to re-pair; (2) the
`/mcp/runner` 401 challenge and omitted-scope OAuth defaults requested
only `paperclip:agent` without `offline_access`, so clients received no
refresh token and broke after 15 minutes while the pairing preview still
promised ongoing access; and (3) expired or unpaired Dot runs failed as
generic `adapter_failed`, triggering an endless 15-minute automatic
recovery retry loop.
> - Operators should not have to re-pair a Dot every day, lose OAuth
access after 15 minutes, or watch failed runs loop every 15 minutes on a
missing or expired connection.
> - This pull request adds 24-hour subscription renewal instructions and
expired-subscription status/guidance, includes `offline_access` in the
Dot OAuth 401 challenge and default scopes with an accurate pairing
preview, and classifies missing or expired Dot connections as
non-retryable `configuration_incomplete` with clear operator
instructions.
> - The benefit is durable Dot OAuth and event-subscription renewal
without needless re-pairing, honest pairing previews, and clean
blocked-task guidance instead of infinite retry loops.

## Linked Issues or Issue Description

**What happened?**

1. `paperclip.dot.mailbox_updated` event subscriptions expire after 24
hours (`lifetime` in `server/src/services/public-mcp/events.ts`), but
neither the Dot setup prompt nor pairing `eventInstructions` told Dot to
resubscribe before `refreshBefore`. After 24 hours, new runs failed with
`"Dot must be paired with a verified event subscription and a completed
event test."` and `DotRunnerConnection` displayed `"Event subscription:
required"`, pushing operators to re-pair needlessly.
2. The `/mcp/runner` 401 `WWW-Authenticate` challenge
(`server/src/routes/public-mcp.ts`) and omitted-scope OAuth defaults
(`server/src/services/public-mcp/oauth.ts`) requested only
`paperclip:agent` instead of `paperclip:agent offline_access`. Clients
following the challenge or omitting `scope` received no refresh token
and failed after 15 minutes even though the pairing preview promised
`"Ongoing until revoked"`.
3. When a Dot binding was unpaired or its event subscription expired,
runs failed with generic `adapter_failed` (before `nativeExecutionInput`
was persisted), so automatic recovery (`issue_recovery_action_restored`
/ `issue_continuation_needed`) kept retrying every 15 minutes
indefinitely.

**Expected behavior**

1. Dot receives explicit instructions to renew
`paperclip.dot.mailbox_updated` before `refreshBefore` and on expiry;
when expired, Paperclip names the expiry and shows `"Event subscription:
expired"` with resubscribe guidance (no new pairing needed).
2. Dot OAuth challenges and default scopes include `offline_access` so
paired clients receive rotating refresh tokens; an explicit agent-only
request without `offline_access` displays an accurate 15-minute
non-renewable access preview.
3. Missing or expired Dot connections fail as non-retryable
`configuration_incomplete` with dedicated operator recovery notices,
moving the task to `blocked` and stopping automatic recovery loops.

**Steps to reproduce**

1. Pair an OpenAI Dot agent and omit `scope` (or follow the
`/mcp/runner` 401 `WWW-Authenticate` challenge); inspect the issued
OAuth tokens (no `refresh_token`) and the pairing preview for an
explicit `paperclip:agent` request.
2. Expire the agent's `mcp_event_subscriptions` row past 24 hours or
revoke the binding, then assign a task to the Dot agent.
3. Observe the run failing as `adapter_failed` and automatic recovery
repeatedly queuing continuation runs every 15 minutes.

**Paperclip version or commit**

Base commit `2d065677959b585065ff3fec8718156a4cf6f41d` on `master`.

## What Changed

- **24-hour event subscription renewal & expired UX**:
- Updated `pair()` `eventInstructions` in
`server/src/modules/external-agents/dot.ts` and `buildDotSetupPrompt` in
`ui/src/lib/dot-setup-prompt.ts` to instruct Dot to renew
`paperclip.dot.mailbox_updated` before `refreshBefore` and whenever
Paperclip reports expiry.
- Added `subscriptionExpired` to `bindingForAgent()`, surfaced an
explicit expired-subscription error in `snapshot()` and the Dot
environment check (`server/src/routes/agents.ts`), added
`subscriptionExpired` to the OpenAPI schema
(`server/src/routes/openapi.ts`), and updated
`ui/src/components/DotRunnerConnection.tsx` to display `"Event
subscription: expired"` with resubscribe guidance without re-pairing.
- **OAuth `offline_access` challenge, default scopes, and honest
preview**:
- Updated the `/mcp/runner` 401 `WWW-Authenticate` challenge
(`server/src/routes/public-mcp.ts`) and Dot `defaultScope` for both
`authorize` and `deviceAuthorize`
(`server/src/services/public-mcp/oauth.ts`) to use
`DOT_RUNNER_MCP_SCOPES` (`paperclip:agent offline_access`).
- Updated `describeDotPairing()`
(`server/src/services/public-mcp/oauth.ts`) to show a 15-minute
non-renewable duration when a client explicitly requests
`paperclip:agent` without `offline_access`.
- **Non-retryable recovery on expired or unpaired Dot**:
- Tagged unavailable Dot binding errors in
`server/src/modules/external-agents/dot.ts` with typed
`DotBindingUnavailableReason` (`dot_subscription_expired` /
`dot_pairing_required`) on `McpOAuthError`, mapped them to
`ConfigurationIncompleteFailure` in
`server/src/services/heartbeat/runtime-selection.ts`, and mapped
`paperclip_runner_dot_config_invalid` / `paperclip_runner_dot_disabled`
to `ConfigurationIncompleteFailure` in
`server/src/services/heartbeat/run-completion.ts`.
- Added `dot_subscription_expired` and `dot_pairing_required` notices in
`server/src/services/recovery/stranded-notice.ts`, added
`configuration_incomplete` to `NON_RETRYABLE_CONTINUATION_ERROR_CODES`,
and extended `CONFIGURATION_INCOMPLETE_ERROR_RE` in
`server/src/services/recovery/service.ts` so pre-existing legacy
`adapter_failed` Dot runs also stop looping immediately.
- Note on file size: `runtime-selection.ts`, `run-completion.ts`,
`recovery/service.ts`, `agents.ts`, and `openapi.ts` already exceeded
1,000 lines on `master`; this PR adds only narrow, owning-module changes
(2 to 31 lines each) without introducing new modules.
- **Tests**:
- Extended `server/src/__tests__/dot-runner.test.ts` with
embedded-Postgres tests covering 24h subscription expiry + resubscribe
recovery without re-pairing, OAuth 401 `offline_access` challenge +
omitted-scope refresh token rotation, and full heartbeat +
`assignedWorkSweep` + recovery classification proof that expired and
unpaired Dot runs fail as non-retryable `configuration_incomplete`
without looping.
- Extended `server/src/__tests__/dot-oauth-onboarding.test.ts` for
omitted-scope device authorization (`offlineAccess: true`) and honest
15-minute pairing preview on explicit agent-only scope.
- Added focused UI regression tests in
`ui/src/components/DotRunnerConnection.test.tsx`.

## Verification

- `pnpm exec vitest run server/src/__tests__/dot-runner.test.ts
server/src/__tests__/dot-oauth-onboarding.test.ts
server/src/__tests__/grok-bot-routine.test.ts
server/src/services/public-mcp/discovery.test.ts`: **4 files, 124 passed
(124)** (`dot-runner`: 59, `dot-oauth-onboarding`: 18,
`grok-bot-routine`: 45, `discovery`: 2).
- `pnpm exec vitest run server/src/__tests__/public-mcp.test.ts
server/src/services/antigravity-swarm.test.ts
server/src/__tests__/disposition-repair.test.ts`: **3 files, 90 passed
(90)**.
- `pnpm --filter @paperclipai/ui exec vitest run
src/components/DotRunnerConnection.test.tsx`: **1 file, 2 passed (2)**.
- `pnpm --filter @paperclipai/ui typecheck` && `pnpm --filter
@paperclipai/server typecheck` (all 7 layers): **PASS**.
- `pnpm check:token-gates`: **All 4 gates CLEAN, cliplab character in
sync**.
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/dot-runner.test.ts
server/src/__tests__/dot-oauth-onboarding.test.ts
ui/src/components/DotRunnerConnection.test.tsx`: **PASS (110 nightly
suites validated, 3 test file(s) checked)**.
- `pnpm verify --base 2d06567795
--explain` selected 2,224/2,927 files because shared server modules
(`oauth.ts`, `run-completion.ts`, `recovery/service.ts`) are modified;
focused affected suites and full UI/server typechecks ran locally, and
sharded PR CI covers the full repository suite.

## Risks

- **Low risk.** No database migrations, no changes to existing OAuth
grants, no changes to the 24-hour subscription security lifetime, and no
changes to Personal MCP, Muse, or Grok Bot scopes or admission gates.
- Existing Dot grants created without `offline_access` retain their
original scopes and will need one reconnect after deploy to obtain
refresh tokens.
- Real ChatGPT/OpenAI Dot client renewal beyond 15 minutes and automatic
idle wake reliability remain subject to OpenAI's external client
behavior (unrelated to Paperclip's webhook delivery path).

## Model Used

- **Provider & Model:** Claude (Anthropic) via Antigravity agent runtime
(exact model snapshot ID and context window size are not exposed in this
environment).
- **Capabilities Used:** Codebase inspection, reasoning,
TypeScript/React editing, shell execution, embedded-Postgres and Vitest
verification, and GitHub CLI PR creation.

## 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-25 15:32:27 -06:00
DottaandPaperclip 71d7f86293 fix(runtime): prevent pre-start plugin workspace, checkpoint, and taskless wake failures (#22973)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip Runner agents run tasks inside local, sandbox, and plugin
task environments.
> - Four pre-start failure modes still prevent valid runs from starting
or create doomed failing runs before the agent launches.
> - A Core-storage project running on a workspace-storage plugin
environment can reserve an empty `adapter_managed` workspace on fresh
retries or `project_primary` runs and retry in an hourly loop.
> - A task reassigned to or reviewed by another agent on the same plugin
environment fails with `plugin_workspace_owner_mismatch` because the
retained `adapter_managed` workspace still names the previous agent.
> - A follow-up wake whose prior plugin task stopped without retained
session state fails with `checkpoint_status_unconfirmed`, and sanitized
plugin task worker errors drop safe closed-enum operation and RPC codes.
> - Non-timer taskless wakes (such as manual Run Heartbeat) still
enqueue doomed Runner runs that immediately fail with an
ineligible-work-mode message.
> - This pull request fixes all four pre-start paths while preserving
cross-environment, local-workspace, credential-redaction, and stop-proof
invariants.

## Linked Issues or Issue Description

Refs #19921, #22849, #19878.

**What happened?**

Four pre-start failure modes affected Paperclip Runner tasks before the
agent started:

1. When a task in a Core-storage project (no `storageProviderPluginId`)
ran on a workspace-storage plugin environment with `project_primary` or
a fresh continuation retry, `prepareHeartbeatWorkspace` called
`reserveFreshPluginTaskWorkspace` before checking project storage
compatibility, creating an empty `adapter_managed` workspace and looping
on retries.
2. When a task with a retained `adapter_managed` plugin workspace was
reassigned to another agent or reviewed by another agent on the same
plugin environment, `prepareHeartbeatWorkspace` threw
`WorkspaceValidationFailure` (`plugin_workspace_owner_mismatch`).
3. When `executeEnvironmentTask` sanitized worker failures, it discarded
safe closed-enum operation and RPC error codes, and when a follow-up run
inspected a committed, provably stopped prior plugin task whose provider
session state was gone (`executionStopped: true, sessionStateAvailable:
false`), `recoverPluginRunnerCheckpoint` failed the run with
`checkpoint_status_unconfirmed` instead of retiring the settled root
into a fresh session.
4. When a user or caller triggered a non-timer taskless wake (for
example `POST /api/agents/:id/heartbeat/invoke` or `/wakeup` without a
task) on a `paperclip_runner` agent, `heartbeat.wakeup` still created a
run that immediately failed with `"Paperclip Runner requires a standard,
planning, ask, or skill test task."`

**Expected behavior**

1. Core-storage project sources running on a workspace-storage plugin
environment fail early with `configuration_incomplete`
(`project_storage_environment_incompatible`) across all workspace
strategies and fresh retries without reserving an empty workspace.
2. Reassigned assignees and reviewers on the same plugin environment
provision their own agent-owned `adapter_managed` workspace (rebinding
`issues.executionWorkspaceId` only for the assignee, leaving the
assignee's workspace intact during reviews, and keeping
cross-environment and local-workspace ownership guards fail-closed).
3. Sanitized plugin task errors carry closed-enum `pluginTaskError`
(`operation`, `errorCode`, `rpcErrorCode`) into `resultJson` without
leaking worker text or credentials, and a committed, provably stopped
prior plugin task with `executionStopped: true` and
`sessionStateAvailable: false` retires cleanly into `continuity-breaks`
so the new run starts fresh.
4. Non-timer taskless wakes for `paperclip_runner` agents are skipped
cleanly with a `heartbeat.task_required` receipt and `reason:
"task_required"` wakeup response instead of creating a failing run, and
`resolveNativeRuntimeMode` distinguishes missing-task
(`paperclip_runner_task_required`) from wrong work mode
(`paperclip_runner_issue_ineligible`).

**Steps to reproduce**

1. Run `prepareHeartbeatWorkspace` with a Core-storage project workspace
on an active workspace-storage plugin environment during a fresh retry
or `project_primary` run.
2. Run `prepareHeartbeatWorkspace` as Agent A on a plugin environment,
then reassign or review the task as Agent B on the same plugin
environment.
3. Trigger a follow-up replacement run when the prior committed plugin
task is stopped (`executionStopped: true`) with `sessionStateAvailable:
false`, or throw a `JsonRpcCallError` timeout from a plugin task worker.
4. Call `heartbeat.wakeup` with `source: "on_demand"` and no task scope
on a `paperclip_runner` agent.

**Paperclip version or commit**

Reproduced on `origin/master` at
`2d065677959b585065ff3fec8718156a4cf6f41d`.

**Deployment mode**

Self-hosted / Cloud server. Verified locally on macOS arm64 with
embedded PostgreSQL.

## What Changed

- `server/src/services/heartbeat/workspace-preparation.ts`:
- Check `projectStorageForEnvironment` for Core-storage project sources
on workspace-storage plugin environments immediately after
`preparePluginWorkspace` and before `reserveFreshPluginTaskWorkspace`,
covering `fresh` retries and `project_primary` as well as
`git_worktree`.
- Detach a foreign agent's `adapter_managed` plugin workspace when a
different `paperclip_runner` agent runs on the same plugin environment
(not during native restart recovery) so the new agent provisions its own
agent-owned workspace cleanly; rebind `issues.executionWorkspaceId` and
idle the previous workspace only when `wasIssueAssignee` is true, and
leave the assignee's workspace untouched during reviews.
- `server/src/services/environment-task-runtime.ts` and
`server/src/services/heartbeat/run-completion.ts`:
- Attach closed-enum `pluginTaskError` (`operation`, optional
`errorCode`, optional `rpcErrorCode`) on sanitized worker errors without
forwarding raw worker text or `cause`, and persist it to
`resultJson.pluginTaskError` on failed runs.
- Attach closed-enum `pluginTaskCheckpointStatus` (`executionStopped`,
`sessionStateAvailable`) to `checkpoint_status_unconfirmed` refusals
while preserving the exact error message.
- `server/src/services/native-runtime/native-session-executor.ts`:
- When a replacement/created run hits `checkpoint_status_unconfirmed`
with explicit `executionStopped: true` and `sessionStateAvailable:
false` on a non-quarantined settled journal, pass
`pluginCheckpointUnavailableConfirmed` into
`retireFinishedPerTurnRunnerdOwner` /
`inspectFinishedPerTurnRunnerdOwner`, verify `remoteExecutionHasStopped`
plus all existing committed-owner and controller-stop proofs, and
archive the prior root into `continuity-breaks` for a fresh session.
Keep unconfirmed stops fail-closed.
- `server/src/services/heartbeat-policy.ts`,
`server/src/services/heartbeat/queue.ts`, `server/src/routes/agents.ts`,
and `server/src/services/native-runtime/runtime-mode.ts`:
- Add `supportsUnscopedHeartbeat`, skip non-timer taskless wakes for
`paperclip_runner` agents with a `heartbeat.task_required` skipped
wakeup receipt, return `reason: "task_required"` in
`buildSkippedWakeupResponse`, and separate
`paperclip_runner_task_required` from
`paperclip_runner_issue_ineligible`.
- `doc/project-environment-compatibility.md`:
- Update the Core-storage-on-plugin-environment note to reflect early
refusal across all workspace strategies and fresh retries.
- Tests added across `workspace-preparation.test.ts`,
`environment-task-runtime.test.ts`,
`environment-task-authority.integration.test.ts`,
`run-completion.test.ts`, `native-session-executor.test.ts`,
`heartbeat-stale-queue-invalidation.test.ts`, `runtime-mode.test.ts`,
and `agent-live-run-routes.test.ts`.
- Note on file length: edits touch existing >1,000-line
lifecycle/executor modules (`workspace-preparation.ts`,
`native-session-executor.ts`, `queue.ts`, `run-completion.ts`,
`agents.ts`) with minimal, scoped additions directly at each invariant
boundary to avoid churn.

## Verification

- **RED (on base `2d065677959b585065ff3fec8718156a4cf6f41d` before
production edits):**
- Ran the 8 new focused tests across `workspace-preparation.test.ts`,
`environment-task-runtime.test.ts`, `run-completion.test.ts`,
`native-session-executor.test.ts`,
`heartbeat-stale-queue-invalidation.test.ts`, and
`runtime-mode.test.ts`: **8 failed | 1 control passed**, confirming
every bug reproduced before edits.
- **GREEN (on head `9c860ca51c4e9742a6594e12ae160895aab8dbdf`):**
- `pnpm --filter @paperclipai/server typecheck` (all 7 layers):
**PASS**.
- Unit suites (`environment-task-runtime.test.ts`,
`runtime-mode.test.ts`, `provider-fresh-workspace.test.ts`,
`native-exact-resume-failure.test.ts`): **4/4 files passed** (`100%`).
- `native-session-executor.test.ts` (focused plugin checkpoint +
unconfirmed checkpoint tests) and `agent-live-run-routes.test.ts`
(focused wakeup/invoke/task_required tests): **PASS**.
- Real embedded-Postgres integration suites
(`environment-task-authority.integration.test.ts` 11/11,
`ephemeral-server-data.test.ts` 6/6, `workspace-preparation.test.ts`
18/18 focused plugin/storage/reassignment/fresh-retry tests,
`heartbeat-stale-queue-invalidation.test.ts` + `run-completion.test.ts`
8/8 focused tests): **PASS**.
- `node scripts/check-test-budget.mjs --files <all 8 modified test
files>`: **PASS** (`110 nightly suites validated, 8 test file(s)
checked`).
- Broad repo-wide verification is supplied by sharded GitHub Actions CI.

## Risks

- Low risk. Cross-environment mismatches, local-workspace reuse on
plugin environments, and native restart recovery ownership checks remain
fail-closed (`plugin_workspace_owner_mismatch`).
- Only committed, provably stopped (`remoteExecutionHasStopped` +
controller-stop proof + settled journal) prior plugin tasks with
explicit provider `executionStopped: true, sessionStateAvailable: false`
retire into `continuity-breaks`; unconfirmed stops still fail closed.
- Sanitized plugin task errors only expose closed-enum operation,
errorCode, and RPC code names; raw worker messages and credentials
remain redacted.
- No database migrations or schema changes are required.

## Model Used

- Google Gemini (Antigravity agentic coding assistant) with tool use,
shell execution, and local embedded-PostgreSQL test verification. Exact
deployment model ID and context window are not exposed to the session.

## 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-25 15:32:20 -06:00
DottaandPaperclip cc5136ca02 fix(workspaces): run projectless isolated tasks and chats without a repo (#22972)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Execution workspace isolation controls how each task and
conversation gets a working directory
> - When isolated workspaces are enabled (including with
`enableIsolatedWorkspacesByDefault`), a task or conversation without a
project or repository can resolve to `isolated_workspace` without an
explicit `workspaceStrategy`
> - Wakeup preflight synthesized the default `git_worktree` strategy and
blocked projectless tasks with `workspace_worktree_requires_project`,
while `shouldUseIsolatedTaskDirectory` only allowed `low_trust_review` +
`sandbox` and failed standard local, sandbox, and plugin runs with
`git_worktree_base_not_git_checkout` or
`plugin_workspace_strategy_unsupported`
> - This pull request admits repository-free isolated tasks and
conversations into private isolated task directories across local,
sandbox, and plugin environments while preserving explicit Git worktree
validation, SSH preflight blocking, cross-task archived-workspace
protection, and low-trust sandbox containment
> - The benefit is that projectless tasks, projectless agent chats, and
repository-free project tasks run cleanly with persistent isolated
directories across turns, without weakening Git worktree isolation for
repository-backed projects

## Linked Issues or Issue Description

Fixes: #20962

Refs #20963, #19860, #14766, #13636

Relationship to #20963: #20963 enables private task directories for
standard local repository-free tasks and guards
`hasSelectedExecutionWorkspace`. This pull request builds on that
direction by also:
- Allowing repository-free isolated tasks without an explicit
`workspaceStrategy` to pass wakeup preflight in
`server/src/services/heartbeat/queue.ts` via the canonical
`shouldUseIsolatedTaskDirectory` predicate with resolved trust preset
and environment driver (otherwise projectless tasks and chats with
`mode: "isolated_workspace"` are blocked with
`workspace_worktree_requires_project` before environment selection runs,
while SSH, explicit `git_worktree`, and cross-task/shared archived
bindings remain blocked pre-dispatch).
- Supporting standard `sandbox` (Paperclip Cloud) and `plugin`
environments in `shouldUseIsolatedTaskDirectory` (including multi-turn
ordinary plugin task directory reuse via `isBoundPluginTaskDirectory`),
not only `local` / `null`.
- Scoping `!hasSelectedExecutionWorkspace` strictly to `trustPreset ===
"standard"` so `low_trust_review` sandbox containment remains unchanged.
- Preserving `nativeChatWorkspaceScope` isolation (zero referenced
project roots) in `workspace-preparation.ts` when an external chat also
uses a private task directory.

## What Changed

- `server/src/services/isolated-task-directory.ts`: Extract
`hasExplicitWorkspaceStrategy`, add a `standard`-scoped
`hasSelectedExecutionWorkspace` guard, and allow
`shouldUseIsolatedTaskDirectory` for `standard` trust on `local`,
`sandbox`, `plugin`, and `null` drivers while keeping `low_trust_review`
sandbox containment unchanged and keeping `ssh`, `denied`, selected
standard workspaces, and explicit strategies excluded.
- `server/src/services/provider-fresh-workspace.ts`: Add
`isBoundPluginTaskDirectory` recognizing both fresh plugin attempt
directories and ordinary task-owned plugin directories
(`/workspaces/<issueId>` with matching `runnerTaskWorkspaceOwner`,
`projectWorkspaceId === null`, and no `runnerTaskFreshWorkspace`) so
multi-turn repository-free plugin tasks reuse their bound workspace
without hitting `plugin_workspace_strategy_unsupported`.
- `server/src/services/heartbeat/queue.ts`: Call the canonical
`shouldUseIsolatedTaskDirectory` during wakeup preflight with resolved
`trustPreset` (`resolveCoreTrustPreset`) and effective
`environmentDriver` (honoring `executionWorkspaceSettings.environmentId`
for `low_trust_review`, `executionMode === "kubernetes"`, and
`enableManagedSandboxOnly`, and allowing verified exclusively task-owned
archived/cleanup_failed task directories matching
`readTaskDirectoryRetention` or `issue_terminal` cleanup while blocking
cross-task/shared archived bindings) to resolve
`effectivePreflightStrategy` to `"project_primary"` instead of adding a
bypass flag on `isUnrunnableWorktreeCombo`.
- `server/src/services/heartbeat/environment-selection.ts`: Use
`isBoundPluginTaskDirectory` for bound plugin task directory reuse and
pass `hasSelectedExecutionWorkspace` into
`shouldUseIsolatedTaskDirectory` so existing or tampered standard
workspace bindings still go through binding validation.
- `server/src/services/heartbeat/workspace-preparation.ts`: Force
`project_primary` strategy for host and plugin preparation when
`useIsolatedTaskDirectory` is active (outside `remoteAuthority`), and
keep projectless `nativeChatWorkspaceScope` runs on the external-chat
directory branch so referenced projects are not attached.
- `doc/experimental/issue-worktree-support.md`: Document private
isolated task directory behavior for repository-free isolated tasks and
conversations.
- Tests: Extend `isolated-task-directory.test.ts`,
`provider-fresh-workspace.test.ts`, `workspace-preparation.test.ts`, and
`heartbeat-workspace-source-trust.test.ts` with unit and
embedded-Postgres E2E coverage across local, sandbox, plugin, and SSH
environments (projectless tasks, projectless chats, repo-free projects,
2-turn local/sandbox/plugin workspace reuse, git-backed project
`git_worktree` regression, explicit projectless `git_worktree` block,
SSH pre-dispatch block, low-trust projectless sandbox on SSH-default
agent, cross-task archived workspace blocking, and exclusively
task-owned archived directory reopening).

## Verification

- `pnpm exec vitest run
server/src/services/isolated-task-directory.test.ts
server/src/services/provider-fresh-workspace.test.ts
server/src/__tests__/execution-workspace-policy.test.ts` — 3 files, 101
passed (101).
- `pnpm exec vitest run
server/src/services/heartbeat/workspace-preparation.test.ts -t "prepares
a repository-free local task directory|reuses a bound ordinary
repository-free plugin task directory|names incompatible Core project
storage"` — 3 passed (including 2-turn ordinary plugin task directory
reuse + explicit `git_worktree` rejection).
- `pnpm exec vitest run
server/src/__tests__/heartbeat-workspace-source-trust.test.ts -t "in a
company with no repository|still uses git_worktree"` — 9 passed with
embedded Postgres (projectless tasks, projectless chats, repo-free
projects on local and sandbox, git-backed project `git_worktree`,
explicit projectless `git_worktree` block, SSH pre-dispatch block,
low-trust projectless sandbox on SSH-default agent, cross-task archived
workspace pre-dispatch block, and own archived isolated task directory
reopening).
- `pnpm exec vitest run
server/src/__tests__/heartbeat-workspace-branch-containment.test.ts -t
"blocks projectless isolated git-worktree issues before dispatch"` — 1
passed.
- `pnpm --filter @paperclipai/server typecheck` — passed (0 errors
across all 7 layers).
- `node scripts/check-test-budget.mjs --files
server/src/services/isolated-task-directory.test.ts
server/src/services/provider-fresh-workspace.test.ts
server/src/services/heartbeat/workspace-preparation.test.ts
server/src/__tests__/heartbeat-workspace-source-trust.test.ts` — PASS
(110 nightly suites validated, 4 test files checked).
- `git diff --check` — clean; no secrets, artifacts, or internal IDs.
- Sharded PR CI on `eb2b11ee9b`: **66/66** executed checks `SUCCESS` (0
failing, 0 pending, 7 skipped, 2 non-blocking neutral Paperclip Review),
including `ci / verify`, `ci / e2e` + all 16 E2E shards, all 20 General
server shards + chat + workspaces-b, all 9 Serialized server shards, all
Verify Paperclip Runner lanes, `Build`, `Typecheck + Release Registry`,
`policy`, `Superagent Security Scan`, `Socket Security`, `Contributor
trust`, `commitperclip`, `Snyk`, and `Greptile Review` (5/5).

## Risks

- Repository-free tasks and conversations with `mode:
"isolated_workspace"` and no explicit `workspaceStrategy` now run in
private task directories under
`<instanceRoot>/isolated-workspaces/<companyId>/<issueId>` (or
`/workspaces/<issueId>` on plugin environments / remote empty workspaces
under `remoteAuthority`) instead of failing preflight or Git checkout
validation.
- Explicit `workspaceStrategy` requirements (including `git_worktree`,
`existingBranch`, and `provisionCommand`), SSH pre-dispatch blocking,
cross-task archived workspace blocking, low-trust sandbox confinement,
tampered-binding checks (`hasSelectedExecutionWorkspace`), and
`git_worktree` isolation for git-backed projects remain unchanged.
- No database migrations, schema changes, or API contract changes.

## Model Used

- Claude Opus 4.6 (`claude-opus-4-6`) in Antigravity with tool use,
shell execution, 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
- [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-25 15:32:12 -06:00