Commit Graph
8835 Commits
Author SHA1 Message Date
Tonio 741bed6651 Align credential chips and clarify Restart sign-in (#23600)
## Thinking Path

> - Paperclip lets people share provider credentials with selected
agents.
> - Connect account shows those agents as profile chips.
> - The identity chip and disclosure link have different alignment
needs.
> - Give the chips one height and place the disclosure beside the access
summary.
> - Label the sign-in restart action directly.

## Linked Issues or Issue Description

Related PR #23598.

**What happened?**

The identity chip was shorter than the agent chips, and the Change link
moved when the chips wrapped.

**Expected behavior**

Keep chips at 28 pixels. Align Change and Done with the summary. Show
Restart sign-in for the isolated sign-in flow.

**Steps to reproduce**

Open Antigravity under Other Models in Connect account and expand the
access editor.

## What Changed

Move the disclosure to the summary row and align its baseline. Set a
common chip height. Update the restart link and its tests.

## Verification

All 51 focused credential access and sign-in tests passed.

## Risks

Long summaries can wrap on narrow viewports.

## Model Used

OpenAI GPT-6, via Codex.

## Checklist

- [ ] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [ ] 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
- [ ] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [ ] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [ ] 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
canary/v2026.1203.0-canary.883500
2026-12-03 08:43:39 +00:00
Okan YücelandClaude Opus 5.5 4363be6069 fix(workspaces): resolve issue identifiers on task workspace routes (#20658)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Each task can have a task workspace, and the API lets agents and
board users inspect and change it
> - The routes `GET` and `PUT /api/issues/:id/workspace` and `POST
/api/issues/:id/workspace/repositories` are in their own router
> - The issues router changes an issue identifier (for example `ABC-12`)
to the issue UUID, but that resolver does not apply to this router
> - So these routes send the identifier into a UUID comparison, Postgres
refuses it, and the API returns 500
> - This pull request makes these routes accept an issue identifier, and
return 404 for a value that is not an identifier and not a UUID
> - The benefit is that the workspace routes act like the other issue
routes, and a bad value gives a clear 4xx, not a 500

## Linked Issues or Issue Description

I searched the open and closed issues and pull requests for this
problem. I did not find one. Related issues show the same class of error
on other routes: #20356, #13504, #17332. They do not touch these routes.

**What happened?**

`GET /api/issues/ABC-12/workspace` and `PUT
/api/issues/ABC-12/workspace` return `500 {"error":"Internal server
error"}`. The server log shows `DrizzleQueryError` caused by
`PostgresError: invalid input syntax for type uuid: "ABC-12"`. The same
request with the issue UUID returns 200. Other issue routes, for example
`GET /api/issues/ABC-12` and `GET /api/issues/ABC-12/comments`, accept
the identifier. A value that is not an identifier and not a UUID (for
example `not-a-task`) also returns 500.

**Expected behavior**

The workspace routes accept an issue identifier, as the other issue
routes do. The agent skill reference
(`skills/paperclip/references/issue-workspaces.md`) writes these routes
with `:issueId`, so agents send identifiers. A value that does not
identify an issue returns a 4xx.

**Steps to reproduce**

1. Create an issue. Note its identifier (for example `ABC-12`).
2. Send `GET /api/issues/ABC-12/workspace` as a board user or as an
agent.
3. See `500 Internal server error` and the UUID syntax error in the
server log.
4. Send the same request with the issue UUID. See 200.

**Paperclip version or commit**

Seen on release `2026.1106.0`. The route code is the same on `master` at
`4f33bb357`.

**Deployment mode**

Authenticated, private exposure. Installed from npm. Embedded Postgres.

**Agent adapter(s) involved**

Not adapter-specific (core bug). An agent found it with the Claude Code
adapter.

## What Changed

- `server/src/routes/task-workspaces.ts`: the shared `task()` lookup now
uses `normalizeIssueIdentifier` and `isUuidLike` from
`@paperclipai/shared`. An identifier matches `issues.identifier`. A UUID
matches `issues.id`. Any other value returns `404 Task not found` before
the query.
- The lookup keeps the same read condition (`issueReadSqlCondition`) and
the same access checks. An identifier that the actor cannot read gets
the same 404 as a UUID that the actor cannot read.
- `server/src/__tests__/task-workspace-binding.test.ts`: one new test.
It reads and selects a workspace with the identifier (in lower case for
the read), and checks 404 for `not-a-task` and for an unknown
identifier.
- No documentation change. The skill reference already writes these
routes with `:issueId`.

## Verification

- Red before the fix: `npx vitest run
src/__tests__/task-workspace-binding.test.ts -t "resolves an issue
identifier"` failed with `expected 500 to be 200`.
- Green after the fix: the same command passes.
- The three test files that mount these routes pass:
`task-workspace-binding.test.ts`,
`heartbeat-repository-catalog-recovery.test.ts` and
`workspace-preparation-history.test.ts` (117 tests).
- `pnpm --filter @paperclipai/server typecheck` passes.
- `pnpm verify --base upstream/master` keeps 2,498 test files, because
`server/src/app.ts` imports the route. I stopped the local run after 75
minutes, in the first of its 10 jobs. In that part, four files failed:
`file-resources-git-scan-load`, `git-restore-point-expiration`,
`git-workspace-expiration` and `issue-recovery-assignments`. None of
them imports the changed route or `app.ts`. On the base revision, the
same four files also stall on this machine: a test database connection
stays idle in a transaction, and the cleanup waits for its lock.
- The CI checks on this pull request run the full suite. All checks
pass.
- Manual check on a release `2026.1106.0` instance before the fix:
identifier 500, UUID 200, `not-a-task` 500.

## Risks

- Low risk. The change touches one lookup in one route file.
- A UUID still matches by id, with the same checks. `isUuidLike` accepts
UUID versions 1 to 5. Issue ids come from `gen_random_uuid()` (version
4).
- A value that is not a UUID and not an identifier now returns 404
instead of 500. No client can depend on the old 500.

## Model Used

- Anthropic Claude Opus 5.5 (`claude-opus-5-5`). Capabilities: extended
reasoning, tool use and code execution. The harness does not show the
context window size.

## Checklist

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

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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1203.0-canary.883400 nightly/v2026.1203.0-nightly.0
2026-12-02 23:47:36 -08:00
Tonio 432ca25efa Manage Connect account access with agent profile chips (#23598)
## Thinking Path

> - Paperclip connects provider accounts to agents.
> - The account dialog summarizes agent access.
> - Initials alone make selected agents hard to identify.
> - Agent Overview already shows agent names and avatars together.
> - Reuse those chips and let people edit the selection in place.

## Linked Issues or Issue Description

Related PR #23576.

**What happened?**

The credential summary showed overlapping badges and required opening
Change to edit the selected agents.

**Expected behavior**

Show each selected agent by name. Offer a searchable add control and a
remove control on each editable agent chip.

**Steps to reproduce**

Open Connect account, choose Antigravity under Other Models, and inspect
credential access.

## What Changed

Reuse profile chips and the agent picker. Keep the draft selection in
sync with the expanded access editor.

## Verification

All 36 focused credential selection and provider sign-in tests passed.

## Risks

A large explicit selection wraps across multiple rows. Organization-wide
agent access uses one summary chip.

## Model Used

OpenAI GPT-6, via Codex.

## Checklist

- [ ] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [ ] 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
- [ ] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [ ] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [ ] 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
2026-12-03 07:11:26 +00:00
3b380c6b15 fix(workspaces): name a saved remote workspace the agent's environment cannot use (#23586)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip can keep a task's workspace in remote storage. Only a
Paperclip Runner agent in a sandbox environment, or a supported agent in
an SSH environment, can restore and save that workspace.
> - An agent can move to another environment, for example from a sandbox
to a plugin computer. Its tasks keep their saved remote workspaces.
> - When such a task woke, workspace preparation threw a bare 409: "This
workspace requires a supported remote execution environment." The run
ended `setup_failed`. The task offered Retry, and each Retry failed the
same way. Sentry received each refusal as an unexpected run failure.
> - This is a known configuration state that only an owner can repair,
like the project-storage mismatch from #22398.
> - This pull request refuses that run as `configuration_incomplete`
with a named reason, and it tells the owner what to do.
> - The benefit is an actionable task notice, no Retry loop, and no
Sentry noise for this state.

## Linked Issues or Issue Description

Refs #22398 (the same treatment for a source project's storage that the
environment cannot serve).
Refs #23568 (that change gave this refusal its own run-failure group, so
it became visible as a separate error).

**What happened?**

A task's workspace was saved in remote storage by an agent in a Daytona
sandbox. The agent was later moved to a plugin computer environment. An
automatic wake on the task failed setup with "This workspace requires a
supported remote execution environment." The run ended `setup_failed`.
The task notice said to press Retry. Retry cannot help, because the
agent's environment still cannot use the saved workspace. Sentry
received the refusal as an unexpected run failure.

**Expected behavior**

The refusal names the cause: the saved workspace is in remote storage,
and the agent's environment cannot use it. The run fails
`configuration_incomplete`. The task notice tells the owner to assign
the task to an agent that can use the saved workspace, or to change the
agent's environment. Sentry does not receive this known configuration
state. The saved workspace stays unchanged.

**Steps to reproduce**

1. Save a task workspace in remote storage with a Paperclip Runner agent
in a sandbox environment.
2. Change the agent's environment to a plugin computer (or assign the
task to an agent in another environment).
3. Wake the agent on the task. The run fails `setup_failed` with the
bare 409 message.

**Paperclip version or commit**

Seen on hosted staging. The new regression tests fail on `master` at
fc09515c7e and pass with this change.

## What Changed

- `remote-workspaces.ts`: extract
`supportsRemoteWorkspaceExecution(adapterType, driver)`.
`shouldUseRemoteWorkspaces` uses it. Its own behavior is unchanged.
- `workspace-preparation.ts`: when the task's existing workspace has
remote authority and the selected executor cannot use it, preparation
throws `ConfigurationIncompleteFailure` with reason
`remote_workspace_environment_incompatible`. This happens before
workspace resolution and environment acquisition. The payload records
the workspace, environment, driver, adapter, a stable fingerprint, and
the agent runtime action URL. Controller-only runs keep their existing
path.
- `run-failure-report.ts`: the exact pre-dispatch outcome is skipped,
together with `project_storage_environment_incompatible`. A marker after
provider work started, during execution, under another error code, or
outside the setup report is still reported.
`PAPERCLIP_SENTRY_RUN_FAILURES=all` still reports it.
- `stranded-notice.ts` and `recovery/service.ts`: the task notice and
the recovery next action name the owner action. Before this change, the
unknown reason fell back to the "missing secret" text.
- `doc/workspace-storage.md`: describe the new outcome.

## Verification

- Red before the fix, green after (red captured on fc09515c7e with only
the tests applied):
- `server/src/services/heartbeat/workspace-preparation.test.ts` › "names
a remote-storage workspace that the agent's environment cannot use as an
owner configuration gap". Before: the run failed with the bare 409 "This
workspace requires a supported remote execution environment." After:
`configuration_incomplete` with the named reason and payload. The test
also confirms that no workspace is resolved, no environment is acquired,
the saved remote authority is unchanged, and the task keeps its
workspace binding.
-
`server/src/services/__tests__/run-failure-report-remote-workspace-environment.test.ts`
› "keeps a remote workspace the agent's environment cannot use on the
task before dispatch". Before: Sentry received the run.
-
`server/src/services/recovery/stranded-notice-remote-workspace-environment.test.ts`.
Before: the notice said that a secret was missing.
- Safety cases (pass before and after): 11 marker variants are still
reported (other status, `setup_failed`, executing stage, exit code,
signal, no bootstrap marker, provider work started, other reason, no
setup phase, execute phase, `all` mode). The existing remote-workspaces
integration cases "preserves enrolled workspaces after disabling
enrollment and rejects a legacy writer" and "keeps enrollment
conditional…" pass. The full `workspace-preparation.test.ts` (161 tests)
passes, including the sandbox enrollment paths.
- Commands (local, Node 24.23, embedded Postgres):
- `pnpm exec vitest run
src/services/recovery/stranded-notice-remote-workspace-environment.test.ts
src/services/__tests__/run-failure-report-remote-workspace-environment.test.ts
src/services/__tests__/run-failure-report-project-access.test.ts
src/services/heartbeat/workspace-preparation.test.ts
src/__tests__/run-failure-sentry.test.ts` (server)
- `pnpm exec vitest run
src/services/remote-workspaces.integration.test.ts -t "preserves
enrolled workspaces|keeps enrollment conditional"` (server)
- `PAPERCLIP_TYPECHECK_LOW_MEMORY=1 pnpm --filter @paperclipai/server
typecheck` (passed)
- `pnpm verify` selected a broad plan because a doc changed. Required CI
supplies the broad coverage.

## Risks

- Low risk. The new path runs only where `shouldUseRemoteWorkspaces`
already threw. No run that started before can fail now.
- For those refused runs, only the failure code, the message, the
notice, and the Sentry decision change.
- The saved remote workspace and the task's binding are not changed. The
owner still chooses a compatible agent or environment.

## Model Used

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

## 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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1203.0-canary.883200
2026-12-02 22:51:09 -08:00
917a38efd7 fix(server): give the retired task workspace conflict a stable code (#23582)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Before a run starts, Paperclip reserves the task's remote workspace.
It refuses a workspace that is archived or whose cleanup failed, with
the message "Workspace ownership changed.".
> - When setup fails, the server sends a run-failure report to Sentry.
Since #23568, the report groups a setup conflict by the stable code in
its details.
> - This conflict has no code. Its reports use the fallback grouping and
share a Sentry group with other uncoded setup conflicts.
> - This pull request gives the conflict the code
`remote_workspace_retired`.
> - The benefit is a separate Sentry group for runs that fail on a
retired task workspace.

## Linked Issues or Issue Description

**What happened**
A task's execution workspace was archived. Automatic recovery then
started new runs for the task. Each run failed setup with "Workspace
ownership changed.". These reports went into a shared Sentry group with
unrelated setup conflicts, because the conflict had no code.

**Expected behavior**
The conflict has a stable code. Its run-failure reports get their own
Sentry group.

**Steps to reproduce**
1. Reserve a remote task workspace, then set its status to `archived` or
`cleanup_failed`.
2. Reserve the workspace again for a new run.
3. The reservation rejects with a 409 conflict that has no
`details.code`.

**Paperclip version or commit**
master at 8379dedd9.

Refs #23568 (reads `details.code` for run-failure grouping).

## What Changed

- `remote-workspaces.ts`: the "Workspace ownership changed." conflict
now has `details.code` `remote_workspace_retired`. The message and the
409 status do not change.
- `remote-workspaces.integration.test.ts`: a new test reserves an
`archived` and a `cleanup_failed` workspace and expects the conflict
with the new code.
- `run-failure-sentry.test.ts`: the example of an uncoded conflict now
uses another conflict that still has no code.

## Verification

- `cd server && npx vitest run
src/services/remote-workspaces.integration.test.ts -t "stable conflict
code"`: 2 of 2 pass. Without the change to `remote-workspaces.ts`, both
fail.
- `npx vitest run src/services/remote-workspaces.integration.test.ts
src/__tests__/run-failure-sentry.test.ts
src/services/__tests__/run-failure-diagnostics.test.ts`: 301 of 302
pass. The one failure, "cleans saved reads with read-only folders", also
fails on unchanged master in my sandbox (file mode 256 instead of 292).
It is not related to this change.

## Risks

- Low risk. The message, the status and the control flow do not change.
Only the conflict details get a code.
- Expected change: after deploy, Sentry reports for this conflict move
to a new group.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution
in a 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.1203.0-canary.883100
2026-12-02 22:13:09 -08:00
Michael NguyenandClaude fc09515c7e Emit Cloud chat.started when a chat with an agent starts (#23558)
<!-- claude-projects-attribution: {"github_login":"nguyenm7"} -->

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip Cloud measures activation with a funnel: account created,
org named, agent named, model connected, chat launched, first agent run
succeeded, first task created
> - `model.connected`, `agent.task_run` and `task.created` come from the
server, but "chat launched" comes only from the browser
(`onboarding_step_completed` with `step=launch`)
> - `task.created` skips chats on purpose, so a person who only chats
with their agent has no server-side step after "first agent run"
> - #23403 added a Cloud-only direct PostHog path
(`trackCloudPostHogEvent`) for onboarding events that must not depend on
the browser
> - This pull request uses that path to emit `chat.started` when the
chat owner's first message or first question-card answer commits
> - The benefit is a server-side "chat started" step that counts a real
action by the person, once per chat, whichever way they reached the chat

## Linked Issues or Issue Description

Refs #23403

**What existing behavior does this improve?**
Server-side activation funnels on Paperclip Cloud.

**Current behavior**
The only "chat launched" signal is the browser `launch` step. Browser
events can be lost (wizard skipped or resumed, navigation, ad blockers
on older builds). On the server, a chat creates an issue but
`emitTaskCreatedAfterCommit` returns early for it, so no event records
that the chat started.

**Proposed behavior**
When the chat owner's first turn commits (their first message, or their
first answer to a question card such as the onboarding welcome card),
the server emits the Cloud-only event `chat.started` with `surface`
(`onboarding_chat` | `agent_chat`) and `agent_id`. Creating or preparing
a chat emits nothing, because onboarding prepares the chat before the
person clicks Launch. The Launch click itself is already relayed
server-side as `onboarding_step_completed` (`step=launch`).

**Reason and benefit**
Funnel steps should come from real product actions that the server
records. With `chat.started`, a funnel can count "chat launched" from
the server and see people who chat but never create a task.

**Breaking changes**
None. The event is new and is Cloud-only.

## What Changed

- `server/src/services/product-telemetry.ts`: add `CHAT_STARTED_EVENT`
and `emitChatStartedIfFirstOwnerTurn`. It runs inside the transaction
that wrote the person's turn and locks the chat's issue row. It checks
that the actor is the chat owner (not an agent, run, or system actor),
and that the owner has no other message and no other answered question
card in the chat. Cancelled or skipped cards do not count. Then it emits
`chat.started` through `trackCloudPostHogEvent` after commit.
- Callers: `addComment` (`issues.ts`), `answerQuestions`
(`issue-thread-interactions.ts`), both headless comment paths
(`headless-comment-group-commit.ts` and the serialized insert in
`routes/headless-channels-schemas.ts`), and the headless one-line
resolve (`headless-events-schedules-interactions.ts`).
- `server/src/__tests__/chat-started-telemetry.test.ts`: unit tests for
the first turn, both surfaces, and every case that must not emit.
- `server/src/__tests__/product-telemetry.test.ts`: embedded-Postgres
tests. Chat creation and system or other-person messages emit nothing.
The owner's first message emits once. A first message after a cancelled
card still emits. A rolled-back first message and a task comment emit
nothing.
- `docs/api/onboarding-telemetry.md`: document the server-emitted
`chat.started` event.

## Verification

- `npx vitest run server/src/__tests__/chat-started-telemetry.test.ts`:
10 passed (helper unit tests).
- `pnpm --filter @paperclipai/server typecheck`: passed.
- The cases in `product-telemetry.test.ts` need embedded Postgres, which
could not start in my environment (it runs as root). CI runs them.

## Risks

- Low. The event is fire-and-forget after commit, inside a `try`. It
does nothing on self-hosted installs, when `PAPERCLIP_POSTHOG_DIRECT=0`,
or when the PostHog environment is not set.
- One event per chat: the check runs under the chat's issue row lock,
and a rolled-back write emits nothing. `/new` in an existing chat does
not emit again.
- Two extra indexed reads run on a person's chat message or answer, and
only on chats.

### Open questions for reviewers

1. **Consent.** Like `model.connected` and the #23403 relay, this server
event is not gated by the browser cookie banner. This PR does not add a
consent check. The only switch is the existing
`PAPERCLIP_POSTHOG_DIRECT=0`. If people who decline cookies must be
excluded from server-side product events, that should be one rule for
all Cloud direct events, not a rule in this PR.
2. **New name or existing name.** This PR adds a new name,
`chat.started`, instead of emitting `onboarding_step_completed`
(`step=launch`) from the server. A new name keeps the browser and server
signals separate, so the two funnels can be compared and the existing
insights do not double count. The other choice is to emit the existing
name with a `source: server` property. Please say which one you prefer.

Not in this PR: "Agent named" has no clean server moment (the setup
agent is saved with a default name before the person names it, and
`agent.created` fires at launch), and `agent.task_run` still does not
say whether a run was a chat reply or a task. That needs a new
registered dimension in the telemetry contract, so it is a follow-up.

## Model Used

Claude Code (Anthropic Claude, agentic coding 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)
- [ ] 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

https://claude.ai/code/session_01KmUZthscGtSrd1KaWnwzWm

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
canary/v2026.1203.0-canary.883000
2026-12-02 20:20:25 -08:00
scotttongandScott Tong 8379dedd93 Pin Plugins by default in workspace navigation (#23578)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - People browse available integrations on the Plugins page.
> - A fresh Coordinator sidebar puts that page inside More.
> - People who look in Settings can miss it.
> - This pull request pins Plugins until a person chooses their own
layout.

## Linked Issues or Issue Description

**What existing behavior does this improve?**

Finding the Plugins catalog on a first visit to the Coordinator
workspace.

**Current behavior**

Open a workspace in a fresh browser profile. The sidebar shows Inbox
followed by More. Open More to find Plugins.

**Proposed behavior**

Show Plugins below Inbox on the first visit. Honor saved pins and their
order, including an empty list.

Related discussion about navigation for individual plugin pages: #21807.

## What Changed

- Use the Plugins route as the default when the signed-in user has no
saved pin list in this browser.
- Add a browser regression for unpinning and re-pinning across reloads.
Update the AgentMail browser journey to use the visible Plugins link.
- Document the default and how to change it.

## Verification

- `pnpm exec vitest run ui/src/hooks/usePinnedNavigation.test.tsx`
passed.
- `pnpm exec playwright test -c tests/e2e/playwright.config.ts
tests/e2e/plugins-browse.spec.ts tests/e2e/agentmail.spec.ts` passed all
four Chromium tests against the built app and a disposable database.
- Compared the parent and feature commits in fresh Chromium sessions.
Confirmed the pin control in More and the unpin and reorder controls on
the pinned row.

## Risks

An existing user who has never saved pins in this browser also receives
the new default. A saved empty list keeps the sidebar empty of pins.

## Model Used

OpenAI GPT-6 (Codex), with repository editing and Chromium 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: Scott Tong <scott@scotts-mbp-m5-max.local>
canary/v2026.1203.0-canary.882900
2026-12-02 18:30:20 -08:00
Tonio a93d971eed Refine Connect account sign-in controls and access badges (#23576)
## Thinking Path

> - Paperclip lets people connect provider accounts to agents.
> - The Connect account dialog shows the sign-in controls and credential
access.
> - A pasted callback requires an additional submit action.
> - The desktop dialog has room for the three controls on one row.
> - Back should return to the provider grid in one step.

## Linked Issues or Issue Description

Related PR #23551.

**What happened?**

The submit control occupied a second row and Back collapsed the selected
provider before returning to the grid.

**Expected behavior**

Keep desktop controls inline, stack them on mobile, and return directly
to the grid.

**Steps to reproduce**

Select Antigravity under Other Models. Inspect the sign-in controls,
then press Back.

## What Changed

Adjust the Antigravity and Grok sign-in marks. Show overlapping
credential access badges. Simplify the submit label and the Back action.

## Verification

All 35 focused AdapterLoginChrome and AgentProviderConnection tests
passed.

## Risks

Narrow viewports use a stacked layout. The available callback controls
depend on the environment.

## Model Used

OpenAI GPT-6, via Codex.

## Checklist

- [ ] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [ ] 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
- [ ] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [ ] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [ ] 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
2026-12-03 02:25:24 +00:00
paperclipbugbotandClaude Opus 5.5 49165825a0 fix(native): restart an unclaimed continued-session follow-up instead of reattaching (#23434)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Native runs can execute in remote Daytona sandboxes. After a server
restart, restart recovery decides how each interrupted run continues.
> - Recovery can restart an incomplete bootstrap, or it can reattach to
a live remote runner.
> - A continued-session follow-up gets the previous turn's checkpoint
and provider session (`sessionIdBefore`) at admission, before an
executor claims it.
> - The unclaimed-bootstrap check (#20214) refuses every run that has
`sessionIdBefore`. Thus a real follow-up never matches it. Recovery
falls through to the generic fallback and reattaches to a runner that
never started.
> - This pull request lets the unclaimed-bootstrap check accept such a
follow-up when all of its session evidence is inherited.
> - The benefit is that the run restarts cleanly. It does not fail, and
it does not cause the next follow-up to fail.

## Linked Issues or Issue Description

Refs #20214, #20153, #20642, #20979, #20226, #19373

**What happened?**
A hard restart reached a continued-session follow-up on a new Daytona
sandbox before any executor claimed it (coordinator attempt 0,
controller generation 0). Recovery chose `reattach_remote_runner` from
the inherited provider session ID only. The run failed with
`remote_reattach_root_missing`. The next follow-up selected the failed
run as its source and failed with
`native_controller_recovery_unsupported:metadata_format`.

**Steps to reproduce**
1. Admit a continued-session follow-up on a remote sandbox. Admission
sets `sessionIdBefore` and rebinds the previous turn's checkpoint to the
run.
2. Hard-restart the server before an executor claims the run.
3. Restart recovery claims the run with `reattach_remote_runner`,
`providerAttempt: 0`, `controllerGeneration: 1`.

**Expected behavior**
Recovery restarts the bootstrap (`bootstrap_incomplete`, reason
`remote_execution_never_claimed`), as it does for an unclaimed first
run.

**Environment**
Staging, remote Daytona sandboxes, master that includes all of the
linked fixes.

## What Changed

- `native-restart-recovery.ts`: `unclaimedBootstrap` accepts
`sessionIdBefore` when all of these are true:
- `sessionIdBefore` equals the rebound checkpoint's `providerSessionId`.
- The checkpoint is continued-session-only and inherited-only: no
cursor, turns, active turn, result, terminal state, pending requests or
provider events.
- A settled earlier run of the same native session saved that exact
provider session (`carriesSettledPredecessorSession`).
- All other unclaimed-bootstrap guards stay the same: no execution-start
evidence, no own runner identity, prepared remote workspace, preparation
fencing.
- `continuedSessionOnly` and `pendingInheritedRequests` move above
`unclaimedBootstrap`. Their definitions do not change.
- `native-runner-restart-recovery.integration.test.ts`: one new
`it.each` with five cases. The rebound follow-up restarts. A session
with no settled predecessor, a carried active turn, a projected provider
event, and a `sessionIdBefore` that differs from the checkpoint all stay
held.

## Verification

- Red on master: the new `restarts an unclaimed continued-session
follow-up` case received `reattach_remote_runner`, `providerAttempt: 0`,
`controllerGeneration: 1`. These are the same values as the staging
failure.
- Green with this change: `npx vitest run
src/services/native-runtime/native-runner-restart-recovery.integration.test.ts`
(from `server/`) gives 232 passed and 22 skipped. The skipped tests need
`PAPERCLIP_TEST_RUNNER_CONTAINER`, and they skip on master too.
- Also passed locally: `heartbeat/recovery.test.ts`,
`heartbeat/live-runner-adoption.test.ts`,
`native-restart-recovery-isolation.test.ts`,
`native-stop-accounting.integration.test.ts`,
`native-warm-transition-restart.integration.test.ts`,
`native-scheduled-resume-lock.test.ts`,
`native-controller-identity.test.ts`,
`__tests__/heartbeat-native-restart-suspension.test.ts`,
`__tests__/heartbeat-native-early-hand-off.test.ts`.
- Not run locally:
`native-runner-restart-preparation.integration.test.ts`,
`remote-workspace-migration.test.ts`,
`heartbeat/workspace-preparation.test.ts`, typecheck and build. The
local sandbox could not run `git`, and those fixtures need it. CI covers
them.

## Risks

- Low risk. The change only adds one more shape to an existing restart
path. The shape needs a settled predecessor that saved the same provider
session, and the run must have no evidence of its own work.
- If the evidence is incomplete, recovery holds the run as before. It
does not reattach or restart it.

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

## Model Used

- Anthropic Claude Opus 5.5 (`claude-opus-5-5`), used as an 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
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 02:23:39 +00:00
c852420baf fix(server): group setup conflicts by their detail code in run-failure reports (#23568)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - When an agent run fails, the server sends a run-failure report to
Sentry. The fingerprint of the report sets the Sentry group.
> - Setup failures without a root error code use a fallback fingerprint:
the exception name and the HTTP status.
> - The `conflict()` helper keeps its stable code in `details.code`. The
diagnostics read only `code` and `reasonCode` on the error. They ignore
`details.code`.
> - Thus every coded 409 setup conflict gets the fingerprint
`exception:Error` + `status:409`. Unrelated causes go into one Sentry
group. For example, an unfinished workspace writer and a missing remote
execution environment share one group.
> - This pull request reads a bounded identifier from `details.code`
when the error has no own code.
> - The benefit is one Sentry group for each setup conflict cause. A fix
for one cause no longer shows as a regression of another cause.

## Linked Issues or Issue Description

**What happened**
One Sentry group receives three different setup failures. They are "The
workspace still has an unfinished writer or save operation.", "This
workspace requires a supported remote execution environment." and
"Workspace ownership changed." Each one has a different cause. The first
two have a stable code in `details.code`
(`remote_workspace_writer_pending` and
`remote_workspace_execution_required`). The run-failure diagnostics do
not read that code, so all three get the same fallback fingerprint.

**Expected behavior**
A setup conflict with a stable code gets a fingerprint with that code.
Different causes go into different Sentry groups.

**Steps to reproduce**
1. Make a run fail setup with `conflict(message, { code:
"remote_workspace_writer_pending" })`.
2. Make another run fail setup with `conflict(message, { code:
"remote_workspace_execution_required" })`.
3. Look at the run-failure fingerprints. Both are `[setup_failed,
<adapter>, setup, exception:Error, status:409]`.

**Paperclip version or commit**
master at 53bebb59f.

Refs #23475, #23446, #22103 (fixes for the unfinished-writer cause; this
change lets Sentry show that cause by itself).

## What Changed

- `run-failure-diagnostics.ts`: when an exception has no `code` and no
`reasonCode`, read `details.code`. Accept it only when it is a lowercase
identifier of 2 to 100 characters (`^[a-z][a-z0-9_]{1,99}$`). Do not
read other fields of `details`.
- An own `code` or `reasonCode` on the error still has priority.
- Tests: a diagnostics test for the accepted and rejected detail values,
and a Sentry capture test that sends real `conflict()` errors through
the diagnostics and checks the fingerprints.

## Verification

- `cd server && npx vitest run
src/services/__tests__/run-failure-diagnostics.test.ts
src/__tests__/run-failure-sentry.test.ts`: 184 of 184 pass.
- Without the change to `run-failure-diagnostics.ts`, the two new tests
fail. The other 182 tests pass.
- All 19 server test files that use run-failure diagnostics or reports
pass (921 passed, 35 skipped).

## Risks

- Low risk. The change affects only Sentry run-failure reports. No other
code reads these exception codes.
- Expected behavior change: setup conflicts with a `details.code` move
from the shared fallback group to new Sentry groups, one for each code.
Uncoded conflicts stay in the fallback group.
- The code value also goes into the `root_error_code` tag and the
`run_exception_N` context. The strict pattern keeps free text and
secrets out.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution
in a 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>
2026-12-02 18:13:08 -08:00
scotttong b0f682b66b Measure when users see a reply to their onboarding chat input (#23574) canary/v2026.1203.0-canary.882500 2026-12-02 18:03:08 -08:00
Devin FoleyandPaperclip 2b65b97cae fix(ui): paginate all task-list views (#23564)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Its task lists help people find and manage work across personal and
organization views.
> - Several personal views stop after 100 tasks, and Blocked stops after
200 tasks.
> - Other lists have page reads but lack a consistent way to load more
or retry a failed page.
> - This pull request makes pagination available across every task-list
view.
> - People can reach older tasks, keep filters active, and retry without
losing readable rows.

## Linked Issues or Issue Description

**What happened?**
Task lists have inconsistent pagination. Mine, Recent, and Unread stop
at the first task batch. Blocked stops at 200 tasks. Everything has the
same missing-page behavior before this PR. Some organization layouts and
searches replace paged rows with separate capped queries.

**Expected behavior**
Every task-list view can load its remaining tasks. A failed later page
keeps loaded tasks visible and offers a retry.

**Steps to reproduce**
1. Use a company and account with more tasks than a view's first batch.
2. Open Mine, Recent, Unread, Everything, or Blocked and scroll to the
bottom.
3. Try to reach older tasks. The affected views stop without a next-page
control.
4. Check organization status views, Archived, search, and board layouts
for consistent loading controls.

**Paperclip version or commit**
The affected code is present at base commit
`53bebb59f907571228dfb85a834a38536f934aa6`.

**Deployment mode**
Observed on hosted staging. Verified locally from source on macOS arm64.

GitHub searches found no duplicate open PR or directly matching issue.

## What Changed

- Apply one task pagination control to personal, organization, status,
archive, classic, and sandbox task lists.
- Make Recent, Unread, and Everything page through touched tasks. Remove
the shared 100-task display cutoff.
- Filter unread tasks on the server before paging.
- Keep Mine's coherent initial snapshot. Fetch older task pages through
the existing authorized list API.
- Add older pages to Blocked. Load Needs attention task details in
batches from its existing task index.
- Let the Tasks route supply paged search and board data to the shared
list components, so separate capped queries cannot replace loaded pages.
- Keep loaded rows visible during later-page loading and errors. Keep
the retry control available when the final attention page fails.
- Pause the classic and streamlined lists' automatic server-page reads
after a later-page error. Keep an explicit retry button available to
restart that page.
- Keep one paging and retry control inside each task-list component for
list and board layouts.
- Reuse the same request filters for the first and later Legacy Inbox
pages.
- Preserve the array cache contract for archive rollback, live updates,
and sharing the first page across tabs.
- Update product documentation and cover the additional views with
regression tests.

## Verification

- Revision: `9275d37c06dc14d00b6759ad71fb6402252db84b`, based on
`origin/master` at `53bebb59f907571228dfb85a834a38536f934aa6`.
- Environment: macOS arm64, Node v25.6.1, pnpm 9.15.4.
- From `ui/`, ran `pnpm exec vitest run
src/components/IssuesList.paging.test.tsx
src/pages/TaskListPagination.test.tsx src/pages/Issues.test.tsx
src/hooks/useInboxTouchedIssues.test.tsx src/lib/inbox.test.ts
src/lib/blockedInbox.test.ts src/lib/inboxArchiveCache.test.ts
src/lib/inboxOrderPin.test.ts src/hooks/useSharedPolling.test.ts
src/hooks/useSharedPollingSnapshot.test.tsx
src/hooks/useTaskListCollection.test.tsx`: all 133 tests passed across
11 files.
- Real IssuesList tests cover both UI modes. They verify that provided
board and search pages stay visible, capped column and search queries do
not run, and each layout has one paging and retry control. Only leaf row
and board rendering are stubbed.
- Real Inbox page tests load later Mine and Recent pages in both UI
modes. They also check Unread's server filter, first-page and later-page
filter agreement, and removal of the control after the last page.
- Page tests cover All tasks, Active, Backlog, Done, Archived, Needs
attention, Blocked, and classic Tasks with server search. Supporting UI
services and row rendering are isolated.
- Red-green regressions proved the old 100-task display cutoff and
automatic retries after a failed page. The fixed lists keep readable
rows and require an explicit retry after failure.
- The work-limit test uses 500 full task fixtures across five pages. A
deterministic counter throws above a linear task-ID read budget. Ten
unchanged rerenders per page perform no collection work.
- Tests also cover page overlap, duplicate observer events, last-page
detection, loading and retry, account and company changes, archive
rollback, live invalidation, and the fallback without
IntersectionObserver.
- Ran `pnpm --dir ui typecheck`: passed.
- Ran `node scripts/check-test-budget.mjs --base origin/master`: passed
for all four changed test files.
- Ran `git diff --check origin/master...HEAD`: passed.
- A prior `pnpm verify` attempt selected 2,319 files and started a broad
server run. It was stopped to avoid duplicating broad CI for this UI
change. That interrupted attempt is not a pass.
- Full local build and browser acceptance of the modified pages were not
run. [Greptile passed with 5/5 on this
revision](https://github.com/paperclipai/paperclip/pull/23564#issuecomment-7362362373).
Both inline review threads are resolved. [CI
typecheck](https://github.com/paperclipai/paperclip/actions/runs/47004999629/job/143907916923)
and
[build](https://github.com/paperclipai/paperclip/actions/runs/47004999629/job/143907916990)
passed. [Both required CI checks passed on this
revision](https://github.com/paperclipai/paperclip/actions/runs/47004999629):
`ci / e2e` and `ci / verify`. No CI checks remain pending or failed.
Confirmation that automated design review has cleared the prior hold is
still pending.

## Risks

- Task updates can move rows between offset pages. The merge removes
duplicate task IDs, and live refreshes update loaded pages.
- Search and task filters cover loaded rows in personal views. Use Load
more tasks to include older rows while filters are active.
- Mine keeps the existing snapshot and access behavior. The change adds
no database migration or public API contract.

## Model Used

OpenAI `gpt-6.1-sol` through the Codex harness, with xhigh reasoning
effort 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1203.0-canary.882400
2026-12-02 17:28:12 -08:00
Devin FoleyandPaperclip 2a8a0b8e18 fix(ci): retry inconsistent release admission listings (#23572)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Core release workflows admit a source revision before running full
verification.
> - Admission discovers an active image or npm release for that exact
revision.
> - One inconsistent GitHub run listing currently fails admission before
tests start.
> - This pull request rereads count mismatches within a fixed retry
budget.
> - Complete listings and fresh canonical run identity remain required.

## Linked Issues or Issue Description

**What happened?**

[Cloud readiness run
47005873736](https://github.com/paperclipai/paperclip/actions/runs/47005873736)
failed candidate admission with `Incomplete release workflow listing.`
This happened before source tests ran. The [image
workflow](https://github.com/paperclipai/paperclip/actions/runs/47005873889)
then canceled itself because source verification failed. Image consumers
could not advance to that revision.

**Expected behavior**

Admission should allow a short, bounded recovery window for an
inconsistent workflow count. It must reject persistently incomplete or
untrusted evidence.

**Steps to reproduce**

Return a workflow listing whose `total_count` differs from the number of
returned runs. Then return a complete listing for the same query. The
original script fails on the first response. The new regression test
requires admission to wait for complete evidence and revalidate the
selected run.

**Paperclip version or commit**

The reported run used `b066a3ddd39123972d0e7f5f9935c83d41303297`. This
fix starts from `6e340a3f962c60e2723c780389db878ce7ff74c7`.

**Deployment mode**

Canonical GitHub Actions master-push release workflows.

Related changes: #18869 introduced release admission; #22677 added
conditional Actions reads; #22690 added quota-aware read retries. I
searched open and closed PRs and issues for admission and
workflow-listing failures. I found no duplicate fix.

## What Changed

- Allow up to three admission listing reads when valid, bounded counts
disagree with the returned run count. Wait one second, then two seconds.
- Include safe workflow and count details if the mismatch persists.
- Preserve strict listing validation and the fresh canonical run check.
Publication and deferred-producer readers retain their existing
single-read behavior.
- Cover recovery for both release consumers, exhausted retries,
overcounts, undercounts, and a run attempt changing before admission.

## Verification

- The new admission regressions fail against the original
implementation.
- `node --test scripts/cloud-source-verification.test.mjs
scripts/github-actions-rate-limit.test.mjs
scripts/docker-image-metadata.test.mjs
.github/scripts/tests/cloud-readiness.test.mjs` — 81 tests pass on the
changed revision.
- `node --check scripts/cloud-release-admission.mjs` and `git diff
--check` pass.
- `pnpm verify --explain` exits 2 as designed: the changed script is a
global CI input. Broad typecheck, test, build, Runner, and browser
checks must run in CI. This is not a full local-suite pass.
- Reviewed the diff and scanned added lines for credentials, personal
paths, and private URLs before pushing. No findings.
- Greptile reviewed `525694ddc75e7f4c4d1e6c2e00fbc9fd15deadd5` at 5/5.
No review threads or actionable comments remain. All underlying
typecheck, build, unit, Runner, serialized-server, and 16 browser shard
checks passed in [CI run
47008128119](https://github.com/paperclipai/paperclip/actions/runs/47008128119)
on `525694ddc75e7f4c4d1e6c2e00fbc9fd15deadd5`. The final [`ci / verify`
aggregate](https://github.com/paperclipai/paperclip/actions/runs/47008128119/job/143921126471)
also passed. All checks are settled with no failures. GitHub reports the
branch clean and mergeable against current master.

## Risks

Low risk. Admission can spend up to six extra seconds across its two
consumer queries. Malformed metadata, oversized listings, and exhausted
mismatches still fail closed. No source proof or publication gate is
relaxed. No database or deployment configuration changes are required.

The original GitHub response was not retained, so its exact invalid
field remains unknown. The regression tests inject count mismatches; a
later healthy master run establishes recovery, but does not prove the
cause of the earlier response.

## Model Used

OpenAI `gpt-6.1-sol` through Codex in T3 Code, with xhigh reasoning and
shell/tool access. The runtime does not report the context window size.
No subagents were used.

## 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-12-02 17:26:18 -08:00
Devin FoleyandClaude Opus 5.5 0e9d4abcb3 docs(release): canonicalize stable notes for v2026.1202.0 (#23570)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The release process promotes a soaked beta to stable and publishes
the curated notes as the GitHub Release body.
> - After the publish, the notes must be at
`releases/v<stable-version>.md` on `master`. The website changelog and
the next release notes use that path.
> - Stable `v2026.1202.0` was published on 2026-12-03 from beta
`2026.1120.0-beta.0`. It used the candidate branch
`candidate/release-2026.1202.0`: the beta source, test and test-runner
fixes, and the notes file.
> - The notes resolved from the source tree (`notes_mode=source_tree`).
In this mode the workflow skips the `canonicalize_stable_notes` job, so
it pushed no canonicalize branch.
> - This pull request does by hand what that job does. It renames the
beta notes file on `master` to the stable path. It changes no content.
> - The benefit is that `releases/v2026.1202.0.md` exists on `master`
and is byte-identical to the published GitHub Release body.

## Linked Issues or Issue Description

Refs #23550 (the notes fix before publish)
Refs #22247 (the same manual rename for v2026.1117.0)

**Issue type**

Missing content

**Where is the issue?**

`releases/` on `master`. The stable notes for `v2026.1202.0` are only at
the beta path `releases/beta/v2026.1120.0-beta.0.md`. The canonical path
`releases/v2026.1202.0.md` does not exist on `master`.

**What's wrong?**

The GitHub Release
https://github.com/paperclipai/paperclip/releases/tag/v2026.1202.0 is
published. The website changelog sync reads `releases/v2026.1202.0.md`
on `master`. The changelog page for this release cannot appear until
this rename merges.

**Suggested fix**

Rename the beta notes file to the stable path with no content change.
This is the same step that the workflow job does in `master_beta` mode.

## What Changed

- Rename `releases/beta/v2026.1120.0-beta.0.md` to
`releases/v2026.1202.0.md`. GitHub reports a rename with 0 additions and
0 deletions.
- No line of the file changes. The blob is
`40c62079534dfa2fc90709d783053653b9744ed8`. This is the same blob as
`releases/v2026.1202.0.md` at the release source commit
`1ffe1fecb0d2dab06987d89069fe502842f75d9b` (tag `v2026.1202.0`).
- This pull request does not change the release workflow.

## Verification

- The compare API shows one file: `releases/v2026.1202.0.md`, status
`renamed` from `releases/beta/v2026.1120.0-beta.0.md`, 0 additions, 0
deletions.
- The file on this branch has blob
`40c62079534dfa2fc90709d783053653b9744ed8`. The file at tag
`v2026.1202.0` has the same blob.
- The raw `body` field of the `v2026.1202.0` GitHub Release is the same
as the file. The only difference in a `--jq` dump is the trailing
newline that `--jq` adds. v2026.1117.0 shows the same result.
- After merge,
https://github.com/paperclipai/paperclip/blob/master/releases/v2026.1202.0.md
must return 200, and the old beta path must return 404.

## Risks

- Low risk. One markdown file moves, and no content changes.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell,
GitHub API).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass (documentation only; no
tests apply)
- [ ] I have added or updated tests where applicable (not 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.1203.0-canary.882200
2026-12-02 17:07:26 -08:00
Devin FoleyandPaperclip 6e340a3f96 Verify onboarding models and explain provider failures (#23563)
Verify deployment-configured model preferences with the selected account.
Preserve structured provider failures and show descriptive messages for known
causes through the existing onboarding error display. Keep the existing failure
buttons, account binding, and retry/sign-in behavior.

Validation: UI typecheck, 38 focused tests, four browser journeys, all applicable
CI checks, and Greptile 5/5 with no unresolved review comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
canary/v2026.1203.0-canary.882100
2026-12-02 16:47:58 -08:00
Dotta b066a3ddd3 fix(cloud-trial): mount internal OpenRouter proxy before actorMiddleware (#23571)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Cloud starter-inference OpenCode runs in remote plugin Runners
authenticate to `/api/internal/cloud-inference/v1/*` using an ephemeral
per-run `pctrial_` Bearer token.
> - In `server/src/app.ts`, `/api/internal/cloud-inference` was mounted
after `actorMiddleware`.
> - In authenticated deployments, `actorMiddleware` intercepted every
`Authorization: Bearer pctrial_...` request, tried to verify it as an
agent JWT/API key, and returned HTTP 401 (`Agent token did not verify`)
before the proxy route ever ran.
> - This pull request mounts `/api/internal/cloud-inference` before
`actorMiddleware` (alongside `voiceWebhookRoutes`, which uses the same
pre-`actorMiddleware` pattern) and adds a full `createApp` regression
test in `authenticated` deployment mode.
> - The benefit is that remote Cloud starter-inference OpenCode runs
authenticate cleanly through `/api/internal/cloud-inference/v1/*` and
stream real replies.

## Linked Issues or Issue Description

Refs #23401, #23559

**Summary**
Mount `cloudInferenceInternalProxyRoutes` before `actorMiddleware` in
`server/src/app.ts` so ephemeral `pctrial_` Bearer tokens are not
rejected as invalid agent tokens.

**Steps to Reproduce**
1. Run Paperclip in `authenticated` deployment mode with Cloud starter
inference enabled.
2. Start a starter-inference OpenCode run in a remote plugin Runner
environment.
3. Observe HTTP 401 (`Unauthorized: Agent token did not verify; obtain
fresh credentials and retry`) when OpenCode calls
`/api/internal/cloud-inference/v1/chat/completions`.

**Expected Behavior**
Requests to `/api/internal/cloud-inference/v1/*` reach
`cloudInferenceInternalProxyRoutes`, validate the active per-run
`pctrial_` token, and forward to OpenRouter with the server-held starter
key.

## What Changed

- `server/src/app.ts`: Moved `cloudTrialInferenceController`
initialization and `app.use("/api/internal/cloud-inference",
cloudInferenceInternalProxyRoutes(cloudTrialInferenceController))` above
`app.use(actorMiddleware(...))`, alongside `voiceWebhookRoutes`.
- `server/src/__tests__/cloud-trial-proxy-middleware-order.test.ts`:
Added a full `createApp` regression test (`deploymentMode:
"authenticated"`) verifying that unknown `pctrial_` tokens reach
`cloudInferenceInternalProxyRoutes`
(`proxy_token_not_found_on_instance`) and active `pctrial_` tokens proxy
cleanly to upstream OpenRouter with the server-held key.

## Verification

- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/cloud-trial-proxy-middleware-order.test.ts
src/__tests__/cloud-trial-inference.test.ts` — passed (7/7 tests).
- `pnpm --filter @paperclipai/server typecheck` — passed (0 errors).

## Risks

- Low risk. `/api/internal/cloud-inference` strictly authenticates every
request against active per-run `pctrial_` tokens in memory using
`timingSafeEqual` and rejects all unauthenticated or unknown tokens with
HTTP 401.

## Model Used

- Google Gemini (Antigravity agentic runtime, thinking mode 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
- [ ] 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
2026-12-02 18:45:16 -06:00
Nicky LeachandPaperclip cc2e1d9d43 Honor plugin task driver concurrency defaults on hire (#23535)
## Thinking Path

> - Paperclip schedules work for agents.
> - Each agent has a limit on simultaneous runs.
> - A task driver can provide an execution environment with its own
capacity.
> - Previously the creation form sent the same limit for every driver.
> - A driver can now declare the value Core saves when a new agent has
no explicit limit.

## Linked Issues or Issue Description

**Subsystem affected**

Agent hiring and plugin environment drivers.

**Current behavior**

The create form, API, and import flow supply the global concurrency
default before the task driver can provide one.

**Proposed behavior**

Let each task driver declare an optional per-agent concurrency default.
Apply it once during hire and honor explicit agent limits.

## What Changed

- Refreshed the three SDK source pins for the changed files.
- Added the optional driver field `defaultMaxConcurrentRuns` with
integer bounds from 1 through 50.
- Applied it during hire using the resolved task environment. Saved the
resolved runtime configuration in hire approvals.
- Removed early defaults from the creation form, routes and new-agent
imports. Preserved saved limits on export, including explicit values
equal to the global default. Kept the current limit when importing an
update with an omitted limit.

## Verification

- [Full PR
CI](https://github.com/paperclipai/paperclip/actions/runs/47000023360)
passed on `83cce42b9a`. Server shard 16 passed on retry after a
PostgreSQL connection reset on the first attempt.
- `pnpm -r typecheck` passed. The SDK source pin check passed. `pnpm
verify` selected broad CI coverage because the SDK input registry
changed.
- On rebased commit `83cce42b9a`, all 441 tests in six focused Vitest
suites passed, including the MCP rollback test corrected in #23560. The
SDK source pin check passed.

## Risks

This affects new hires on drivers that opt in. Existing agents retain
their saved configuration. Single-run provider limits still apply. An
older client that explicitly sends the global default will keep that
value.

## Model Used

OpenAI GPT-6 via Codex. Used local source inspection, code editing,
TypeScript and test execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [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>
canary/v2026.1203.0-canary.881900
2026-12-02 16:23:42 -08:00
DottaandPaperclip 53bebb59f9 test: keep connection rollback retry drafts unbound (#23560)
Align the rollback retry test with draft resume. Preserve the catalog rollback and public identity checks.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
canary/v2026.1202.0-canary.881801
2026-12-02 22:56:20 +00:00
Dotta 85b9586dd5 fix(cloud-trial): transfer OpenRouter starter proxy credentials to remote plugin Runners (#23559)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Cloud starter-inference onboarding (`free_inference_1`) runs the
first OpenCode agent inside a remote plugin Runner environment using a
per-run server proxy (`PAPERCLIP_OPENROUTER_PROXY_URL` and
`PAPERCLIP_OPENROUTER_PROXY_TOKEN`) instead of exposing the raw
OpenRouter key.
> - On remote plugin Runner environments, OpenCode runs failed
immediately with OpenRouter HTTP 401 (`No cookie auth credentials
found`) because the proxy URL and token never reached the sandbox.
> - Three boundaries stripped the proxy credentials:
`preparePluginRunnerCredentials` returned early when
`managedAiCredentialIdentity` was absent,
`ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS.opencode` did not allow
the proxy pair, and Rust `OPENCODE_PROVIDER_ENVIRONMENT_KEYS` in
`codex_provider.rs` did not forward those keys.
> - This pull request adds the `[PAPERCLIP_OPENROUTER_PROXY_URL,
PAPERCLIP_OPENROUTER_PROXY_TOKEN]` pair across all three boundaries
while keeping raw starter keys strictly server-side and failing closed
on partial or ambiguous credentials.
> - The benefit is that Cloud starter-inference OpenCode runs
authenticate cleanly through the server proxy inside remote plugin
Runner sandboxes.

## Linked Issues or Issue Description

Refs #23401, #23427

**Summary**
Transfer `PAPERCLIP_OPENROUTER_PROXY_URL` and
`PAPERCLIP_OPENROUTER_PROXY_TOKEN` through the plugin Runner credential
boundary and Rust `runner-core` allowlist for Cloud starter-inference
OpenCode runs.

**Steps to Reproduce**
1. Create a Cloud starter-inference (`free_inference_1`) workspace
running OpenCode in a remote plugin Runner environment.
2. Send a message in the onboarding chat.
3. Observe `APIError` HTTP 401 (`No cookie auth credentials found`) from
OpenRouter because the sandbox OpenCode proxy received neither
`PAPERCLIP_OPENROUTER_PROXY_URL` nor `OPENROUTER_API_KEY`.

**Expected Behavior**
The remote plugin Runner receives `{ PAPERCLIP_OPENROUTER_PROXY_URL,
PAPERCLIP_OPENROUTER_PROXY_TOKEN }` via the `opencode` `provider-env`
credential channel, forwards them to OpenCode, and routes inference
through the server-side starter proxy.

## What Changed

- `packages/plugins/sdk/src/environment-tasks.ts`: Added
`["PAPERCLIP_OPENROUTER_PROXY_URL", "PAPERCLIP_OPENROUTER_PROXY_TOKEN"]`
to `ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS.opencode`.
-
`packages/paperclip-runner/runner/crates/runner-core/src/codex_provider.rs`:
Added `"PAPERCLIP_OPENROUTER_PROXY_URL"` and
`"PAPERCLIP_OPENROUTER_PROXY_TOKEN"` to
`OPENCODE_PROVIDER_ENVIRONMENT_KEYS`.
- `server/src/services/native-runtime/plugin-runner-credentials.ts`:
Allowed `opencode` runs with both `PAPERCLIP_OPENROUTER_PROXY_URL` and
`PAPERCLIP_OPENROUTER_PROXY_TOKEN` to transfer that `provider-env`
credential when `identity` is absent (using `"cloud-trial"` as
`accountIdentity`).
-
`server/src/services/native-runtime/plugin-runner-credentials.test.ts`:
Added regression coverage for transferring the Cloud starter proxy pair
without a managed AI connection identity and failing closed on partial
or ambiguous combinations.
- `tests/runner-e2e/source-sdk-public-inputs.json`: Updated reviewed SDK
public inputs pin for `packages/plugins/sdk/src/environment-tasks.ts`.

## Verification

- `pnpm --filter @paperclipai/plugin-sdk build` — passed.
- `pnpm --filter @paperclipai/plugin-sdk exec vitest run
tests/environment-tasks.test.ts
tests/environment-task-release-resume.test.ts` — passed (104/104 tests).
- `pnpm --filter @paperclipai/server exec vitest run
src/services/native-runtime/plugin-runner-credentials.test.ts
src/__tests__/plugin-runner-credential-names.test.ts` — passed (45/45
tests, verifying SDK allowlist, Runner TS allowlist, and Rust
`codex_provider.rs` allowlist together).

## Risks

- Low risk. Only the ephemeral per-run proxy URL and `pctrial_` token
pair is allowed when both are present and non-empty; partial or mixed
sets still fail closed in `environmentTaskCredentialSchema`, and raw
OpenRouter keys never leave the server process.

## Model Used

- Google Gemini (Antigravity agentic runtime, thinking mode 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
- [ ] 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
2026-12-02 16:53:07 -06:00
DottaandPaperclip 9aaeae40bf test: prune orphaned test-support fixtures and helpers (#23360)
Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com>
2026-12-02 16:40:01 -06:00
DottaandPaperclip d5c22b8424 fix(ui): skip Step 3 early setup draft in free_inference_1 and ignore setup drafts in paused banner (#23555)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - In the `free_inference_1` onboarding flow, `OnboardingWizard` skips
Step 4 ("Connect a model") and hires the first agent directly on starter
inference when the user submits Step 3.
> - However, Step 3's early-setup effect still auto-created a
provisional `General` draft agent (`pauseReason: "setup"`, `adapterType:
"process"`) as soon as Step 3 mounted, even though Step 4 login is never
used in `free_inference_1`.
> - If the user reloaded or navigated to the Dashboard before submitting
Step 3, that orphaned `pauseReason: "setup"` draft prevented onboarding
from re-opening and caused `Dashboard.tsx` to show "All agents in this
organization are paused — nothing will run."
> - This pull request skips Step 3 early-setup draft creation while
`free_inference_1` is active (or while the onboarding variant/status
queries are still pending) and filters out unfinished `pauseReason:
"setup"` drafts and terminated agents in
`Dashboard.derivePausedAgentBanner` and `hasNoAgents`.
> - The benefit is a clean `free_inference_1` onboarding experience with
no orphaned paused drafts and accurate Dashboard empty-state banners.

## Linked Issues or Issue Description

**Subsystem affected**

`ui/` — React + Vite board UI

**Problem or motivation**

When a Cloud workspace is assigned to `free_inference_1`, opening Step 3
of `OnboardingWizard` immediately created an unfinished `General` draft
agent (`pauseReason: "setup"`, `adapterType: "process"`) meant only for
Step 4 provider login. Navigating to `/dashboard` before clicking "Start
chatting" left that orphaned draft in place and triggered the "All
agents in this organization are paused — nothing will run." warning
banner.

**Proposed solution**

- Add `shouldSkipEarlyOnboardingSetupDraft` in
`ui/src/lib/cloud-trial-gate.ts` and gate `OnboardingWizard`'s Step 3
early-setup effect on `!shouldSkipEarlyOnboardingSetupDraft({
isFreeInferenceOnboarding, onboardingVariantPending })`.
- Update `derivePausedAgentBanner` and `hasNoAgents` in
`ui/src/pages/Dashboard.tsx` to ignore unfinished `pauseReason: "setup"`
drafts and `terminated` agents.
- Add unit tests in `ui/src/pages/Dashboard.test.ts` and
`ui/src/components/CloudTrialGate.test.tsx`.

**Alternatives considered**

- Deleting the setup draft on wizard unmount was ruled out because
browser reloads or tab closes do not reliably run unmount cleanup, and
`free_inference_1` never needs a Step 3 setup draft in the first place.

## What Changed

- `ui/src/lib/cloud-trial-gate.ts`: Added
`shouldSkipEarlyOnboardingSetupDraft`.
- `ui/src/components/OnboardingWizard.tsx`: Tracked
`onboardingVariantPending` (`onboardingSessionPending` /
`cloudTrialStatusPending`) and gated the Step 3 early-setup draft
creation effect so `free_inference_1` never creates a provisional
`General` (`pauseReason: "setup"`) draft.
- `ui/src/pages/Dashboard.tsx`: Excluded `pauseReason: "setup"` drafts
and `terminated` agents from `derivePausedAgentBanner` and
`hasNoAgents`.
- `ui/src/pages/Dashboard.test.ts` &
`ui/src/components/CloudTrialGate.test.tsx`: Added unit test coverage.

## Verification

- `pnpm --filter @paperclipai/ui typecheck` (0 errors)
- `pnpm exec vitest run ui/src/pages/Dashboard.test.ts
ui/src/components/CloudTrialGate.test.tsx
ui/src/lib/onboarding-auto-open.test.ts` (24/24 passed)

## Risks

- Low risk: `baseline` onboarding behavior is unchanged once
`onboardingSession` resolves (a cached session query already loaded by
the app shell), and `Dashboard` still shows the all-paused banner
whenever real hired agents are paused.

## Model Used

- Google Gemini (Antigravity agentic coding environment with tool use
and local Vitest + TypeScript 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-12-02 16:30:22 -06:00
Dotta 86927d4933 feat(cloud-trial): enable fast responses by default with starter inference key (#23556)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Fast responses send a brief acknowledgement in the agent's voice
while the full agent run starts.
> - During Cloud starter-inference onboarding (`free_inference_1`),
users start chatting immediately before connecting their own model
provider, so no `company_fast_responses` connection exists yet.
> - Without a default fast-response path, the first chat waits silently
while the Runner starts up and thinks.
> - This pull request enables fast responses by default while Cloud
starter inference is active, routing acknowledgements through the
server-held OpenRouter starter key with `$1` quota and `llmBlocked` gate
enforcement.
> - The benefit is immediate, responsive first-chat acknowledgements out
of the box with a clean handoff once the user connects their own model
provider.

## Linked Issues or Issue Description

Refs #23401, #23427

**Summary**
Enable fast-response acknowledgements by default for companies running
on active Cloud starter inference (`free_inference_1`), using the
existing server-side OpenRouter starter inference key.

**Problem Statement**
Fast responses currently require both the experimental
`enableFastResponses` instance flag and an explicit shared API
connection in `company_fast_responses`. New Cloud starter-inference
workspaces have no saved API connection yet, so users do not get fast
acknowledgements during their initial onboarding chat.

**Proposed Solution**
Fall back to the server-side Cloud starter inference OpenRouter key
(`FAST_RESPONSE_DEFAULT_MODEL`, `openai/gpt-oss-120b`) when a company
has no `company_fast_responses` row and is actively on trial-only
inference without a blocked gate. Respect explicit company
configuration/opt-out, enforce `responsibleUserId` and `issue:read`
authorization, disallow sponsored webhooks on the starter key, mark the
trial exhausted on HTTP 402/limit errors, and stop using the starter key
automatically once the user connects their own model provider.

## What Changed

- `server/src/services/cloud-trial-proxy.ts` &
`server/src/services/cloud-trial-inference.ts`: Added
`isCloudTrialFastResponseEligible` and `prepareCloudTrialFastResponse`.
Keeps the raw OpenRouter key strictly in server process memory, enforces
`isCompanyOnTrialOnlyInference`, the `$1` quota, and the
`work_requires_model` / `exhausted` gates, wraps `fetch` to call
`markExhausted` immediately on HTTP 402/limit responses, and probes
usage on cleanup.
- `server/src/services/fast-responses.ts`: Updated
`enqueueFastResponse`, `fastResponseSourceCurrent`, `settings`,
`availability`, `resolve`, `process`, and `history` to use Cloud starter
inference by default when no `company_fast_responses` row exists and
starter inference is active and unblocked. Explicit
`company_fast_responses` rows (including opt-out `enabled: false`)
always take precedence, and connecting a user model provider cleanly
ends starter-key usage.
- `packages/shared/src/fast-response.ts`: Added optional
`usingCloudTrialDefault?: boolean` to `FastResponseSettings`.
- `server/src/__tests__/fast-responses.test.ts`: Added regression tests
covering starter-inference default fast responses (even when
`enableFastResponses` is `false`), raw key non-leakage,
`work_requires_model` gate blocking, HTTP 402 exhaustion, explicit
opt-out, and clean handoff after connecting a user model provider.

## Verification

- `pnpm --filter @paperclipai/shared typecheck` — passed (0 errors).
- `pnpm --filter @paperclipai/server typecheck` — passed (0 errors).
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/fast-responses.test.ts
src/__tests__/cloud-trial-inference.test.ts` — passed (44/44 tests).

## Risks

- Low risk. No database schema migration is required
(`fast_response_requests.connection_id` and `grant_id` are already
nullable). Self-hosted instances and `baseline` Cloud stacks are
unaffected because `trialInferenceEnabled` is `false`. Companies that
explicitly configure or disable `company_fast_responses` or connect
their own AI provider never fall back to the starter key.

## Model Used

- Google Gemini (Antigravity agentic runtime, thinking mode 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
- [ ] 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-12-02 16:29:41 -06:00
DottaandPaperclip 1fdd112682 fix(connections): keep resumed setup drafts unbound until finish (#23553)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - A connection starts as a draft. The operator saves its actions and
agent access at the finish step.
> - A saved draft can resume through the same connection path as a
removed connection.
> - That path restored default access for every saved connection,
including a new draft.
> - This created a company binding before the operator selected an
audience. Finish then checked every agent in the company.
> - This pull request keeps a resumed draft unbound until finish.
Previously configured connections keep their restore behavior.
> - A small audience now has a small authorization cost, even in a large
company.

## Linked Issues or Issue Description

**What happened?**

A saved MCP draft gained a company-wide profile when setup resumed.
Saving access for one agent then caused 16,610 SQL queries in a local
fixture with 1,100 agents. The request took about 8 seconds with a local
database. A remote setup request can exceed the client's deadline while
its write still completes later.

**Expected behavior**

A new draft must have no profile or access binding until the operator
saves access. Saving one selected agent must not check the full company
roster.

**Steps to reproduce**

1. Create a disabled MCP URL draft in a company with 1,100 agents.
2. Resume it with `reconnectConnectionId` and complete catalog
discovery.
3. Finish with one selected agent and one Ask first action.
4. Before this fix, the draft has a company binding and finish runs
thousands of queries.

**Paperclip version or commit**

Reproduced on `master` at `3d0e0b6dd989baeb469f99380b496c273b0b290a`.

**Deployment mode**

Any server with saved connection drafts. The local proof uses embedded
PostgreSQL and the real service and HTTP route.

Related work:
[#22080](https://github.com/paperclipai/paperclip/pull/22080) resumes
saved sign-in drafts. This change fixes the default access restored
during a draft resume.

## What Changed

- `connectGalleryApp` does not request default restoration when the
retained connection is still a draft.
- Active and archived connections keep the existing restoration path.
- Two database regressions cover URL drafts and gallery API-key drafts.
The URL test uses 1,100 agents, the real finish route, an owner session,
and a bound of fewer than 200 SQL queries. It also checks that only the
selected agent is installed and the Ask first policy is saved.
- Tests stay in the existing service suite. Its shared PostgreSQL
fixture already owns setup, finish, and restore coverage. No new
production module or schema is needed.

## Verification

- Red: both new tests failed on the old code. The saved drafts had an
active profile or a company binding before finish.
- Green: 7 focused tests passed. These include both new regressions,
archived action restoration, retained archived managed-profile
restoration, active custom MCP reconnect, and two OAuth draft resume
paths.
- Local probe before the fix: 16,610 SQL queries and about 8 seconds for
finish with 1,100 agents. The new regression requires fewer than 200
queries after the fix. It does not use a wall-clock timing assertion.
- `pnpm verify` could not run: the managed Git storage guard rejects
`git ls-files` with exit 75. The two changed files were compared with
the pinned master files before the patch. Remote file bytes were
verified after Git Data API publication.
- Full preflight installed dependencies and built shared and plugin SDK
packages. It could not build Rust Runner binaries because `cargo` is
unavailable. The focused tests completed with the real embedded
database.
- `pnpm --filter @paperclipai/server typecheck` passed, including its
test layers.
- Final-head CI passed at `b166b20550de98337842fb6fee96ca1024e09c34`:
[run
46979210544](https://github.com/paperclipai/paperclip/actions/runs/46979210544),
including typecheck, build, tests, and all 16 E2E shards. Greptile
scores this revision 5/5; all review threads are resolved. Staging
acceptance remains pending.

## Risks

- The status check must preserve restoration for a connection that was
already configured or removed. The focused suite checks active and
archived reconnects.
- A draft that already has retained access keeps those saved rows. This
change prevents the default-restoration call; it does not delete
existing access.
- The change does not relax permission checks, change Ask first
behavior, increase timeouts, or retry writes.

## Model Used

OpenAI GPT-6 Codex agent, with reasoning, shell tools, code execution,
and GitHub API 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

hint: if you need to wait for this pull request to be reviewed, merged,
or closed before continuing, use this instead of polling:
gh event listen --resource
https://github.com/paperclipai/paperclip/pull/23553 --event
com.github.pull_request.review.submitted.v1,com.github.pull_request.state.changed.v1
- It prints the first event as a JSON line on stdout and exits; run it
again to wait for the next one.
- Add `--timeout` to stop waiting after a while, for example `--timeout
30m`; it then exits with status 8.
  - Events carry no details; read the pull request to see what changed.
- It misses changes made before it starts, so read the pull request once
it is running.
  - See `gh event listen --help` for other event types.
- Event subscriptions are in preview and may not be enabled for your
account.

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-02 16:09:19 -06:00
DottaandPaperclip 0352347937 refactor(runner): remove unreferenced profile identity fixtures under test/fixtures (#23356)
Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com>
2026-12-02 16:02:25 -06:00
Devin FoleyandPaperclip 34389a7921 Keep onboarding agent timer heartbeats disabled (#23552)
## Thinking Path

> - Paperclip manages agents and their work.
> - Onboarding hires the first agent in a company.
> - Normal new-agent settings disable timer heartbeats.
> - The onboarding hire path overrides that setting and enables a
five-minute timer.
> - This change makes onboarding use the normal settings and preserves
saved policy when reconnecting an existing agent.
> - New hires keep on-demand wakes without an unwanted timer.

## Linked Issues or Issue Description

**What happened?**

Completing first-agent onboarding sends `heartbeat.enabled: true` with a
300-second interval. This differs from other new-agent paths. The
enabled timer can prevent idle sleep even when the selected runtime does
not execute unscoped timer heartbeats.

**Expected behavior**

First-agent onboarding must use the normal disabled timer default.
On-demand wakes must stay enabled. Reconnecting an existing agent must
preserve its saved policy.

**Steps to reproduce**

1. Create a company and complete first-agent onboarding.
2. Inspect the hire request's runtime configuration.
3. Before this change, its timer is enabled. After this change, it is
disabled.

## What Changed

- Use the normal new-agent runtime configuration for onboarding drafts
and hires.
- Keep the existing agent's runtime policy when reconnecting it.
- Test new hires, restored drafts, existing policy, and on-demand wakes.
- Document the default. The large wizard only changes its helper and
call sites; the merge logic and tests stay in the small runtime-config
module.

## Verification

- `pnpm exec vitest run ui/src/lib/new-agent-runtime-config.test.ts
ui/src/lib/onboarding-state.test.ts`: 10 tests passed.
- `pnpm --filter @paperclipai/ui typecheck`: passed.
- `pnpm verify`: selected 2,317 test files. An unrelated CPU timing
assertion failed in `server/src/event-loop-stall-monitor.test.ts`; the
broad run was then stopped (exit 130). This is not a passing full-suite
claim. Required CI must pass for the final head.
- [Full CI
run](https://github.com/paperclipai/paperclip/actions/runs/46974544702)
is green on final head `913daa0d0ff`, including the rerun of jobs
interrupted by runner shutdown. Greptile is 5/5 on that same head, with
no unresolved comments or merge conflicts.
- `git diff --check`: passed. Reviewed and scanned the diff for secrets,
private URLs, personal data, and infrastructure identifiers.

## Risks

Low risk. New hires now match the established new-agent default.
Existing agent settings stay intact during reconnection. No database
schema or scheduler changes. Existing records require a separate, scoped
data repair.

## Model Used

OpenAI Codex, `gpt-6.1-sol`, xhigh reasoning effort, with local code and
test tools.

## Checklist

- [x] Included project context and the problem
- [x] Specified the model used
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] Described the bug with the issue-template labels
- [x] Kept internal issue links and operational identifiers out of this
public PR
- [x] Used a descriptive branch name
- [x] Focused tests and UI typecheck pass; the interrupted broad run is
disclosed above
- [x] Added regression coverage and updated documentation
- [x] Documented risks
- [x] All required CI gates are green
- [x] Greptile is 5/5 with no unresolved comments
- [x] Will address review findings before requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1202.0-canary.881100
2026-12-02 13:41:34 -08:00
Tonio 3d0e0b6dd9 Unify provider sign-in and access controls in Connect account (#23551)
## Thinking Path

> - Paperclip manages work for AI agents.
> - Agents use provider accounts.
> - People connect those accounts in a dialog.
> - Other Models uses a second heading and a separate sign-in action.
> - Reusing the wizard card puts provider instructions and sign-in
controls together.

## Linked Issues or Issue Description

Related PR: #23474.

**What happened?**

Other Models shows duplicate headings and nested access controls.

**Expected behavior**

Show one heading, a full-width provider card, and an access disclosure
below the credentials.

**Steps to reproduce**

Open Connect account, choose Other Models, select xAI, and expand
Change.

## What Changed

Use the wizard sign-in card for subscription providers. Move access
settings below the credentials. Flatten the disclosure and show Done
when it is open.

## Verification

All 35 focused AgentProviderConnection and AdapterLoginChrome tests
passed.

## Risks

Browser redirect and code-based providers use different credential
fields.

## Model Used

OpenAI GPT-6, via Codex.

## Checklist

- [ ] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [ ] 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
- [ ] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [ ] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [ ] 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
canary/v2026.1202.0-canary.881000
2026-12-02 21:34:41 +00:00
Devin FoleyandClaude Opus 5.5 7851c2d1e3 docs(release): prepare v2026.1202.0 stable notes before publish (#23550)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Each stable release publishes curated release notes as its GitHub
Release body.
> - The stable release workflow reads
`releases/beta/v2026.1120.0-beta.0.md` from master when it starts. It
publishes that exact revision.
> - The notes on master show v2026.1123.0 and the date 2026-11-23. That
version did not ship.
> - The promotion of `2026.1120.0-beta.0` starts on 2026-12-02, so the
version is `2026.1202.0`.
> - An audit of the release range also found an incorrect contributor
count and four user-facing fixes that the notes do not cite.
> - This pull request corrects these before the stable release starts.
> - The benefit is that the release page shows the correct version,
date, counts and changes.

## Linked Issues or Issue Description

Refs #22372 (the curated notes for the `2026.1120.0-beta.0` soak).

**Problem**
The stable notes for the promotion of `2026.1120.0-beta.0` show `#
Paperclip v2026.1123.0` and `> Released: 2026-11-23`. The next stable
version for 2026-12-02 is `2026.1202.0`. The Contributors line says 16
contributors. The range has 18. Four user-facing fixes in the range are
not in the notes.

**Expected result**
The notes show `# Paperclip v2026.1202.0` and `> Released: 2026-12-02`.
The intro names v2026.1202.0. The counts match the range. The notes
describe the user-facing changes for self-hosted installs.

**Impact**
The stable workflow publishes these notes as the GitHub Release body. If
this pull request does not merge before the release starts, the release
page shows incorrect data.

## What Changed

- Set the H1 to `# Paperclip v2026.1202.0`, the release line to `>
Released: 2026-12-02`, and the version in the intro to v2026.1202.0.
- Set the contributor count to 18. The credited handles do not change.
- Add four fixes to the **Other** group in **Fixes**: the tool gateway
advertises only the MCP capabilities its token allows (#19279,
@Pavel-Guseynov), database queries recover from invalidated prepared
statements (#21718), a plugin's first configuration save works (#19847),
and cost views name Ollama billers correctly (#20420).
- One file changes. No text outside `releases/` changes.

## Verification

- The next stable version for 2026-12-02 is `2026.1202.0`. This uses the
`next_stable_version` rule in `scripts/release-lib.sh`: no public
package has a `2026.1202.N` stable version on npm, so N is 0.
- The file has no `1123` or `2026-11-23` strings after the change.
- Audit against `v2026.1117.0..28043f8b93fa208ac83f96946953d05e7ba1dfd3`
(the `beta/v2026.1120.0-beta.0` source):
  - The range has 1,222 commits. This matches the notes.
  - All 294 cited PR numbers are in the range.
- Every PR in the range that the notes do not cite was classified as
internal (CI, tests, lockfiles, release housekeeping, docs and rules for
contributors), covered by an existing line, Paperclip Cloud only (kept
out), or user-facing. The four user-facing ones are added here.
- The range has 18 commit authors without `github-actions[bot]`. This is
the same method as the v2026.1117.0 notes. The 10 credited handles are
the same.
- The range adds migrations `0452`–`0499` (48 files). This matches the
Upgrade Guide. The new environment variables and their defaults match
the code at the source commit.
- The file on this branch has blob
`40c62079534dfa2fc90709d783053653b9744ed8`.

## Risks

- Low risk. This is a change to documentation only, in one file.
- If the UTC date changes before the release starts, the release
workflow keeps `stable_date=2026-12-02` to match this header.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell,
GitHub API). Used to compute the version, audit the range, and write the
change.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass (documentation only; no
tests apply)
- [ ] I have added or updated tests where applicable (not 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.1202.0-canary.880900
2026-12-02 13:15:30 -08:00
DottaandPaperclip a30b1be565 fix(realtime): live-sync open web UI windows on headless pc mutations (#23532)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Headless channel and task commands (`pc post`, `pc reply`, `pc
claim`, `pc complete`, `pc dep`, `pc ask`, etc.) let scripts, operators,
and agents update threads and tasks from the CLI while the Web UI stays
open
> - When an operator kept an issue detail page open and ran `pc reply`
(or other `pc` mutations) from a terminal, the open Web UI page did not
live-update without a manual page refresh
> - Three gaps caused this: `publishCommittedBoardEvent` emitted
`activity.logged` events without `entityType`, `entityId`, or `action`
(so `LiveUpdatesProvider` ignored them and authenticated WebSocket
delivery stripped the custom fields); `pc reply` logged
`issue.comment_added` under the same `userId` (`local-board` in local
mode or the signed-in user in authenticated mode), which
`selfCommentActivity` downgraded to `refetchType: "inactive"` while
`hydrateVisibleIssueComment` skipped unfocused windows; and
`resolveIssueQueryRefs` missed identifier-keyed `issues.detail` cache
entries when `details` was omitted and the window was unfocused
> - This pull request maps committed headless board events onto
structured `activity.logged` payloads, tags headless comment activities
as external (`source: "headless"` / `actorProfile`), and updates
`LiveUpdatesProvider` to resolve cached detail identifiers and actively
refresh issue, comment, interaction, relation, and attention queries for
headless board events
> - The benefit is immediate live updates in open (focused or unfocused)
Web UI windows for all `pc` commands without refreshing the page, in
both local and authenticated deployments

## Linked Issues or Issue Description

**What happened?**

Running `pc reply "<ID>" "unit tests brown" --as ci-bot` or other `pc`
task/workflow/interaction commands while the issue detail page is open
in a browser window does not update the page until the user manually
refreshes.

**Expected behavior**

Commands executed through `pc` (such as `pc reply`, `pc claim`, `pc
release`, `pc complete`, `pc fail`, `pc assign`, `pc handoff`, `pc
cancel`, `pc reopen`, `pc deps`, `pc ask`, `pc approve`, `pc reject`,
`pc label`, `pc post`) should live-update open Web UI windows
automatically without a page refresh, matching the live SSE behavior of
the experimental channels viewer.

**Steps to reproduce**

1. Start a local board with `pc up --local` and open an issue detail
page in the Web UI.
2. Focus a terminal window and run `pc reply "<ID>" "unit tests brown"
--as ci-bot` (or `pc tasks claim` / `pc tasks complete`).
3. Observe that the open issue detail page does not show the new reply
or updated task state until manually refreshed.

**Paperclip version or commit**

`4db307d53c` (`origin/master`)

**Deployment mode**

Local dev (`pc up --local`) and authenticated deployments

## What Changed

- **`server/src/services/headless-board-events-write.ts`**: Added
`buildBoardEventLiveActivityPayload` and updated
`publishCommittedBoardEvent` so every committed headless
`BoardEventView` publishes a structured `activity.logged` live event
with `entityType` (`issue`, `approval`, or `channel`), `entityId`,
`action` (`issue.thread_interaction_created`,
`issue.thread_interaction_resolved`, `approval.decided`, or
`board.<type>`), `actorType`, `actorId`, and `details` (preserving
existing top-level `boardEvent*` fields).
- **`server/src/services/headless-comment-group-commit.ts`** and
**`server/src/routes/headless-channels-schemas.ts`**: Added `source:
"headless"` (and `actorProfile` when present) to `issue.comment_added`
activity details for headless replies.
- **`ui/src/context/LiveUpdatesProvider.tsx`**:
- Extended `resolveIssueQueryRefs` to scan cached `["issues", "detail"]`
queries so identifier-keyed detail routes resolve from UUID-only events
even when unfocused or in authenticated mode.
- Exempted headless comments (`source: "headless"` or `actorProfile`)
from `selfCommentActivity` suppression.
- Actively invalidated `issues.comments(ref)` on `board.comment.posted`
and added `board.task.*` actions to
`ISSUE_RELATION_SUMMARY_ACTIVITY_ACTIONS` and
`BOARD_DECISION_PROJECTION_ACTIONS`.
- **`server/src/__tests__/headless-board-events-live-sync.test.ts`** and
**`ui/src/context/LiveUpdatesProvider.test.ts`**: Added regression tests
covering structured board-event live payloads, unfocused `pc reply --as
ci-bot` as `local-board`, authenticated `board.comment.posted` with
stripped details, and `board.task.completed` relation/attention
invalidation.

## Verification

- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/headless-board-events-live-sync.test.ts
src/__tests__/live-events-ws.test.ts` (2 files, 11/11 passed)
- `pnpm --filter @paperclipai/ui exec vitest run
src/context/LiveUpdatesProvider.test.ts` (1 file, 138/138 passed)
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/headless-channels-schemas-batch.test.ts
src/__tests__/headless-queues-leases-events.test.ts` (2 files, 24/24
passed)
- `cd server && node scripts/typecheck-layers.mjs` (0 errors across all
7 layers)
- `pnpm --filter @paperclipai/ui typecheck` (0 errors)

## Risks

- Low risk. Structured `board.<type>` actions do not overlap with
`ISSUE_TOAST_ACTIONS`, so headless mutations do not emit duplicate
browser toasts when `logActivity` also fires. Authenticated WebSocket
delivery continues to authorize every `entityType: "issue"` event
against `issueId` via `getHeartbeatRunReadDecisions`, failing closed for
private issues. Existing browser-composer `selfCommentActivity`
suppression is unchanged.
- Note on file length: `ui/src/context/LiveUpdatesProvider.tsx` was
already over 1,000 lines; this PR adds a focused 68-line diff directly
inside the existing activity-invalidation and issue-ref resolution
functions rather than introducing an unrelated refactor.

## Model Used

- Google Gemini (Antigravity agentic coding assistant, medium reasoning
mode with shell, file inspection, and 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1202.0-canary.880800
2026-12-02 14:47:56 -06:00
scotttongandScott Tong 89c6e38ad1 Hide refresh for static Claude catalogs in Cloud agent settings (#23544)
Expose catalog refresh capability to the Cloud Claude picker. Preserve routed and account-bound model discovery.

Co-Authored-By: Scott Tong <scott@scotts-mbp-m5-max.local>
canary/v2026.1202.0-canary.880700 nightly/v2026.1202.0-nightly.2 beta/v2026.1203.0-beta.0
2026-12-02 12:05:16 -08:00
DottaandPaperclip f5f47b1ec4 fix(runner): omit provider mode from ordinary Antigravity ACP runtime identity (#23536)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Paperclip Runner executes Google Antigravity agents through
`AcpxRuntimeHost` and the unified `agy acp` 1.5.19 runtime
(`openAntigravityAcpRuntime`)
> - After #23168 moved ordinary Antigravity turns onto
`openAntigravityAcpRuntime`, its `identity()` method hardcoded `mode:
"persistent"`, confusing ACPX session persistence with
`AcpxRuntimePortIdentity.mode` (the optional provider mode)
> - Ordinary Antigravity turns resolve `binding.mode` to `undefined`, so
`AcpxRuntimeHost.open()` rejected every ordinary Antigravity run during
identity admission with `ACPX_ADMISSION_IDENTITY` (`ACPX runtime
Provider mode does not match the admitted session configuration`)
> - This pull request omits `mode` from `openAntigravityAcpRuntime`'s
`identity()`, rejects unexpected provider modes passed directly to
`openAntigravityAcpRuntime`, and adds an `AcpxRuntimeHost.open()`
fresh-open and session-resume regression test
> - The benefit is that ordinary Google Antigravity runs pass admission
and resume cleanly on both local and remote runners

## Linked Issues or Issue Description

Refs #23168

**What happened?**
Every ordinary (non-`/swarm`) Google Antigravity run failed during
`session.open` admission with `ACPX_ADMISSION_IDENTITY`: `ACPX runtime
Provider mode does not match the admitted session configuration`.
`openAntigravityAcpRuntime` returned `mode: "persistent"` from
`identity()`, while `AcpxRuntimeHost.open()` bound `binding.mode` to
`undefined` via `resolveAcpxProviderMode("antigravity", undefined)`.

**Expected behavior**
Ordinary Antigravity runs omit `mode` (`undefined`) in
`AcpxRuntimePortIdentity`, matching `binding.mode` during both initial
`AcpxRuntimeHost.open()` admission and subsequent `expectedIdentity`
session resume. Only trusted `/swarm` turns (served by
`openAntigravitySwarmRuntime`) carry `mode: "swarm"`.

**Steps to reproduce**
1. Open an ordinary Antigravity session (`mode: undefined`) through
`AcpxRuntimeHost.open()` backed by `openAntigravityAcpRuntime`.
2. Observe `AcpxRuntimeHost.open()` throw `ACPX runtime Provider mode
does not match the admitted session configuration` at `runtime-host.ts`
during identity verification.

**Paperclip version or commit**
`4db307d53c` (`master`, regression introduced in `3df59a1853` / #23168)

**Deployment mode**
Self-hosted server

## What Changed

- Remove hardcoded `mode: "persistent"` from
`openAntigravityAcpRuntime`'s `identity()` return value in
`packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.ts`
so `runtimeIdentity.mode` is `undefined` and matches `binding.mode` for
ordinary turns.
- Fail closed in `openAntigravityAcpRuntime` if a caller passes a
non-`undefined` `options.mode`.
- Add red-green regression tests in
`packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`
covering `AcpxRuntimeHost.open()` admission, `expectedIdentity` session
resume, and direct non-empty `mode` rejection.
- Update the ordinary-route identity expectation in
`packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-route.test.ts`
from `mode: "persistent"` to `mode: undefined`.

## Verification

- Reproduced the exact failure before the fix: `AcpxRuntimeHost.open()`
threw `ACPX runtime Provider mode does not match the admitted session
configuration` on the new regression test in
`packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.test.ts`.
- Verified green after the fix:
- `pnpm --dir packages/paperclip-runner exec vitest run
src/drivers/acpx/antigravity-acp-runtime.test.ts
src/drivers/acpx/antigravity-swarm-route.test.ts
src/drivers/acpx/antigravity-admission.test.ts
src/drivers/acpx/antigravity-acpx-runtime.test.ts
src/drivers/acpx/antigravity-credentials.test.ts
src/drivers/acpx/antigravity-swarm-guard.test.ts
src/cli/acpx-runtime-sidecar.test.ts` (7 test files, 244 tests passed)
- `pnpm --dir packages/paperclip-runner exec vitest run
src/drivers/acpx/antigravity-swarm-runtime.test.ts
src/drivers/acpx/runtime-host.test.ts` (157 tests passed)
- `pnpm --dir packages/paperclip-runner typecheck` (TypeScript + Rust
checks passed)
- Live remote staging execution requires deploying this fix; local
verification exercised the real `AcpxRuntimeHost` admission, binding,
and resume boundary with the ordinary Antigravity ACP fixture.

## Risks

- Low risk. The change aligns `openAntigravityAcpRuntime`'s reported
identity with `AcpxRuntimeHost`'s existing provider-mode contract
(`acpx-runtime-adapter.ts` already omits `mode` when no provider mode is
active). `/swarm` turns still route through
`openAntigravitySwarmRuntime` and report `mode: "swarm"`.

## Model Used

- Google Gemini 4 Neon (Medium) via Antigravity agent 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
- [ ] 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.1202.0-canary.880600
2026-12-02 13:42:53 -06:00
scotttongandScott Tong c655f38b72 Fix mobile scrolling inside chat and task cards (#23538)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - People review pending requests in agent chats and tasks.
> - The request card sits above the composer in both views.
> - On mobile, a long card can extend beyond the visible screen and
cannot scroll.
> - This pull request limits the card height to part of the visible
viewport.
> - People can scroll the card to read the details and reach its
buttons.

## Linked Issues or Issue Description

Fixes: #21626

## What Changed

- Give mobile composer takeover cards their own vertical scrolling and
contain their scroll at the edges.
- Size the mobile card against the visible chat viewport, including when
the keyboard shrinks it. Keep the desktop limit and Inbox behavior
unchanged.
- Add browser regression tests for touch scrolling through a long
confirmation card in Chat and Tasks.

## Verification

- On master at `4db307d53c`, both regressions reproduced at 390 × 664
with emulated touch. The card extended past the viewport and a swipe did
not move its scroll position.
- Both patched Chromium regressions passed. A touch swipe scrolled the
card, and subsequent swipes brought the approval button into view.
- `pnpm --filter @paperclipai/ui typecheck` passed.
- The isolated mobile preview also loaded the Inbox without changing it.
Physical iPhone and keyboard testing were not performed.

## Risks

- Low risk. The change is limited to the shared composer card layout and
does not change how requests are accepted or stored. The composer is
already above the 1,000-line threshold; changing its existing card
classes keeps the fix local.
- A long card uses part of the available height, so its contents scroll
instead of pushing the controls offscreen.

## Model Used

- OpenAI GPT, in Codex with repository and Chromium 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: #123` /
`Closes #123` / `Refs #123` 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>
canary/v2026.1202.0-canary.880500
2026-12-02 11:25:44 -08:00
Nicky LeachandPaperclip 4db307d53c Stop resuming completed Claude sign-ins (#23530)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents can use a personal or shared Claude connection.
> - Setup checks for an active sign-in before starting another.
> - A successful credential write leaves a claim for its caller to
collect.
> - This pull request limits active sign-in discovery to the three
states that still require work.

## Linked Issues or Issue Description

**What happened?**

After a shared Claude sign-in completed, personal account setup kept
finding the saved attempt until expiry.

**Expected behavior**

A user can sign in to another account as soon as the previous attempt
succeeds.

**Steps to reproduce**

Finish a shared Claude sign-in. Start a personal Claude sign-in before
the old deadline.

## What Changed

- Use the same active states for the live session lookup and the durable
lookup. Keep the saved claim available for completion.
- Check active lookup after success, after restart, and when a new
active row shares the same owner and provider.

## Verification

- Ran the setup-token session, transport binding, and HTTP route Vitest
suites. All 120 tests passed. The regression failed before the fix.

## Risks

- In-progress sign-ins still resume. Existing completion reads and claim
consumption retain their previous behavior. No migration is required.

> 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

OpenAI Codex (GPT-6), with repository and test 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1202.0-canary.880400
2026-12-02 08:20:16 -08:00
paperclipbugbotandClaude Opus 5.5 51cb918a03 fix(opencode): stop OpenCode from running npm inside opencode serve at startup (#23512)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The native Runner starts `opencode serve` (pinned to 1.18.34) for
each OpenCode turn, with its own fresh config directory and a fresh
isolated `HOME`.
> - #23372, #23391 and #23428 showed that the kernel OOM killer stops
`opencode serve` at the 8 GiB sandbox limit about 50 seconds into light
turns. The memory is OpenCode's own resident set. The model traffic is
small and complete when OpenCode dies.
> - A local reproduction finds the cause. On every project bootstrap,
OpenCode installs `@opencode-ai/plugin` into its global config directory
with npm's Arborist. The install runs inside the `opencode serve`
process. It downloads about 114 MB into a fresh npm cache and keeps the
JavaScript event loop busy while it allocates. OpenCode stops answering
HTTP, emits no events, and does not send the next model request.
> - OpenCode skips this install when the directory has `node_modules`
and a `package-lock.json` that lists the dependency. Today only launches
with configured secrets write that marker, as part of output custody.
> - This pull request writes the marker for every launch.
> - The benefit is that OpenCode no longer runs npm at startup, so it
stays responsive and its memory stays flat.

## Linked Issues or Issue Description

Refs #23372 (kernel OOM evidence). Refs #23391 (memory attribution).
Refs #23428 (model traffic counts).

**What happened?**
Native OpenCode turns on cloud sandboxes fail with
`opencode_server_exited` and SIGKILL. The failure record shows
`memoryKill: observed`, an OpenCode resident set of about 8 GB at the 8
GiB limit, and one or two small, completed model responses. The run log
stops for about 42 to 48 seconds before the kill. The failures happen
with and without tool calls. Agents with configured secrets are not
affected, because output custody already writes the install marker.

**Expected behavior**
`opencode serve` stays responsive after startup. It does not download or
install packages, and its memory does not grow while it waits for a
model or a tool.

**Steps to reproduce**
1. Start `opencode serve` 1.18.34 with an empty
`$XDG_CONFIG_HOME/opencode` that has only `opencode.json`, and an empty
`HOME`, as the Runner does for an agent without configured secrets.
2. Send one request, for example `GET /config`, so that OpenCode
bootstraps the project.
3. Within about 8 seconds, OpenCode uses 100 to 150% CPU on its
JavaScript main thread. It stops answering HTTP (`GET /config` times
out), and its memory grows. `$XDG_CONFIG_HOME/opencode/node_modules` and
`$HOME/.npm/_cacache` fill with `effect`, `zod`, `yaml`, `@ai-sdk/*` and
other packages.

**Paperclip version or commit**
`master` at debfa75a7a.

## What Changed

- New `config-dependencies.ts`:
`markOpenCodeConfigDependenciesInstalled(configDirectory)` creates
`node_modules` and writes `package-lock.json` with `@opencode-ai/plugin`
in its root dependencies. It keeps an existing lock that already lists
the package, for example one that a completed install wrote. It replaces
a lock that does not list it, with a temporary file and a rename.
- `startRuntime` calls it for OpenCode's global config directory on
every launch, before OpenCode starts. This applies with or without
configured secrets.
- Output custody no longer writes the marker, and
`prepareOpenCodeOutputCustody` no longer takes `configDirectory`. The
launch now does this once for every agent.
- `scripts/qualify-opencode-runtime.test.mjs` starts OpenCode directly.
It now records the dependency as installed for both secret cases, as the
Runner launch does.
- The Runner loads only local plugin files (`file://…`), which import
nothing from `@opencode-ai/plugin`. So nothing needs the skipped
install.
- With `OPENCODE_DISABLE_PROJECT_CONFIG=true`, which the Runner already
sets, OpenCode does not install into a workspace `.opencode` directory.
I checked this with a workspace that has a `.opencode` directory.

## Verification

- `npx vitest run src/drivers/opencode/config-dependencies.test.ts`: 3/3
pass. The tests copy OpenCode 1.18.34's install decision (`Npm.install`:
`node_modules` must exist, and the lock root must list every dependency
that `package.json` and the install would add). They check a fresh
directory, that an existing lock stays unchanged, and that a lock which
does not list the package is replaced. With the helper turned into a
no-op, 2 of 3 fail.
- New driver test: a launch with no configured secrets leaves
`node_modules` and a lock that lists `@opencode-ai/plugin` in the config
directory, and no plugin in `opencode.json`. CI runs it with the full
driver suite.
- Real OpenCode 1.18.34, idle, with the config directory prepared by
this helper:

| Config directory | OpenCode CPU | OpenCode RSS | `GET /config` | npm
cache |
  | --- | ---: | ---: | ---: | ---: |
| As on `master` without secrets | 127–148% | 0.6 GB and climbing |
times out after about 8 s | about 114 MB |
| With this change | 1–2% | 311 MB, 485 MB after a prompt | 2–3 ms |
none |

- Real OpenCode 1.18.34 with a mock provider and one `bash` call that
runs `sleep 30`: before the change, OpenCode never sent the reply, and
its memory churned between 1.1 and 1.9 GB (a peak of 3.1 GB in one run).
With the change, the tool result went back to the model, and the turn
completed after 37 s. Memory stayed at about 510 MB and CPU stayed near
0%.
- `PAPERCLIP_OPENCODE_QUALIFY=1 node --test
scripts/qualify-opencode-runtime.test.mjs` with the real OpenCode
1.18.34, using type-stripped builds of the two changed modules, three
runs each. Before the qualification change, the protected case failed
every time after about 16 s, the same as the first CI run (16.9 s).
After it, all three tests passed every time, and both secret cases took
about 2.3 s. The qualification now records the dependency as installed
for both cases, as every Runner launch does.
- I could not run the full runner suite and the typecheck in my sandbox.
Its dependencies are not installed there. CI runs them on this branch.

## Risks

- Low risk. The change writes two small files in a directory that the
Runner owns, before OpenCode starts.
- If a future OpenCode version needs `@opencode-ai/plugin` in the config
directory, its plugins could fail to load. Today the Runner loads only
its own local plugin file, which has no imports from that package. A new
OpenCode version must pass qualification before the Runner uses it.
- OpenCode's other startup installs, for example of npm plugins named in
config, are not affected. The Runner configures none.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in an 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: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 15:53:28 +00:00
Nicky LeachandClaude Opus 5.5 c31197f89f fix(onboarding): stop re-preparing an agent when a save reorders its configuration keys (#23440)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Onboarding signs the first agent in to Claude or Codex through a
plugin-managed execution environment that is prepared for the agent
(#23312, #23383)
> - Core prepares that environment again whenever the draft's execution
configuration changes, and refuses a sign-in while it does
> - Core detected a change with `JSON.stringify`, so the same
configuration saved with its keys in a different order counted as a
change. Postgres `jsonb` returns keys in its own order, so an onboarding
save of the same choice could re-prepare the environment
> - The wizard held sign-in readiness per harness only, so after such a
re-preparation it still treated the environment as ready and started a
sign-in that Core refused
> - This pull request compares configuration independent of key order,
and holds readiness per harness and model
> - The benefit is that re-picking the saved choice keeps the prepared
environment and signs in at once, and a real change waits for its
preparation instead of failing

## Linked Issues or Issue Description

Refs #23312 and #23383.

**What happened?**

With a plugin-managed execution environment as the instance default, the
onboarding agent was already prepared for Claude (`verifying`). Picking
Claude again saved the same configuration. Core moved the agent back to
`preparing` and bumped its lifecycle version, and the wizard started a
sign-in at once. Core returned `400 login_agent_unavailable` and the
card showed that error.

**What did you expect to happen?**

Saving an unchanged configuration leaves the prepared environment alone,
and the sign-in starts.

**Steps to reproduce**

1. Make a plugin-managed execution environment that prepares an
environment per agent the instance default.
2. Start onboarding, choose Claude with a subscription, and wait until
the environment is prepared.
3. Reload onboarding and pick Claude again.
4. See the sign-in fail with the message above.

## What Changed

- Agent configuration comparison (`jsonEqual`) uses canonical JSON with
sorted keys. This covers the lifecycle's re-preparation check, the
changed-field check for configuration patches, and the changed fields
recorded in configuration revisions. A save that only reorders keys no
longer re-prepares the agent or records a revision field change.
- Onboarding holds sign-in readiness per selected harness and model, so
a model change waits for the preparation it causes.

## Verification

- `pnpm --filter @paperclipai/server typecheck` and `pnpm --filter
@paperclipai/ui typecheck`: no errors.
- `server`: the agent lifecycle, configuration save and configuration
revision suites pass (97 tests). The lifecycle test now saves the same
runtime configuration with its keys reversed and asserts the lifecycle
version does not change. That assertion fails without the comparison
change (`expected 3 to be 2`).
- `ui`: the sign-in readiness hook suite passes (4 tests). It already
covers a hold-key change waiting for the new preparation.
- I reproduced the failure in a running instance and read it from the
network log. I did not repeat that sign-in with this change. CI runs the
full suites and end-to-end tests.

## Risks

- Comparisons that previously reported a key-order-only difference as a
change now report none. Every caller wants value equality, so this
removes spurious re-preparations and revision entries.
- No migration and no API change.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), with extended thinking and tool
use (code search, shell, tests, browser network inspection) 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
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1202.0-canary.880200
2026-12-02 07:32:27 -08:00
DottaandPaperclip debfa75a7a perf(server): coalesce concurrent channel posts and replies with debounced activity (#23448)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Headless channels and thread replies let many agents publish
concurrent updates, tasks, and replies into shared company streams while
preserving gapless company identifiers and commit-ordered board events
> - After PR #23426 removed per-request query overhead, a fresh local
headless benchmark on merged `origin/master` (`ab2183aaed`) showed
concurrent post throughput hitting a serialization wall at 770–805 req/s
(`c=32`) and degrading to 653 req/s (`p99 = 295.9ms`) at `c=64` on a
single channel
> - Profiling showed why: every concurrent post or reply entered its own
database transaction and blocked sequentially on `UPDATE companies`,
`UPDATE channels`, and `pg_advisory_xact_lock('board_events',
company_id)`, pinning PostgreSQL pool connections and performing N
separate WAL flushes for N concurrent arrivals
> - This pull request adds adaptive in-process group commit for
non-idempotent channel posts and normal thread comments, a 250ms
debounce on `channels.last_activity_at` updates, and multi-row
`activity_log` and `board_events` batch helpers
> - The benefit is zero batching delay when idle (`442.7 req/s`, `p50 =
2.12ms` at `c=1`), `2.40x–2.55x` higher post throughput at `c=32`
(`1,849–2,055 req/s`), `3.11x–3.79x` higher post throughput at `c=64`
(`2,475–2,501 req/s`, `p99` down 85.5%), and `2.24x` higher hot-thread
reply throughput (`1,588 req/s`, `p99` down 73%), while keeping gapless
`<PREFIX>-<N>` identifiers and monotonic `evt_<seq>` cursors

## Linked Issues or Issue Description

Refs #23426

**What existing behavior does this improve?**

`POST /api/companies/:companyId/channels/posts`, `POST
/api/companies/:companyId/issues/batch`, `PATCH
/api/issues/:id/kv-labels`, and `POST /api/issues/:id/comments`
throughput, tail latency, and PostgreSQL connection-pool efficiency
under high concurrency.

**Subsystem affected**

- `server/ — REST API & orchestration services`

**Current behavior**

On `origin/master` (`ab2183aaed`, Node `v26.4.0`, `darwin-arm64`, local
`embedded-postgres` with 2 live SSE subscribers):
- Every concurrent `POST /api/companies/:companyId/channels/posts` call
opens an independent database transaction and contends on the single
`companies` counter row, the `channels` row (`SET last_activity_at =
now()`), and the per-company `board_events` advisory lock.
- At `c=32`, post throughput caps at `770.1 req/s` on a single channel
and `804.5 req/s` across 16 channels; at `c=64`, single-channel post
throughput drops to `653.1 req/s` with `p99 = 295.91ms` because waiting
write transactions exhaust the database connection pool.
- Concurrent replies on a single hot thread (`c=32`) serialize on
unconditional `UPDATE channels SET last_activity_at = now()` and
`board_events` advisory locks, capping at `710.1 req/s` (`p99 =
84.47ms`).

**Proposed behavior**

- Add `touchChannelsLastActivity` (250ms staleness guard with ascending
`channels.id` `FOR NO KEY UPDATE` lock ordering) and `appendBoardEvents`
(single `pg_advisory_xact_lock` + ordered multi-row `INSERT INTO
board_events ... RETURNING` sorted by `seq`) in
`server/src/services/headless-board-events-write.ts`, plus
`logActivitiesBatch` in `server/src/services/activity-log.ts`.
- Add `server/src/services/adaptive-company-batcher.ts`,
`server/src/services/headless-post-group-commit.ts`, and
`server/src/services/headless-comment-group-commit.ts` with a
self-cleaning `WeakMap`-backed per-company batcher
(`MAX_COALESCED_BATCH_SIZE = 64`, `MAX_PENDING_PER_COMPANY = 1024`):
- When no batch is in flight (`c=1`), the request dispatches immediately
with zero artificial timer delay.
- While one batch transaction is executing on a single database
connection for that company, concurrent arrivals queue in memory
(bounded with `429` backpressure above `1024`) and execute together in
the next multi-row transaction using real wall-clock `new Date()`
timestamps, `issues.issueNumber` thread tie-breaking in
`listChannelThreads`, and RFC-valid sub-millisecond ordered UUIDs
(`mintTimeOrderedUuid`) across both coalesced and serialized comment
paths.
- Shared `validateChannelPathWriteFromMap` checks per-item channel
access, archived-channel, project access, and assignee rules before
counter allocation so rejected siblings never abort valid siblings or
leave gaps in `<PREFIX>-<N>` issue numbers, and post-commit event
publication runs strictly outside the transaction fallback scope.
- Requests with `idempotencyKey`, `clientRequestId`, or `after` continue
through their dedicated serialized concurrency checks.

**Reason and benefit**

Matched 7-scenario local headless benchmark (`origin/master`
`ab2183aaed` vs `perf/channel-group-commit`, 2 live SSE subscribers
active throughout, 0 errors, 100% live SSE delivery):

| Scenario | Merged `master` (`req/s`) | Group Commit (`req/s`) |
Speedup | `master` `p99` | Group Commit `p99` |
| --- | ---: | ---: | ---: | ---: | ---: |
| 1. Sequential channel posts (`c=1`, 300 msgs) | 451.4 | 442.7 | 0.98x
(no idle delay) | 4.06 ms | 3.79 ms |
| 2. Single-channel posts (`c=32`, 1,000 msgs) | 770.1 | 1,849.2 |
**2.40x** | 89.23 ms | 34.67 ms |
| 3. 16-channel posts (`c=32`, 1,000 msgs) | 804.5 | 2,054.6 | **2.55x**
| 71.76 ms | 22.73 ms |
| 4. 16-thread replies (`c=32`, 1,000 msgs) | 1,045.7 | 1,486.6 |
**1.42x** | 59.53 ms | 28.91 ms |
| 5. Single hot-thread replies (`c=32`, 500 msgs) | 710.1 | 1,588.3 |
**2.24x** | 84.47 ms | 22.70 ms |
| 6. Single-channel posts (`c=64`, 2,000 msgs) | 653.1 | 2,474.7 |
**3.79x** | 295.91 ms | 42.80 ms |
| 7. 16-channel posts (`c=64`, 2,000 msgs) | 803.4 | 2,501.3 | **3.11x**
| 124.65 ms | 32.72 ms |

**Breaking changes**

None. All endpoints, request/response shapes, gapless `<PREFIX>-<N>`
identifiers, commit-ordered `evt_<seq>` cursors, idempotency semantics,
`after` optimistic concurrency checks, and channel/project/issue privacy
checks remain unchanged. `channels.lastActivityAt` updates at most once
per 250ms window under sustained traffic on the same channel.

**Additional context**

Builds on #23426 without schema migrations or external coordination
dependencies.

## What Changed

- Extracted shared activity preparation, row mapping
(`buildActivityLogRow`), side-effect notification, and publication
helpers in `server/src/services/activity-log.ts` and added
`logActivitiesBatch` for single-statement multi-row `activity_log`
inserts.
- Extracted `server/src/services/headless-board-events-write.ts`
(re-exported from `server/src/services/headless-common.ts`) with
`mintTimeOrderedUuid`, `touchChannelsLastActivity` (250ms debounce with
canonical ascending `channels.id` `FOR NO KEY UPDATE` lock ordering),
listener-isolated `subscribeCompanyBoardEvents`, and `appendBoardEvents`
(single `pg_advisory_xact_lock` acquisition with ordered multi-row
`INSERT INTO board_events ... RETURNING` sorted by `seq`).
- Extracted `server/src/services/headless-channel-write-helpers.ts`
(re-exported from `server/src/services/headless-channels.ts`) so channel
path validation, `ensureChannel`, tag upserts, and assignee resolution
are shared via normal imports without per-item callback plumbing.
- Added `server/src/services/adaptive-company-batcher.ts`,
`server/src/services/headless-post-group-commit.ts`, and
`server/src/services/headless-comment-group-commit.ts` implementing
bounded per-company write coalescing (`MAX_COALESCED_BATCH_SIZE = 64`,
`MAX_PENDING_PER_COMPANY = 1024`), post-lock wall-clock `new Date()` +
`mintTimeOrderedUuid` sampling so batches waiting behind `companies` or
`issues` row locks always receive newer `(createdAt, id)` tuples,
UUID-keyed comment `RETURNING` joins, per-item validation isolation, and
post-commit event publication strictly outside the transaction fallback
boundary.
- Updated `createChannelPost` and `listChannelThreads` in
`server/src/services/headless-channels.ts`,
`server/src/services/headless-labels-batch.ts`, and
`server/src/routes/headless-channels-schemas.ts` to tie-break equal
`createdAt` rows on `issues.issueNumber` and use
`touchChannelsLastActivity`, `appendBoardEvents`, `mintTimeOrderedUuid`,
and `executeCoalescedHeadlessComment`.
- Added regression tests in
`server/src/__tests__/adaptive-company-batcher.test.ts`,
`server/src/__tests__/headless-channels-schemas-batch.test.ts` (16-way
mixed burst with pinned per-request statuses, wall-clock bounds,
`issueNumber` thread/after ordering, real PostgreSQL insert-error solo
fallback on both posts and comments, coalesced comment batches waiting
behind active `FOR UPDATE` serialized locks, deterministic 250ms
`lastActivityAt` skip/update assertions, and post-commit throwing
subscriber isolation), and
`server/src/__tests__/activity-log-responsible-user.test.ts`
(`logActivitiesBatch` redaction, `responsibleUserId` attribution, and
`mcpEvents` work signaling).

## Verification

- `cd server && node scripts/typecheck-layers.mjs` (0 errors across all
7 layers)
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/adaptive-company-batcher.test.ts
src/__tests__/activity-log-responsible-user.test.ts
src/__tests__/headless-channels-schemas-batch.test.ts
src/__tests__/headless-queues-leases-events.test.ts
src/__tests__/headless-task-workflows.test.ts
src/__tests__/experimental-channels-viewer.test.ts` (6 files, 47/47
tests passed)
- Matched 7-scenario local headless benchmark on `origin/master`
(`ab2183aaed`) vs `perf/channel-group-commit` with 2 live SSE
subscribers (`0` errors, `100%` SSE event delivery across all runs)

## Risks

- Low risk. No database migrations or API contract changes. Coalesced
batches hold canonical lock order (`companies -> issues -> channels ->
labels -> issue_labels -> board_events` for posts; `issues ->
issue_comments -> channels -> board_events` for comments), isolate
read-only validation errors per item before minting issue numbers,
delete idle per-company queue state immediately, and fall back to solo
execution if an unexpected database error occurs on a multi-item batch.

## Model Used

- Google Gemini (Antigravity agentic coding assistant, extended thinking
mode with shell, profiling, and 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
canary/v2026.1202.0-canary.880100
2026-12-02 06:13:26 -06:00
f91e05406d fix(server): bound the shutdown steps after the run drain (#23491)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The server runs an ordered shutdown when it gets SIGTERM. It drains
runs, stops workers, tears down the app services, closes the database
and exits.
> - The steps before the run drain have a shared deadline. Most steps
after the run drain have no deadline.
> - When one of those late steps stalls, a server that has finished its
work does not exit. It stays alive until the platform sends SIGKILL. On
Railway that is the full 90 s drain window.
> - A hosted Cloud idle stop waits for the deployment to stop. It has a
fixed stop budget, so a 90 s wait makes it fail with a production error.
> - This pull request puts the late steps under one shared post-drain
deadline and logs each step by name.
> - The benefit is that a stalled step cannot hold the exit, and the log
names the step that stalled.

## Linked Issues or Issue Description

**What happened?**
A hosted Cloud idle stop failed with "Automatic provider stop exhausted
its end-to-end budget" (Sentry PAPERCLIP-CLOUD-BACKEND-8Y, 2026-12-02).
The stop was in its Railway confirmation step, 95 s into a 120 s budget.

**Steps to reproduce**
1. Start a server. Make one step after the run drain stall, for example
a worker `stop()` or the app service teardown that never settles.
2. Send SIGTERM.
3. The server logs its ordered shutdown up to "plugin job coordinator
stopped", and then nothing more. The process does not exit until
SIGKILL.

**Expected behavior**
The server exits within a bounded time after the run drain, also when
one late step stalls. The log names the step that stalled.

**Evidence**
The stack's deployment logs show SIGTERM at 11:00:31.25. The ordered
shutdown logged its last line ("plugin job coordinator stopped") at
11:00:31.53. After that line the server logged nothing. The deployment
was still stopping 89.8 s after SIGTERM, when the Cloud stop budget ran
out at 11:02:01.03. Railway's 90 s drain window ends at about
11:02:01.25. The current code has no log lines after that point, so the
logs cannot show which step stalled. This change adds those log lines.

## What Changed

- `server/src/shutdown.ts`: add `POST_DRAIN_SHUTDOWN_BUDGET_MS` (20 s)
and `createPostDrainShutdownBudget`. It uses the same shared-deadline
step runner as the existing pre-drain budget.
- `finalizeServerShutdown` runs the app service teardown inside the
caller's post-drain budget (`app_services_shutdown`). It bounds the
run-failure report drain (`run_failure_report_drain`) and the span flush
(`instrumentation_shutdown`) to 5 s each, like the database close and
the Sentry close. The embedded PostgreSQL stop has no bound, as before.
- `server/src/index.ts`: the cancellation, runtime response, deployment
hint, delivery work and managed environment recovery stops, and the
run-log mirror flush, now run as named steps in the shared post-drain
budget. The same budget then goes to `finalizeServerShutdown`.
- Failures and timeouts use the existing "shutdown step failed" /
"shutdown step timed out" log lines with the step name.

## Verification

- Red before the change: the new test "bounds the run-failure report
drain and the span flush" failed by a 30 s test timeout, because the old
code waited forever. The budget tests failed because the post-drain
budget did not exist.
- Green after the change: `cd server && npx vitest run
src/shutdown.test.ts` gives 32 passed.
- New tests: a teardown that never settles still reaches the database
close, the provider stop, the Sentry flush and the exit continuation. A
stalled report drain and a stalled span flush time out by name. Steps
after the run drain share one deadline.
- Typecheck: the server's lower layer (with `shutdown.ts`) passed
locally. The `index.ts` layer was killed by this machine's memory limit,
so required CI covers it.

## Risks

- Low risk. Behavior changes only when a late shutdown step takes longer
than its bound. Then the shutdown continues without it, as the pre-drain
steps already do.
- A timed-out setup-token lease release stays a durable record for the
startup reaper, as the existing code comments describe.
- The run-log mirror flush now gets what is left of the 20 s budget. A
very large tail upload on a busy restart can time out. Before this
change, the platform SIGKILL stopped it at the end of the drain window.
- The new per-step log lines add about nine info lines to each shutdown.

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

## Model Used

- Anthropic Claude Opus 5.5 (`claude-opus-5-5`), run through Claude Code
with tool use (shell, file edits, Sentry and Railway read tools).
Reasoning mode: standard.

## 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>
canary/v2026.1202.0-canary.880000
2026-12-02 04:11:05 -08:00
7636441c46 fix(recovery): hold an agent comment wake behind a refused workspace writer hold (#23475)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A run fails setup with "The workspace still has an unfinished writer
or save operation." when the task's remote workspace is still held by an
earlier writer run that did not finish its save, and the hold refuses a
start.
> - #22103 and #23446 stopped the assigned-work sweep, the bounded retry
and stranded recovery from starting runs behind such a hold. On staging,
the failures are now single runs, not pairs.
> - The remaining single failures come from comment wakes. An agent
comments on a task (for example, an automated status note), and the
route wakes the assignee. The assignee's latest run on that task already
failed on the same refused hold, so the new run can only fail the same
way.
> - The blocker-stall wake already checks this case before it wakes a
waiter. The comment wake paths do not check it.
> - This pull request makes the comment wake paths skip the assignee
wake for an agent-authored comment while the assignee's latest run on
the task failed on that hold and the hold still refuses a start.
> - The benefit is no new failed run for each automated comment on a
held task. The comment stays on the task, and the existing recovery
continues the task when the hold settles.

## Linked Issues or Issue Description

Refs #22103
Refs #23446
Refs #21221

**What happened?**
On staging, after #22103 and #23446 were deployed, two runs failed setup
with the writer-pending message (`setup_failed`, before provider work).
Each run was started by an agent comment on a task: one through
`issue.comment`, one through `issue.comment.reopen`. Both tasks have
workspaces whose writer run ended long ago with an unsaved workspace, so
the hold refuses a start. In one task, the assignee's previous run had
already failed setup on the same hold. No retry followed either failure,
so #23446 works. But every new automated comment on such a task starts
one more run that fails.

**Expected behavior**
An agent comment does not start a run that can only fail setup on a
refused workspace hold. The comment is kept. The task continues through
stranded-work recovery and the released-writer pass when the hold
settles. A person's comment still wakes the assignee.

**Steps to reproduce**
1. Bind an in-progress task to an execution workspace whose remote
writer is an ended run with dirty, unsaved state, so the hold refuses a
start.
2. Fail the assignee's latest run on the task with `setup_failed` and
the writer-pending message.
3. As another agent, post a comment on the task (`POST
/api/issues/:id/comments`, or `PATCH /api/issues/:id` with `comment`).
4. Before this change, the route wakes the assignee, and the new run
fails setup on the same hold.

**Paperclip version or commit**
`master` at 5a956b724.

**Deployment mode**
Hosted (cloud sandbox workspaces).

## What Changed

- `server/src/services/remote-workspace-writer-hold.ts`: add
`agentTaskWorkspaceHoldRefusesStart(db, { companyId, issueId, agentId
})`. It reads the agent's latest run on the task (indexed on company,
`contextSnapshot.issueId` and `createdAt`). It returns true only when
that run failed setup on the writer hold and the hold still refuses a
start (`failedRunWorkspaceHoldRefusesStart` from #23446).
- `server/src/routes/issues.ts`: the POST comment and PATCH comment wake
paths skip the assignee wake when the actor is an agent and that check
is true. In the PATCH path, the same result (read once per request) also
holds the `issue_status_changed` wake, for example when an agent moves a
blocked task to `todo` with a comment. The check runs only when the
route would otherwise wake the assignee. If the check fails to read, the
wake goes through as before.
- Person comments, a settled hold, and a later run of the assignee on
the task all keep today's behavior.
- The rule needs evidence that reservation already refused this hold
(the latest run failed on it). Reservation can still release an
unchanged or superseded writer before it reads the hold, so a hold read
alone could hold a wake that reservation would admit.
- Tests: `released-writer-escalation.test.ts` checks the helper against
Postgres: true behind the refused hold, false for another agent, false
after the hold releases, and false after a later run.
`issue-comment-reopen-routes.test.ts` checks both wake paths: an agent
comment behind a refusing hold wakes nobody, a person's comment still
wakes the assignee and does not read the hold, and an agent comment
wakes the assignee when the hold does not refuse. A PATCH that moves a
blocked task to `todo` with an agent comment wakes the assignee zero
times behind a refusing hold and once otherwise.

## Verification

- `cd server && npx vitest run
src/__tests__/issue-comment-reopen-routes.test.ts
src/__tests__/released-writer-escalation.test.ts`: 123/123 and all
released-writer tests pass.
- With the route check disabled, the two "agent comment behind a
refusing hold" cases fail (one wake, expected none). With only the
status-wake check removed, the blocked-to-`todo` case fails.
- Related suites (11 files: issue comment routes, comment wakeups,
queued comments, scheduled retry routes, retry scheduling, assigned-work
invariant, released-writer escalation): 457/457 pass.

## Risks

- Low. The new read runs only for an agent-authored comment that would
wake the assignee. It is one indexed query, plus the workspace hold read
only when the latest run failed on the hold.
- An agent comment on a task behind a refused hold no longer starts a
run. The assignee reads the comment on its next run, which stranded-work
recovery and the released-writer pass start when the hold settles.
- Person comments are unchanged.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, git, GitHub CLI) 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 (not
needed: no command or documented behavior 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>
2026-12-02 02:26:46 -08:00
Tonio 2bef9e3a80 Keep Connect account steady when switching credential methods (#23480)
## Thinking Path

> - Paperclip manages work for AI agents.
> - Agents use provider accounts.
> - People connect those accounts in a dialog.
> - Switching methods can move the controls.
> - A shared minimum panel height keeps the footer steady.

## Linked Issues or Issue Description

Related PR: #23474.

**What happened?**

The API key panel used less space than the subscription panel.

**Expected behavior**

Changing methods keeps the dialog height steady.

**Steps to reproduce**

Open Connect account and switch from subscription to API key and back.

## What Changed

Apply a common minimum height to credential cards inside Connect
account.

## Verification

All 10 AgentProviderConnection component tests passed. Compare both
directions in the staging dialog.

## Risks

Long instructions or additional controls can still grow beyond the
minimum height.

## Model Used

OpenAI GPT-6, via Codex.

## Checklist

- [ ] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [ ] 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
- [ ] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [ ] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [ ] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [ ] 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
canary/v2026.1202.0-canary.879800
2026-12-02 09:00:36 +00:00
Tonio 28c44fa2a1 Use in-panel OpenAI sign-in from Other Models (#23474)
## Thinking Path

> - Paperclip lets people connect provider accounts for agent work.
> - The Connect account dialog includes a provider grid.
> - OpenAI subscription setup from that grid still uses the footer to
start sign-in.
> - This change uses the same sign-in panel as direct OpenAI setup.
> - People can see when authorization is pending and when they can
proceed.

## Linked Issues or Issue Description

**Subsystem affected**

Agent settings and managed AI accounts. Related change: #23361.

**Current behavior**

OpenAI under Other Models presents a sign-in hyperlink and repurposes
the footer during authorization.

**Proposed behavior**

Start device authorization from the panel. Show Waiting… there and keep
Next disabled while authorization is pending.

## What Changed

- Enable inline subscription controls for OpenAI when opened from the
provider grid.
- Exercise the grid presentation in the sign-in panel tests.

## Verification

- All 33 focused agent connection and sign-in panel tests passed.
- Open Connect account, select Other Models, select OpenAI, and click
Sign in.

## Risks

The changed path shares completion handling with direct subscription
setup. Provider authentication and access settings still use the same
APIs.

## Model Used

OpenAI GPT-6 through Codex with local editing, terminal tests, 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)
- [ ] 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
canary/v2026.1202.0-canary.879700 nightly/v2026.1202.0-nightly.1
2026-12-01 23:57:07 -08:00
Nicky Leach 5a956b724b fix(agents): set agents up again when their environment driver changes (#23449) canary/v2026.1202.0-canary.879600 2026-12-01 23:33:24 -08:00
Devin FoleyandPaperclip 725a9e36b6 fix(connections): let a dedicated account serve every agent picked for its connection (#23431)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A GitHub connection can use "A dedicated account for an agent", for
example a bot account that an agent uses instead of the person who gives
instructions
> - The account lives on the grant of the agent that signed in. Core
gives one connection to one signed-in agent
> - A team often wants several agents to use the same bot account, or to
move a bot account to a new agent. Today each agent needs its own GitHub
sign-in as the bot
> - The permissions page also lets an owner pick more agents for the
connection, which looks like sharing but gives those agents nothing
> - Sharing a credential must stay under the owner's control: an install
of a connection needs only `agents:configure`, which agents and
operators have, so installs cannot be the share signal
> - This pull request adds an explicit share list for a dedicated
account. Only the person who connected the account, a company owner or
admin, or an instance admin can change it
> - The benefit is that a bot account can serve several agents without a
new sign-in, and no one else can attach the account to their agents

## Linked Issues or Issue Description

No public issue exists.

**What happened?**
A GitHub connection with a dedicated account was signed in for agent A.
The owner then picked agent B for the same connection on the permissions
page. The page showed "Used only by A" and also "2 agents selected" with
A and B. Agent B made no GitHub tool calls through the connection, and
its git work used the responsible person's GitHub account. There was no
way to let agent B use the bot account without a second GitHub sign-in
as the bot.

**Expected behavior**
The owner of a dedicated account can share it with chosen agents, and
those agents use it for managed git and the connection's tools. No one
else can share it.

**Steps to reproduce**
1. Add a GitHub connection with "A dedicated account for an agent" and
pick agent A.
2. On the connection's permissions page, pick agent B too.
3. Start a run for agent B that pushes with git. See that it uses the
responsible person's account, and that the page offers no way to share
the bot account.

**Paperclip version or commit**
`master` at fcb8fc5deb.

**Deployment mode**
Any deployment with a GitHub connection that uses a dedicated agent
account.

## What Changed

- `agent-grant.ts`:
- `agentGrantScope`: a dedicated grant serves its signed-in agent, or an
agent with a share row (a `connection_grant_delegations` row on the
agent grant). Installs and app profile bindings do not count.
- `replaceSharedAgents`: replaces the share list in one transaction, and
checks share permission again on the locked grant row, so a share
request cannot land after another person's reconnect. It accepts only
active agents of the company, skips the signed-in agent, refuses an
inactive grant, and records a `connection_grant.shared_agents_replaced`
audit event.
- `sharedAgentGrantIds` and `dedicatedIdentityAgentIds` read the share
list.
- New route `PUT
/tool-connections/:connectionId/grants/:grantId/shared-agents` with
`replaceDedicatedAccountAgentsSchema` (at most
`DEDICATED_ACCOUNT_SHARE_LIMIT`, 1000 agents, the same as a grant's
member audience; the picker does not send a larger selection and says
why). Only a board user can call it, and only when the user connected
the account, is a company owner or admin, or is an instance admin.
Agents and other operators get 403.
- The credential access, tool gateway and token broker lookups for a
per-agent connection use `agentGrantScope`.
- `git-credentials.ts`: managed git identity uses the share list. An
agent that has its own dedicated account uses its own account first.
Live shared grants come before revoked ones, and a run still asks for a
reconnect when no live grant remains.
- The grants endpoint returns `dedicatedAgentIds` (the signed-in agent
and the shared agents) and `canShareDedicatedIdentity` for the viewer.
- Existing delegation lookups match only personal grants, so a share
never acts as a personal delegation.
- Every path that replaces a dedicated grant's credential (the connect
upsert, the cloud connector callback and the credential reconnect) calls
`reauthorizeAgentGrant`. It locks and rereads the grant, records the new
authorizer as the grant's `createdByUserId`, and clears the share list
when the authorizer or the provider account changes. So only the person
behind the current credential, or an admin, can share it.
- `revokeConnectionGrant` keeps the share rows of a dedicated agent
grant, so a revoked account asks shared agents to reconnect instead of
switching them to a person's account. A reconnect reactivates the same
grant with its shares.
- Permissions page: the GitHub identity card lists each agent that uses
the account and, for a person who can share it, shows "Share this
account with other agents". The sharing state lives in the new
`useDedicatedAccountSharing` hook.
- Agent Tools tab: uses `dedicatedAgentIds`, so a shared agent shows the
shared account.
- `doc/execution-github-identity.md`: describes the share list and who
can change it.

## Verification

- `pnpm --filter @paperclipai/server typecheck` and `pnpm --filter
@paperclipai/ui typecheck` pass.
- `server/src/__tests__/agent-grant-scope.test.ts` (7 tests, including a
reconnect that clears shares and a share request whose permission is
checked against the locked, already-reconnected grant): the signed-in
and shared agents get the grant; installed, bound and unpicked agents do
not; a former agent keeps only its own revoked grant; the share list
accepts only active company agents, skips the signed-in agent, refuses
an inactive grant and records an audit event.
- `server/src/__tests__/dedicated-account-sharing-routes.test.ts` (3
tests): an operator with `tools:manage_connections` and a member get
403; after another person reconnects the account, the shares are cleared
and only that person (or an admin) can share; the person who connected
the account and an admin can replace the list; the grants endpoint
reports the agents and the viewer's permission.
- `github-operation-credentials.test.ts`: a shared agent uses the
dedicated account; installed and bound agents use the person's account;
an agent's own dedicated account comes first; a revoked grant for
another account does not make the identity ambiguous. 27 tests pass.
- `agent-grant-scope.test.ts` also checks that a revoke keeps the share
list (fails without the change), and
`github-operation-credentials.test.ts` checks that a shared agent gets a
reconnect error, not the person's account, after a revoke.
- UI: `DedicatedIdentity.test.tsx` (4 tests, including the sharing
picker with 800 agents and 20 unchanged rerenders under a fixed read
budget), `dedicated-github-identity.test.ts` (3 tests) and
`useDedicatedIdentityAgents.test.ts` (2 tests, 800 agents behind a read
counter).
- I ran the 92 server test files that mention per-agent connections,
agent grants, dedicated accounts or delegations: 81 files and 6852 tests
pass, including `openapi-routes.test.ts` with the new route in the spec.
The other 11 files are integration tests that skip without their test
database. I also ran 34 UI test files for the apps pages, the Tools tab
and replay masking: 457 tests pass.
- `tests/runner-e2e/source-sdk-public-inputs.json` is regenerated with
`source-sdk-public-inputs.mjs --write`, because the change touches
pinned `packages/shared` files.

## Risks

- No schema change: the share list reuses
`connection_grant_delegations`.
- Agents keep their current identity after this change. An agent uses a
shared account only after an owner or admin shares it.
- A connection manager who is not an admin can still remove a share
through the existing delegation delete route. That only reduces access.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, read-only database queries on a hosted instance for
the diagnosis).

## 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.1202.0-canary.879500
2026-12-01 22:40:42 -08:00
29a45b42db fix(recovery): stop retrying a setup failure behind a refused workspace writer hold (#23446)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A run can fail setup with "The workspace still has an unfinished
writer or save operation." when the task's own remote workspace is still
held by an earlier writer run that never finished saving.
> - #22103 stopped the assigned-work sweep from looping a board
escalation behind such a hold. Staging still showed these failures in
pairs.
> - Each pair is one continuation (a sweep continuation, a delivered
fresh continuation, or a comment that reopened the task) whose run fails
on the hold, followed by an immediate bounded `transient_failure` retry
from the failure path, which fails the same way.
> - `scheduleBoundedRetryForRun` never reads the workspace hold before
it schedules that retry.
> - This pull request makes the retry scheduler, the assigned-work sweep
and stranded recovery agree: while the hold refuses a start, nobody
starts another run; the task goes to the board-owned stranded hold,
which the sweep (#22103) and the released-writer pass (#21221) continue
once the writer releases.
> - The benefit is one failed run per held workspace instead of repeated
pairs, and no task left in progress with nothing moving it.

## Linked Issues or Issue Description

Refs #22103
Refs #21221
Refs #21394
Refs #23051

**What happened?**
On staging, tasks whose workspace writer hold stayed refused produced
failed runs in pairs, seconds apart:
- A continuation run failed setup with the writer-pending message
(`setup_failed`, `executionRecovery: { kind: "bootstrap",
providerWorkStarted: false }`).
- The failure path then scheduled a bounded `transient_failure` retry of
that run (`scheduledRetryAttempt: 1`), which failed setup on the same
hold.
One pair started from a delivered fresh continuation (`source:
execution.reconciled`), another from an assigned-work sweep continuation
of a task a comment had reopened (`source:
issue.assigned_work_invariant`, `assignedWorkViolation: retry_offered`).

**Expected behavior**
While the task's workspace writer hold refuses a start, no retry or
continuation is started. The task is escalated once to the board-owned
stranded hold and continued once after the hold releases.

**Steps to reproduce**
1. Bind an in-progress task to an execution workspace whose remote
workspace writer is an ended run with dirty, unsaved state (the hold
refuses a start).
2. Fail the task's latest run with `setup_failed` and the writer-pending
message, before provider work, as an assigned-work continuation.
3. Call `scheduleBoundedRetryForRun` for that run: before this change it
schedules a retry.
4. Run the assigned-work check: before this change it continues the task
(`retry_offered`).
5. Run stranded recovery: before this change it skips the task because
the sweep owns the failed continuation, so with the sweep held back the
task would have no path.

**Paperclip version or commit**
`master` at ab2183aae.

**Deployment mode**
Hosted (cloud sandbox workspaces).

## What Changed

- `server/src/services/remote-workspace-writer-hold.ts`: add
`failedRunWorkspaceHoldRefusesStart(db, run)`: true when the run failed
setup with the writer-pending message and its task's workspace hold
still refuses a start (`remoteWorkspaceHoldRefusesStart`). Export
`REMOTE_WORKSPACE_WRITER_PENDING_CODE`, the code reservation already
uses.
- `server/src/services/heartbeat/retries.ts`:
`scheduleBoundedRetryForRun` returns `not_scheduled` with `errorCode:
remote_workspace_writer_pending` for such a run. Other runs do not read
the database for this check.
- `server/src/services/recovery/assigned-work-sweep.ts` (+
`assigned-work-invariant.ts` fact): the hold read from #22103 now also
covers a task whose latest run failed on the hold. For an open task with
a `retry_offered` or `no_pending_path` violation behind a refused hold,
the sweep reports `left_to_hold_owner` instead of continuing it,
including in the locked re-check.
- `server/src/services/recovery/service.ts`: stranded continuation
recovery does not count such a failed run as owned by the sweep, so it
escalates the task to the board hold instead of skipping it.
- Tests: `retries.test.ts` (refused hold: no retry and no successor;
released hold: retry scheduled) and `released-writer-escalation.test.ts`
(reopened task behind the refused hold: sweep leaves it, stranded
recovery escalates with no successor run, and the released-writer pass
continues it once after release).

## Verification

- `cd server && npx vitest run src/services/heartbeat/retries.test.ts
src/__tests__/released-writer-escalation.test.ts
src/__tests__/assigned-work-invariant.test.ts
src/services/heartbeat/recovery.test.ts`: 210/210 pass.
- The 19 other server test files that call
`reconcileStrandedAssignedIssues` pass on this head (18 files: 1,350
passed, 19 skipped; `workspace-recovery-admission.test.ts`: 149/149).
- Each part is needed. With the scheduler check removed, the retries
test schedules a retry (`scheduled`, expected `not_scheduled`). With the
stranded ownership change removed, the escalation test leaves the task
in progress (expected `blocked`). With the sweep change removed, the
sweep continues the task (expected `left_to_hold_owner`).
- I could not run the full server `tsc` locally (the sandbox's memory
limit stops it). CI must confirm typecheck, build and the full suite.

## Risks

- Low to medium. The new reads happen only for runs that failed setup
with the writer-pending message: one join from the task to its execution
workspace and one hold read.
- A task behind a long refused hold now waits on the board-owned
stranded hold instead of failing repeatedly. The sweep and the
released-writer pass already continue that hold when the writer
releases.
- If the hold is already free when these paths look, behavior is
unchanged: the retry is scheduled and the sweep continues the task.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, git, GitHub CLI) 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 (not
needed: no command or documented behavior 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>
nightly/v2026.1202.0-nightly.0 canary/v2026.1202.0-canary.879400
2026-12-01 20:41:33 -08:00
Devin FoleyandPaperclip ab2183aaed test(server): settle coalesced work before measuring idle drain (#23437)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Image publication requires source verification for the same commit.
> - The maintenance suite checks work committed during an idle drain.
> - Managed channel pools batch change notifications for 50 ms.
> - The test API helper freezes the child clock when a response ends.
> - A notification can then retain its work token while its timer cannot
fire.
> - This change advances the existing test clock before measuring quiet
drain.

## Linked Issues or Issue Description

Refs #23415 and #22523.

**What happened?**

[Source verification
failed](https://github.com/paperclipai/paperclip/actions/runs/46783252165/job/143126872561)
in `maintenance-server-routes.test.ts`. The case `processes the first
ordinary external-object producer committed during idle drain and
becomes quiet again` timed out with one tracked work token. The image
watcher then canceled [Docker
publication](https://github.com/paperclipai/paperclip/actions/runs/46783252123).

The issue write notifies the managed channel pool worker. That worker
batches notifications for 50 ms. The API helper freezes the child clock
after the response. The test then waits for quiet without advancing that
timer. Response timing determines whether the worker finishes first.

**Expected behavior**

The test must let bounded change notifications finish their drain
reconciliation. It must still prove that provider work does not start
during drain, that the database stays quiet across the measured drain
windows, and that deferred work resumes afterward.

**Steps to reproduce**

Run `pnpm exec vitest run
server/src/__tests__/maintenance-server-routes.test.ts -t 'processes the
first ordinary external-object producer'` with the required local
runtime outputs prepared. The unchanged test failed locally with
`idle.active: 1` and no pending database request. Temporary local
tracing identified the retained token at the managed-channel-pool
notification in `notifyIssueRecovery`. That tracing is not part of this
change.

## What Changed

- Use the existing bounded `settleClock` helper after the held producer
request completes.
- Keep the existing provider-request, quiet-window, restart, and retry
assertions.

## Verification

- Red: the unchanged case failed locally with the same 30-second
settling timeout as CI. A second diagnostic run identified the coalesced
managed-channel-pool token.
- Green: the final focused case passed in 24.82 seconds on Node 24.23.0
with pnpm 9.15.4 and embedded PostgreSQL 18.1.
- The complete maintenance file passed on `58ccfb513f7`: 17/17 cases in
246.23 seconds. The subsequent change only removes the added comment;
the focused case was rerun after that cleanup. Command: `pnpm exec
vitest run server/src/__tests__/maintenance-server-routes.test.ts`. This
includes the real idle windows, committed-during-drain producer,
provider-error retry, shutdown recovery, and signed warm-claim cases.
- `pnpm verify --base origin/master` selected 1,993 of 2,353 test files.
I interrupted that broad local run and ran the complete maintenance file
above. Required CI supplies broad verification.
- CI attempt 1 on `f2a83ce4ba4` lost the runners for [General tests
(server
6/20)](https://github.com/paperclipai/paperclip/actions/runs/46788843123/job/143146044550)
and [serialized suites
(9/9)](https://github.com/paperclipai/paperclip/actions/runs/46788843123/job/143146044125).
Both job logs report a runner shutdown at 01:40:57 UTC, followed by
cancellation. These interrupted jobs are not passes. The existing
first-attempt runner-loss workflow retries after the parent CI run
completes, if no other job has a source failure.
- [CI attempt
2](https://github.com/paperclipai/paperclip/actions/runs/46788843123/attempts/2)
passed on final head `f2a83ce4ba44e639902ae57db1aba233562e3293`. Both
interrupted jobs passed on retry. No failed or pending checks remain
among the 72 reported checks; applicable checks passed and optional
lanes were skipped. Greptile scored this head 5/5 with no unresolved
review threads. Source verification and image publication checks remain
enabled.

## Risks

The change affects one test. It uses the suite's existing bounded
clock-settling helper. The drain assertions still reject provider work
and database polling in the measured windows. No production source,
timeout, schema, or deployment setting changes.

## Model Used

- OpenAI `gpt-6.1-sol` through Codex in T3 Code, with xhigh reasoning,
repository tools, shell commands, and local test execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] 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>
canary/v2026.1202.0-canary.879300
2026-12-02 01:50:08 +00:00
Nicky LeachandPaperclip 9092b0c667 Support live Antigravity credential writeback for both token stores (#23397)
## Thinking Path

> - Paperclip manages the connections agents use to work.
> - A run can outlive the Google refresh token that started it.
> - Antigravity writes a rotated token to a private file. Its two
runtimes use different paths and JSON layouts.
> - The task already records which connection supplied its sign-in.
> - Runner reports a rotation on PRP. Core saves it to that connection
if the saved generation still matches.
> - The next run can start with the rotated token.

## Linked Issues or Issue Description

Refs #23395. Refs #23168.

This PR targets `master` and includes the capability-based handler from
#23395. Merging this PR lands the handler and Antigravity writeback
together.

**Current behavior**

A managed Antigravity sign-in reaches the plugin as an environment
credential. Core waits for task retirement to collect a refresh.

**Proposed behavior**

Seed a private auth-file. Observe refresh-token changes for the ordinary
ACP server and the unified CLI. Use the existing credential update event
to save them during execution.

**Reason and benefit**

A long-running task can keep its source connection current across
successive rotations.

## What Changed

- Dispatch PRP credential updates to the live writeback capability
declared for the bound harness and execution target.
- Send Antigravity subscriptions as auth-file credentials to environment
task providers. Keep Gemini API keys and previously admitted environment
credentials on their existing paths.
- Watch the ACP token file and the unified CLI token file. Compare the
refresh token, copy it to the bound file, and emit the existing
secret-free event.
- Bind writeback to the original grant, secret, session epoch, and
credential generation. Save the next generation in the same transaction.

## Verification

- Reproduced the failed final Google save hanging on the next session
close. After commit `2b3e7897cd`, both focused cleanup suites passed (43
tests). The regression covers two overlapping close retries after the
credential home is released and checks that the saved credential is
removed only after persistence succeeds.
- All 21 Rust observer tests passed on both builds. They cover
interruption between the host file and event journal writes, a further
rotation before restart, and a reconnect that supersedes the task.
- On the legacy build, 422 Runner TypeScript tests passed. With the
merged unified CLI on this branch, all 126 tests in the auth, credential
staging, and runtime host suites passed.
- The two plugin writeback database suites passed (39 tests). A refresh
that starts before task stop cannot overwrite the final token after
stop.
- One run timed out in an unrelated process-retirement test. All three
suites passed together on repeat. All OAuth documents in these tests are
fixtures. No live Google sign-in was exercised.

## Risks

- The agent and any process it starts are trusted not to substitute
another account’s refresh token in the harness credential file. Core
accepts the file’s refresh token for the original connection only while
the grant, secret, session epoch, and expected credential generation
still match. Substitution within that boundary is an accepted risk.
[Review
finding](https://github.com/paperclipai/paperclip/pull/23397#discussion_r4759261984)
- Deploy with a plugin and Launcher that support the new auth-file
provider. This branch includes the unified CLI from #23168 and still
observes the legacy token format.

> 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

OpenAI GPT-6 in Codex, with local code execution and GitHub CLI.

## Checklist

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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-02 01:49:46 +00:00
DottaandPaperclip c47452699a perf(server): speed up headless channel posts, replies, and SSE bursts (#23426)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Headless channels, threads, and SSE streams let agents and tools
exchange high-rate status updates and structured messages
> - A local headless benchmark on `origin/master` (`828b8c2a2a`) showed
channel posts at 226 req/s (`c=1`) and 342–346 req/s (`c=32`), with
database tuple scans growing linearly with company issue count and live
SSE streams falling behind under burst
> - CPU, heap, and PostgreSQL profiling traced the bottlenecks to an
unindexed `O(N)` `MAX(issue_number)` scan per post, redundant SQL
round-trips and uncached transactional `instance_settings` reads inside
the company row lock, upfront `FOR UPDATE` locks on normal replies,
serial per-event SSE database checks, and routing through 64 unrelated
Express sub-routers
> - This pull request adds an online-compatible `issues(company_id,
issue_number)` index so `MAX(issue_number)` floor checks run as `O(log
N)` index-only probes inside the `companies` counter update, eliminates
redundant channel/view/savepoint queries, locks parent issues on replies
only when `clientRequestId` or `after` is supplied, mounts headless
routers early, and extracts a unified bounded SSE/replay filter pipeline
with creation-time `kvLabels`/`tagLabels` snapshots and pre-change label
history lookup
> - The benefit is 2.09x to 2.67x higher channel post throughput (473
req/s at `c=1`, 885–924 req/s at `c=32`), 1.75x higher reply throughput
(1,221 req/s at `c=32`), 55.5% less heap allocation, `O(log N)`
index-only counter floor checks as issue count grows, and 100% real-time
SSE delivery under burst

## Linked Issues or Issue Description

**What existing behavior does this improve?**

`POST /api/companies/:companyId/channels/posts`, `POST
/api/companies/:companyId/issues/batch`, `POST
/api/issues/:id/comments`, and `GET
/api/companies/:companyId/events/stream` throughput, tail latency, heap
allocation, and database scalability.

**Subsystem affected**

- `packages/db/ — Drizzle schema & migrations`
- `server/ — REST API & orchestration services`

**Current behavior**

On `origin/master` (`828b8c2a2a`, Node `v26.4.0`, `darwin-arm64`, local
`embedded-postgres` with 2 live SSE subscribers):
- `createChannelPost` and `createBatchIssuesPlan` run `SELECT
coalesce(max(issue_number), 0) FROM issues WHERE company_id = $1` on
every call without an index on `(company_id, issue_number)`, scanning
every issue row in the company (`2,029` tuples/request at ~2,400
issues).
- `ensureChannel` ignores the channel row already fetched by
`assertChannelPathWritePreconditions`, runs `INSERT ... ON CONFLICT DO
NOTHING`, and selects the channel a second time.
- `createChannelPost` holds the `companies` row lock while calling
`logActivity(tx, ...)` (which skips the `instance_settings` read-through
cache on `PgTransaction` handles and opens a nested `SAVEPOINT` +
`SELECT pg_current_xact_id()`), running two round-trips in
`appendBoardEvent`, and re-querying four tables in
`loadHeadlessIssueView`.
- `POST /api/issues/:id/comments` selects all 89 `issues` columns via an
unindexed `upper(identifier)` scan when given an identifier and
unconditionally acquires `SELECT ... FOR UPDATE` on `issues` even when
neither `idempotencyKey`/`clientRequestId` nor `after` is supplied.
- `GET /api/companies/:companyId/events/stream` evaluates live events
one at a time with serial `channels` and `issues` queries per event per
subscriber and misses creation-time `labels`/`tagLabels` snapshots
during `?label=` filtering, delivering only ~302–373 of 1,000 events
during a 1,000-message burst.
- `headlessChannelsSchemasRoutes` and `headlessQueuesEventsRoutes` sit
behind 64 unrelated `api.use(...)` Express sub-routers (`15%` CPU in
`path-to-regexp` and `router`).

**Proposed behavior**

- Add an online-compatible `CREATE INDEX CONCURRENTLY IF NOT EXISTS
"issues_company_issue_number_idx" ON "issues" USING btree ("company_id",
"issue_number")` migration (`0513_closed_wither.sql`) and compute
`greatest(companies.issue_counter, coalesce((select
max(issues.issue_number) from issues where issues.company_id = $1), 0))
+ count` directly in `UPDATE companies`, preserving exact monotonic
counter floors (including lone backdated imports) via an `O(log N)`
index-only backward probe in a single round-trip.
- Return the existing channel directly in `ensureChannel` when
`allowUpdateExisting` is false, serialize newly created
`HeadlessIssueView` objects in memory, sort tag labels canonically
before `ON CONFLICT DO NOTHING` upserts, and combine
`pg_advisory_xact_lock` + `INSERT INTO board_events` into one SQL
statement.
- Pre-create `createActivityDetailsRedactor(db)` before transactions so
the 2-second `instance_settings` cache applies, prime
`pg_current_xact_id()` on existing `RETURNING` clauses, and skip nested
`db.transaction` savepoints in `persistActivity` when `db` is already a
`PgTransaction` while preserving `databaseWorkContext` attribution.
- Probe `eq(issues.identifier, normalizedUpper)` first so identifier
lookups use `issues_identifier_idx`, project only the 11 required
columns in issue route interceptors, narrow `--as` profile collision
checks to non-terminated company agents with JS `.trim()` +
`deriveAgentUrlKey` parity, and acquire `FOR UPDATE` on comment creation
only when `clientRequestId` or `after` is present.
- Extract `server/src/services/headless-board-event-stream.ts` and stamp
commit-time `kvLabels` and `tagLabels` snapshots onto issue-scoped event
payloads inside `appendBoardEvent`, so `queryBoardEventsAfter`,
`waitForBoardEvent`, and `filterBoardEventsBatchForSubscriber` share a
single stateless `eventMatchesFiltersAndAccess` verdict pipeline without
cross-batch label caches.
- Mount `headlessChannelsSchemasRoutes` and `headlessQueuesEventsRoutes`
right after `headlessIdentityRoutes` with `headlessHeartbeat` wired in
`server/src/app.ts`.

**Measured performance impact**

- `POST /channels/posts` (`c=1`): `226.4` -> `473.1 req/s` (`2.09x`),
p50 `4.27ms` -> `2.05ms`, p99 `6.98ms` -> `3.15ms`
- `POST /channels/posts` (`c=32`, single channel): `346.4` -> `885.5
req/s` (`2.56x`), p50 `91.8ms` -> `35.4ms`
- `POST /channels/posts` (`c=32`, 16 channels + 2 live SSE clients):
`342.4` -> `924.6 req/s` (`2.70x`), p50 `93.3ms` -> `33.2ms`, live SSE
events delivered during run `302` -> `1,000 / 1,000`
- `POST /issues/:id/comments` (`c=32`): `696.2` -> `1,221.6 req/s`
(`1.75x`), p50 `44.9ms` -> `25.3ms`
- Profiled 1,500 mixed messages (`c=32`): heap allocated `2,369 MB` ->
`1,054 MB` (`-55.5%`).

**Breaking changes**

None. All request/response schemas, status codes, idempotency conflict
rules, `after` stale-cursor checks, gapless `board_events.seq` commit
ordering, and private channel/issue revocation rules remain unchanged.

## What Changed

- Added `issues_company_issue_number_idx` in
`packages/db/src/schema/issues.ts`,
`packages/db/src/migrations/0513_closed_wither.sql` (`CREATE INDEX
CONCURRENTLY IF NOT EXISTS`), and `MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`
in `packages/db/src/client.ts`.
- Updated `server/src/services/headless-common.ts`,
`server/src/services/headless-channels.ts`, and
`server/src/services/headless-labels-batch.ts` to compute exact indexed
`MAX(issue_number)` counter floors inside `UPDATE companies`, return
existing channels early in `ensureChannel`, prime transaction XIDs, sort
tag label names before upsert, serialize newly created
`HeadlessIssueView` responses in memory, include `kvLabels` and
`tagLabels` snapshots on creation/ready board events, and combine
`pg_advisory_xact_lock` + `INSERT INTO board_events` into a single
round-trip.
- Updated `server/src/services/activity-log.ts` to accept an optional
pre-built `ActivityDetailsRedactor` and skip nested `db.transaction`
savepoints when `persistActivity` runs on an existing `PgTransaction`
while preserving `databaseWorkContext` attribution.
- Updated `server/src/routes/headless-channels-schemas.ts` to use
`resolveIssueCommentTarget`, pre-create the activity redactor on `db`,
prime transaction XIDs on comment inserts, and lock the parent issue
`FOR UPDATE` only when `clientRequestId` or `after` is supplied.
- Extracted `server/src/services/headless-board-event-stream.ts`
(re-exported from
`server/src/services/headless-events-schedules-interactions.ts`) and
updated `server/src/services/headless-common.ts`,
`server/src/routes/headless-queues-events.ts`, and `server/src/app.ts`
to stamp commit-time `kvLabels` and `tagLabels` snapshots in
`appendBoardEvent`, unify single-event, replay, and batched SSE
filtering without cross-batch label caches, and mount headless routers
early with `headlessHeartbeat`.
- Added regression tests in
`server/src/__tests__/headless-channels-schemas-batch.test.ts` (drifted
`issueCounter` + lone backdated `#95` floor, concurrent tag upserts, and
tab/CJK `--as` profile parity) and
`server/src/__tests__/headless-queues-leases-events.test.ts` (live SSE
burst ordering, cold-cache `?label=urgent` `exists` tag +
`labels.changed` interleaving + unlabeled `comment.posted`, and
immediate private-channel revocation).

## Verification

- `pnpm --filter @paperclipai/db run check:migrations && pnpm --filter
@paperclipai/db exec vitest run src/migration-snapshot-drift.test.ts`
(passed, 0 blocked migrations)
- `cd server && node scripts/typecheck-layers.mjs` (0 errors across all
7 layers)
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/activity-log-responsible-user.test.ts
src/__tests__/headless-channels-schemas-batch.test.ts
src/__tests__/headless-queues-leases-events.test.ts
src/__tests__/headless-task-workflows.test.ts
src/__tests__/experimental-channels-viewer.test.ts` (5 files, 41/41
tests passed)

## Risks

- Low risk. Migration `0513_closed_wither.sql` uses `CREATE INDEX
CONCURRENTLY IF NOT EXISTS` and is registered in
`MIGRATIONS_WITH_TOP_LEVEL_STATEMENTS`, so online rollouts do not block
reads or writes on `issues`. Live SSE micro-batching re-evaluates
channel and issue visibility fresh on every drained batch without
cross-batch permission caching, preserving immediate membership
revocation.

## Model Used

- Google Gemini (Antigravity agentic coding assistant, extended thinking
mode with shell, profiling, and 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-02 01:47:17 +00:00
c59a56883c fix(recovery): leave a board escalation behind a refused workspace writer hold to the released-writer pass (#22103)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The recovery service has an assigned-work sweep. The sweep continues
tasks that stopped without a clear owner.
> - Stranded-work recovery can block a task with a board escalation. The
sweep continues that task when the failed run's cause looks temporary.
> - A setup failure on the task's own workspace writer hold ("The
workspace still has an unfinished writer or save operation.") counts as
temporary. Since #23051, such a failure before provider work stays
eligible for 7 days. The sweep does not read the hold before it
continues the task.
> - Each continuation fails setup on the same hold. Recovery then
escalates the task again, and the sweep continues it again at 2, 4, 8
and 15 minute spacing.
> - The released-writer pass from #21221 already owns this escalation.
It continues the task only when the hold releases.
> - This pull request makes the sweep leave such an escalation to the
released-writer pass while the hold still refuses a start.
> - The benefit is that a held workspace no longer causes a loop of
failed runs and repeated escalations.

## Linked Issues or Issue Description

Refs #21221
Refs #21505
Refs #20273
Refs #23051

**What happened?**
On staging, a task was blocked by stranded-work recovery with a board
escalation. The assigned-work sweep continued it 5 times in 30 minutes.
Each continuation failed during setup with "The workspace still has an
unfinished writer or save operation." (HTTP 409,
`remote_workspace_writer_pending`), before any provider work. Recovery
escalated the task again after each failure. The loop stopped only when
a person cancelled the task. This error group had 45 events on staging,
and releases that already contain #21106, #21136 and #21221 still had
events.

**Expected behavior**
While the task's workspace writer hold still refuses a start, the sweep
must not continue the task. The released-writer pass must continue it
one time, after the hold releases.

**Steps to reproduce**
1. Put a task in `blocked` status with an active
`stranded_assigned_issue` recovery action that the board owns.
2. Set the action's latest run to `setup_failed` with the writer-pending
message and `executionRecovery: { kind: "bootstrap",
providerWorkStarted: false }`.
3. Bind the task to an execution workspace whose remote workspace writer
hold refuses a start (an ended writer run with dirty, unsaved state).
4. Run the assigned-work check for the task. Before this change, the
outcome is `repaired` and a continuation is created. That continuation
fails setup on the same hold.

**Paperclip version or commit**
`master` at 0d3ed4455.

**Deployment mode**
Hosted (cloud sandbox workspaces).

## What Changed

- `server/src/services/recovery/assigned-work-sweep.ts`: For a
board-owned stranded escalation whose latest run failed setup with the
writer-pending message, the sweep reads the bound workspace's writer
hold. When `remoteWorkspaceHoldRefusesStart()` is true,
`continuedBySweep` is false. The sweep then gives the
`left_to_hold_owner` outcome and does not continue the task. When the
hold has released, the sweep continues the task as before.
- `server/src/__tests__/released-writer-escalation.test.ts`: Add a
regression test that reuses this suite's stranded-task fixture (an ended
dirty writer, setup failures before provider work, and a board-owned
stranded escalation). While the hold refuses a start, the assigned-work
check gives `left_to_hold_owner`, the task stays blocked, the board
action stays active, and there is no wake. After the hold releases, the
check gives `repaired` and sends exactly one wake. The earlier version
of this PR put the test in
`failed-continuation-continues-again.test.ts`, which #22831 removed.

## Verification

- `cd server && npx vitest run
src/__tests__/released-writer-escalation.test.ts
src/__tests__/assigned-work-invariant.test.ts`: 61/61 pass on this head.
- The new test fails without the change: the outcome is `repaired`, but
the test expects `left_to_hold_owner`. With the change, the test passes.
- I could not run the full server `tsc` locally, because the sandbox's
memory limit stopped it. CI must confirm typecheck, build and the full
suite on this head.

## Risks

- Low risk. The change applies only to board-owned stranded escalations
whose latest run failed setup with the writer-pending message, and only
while the hold refuses a start.
- The sweep does one extra query (issues joined to execution workspaces)
and one hold read for each matching task. The sweep makes these calls
only when such tasks exist.
- If the hold stays refused for a long time, the task stays blocked
until the released-writer pass continues it. This is the intended owner.
Before this change, the task looped through failed continuations
instead.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use (shell, git, GitHub CLI and connector) 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 (not
needed: no command or documented behavior 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>
2026-12-02 01:36:25 +00:00
Devin FoleyandPaperclip 90bf446ad5 Guard release onboarding with scoped source E2E (#23432)
## Thinking Path

> - Paperclip helps people manage work with AI agents.
> - A release must pass onboarding before it reaches nightly.
> - Onboarding changes already run source browser tests on PRs.
> - The published release smoke used a separate scenario, which could
drift from those tests.
> - That drift blocked the December 1 nightly after onboarding
succeeded.
> - This PR fixes the stale welcome assertion and shares the scenario
between release smoke and relevant PR E2E runs.

## Linked Issues or Issue Description

Refs #23334 and #22259.

**What happened?**

[The December 1 nightly
release](https://github.com/paperclipai/paperclip/actions/runs/46614290688)
failed twice at `The onboarding chat must queue the lead's live
welcome`. PR #23334 changed the welcome to a saved message and a
question card. The greeting endpoint succeeded with `started: true` and
`runId: null`, but the release test still required a model run. PR
browser tests did not run those release expectations against the changed
source.

**Expected behavior**

Onboarding PRs and changes to their shared dependencies must run the
release scenario before merge. Known unrelated leaf-page changes and
source-unit-test-only changes can omit the extra case. Shared and
unfamiliar source paths must keep coverage. The scenario must check the
lead's welcome and all three first-chat choices, with no model run
before the user sends a choice or message. A mismatch must fail the
required `ci / e2e` check.

**Steps to reproduce**

1. Start the Docker onboarding harness with
`PAPERCLIPAI_VERSION=2026.1130.0-canary.873300` and its provider
verification mock.
2. Run the original release smoke test.
3. Observe successful login, setup, hire, and chat entry, followed by a
timeout because the run list stays empty.

**Paperclip version or commit**

Failed release source: `7ce7d99f8af81ae90f97650ef7a8692a86c63a35`.
Published package: `2026.1130.0-canary.873300`.

**Deployment mode**

The release test uses authenticated private Docker mode. The new PR test
uses the existing disposable source E2E instance and provider
verification fixture.

## What Changed

- Check the saved welcome and the three visible choices, then require an
empty agent run list.
- Move the complete wizard, hire, and chat assertions into one shared
onboarding scenario. Keep sign-in in the authenticated release wrapper.
- Add the shared scenario to the normal PR E2E suite. Omit only this
extra case when eligible source changes are confined to the Costs or
Approvals UI page, source unit tests, and audited prose. Shared
components, hooks, libraries, server code, mixed changes, and unfamiliar
source paths keep it. The repository rules require `ci / e2e` before
merge.
- Pass the trusted CI change plan to shard selection and bind it to the
checked-out commit. Reuse the existing lightweight source-diff
eligibility gate for both Vitest and E2E, with the old Vitest export
preserved. Full and shadow CI, broad or deleted inputs, invalid plans,
and stale plans keep the case. No extra browser job or matrix is added.
- Add release smoke files to the E2E and typecheck task inputs. Test
that onboarding changes select E2E and that smoke-only changes select
their two owners without forcing unrelated lanes.
- Document the shared test command and the source and installation
coverage.

## Verification

The shared browser scenario is unchanged from
`2044ada98e953504af68febe4c196f414d0bb1ae`. The selector review fix is
based on master’s hosted-shard speed improvement. Selector and
eligibility verification covers
`236640e419d1177aafb64f3f7dd1ee49848ee707`.

- Reproduced the original nightly timeout locally against the exact
published canary.
- The extracted release scenario passed against that canary in 22.1
seconds.
- The new source E2E passed against PR source and the built UI in 32.3
seconds.
- Restored the obsolete model-run assertion temporarily. The new source
E2E failed with the same `Expected: > 0 / Received: 0` timeout. Restored
the correct assertion. The final source confirmation passed in 31.7
seconds.
- `node --test scripts/__tests__/e2e-shard.test.mjs
.github/scripts/tests/ci-plan.test.mjs
scripts/ci/test-selection-workflow.test.mjs`: all 52 tests passed after
rebase. Coverage includes unrelated changes, relevant dependencies,
rename paths, full/invalid/stale plans, exact CLI shard partitions, and
both hosted shard policies. The unrelated-change and wiring tests failed
before the filter was implemented.
- Regression selection tests failed on `TaskChatComposer.tsx` and shadow
mode before this review fix. They now keep the composer, new-agent
runtime configuration, AI connection components, hooks, libraries, and
mixed source changes.
- The 3 existing source-diff eligibility contract tests passed after
extraction into the shared module.
- `actionlint .github/workflows/pr-trusted.yml` passed.
- `node --test scripts/ci/test-selection-inputs.test.mjs`: 4 tests
passed.
- The Playwright program and focused source scenario typechecks passed.
The test-budget check and `git diff --check` passed.
- The default local source bootstrap could not load the macOS embedded
PostgreSQL binary because its distribution lacked `libzstd.1.dylib`.
Source browser verification used a separate disposable Docker PostgreSQL
16 instance. Linux CI will cover the normal embedded database path.
- Earlier [hosted release
smoke](https://github.com/paperclipai/paperclip/actions/runs/46776940022)
passed both Docker onboarding and Linux background-service onboarding at
the first fix commit. The service job first hit npm package propagation
and passed on retry after publication completed.
- `pnpm verify --explain` requested broader CI coverage because the CI
task inputs changed. The focused checks above passed; the required CI
jobs will provide broad coverage.
- [Final-revision
CI](https://github.com/paperclipai/paperclip/actions/runs/46782167000)
passed on `236640e419d1177aafb64f3f7dd1ee49848ee707`. Both required
aggregates, all 16 browser shards, and all selected typecheck, build,
server, Runner, and canary dry-run jobs passed. [Incremental CI
qualification](https://github.com/paperclipai/paperclip/actions/runs/46782166749)
also passed.
- [The new source onboarding
case](https://github.com/paperclipai/paperclip/actions/runs/46782167000/job/143123174120)
ran on the hosted Linux runner and passed in 20.8 seconds.
- [Greptile
review](https://github.com/paperclipai/paperclip/pull/23432#issuecomment-7330325410)
scored `236640e419d1177aafb64f3f7dd1ee49848ee707` 5/5 and confirmed the
shared-dependency finding is fixed. There are no unresolved review
threads.

## Risks

- This changes test coverage and CI selection. It does not change
application behavior, release permissions, or publication rules.
- The source case stays on for shared and unfamiliar source changes. It
skips only the documented leaf pages and source-unit-test-only edits in
eligible plans. Local full E2E still includes it. Extend exclusions only
after checking that a path cannot affect onboarding.
- The trusted PR workflow is loaded from master. Before merge, the
current workflow keeps the full fallback because it does not yet pass
the change plan to the shard command. The unit and CLI tests qualify the
filtered path; after merge, the new workflow environment activates it.
- The source test uses local trusted authentication. The authenticated
published-package test remains responsible for login and installation
checks. Neither run needs paid model completions.
- GitHub master rules require code-owner approval for the protected CI
changes. Those review requests are already open. There are no conflicts
or unresolved review threads.
- A replacement nightly still needs a successful release run after this
reaches master. This PR does not bypass qualification or promote beta or
stable.

## Model Used

OpenAI Codex, `gpt-6.1-sol`, with xhigh reasoning effort, terminal
tools, GitHub CLI, and Playwright. The harness does not report the
context window size.

## Checklist

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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-01 17:23:13 -08:00
Nicky LeachandPaperclip 54b86a6af2 Allow New Agent sign-in during computer preparation (#23435)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->

## Thinking Path

> - People use Paperclip to set up agents for work.
> - New Agent lets a user connect a provider account.
> - A plugin can host that sign-in on a sandbox or an eligible computer.
> - The form disabled sign-in while the draft agent's computer prepared.
> - This change enables sign-in when its host is ready.
> - The user can connect the account while the task computer prepares.

## Linked Issues or Issue Description

**What happened?**

New Agent disabled the sandbox sign-in controls while the draft computer
prepared. A ready computer in the same task environment could also be
overlooked.

**Expected behavior**

The user can sign in on an eligible host while task preparation runs. A
connection test that uses the draft computer waits for it.

**Steps to reproduce**

Open New Agent with a draft computer in preparation. Select a harness
that supports sandbox sign-in. The login panel opens with its controls
disabled.

**Additional context**

Related to #23425, which added login driver preferences.

## What Changed

- Separate readiness of the Connect step from readiness of the draft
computer.
- Allow the user to request an available computer in the same
environment for sign-in.
- Keep connection tests, keyboard submission of credentials, and setup
completion behind the task computer readiness check.
- Document the behavior and cover both login hosts in the rendered New
Agent flow.

## Verification

- Reproduced the disabled sandbox control and the unavailable fallback
action in failing regression tests. Both passed with the fix.
- The UI typecheck passed. All 18 focused provider sign-in and host
readiness tests passed.
- The selected local UI suite passed 4,152 tests with one skip. The
broader local verification run failed in four CLI test files on macOS.
These included embedded Postgres shared-memory exhaustion, a loopback
expectation on a Tailscale host, and headless-board CLI failures. Final
[GitHub Actions
CI](https://github.com/paperclipai/paperclip/actions/runs/46785144221)
passed.
- Live provider sign-in was outside the scope of this UI test.

## Risks

Low risk. The UI uses the existing company capability response. Core
still checks the selected host when sign-in starts. The change touches
the existing setup components because they own the Connect controls and
the task readiness checks.

> 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

OpenAI Codex (GPT-6) with local code inspection, TypeScript checks, and
test execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [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
- [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-12-02 01:20:17 +00:00
paperclipbugbotandClaude Opus 5.5 64c872e4da fix(opencode): record model traffic when opencode serve is OOM-killed (#23428)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The native Runner starts `opencode serve` for each OpenCode turn and
sends every model request of OpenCode through a local provider proxy.
> - #23372 and #23391 showed that the kernel OOM killer stops `opencode
serve` at the 8 GiB sandbox limit about 50 seconds into light turns, and
that the memory is OpenCode's own resident set (about 7.6 GiB) and
anonymous memory.
> - The retained run log has no raw provider or SSE trace. So we cannot
tell a huge provider response, a loop of model requests, or growth
inside OpenCode on a normal stream from one another.
> - The provider proxy already sees each model request and its response.
It is the cheapest place to measure this.
> - This pull request counts the model traffic in the proxy and reports
the counts when `opencode serve` dies by a signal.
> - The benefit is that the next OOM kill shows which of the three
causes applies, so the fix can target it.

## Linked Issues or Issue Description

Refs #23372 (kernel OOM evidence). Refs #23391 (memory attribution).

**What happened?**
On a cloud sandbox, native OpenCode turns with a fast DeepSeek model
fail with `opencode_server_exited`. The failure record shows
`memoryKill: observed` and `opencodeRssBytes` of about 8.16 GB at the 8
GiB limit. The run log shows no event for about 46 seconds before the
kill. It does not show how much model traffic OpenCode handled in that
time.

**Expected behavior**
When the kernel stops `opencode serve`, the failure record says how many
model requests OpenCode sent, how many bytes the provider returned, and
how large and how old the response was that was still streaming.

**Steps to reproduce**
1. Run a native OpenCode turn through the Runner provider proxy in a
Linux sandbox with a cgroup v2 memory limit.
2. Make the kernel OOM killer stop `opencode serve` while a model
response streams.
3. Read `resultJson.nativeTurnFailure`. Before this change, it has no
model traffic counts.

**Paperclip version or commit**
`master` at fcb8fc5deb.

## What Changed

- New `provider-traffic.ts`: a meter that counts, for one `opencode
serve` launch, model requests, request bytes, completed responses,
response bytes, and the size and age of responses that still stream. It
keeps only numbers. It records no request or response content.
- `startOpenCodeProviderProxy` starts one meter entry for each forwarded
request. It counts response bytes with a pass-through stream in the
existing response pipeline. A request ends as completed only when its
response pipeline finishes. Any other ending counts as interrupted. The
proxy keeps the largest interrupted response's bytes and duration. When
OpenCode dies while it reads a response, its connection closes and that
response ends first, so this keeps the response it was killed on. A
request that the proxy rejects before it calls the provider is not
counted.
- A signal death of `opencode serve` adds these fields to
`opencodeFailure`: `providerRequests`, `providerResponsesCompleted`,
`providerResponsesInterrupted`, `providerRequestBytes`,
`providerResponseBytes`, `providerInflightResponses`,
`providerInflightResponseBytes`, `providerInflightMs`,
`providerInterruptedResponseBytes` and `providerInterruptedMs`.
- `native-provider-failure.ts` keeps the new fields in its closed
vocabulary. Each must be a safe integer that is zero or more. Other
values are dropped.
- `openCodeServerDriverInternals` also exports
`startOpenCodeProviderProxy` for tests.
- This is a diagnostic. It does not change how a turn fails or recovers,
and it does not change any forwarded bytes.

## Verification

- `cd packages/paperclip-runner && npx vitest run
src/drivers/opencode/provider-traffic.test.ts
src/drivers/opencode/provider-traffic-proxy.test.ts`: 6/6 pass.
- The meter tests check completed and in-flight counts, the largest
in-flight response, the oldest in-flight age, and that late bytes, a
repeated end and bad sizes change nothing.
- A meter test checks that a response which ends before it completes
keeps its size and duration.
- The proxy test sends one finished request and one request whose
response still streams through the real proxy to a local fake provider.
It checks the exact request and response byte counts. Then the client
stops reading, as a killed OpenCode does, and the test checks that the
response is reported as interrupted with its byte count. A second test
checks that a rejected request is not counted.
- `cd packages/paperclip-runner && npx vitest run
src/drivers/opencode/opencode-server-driver.test.ts -t "OpenCode stops
mid-turn|classifies a lost event stream"`: 2/2 pass. The SIGKILL test
now expects zero traffic counts, because its fixture does not call the
model.
- `cd server && npx vitest run
src/services/native-runtime/native-provider-failure.test.ts`: 65/65
pass. A new test checks that the counts pass through and that bad values
are dropped.
- A scoped `tsc --noEmit` of the server file shows no errors. `tsc -p
packages/paperclip-runner/tsconfig.json --noEmit` shows no errors in the
changed files.
- These local runs used an older parent commit with the same versions of
the changed code paths. CI runs the full suites on this branch.

## Risks

- Low risk. The counter is a pass-through `Transform` in the existing
response pipeline. It forwards each chunk unchanged and adds its length
to a number.
- The meter keeps one small entry for each in-flight request and removes
it when the request ends.
- Counts are reported only for a signal death of `opencode serve`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code
execution in an 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: Claude Opus 5.5 <noreply@anthropic.com>
canary/v2026.1202.0-canary.878700
2026-12-02 01:19:59 +00:00
Nicky LeachandPaperclip 550d8fc576 feat(plugins): honor harness login driver preferences (#23425)
## Thinking Path

> - People use Paperclip to manage agents and the accounts they use.
> - A harness can sign in on an environment supplied by a plugin.
> - Some plugins offer several environments with different login
requirements.
> - Today the task environment also determines where sign-in runs.
> - This change lets the plugin declare its preferred login drivers.
> - A company can use a temporary environment for sign-in and keep
running tasks on its chosen computer.

## Linked Issues or Issue Description

**Subsystem affected**

Plugin manifests, login target selection, and the harness sign-in UI.

**Current behavior**

A plugin with several environments cannot direct sign-in to a preferred
driver. Selecting an agent computer for tasks can require an agent even
when a temporary environment is available for login.

**Proposed behavior**

Allow the manifest to declare an ordered list of login drivers. Select
the first eligible environment for the company and harness before
starting a login.

**Reason and benefit**

A plugin can offer agentless sign-in first and keep an agent-targeted
computer as a fallback. The choice applies only to sign-in.

**Additional context**

This builds on the agentless login capability in #23392.

## What Changed

- Validate ordered login driver keys in the manifest and expose the
eligible environments to the company.
- Use the same selection rule for device login, setup-token login,
onboarding, agent configuration, and AI Connections.
- Bind the session and lease to the selected environment. Existing agent
eligibility checks apply when the target needs an agent.

## Verification

- Server and UI typechecks passed. Focused Vitest runs covered shared
manifest validation, driver order, the company access boundary, lease
checks, both HTTP login flows, and the UI helpers.
- The public SDK source input registry was regenerated. The registry
change requires broad CI coverage under `pnpm verify`.
- Regression tests cover skipping an environment without an eligible
computer, using a newly prepared draft computer, and holding the
selected host across capability and readiness updates during sign-in.
The UI typecheck and all 16 focused login tests passed on the final
commit.
- No external provider credentials were used.

## Risks

A plugin that opts in must declare at least one usable driver for the
user's harness and company. If none qualifies, the start fails before
acquisition. Manifests that omit the field keep their existing routing.
There is no database migration.

> 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

OpenAI Codex (GPT-6), with local code inspection, TypeScript checks, and
test execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [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-12-01 16:58:28 -08:00