mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 05:47:10 +01:00
18aa2b353daa65058fa26eb05875c9cd98072a82
2557
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b6f1b7b4af |
feat(antigravity): pin and provision the Antigravity CLI route (#22728)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Runner launches native agent harnesses, including Google
Antigravity, from pinned and verified distributions
> - Antigravity's native `/swarm` exists only in Google's Antigravity
CLI (`agy acp`), not in the registry ACP server 1.5.2 that Paperclip
pins today
> - Before a driver can use the CLI, Paperclip needs a pinned, verified
way to install it and to launch exactly those bytes
> - This pull request adds the CLI distribution pin, a setup command and
a launch resolver. It is the first step of a short series. Route
selection, `/swarm` detection and the driver follow in later pull
requests
> - The benefit is that the later driver work starts from a fixed,
digest-checked binary, and the existing Antigravity route does not
change
## Linked Issues or Issue Description
**Subsystem affected**
Runner native provider distributions (`packages/paperclip-runner`) and
the `paperclipai runtime setup` CLI command.
**Problem or motivation**
Google documents `/swarm` for the Antigravity App and the Antigravity
CLI only. The registry ACP server 1.5.2 does not offer it. To make
`/swarm` work, Paperclip must run `agy acp`. The CLI is a signed Go
binary with no patch point, so the owned admission patch cannot apply.
Integrity must come from pinned archive and executable digests. Google
publishes no redistribution licence for the CLI, and the bucket's object
immutability cannot be checked anonymously. So Paperclip must fetch the
CLI from Google at setup time and verify it against digests that are
pinned in the repository.
**Proposed solution**
A sibling declaration, `antigravity-cli-distributions.json`, pins 1.5.15
(build `1.5.15-5514532022517760`) for darwin-arm64, linux-x64 and
linux-arm64. `paperclipai runtime setup antigravity-cli` downloads,
verifies, extracts and installs it beside the existing runtime.
`resolveAntigravityCliLaunch()` returns the launch through the existing
sealed native store.
**Alternatives considered**
- Add the CLI to `antigravity-distributions.json`. That file feeds the
generated profiles, the Rust profile table, release attestations and the
provider pack. A sibling file leaves all of them unchanged.
- Bundle the binary in the provider pack or image. Not cleared: there is
no redistribution licence.
**Roadmap alignment**
This is experimental provider work behind later route selection. It
changes no qualified behavior.
## What Changed
- `packages/paperclip-runner/antigravity-cli-distributions.json`: the
new pin. For each platform it records the Google URL, archive format and
size, archive SHA-512 and SHA-256, the single tar member
(`antigravity`), the executable name (`agy`), the executable SHA-512,
and the closure entry (SHA-256 and size) that the sealed store uses. It
also pins the leading arguments (`acp`) and the environment
`AGY_CLI_DISABLE_AUTO_UPDATE=1`.
- `scripts/materialize-antigravity-cli-distribution.mjs`: reads only the
checked-in declaration and accepts only Google's versioned bucket path.
It enforces the pinned size while it streams the download, refuses
redirects, and checks SHA-512 and SHA-256. It reads a strict one-member
tar (a regular executable, no links, no extra members, zero padding
only) and checks the executable's SHA-256 and SHA-512. It publishes the
directory with an atomic rename. Every failure gives a plain message
that ends "Nothing was installed."
- `scripts/provision-antigravity-cli.mjs`: installs to
`~/.paperclip/runtimes/antigravity-cli/<target>/<closure>`. A re-run
verifies the installed copy in place with no download. A copy that no
longer verifies is retired and replaced from a fresh verified download.
- `scripts/materialize-antigravity-distribution.mjs`: exports its
existing owned-file helpers so the new route reuses them. There is no
behavior change.
- `src/drivers/acpx/antigravity-cli-installation.ts` and
`antigravity-cli-pins.ts`: `resolveAntigravityCliLaunch({ arguments?,
platform?, architecture?, home? })`, exported from the package. It
returns `version`, `build`, `target`, `commandDigest`, the exact
`arguments` (`acp` followed by the driver's), the frozen pinned
`environment`, `environmentFor(base)`, and a `VerifiedAcpxInstallation`
from `verifyNativeAcpxInstallation` (sealed store, per-launch executable
hash, `storeFamily: "antigravity-cli"`). Errors are
`AntigravityCliRuntimeError` with the codes
`ANTIGRAVITY_CLI_UNSUPPORTED_PLATFORM` and
`ANTIGRAVITY_CLI_RUNTIME_MISSING`. Both are permanent. The pins are
compiled in, and a test keeps them equal to the JSON.
- `cli/src/commands/runtime.ts`: adds `paperclipai runtime setup
antigravity-cli` through a small shared resolver and runner for vendored
provisioners.
- The bundle step builds `dist/cli/provision-antigravity-cli.{js,cjs}`
and copies the JSON pin to `dist/`. No binary goes into npm, the
provider pack or an image.
- Docs: a README section on the resolver, and a note in
`doc/plans/2026-11-22-antigravity-qualification.md`. The note says the
CLI route is experimental, is fetched at setup time, and why.
Pinned values (downloaded once from Google into an empty scratch
directory. Each archive matched Google's published manifest. The Linux
binaries were not run):
| Target | Archive URL (under
`https://storage.googleapis.com/antigravity-public/antigravity-cli/1.5.15-5514532022517760/`)
| Archive bytes | Archive SHA-512 | Executable bytes | Executable
SHA-256 |
|---|---|---|---|---|---|
| darwin-arm64 | `darwin-arm/cli_mac_arm64.tar.gz` | 86,166,538 |
`b03a841e…` | 229,617,904 | `8097b24d…` |
| linux-x64 | `linux-x64/cli_linux_x64.tar.gz` | 101,464,790 |
`af3f0be5…` | 273,879,752 | `7b004d26…` |
| linux-arm64 | `linux-arm/cli_linux_arm64.tar.gz` | 92,373,221 |
`d64ad759…` | 256,660,144 | `497580a7…` |
The darwin-arm64 executable matches the copy that was already verified
(Developer ID Application: Google LLC, team `EQHXZ8M8AV`). The full
digests are in the JSON.
## Verification
- Red then green: `node --test
packages/paperclip-runner/scripts/materialize-antigravity-cli-distribution.test.mjs`
(9 tests). It uses in-memory tar.gz fixtures and makes no network calls.
It covers the pins, a refused declaration, tar strictness, a verified
install with an idempotent re-run, a tampered archive, truncation, a
wrong-platform archive, an executable digest mismatch, the size
enforcement and redirect refusal of the download path, the repair of a
modified install, and an unsupported host.
- Red then green: `vitest run
src/drivers/acpx/antigravity-cli-installation.test.ts
src/drivers/acpx/antigravity-cli-pins.test.ts`. The resolver spawns a
fixture `agy` from the sealed store with `acp` plus the driver's
arguments and the pinned environment. It also covers a modified install,
a missing install that names the setup command, an unsupported platform,
and invalid arguments.
- Red then green: `cli` `vitest run src/__tests__/runtime-setup.test.ts
src/__tests__/runtime.test.ts`.
- Existing suites: `vitest run src/drivers/acpx/antigravity*
native-distribution-integrity* candidate-admission.antigravity-release
capability-profiles.antigravity-release` and `node --test
scripts/build-verified-provider-entrypoints.test.mjs` (includes the
registry-server materialize and patch tests),
`acpx-release-attestations`, `release-provider-pack`,
`antigravity-provider-pack-smoke`, `installed-package-pack`,
`candidate-provider-pack`. All pass. Under full parallel load, two
existing timing-sensitive tests (`probe-antigravity-metadata` SIGKILL
shutdown, `antigravity-acpx-runtime` model admission) failed once and
passed when run alone. This change does not touch those modules.
- Typecheck: `tsc --noEmit` for `packages/paperclip-runner` and `cli`.
- Real archives, local: materialize succeeded for all three real
archives against the real pins. The Linux binaries were extracted and
hashed only. The darwin build with a linux-x64 archive failed closed
with "Nothing was installed."
- End to end on macOS ARM64 with a scratch `HOME`: the bundled
`dist/cli/provision-antigravity-cli.cjs` downloaded from Google and
installed in 10.7 s. The re-run printed "Verified" with no download.
`resolveAntigravityCliLaunch({ arguments: ["--help"] })` ran the real
`agy acp --help` from the sealed store copy (exit 0, 1.4 s including
first store admission). `codesign --verify --strict` passes on the
installed copy.
- `pnpm verify` returned exit 2 (the README is a broad input). Required
CI supplies the broad coverage.
- Not run: the Linux binaries (no execution on this Mac), a Linux host
setup, and the full local suite.
## Risks
- Low risk. Nothing selects or launches the CLI route yet. The existing
registry-server pins, the admission patch, profile digests and
`acpx-profiles.json` are unchanged.
- The provider pack and the server's vendored Runner now also carry the
small provisioner script and the JSON pin (no binary), like the existing
Antigravity provisioner.
- Bucket immutability is not proven. If Google replaces an object at the
versioned path, setup fails closed on the digest. It does not install
different bytes.
- macOS code-signature team checks are not added. The repository has no
such hook, and the exact executable digest is a stronger pin.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- Anthropic Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with
tool use (shell, file edits) and extended reasoning.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
37cbad2cd5 |
docs(connections): record the reviewer decision and the live REST results on the staging tester (#22725)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The built-in Google Workspace connector is going through Google approval > - `doc/memory/google-connector-memory.md` holds the decisions and environment state for that work > - On November 23 the six services moved to Paperclip's own REST tools, and the staging tester was tested live against Google > - The doc still says the reviewer destination is undecided and that the REST tools were never run against Google > - This pull request records the decisions, the tester state, the live results and the open items > - The benefit is that the next session starts from the true state ## Linked Issues or Issue Description Refs #22634, #22706, #22714. **What happened?** The working memory and the production checklist are out of date after the work of November 23. **What did you expect to happen?** The docs show the current decisions, the tester state and what is still open. **Steps to reproduce** 1. Read "Still open" and "Environments" in `doc/memory/google-connector-memory.md` on master. 2. Compare them with the merged pull requests of November 23. ## What Changed - `doc/memory/google-connector-memory.md`: four decision rows (reviewers get the staging tester; the recommended security lab; tools refuse unknown arguments; a cancelled sign-in leaves no connection), the tester state, the live results, new open items and new next steps. - `doc/plans/2026-11-17-google-workspace-production-checklist.md`: ticked the reviewer destination and the revoke-at-Google items; noted the lab recommendation. ## Verification - Docs only. No code or tests changed. - Checked that the diff has no client ids, project ids, stack ids, passwords, codes or keys. ## Risks - Low. Docs only. The memory doc is temporary and is deleted when the connector is released. ## Model Used - Anthropic Claude Fable 5.2 (`claude-fable-5-2`), in Claude Code with tool use and browser control. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
506211b917 |
fix(run-logs): archive a finalized log that a later attempt extended (#22709)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Hosted stacks move from a volume to volume-free storage, and the durable-data migration must move every run log first > - Some finalized run logs grew after their size and SHA-256 were recorded, because a later attempt of the same run appended to the same local file > - Both the online and offline migration refused these logs as `legacy_length_or_digest_mismatch`, so the stack could never leave its volume > - This pull request archives such a log when the recorded proof matches a prefix of the file, and names the real corruption case distinctly > - The benefit is that these stacks can move without deleting or hiding any bytes, and real corruption still blocks the move ## Linked Issues or Issue Description **What happened?** Durable-data migration blocks a run log with `legacy_length_or_digest_mismatch` when the local file is longer than the size and SHA-256 recorded at finalize. The run log store never truncates, so a later attempt that shares the run id appends to the finalized file. The stack then cannot move to volume-free storage. **Steps to reproduce** 1. Finalize a run log so that the run records its size and SHA-256. 2. Append more output to the same local file. 3. Run the online or offline durable-data migration. 4. See the log blocked as `legacy_length_or_digest_mismatch`. **Expected behavior** When the recorded size and SHA-256 match a prefix of the file, the migration keeps every current byte, records both proofs, and lets the stack move. When the recorded proof matches no prefix, the log stays blocked under a distinct name. ## What Changed - `server/src/services/run-evidence-migration.ts`: before it claims the object journal, the migration checks if the recorded size and SHA-256 match a prefix of a longer file. If yes, it archives every current byte as a read-only `s3_archive` log in the `<run>.archive` journal. - The publish sets the run's size and SHA-256 to the archived bytes. In the same transaction it writes a `run.historical_log_archived` activity entry with the original prefix proof (`recorded`) and the new size and SHA-256. - A log whose recorded size and SHA-256 match no prefix (a different longer file, a shorter file, or a same-size file with different bytes) stays blocked as `legacy_recorded_log_not_a_prefix`. Nothing is uploaded or published for a longer file that fails the prefix check. - The extended log must come from the local file. A longer mirror copy stays blocked as `mirror_completeness_unproven`, because a matching prefix does not prove that the mirror holds the whole file. - While the run still has a pending or leased attempt (a native finalization with `next_attempt_at`, a lease owner, or a phase other than `committed` or `terminal_failure`), the log stays blocked as `legacy_writer_retry_pending`. The publish `WHERE` rechecks this condition, so a later attempt of the same run never finds a read-only archive. - Both archive publications (settled native history and extended logs) share one helper that publishes and writes the activity entry in one transaction. - `legacy_length_or_digest_mismatch` stays for the other cases: a source that changed while it was read, and a run that recorded only one of size or SHA-256. - The online path (`migrateRunEvidencePage`) and the offline path (`preserveHistoricalFiles`) use the same code, so the rule is the same for both. - `doc/run-evidence-storage.md` describes the new rule. ## Verification - New test `server/src/services/run-evidence-migration-appended.test.ts` uses embedded PostgreSQL, real local files and an in-memory object store: - online and offline: a log with appended output is archived, the run row has the new size and SHA-256, the archive reads back every byte after the local file is deleted, and one activity entry holds both proofs. - online and offline: a longer file, a shorter file and a same-size file whose bytes differ stay blocked as `legacy_recorded_log_not_a_prefix`, keep their local reference, and write no activity. - online and offline: an extended log whose run has a pending attempt stays blocked as `legacy_writer_retry_pending`, unchanged and with no activity. - a longer mirror copy (local file missing) stays blocked as `mirror_completeness_unproven`. - Red: the first 3 tests fail on master (`legacy_length_or_digest_mismatch`). The pending-attempt and mirror tests fail on the first commit. Green: all 5 pass with this change. - `npx vitest run src/services/run-evidence-migration-appended.test.ts src/services/run-evidence-migration-page.test.ts src/services/online-durable-data-migration.test.ts`: 40 passed. - `npx tsc --noEmit -p server`: clean. - I did not run the opt-in S3 integration suite (`run-evidence-migration.integration.test.ts`), because it needs an external S3 endpoint. Its `wrong-digest` case records only a SHA-256, so it keeps `legacy_length_or_digest_mismatch`. ## Risks - An archived log is read-only. This is the same as the existing historical archives. The publish requires a settled run with no writer lease, so no attempt can still be writing. - The prefix check reads the recorded prefix (not the whole file) one more time before the copy. This happens only when the file is longer than the recorded size. It lets a non-prefix file fail before anything is uploaded. - Low risk otherwise: logs whose bytes match their recorded proof follow the same path as before. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge Related: #22697 (archived workspaces whose files are gone) and #22698 (skills whose remote source is gone) settle the other two cases that block the same move. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
bda1bf7b52 |
fix(ci): respect GitHub quota resets during image publication (#22690)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Its image workflow builds immutable images and requires proof for the exact source. > - GitHub API quota failures can stop metadata generation and verification reads. > - Short retries before the quota reset consume requests without restoring progress. > - This pull request removes metadata API reads and makes quota retries respect server timing and job budgets. > - The benefit is fewer API requests and clear quota errors without weakening release proof. ## Linked Issues or Issue Description Refs #22677, which adds conditional requests for unchanged Actions polls. This change retains that cache and extends quota recovery. **What happened?** [Docker run 45215585951](https://github.com/paperclipai/paperclip/actions/runs/45215585951) failed in both Docker metadata steps with an installation API rate-limit error. [Run 45210434846](https://github.com/paperclipai/paperclip/actions/runs/45210434846) built both architectures but failed during source verification reads. The reader retried quota-proven HTTP 403 responses after seconds and then failed with a generic HTTP error. It ignored the primary reset time and could shorten Retry-After below the server requirement. **Expected behavior** Metadata generation should need no GitHub API request. Quota recovery should wait until GitHub permits another request, within the caller deadline. Exhausted budgets should identify the quota failure and safe response-header details. Permission failures must remain immediate. Missing source, migrator, or attestation proof must still block publication. **Steps to reproduce** 1. Return HTTP 403 with zero remaining requests and a reset two minutes away to the Actions reader. 2. Observe the old reader retry after seconds and exhaust its attempts before the reset. 3. Return an hour-long Retry-After value. Observe the old reader retry after its one-minute cap. **Version** Master after #22677. **Deployment mode** GitHub Actions image publication and release verification. ## What Changed - Honor primary reset times and Retry-After seconds or dates. Use a minute-long exponential fallback for secondary throttling without timing headers. - Bound the entire wait by a per-read budget and the caller deadline. Keep permission-denied 403s immediate and preserve ETag caching and transport retries. - Emit a typed quota error with allowlisted token-source, resource, limit, remaining, and reset diagnostics. Do not log tokens, response bodies, or request URLs. - Share the Docker observer's 40-minute deadline with its reader. Bound final proof rechecks to five minutes. Add an explicit `github.token` source hint beside workflow-issued token bindings. - Generate Docker tags and OCI labels from checkout and workflow inputs. Keep release-lane and immutable SHA tags. Feed metadata JSON explicitly to manifest publication. Stop fetching the GitHub repository description; keep local license and migration labels. - Add regression tests and run them in the trusted PR and source-verification workflows. Document retry budgets and metadata inputs. ## Verification - Final acceptance: [CI attempt 3](https://github.com/paperclipai/paperclip/actions/runs/45263398107/attempts/3) succeeded on `302da8c`. All 68 reported checks are complete, with no pending or failing checks. Greptile reviewed that exact commit at 5/5 and both review threads are resolved. The voice timeout recovered without code changes; its earlier cause remains unconfirmed. Prior failures and local reproduction limits remain below. - [CI attempt 2](https://github.com/paperclipai/paperclip/actions/runs/45263398107/attempts/2) recovered the interrupted checks. Its only remaining test failure is server shard 2/12: `voice-session-store.integration.test.ts`, “retains both spoken sides once on the public call task and preserves quarantine,” exceeded 15 seconds on both Vitest attempts. The `ci / verify` failure is its aggregate. The voice test file is byte-identical to master and absent from this PR diff; its cause is not established as an infrastructure fault. A focused local attempt could not start PostgreSQL because the macOS binary lacks `libzstd.1.dylib`; no voice test passed locally. Requesting one bounded retry of the affected shard without code changes; all earlier failures remain recorded here. - The automatic runner-loss retry helper for the current run failed on a GitHub job-log download with HTTP 503 ([helper run 45265762243](https://github.com/paperclipai/paperclip/actions/runs/45265762243)). Once the PR workflow completed, a manual failed-job retry was requested successfully for unchanged head `302da8c`. Retry results remain pending; no interrupted check is treated as passed. - [CI run 45263398107](https://github.com/paperclipai/paperclip/actions/runs/45263398107) on `302da8c` lost 25 jobs during verification. Inspected the logs for these 25 jobs: all 25 contain an explicit runner shutdown signal followed by cancellation, with no additional error records. This includes Rust, browser, general-server, and serialized-server lanes. These are interrupted checks and remain unverified until retried. Greptile reviewed this exact commit at 5/5 with no new findings. - Combined focused release/metadata and PR policy suite: **1,008 tests passed**, zero failures. Command: `node --test scripts/github-actions-rate-limit.test.mjs scripts/docker-image-metadata.test.mjs scripts/cloud-source-verification.test.mjs scripts/cloud-readiness-runner-loss.test.mjs scripts/standard-image-contract.test.mjs scripts/reuse-canary-image.test.mjs scripts/merge-group-image.test.mjs scripts/__tests__/release-verify-workflow.test.mjs .github/scripts/tests/*.test.mjs`. - `pnpm exec vitest run server/src/services/online-durable-data-migration.test.ts --project @paperclipai/server`: **32 tests passed** after incorporating upstream #22686. The final PR diff includes no migration test or runtime change. - In `packages/paperclip-runner`, `pnpm exec vitest run src/drivers/acpx/cursor-mode.test.ts src/drivers/acpx/grok-native-session-options.test.ts --maxWorkers 1`: **26 tests passed**. This local pass does not explain the earlier CI timeouts. - New tests first reproduced ignored primary reset timing, early Retry-After retries, missing service-error waits, and older-checkout failures. CLI tests confirm quota exhaustion produces a safe annotation, no verified output, and no cancellation request. Workflow tests cover neither, either, and both new test files being present. - Initial policy CI failed two assertions that expected the old metadata action and single-file proof test command. Updated them to check both local metadata steps, the full-SHA tag, and all proof tests. Initial Greptile findings about service Retry-After and older checkouts are fixed and resolved. - [CI attempt 1](https://github.com/paperclipai/paperclip/actions/runs/45259240827/attempts/1) lost the Build runner and server shards 1, 7, and 12 within four seconds. Logs explicitly record shutdown signals followed by cancellation; Build reported no compiler error. Runner lane 2/3 hit five-second Cursor and Grok test timeouts. E2E shard 2/8 failed document visibility after outage/reload and the cached-task 404 assertion. Those test failures are not assumed to be infrastructure faults. Their aggregate checks also failed. They remain merge blockers until fresh CI passes. - Server shard 9 also found a deterministic, pre-existing blocker-enumeration test failure. Reproduced it on unchanged base `427d13c38c63`: the source scanner omitted helper-declared blockers. Upstream #22686 fixes that test. Incorporated its version when updating from master and removed the duplicate fix from the final diff. A failed-job retry was accepted after attempt 1 finished; the updated branch now needs fresh CI. - Local setup: filtered frozen-lockfile installation changed no lockfile. Initial server-test startup lacked built plugin SDK output; `pnpm --filter @paperclipai/plugin-sdk ensure-build-deps` supplied it before the passing run. Local tests used macOS and Node 25.6.1; CI checks Linux and its configured Node version. - `pnpm verify` initially could not start because the fresh worktree lacked `cli/node_modules/tsx`. The underlying `node scripts/local-verify.mjs` returned exit 2: workflow changes require broad CI. No full local Vitest or Docker build was run. Required CI supplies broad coverage. - No credentials were changed and no live publication or deployment was requested. CI retries do not authorize image publication or bypass proof. ## Risks - A reset outside the allowed wait still fails closed. Shared repository quota pressure from other workflows can still delay publication. - Attestation and source/migrator proof remain required. This change does not add a privileged token or bypass a check. - OCI labels now use checkout inputs. The remote repository description is omitted; source, revision, version, creation time, license, and schema labels remain available. - Revert this PR to restore the previous reader and metadata action. No database or runtime application changes are required. ## Model Used OpenAI gpt-6.1-sol with xhigh reasoning, through Codex in T3 Code. Used code editing, GitHub log and upstream action-source inspection, and local test execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] This is a CI reliability fix; it does not change planned product scope - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have described the issue in-PR following the bug template - [x] I have not referenced internal or instance-local issues or links - [x] My branch name describes the change - [x] I have run focused tests locally and they pass; the broad verification limitation is recorded - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation - [x] I have considered and documented risks - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
63e6e56407 |
fix(onboarding): disable unsupported browser sign-in (#22695)
## Thinking Path > - Paperclip lets people manage AI agents and connect their AI accounts. > - Onboarding connects the first agent to a provider account. > - Some execution environments cannot start browser sign-in. > - The wizard showed this limitation but left Connect enabled. > - This pull request uses that same state to block Connect and keyboard submission. > - Users get a clear reason and can go back to use an API key or another model. ## Linked Issues or Issue Description **What happened?** Onboarding showed that browser sign-in was unsupported. Connect remained enabled when no saved subscription was available. Repeated clicks could test a connection that the user could not establish. **Expected behavior** Disable Connect and keyboard submission while browser sign-in is unsupported and no saved subscription is available. Show the reason. Keep saved subscriptions and API-key connections usable. **Steps to reproduce** 1. Open the onboarding Connect step in an environment without browser sign-in support. 2. Select Claude or OpenAI with subscription authentication and no saved subscription. 3. Observe the unsupported sign-in notice and press Connect or Cmd/Ctrl+Enter. **Paperclip version or commit** Reproduced in component tests on master at `8ce422e45d0c47ede1c8ea905575b93879c1854b`. **Deployment mode** Authenticated setup with a sandbox provider that reports `supportsLoginPty: false`. Tests use the real wizard with simulated API responses. Related: #19336 fixes shared sign-in actions and retry behavior. #17615 addresses a platform-specific login transport error. This change guards the onboarding submission action when browser sign-in is unavailable. ## What Changed - Use one unsupported sign-in state for the notice and the Connect submission guard. - Block mouse and keyboard submission before connection testing or hiring. - Keep saved subscriptions and API-key authentication available. - Add regressions for Claude, Codex, saved subscriptions, and returning to API-key setup. - Give existing hire tests usable authentication fixtures and document the behavior. ## Verification - Baseline on unchanged master: both unsupported-sign-in regressions fail because Connect is enabled. Both alternate-authentication tests pass. - Patched focused run: 4 tests pass with `pnpm exec vitest run ui/src/components/OnboardingWizard.test.tsx -t 'browser sign-in is unsupported'`. - Full onboarding component group: 290 tests pass across the wizard, step, adapter, and variant suites. - `pnpm -r typecheck` passes for all workspace packages. - `pnpm build` passes for all workspace packages. - `pnpm test:run` stopped in the chat integration shard: 315 passed, 5 failed, 1,633 skipped, and one unhandled error. The failures include `ENFILE: file table overflow` and SQLite database-open errors. The server, packages, and test-runner sources match the base commit. The focused rerun below passes; this full-suite attempt is still not a pass. - Token gates and `git diff --check` pass. - Focused chat-failure check: 67 tests pass, including all five failures, without source changes. Command: `pnpm exec vitest run server/src/__tests__/chat-channels.integration.test.ts -t 'retains HTTP Retry under the endpoint authorization row lock|retries the newer saved github request instead of the failed request after a budget hold' --maxWorkers=1`. This establishes recovery in isolation, not completion of the full local suite. - CI attempt 1: [serialized server suites (1/9)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011142554), [Runner Vitest package (3/3)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011141444), [server tests (7/12)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011143258), and [server tests (9/12)](https://github.com/paperclipai/paperclip/actions/runs/45265381027/job/138011143086) stopped after their runners received shutdown signals. The repository runner-loss workflow retried these jobs once after the attempt completed. The interrupted first-attempt jobs are not passes. - [Automatic CI recovery](https://github.com/paperclipai/paperclip/actions/runs/45268368345) confirmed that all four failed jobs lost their runners and requested their rerun. The initial aggregate `ci / verify` failed because a dependency was cancelled. [CI attempt 2](https://github.com/paperclipai/paperclip/actions/runs/45265381027/attempts/2) passed for `b92ea53b5322e2d32bf8235db96ce94087fffde4`. The current PR has 58 successful checks, 3 skipped checks, no failures or pending checks, and no merge conflicts. - [Greptile review](https://github.com/paperclipai/paperclip/pull/22695#issuecomment-7113951912): 5/5 on `b92ea53b5322e2d32bf8235db96ce94087fffde4`, with no actionable issues. - No live provider sign-in or browser acceptance is claimed. ## Risks - The gate must keep saved credentials usable. Regression tests cover saved subscriptions and API keys. - Authentication and environment capability reads keep their existing behavior. This change adds no API, schema, or deployment-policy changes. ## Model Used - OpenAI `gpt-6.1-sol` through the Codex harness in T3 Code, with xhigh reasoning effort, code execution, and tool use. The harness does not expose the context-window size. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
298026eadc |
fix(ai-connections): reconnect typed auth failures and stop quota retry countdowns (#22692)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Runs preserve typed provider failures so recovery can select the right next action. > - Authentication repair still recognized only older run error codes. Native typed authentication failures could miss the reconnect request. > - A typed exhausted quota with no reset also produced an estimated one-hour admission hold. Waiting cannot repair that account. > - This pull request uses the existing reconnect and validated adoption flow for authentication. It asks for billing and usage repair for typed quota exhaustion without a reset. > - Rate limits and provider-reported resets keep their existing automatic waits. Account authority, saved-work checks, pauses, and approvals keep their existing gates. ## Linked Issues or Issue Description Refs #15110. That open PR classifies the legacy Claude monthly-spend message. This change does not duplicate its adapter parsing or change older untyped quota recovery. Refs #21351. That open PR changes legacy Claude edge-error classification and repeated-failure latching. This change consumes the typed provider category and retains the existing credential-generation checks. **What happened?** A failed run with `providerFailure.category: authentication` and a generic native error code did not create its reconnect request. A typed `quota_exhausted` failure without a reset produced an estimated provider cooldown, although the account needed attention. Recovery's narrow PostgreSQL result projection also omitted typed native provider failures. **Expected behavior** Ask the responsible person to repair the selected account or explicitly adopt a compatible managed connection. Ask for billing and usage repair when an exhausted allowance has no reported reset. Continue to wait automatically for transient rate limits and reported allowance resets. **Steps to reproduce** Use a failed native run with a typed OpenAI authentication error and a generic native error code. The existing reconnect controller should create one card. Use typed `quota_exhausted` evidence with no reset. The task should offer account review and manual Retry, with no invented reset or automatic provider retry. ## What Changed - Recognize typed authentication failures and the reported `provider_invalid_credentials` run code. Reuse the existing controller-only reconnect request, account freshness checks, durable continuation, and explicit legacy adoption. - Retain typed provider failures in the bounded PostgreSQL recovery projection. - Refresh the reviewed SDK public-source pin for the changed shared interruption type with the repository generator. - Keep typed quota exhaustion without a reset out of provider cooldown, bounded retry, and periodic quota-recovery paths. A newer billing refusal supersedes older reset evidence. Classify a startup billing refusal before the remote exit-confirmed retry branch, and prevent the startup planner from falling back to plain backoff. - Add the derived `provider_billing` task action, an account-review link, and a matching Inbox label. Preserve saved-work recovery and current user gates. - Update the connection documentation for these recovery decisions. ## Verification - Red: five server regressions failed on current master for typed authentication, the invalid-credential code, a false quota cooldown, and the missing billing action. The new task notice regression also failed before the repair. - Green: the first focused set passed 241 tests. The final quota/retry/UI set passed 281 tests. The database-backed reconnect set passed seven selected cases for Claude, OpenAI, method switching, and explicit legacy adoption. Sets overlap; these counts are not additive. - Database tests check current account attribution, refreshed credential generations, bounded result projection, and preservation of reported resets. A quota without a reset must not schedule a successor. Two additional startup regressions failed before the startup repair. The repaired startup suites pass all 45 integration cases and 11 focused classification cases. They check a blocked task, billing presentation, no retry deadline, no resumable claim, and preserved retries for rate limits and reported resets. - `pnpm check:token-gates` and `git diff --check` passed. - The earlier [Runner support failure](https://github.com/paperclipai/paperclip/actions/runs/45263306284/job/138003893674) came from a stale reviewed SDK source pin. The same three SDK evidence files failed locally on `cacdb81`. Regenerating the pin from that committed tree made all 59 tests in those files pass. Only the shared `execution-projection.ts` source hash changed; lock and runtime pins remain unchanged. - `pnpm build` and repository-wide `pnpm -r typecheck` passed for the initial change. The authentication/recovery policy set also passed 99 tests. Server typecheck and build also passed for the startup repair at `cacdb81c26988394e11f934d05531bcbb121c7a2`. The full local `pnpm test:run` stopped in chat shard 4/6 with 15 failures: fourteen file/database-open failures during `ENFILE` file-table exhaustion and one retry polling timeout. The failed run also reported an unhandled `ENFILE` error. All 40 selected chat cases, including those 15 failures, passed in a fresh process on `06c14a8`. This does not qualify the full local suite. The complete CI workflow passed on the final head, as recorded below. - Local environment: isolated macOS arm64 checkout and disposable PostgreSQL fixtures. The branch was replayed onto master at `32375d302fbc3a233531674aedefa273adee2d97`; that base change touches an unrelated migration test. - Live provider account repair and the original reported credential failure remain unverified. A read-only operational trace confirmed retained runner checkpoint versions, but the reported runtime string was absent from retained onboarding and run logs as well as current Core and available Cloud source refs. Its producer remains unidentified. - [Trusted PR CI, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/45265943006/attempts/2) completed successfully on `06c14a8cbcf2480eb9d2841bebda3337d4248bd6`, including typecheck, build, Runner, serialized server, general test, and browser suites. The previously cancelled serialized suite passed on that attempt. All 59 commit checks are terminal: 56 succeeded and three conditional checks were skipped. The Snyk commit status also passed. - Greptile completed on `06c14a8cbcf2480eb9d2841bebda3337d4248bd6` with 5/5 and no new findings. Both earlier review threads are resolved. ## Risks - A typed exhausted allowance without a reported reset now requires account repair. Older untyped quota errors retain their existing recovery policy; #15110 remains separate. - Authentication repair must follow the recorded account rather than infer an account from a proxy driver's upstream name. Existing generation checks must still protect newer credentials. - No schema migration or provider replay authority is added. Existing stored runs keep their data. The new task action is derived at read time. - Live recovery of the originally reported incident remains unverified; the operational trace did not locate the reported runtime code. ## Model Used OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort, tool use, code editing, and test execution. The harness does not expose the context-window size. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
8c6e5cbbb8 |
fix(connections): offer Paperclip's Google sign-in on Paperclip Cloud only (#22699)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use Google Workspace through a connection. A connection can
use Paperclip's own Google sign-in ("Connect with Paperclip") or the
customer's own Google OAuth client
> - Paperclip's own Google sign-in goes through the Paperclip Cloud
broker with Paperclip's verified Google client
> - Google's restricted-scope verification and security assessment cover
only the servers that Paperclip operates
> - The owner decided on 2026-11-23: Paperclip's own Google sign-in is
for Paperclip Cloud workspaces only. Self-hosted instances use their own
Google OAuth client
> - This pull request hides and refuses Paperclip's own Google sign-in
on self-hosted instances, keeps saved connections working, and gives
clear guidance
> - The benefit is that restricted-scope Google tokens stay on servers
that Paperclip operates, and self-hosted users always see a path that
works
## Linked Issues or Issue Description
Refs #22635
**What happened?**
A self-hosted Paperclip instance offered "Connect with Paperclip" for
Google Workspace and other Google apps. That sign-in uses Paperclip's
verified Google client. It sends restricted-scope Google tokens to a
server that Paperclip does not operate. A self-hosted instance also
offered Paperclip Cloud enrollment only to use that sign-in.
**What did you expect to happen?**
Paperclip's own Google sign-in is available only on Paperclip Cloud
workspaces. A self-hosted instance shows only "Use your own Google OAuth
app", with a short reason and a link to a setup guide. Saved Google
connections on a self-hosted instance keep working until a sunset date
that the owner sets on the Paperclip Cloud broker. After that date, the
connection tells the user to reconnect with their own Google client.
Paperclip Cloud workspaces do not change.
**Steps to reproduce**
1. Run Paperclip without Paperclip Cloud markers (self-hosted).
2. Turn on the Google Workspace connector in **Settings →
Experimental**.
3. Open **Apps** and choose **Google Workspace** or **Gmail**.
4. Before this change: setup offers "Connect with Paperclip" or asks to
connect the instance to Paperclip Cloud first.
## What Changed
- `packages/shared/src/google-sign-in-deployment.ts`: new
`appDefinitionForDeployment` and `isCloudOnlyConnectionMethod`. On a
self-hosted instance they remove every Paperclip-managed Google method.
Other providers do not change. New shared message
`GOOGLE_SIGN_IN_CLOUD_ONLY_MESSAGE`.
- `server/src/services/google-sign-in-availability.ts`:
`paperclipGoogleSignInAvailable()` returns `isCloudManagedInstance()`.
This is the existing single Cloud check. No new environment variable.
- `appWithPaperclipCloudConnectorAvailability` (gallery and setup
validation) uses that check. A self-hosted gallery and setup do not show
managed Google methods.
- `authorization-start.ts`: a self-hosted instance refuses to start a
managed Google authorization before it calls Paperclip Cloud (`422`,
code `google_sign_in_cloud_only`). A broker refusal with
`PROVIDER_CLOUD_ONLY` maps to the same message, also on a Cloud
instance.
- `paperclip-cloud-connector.ts`: `PROVIDER_CLOUD_ONLY` is a known
broker reason.
- `grant-refresh.ts`: when the broker refuses a refresh with
`PROVIDER_CLOUD_ONLY` (after the sunset), the grant is marked for
reconnection. The error keeps code `oauth_reauthorization_required`,
adds reason `google_sign_in_cloud_only`, and tells the user to reconnect
with their own Google OAuth client.
- `ConnectionSetupFlow.tsx`: on a self-hosted instance (no `cloud` block
in health), Google setup uses the filtered definition. It never shows
Cloud enrollment for Google. The customer-owned Google client step shows
this note and a link to Google's client guide.
- Docs: `doc/connections/GOOGLE-WORKSPACE.md` ("Who can use Paperclip's
Google sign-in", "Self-hosted instances: use your own Google client")
and a dated decision row in `doc/memory/google-connector-memory.md`.
- `tests/runner-e2e/source-sdk-public-inputs.json`: pins the new shared
files (generated).
## Verification
- Red first, then green:
- `packages/shared/src/google-sign-in-deployment.test.ts` fails without
the new module and passes with it (4 tests).
- With the source files from `origin/master`, these new tests fail: 2 in
`server/src/__tests__/tool-access-service.test.ts` (self-hosted refusal,
refresh guidance and saved-connection refresh; broker refusal mapping),
3 in `server/src/services/paperclip-cloud-connector.test.ts`, and the
self-hosted test in `ui/src/pages/apps/AppsConnect.test.tsx`. With the
change they pass.
- Cloud path proof: "never shows the self-hosted Google notice on
Paperclip Cloud" (UI), "leaves every app unchanged on Paperclip Cloud"
(shared, identity check on every definition), "decides Cloud or
self-hosted from the instance's Cloud markers" (server). All existing
managed Google service tests (515) pass in a Cloud context.
- `npx vitest run src/__tests__/tool-access-service.test.ts` (server):
517 passed.
- `npx vitest run src/services/paperclip-cloud-connector.test.ts`
(server): 71 passed.
- `npx vitest run src/pages/apps/AppsConnect.test.tsx
src/features/connections` (ui): all passed.
- `npx vitest run` for `agent-connection-catalog.integration`,
`tool-gateway-service`, `google-access-removal`,
`connection-management.integration`, `generic-mcp-connection`,
`remote-mcp-connectors` and `plugin-connectors-circleback-parity`
(server): 446 passed, 1 skipped.
- `npx vitest run` in `packages/shared`: 1383 passed.
- `pnpm verify` exits 2 because `doc/connections/GOOGLE-WORKSPACE.md` is
a global CI input. Required CI supplies the broad coverage.
- Not run: no requests to staging, production, or Google. The reconnect
of a saved managed Google connection on a self-hosted instance after the
sunset was not run end to end in a browser.
## Risks
- Behavior change for self-hosted instances: new Paperclip-managed
Google connections stop. Saved ones keep refreshing until the broker
sunset (not set yet).
- The decision uses `isCloudManagedInstance()`. If a Cloud workspace
does not have its Cloud markers, it shows the self-hosted path. Cloud
stacks always have the tenant token, so the risk is low.
- Works with old and new brokers. An old broker does not refuse. The app
check still hides and refuses the method. A new broker refuses
self-hosted instances, and the app maps the refusal to the same
guidance.
- Deploy order: the broker change (paperclip-cloud) and this change can
deploy in any order.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, test runs).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
a00e31967b |
feat(connections): live setup progress from the person's own agent (#22626)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Several setup screens offer "Set it up with your agent": a prompt the person pastes into their own agent (Claude Code, Codex) to do the setup on their computer. AWS role setup is the newest > - Once the prompt is copied, the setup page goes quiet: the person cannot see what their agent is doing or when it is done, and has to switch windows to find out > - The agent already runs commands, so it can report its progress back if we give it a safe place to send it > - This pull request adds a live checklist the agent fills in: the page creates it, the prompt gives the agent curl commands with a token, and the page shows every update as it happens > - The benefit is a setup that shows its own progress, and a reusable piece any "Set it up with your agent" screen can use ## Linked Issues or Issue Description Refs #22233 (the AWS setup screen this extends). **Subsystem affected** Connections (agent-guided setup), live updates, a new public agent API, UI. **Problem or motivation** After a person copies a setup prompt into their own agent, Paperclip shows nothing until they come back and paste a result. There is no way for the agent to say what it is doing. **Proposed solution** A setup checklist a person's own agent writes to, shown live on the setup page. The agent's requests need no Paperclip sign-in, so they carry a narrow, expiring bearer token. Paperclip Cloud needs no front-door change: it already forwards `/api` requests that carry an `Authorization` header to the workspace without Cloud identity (its machine-request lane), and these always do. **Alternatives considered** - Polling the page instead of live events: slower and adds load to every open setup page. The page uses the existing live-event channel, with a 20-second backup refresh while the agent works. - Putting the token in the URL: URLs end up in logs. The token goes in the `Authorization` header. - Letting the agent set the role ARN itself: the person still pastes it (as decided for #22233). The agent's finish summary shows the ARN to copy. ## What Changed - `packages/db`: new `agent_setup_progress` table (company-scoped, purpose and subject, token hash, items, status, summary, update count, expiry). Migration `0501` is idempotent. - `packages/shared`: `agent-setup-progress` types, limits and validators; new live event type `agent_setup_progress.updated`. - `server`: - `agentSetupProgressService`: create (random `pcsp_` token, only its SHA-256 kept), read, and the agent's set-checklist, update-item and finish. Tokens are compared in constant time; a write is refused after expiry (6 hours) or 300 updates, and concurrent writes are guarded by the update counter. Finishing `done` ticks off open steps. - Routes: board-only `POST /api/companies/{companyId}/agent-setup-progress` and `GET /api/agent-setup-progress/{id}`; agent routes `PUT …/checklist`, `POST …/items/{key}` and `POST …/finish` mounted with the other public routes. Activity entries for created, started and finished. - Each agent write publishes `agent_setup_progress.updated`; the live-events socket forwards it with only the checklist ID. - OpenAPI entries for all five routes. - `ui`: - Reusable `ui/src/components/AgentSetupProgress.tsx`: `useAgentSetupProgress` (creates one checklist per setup and follows it), `agentSetupProgressInstructions` (the prompt section with the agent's curl commands) and `AgentSetupProgressPanel` (waiting, working, done and failed states, using the task status glyphs). - `LiveUpdatesProvider` refreshes the checklist on its live event. - AWS role step: one step (no numbering) with the prompt, the live checklist and the Role ARN field. The prompt starts with the progress instructions and asks the agent to put the role ARN in its finish summary. - Docs: `docs/api/agent-setup-progress.md` (API and how to add it to another page) and the AWS setup section. - Storybook: AWS step in waiting, working, done and failed states, and the panel on its own. ## Verification - `server/src/__tests__/agent-setup-progress.test.ts` (real routes, embedded Postgres): set, update and finish with the prompt's token; only the hash is stored; four live events carry the checklist ID; activity entries. Refusals: missing token, wrong token, another checklist's token (401), bad key (400), unknown item (404), update limit (429), expired (410). Company boundary: another company's member gets 403 on read and create. - `live-events-toast.test.ts`: the socket delivers the event with only `{ progressId }`. It failed before the socket fix (red/green), which an end-to-end run found. - `AgentSetupProgress.test.tsx`: the prompt section's exact commands; the hook creates one checklist and the panel follows waiting → working → done on live refreshes. - `AwsRoleSetup.test.tsx`: the step creates the checklist for its connection, waits for the agent, and the prompt leads with progress reporting. - Totals: shared 1362, server (new, OpenAPI, live events, AWS) 101, UI (components, connections, apps, live updates) 1469. Typecheck clean for db, shared, server and UI (except Storybook's generated catalog, not built in this worktree). - End to end on a local instance: Playwright opened the real AWS setup step, read the prompt, sent the agent's requests with its token, and the page showed each update within 1.5 seconds (inside the 20-second backup refresh, so from live events) through "Your agent set up AWS" with the role ARN summary. No page errors. - Not run yet: Paperclip Cloud staging (after deploy) and an agent running the prompt on its own. ## Risks - New anonymous routes. The token is the only credential: 32 random bytes, stored as a hash, scoped to one checklist, six hours, 300 updates. Text from the agent is shown as plain text (no links or markup), so the worst a leaked token can do is change one checklist's wording until it expires. - One new table and migration (idempotent). - Live delivery is per server process, like every other live event; the 20-second refresh covers a missed event. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, Storybook and Playwright screenshots, the in-app browser against a local dev server). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
ec8c1d2102 |
docs(antigravity): record that /swarm is not available over the 1.5.2 ACP server (#22700)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip runs Google Antigravity through Google's ACP server, pinned at 1.5.2 > - Google Antigravity has a `/swarm` command that runs a coordinator, workers and a verifier > - The qualification plan said only that the ACP layer has no "Orchestrator mode", which mixes two features > - This pull request records what `/swarm` is, that the pinned server does not offer it, and what Paperclip does with it > - The benefit is that the owner can decide how to support `/swarm` from facts, not from a guess ## Linked Issues or Issue Description **What is the issue?** The Antigravity qualification plan does not say whether `/swarm` works through Paperclip. It names only "Orchestrator mode", which is a different feature. **Where is it?** `doc/plans/2026-11-22-antigravity-qualification.md`. **What should it say?** It should separate the Orchestrator model from the `/swarm` command. It should record the upstream facts, the live server advertisement, the result of a live `/swarm` task, and the options for support. Refs #22591 ## What Changed - Add a "Swarm (`/swarm`) and Orchestrator" section with upstream facts and sources ([Swarm](https://antigravity.google/docs/swarm), [Slash commands](https://antigravity.google/docs/slash-commands)). - Record the live 1.5.2 advertisement: commands `plan`, `logout`, `usage`; modes `default`, `auto_edit`, `yolo`; config options `model`, `thinking_level`, `mode`. - Record that the bundled SDK has no swarm slash command and no swarm tools, so `/swarm` reaches the model as plain text. - Record the local `/swarm` task result: the agent hired three agents and made three subtasks with Paperclip tools. No native swarm started. - Add a ledger row for `/swarm` and an entry in the excluded list. - Replace the "Orchestrator mode" open decision with options and a recommendation for `/swarm`. ## Verification - `pnpm verify`: no product inputs changed; passed. - Live probe of the installed 1.5.2 closure (`1.5.2-paperclip.2`, darwin-arm64): `initialize`, `authenticate` (`gemini-api-key`) and `session/new`. The probe captured the advertisement above. - One live `/swarm` task on a local instance (Gemini 3.8 Flash, Google sign-in). The parent task finished after five successful runs across four agents. ## Risks - Low risk. The change is documentation only. - `agy acp` (the Antigravity CLI ACP server) is not verified. The text says so. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [ ] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8957941656 |
fix(ui): keep AI accounts compatible with harness selection (#22691)
Clear incompatible managed AI accounts when a saved agent changes harness. Filter account choices by saved routing metadata and the selected model. Keep supported Pi accounts before model selection and preserve heartbeat and debug edits in connection saves. Make managed OpenCode and Pi accounts optional. Preserve harness sign-in through setup saves and reopening. Put Connect beside missing-default errors and cover managed versus host-auth model selection. Supersedes #17411. Fixes #14078. Co-Authored-By: Luri Darmawan <luri@carik.id> Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
92cf446fb6 |
fix(native): keep an accepted finish as the outcome after a transient provider refusal (#22676)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Native harness runs end with a result from the agent's finish tool
and a provider terminal
> - A provider can refuse a later request in the same turn after the
finish was accepted (Antigravity 1.5.2 streams its final reply after the
finish)
> - Paperclip counted that run as failed and retried it, so the agent
did the work again and posted the same reply again
> - The product rule is that recovery is automatic and that finished
work is never repeated visibly
> - This pull request makes an accepted done report the run's outcome
when the only later failure is a transient provider refusal (capacity or
rate limit), for every native harness
> - The benefit is one reply per task and no retry for work that is
already done
## Linked Issues or Issue Description
**What happened?**
In a local run of Google Antigravity 1.5.2 (Google sign-in,
`gemini-3.8-flash-low`), Google refused 10 of 17 runs with 503 "No
capacity available". In two runs the agent's finish was already accepted
when the refusal came. Paperclip failed those runs and scheduled the
capacity retry. One task got the same answer three times.
**Expected behavior**
When the agent's done report was accepted and the only later failure is
a transient provider refusal, the run succeeds, the task closes as for
any done report, and no retry starts. A real failure (model not
available, exhausted allowance, rejected sign-in, untyped failure,
cancelled run, no accepted finish) stays a failure.
**Steps to reproduce**
1. Run a native task whose finish tool is accepted.
2. Make the provider fail the same turn afterwards with a typed
`overloaded` or `rate_limit` failure (or Codex `serverOverloaded`).
3. See that the run fails and a capacity retry is scheduled.
**Agent adapter(s) involved**
Not adapter-specific (core bug). Observed with Google Antigravity; the
same path applies to Codex and other native harnesses.
## What Changed
- `native-provider-failure.ts`: the rule
`nativeAcceptedResultOutlivesProviderFailure`. It reads only the
committed terminal and its typed failure. It is true only for a failed
turn with an accepted `done` report and a transient `overloaded` or
`rate_limit` failure (or the classified Codex overload). Other accepted
dispositions keep the bounded capacity retry.
- `native-accepted-outcome.ts` (new): the decision is made once, when
`PaperclipControlPlanePort.completeRun` accepts the result, and saved as
`acceptedOutcome` beside the raw terminal in
`native_run_results.result_json`. The raw terminal does not change,
because it is part of the accepted result's integrity digest. No
migration: the field is optional JSON, and a row saved by an older
release keeps its raw terminal as before.
- Every reader of the run outcome uses that saved value: the executor's
adapter result, the finalizer, the projection repair pass
(`native-run-projection.ts`, also in SQL), accepted-result settlement,
and the run's saved `prpRunTerminalState` (read by the exhausted and
superseded finalization paths).
- The run records a closed diagnostic
`providerFailureAfterAcceptedResult: { provider, category }` and no
provider text. Its warm provider session stays open
(`nativeRetainsWarmSession`): the refusal came from the remote model
service and the turn ended cleanly, so closing it would only cold-start
the next message.
- `doc/plans/2026-11-22-antigravity-qualification.md`: records the first
completed prompts on 1.5.2 and the open decisions below.
## Verification
-
`server/src/services/native-runtime/native-provider-overload.integration.test.ts`
(embedded Postgres, executor and finalizer, replayed twice):
- New: accepted finish, then a typed capacity refusal, a typed rate
limit, or Codex `serverOverloaded`: the run succeeds, the task is done,
no successor run, no failure report. Red before the fix (3 failed),
green after.
- New: after the finalizer commits, a restart that leaves the run
`running` is settled by the projection repair pass as succeeded, with no
failure report; the saved `prpRunTerminalState` is `succeeded`. Red
before the stored outcome (projection flipped the run to failed).
- New: a row saved without the accepted outcome (older release) stays
failed through finalizer and projection.
- New guards: accepted finish, then model unavailable, exhausted
allowance, rejected sign-in or an untyped failure: the run still fails
and the task is not done.
- Existing capacity-retry cases (accepted `needs_review` result) still
retry after one and two minutes, then block.
- `server/src/services/native-runtime/native-provider-failure.test.ts`:
new unit cases with the real Antigravity observation (503 and 429
outlive the finish; model, quota, sign-in, unknown retryability,
timeout, `needs_review` and cancelled do not). 70/70 pass.
- `tsc --noEmit` for `server`: clean.
- 40 neighbouring test files that import the port, projection,
settlement or finalizer: 4,193 passed, 10 failed. The same 10 fail with
the base source (missing local bundled skill file and a runnerd fixture
directory), so they are local-environment failures.
- `pnpm verify` selected 2,980 of 3,857 test files (core native-runtime
modules changed), which is a full-suite run. I stopped it after its
first group (4 files, 85 tests) passed and left the broad suite to
required CI, as AGENTS.md section 7 says.
- Not run live: the fixed behavior has not been re-run against Google.
The evidence came from a local instance before this change. Daytona and
the API-key route were not run.
## Risks
- Behavior change for every native harness: a failed turn with an
accepted done report and a transient refusal now ends as success. A done
report still goes through the same completion policy, deliverable
evidence check and review stages as any done report.
- A run whose result was saved by the previous release and finalized by
this one keeps its raw failed terminal (old behavior), consistently in
the finalizer and the projection (tested).
- Not fixed here, open for an owner decision:
- A capacity refusal before any accepted result takes the saved-work
replacement path (about 30 s, task shown as blocked meanwhile). One
after an accepted result takes the bounded capacity retry. The
Antigravity classifier already types both as `overloaded`/`transient`;
the split is by path. Moving the first kind to the capacity retry skips
the replacement's stop proof and unconfirmed-action check.
- Antigravity 1.5.2 streams the provider's error text as agent text
before it ends the turn, so the live transcript shows it like a reply. A
fix belongs in the runner driver.
- Follow-ups seen in the same evidence, not fixed here: the finish tool
once refused a reply that cited a workspace-only file before the agent
registered a deliverable.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits, local test runs).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
0aaf946227 |
fix(connections): keep retrying when Google does not confirm a revoked grant (#22669)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Cloud can manage the Google sign-in for a Google Workspace connection. The app keeps the refresh token. Cloud keeps no token. > - When a user removes the connection, the app asks Cloud to end the access at Google (#22065). > - Before this change, the app deleted the token after that call, whatever Cloud answered. If Google or Cloud could not be reached, the access stayed open at Google, and no retry was possible. > - The owner decided on 2026-11-23: the app keeps the token in a pending record and retries until Google answers. Cloud still never stores a provider token. > - This pull request adds that pending record and a background retry. It also covers company deletion and a Cloud-removed instance. > - The benefit is that a removed Google connection does not keep access at Google because of a short outage, and the user does not need to do anything. ## Linked Issues or Issue Description Refs #22065 **What happened?** A managed Google connection was removed while Paperclip Cloud or Google was unavailable. The removal result was `not_ended`, and the refresh token was deleted. Paperclip could not try again, so Google access stayed open. **What did you expect?** Paperclip keeps the token only for the retry, and retries automatically until Google confirms or gives a final answer. The user sees that Paperclip keeps trying, and does not need to act. **Steps to reproduce** 1. Connect Gmail through Paperclip Cloud. 2. Make the broker revoke fail (Cloud unavailable, or Google 5xx). 3. Remove the connection. The token is deleted and nothing retries. ## What Changed - New table `google_pending_revocations` (migration `0502`, additive, `CREATE TABLE` only). It has `company_id` with no foreign key, so a row outlives a deleted company. It stores the token as the same `local_encrypted` material as the connection secret version. It never stores plaintext. It is not a company secret: it is not listed, an agent cannot bind it, and no route reads it. - `google-access-removal.ts`: before the broker call, the app copies the sent token version into a pending row (lease 2 minutes, so a restart during the call resumes). A final outcome deletes the row. A retryable outcome (`provider_revocation_failed`, `revocation_in_progress`, `broker_unavailable`, `broker_error`, `unexpected_error`) keeps it, and the result is the new `retrying`. If the connection secret is still live after the conditional delete (for example, the user signed in again during the call), the row is deleted. - New worker on the `google-pending-revocation` delivery queue (`registerDeadlineWork`; it registers the real next deadline and has no deadline when the table is empty). Each attempt takes a lease on the row and calls the broker with a 15-second timeout. Backoff is 1, 2, 4 ... minutes, up to 6 hours. The hard stop is 30 days. The worker stops without a call if a live company secret holds the same token. - When a retry ends, the worker writes a `connection.google_access_retry` audit event and a `tool_connection.google_access_ended` or `tool_connection.google_access_not_ended` activity entry (labels added to the activity feed). For a deleted company, it writes only a log line. - Company deletion queues every managed Google token of the company inside the delete transaction, before the secrets are deleted (`reason = company_deleted`). - When the Cloud connection status check finds the instance `removed`, the app queues every managed Google token (`reason = instance_removed`), then deletes each connection secret. - `ManagedGoogleAccessRemoval.result` gets `retrying` (shared type and OpenAPI schema). The removal message for `retrying`: "Google didn't confirm that Paperclip's access has ended yet. Paperclip will keep trying automatically." It has no link and asks for no action. - Docs: `doc/connections/GOOGLE-WORKSPACE.md` ("Pending revocation"), `docs/api/tool-connections.md`, the help page `docs/guides/board-operator/deleting-connection-data.md`, and a dated decision row in `doc/memory/google-connector-memory.md`. - `tests/runner-e2e/source-sdk-public-inputs.json` refreshed for the changed shared type, as `pnpm verify` asks. ## Verification - `npx vitest run src/__tests__/google-managed-connection-removal.test.ts` (embedded Postgres): 46 pass. Without the fix, 15 fail (red), with the fix all pass (green). New cases: - an unconfirmed token is kept only in the pending row, encrypted, not in the secrets list; the worker retries and deletes the row when Google confirms; audit and activity are written; - the row exists during the broker call, so a fresh worker after a restart revokes it; - `binding_not_known`, `other_connections_remain` and `provider_revocation_disabled` stop the retry; - backoff 1 minute to 6 hours, and give-up at 30 days with a final audit and activity entry; - a live secret with the same token stops the retry without a call; - an older broker's `403 INSTANCE_SUSPENDED` is retried; - company deletion queues the token and the worker revokes it after the company is gone; - a removed instance queues every token, drops the secrets, does not queue again, and the worker revokes. - `npx vitest run src/__tests__/paperclip-cloud-connector-status.test.ts`: the removed-instance hook runs only for `removed`, and a failure does not change the status. - `ui`: `npx vitest run src/features/connections/googleAccessRemoval.test.ts` (7 pass, the new `retrying` case is red without the change). - Also passed: `tool-connection-content-deletion`, its canary, `delivery-work-coordinator`, `idle-local-work`, `packages/db` tests; `server` `tsc --noEmit`. - `pnpm verify` exits 2 (global doc input changed), so required CI supplies the broad coverage. - Not verified: any call to a real broker or to Google. No request was sent to staging, production or Google. ## Risks - Migration is additive (`CREATE TABLE` and indexes on the new table): `online_compatible`. - Paperclip now holds an encrypted token for at most 30 days after removal when Google did not confirm. The token is never usable for tool calls: no grant or connection refers to the row. - Instance removal deletes the managed Google connection secrets. Those connections then need a reconnect after a new enrollment. They could not refresh anyway, because Cloud refuses a removed instance. - Deploy order: either order is safe. With the current production broker, a removed instance's revoke gets `403` and the app retries until the hard stop. The Cloud broker change that accepts it is a separate PR in the private Cloud repository. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) through Claude Code, with tool use (shell, file edits, embedded Postgres tests), standard reasoning. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4434d12e2f |
fix(setup-token): back off cleanup retries after failed sweeps (#19446)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A setup-token login keeps a durable cleanup record. The setup-token reaper releases its provider lease and removes the record > - A sweep that fails keeps the record and retries on the next 30-second tick, for as long as the failure lasts > - During a provider outage, that is a steady stream of provider calls and log lines with no recovery benefit > - This pull request backs off consecutive failed sweeps from 30 seconds to 30 minutes and resets after a successful sweep > - The benefit is less load and log noise during outages, with the same recovery once the provider is back ## Linked Issues or Issue Description Refs #14777 (fixed by #15200 and #22667; this pull request adds the retry backoff that the report also asked about). This pull request was rebased onto `master` and reduced to the backoff. #15200 already makes a blank lease lookup return null, and #22667 already logs the failure class and code and covers a restart with a PostgreSQL test. The earlier redacted-message logging is removed, because the reaper now logs no error message. **What happened?** When a setup-token cleanup sweep fails, for example because the sandbox provider is down, the cleanup worker retries every 30 seconds until the failure ends. Each retry calls the provider again and logs again. **Expected behavior** Repeated failures back off. A successful sweep returns to the normal interval. **Steps to reproduce** 1. Make `releaseById` fail for a reapable setup-token record. 2. Watch the setup-token cleanup worker. It retries the release every 30 seconds without a limit. ## What Changed - `setup-token-reaper.ts`: count consecutive failed sweeps (a sweep with a failed record, or a sweep that throws). `retryDelayMs()` returns 30 s, 60 s, 120 s and so on up to 30 min, and 0 after a successful sweep. - `login-cleanup-work.ts` and `index.ts`: the setup-token cleanup duty passes `retryDelayMs` to the shared scheduler. The next run waits for the larger of the configured interval and the backoff delay. - `setup-token-session.ts`: skip the provider call for a reapable record with no lease id and remove the record directly. - `index.ts`: the sweep log line says "cleared records", because a record without a lease is cleared with no release. - `setup-token-session.ts`: the failure log line says "a cleanup failed", because a failure can now come from removing the record as well as from the provider release. - `doc/heartbeat-internals.md`: document the retry behavior. - Tests: backoff to the cap and reset (`setup-token-reaper.test.ts`), backoff after a thrown sweep, removal of records without a lease, and the scheduler honoring the backoff across notifications for both a sweep with failed records and a sweep that throws (`login-cleanup-work.test.ts`). ## Verification - `pnpm exec vitest run server/src/services/setup-token-reaper.test.ts server/src/__tests__/login-cleanup-work.test.ts server/src/services/setup-token-session.test.ts`: 3 files, 98 tests passed. - The seven new tests fail without the source changes. - `pnpm --filter @paperclipai/server typecheck` passes. ## Risks - The backoff applies to the whole setup-token cleanup worker. While one record keeps failing, new cleanup can wait up to 30 minutes. Records stay in the database, so nothing is lost. - The failure count lives in memory and resets on restart. The retained rows rebuild the cleanup work. ## Model Used - Original change by the pull request author. Rebased and reduced by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with shell, file edit, and code execution tools. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
2821af0b52 |
fix(db): fail PR CI on a requires_staging migration without an override (#22628)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip Cloud deploys a new release while the previous release still serves the same database > - Core classifies every new migration as `online_compatible`, `requires_staging`, or `unknown`, and the pull-request guard checks the migrations a PR adds > - The guard fails an `unknown` migration without an override, but it only prints a notice for a `requires_staging` migration > - A `requires_staging` release is refused by every stack that serves two releases at once, so continuous deploy stalls until somebody runs a maintenance deploy > - This pull request makes the guard fail a `requires_staging` migration unless the file carries a justified `requires_staging` override > - The benefit is that a migration that forces a maintenance window cannot merge by accident. The author must split it or accept the maintenance deploy in writing. ## Linked Issues or Issue Description Refs #20913 (the classifier and the guard). Refs #22513 (the migration that stalled deploys). **What existing behavior does this improve?** The pull-request migration guard in `packages/db/src/migration-compatibility.ts` and `.github/scripts/check-pr-migration-order.mjs`. **Current behavior** A new migration classified `requires_staging` passes the guard with a `::notice`. Nothing stops it from merging. Stacks that deploy with overlap then refuse the release. **Proposed behavior** A new `requires_staging` migration fails the guard unless the file starts with `-- paperclip:migration-compat requires_staging: <justification>`. The error lists the reasons and tells the author to split the migration into expand and contract steps, or to add the override and accept a maintenance deploy. A justified override passes with a notice that says the release ships with a maintenance deploy. **Reason and benefit** On 2026-11-22 a `requires_staging` migration merged. Continuous deploy to the overlap-deploy staging stacks stalled for about 4.5 hours, and a manual maintenance deploy took 38 stacks offline for a median of about 2.5 minutes each. An explicit decision in the migration file makes this cost visible at review time. **Breaking changes** None for existing migrations. The guard judges only the migrations that a PR adds. A PR that adds a `requires_staging` migration must now add the override or split the migration. ## What Changed - `checkNewMigrationCompatibility` returns an error for a `requires_staging` migration without an override. The error lists the `requires_staging` and `unknown` reasons and the two ways forward. - A `requires_staging` migration with a valid override passes with a notice. It reuses the existing in-file directive and its minimum justification length. There is no new mechanism. - `doc/DATABASE.md` ("Migration compatibility with the running release") says that `requires_staging` fails the PR and when to use the override. - Doc comments in the CI script and the `--check` CLI usage now name both blocking classes. The CLI success line says "none blocked". - Red/green tests in `packages/db/src/migration-compatibility.test.ts` and `.github/scripts/tests/check-pr-migration-order.test.mjs`: `requires_staging` without an override fails, with a justified override passes, with an empty justification fails, and `online_compatible` passes. ## Verification - Red: with the old guard, the new tests failed (vitest: 3 failed of 116; node test: 3 failed of 14). - Green: `cd packages/db && pnpm exec vitest run src/migration-compatibility.test.ts` passes 116 of 116. - Green: `node --test .github/scripts/tests/check-pr-migration-order.test.mjs` passes 14 of 14. - `pnpm --filter @paperclipai/db typecheck` passes, including `check:migrations`. - `pnpm verify` exits 2 because a global CI input changed (`.github/scripts/check-pr-migration-order.mjs`). Required CI supplies the broad coverage. ## Risks - Low risk. The change affects only the PR guard for new migrations. Deployers and the cloud migrator manifest do not change. - An open PR that adds a `requires_staging` migration fails the guard after it rebases. The error says how to fix it. - Note: migration `0500_funny_malcolm_colcord.sql` from #22513 already has a justified `requires_staging` override. This guard passes it with a notice. To stop such a migration at review time, a further policy is necessary, for example a required reviewer for the override. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), in Claude Code with tool use (shell, file edits) and extended reasoning. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
427d13c38c |
fix(connections): clean up audit-only task traces and wait without rescanning content (#22658)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - #22636 removes connection content (for example Google results) when a task or a company is deleted > - Review on #22636 found two more gaps after it merged > - A task whose only connection trace is an audit entry (for example a denied call) got no cleanup job, so the argument preview stayed after the task was deleted > - A cleanup job that waits for open runs re-ran all content steps on every recheck, which is wasted database work > - This pull request queues a job for audit-only tasks and adds a `waiting` phase that only counts open work > - The benefit is that no audit preview of a deleted task is left behind, and a waiting job stays cheap ## Linked Issues or Issue Description Refs #22636 **Problem** 1. Deleting a task whose only connection trace is a `tool_access_audit_events` row with the task's ID creates no cleanup job, so its argument preview stays. 2. While a task cleanup job waits for open runs or approvals, every recheck runs the six content steps again from the start. **Expected behavior** 1. The audit preview is cleared after the task is deleted. 2. A waiting job only checks whether work is still open, and runs the content steps once when the work settles. **Steps to reproduce** 1. Write a denied policy audit entry with the task's ID and no call or call event. Delete the task. The preview stays. 2. Delete a task while one of its runs is working. Each recheck scans every content table of the task again. ## What Changed - `issue-content-deletion.ts`: when the task has no recorded runs, calls or call events, check for an audit entry with the task's ID. If one exists, queue the job. The audit step already matches by task ID. - `content-deletion.ts`: new `waiting` phase. After a content pass with open work, the job moves to `waiting` instead of restarting. Each recheck counts open runs, open calls, open approvals and open wakes with results for the task. When the count is zero, or after the one-day bound, the job runs the content steps once more and finishes. - Moved the pure JSON cleaning helpers to `content-cleaning.ts` to keep `content-deletion.ts` under 1,000 lines. No behaviour change. - Two canary tests: a task with only an audit entry, and a waiting job that leaves new content alone on a recheck and clears it after the open run settles. Both failed before the fix. - The working memory note is updated. ## Verification - `cd server && npx vitest run src/__tests__/tool-connection-content-deletion-canary.test.ts src/__tests__/tool-connection-content-deletion.test.ts src/__tests__/server-startup-feedback-export.test.ts` (156 tests pass). The two new tests failed before the fix. - `cd server && pnpm typecheck` passes. ## Risks - Task deletion with no other connection trace runs one more query on `tool_access_audit_events` for the company, with `limit 1`. That table has no index on the task ID in its details. - No schema change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edit, test runs). Extended reasoning on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d28becf0f5 |
fix(server): run person-opened gateway sessions as their opener for personal connection grants (#22643)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The tool gateway lets an agent run call connected apps through a short-lived session > - A person on the board can also open a gateway session for a running agent > - Such a session resolved credentials for the run's responsible person, not for the person who opened it > - A member could therefore use another member's personal connection grant through that member's running agent > - This pull request limits personal grants in a person-opened session to the grant owner and requires permission to act on the agent > - The benefit is that a personal connection is used only by its owner or by the owner's own agent runs ## Linked Issues or Issue Description Refs #22635 **What happened?** `POST /api/tool-gateway/sessions` let any non-viewer member open a session for any running agent in the company. Tool calls in that session used the personal grant of the run's responsible person. **What did you expect to happen?** A person who opens a session can use a personal (user-owned) grant only when they own it. The person needs permission to act on the agent. Company-shared connections and agent-opened sessions work as before. **Steps to reproduce** Two members are in one company. Member A has a personal grant on a connection that agent X uses. While a run of X is active, member B opens a gateway session for that run and calls a tool on that connection. The new route test covers this case. **Impact** Access-control hardening for personal connection grants. ## What Changed - Add the nullable column `tool_gateway_sessions.created_by_user_id` (migration `0502`, which also adds `tool_mcp_tasks.created_by_user_id`). The route sets it when a person (not a local implicit board) opens a session. - Grant resolution for such a session acts as the person who opened it. That person's own personal grant is used, or a connect card is addressed to that person. Another member's personal grant is never selected, and that member gets no card. - The opener is recorded on the tool invocation (server-written `policyExplanation.sessionOpenedByUserId`) and restored when an approved action runs. An approved call from that session therefore uses the same person's grant. - A guard after grant resolution refuses a user-owned grant of another person with `403` and `reasonCode: personal_grant_owner_required`, as defense in depth. - Saved-call replay is scoped to the opener: idempotency keys get an opener suffix for such sessions, and approval replay matches only invocations recorded with the same opener. The lookup of keys saved before this change still runs: a saved call that can be attributed to the same person replays, one attributed to another person does not, and one that cannot be attributed returns the existing `legacy_tool_idempotency_unverifiable` conflict instead of running the write again. - Long-running provider tasks (`tool_mcp_tasks`) record the opener in a new `created_by_user_id` column (same migration) and restore it on each background poll, so the task keeps the opener's grant and is attributed to the opener. - Managed GitHub identity selection uses the opener, in the first and the fallback selection. - A call attaches to an existing long-running provider task only when the task uses the same grant the call resolves to. On a personal grant it must also be the same person (an agent session matches only tasks with no opener; the grant owner may also collect a legacy task with no opener). On a shared grant any person may collect. The wake for a finished task now carries the task id, so the agent's continuation resolves the opener's grant and collects the result instead of calling the provider again. - `POST /api/tool-gateway/sessions` checks the existing `agent:wake` permission for a board caller, the same check as invoking the agent. - Agent-opened sessions do not set the column, so agent runs and the recovery of interrupted runs do not change. - Document the rule in `doc/MCP-ACCESS-GOVERNANCE.md`. - I checked the sibling routes. Named gateway tokens minted by a person need `tools:admin` and carry no responsible person. Board test calls and MCP app view calls already run as the caller. Stored MCP task continuations stay pinned to the grant they started with. ## Verification - New route tests in `server/src/__tests__/tool-gateway.test.ts`: - Three members, two with personal grants, on a run that belongs to the first. A session opened by the second member uses only that member's credential. The run owner's session and an agent-opened session use the run owner's credential. A member with no grant gets `409 user_authorization_required`, the card is addressed to that member, and the remote server gets no request. A reviewed call from the second member's session, once approved, runs with that member's credential. The same write from two people's sessions runs once for each person, and only the same person's retry replays. - A pre-upgrade saved write retried by the same person replays (or conflicts when it cannot be attributed) and never reaches the provider twice; another person's identical write runs. - `mcp-tasks.test.ts`: a person-started task keeps the opener's grant through a background poll; an agent retry never receives that task's result and keeps its own task; the continuation after a wake collects once with no new provider call; on a shared grant another person collects the task, including a task started before openers were recorded. - `tool-gateway-service.test.ts`: an opener with their own managed GitHub grant uses it; an opener without one is refused and the run owner's grant is never used. - A viewer cannot open a session for the agent. - Before the fix, the second member's session used the run owner's credential, and the viewer got `201`. Both tests pass now. - `npx vitest run src/__tests__/tool-gateway.test.ts src/__tests__/connection-management.integration.test.ts src/__tests__/mcp-tasks.test.ts`: with `tool-access-service.test.ts` and the policy tests, 833 tests pass. - `tsc --noEmit` for `server` passes. - `pnpm verify` exits 2 because a global CI input (a doc) changed. Required CI gives the broad coverage. ## Risks - A person who opened a session for another member's run used that member's personal grants before. Now the session uses the opener's own grants. This was not an intended flow. Shared connections and agent runs do not change. - A person-opened session that repeats exactly the same side-effecting call an agent session already made in the same run gets a `409` conflict instead of a second write, because that earlier call has no recorded opener. Use a new explicit idempotency key for an intentional repeat. - The migration only adds nullable columns. Sessions and review requests created before this change have no opener record and keep the previous behavior until they expire (15 to 60 minutes). - Follow-up, out of scope: in the experimental MCP Tasks path, a call with a new explicit idempotency key and the same arguments still attaches to the same person's open task under the same grant. That is the existing de-duplication for every caller and does not depend on the opener rule. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b865dd112b |
feat(google-workspace): run Gmail, Drive, Docs, Sheets, Slides and Calendar on Paperclip's REST tools (#22634)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The built-in Google Workspace connector gives agents Gmail, Drive, Docs, Sheets, Slides and Calendar actions through one connection > - Google's hosted Workspace MCP servers are a Developer Preview, so Paperclip cannot offer them to the public > - Paperclip has its own REST tool set for all 36 allowlisted actions, but every service still sent its calls to Google's MCP servers > - The owner decided on 2026-11-23 to launch all six services on REST now and to live-test on the staging tester after deploy > - This pull request switches the six services to `paperclip_rest` and fixes what the switch breaks > - The benefit is that the connector no longer depends on Developer Preview servers, and agents get all 36 actions, including the two Gmail actions Google's live server did not offer ## Linked Issues or Issue Description Refs #22016 (the transport switch), #22000, #22014, #22017, #22027, #22028, #22029 (the REST tool set). **Subsystem affected** Built-in Google Workspace connector (`google-workspace`, `workspace.all`): transport setting, catalog publication, tests and docs. **Problem or motivation** All six launch services used Google's hosted MCP servers. These servers are a Developer Preview and are not available to the public. Google's live Gmail MCP server also did not offer `gmail__list_threads` and `gmail__search_messages`. **Proposed solution** Set Gmail, Drive, Docs, Sheets, Slides and Calendar to `paperclip_rest` in `GOOGLE_WORKSPACE_TOOL_TRANSPORT`. Keep Chat, People and Search on `google_mcp`. Fix the catalog refresh so that an existing connection keeps its actions active after the switch. **Alternatives considered** Switch one service at a time after a live test (the Nov 17 rule). The owner replaced this rule on Nov 23: switch all six now and fix forward. **Roadmap alignment** This is the planned launch step for the Google Workspace connector. It does not overlap other core work. ## What Changed - `packages/shared/src/google-workspace-connectors.ts`: set `gmail`, `drive`, `docs`, `sheets`, `slides` and `calendar` to `paperclip_rest`. `chat`, `people` and `search` stay `google_mcp`. - Connections saved before the switch keep Google's MCP definitions in their catalog. Two changes make them work with no user action: - New resolver `paperclipDefinedTool(connection, toolName)` in `server/src/services/connectors/paperclip-defined-tools.ts` (typed result). It is the one place that says which tools are Paperclip-defined; for a `google-workspace` connection it calls `googleWorkspaceRestToolDefinition` in the dispatch adapter, which returns the REST definition when the service is on `paperclip_rest`. - `server/src/services/tool-gateway.ts`: when the gateway lists a connection's tools, it takes the input schema, output schema, description and annotations of a Paperclip-defined tool from the resolver, not from the saved row. Routing and the advertised definition read the same transport setting in the same process. This is an in-memory lookup, so it adds no request to the turn start. Example: an agent gets the REST `docs__update_doc` schema, where `writeControl.requiredRevisionId` is required, not Google's schema, where it is optional. - `server/src/services/tool-access/catalog/publication.ts`: catalog publication asks the same resolver. It never holds a Paperclip-defined action for review, and it clears the review hold (`quarantined`, `pending_review`) of an action held only because a remote definition changed. Clearing the hold does not count the action as new, so it is never added to the profile: Off stays Off and Ask first stays, also for a held action. Only actions the connection never had (Gmail `list_threads` and `search_messages`) get the default for new actions. Before this fix, a refresh after the switch put every action of an existing managed connection into `pending_review` (10 of 10 in the regression test). - `server/src/__tests__/google-workspace-rest-transport.test.ts`: the fake Google now answers the Docs, Sheets and Slides REST hosts and the Drive and Calendar paths. New tests: - The transport map has exactly the six launch services on `paperclip_rest`. - A full read and write grant lists exactly the 36 allowlisted actions (with `gmail__list_threads` and `gmail__search_messages`) and sends no MCP request. A read-only grant lists the 23 read actions. Gmail, Drive and Calendar group grants list exactly their actions. - One read and one write per service run through the real `executeTool` path on REST with the default policy (no approval request). Each call records the invocation and the `call_completed` event with the connection ID (the "Delete data" bookkeeping keys), and audits the protocol `Google Workspace REST` with the service endpoint. - Injected instructions in Docs, Sheets, Slides, Drive and Calendar REST results are blocked. - An existing connection discovered over MCP keeps its actions active after the switch and can call the new Gmail actions. - Migration without refresh: a connection saved with Google's MCP schemas (`update_doc` with `writeControl` optional) advertises the REST schemas after the switch with no refresh, and `read_doc` then `update_doc` with the revision succeed over REST. - The first refresh after the switch releases an action held for `pending_review`, keeps an Off action unlisted and keeps Ask first (`approval_required`). - An action that is both Off and held stays Off, and one that is both Ask first and held stays Ask first, after the switch and after two refreshes. - The MCP-path test pins Gmail and Docs to `google_mcp` explicitly. - `server/src/__tests__/helpers/google-workspace-transport.ts`: new helper `useGoogleMcpTransport()`. Tests whose fixtures act as Google's MCP servers use it (`tool-access-service`, `tool-gateway-service`) or pin the transport in `beforeAll` (`google-workspace-injection-screening`). These tests still cover the MCP path, which stays available for Chat, People, Search and a switch back. - `packages/shared/src/google-workspace-connectors.test.ts`: assert the new transport map. - Docs: `doc/connections/GOOGLE-WORKSPACE.md` and the REST folder `README.md` say that the six services run on REST. `doc/memory/google-connector-memory.md` has three dated Nov 23 decisions (all six switched to REST, writes default to Allowed, image-by-URL inserts allowed), and the two items are removed from "Still open". ## Verification - Red: after the flip, 50 tests failed in four files because their fixtures act as Google's MCP servers. These are fixture assumptions, not product bugs. - Red: without the gateway change, the migration test gets Google's saved schema; without the publication change, the held action stays `quarantined`; without excluding released rows from the new-action default, the Off and held action comes back. All green with the fixes. - Red: the new test "keeps an existing connection's actions usable when its services move from Google's MCP servers to REST" failed before the `publication.ts` fix: 10 catalog entries were `quarantined` with `pending_review`. Green after the fix. - `cd server && npx vitest run src/__tests__/google-workspace-rest-transport.test.ts src/__tests__/google-workspace-injection-screening.test.ts src/__tests__/tool-gateway-service.test.ts src/__tests__/tool-access-service.test.ts src/services/google-workspace-rest-dispatch.test.ts src/google-workspace-rest-tools`: with `connection-management.integration.test.ts` added: 60 files, 2232 tests pass. `google-workspace-rest-transport.test.ts`: 52 tests pass. - `cd packages/shared && npx vitest run src/google-workspace-connectors.test.ts`: 14 tests pass. - `npx tsc -p server/tsconfig.json --noEmit`: no errors. - Trace of a read (`gmail__get_message`) and a write (`gmail__create_draft`) through `executeTool` in `server/src/services/tool-gateway.ts`: policy decision and invocation record (13723, 13731), approval gate (13820), `call_allowed` audit (13885), dispatch to `executeRemoteHttpTool` (13915), prompt-injection screening of the result (13964), `call_completed` event and audit (14022, 14044), failure audit (14187). In `executeRemoteHttpTool` the grant scope check (8172) runs before the REST branch (8276), which rechecks the current grant and returns before any MCP session, MCP Task or elicitation code. The REST adapter (`google-workspace-rest-dispatch.ts`) calls `google-http.ts` only through the gateway's guarded fetch. - Not verified: calls against real Google. The live test on the staging tester runs after deploy. ## Risks - Real Google answers can differ from the fixtures. The REST tools are not yet run against real Google. The live test on the staging tester runs after this deploys, and problems are fixed forward. - The OAuth client on the staging tester is marked for AI agents and was only used through MCP. If Google refuses REST calls from that client, all six services fail on the tester until the client changes. - Existing connections keep their stored MCP schemas until a catalog refresh, but agents receive the REST definitions at once. The stored risk level of the four update actions stays `write` until that refresh, then becomes `destructive`. The two new Gmail actions appear after a refresh. - Input differences between Google's MCP schemas and the REST tools are listed in the REST folder `README.md` ("Input differences an agent meets after a switch"). Agents receive the REST schemas, so these differences are visible to them. No `tools/list` from Google's servers is recorded, so the check uses Google's published references. - Accepted risk (owner decision, 2026-11-23): Docs and Slides edits may insert an image from any public web address. Google, not Paperclip, fetches the address, and Paperclip's own requests still go only to the allowed Google hosts. The residual risk is that an agent could put data in the address it chooses. Links to Drive or Docs files stay refused. - Update actions (`update_doc`, `update_presentation`, `update_spreadsheet`, `update_event`) are labelled destructive on REST, as decided on Nov 17. This does not add an approval step: write actions stay Allowed by default. - A switch back to `google_mcp` stays possible with a one-line change. The MCP path tests still run. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, test runs). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ba1b0585bc |
fix(server): send deployment OAuth client secrets only to the token endpoint they are configured for (#22649)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - App connections sign in with OAuth, and an operator can set a deployment-wide OAuth client with `PAPERCLIP_TOOL_OAUTH_*` variables > - The server picked that client by a provider name, and a connection's own settings could set both the provider name and the token URL > - So a deployment client secret could go to a token URL that the deployment did not choose > - A deployment secret must go only to the endpoint of the app it was set up for > - This pull request pins each deployment client to the token endpoint that its app definition fixes, and fails closed for any other endpoint > - The benefit is that member-entered or custom endpoints get only a member-entered client ## Linked Issues or Issue Description Refs #22635 **What happened?** `configuredOAuthClientForConnection` returned the deployment client for any connection whose provider name matched, or the unsuffixed client for any connection. The token exchange then sent that client secret to the connection's token URL. **What did you expect to happen?** A deployment client goes only to the token endpoint that its app definition fixes. A custom endpoint needs a client that the member adds. **Steps to reproduce** Set a provider-specific deployment client. Create a custom connection that names that provider and a different token URL, and start sign-in. The new unit tests cover this case. **Impact** Secret-handling hardening for deployment OAuth clients. ## What Changed - `configuredOAuthClientForConnection` now takes the token URL that the caller will post to. It returns a deployment client only when the connection comes from a real app definition, the provider is that app, the method lists `customer` ownership, and the token URL equals the method's `defaults.tokenEndpoint` (or, when the method fixes no token endpoint, is on the exact host of its fixed server, discovery, metadata or authorization URL). - A pasted (custom) server never gets a deployment client, including the unsuffixed one. It needs a client of its own, or CIMD or dynamic registration. - The token URL is required at every call site: start, callback, connection refresh and grant refresh. - When a deployment client exists but the endpoint does not match, and the connection has no client of its own, sign-in fails with `oauth_instance_client_endpoint_mismatch` and a clear message. - Pin `defaults.tokenEndpoint` in the Asana and Railway definitions, whose token endpoints are on another host than their MCP servers. - Update `doc/connections/GENERIC-REMOTE-MCP.md` and `doc/connections/CONNECTOR-PLAYBOOK.md`. ## Verification - New `server/src/services/tool-access/oauth/client-settings.test.ts` (16 tests): other hosts, a path that resolves elsewhere, plain HTTP, vendor subdomains, another port, a missing URL, empty or padded gallery markers, colliding host names, a custom connection that names a provider, the unsuffixed client on a custom connection, and a connection that names another app's provider all get no deployment client. Slack's fixed endpoint, Notion's server host and the pinned Asana and Railway endpoints still get it. These cases failed before the fix and pass now. - `server/src/__tests__/generic-mcp-connection.test.ts` and the machine-to-machine test in `tool-access-service.test.ts` now check that a pasted server never receives the deployment client or secret. Both failed before the fix. Two other pasted-server tests now use a client of their own. - A positive test sends the Slack deployment client to Slack's pinned token endpoint, with its secret, and nowhere else. - The connect route keeps the draft and returns `manualClientRequired` with a plain reason when a deployment client cannot be used (route and UI tests). - `npx vitest run` on the OAuth service and connection tests: 686 tests pass. Shared app-definition tests pass. `tsc --noEmit` for `server` passes. - `pnpm verify` exits 2 because a global CI input (a doc) changed. Required CI gives the broad coverage. ## Risks - A self-hosted deployment that used `PAPERCLIP_TOOL_OAUTH_*` for a pasted server must add a client to that connection. Sign-in shows a clear error instead of sending the secret. - A gallery app with `customer` ownership whose token endpoint is on another host than its fixed URLs needs `defaults.tokenEndpoint` to keep using a deployment client. Asana and Railway are pinned here. Box, Notion, PostHog, Sentry and Xero rely on the same-host rule: if their discovery returns a token endpoint on another host, a deployment-wide client is refused until the endpoint is pinned, and a client added to the connection always works. A test lists these apps by name, so a new app must choose. Gallery apps with a fixed token endpoint (Slack, Linear, Google) do not change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
70d4b6524c |
fix(antigravity): offer the cloud candidate in the agent picker for linux-x64 environments (#22655)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity is a native Runner harness (#22591). Its profile is still pending, so only a company with an operator grant can see or run it > - A grant can name the cloud target (linux-x64), and save, Test and execution already accept it for a cloud environment > - The agent picker computed the candidate only for the local target, so a company with a valid cloud grant never saw the harness for a cloud environment > - This pull request binds the picker to the selected environment's target, in the Antigravity-owned module > - The benefit is that a granted company can pick Antigravity for the linux-x64 cloud environments that can run it, and still sees nothing anywhere else ## Linked Issues or Issue Description Refs #22591 **What happened?** `GET /api/adapters?companyId=…&environmentId=…` returned `candidateHarnesses` only when the environment target was `local`. A company with a valid linux-x64 Antigravity grant got no candidate for a Core sandbox or SSH environment. **What did you expect?** The picker offers the candidate for a linux-x64 cloud environment when the company holds a grant for that target, the same way save, Test and the executor admit it. **Steps to reproduce** 1. Set a candidate grant that names linux-x64 for a company and exact model. 2. Request the adapter list for that company with a linux-x64 sandbox environment. 3. `paperclip_runner` has no `candidateHarnesses`. ## What Changed - `antigravityCandidateForRunnerTarget` (in `antigravity-release.ts`) decides the picker candidate per environment target: - local: unchanged. - Core sandbox or SSH that is linux-x64, or the managed cloud image: only a grant that names linux-x64 and its patched closure. - plugin Runner-task environment, unknown or other platform, unavailable Computer: none. - released profile: none. - `GET /api/adapters` uses it for every resolved target. Expired or mismatched grants stay quiet; malformed grants still log one warning. - The qualification plan notes the picker rule and records, as an open decision, why plugin Runner-task environments cannot run Antigravity yet. ### Not in this PR: plugin Runner-task environments Paperclip Cloud's warm Agent Computer runs agents only as plugin Runner tasks. Antigravity cannot run there yet, and the fix is outside Core alone: - The plugin task credential contract (`environmentTaskCredentialSchema`) has no Gemini API key type. - The plugin prepares the provider launch from `launch-requirements.v1`, which carries no candidate grant. The ACPX sidecar refuses a pending profile without one. - The Cloud plugin's harness table lists only Codex, Claude and OpenCode. Kimi, Copilot and Pi do not run there either. - Antigravity Test refuses the Runner-task path. The picker therefore offers nothing for those environments until that work lands. ## Verification - Red, then green: `server/src/__tests__/adapter-routes.test.ts` "offers a cloud environment the candidate only for the company's linux-x64 grant" failed before the fix and passes after it. - New unit tests in `antigravity-release.test.ts` run the real grant resolver: cloud grant offered, other company / arm64 / Runner-task / expired / host grant refused, released profile offers none. - `npx vitest run src/__tests__/adapter-routes.test.ts src/services/native-runtime/antigravity-release.test.ts src/services/native-runtime/acpx-qualification.test.ts src/services/native-runtime/antigravity-candidate-admission.test.ts`: 98 passed. - Server `tsc --noEmit`: clean. `pnpm verify`: see the CI checks for the final revision. - Not run live: no Antigravity prompt has completed in any environment yet, and the only available Gemini key is free tier. No paid runner E2E workflow was dispatched. ## Risks - Low risk. The change is read-only catalog output. Save, Test and execution keep their strict admission checks. - A company that holds a linux-x64 grant now sees Antigravity for linux-x64 sandbox and SSH environments. Those paths already accept that grant. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell, file edits) in Claude Code. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a3af1ac6db |
fix(connections): remove connection content when a task or company is deleted (#22636)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents call connected apps, such as Google Workspace, and Paperclip keeps parts of the results in tool-call records, approvals, run transcripts and files > - #22010 added "Delete data" on a connection. It removes that content for one connection. > - Deleting a task or a company did not run the same cleanup. Task deletion set the task link to null on tool calls, approvals and runs, so their previews and transcripts stayed. Company deletion removed the rows but left run logs and files in storage. > - Google's restricted-scope review requires that users can delete the Google data we hold, and that the policy matches the product > - This pull request runs the "Delete data" steps when a task is deleted, and removes a deleted company's run logs and files from storage in the background > - The benefit is that deleting a task or a company removes every copy of connection content, and a canary test makes sure that a new store cannot skip these paths ## Linked Issues or Issue Description Refs #22010 **Problem** Deleting a task leaves connection content in tool-call previews, audit history, approval requests, results passed to later runs, run transcripts (events, excerpts, result text and the run log in every copy) and saved tool results over 500,000 bytes. Deleting a company leaves run logs (object journal, archive, local file, S3 mirror) and all stored files, including attachments and saved tool results. "Delete data" on a connection also left saved tool results over 500,000 bytes in storage. **Expected behavior** Deleting a task removes the connection content of the task's runs and calls. Deleting a company removes its run logs and files from storage, not only its rows. "Delete data" removes saved tool results of the runs whose transcripts it deletes. **Steps to reproduce** 1. Let an agent call a connection on a task, so that the run has a log, events and a saved tool result. 2. Delete the task, or delete the company. 3. Look in `tool_invocations`, `heartbeat_runs`, `heartbeat_run_events` and object storage. The content is still there. ## What Changed - New table `issue_connection_content_deletions`. Task deletion records, in the same transaction and before the task row goes, the task's runs that used a connection or are still working, the task's calls without a run, and the task's call events that belong to neither. Audit entries are matched by run, call or task. The background worker then runs the existing "Delete data" steps for that scope. Runs of the task that are still working are recorded too, even if they have not used a connection yet, so a connection call they make after the deletion is also cleared. The job rechecks every 1 to 5 minutes while runs or approvals are open and finishes as soon as they settle, for up to a day. It writes an `issue.connection_content_deleted` activity entry with counts only, and only when it deleted something. - New table `stored_object_deletions`. Company deletion records every run log and every file of the company before the rows go. The table has no foreign key to the company, so the removal continues after the company is gone. Each object is retried with backoff until storage confirms the deletion. Task deletion also records the task's attached files here, so a failed best-effort delete in the route is retried. - `content-deletion.ts` stays the one owner of "remove connection content". Each job table has its own typed store (load, save, finish, activity, failure), so no per-table column can compile against the other table. The storage ledger is in `stored-object-deletion.ts`, and the task request is in `issue-content-deletion.ts`. The steps now take a scope (one connection, or the runs and calls of one deleted task). The connection path behaves as before. - "Delete data" and task deletion now also delete saved tool results over 500,000 bytes (`runner-api` assets) of each run whose transcript they delete: the object in storage and the asset row. Files attached to a task, a case or a company logo are not touched. - The canary test scans every text and JSON column and every storage copy (object journal, legacy mirror, local files and file storage) after a connection deletion, a task deletion and a company deletion. It also checks that another task and another company keep their content. - Docs: the store inventory in `doc/memory/google-connector-memory.md` has columns for task and company deletion. The production checklist, the code-fixes plan, the connector playbook and the user help page `docs/guides/board-operator/deleting-connection-data.md` are updated. ## Verification - `cd server && npx vitest run src/__tests__/tool-connection-content-deletion-canary.test.ts` (12 tests). Before the fix, the new task and company tests failed: the scan found the marker in run logs, the legacy mirror, local files, saved results and attachments. The connection test also failed on the saved tool result file. - `cd server && npx vitest run src/__tests__/tool-connection-content-deletion.test.ts src/__tests__/google-managed-connection-removal.test.ts src/__tests__/git-restore-point-ledger.test.ts src/__tests__/agent-observability.test.ts` (85 tests pass). - Nine more suites that delete tasks or companies pass (456 tests), for example `decision-target-work`, `approval-retention-work`, `cleanup-removal-service` and `tool-gateway-service`. - `pnpm --filter @paperclipai/db typecheck` passes, including the migration compatibility guard (`0501` is `online_compatible`: two new tables and their indexes). - `cd server && pnpm typecheck` passes. - `pnpm verify` exits 2 because a global CI input changed. Required CI supplies the broad coverage. ## Risks - Migration: two new tables only. The previous release does not read them, so it keeps working during the overlap deploy. - Task deletion runs three more indexed queries in its transaction. It creates a job only when the task used a connection. - Company deletion inserts one ledger row per run log and per file in its existing transaction. The storage work is batched in the background, 50 objects at a time. - Company deletion now removes all of the company's files and run logs from storage. Before, they stayed in storage with no row that pointed to them. - `stored_object_deletions` keeps `company_id` without a foreign key, like `execution_workspace_restore_points`, so that removal can finish after the company is gone. It holds object keys only, no content. - A task deletion creates a job when the task used a connection or still has a run that is working. While runs or approvals are open, the job rechecks every 1 to 5 minutes. It stops waiting one day after the deletion. It then writes `issue.connection_content_deletion_incomplete` with the counts of what was still open, and that content stays. A job that deleted nothing and left nothing open writes no activity entry. - A run of the deleted task that was still working is in the scope. If it calls a connection after the task is deleted, the job waits for it and clears that content too. - Not changed: deleting a company does not ask Google to revoke the grant. Raw provider traces still expire on their own. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edit, test runs). Extended reasoning on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
30881e6aa9 |
fix(ui): keep the tasks the user opened in the saved read cache ahead of preloaded ones (#22627)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board UI saves a read cache in local storage. Since #21671 it also saves the first chat frame of the 20 most recently opened tasks, so a hard load of such a task shows its chat at once. > - The 20-task limit ranks tasks by when this page opened them, or else by when their data was read. > - Task lists and the sidebar's Recents preload the chat of their top rows in the background. Those reads land after the user opens a task, so preloaded tasks rank above the opened one. > - On staging, more than 20 preloaded tasks pushed out the task the user had opened (PAP-4463): neither its record nor its chat was saved, so it never opened from the saved chat. > - This pull request ranks opened tasks first and saves the time each task was last opened with the record, so the order also holds on the next load. > - The benefit is that the tasks the user actually opens are the ones that open instantly next time. ## Linked Issues or Issue Description **Describe the bug** After a hard load of a task, the saved read cache often does not contain that task. Tasks that a list or Recents only preloaded take the 20 slots. **Steps to reproduce** 1. On staging, open a task (for example PAP-4463) while the sidebar Recents and a task list preload other tasks. 2. Read `paperclip:query-cache:v1:<user>:<company>` in local storage after the page settles. 3. The record holds the chat of up to 20 preloaded tasks, and not the opened task. **Expected behavior** The tasks the user opened rank first for the 20-task limit, also after a reload. **Actual behavior** Preloaded tasks have newer read times than the opened task's visit, so they rank first and push it out. Refs #21671. ## What Changed - `ui/src/lib/persisted-query-cache.ts`: the 20-task limit ranks tasks that the user opened before tasks that were only read in the background. Opened tasks are ordered by their latest open, the others by their read time. An open is recorded by the task page (`recordTaskOpen`), keyed by the task's id, so a task row or link never counts and any ref spelling ranks the same. Each company record saves the open times of its saved tasks (`visits`, an optional field), and a restore reads them back. Older records without `visits` still load. Open times are cleared on sign-out, on an account change and for a refused task. - `ui/src/pages/IssueDetail.tsx`: records the open once the task has loaded. - `ui/src/lib/saved-task-chat.test.ts`: a task opened before 25 newer preloads (with mounted detail observers) keeps its record and chat, also after a reload that preloads 25 more; a task opened by a lowercase identifier ranks as opened; another user's record never receives the open times; a refused task's open time is dropped. - `doc/ui-internals.md`: the read-cache rules state the ranking. ## Verification - `cd ui && npx vitest run src/lib/saved-task-chat.test.ts`: 25 passed. With the ranking change reverted, the new case fails. With only the restore of saved visit times disabled, it fails at the after-reload assertion. - `src/lib/persisted-query-cache.test.ts` and `src/lib/restored-task-chat-bootstrap.test.ts` also pass (91 tests across the three files). `pnpm --filter @paperclipai/ui typecheck` passes. - Staging evidence (build `cb4129a91`): the saved company record held chat for preloaded tasks (1.38 MB, 234 entries) and did not contain PAP-4463, whose whole chat is about 105 KB. ## Risks - Low risk. Only the order in which tasks fill the 20 slots changes. The saved data, the bounds, expiry and revocation do not change. The visit times are timestamps under keys that the record already contains. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, browser automation). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
78e4f4f130 |
feat(runner): Antigravity on ACP 1.5.2 with Linux, API-key auth and Gemini 4 Neon (still pending) (#22591)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The native Runner starts each agent harness and owns its lifecycle, credentials and recovery > - Google Antigravity is Google's only first-party coding harness, and it is the harness for Gemini 4 Neon > - The Runner had an Antigravity integration, but only as a pending candidate: ACP server 1.4.3, macOS ARM64 only, Google sign-in only, closed unless an operator opened it for one company and one model > - Cloud sandboxes run Linux and use API keys, so the candidate could not run there, and it had one attended test cell > - This pull request moves the integration to ACP server 1.5.2, makes it run on Linux and with a Gemini API key, adds the tests the other ACPX harnesses have, and removes the code paths that would block recovery after release > - The benefit is that the release of Antigravity becomes a small declaration change after the live suites pass. The profile stays `pending` in this pull request. ## Linked Issues or Issue Description Refs #98 Refs #6559 Refs #8523 Refs #21121 (a separate legacy-style `agy_local` adapter that uses the CLI print protocol; this pull request does not replace or include it) ## What Changed **Runtime** - Pin Antigravity ACP server 1.5.2 (was 1.4.3). Owned admission patch is `1.5.2-paperclip.2`. - Verified patched closures for `darwin-arm64`, `linux-x64` and `linux-arm64`. `darwin-x64` stays inventory-only. - The patcher reads Mach-O and ELF builds. It signs macOS output only. One admission source serves all platforms. - Platform gates in TypeScript, Rust, the sidecar schema and the server admit each host that has a verified closure. **Auth and models** - Gemini API-key auth reaches an exact-model session receipt. Admission accepts a model only when the base model and the thinking level both match the requested ID. - API-key connections get a model list on local and cloud environments. The list is generated at build time from the pinned runtime. The server starts no process to read it. - Gemini 4 Neon, Carbon, Argon and Hydrogen are selectable. The picker marks them "needs a paid Gemini API plan" for API-key connections. - One shared module maps model ID to family and thinking level. - `google/gemini-4-neon` is added to the OpenCode model list. A new model audit is in `doc/adapter-model-audit-2026-11-22.md`. **Lifecycle and failures** - A provider error no longer completes the turn. The driver classifies it: overloaded, rate limit, quota, auth rejected, model unavailable. - Overload retries are bounded (3 attempts, about 14 seconds). - A refused session reload maps to incompatible saved state, so the automatic replacement conversation applies. - Server gates that refused restart recovery, remote targets and shared state for Antigravity now apply only while the profile is pending. - A Google sign-in connection with a cloud environment is refused at save and at Test, with a plain message. - A released profile rejects candidate grants in TypeScript and in Rust. **Launch cost and integrity (all native ACPX providers)** - Each closure is verified one time into a sealed read-only store. Later launches check file identities and hash the exact executable they start. - Remote provider-pack verification is recorded per sandbox lease. Later runs check kernel identity and fall back to the full hash on any difference. - Superseded stores are removed in the background after a launch. **Provider pack and image** - The provider pack carries Antigravity for `linux-x64` as a candidate provider. It becomes an ordinary provider from the profile status alone. - The Daytona image build accepts the candidate. A credential-free smoke runs in the build. **Tests and CI** - New `antigravity-qualification` suite: 24 cells, local and Daytona. - New model lineup suites: 14 API-key cells and 14 Gemini 4 cells. Each cell requires the exact model in the Runner receipt. - Antigravity can run the `chat-features` cases with `--profile runner-acpx-antigravity`. - `runner-full-stack-e2e.yml` passes `GEMINI_API_KEY` for the new profile and derives candidate providers from the selected Daytona cells. **Docs** - `doc/plans/2026-11-22-antigravity-qualification.md` is the current release contract, acceptance ledger and operator recipe. ## Verification Commands that passed on the final revision: - `pnpm build` - Typecheck for all packages, including the runner-e2e test projects - `pnpm test:e2e:runner:unit`: 11,665 Vitest tests passed, 25 skipped; 386 node tests passed - `cargo test -p paperclip-runner-core -- --test-threads=4`: 1,199 passed, 2 failed. The 2 failures are Codex transport timing tests that pass alone and on `master`. - `cargo fmt --check`, `check:acpx-profiles`, `check:protocol-types`, `node scripts/check-maps.mjs` - Native patch tests: 9 of 9 on `darwin-arm64` and 9 of 9 on `linux-x64` - UI picker tests: 397 of 397 Known failures that also fail on `master`: - 11 runner package script tests (browser, Pi and package-boundary checks) - 6 `runtime-selection` tests that read an untracked local skill file Live evidence, without a prompt: - Clean provisioning on `darwin-arm64` and on `linux-x64` in a Daytona sandbox. The closure digests reproduce. A changed or missing file is rejected. - `initialize` reports 1.5.2. An API-key session returns a receipt for exactly `gemini-3.8-flash-low` and the exact instruction bytes, on both platforms. - All 28 model IDs (14 Gemini 3, 14 Gemini 4) return an exact receipt under an API key. - A session survives a process kill and resumes in a new process with exact receipts, on both platforms. - The server's remote path verifies the provider pack in a Daytona sandbox. - Run start to native `initialize`: 3.45 s to 1.46 s on macOS, 3.65 s to 1.74 s on Linux x64, before the per-launch executable hash was restored (about 60 ms on macOS; not measured on Linux). - Remote pack verification on a reused sandbox lease: about 4.3 s to about 0.25 s. Live evidence, with a prompt, on an already-released harness: - Pi native, `pi-native.runner-acpx-pi.local.agent-files-fresh-run`, on `darwin-arm64` at `427e9b088b`: 1 of 1 passed, 14 of 14 checks, both native runs succeeded (25.5 s and 25.7 s). The process started from the new launch store with no fallback warning. - The same cell and `native-pending-controller-restart` failed in the paid workflow on this branch and on `master` in the same way, before any native start. The workflow does not install the Pi runtime for local cells, so the agent setup check fails. That is a workflow gap, not part of this change. **Not run.** No Antigravity prompt completed on 1.5.2 on any platform. The only Gemini key available is on the free tier, and Google returned 503 or 429 for each attempt on two days. These gates are open: - All 24 `antigravity-qualification` cells - Both model lineup suites, including inference on Gemini 4 Neon - The attended Google sign-in journey on 1.5.2 - The chat cases under Antigravity - Image pull time and startup time on a published image - A native start on `linux-arm64` - A live provider-death cell for Kimi, Pi or Copilot on the new launch store (one ordinary Pi cell passed live; see above) ## Risks - **The launch store changes how every native ACPX provider starts** (Kimi, Copilot, Cursor, Pi), not only Antigravity. A review found two defects in the first version (an executable swap was possible, and Pi launches broke). Both are fixed with tests. One live Pi cell passed on this branch on macOS. No live provider-death cell and no Linux cell ran for those providers. - The profile digest changes. Saved Antigravity candidate sessions and existing candidate grants stop working. The new release refuses old state by name and starts a replacement conversation. - The Linux provider pack and the Daytona image grow by about 834 MB (about 274 MB compressed) when Antigravity is included. - The pack verification record is in server memory. The first run after a server restart pays the full hash again. - Antigravity 1.5.2 reads the workspace `GEMINI.md` and `AGENTS.md` as user rules. This is deliberate and matches Codex. Any other rule file is refused. - Orchestrator mode is not available. ACP server 1.5.2 does not expose it. - Antigravity stays `pending`. Normal users cannot run it until a later change removes the pending status. ## Model Used - Claude Fable 5.2 (`claude-fable-5-2`) planned, briefed and integrated the work, with tool use. - Claude Opus 5.5 (`claude-opus-5-5`) subagents wrote the code and ran the tests, with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
50cee0cb8f |
fix(recovery): do not hold a task for a retry cancelled before it started (#22262)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The heartbeat service holds a task for reconciliation when a legacy run stops and Paperclip cannot tell which of its actions took effect > - A task moved to backlog while its automatic retry still waited for its scheduled time. The control plane cancelled that retry before anyone claimed it > - The cancelled retry had no start time, stage, process, lease or execution events. It still got an "unknown outcome" hold, because its chain had already spent two failure retries > - After that, every wake was refused with `execution_reconciliation_required`, and Retry could not clear the hold. The rule is that a Retry button that is shown must work > - This pull request treats an unclaimed control-plane cancellation like the other never-started dispatch cancellations > - The benefit is that the task continues on its next wake or Retry, and tasks that are already stuck recover without manual work ## Linked Issues or Issue Description Refs #20752 (related: it hardens the `queued` cancel marker; it does not cover a cancelled `scheduled_retry`) **What happened?** A task had a pending scheduled retry (status `scheduled_retry`, never started). The task moved to backlog, and the control plane cancelled the retry (`errorCode: "cancelled"`, cancellation `source: control_plane`, `expected: true`, initiator `system`). The chain had `executionRetryAccounting.failureRetries = 2`. Terminalization recorded a `legacy_execution_requires_reconciliation` hold with automatic replay blocked. When the task moved back to todo, each new run was cancelled before it started with `execution_reconciliation_required`. The task showed `canRetry: false`, and a Retry press did not start a run or clear the hold. **Steps to reproduce** 1. Give a legacy-runtime agent a task with a pending `scheduled_retry` run whose chain has spent two failure retries. 2. Move the task to backlog. The control plane cancels the pending retry with `expectedStatus: "scheduled_retry"`. 3. Move the task to todo, then press Retry. **Expected behavior** The cancelled retry never ran, so there is nothing to reconcile. The next wake or Retry starts a fresh run. **Actual behavior** The task stays held. Every wake is refused, and Retry does not start a run. ## What Changed - Root cause 1: cancelling a never-started run stamps "no provider work" evidence only when its status was `queued`, not `scheduled_retry`. - Root cause 2: `legacyExecutionNeedsReconciliation` returns "hold" when the chain has two or more failure retries, before it reads any no-provider-work evidence. - `neverStartedDispatchCancellationPredicate` (and its synchronous pre-check in `isPreDispatchReviewWaitVerified`) now also accepts an expected system `control_plane` cancellation with `errorCode = "cancelled"`. It requires the same retained-execution proof as the dispatch-gate cancellations. A retry also needs a settled predecessor (`settledRetryPredecessorPredicate`). Terminalization records a reconciliation hold on a predecessor whose outcome is unknown, and the scheduler does not retry such a run. So the predecessor must exist and carry no effective or superseded reconciliation hold. A row with retry metadata whose predecessor was deleted fails closed. Workspace-wait chains keep their dedicated proof. The candidate check reads the cancellation with `readRunCancellation`; the SQL predicate in `pre-dispatch-execution-evidence.ts` is the single proof. - The same predicate is used at terminalization (no new hold) and in `executionBlockerPredicate` (a hold that an earlier release recorded no longer blocks). Tasks that are already stuck therefore recover on their next wake or Retry. The audit row is kept. - `doc/heartbeat-internals.md` documents the rule. ## Verification - New `server/src/__tests__/never-started-retry-cancellation-hold.test.ts`: - backlog cancel of a pending retry (real `cancelRun` with `expectedStatus: "scheduled_retry"`) → no hold → todo → Retry queues a fresh run, and the dispatch gate sees no blocker; - a hold recorded by an earlier release plus a refused todo run → Retry queues a fresh run, and the blocker clears; - the hold stays when the cancelled retry shows a start time, a process, a stage, an execution event, or an unexpected cancellation, or when its predecessor is held or was deleted. The main case runs with three real chains: a transient failure before provider work, an `ai_connection_busy` wait, and an environment wait after a succeeded run. - Red/green: without the fix, the first two cases fail (the blocker shows `canRetry: false` and "Automatic recovery stopped…"). With the fix, all 11 cases pass (4 fail without it). - Related suites pass: `explicit-native-continuation`, `task-retry`, `legacy-execution-recovery`, `heartbeat-undispatched-execution-wait`, `issue-scheduled-retry-routes`, `execution-blocker-read`, `legacy-continuation-authority` (728 tests across 8 suites). - `pnpm typecheck` in `server/` passes. - Note: 7 tests in `chat-channels.integration.test.ts` ("reconciled chat retry delivery ownership") fail locally when the full file runs, on unmodified `master` too. A continuation from an earlier test in the shared database leaks into their global delivery sweep. They pass when run alone. This change does not cause them. ## Risks - Low risk. The exemption needs all of these: a legacy run; `cancelled` status with `errorCode = "cancelled"`; an expected system `control_plane` cancellation; no retained execution evidence (start, stage, controller, process, session, lease, finalization or execution events); and, for a retry, a predecessor that still exists and has no reconciliation hold. Operator Stops, failed predecessors and runs with any execution evidence keep today's behavior. - No migration. Historical holds are kept as audit rows. They only stop blocking. - Not covered here: a retry cancelled while its predecessor failed with unknown outcomes keeps its hold. That case needs a separate decision about where Retry should anchor. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, test runs) and extended reasoning. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
28ed2f1db0 |
fix(runner): support native OpenCode on macOS SSH hosts (#22534)
## Thinking Path > - Paperclip coordinates agents across local, SSH, and sandbox environments. > - Native Runner must launch artifacts for the execution host. > - A Linux controller currently selects Linux OpenCode assets for a macOS SSH host. > - Remote launch-file validation also accepts only ELF executables. > - The standard Core image must carry a verified Mac runtime for this host pair. > - This pull request adds that runtime and selects it for Apple Silicon SSH hosts. > - Self-hosted and hosted controllers can use the same generic implementation. ## Linked Issues or Issue Description **What happened?** A native OpenCode run on an Apple Silicon SSH host receives Linux controller artifacts. Its private launch-file verifier also rejects Mach-O files. A working legacy CLI agent does not exercise this path. **Expected behavior** The controller must select and verify the target's native daemon, Node, OpenCode executable, and proxy. Existing Linux targets and legacy agents must keep their current behavior. **Steps to reproduce** 1. Run a standard Linux Core image. 2. Select an SSH environment on an Apple Silicon Mac. 3. Start a native OpenCode agent with a compatible model connection. 4. Observe the incompatible runtime selection before useful agent work. **Paperclip version or commit** Base: `324ec1f537a9ba1e84239faa81bcef326a5dd1b7`. **Deployment mode** Docker or another Linux controller, with macOS ARM64 execution over SSH. Related work: #21662 covers local OpenCode confinement. #22236 covers SSH process cleanup. This change does not depend on either PR. No duplicate macOS OpenCode runtime PR was found. ## What Changed - Select a verified `darwin-arm64` runtime for OpenCode SSH targets. Preserve the Linux image default and explicit operator overrides. - Verify Mach-O launch files against the admitted architecture, file digests, and remote account. Keep existing Linux receipt and recovery behavior. - Build the Mac runtime on an Apple Silicon CI host with standalone Node 24.21.0. Keep OpenCode pinned to 1.18.34. - Package the sealed OpenCode runtime artifacts and required package metadata. Omit other harness distributions and their optional qualification inventories. - Verify archive provenance and safe extraction on Linux. Include the runtime in standard and merge-queue Core images. Avoid storing the transport archive in an image layer. - Reuse artifacts only from successful protected master image builds with identical runtime inputs. Test cache trust boundaries and register the script tests in CI. - Document runtime delivery, manual image inputs, and the initial Apple Silicon scope. No Cloud source, schema, or agent configuration changes. ## Verification - `pnpm -r typecheck` — passed. - `pnpm build` — passed. - Focused OpenCode artifact selection and private staging tests — 21 passed. - Focused native executor tests for OpenCode, SSH, and provider packs — 60 passed. - Real Rust daemon transport tests with the OpenCode protocol fixture — 4 passed. - Installed OpenCode 1.18.34 server qualification with a local provider fixture — 3 passed. - Runtime packaging, cache trust, workflow, image-contract, and merge-queue tests — 26 passed. - The CI release-workflow test group, including canary reuse and provenance — 218 passed. - Docker workflow and build-stamp guards — 29 passed after adding the Mac digest expectation, updating the excluded-source COPY expectation, and removing the redundant production commit ARG. - The source SDK registry, public-type, and evidence checks — 59 passed after updating only the root package metadata hash. Lock, compiler, parser, and model pins did not change. - Fresh-host provider-pack upload harness — 7 passed. The new regression first failed with `package_version:acpx`, then passed after the required metadata was preserved. - Node version policy — passed against a clean tracked-file snapshot. Generated local provider assets make the direct workspace scan fail; they are absent from the CI checkout. - Built, packaged, installed, and verified the actual Mac runtime. Both the controller verifier and the remote startup verifier accept its pins, target, sealed files, manifest, and package metadata. The pre-change private launch verifier rejects the real Mach-O files; the candidate accepts those same files. The dedicated archive is about 101 MB. - Live native smoke: real Mac daemon, private staged Mach-O files, OpenCode 1.18.34, and a local GLM-5.3 backend. The model read two files, edited the implementation, ran three tests, completed the semantic finish call, and summarized the three passes. An independent test run passed. The test file stayed unchanged. This used the existing `allow` mode and a scratch account-home fixture on a Mac. It does not prove hosted SSH dispatch. - The full CI workflow passed on `ae74808631f1933edec89aa1e80db7f2b756aca3`: server test shards, Runner Rust and native server tests, type checking, builds, browser suites, image checks, the native Mac producer, and Linux runtime installation. Greptile is 5/5 with no unresolved threads. - Local `pnpm test:run` used a disposable PostgreSQL 18 fixture after embedded Postgres failed to start because its macOS package lacks dynamic libraries. All six chat shards passed (1,971 tests). The redundant unsharded local run was interrupted during the general-server group after all current-head CI test jobs passed. The later local workspace and serialized groups did not run. The owned PostgreSQL fixture is stopped. This is not a local full-suite pass. Retained review failures: the first PR revision omitted package metadata and did not ignore downloaded image inputs. The fresh-host upload regression reproduced the metadata failure before its fix. Generated inputs are now ignored. CI also exposed a missing Node policy exception for the pinned Mac producer; the exception is limited to that producer job. A later policy attempt exposed an old exact-dependency assertion in canary reuse tests. The assertion now covers the added runtime and evaluates the publication gate for success, failure, cancellation, and skip outcomes. The Runner support suite then found that the new test registration changed a pinned root package input; the standard source registry generator updated that one hash, and all 59 affected tests passed. The server matrix then found four outdated image guard expectations and a duplicate production commit ARG. The focused image guards now pass after updating those expectations and keeping one commit ARG before Mac verification. Retained failures: the first producer attempt used Homebrew Node, which failed the relocation check. The successful producer used standalone Node 24.21.0. Live smoke attempts also encountered a stopped tunnel, an upstream model failure, and the existing Rust restriction on OpenCode permission requests in `ask` mode. The successful tool trace used the existing `allow` mode. Its initial reporter looked for tool names in generic item events; verification of the retained canonical tool events and an independent rerun confirmed the result. The upstream model failure is not explained by a later pass. Not run locally: a full Docker image build, because the existing Docker daemon does not respond. The PR adds native producer qualification and Linux installation verification to CI. Hosted deployment, remote service-account dispatch, and hosted continuation remain acceptance steps after deployment. ## Risks - A cold Mac runtime build adds CI time when Runner or producer inputs change. Reuse is bounded and accepts only a successful protected master producer. The artifact digest and runtime input identity remain verified. - Standard images gain a dedicated Mac runtime payload. Manual image builds can omit it; Mac OpenCode SSH runs then fail with a named missing-runtime error. Linux behavior remains available. - This release covers Apple Silicon SSH distribution. It does not qualify Intel Mac distribution or expand other harness support. - The OpenCode permission bridge keeps its existing behavior. This PR does not add `ask` approval support. - No saved run/session schema or provider pin changes. Existing Linux receipts retain their interpretation. A surviving admitted Runner bypasses new artifact discovery. Legacy agents are not converted. Existing account-change and old-receipt restoration tests remain in coverage. - No migration, cluster change, new sandbox image requirement, or Cloud control-plane change. A staging application rebuild and deployment are separate from this PR. ## Model Used OpenAI GPT-6, through Codex, with repository tools, code execution, tests, and SSH inspection. The session does not expose a more specific model ID or 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> |
||
|
|
856f14e507 | fix(dashboard): scope areas and responsibilities to each user (#22513) | ||
|
|
1b1861c29d |
Fix skill upload conflicts blocking first-agent onboarding (#22477)
## Thinking Path > - Paperclip manages agents and the skills they need to work. > - First-agent setup resolves the bundled skills before onboarding can finish. > - Skill packages use durable upload claims to protect their object-storage receipts. > - A failed attempt kept its claim active for ten minutes. A concurrent caller received an immediate conflict. > - This pull request expires a failed owner's unpublished claim and waits for an active upload to settle. > - Onboarding can retry skill setup without a false upload-in-progress error. ## Linked Issues or Issue Description **What happened?** First-agent onboarding could show "This skill package is being saved. Retry after its upload settles." during the subscription connection step. The agent's bundled skill setup called the package store. A failed upload retained its active claim, and calls from another database client also returned a conflict while an upload was in progress. **Expected behavior** A failed attempt permits an immediate retry with new object keys. Concurrent callers reuse the completed receipt or claim the failed attempt. They preserve another owner's active lease and every published receipt. **Steps to reproduce** 1. Fail the first object upload while resolving the first agent's bundled skills. 2. Retry the same skill selection before the ten-minute lease expires. 3. Observe the upload-in-progress conflict. The new regression reproduces this through `companySkillService.resolveRequestedSkillEntries`. **Paperclip version or commit** Reproduced on `6bf312270c3e`. **Deployment mode** Hosted onboarding; the package-store fix also applies to self-hosted instances. Related implementation: #18082. Searched open and closed pull requests and open issues for related skill-upload and lease failures. No duplicate fix was found. ## What Changed - Expire only the failed attempt's token-matched, unpublished upload claim. Keep its exact keys for the existing deletion outbox. Cleanup has a one-second client deadline and a transaction-local statement timeout. Queued cleanup skips its write after that deadline; failed cleanup retains the original crash lease. - Wait for a competing package preparation within the existing three-minute deadline. Re-read the receipt every 250 ms while this concrete request remains active. Release the database connection between reads and stop on cancellation. This adds no idle worker or permanent polling. - Preserve cancellation reasons, published receipts after lost commit replies, and claims acquired by a newer owner. - Add real PostgreSQL regression coverage for first-agent bundled skill setup, cross-client contention, failed-owner takeover, crash expiry, cancellation, ambiguous publication, and ownership changes. - Document upload recovery behavior. No schema or public API change is required. ## Verification - Red: four new or updated checks failed against the original implementation. They reproduced the exact conflict and the retained ten-minute lease. - Green: 189 targeted tests passed across `skill-package-upload.test.ts`, `skill-package-store.test.ts`, `skill-package-work.test.ts`, both package-storage migration suites, and `agent-skills-routes.test.ts`. The combined run passed 188 tests. The final SQL-lock regression passed separately. - Command: `pnpm exec vitest run server/src/__tests__/skill-package-upload.test.ts server/src/__tests__/skill-package-store.test.ts server/src/services/skill-package-work.test.ts server/src/services/skill-package-storage-migration.test.ts server/src/services/skill-package-storage-migration-postgres.test.ts server/src/__tests__/agent-skills-routes.test.ts`. - `pnpm --filter @paperclipai/server typecheck` passed, including source and test layers. - The cancellation test first exposed Node's timer wrapping the caller's abort reason. The final implementation preserves that reason, and the full targeted run passed. - Greptile identified an unbounded cleanup write. Two new real-PostgreSQL tests reproduced delayed errors and cancellations behind an occupied one-connection pool. They now pass and prove that late cleanup skips its write. A further row-lock test proves that the PostgreSQL statement timeout frees the pool while another transaction still holds the package row. - Local setup initially lacked macOS embedded-Postgres library links. Repaired ignored dependency links before the red and green database tests. The initial server typecheck also lacked SDK links for excluded plugin packages; ran the maintained `node scripts/link-plugin-dev-sdk.mjs` helper before repeating it. - `pnpm verify --explain` returned exit 2 and requested broader CI coverage. No full local suite was substituted for that CI requirement. - `git diff --check` passed. Reviewed the full diff for secrets, private URLs, personal data, generated files, and run artifacts. - Final revision: `4b4814ac01522599901a3dc29f650a1b33c0b4e2`. [CI run](https://github.com/paperclipai/paperclip/actions/runs/44880245673) passed all applicable checks, including typecheck, build, all general and serialized server test shards, all e2e shards, Runner verification, and the final verify gate. [Greptile review](https://github.com/paperclipai/paperclip/pull/22477#issuecomment-7059199437) scored this revision 5/5 with no unresolved threads. GitHub reports the branch as mergeable and clean. ## Risks Contended preparations now wait within their existing request deadline. A crashed process or an unavailable cleanup database still uses the ten-minute lease expiry. Genuine storage failures remain errors; this change does not hide an unavailable backend. The existing object deletion grace remains intact. Live provider authorization and a deployed Cloud onboarding journey were not run. Tenant release and deployment are separate from this source fix. No production migration is needed. ## Model Used OpenAI GPT-6.1 Sol (`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> |
||
|
|
6bf312270c |
fix(ci): stabilize database-backed readiness checks (#22476)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - CI checks its recovery workers, attention routes, and external chat admission against real PostgreSQL. > - Large fixtures start from an empty database without statistics for their new rows. > - Slow query plans can exhaust test deadlines before the behavior checks finish. > - Route responses can also leave wakeups writing rows while teardown deletes their agents. > - Setup admission takes an endpoint lock that can deadlock with resource foreign-key checks and agent invalidation. > - This pull request prepares fixture statistics, drains pending work, and uses a compatible endpoint lock. > - The benefit is reliable readiness checks with the same fixtures, assertions, and deadlines. ## Linked Issues or Issue Description Refs: #21941, #21831, #21132. The compiler-memory mitigation in #19383 is already merged and is not repeated here. **What happened?** The recovery census and review-attention equivalence tests repeatedly timed out on unrelated PRs. Recovery-action teardown also failed on an agent-wakeup foreign key, and concurrent first GitHub mentions could deadlock during resource admission. Examples: [census timeout](https://github.com/paperclipai/paperclip/actions/runs/44868742060/job/136738633187), [review timeout](https://github.com/paperclipai/paperclip/actions/runs/44856500775/job/136732143246), [cleanup failure](https://github.com/paperclipai/paperclip/actions/runs/44866635624/job/136731817497), and [chat deadlock](https://github.com/paperclipai/paperclip/actions/runs/44845946341/job/136667344125). **Expected behavior** The complete fixtures retain their regression coverage, pending wakeups finish before deletion, and concurrent chat admission completes with exactly one setup destination enabled. **Steps to reproduce** 1. Run the two timeout suites against a freshly seeded database before its statistics refresh. 2. Complete an issue-update request that schedules an assignee wake, then delete its fixture immediately. 3. Run the new resource-admission regression on the base revision. It forces the endpoint/agent lock order and fails with PostgreSQL SQLSTATE `40P01`. **Paperclip version or commit** Base: `33ffaa5b9a2e0954c2afc063572346cb1be534a7`. ## What Changed - Run `ANALYZE` on the populated fixture tables after seeding the existing census and review-attention populations. No fixture reduction, assertion removal, retry increase, or deadline increase. - Await `drainActiveRunExecutions()` before recovery-action fixture cleanup. This includes pending wake admission after HTTP responses. - Use `NO KEY UPDATE` for setup endpoint admission. It still serializes competing admission transactions and endpoint mutations while allowing resource foreign-key `KEY SHARE` locks. - Add a real PostgreSQL regression using the real `ensureResource` write, with barriers that force concurrent endpoint admission and an agent-locked resource insert. Both transactions must finish and exactly one destination must become enabled. - Document fixture statistics, teardown ownership, and admission locking in `doc/test-infrastructure.md`. ## Verification - The new concurrency regression fails on the original endpoint lock with SQLSTATE `40P01`, then passes with `NO KEY UPDATE`. - Both timeout suites pass with their full populations and original deadlines: 8 tests. - The full recovery-action suite passes: 120 tests. - Existing GitHub first-repository and disabled-repository integration checks pass: 7 tests. - The new PostgreSQL concurrency regression passes: 1 test. - The local baseline timeout suites passed slowly; the review equivalence case took 35.8 seconds before statistics and 0.63 seconds afterward. These are local observations, not a CI speed guarantee. - The first broad typecheck caught an unsupported `Promise.withResolvers` type in the new test. The barriers now use ordinary promises compatible with the repository target. The final `pnpm -r typecheck` passes. - `git diff --check` passes. - `pnpm -r typecheck` and `pnpm build` pass. The full local `pnpm test:run` attempt stopped after all six chat shards: 1,969 tests passed and two Slack tests failed on skill-root discovery. The remaining local groups did not run. Both failures reproduce with the production change reverted to `origin/master`: the resolver selects an unrelated ancestor `skills/` directory without `slack/SKILL.md`, which also prevents the mocked Slack run from starting. This is a confirmed baseline local-layout issue, not a passing full-suite result. The [complete CI run](https://github.com/paperclipai/paperclip/actions/runs/44873350026) passes on `66c146b177b50e052a21921644dfd626c96c010d` on attempt 1. The PR check rollup has 58 successes, three expected skips, and no pending or failing checks. [Greptile reviewed the current head `66c146b`](https://github.com/paperclipai/paperclip/pull/22476#issuecomment-7058185817) at 5/5 with no actionable findings. Review follow-up verification: - Replaced the resource-read stub with the real `createChatInboundAuthority(...).ensureResource` persistence path. The revised regression fails with `FOR UPDATE` and PostgreSQL `40P01`, then passes with `NO KEY UPDATE`. - Scoped `ANALYZE` to the fixture tables and moved the behavior note from `DEVELOPING.md` to `test-infrastructure.md`. - All 9 affected tests pass after these edits; the complete server typecheck also passes. The production lock change is unchanged from the earlier full workspace typecheck and build passes. - The previous CI attempt had two interrupted jobs: [Runner static checks](https://github.com/paperclipai/paperclip/actions/runs/44872465981/job/136749952142) and [serialized server 9/9](https://github.com/paperclipai/paperclip/actions/runs/44872465981/job/136749952782). Both logs record a runner shutdown. The static lane reported 2,371 passing tests before cancellation; the interruption is not counted as a pass. The final head passes the complete fresh CI run linked above, including both lanes. ## Risks Low scope. Production code changes only the endpoint row-lock strength. The regression uses real foreign keys and connector invalidation triggers; the existing integration checks retain first-destination serialization and disabled-destination behavior. No schema, API, or authorization changes. `ANALYZE` updates only test-database statistics. Drain failures still fail teardown. All current-head remote checks now pass, including typecheck, build, tests, and e2e. The baseline local full-suite failure and unrun remaining local groups are recorded above; focused local checks pass. The already merged compiler-input fix does not establish the cause of every past runner shutdown. ## Model Used OpenAI GPT-6.1 Sol (`gpt-6.1-sol`) through the Codex harness, with xhigh reasoning and shell/code execution. The session does not expose its 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> |
||
|
|
6b9952525d |
build(server): omit tests from production compilation (#19383)
Use a separate production TypeScript configuration that excludes colocated tests while retaining every runtime source input and keeping tests in source typechecking. Verify the real compiler input sets and bound compiler-list capture for the larger source graph. Validation: focused compiler-input regression passes; fresh CI has 61 passing checks and three optional skips on 181ad8d; Greptile Apex is 5/5 with no unresolved comments. Co-Authored-By: Scott Goodson <scottgoodson@gmail.com> Co-Authored-By: Devin Foley <devin@paperclip.ing> Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
18978bdc1d |
fix(native): preserve named human unblock owners (#22438)
## Thinking Path > - Paperclip manages work carried out by agents and people. > - Native finalization converts a runner result into a durable task status and follow-up effects. > - A blocked result can name the person who must decide what happens next. > - The classifier discarded that identity, and the arbiter saved a generic board owner. > - This could replace an explicit user owner saved through the task API and leave the decision outside that person's inbox. > - This pull request resolves human owners against active company membership and preserves them through commit. > - The named person receives the existing blocker card, and the blocked worker does not get another wake. ## Linked Issues or Issue Description **What happened?** Native finalization replaced a named human unblock owner with `board`. It also overwrote an explicit user owner saved through the task API during the turn. **Expected behavior** Keep a valid human unblock owner and route the blocker card to that person's inbox. Use the board when the reference is unknown, inactive, ambiguous, or outside the company. **Steps to reproduce** 1. Create an active company member with a distinct display name. 2. Have a native worker report a human blocker using that name. 3. Finalize the run and read the task's unblock owner and the member's inbox. Related: #21265 covers named agent handoffs and retains board ownership for people. This change covers human member routing and does not add agent handoffs. ## What Changed - Resolve a human owner from an explicit user ID, an API-bound user, or one matching company member by ID, full name, or email. - Preserve the user owner for both blocker scopes and durable dependency waits. - Recheck the accepted result and active membership under the status commit lock, including board fallbacks. Rebuild the assessment on every status retry so a newly saved owner or revoked membership cannot be overwritten by stale evidence. - Enforce `canAssignTasksToHumans` before binding a human owner, including dependency waits that do not emit a `bind_blocker` effect. - Validate the result before retiring automatic completion reviews. Invalid results leave existing reviews pending; valid results retain the normal cleanup path. - Keep human blocker routing out of the agent wake queue. - Add embedded Postgres regressions for finalization, replay, personal attention, invalid owners, late API ownership changes, membership revocation, permission denial, and answer continuation for human-owned blockers. - Make the answer-continuation fixture persist the same result it classifies, so commit-time evidence validation sees realistic saved evidence. Assert the resolved user owner in both blocker scopes. - Let the recovery census clock advance at real-time pace during delivery I/O waits. This handles callbacks and nested timers without jumping to maintenance deadlines. Preserve the existing real-clock timeout and recovery assertions, and name pending queues in failures. - Document human blocker resolution and compatibility. ## Verification - Red-green reproduction: three ownership regressions failed on the original implementation and passed with the fix. - Red-green race reproduction: late API ownership changes and membership revocation failed before the commit recheck and per-retry reassessment fixes. Each finalization invocation now has to commit; a later replay cannot hide an exhausted retry. - Red-green review-retirement reproduction: a new invalid result cancelled a proven automatic review before throwing `native_result_invalid_disposition`. The new invalid/valid regression pair verifies that invalid results preserve the pending review and task decision, while valid completion still retires the card. - Red-green answer-continuation reproduction: both human-owner cases failed with `native_status_race` while saved evidence was empty. Persisting the classified result and asserting `{ userId }` restored all 13 answer-continuation cases, including worker resumption. - Red-green permission reproduction: an agent with `canAssignTasksToHumans: false` could bind a human blocker before the permission check. Direct and dependency cases now refuse finalization without creating a personal blocker card. - On refreshed head `a6d37916546`, `pnpm --filter @paperclipai/server exec node scripts/typecheck-layers.mjs` passed on macOS with Node 24. - On refreshed head `a6d37916546`, from the repository root, `CI=true node node_modules/vitest/vitest.mjs run server/src/services/native-runtime/native-agent-blocker.integration.test.ts server/src/services/native-runtime/status-arbiter.test.ts server/src/services/native-runtime/evidence-classifier.test.ts server/src/__tests__/native-status-reassessment-work.test.ts server/src/__tests__/routable-blocked.test.ts server/src/__tests__/native-status-arbiter-corpus.test.ts server/src/services/native-runtime/native-environment-blocker.integration.test.ts server/src/__tests__/heartbeat-blocked-question-answer.test.ts server/src/__tests__/issue-recovery-live-run-agent-census.test.ts` passed: 292 tests in nine files on macOS with Node 24. - Red-green census reproduction: both post-I/O callbacks and nested timers must settle without jumping to a future maintenance deadline. The nested case timed out under a zero-only clock pump; the shared automatically advancing census clock handles both. - Final CI at `a6d37916546`: [run 44848053016, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/44848053016/attempts/2) completed successfully. Build, Canary Dry Run, policy, every server and workspace test shard, Runner checks, serialized suites, e2e, and verify are green. Greptile review 7 is 5/5 on the same head, Superagent and other security checks pass, and no review threads remain unresolved. A local merge-tree check against master `621c5577cdf` also passed with no conflicts. - Current CI at `a6d37916546`, [run 44848053016](https://github.com/paperclipai/paperclip/actions/runs/44848053016): attempt 1 finished with 13 interrupted nonaggregate jobs, each with an explicit runner shutdown signal in its log. Nine signals occurred within three seconds on separate m6a.xlarge hosts in us-east-1a; Build and Canary also shut down later. Aggregate e2e and verify failed on those dependency results. The underlying termination cause remains unknown. Shared CI settings are unchanged. - The [automatic recovery run](https://github.com/paperclipai/paperclip/actions/runs/44849704877) skipped retry because Build had only the annotation `Process completed with exit code 143.` The classifier reads logs for cancellation annotations, but did not read this job's log. That log explicitly records a runner shutdown at 01:10:49 UTC. The other 12 failed jobs were recognized as runner loss. After verifying all 13 logs, manually requested failed-job attempt 2; it completed successfully without source or configuration changes between attempts. The shared recovery classifier is unchanged; this false negative remains a documented follow-up. - Historical CI at `cf601ba`: all server shards (including the census), Runner checks, typecheck/release registry, serialized suites, e2e, and canary dry run passed. Build received runner shutdown signals on attempts 1–7; aggregate verify failed because Build failed. Attempt 5 diagnostics show shutdown while the job lease was valid. Attempt 7 stopped after server dependency preparation, without a compiler error. The termination cause remains unknown. Three recent PRs completed Build on the same AWS fleet; this is not evidence of a fleet-wide outage. Shared CI settings are unchanged. - Diagnostic comparison at `cf601ba`: the server compiler passed locally on macOS with four checkers, full typechecking, and declaration/JavaScript emission (`node ../scripts/run-tsc.mjs --checkers 4 --extendedDiagnostics` under Node 24). The monitored process group peaked at about 10.5 GiB RSS and finished in 25.8 seconds. This does not establish the cause of the Linux runner shutdowns. - Refreshed the branch onto master `611dc68581c` without conflicts; the PR source diff is unchanged. Greptile review 7 scored head `a6d37916546` 5/5 with no new actionable findings and no unresolved review threads. All applicable CI gates passed on attempt 2. - Full local workspace build at `cf601ba` passed on macOS using Node 24 and the documented single-thread compiler mode: `PAPERCLIP_TYPECHECK_LOW_MEMORY=1 npx --yes --package=node@24 --package=pnpm@9.15.4 pnpm build`. This includes typechecking and artifact emission. The tracked working tree stayed clean. - `pnpm verify --explain` returned exit 2 because this documentation path requires broad CI coverage. Fresh CI will supply that coverage; the full local test suite was not run. - Earlier CI build and canary jobs received runner shutdown signals. The server shard also exposed an answer-continuation fixture that saved an empty result while classifying a named human. That mismatch was reproduced locally, and the fixture now persists the classified result and checks the user owner. Fresh CI is required for this revision. - `git diff --check` and the staged gitleaks scan passed. The diff was also checked for private issue references, identifiers, URLs, and personal data. ## Risks - Name and email matching ignore case. Several matches fall back to the board. Invalid explicit IDs never fall through to another person. - Resolution adds bounded reads only when a native result reports a human blocker. It adds no worker, timer, or idle scan. - No database or result-schema migration is required. Existing board and agent decisions remain readable. Committed historical decisions are not rewritten; new finalizations use current membership. - This changes human routing only. It grants no access and changes no merge, approval, or dependency policy. ## Model Used - OpenAI GPT-6.1 Sol (`gpt-6.1-sol`) through Codex in T3 Code, with xhigh reasoning effort, code editing, shell tools, 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 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> |
||
|
|
b4cea5b5a4 |
fix(runner): show disk exhaustion before recovery errors (#22448)
Show the confirmed sandbox disk failure before a later lost-turn or restore error in saved run errors and both run detail views. Preserve the original diagnostics and leave scarce inodes available when preparing the existing runner relaunch reserve. Verified focused regressions, scoped typechecks, and full CI on the reviewed revision, including Runner checks and all eight end-to-end shards. Greptile is 5/5 with all review findings resolved. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
ae2afd525b |
Make harness choices deployment-configurable
Managed deployments need to control harness availability without changing Core policy. Add a generic environment contract and apply it across harness and model selectors, preserving saved supported profiles and validating import, team, and invite selections. Document deployment ownership in agent guidance. Validation: focused local tests and typechecks passed; all applicable CI checks passed on the reviewed head. Greptile scored 5/5 with no unresolved comments. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
9bc90cb189 |
Show useful task notification content (#22441)
Task notifications repeated identifiers and omitted useful activity details. Use task titles, actor and comment previews, and concrete field changes. Share bounded secret redaction per event after viewer access checks. Suppress updates without useful details. Verified with focused regression tests, package typechecks and server build, and the full green CI run. Greptile scored the final head 5/5 with no unresolved review threads. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
2898acee2d |
fix: exclude responsibility repairs from Mine participation (#22434)
Exclude responsibility-repair audit entries from personal task participation. Maintenance attributed to an operator no longer pulls unrelated tasks into Mine, unread badges, or task notifications. Preserve audit history and genuine participation through creation, assignment, comments, deliberate edits, and pending requests. Add database regressions and document the rule. Verified with 174 targeted tests, server typecheck, fully green CI, and Greptile 5/5 with no unresolved review comments. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
dce4d47f60 |
feat(plugins): carry Grok, Copilot and OpenCode credentials to plugin Runners (#22359)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Environment-driver plugins can run `paperclip_runner` tasks on hosts
that the plugin owns
> - Core transfers the selected managed AI credential to the plugin as a
typed task credential
> - The credential contract has only two types: a Codex auth file and a
direct Claude credential
> - Grok, GitHub Copilot and OpenCode agents in a task-capable plugin
environment therefore fail closed, although the Runner already reads
their credentials from its environment
> - This pull request adds one generic, allowlisted environment
credential for these three harnesses and accepts the Runner's Grok
launch settings
> - The benefit is that plugin-provided Runner execution can run Grok,
Copilot and OpenCode agents with their selected connection
## Linked Issues or Issue Description
**Subsystem affected**
Plugin environment tasks (`packages/plugins/sdk` task contract) and
plugin-provided Runner execution in `server`.
**Problem or motivation**
An agent with the Grok, Copilot or OpenCode harness cannot run in a
plugin environment that runs Runner tasks. Core stops at credential
preparation with "Plugin Runner does not support the selected credential
provider". A Grok agent fails before that point too. The Runner emits
`grokEffort` and `grokDisableWebSearch` in its launch requirements (Core
turns off Grok web search by default), but the strict `settings` schema
of `environmentRunnerLaunchRequirementsSchema` rejects both keys.
**Proposed solution**
Core transfers the selected connection's credential variables for these
harnesses through one typed `provider-env` credential. Each provider has
a fixed allowlist of complete variable sets. The plugin sets the
variables in the Runner process environment.
**Alternatives considered**
One credential type per harness (`grok-env`, `copilot-env`,
`opencode-env`). This adds a type for each new harness. One generic type
with an exported allowlist keeps the same strictness with less surface.
**Roadmap alignment**
The roadmap lists Grok and OpenCode as supported harnesses. This change
lets plugin environments run them. It adds no new product concept.
**Additional context**
Grok subscription login (an auth file with refresh and writeback) is out
of scope. It still fails closed, with an error that names the xAI API
key as the supported option.
## What Changed
- `packages/plugins/sdk`: Added the `provider-env` task credential: `{
type: "provider-env", provider: "grok" | "copilot" | "opencode",
environment }`. The environment must contain exactly one complete
variable set for the provider and no other variable. Values are
non-empty, NUL-free and at most 65,536 characters, as for the other
credential types.
- `grok`: `XAI_API_KEY`
- `copilot`: `COPILOT_GITHUB_TOKEN`
- `opencode`: `OPENROUTER_API_KEY`, or `PAPERCLIP_AI_PROVIDER_URL` with
`PAPERCLIP_AI_PROVIDER_KEY`
- `packages/plugins/sdk`: Exported the allowlist as
`ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS` and the
`PluginEnvironmentTaskCredentialProvider` type. `claude-env` and
`codex-auth-json` do not change.
- `packages/plugins/sdk`: Added `grokEffort` (`minimal` to `xhigh`) and
`grokDisableWebSearch` (boolean) to the launch requirements `settings`,
with the types that the Runner uses.
- `server`: `preparePluginRunnerCredentials` now transfers the selected
connection's variables for the `grok`, `copilot` and `opencode`
harnesses, with the same account identity semantics as the Claude
branch. It refuses a Grok subscription, a Grok base URL override, and an
incomplete or ambiguous set. The error never contains a credential
value.
- `server`: The submit check now matches a `provider-env` credential to
the task harness. Before, it treated every non-Codex credential as
Anthropic.
- Drift test:
`server/src/__tests__/plugin-runner-credential-names.test.ts` checks the
SDK key sets against the Runner. The SDK list stays written by hand, and
the Runner keeps its own lists of forwarded names. For `grok` and
`copilot`, each name must be in `ACPX_CREDENTIAL_NAMES`, survive sidecar
admission with the session binding that the Runner mints, and reach the
agent process. The binding requirement must match the Rust sidecar's
candidate agents. For `opencode`, each name must be in the OpenCode
proxy environment set. Each name must also be in the Rust sidecar
credential keys or the Rust OpenCode provider keys. The test reads those
from the Runner source, as the Codex security test does. A provider
without a Runner route fails the test.
`OPEN_CODE_RUNNER_ENVIRONMENT_KEYS` is now exported for this test.
- Docs: Added a "Typed credentials" section to
`doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md`. It also documents the ACPX
credential binding that the Runner requires with a Copilot token.
Updated `doc/plugins/PLUGIN_RUNNER_EXECUTION.md`.
## Verification
- `npx vitest run tests/environment-task-release-resume.test.ts
tests/environment-tasks.test.ts` in `packages/plugins/sdk`: 96 passed.
The tests accept each valid shape. They reject mixed sets, two sets,
extra variables, another provider's variable, empty values, NUL bytes,
oversized values, unknown providers and extra fields, on `submit` and on
`resume`. They also check that every published allowlist set parses.
- `npx vitest run
src/services/native-runtime/plugin-runner-credentials.test.ts
src/__tests__/environment-task-runtime.test.ts` in `server`: 79 passed.
The new tests cover each provider's transfer, Grok subscription refusal,
Grok routing refusal, the fail-closed cases without value leaks, harness
matching at submit, and Runner-built Grok requirements
(`runnerProviderLaunchRequirements`) that parse through the task
contract and produce a Grok launch.
- `npx vitest run src/__tests__/plugin-runner-credential-names.test.ts`
in `server`: 4 passed. I broke each list locally to confirm that the
test fails: a renamed SDK key, an SDK provider without a Runner route,
and a dropped name in the Rust sidecar keys, the Rust candidate agents,
the Rust OpenCode keys and the TypeScript OpenCode keys. Each change
failed the test.
- `node scripts/typecheck-layers.mjs` in `server` (includes
`src/__tests__`): no errors.
- `npx vitest run
server/src/services/native-runtime/plugin-runner-probe.test.ts` (from
the root): 15 passed.
`server/src/services/native-runtime/plugin-runner-task.test.ts`: passed.
- `tsc --noEmit` for `packages/plugins/sdk` and `server`: no errors.
- I did not run the full suite locally. CI supplies that coverage.
## Risks
- Low risk for existing plugins. The change only adds a credential type
and two optional settings. A plugin that does not handle `provider-env`
gets a typed value that it does not recognize. Before this change, Core
failed these runs before it called the plugin.
- A plugin must set `PAPERCLIP_ACPX_CREDENTIAL_BINDING` for a Copilot
task. Otherwise the Runner refuses the token. The new doc section shows
the value.
- An OpenCode gateway connection without a key (`auth: none`) still
fails closed, because every value must be non-empty.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) by Anthropic, through Claude Code
with tool use (shell, file edits, test runs).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [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>
|
||
|
|
7ef731ec7e |
fix(workspaces): name incompatible project storage when a volume-free server refuses a run (#22398)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - A volume-free server admits a run only when its task files have
durable storage.
> - A project can keep its task files in plugin storage, such as an
agent-computers plugin. Only environments of that plugin can use that
storage.
> - A task keeps its selected source when it moves to another project.
So the source project's storage still applies after the move.
> - When an agent in a Daytona sandbox got such a task, the volume-free
check refused the run with a generic message. The message said "native
Paperclip Runner with remote workspace storage". The agent already used
native Paperclip Runner.
> - The run ended `setup_failed`. The task offered Retry, but Retry
always failed the same way. Sentry received the refusal as an unexpected
run failure.
> - This pull request finds the real cause with the existing
project-storage compatibility rule. It records the refusal as a
configuration problem that an owner must repair.
> - The benefit is a message that names the storage and the environment,
a task notice with the correct owner action, and no Sentry noise for
this known configuration state.
## Linked Issues or Issue Description
Related: #17552 (a task project and its selected workspace are separate
settings, so a moved task keeps its source).
**What happened?**
On a volume-free server, a task's source project used plugin storage.
The assigned agent used a sandbox environment that cannot use that
storage. Workspace preparation refused the run with "Volume-free servers
require native Paperclip Runner execution with remote workspace
storage." The run failed with `setup_failed`. The task notice told the
user to press Retry. Each retry failed the same way. Sentry received
each refusal as an unexpected run failure.
**Expected behavior**
The refusal names the real cause: the project's workspace storage does
not support the agent's environment. The run fails
`configuration_incomplete`. The task notice tells the owner to use an
agent in a compatible environment, or a source from a project for this
environment. Sentry does not receive this known configuration state.
**Steps to reproduce**
1. Start the server with `PAPERCLIP_EPHEMERAL_SERVER=true`.
2. Create a project whose storage is a plugin workspace provider.
3. Assign a task in that project to a Paperclip Runner agent in a
Daytona sandbox environment.
4. Wake the agent. The run fails `setup_failed` with the generic
volume-free message.
5. Move the task to a project without plugin storage and comment "try
again". The task keeps its source, and the run fails the same way.
**Paperclip version or commit**
Seen on a hosted volume-free staging server. The new regression test
fails on `master` at
|
||
|
|
812e30d423 |
fix(ui): drop Firefox for iOS injected-script errors from browser Sentry (#22378)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The browser UI sends unhandled errors to Sentry through `ui/src/lib/sentry.ts` > - Firefox for iOS injects its own Reader-mode and helper scripts into each page. These scripts read a `__firefox__` global > - When one of these scripts runs before its setup is complete, the page's `window.onerror` reports an error. Sentry then records it as a Paperclip error > - No Paperclip code defines or reads `__firefox__`. These reports are browser noise and hide real errors > - This pull request drops errors whose message contains `__firefox__` with the built-in Sentry `ignoreErrors` option > - The benefit is fewer false error reports. All other errors from the same browser still go to Sentry ## Linked Issues or Issue Description **What happened?** Hosted browser Sentry recorded two errors from one page load on Firefox for iOS: `TypeError: undefined is not an object (evaluating 'window.__firefox__.reader')` and `ReferenceError: Can't find variable: __firefox__`. Both events have the same trace and the same timestamp. The only stack frame is the page document (line 1, column 19), not a Paperclip bundle file. **Steps to reproduce** 1. Open a Paperclip page in Firefox for iOS. 2. Let the browser's Reader-mode script run before its `__firefox__` setup is complete. 3. See the `__firefox__` error in the browser Sentry project. **Expected behavior** Sentry does not record errors that come from scripts the browser injects. **Actual behavior** Sentry records them as unhandled Paperclip errors. No duplicate or related public PRs were found (searched for `__firefox__` and "firefox ios sentry"). ## What Changed - `ui/src/lib/sentry.ts`: add `ignoreErrors: ["__firefox__"]` to the browser Sentry init options. A module comment tells why. - `ui/src/lib/sentry.test.ts`: add tests that use the real Sentry SDK. The tests send both `__firefox__` messages and make sure that Sentry drops them. Each test also sends a normal app error and makes sure that Sentry keeps it. - `doc/observability.md`: describe the filter. Correct an old line that said that the browser adds no `beforeSend` hook. ## Verification - `cd ui && pnpm exec vitest run src/lib/sentry.test.ts src/lib/browser-error-context.test.ts`: 55 passed. - Without the fix (tests kept), the 3 new tests fail. - `pnpm verify` was not run locally because of a partial dependency install. CI runs the full suite. ## Risks - Low risk. The filter drops only messages that contain the string `__firefox__`. Paperclip code does not use that name. All other errors are not changed. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code execution in an agent harness. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
62bc0519d9 |
fix(native): bound per-turn harness backups by inactivity, not total time (#22382)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - After a remote native turn is accepted, the executor saves the provider's harness state to durable storage, so another web server can continue the same conversation. > - That save runs under a fixed 300 s total deadline (`AbortSignal.timeout(300_000)`). The deadline covers archive capture, digest, encryption, the upload, any storage-outage wait and a full verifying read-back. > - On staging, five accepted runs failed this save 337–388 s after it began. The run then reported `native_workspace_sync_out_failed` with "The operation was aborted" or tar-stream's "already finalized or destroyed", and workspace copy-back went to retry. > - #19906 fixed the same fixed-deadline rule on the restore side. The write side still uses it. Since #20772/#20871 the save also waits out storage throttling and outages for up to five minutes, which cannot finish inside a five-minute total. > - This pull request bounds the upload and the read-back by inactivity instead of total time. A slow transfer continues while the store makes progress. A transfer that stops fails with a named code. > - The benefit is that an accepted turn no longer loses its provider backup only because the backup is large or the store is slow. ## Linked Issues or Issue Description Refs #19906 (same idle-deadline rule for failover-backup restores), #20772 and #20871 (file-source resends and storage-outage waits during the save), #19108 (stops tar-stream from hiding the real abort), #18932 (durable harness backups). **What happened?** On staging, five native per-turn runs failed within one hour, all after the provider turn was accepted. In each run, `harness_state.backup.persist` failed after 359,588 / 365,422 / 387,471 / 383,801 / 337,335 ms, and `session.checkpoint.persist` failed with it. The only fixed limit on that path is `AbortSignal.timeout(300_000)` around `persistNativeHarnessBackup` in `native-session-executor.ts`. The durations sit just above 300 s, plus a variable sandbox sync-out step before the save. Errors were reported as "The operation was aborted" and, before #19108, as "already finalized or destroyed". **Expected behavior** An accepted turn saves its provider backup while the store keeps making progress, even when the total time is more than five minutes. A write or read-back that stalls fails with a named, diagnosable code. A failed save publishes no backup. **Steps to reproduce** 1. Persist a native harness backup through a store that takes upload chunks slowly, so the full save takes longer than the deadline. 2. With the executor's fixed total deadline, the save fails with "The operation was aborted" and publishes nothing. 3. A store that stops taking bytes, with no caller deadline, waits indefinitely. ## What Changed - `native-harness-backup-storage.ts`: generalize `withDownloadProgressDeadline` into `withTransferProgressDeadline`. It still wraps `getObject` exactly as before, and it now also wraps `putFile` with a five-minute idle timer: - A provider that reads the stream body (local disk) renews it with each chunk it takes. - A provider that sends the file source itself (S3 with `sourceFile`, which never reads the stream) renews it with each request the store answers, each multipart part it takes, and each resend or outage wait that starts. - After the last of them the timer stays armed until the store answers, so a write that never completes is named too. - `persistNativeHarnessBackup` gains `transferIdleTimeoutMs` and `persistMaxMs` (default 30 minutes). The outer bound wraps the whole save, including the storage-outage wait. With an idle limit, a stalled upload throws `native_harness_storage_upload_stalled`, a stalled read-back throws `native_harness_storage_download_stalled`, and the whole save throws `native_harness_storage_persist_deadline_exceeded` at the outer bound. Caller cancellation keeps its own reason, and a storage outage that outlasts its own budget still surfaces as the storage error. Callers that pass no idle limit (controller archive, offline migration, preservation) are unchanged. - `storage/request-stats.ts`: add `observeStorageProgress(onProgress, work)`, an `AsyncLocalStorage` observer called from the existing `recordStorageRequest`, `recordStoragePart` and `recordStorageBackoff` hooks. It is scoped to the wrapped `putFile` call only, and a throwing observer is ignored. Stats collection is unchanged. - `native-session-executor.ts`: the per-turn backup passes `NATIVE_HARNESS_UPLOAD_IDLE_TIMEOUT_MS` (five minutes) instead of `AbortSignal.timeout(300_000)`. - Restore behavior and error codes are unchanged: `withDownloadProgressDeadline` now delegates to the shared helper with the same defaults. - `doc/database-backups.md`: document the write-side idle limit, what counts as progress, and the new codes. Previous-release story (`rules/upgrade-safe-run-state.mdc`): no persisted shape changes. Backup rows, references, receipts and checkpoints are unchanged. A deploy that lands during a save stops the process, and the pending row is never published, as before. ## Verification Run from `server/` (provider env vars unset): - `pnpm exec vitest run src/services/native-runtime/native-harness-backup-upload-deadline.integration.test.ts`: 6 tests passed. They use embedded PostgreSQL, local-disk storage and an incompressible 1 MB acpx backup. - "keeps saving a backup whose upload outlasts the idle window while the store keeps taking bytes". Under the former fixed-total policy the same slow upload fails with "The operation was aborted" and publishes nothing. With the idle limit it completes after more than twice the window and restores. - "names an upload that stops taking bytes and publishes no backup", then saves the same source once the store responds. - "keeps a file-source upload going while the store answers its requests, and names one that stops". The fake store never reads the stream and records each request answer the way the S3 provider does. - "names a read-back that stops sending bytes and publishes no backup". - "stops at the outer bound while an upload still progresses". - "lets Stop end a progressing upload with its own reason". - RED, part 1: with `native-harness-backup-storage.ts` and `request-stats.ts` reverted to `master`, 4 tests fail. Three stall tests hang until the 10 s test timeout, and the outer-bound test resolves instead of rejecting. - RED, part 2: with only the progress observer disabled, the file-source test fails with `native_harness_storage_upload_stalled` on an upload that is still progressing. - `native-harness-backup-*` suites, `native-harness-online-preservation`, `src/storage/`, `storage-request-stats` and `storage-s3-multipart-backoff`: 200 of 201 passed. The one failure, `native-harness-backup-cleanup.test.ts` ("removes retired backups containing immutable skills…", expected mode 256 to be 292), fails the same way on unmodified `master` in this sandbox. - `native-session-executor.test.ts`: 1541 of 1542 passed. The new assertion checks that the per-turn backup passes `transferIdleTimeoutMs` and no fixed signal, and flipping it fails the `opencode-new-durable*` cases. The one failure, "compares export process compatibility without changing conversation identity (changed: false)" (`db.transaction is not a function`), fails the same way on unmodified `master`. - `node scripts/typecheck-layers.mjs`: no errors in `server/`. The local filtered install lacked some CLI/UI/demo packages, which reported unrelated errors. CI covers the full typecheck. Not verified: a live staging run with this build. The staging evidence shows the save failing just after 300 s on several runs. It does not show which step was slow (upload, read-back or local capture), so the fix removes the fixed total for every step on that path. ## Risks - A save that progresses very slowly can now take longer than five minutes. Before, it failed. The settle step waits for it, up to the 30-minute outer bound. - A local step that hangs (for example a stalled disk during capture) is now cut off at 30 minutes instead of 5 minutes, with `native_harness_storage_persist_deadline_exceeded`. - For S3 file-source uploads, progress is measured per request, not per byte. A single request that takes more than five minutes counts as stalled. For a 16 MiB single PUT, that is a store slower than about 55 KB/s. Multipart parts are 8 MiB, eight in flight. - If a successor takes over during a long save, the existing fence checks before and after the upload reject it with `owner_superseded`, and nothing is published. This is unchanged behavior. ## Model Used - Provider: Anthropic. Model: Claude Opus 5.5 (`claude-opus-5-5`), with tool use (shell, file edits) in Claude Code. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c41145e72a |
fix: wait on pending questions and quiet provider holds (#22363)
## Thinking Path > - Paperclip manages agents and the tasks they work on. > - Recovery should continue unfinished work when it is eligible. > - An active unanswered question is a persisted reason to wait for a person. > - Treating a later Retry as an answer makes the recovery sweep repeatedly request continuations that admission refuses. > - Provider-limit holds also produce one cancellation toast per task, even though provider work never started. > - This PR aligns recovery with persisted interaction status and presents these waits accurately. ## Linked Issues or Issue Description Refs: #20466. This addresses the question blocker presentation and automatic recovery loop; it preserves the existing interaction-resolution policy. Related work: #19420 schedules provider quota retries, and #21570 handles notices and reply ownership in agent chats. This change concerns assigned-task reconciliation, task/inbox status, and per-run cancellation toasts. **What happened?** The assigned-work sweep ignored pending interactions whenever a newer run carried `explicitUserContinuation`. Continuation admission still refused the pending question, so repeated sweeps recorded unsuccessful continuation attempts. The task could meanwhile show an older provider error as its current blocker. Separately, each pre-dispatch provider-limit hold generated a cancellation toast, and the one-hour fallback was described as a known reset and promised start time. **Expected behavior** Wait quietly while the question remains active under the shared interaction eligibility rules, then react to the existing resolution notification. Dismissed or historical ordinary questions remain answerable without blocking work; governed requests keep their gates. Show the current question on task and inbox surfaces. Keep provider failure history, suppress cancellation toasts for expected provider holds, and describe scheduled availability checks without promising the provider will accept work. **Steps to reproduce** 1. Leave an `ask_user_questions` interaction pending with `supersedeOnUserComment: false`. 2. Create a later failed/interrupted explicit Retry and run assigned-work reconciliation repeatedly. 3. Observe that the question remains pending while the sweep attempts fresh continuations. 4. Separately, let an agent with recent provider rate-limit evidence receive automatic task wakes without a reported reset time. ## What Changed - Remove inferred question supersession from both assigned-work fact loading and candidate selection. Use the existing active-interaction predicate consistently in those reads, fresh-continuation admission, and the task projection. Cover dismissed/historical ordinary questions, retained governed gates, repeated checks, idle workers, and the existing resolution notification. - Add the `question` interruption action, load active pending question IDs alongside approvals in one company-scoped query, and show that blocker on tasks and inbox rows. Preserve a supported manual Retry after a failed attempt, suppress duplicate actions for saved input, and keep other current user gates authoritative. This preserves the existing issue-detail SQL statement budget. Historical run failures remain intact. Refresh the shared source SDK input pin. - Suppress cancellation toasts specifically for cancelled `provider_limit_wait` runs. Label provider retry deadlines as availability rechecks, retain relative-time formatting, and record successful scheduling as an informational lifecycle event. - Document the wait contract in the continuation architecture guide. ## Verification - Demonstrated failing regressions before the implementation: continuation loop, task projection, task notice, cancellation toast, provider deadline wording, and deadline formatting. - Initial focused Vitest qualification: 642 tests passed across 14 files, using: ```sh pnpm exec vitest run \ server/src/__tests__/{assigned-work-invariant,assigned-work-recheck-idle,heartbeat-provider-limit-wait,task-interruption-query}.test.ts \ server/src/services/{task-interruption-presentation,execution-projection,fresh-continuation-fallback,issue-thread-interactions}.test.ts \ server/src/services/recovery/assigned-work-invariant.test.ts \ ui/src/{components/ExecutionBlockerNotice.test.tsx,context/LiveUpdatesProvider.test.ts,context/LiveUpdatesProvider.hook.test.tsx,lib/provider-limit-message.test.ts,pages/Inbox.test.tsx} ``` - `pnpm --filter @paperclipai/shared typecheck` — passed. - Review follow-up: 157 tests passed in `assigned-work-invariant`, `task-interruption-query`, and `fresh-continuation-fallback`; 575 passed in `task-interruption-query`, `assigned-work-recheck-idle`, `task-interruption-presentation`, `issue-question-context`, `issue-thread-interactions`, and `explicit-native-continuation` (the query file overlaps). The strengthened final dismissed/historical/governed projection regression also passed separately. - Final query-consolidation verification: 157 tests passed across five files, including the unchanged 64-statement issue-detail census and mixed approval/question batches: ```sh pnpm exec vitest run \ server/src/__tests__/{issue-detail-statements,task-interruption-query,assigned-work-invariant,assigned-work-recheck-idle}.test.ts \ server/src/services/task-interruption-presentation.test.ts ``` - `pnpm --filter @paperclipai/server typecheck` — passed, including test layers. - Manual-recovery follow-up: 204 tests passed across seven projection/recovery/notice suites, and all 104 Inbox tests passed. The lost-runner integration still starts exactly one run from a manual Retry and leaves the question unanswered. The saved-decision census verifies one decision batch query for a 41-task list, with at most three statements referencing interactions; the overall 64-statement issue-detail limit remains unchanged. - `pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm --filter @paperclipai/ui build` — passed. - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` — passed. - `pnpm verify` — exit 2: broader CI is required for changed global inputs. Focused tests and package checks supply local evidence; broad CI remains required. - `git diff --check` and a local secret/instance-data scan — passed. - Final CI on `1c16fe7c0d8`: [trusted CI workflow](https://github.com/paperclipai/paperclip/actions/runs/44650155842) passed, including all server shards, native-server verification, build, canary, e2e, release registry, and serialized suites. All PR checks are complete, with no failures; the branch is conflict-free. - Greptile reviewed the latest revision, `1c16fe7c0d8`, at 5/5 with no actionable findings or unresolved review threads. The focused tests cover genuine provider failures, live work and terminal tasks, unchanged task locks/retry delivery, preservation of historical failures, and question resolution waking the affected task while other active pending questions remain quiet. Review regressions also cover dismissed/historical ordinary questions retaining Retry and governed requests retaining their gates. No live task was retried or answered for validation. ## Risks - An active pending question now consistently blocks automatic assigned-work recovery. Shared interaction eligibility determines when ordinary conversation input becomes deferred or historical; governed requests retain their authority. Automatic recovery no longer infers that a newer Retry resolved an active question. - Manual Retry keeps its existing admission policy and recovery checks. The question notice preserves that supported action after a failed attempt without changing approval or credential authority; pending saved input prevents duplicate actions. - The shared interruption action gains `question`; the task and inbox consumers are updated together. The pending-question query returns only task IDs and uses the existing company/task/status index. - Provider cooldown policy, quotas, credentials, routing, cancellation history, and durable retry timing are unchanged. The actual provider can still return a rate limit at the recheck. - No migration is required. Existing large owner modules receive small localized changes; no code file crosses 1,000 lines. ## Model Used OpenAI `gpt-6.1-sol` through the Codex harness in T3 Code, xhigh reasoning effort, with code execution and tool use. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either linked existing issues or described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal 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> |
||
|
|
25b5cad7f9 |
fix(native-runtime): start first OpenCode turns from any saved launch-file copy instead of waiting on a stalled one (#22367)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - OpenCode agents in remote sandboxes must have a saved, verified copy of their launch files before their first turn (#19622, #21287) > - The first runs of a company share one copy of these files per server. Other runs wait for it > - In a restart chaos wave, the shared copy out of one sandbox stalled for 330 s. Seven other runs waited silently for it. Two runs then failed before their first turn with the cause `unknown` > - The copy speed out of a sandbox differs from one sandbox to the next. When the first copy failed, the other sandboxes copied the same 314 MB in 15 to 24 s > - This pull request lets every waiting run use the first copy that any run saves, starts a second copy when the first one is slow, and names the cause of a stalled copy > - The benefit is a shorter cold start for the first runs of a company, no failed run when another run already saved the files, and a named cause instead of `unknown` ## Linked Issues or Issue Description Refs #19622 Refs #21287 **What happened?** A restart chaos wave started 15 OpenCode runs on new Daytona sandboxes (1 vCPU) in a new company. The first run (A) started the shared copy of the 314 MB launch files out of its sandbox. The copy did not finish. The plugin call timed out after 330 s, and run A failed before its first turn. The other runs waited for that copy without any run event, so the task looked dead for 284 to 343 s. When run A failed, every waiting run started its own copy at the same time. Five copies finished in 15 to 24 s. One copy (run B) stalled again and failed after 330 s, although a saved copy existed after 15 s. One copy (run C) took 5 min and started its turn 10 min after the run started, although it could have used the saved copy 5 min earlier. Both failures had the technical cause `unknown`. Each failure also logged "native result could not be marked workspace_failed; the reconciliation loop will retry persisted results", but the run had no result, so there was nothing to retry. **Expected behavior** A run uses the first saved copy as soon as one exists. A slow copy does not hold all first runs. A stalled copy out of the sandbox has a named cause. A run with no result does not log a result-finalization failure. **Steps to reproduce** 1. Use a company with remote OpenCode agents on Daytona sandboxes with durable storage and no saved launch-file copy. 2. Start 8 or more runs together on new sandboxes. 3. Make the copy out of the first sandbox stall (for example, a slow sandbox link). 4. See that all other runs wait for the full plugin timeout, and see the failures with the cause `unknown`. **Agent adapter(s) involved** OpenCode (native runtime, remote sandbox). ## What Changed - `shareNativeProviderArtifactCapture` (`native-provider-artifact-capture.ts`): - The first capture that saves a ready copy ends the wait for every run. A run whose own capture is still copying uses the saved copy and aborts its own copy. - A run whose own capture fails uses a saved copy when one exists, and fails only when none exists. - When the running capture is slower than 90 s, one waiting run starts one more capture from its own sandbox. At most two captures run at once. A capture keeps its slot until its copy out of the sandbox ends. - The start decision is owned by one `SharedArtifactCapture` coordinator (`tryStart()` returns a release lease). - When the shared capture fails, one waiting run starts the next capture. The other runs keep waiting for it. Before, every waiting run started its own copy at the same time. - The capture callback now gets its own abort signal, so a superseded copy stops before upload. - A failed copy out of the sandbox is now `NativeProviderArtifactExportError` with the code `native_provider_artifacts_export_timeout` (plugin call timed out) or `native_provider_artifacts_export_failed`. The run's technical cause shows this code instead of `unknown`. A timeout shows "Setting up the computer took too long ...". - `runtime-execution.ts`: do not try to mark the workspace as failed on a native result when the run has no result. Before, this always threw `native_finalization_missing` and logged a false "will retry" warning. - `doc/opencode-cold-recovery.md`: describe the new sharing, the second capture and the new cause codes. ## Verification - Red/green: with the old `native-provider-artifact-capture.ts`, these 5 new tests fail. With this change, they pass: - `native-provider-artifact-gate.test.ts`: "starts a run's turn from another run's saved artifact while its own capture is still copying", "uses a saved artifact when the run's own capture fails after another run saved one", "starts one more capture when the shared capture runs past the hedge delay, not one per waiting run", "does not start a capture per waiting run when the shared capture fails", "names a stalled copy out of the sandbox instead of an unknown cause". - Red/green: `heartbeat-native-predispatch-retry.test.ts` "continues on a fresh ... sandbox when the provider artifacts fail to save before any turn" now also asserts that no "could not be marked workspace_failed" warning is logged. It fails before the `runtime-execution.ts` change and passes after it. - `cd server && npx vitest run src/services/native-runtime/native-provider-artifact-gate.test.ts src/services/native-runtime/native-provider-artifact-capture-confinement.test.ts src/services/native-runtime/native-session-executor.test.ts src/services/native-runtime/native-harness-backup-storage.integration.test.ts src/services/native-runtime/native-provider-artifact-capture.test.ts src/services/heartbeat/runtime-execution.test.ts src/services/task-interruption-presentation.test.ts src/__tests__/heartbeat-native-predispatch-retry.test.ts`: all pass. - `npx tsc --noEmit -p server`: pass. ## Risks - A slow first capture can now cause one more 314 MB copy after 90 s. At most two copies run at once for one company and manifest. A run whose saved copy cannot be reused (for example, an ownership fence mismatch) starts its own copy at once. Before, a failed burst started one copy per waiting run at once, which was more. - A superseded copy never uploads, but the provider call that copies files out of the sandbox continues until it ends or times out. Its local temporary directory is removed when it ends. - Sharing is still per server. Two servers can still copy the same files. - No change to the rule from #19622: a verified saved copy still exists before the first turn. - No runner or image change. No 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 - Claude (Anthropic), model ID `claude-opus-5-5`, used through Claude Code with tool use (shell, file edit, test runs). Default context window; extended reasoning on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
19a7381398 |
feat: restore personal archiving in task views (#22358)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People use Tasks to see shared work and manage the work that needs their attention. > - The old inbox already let each person archive a task and undo that action. > - The combined Tasks surface needs the same controls in Unread and in task table rows. > - The existing inbox archive rules determine when new activity brings a task back. > - This pull request adds an Archived view so people can find and restore their archived tasks. ## Linked Issues or Issue Description **What existing behavior does this improve?** Personal task archiving in Tasks. Related work includes the combined Inbox and Tasks surface (#15100), the Coordinator workspace (#17983), moving Mine into Tasks (#19363), and the existing inbox archive rules (#9931). **Subsystem affected** Cross-cutting. The UI and task list API reuse the existing inbox archive state. **Current behavior** Mine has an archive action. Unread and the task table have no equivalent action. The Tasks menu has no dedicated view for restoring archived tasks. **Proposed behavior** Add Archive and Undo to the task views. Let people restore tasks from Archived. Keep archived tasks available in All tasks. **Reason and benefit** People can clear their personal lists and still find the original task. **Breaking changes** The task list API adds an optional archive filter and viewer archive field. Existing callers use the same response and filters unless they opt in. ## What Changed - Reuse the current inbox archive and restore actions, activity rules, and authorization. - Add Archive and Restore to task table rows, Archive and Undo to Unread, and a personal Archived view. - Give each archived task its own Undo control, including when people archive tasks quickly. - Add tests for the archive list, account isolation, new activity, row actions, and Undo. - Document the archive flow and API filter. Refresh the generated SDK source input registry. ## Verification - Passed 287 focused tests in 12 Vitest files. These cover the task views, row actions, archive cache, and PostgreSQL routes. - Passed local server and UI typechecks. The source input registry check also passed. - Reproduced a missing Undo action when archiving two tasks in a row. After the fix, the 158 task and inbox tests and the 2 toast tests passed. - On macOS with Chrome, archived a task from Mine and restored it using Undo. Archived another task from All tasks, reloaded Archived, restored it, and verified its Todo status and return to Mine. - A human tester also verified Archive, Undo, and Restore in the local browser. - On commit `c5526fd9b1`, GitHub's [verification](https://github.com/paperclipai/paperclip/actions/runs/44630156078/job/135950130662) and [browser tests](https://github.com/paperclipai/paperclip/actions/runs/44630156078/job/135946228919) passed. A targeted retry passed after the first attempt hit a watchdog self-test failure and two cancelled jobs. - [Greptile scored 5/5](https://github.com/paperclipai/paperclip/pull/22358#issuecomment-7024083610) on the same commit. Both review threads are resolved. ## Risks - An incorrect visibility rule could hide a task from a personal list. The archived filter uses the same activity predicate as Mine. The PostgreSQL test covers isolation between people and resurfacing after a reply. - The archive state is already stored per person and company. No database migration is required. ## Model Used - OpenAI Codex, GPT-6, with shell, code editing, and browser verification tools. The serving model ID and context size were unavailable in this session. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <1504818+scotttong@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
24132dac16 |
fix(tasks): verify PR merges with the managed run identity (#22357)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native task completion independently verifies that declared PR deliverables are merged. > - Runs can already use an authorized managed GitHub connection to merge private PRs. > - Completion used the background credential resolver, which cannot select that run's managed identity. > - This pull request reuses operation-time identity and grant checks for completion verification. > - Agents can finish delivered work while unavailable grants and unverified merges remain blocked. ## Linked Issues or Issue Description Related: #22244 introduced the native PR merge gate. No duplicate fix was found in the open PR search. The roadmap's personal GitHub identity capability already covers the intended identity model. **What happened?** A native agent with a managed GitHub connection merges a private PR, then completion rejects it as not verified merged. The independent server-side check only tries legacy company token names or an instance token; it does not use the agent run's managed connection. **Expected behavior** Verify the merge with the run's current accepted GitHub identity, retaining current grant, membership, trust and company boundaries. GitHub must confirm the merge regardless of saved work-product metadata. **Steps to reproduce** 1. Configure a managed GitHub identity with access to a private repository and no legacy company GitHub token. 2. Use a native task run to merge and register a PR deliverable. 3. Finish the task. Before this change, the merge verifier cannot authenticate with the managed identity and rejects completion. ## What Changed - Bind completion credential lookup to the persisted company, native task and run. - Add a server-side completion credential path that shares managed grant, membership and trust checks with command credentials. Both active and succeeded runs capture identity under the existing task/run locks and reconcile pending steering acknowledgements before credential lookup. The command credential API still requires a running run. - Resolve credentials once for all PRs in a verification attempt; do no credential work for tasks without PR deliverables. - Preserve legacy fallback only for runs without a managed identity, and preserve the public-only restriction on server-environment credentials. - Add 23 PostgreSQL-backed authorization regression cases and document completion's identity behavior. ## Verification - Local checks cover revision `da2a3608b0375ead646bbbad35af853191488f07`. [Greptile review](https://github.com/paperclipai/paperclip/pull/22357#issuecomment-7023243798) is 5/5 on that revision with both prior threads resolved. [Required CI](https://github.com/paperclipai/paperclip/actions/runs/44625662403) passed on attempt 2 for the same revision, including typecheck, build, canary, server/runner suites and all eight e2e shards. - Red/green: the private-PR and identity-selection cases failed before the initial fix. Review exposed a succeeded-run reassessment failure and then an unsettled-steering gap in that path; each has a regression that failed on the reviewed commit and passes after its correction. Unresolved steering performs no token lookup, and durable acknowledgement selects the new person. The full worker test completes the task after automatic-review withdrawal while command credentials remain unavailable to the finished run. - `pnpm exec vitest run server/src/services/native-runtime/native-pull-request-completion.test.ts server/src/services/native-runtime/native-completion-feedback.test.ts server/src/__tests__/github-operation-credentials.test.ts server/src/__tests__/native-status-reassessment-work.test.ts server/src/__tests__/run-identity.test.ts server/src/__tests__/run-identity-projections.test.ts` — 222 tests pass across six files, on macOS arm64 with Node 25.6.1 and embedded PostgreSQL. - `pnpm --filter @paperclipai/server typecheck` — passes. - `pnpm verify --explain` — exits 2 because the subsystem documentation selects broad CI coverage. Required CI supplies the broader test/build coverage; this exit is not a full-suite pass. - The credential selection, steering, grant and company checks use real PostgreSQL state. Only the secret vault and GitHub HTTP transport are mocked; test requests never reach GitHub. - `git diff --check` and the staged secret/PII scan pass. No runtime artifacts are committed. - Earlier CI revision `4e42f64`: the [Build job](https://github.com/paperclipai/paperclip/actions/runs/44624163145/job/135914203042) ended after the runner received a shutdown signal and the workflow was cancelled. Its log does not show a compiler error before interruption; this interrupted attempt is not build verification. The current revision subsequently passed its own CI build on attempt 2. - Current revision canary: the [Canary Dry Run job](https://github.com/paperclipai/paperclip/actions/runs/44625662403/job/135919504493) was interrupted by runner shutdown before completion. The repository runner-loss classifier returns `lost: true` for its actual annotation and log. A targeted retry was refused while the workflow remained active. The same revision subsequently passed Canary Dry Run and the full workflow on attempt 2; the earlier interrupted attempt remains recorded here separately. - Live acceptance remains pending deployment; the change has not been deployed. ## Risks Completion now reads managed credentials through a server-side path shared with the existing authorization checks. Successful finished runs can be reassessed without granting them command execution credentials. Denied or unavailable identities must remain blocked without falling through to a different identity; regression tests cover revocation and company/task isolation. Credential lookup is shared within one bounded PR verification attempt, not cached across attempts. The existing HTTP deadline and merge proof requirements remain in place. No migrations or API contract changes. ## Model Used OpenAI Codex, `gpt-6.1-sol`, xhigh reasoning, with repository inspection, code editing and test execution. Context-window size is not exposed by the harness. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [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> |
||
|
|
3c32b8d4dc |
fix(ci): waive lockfile bake time for pinned harnesses (#22349)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Runner ships pinned harnesses that run those agents. > - Some new models require a new harness release before they can run. > - The lockfile bot waits three days before it can merge new dependency versions automatically. > - That wait held the Claude and Codex refresh in #22231. > - This PR waives the wait for a fixed set of harness packages so model updates can ship as soon as npm confirms the releases. ## Linked Issues or Issue Description Refs #22231, #22278, #14942, #15572, and #18238. **What happened?** The refresh in #22231 held 16 new Claude Agent SDK and Codex versions even though the new model support needed those harness updates. **Expected behavior** Verified npm releases of named harness packages can pass the gate immediately. The gate applies the normal minimum age to other packages. **Steps to reproduce** Compare the parent and head of #22231 across the three lockfiles managed by the bot. Run the gate with the publish times in its hold comment and a clock within three days of the releases. ## What Changed - Exempt 28 exact package names from the minimum age. These cover the Claude Agent SDK, Codex CLI, their provider-specific ACP bridges, OpenCode, and the Copilot binaries pinned by Runner. - Take package identities from the Runner manifest and active provider profiles, then check the managed lockfiles for platform binaries. Codex platform aliases use the same registry name with a platform suffix on each version. Pi and Kimi use separate npm locks. Gemini, Grok, the local Cursor CLI, and Antigravity use separate install paths. The Cursor Cloud SDK gets model availability from the service. - Keep the npm publish-time and resolution checks for every entry. Update the bot report and setup documentation. ## Verification - Replayed the exact #22231 lockfile diff using the bot's recorded publish times and a fixed clock. The previous gate held all 16 versions. The new gate verified all 16 and held zero. - Ran the workflow CLI against the same three lockfile pairs and the live npm registry. It wrote `eligible=true` and reported 16 passing versions. - Reconciled the 28 exact names with the Runner manifest, provider profiles, all three bot-managed pnpm lockfiles, and the npm manifests for Claude Agent SDK 0.3.328, Codex 0.170.0, and OpenCode 1.18.34. - Ran `node --test '.github/scripts/tests/*.test.mjs'` locally. All 810 tests passed. The new cases cover mixed refreshes, similar names, registry errors, missing publish times, and non-registry resolutions. - Ran `git diff --check`. - GitHub Actions passed the required typecheck, build, test, and e2e checks on `9c8bccac51`. The Canary runner shut down on the first attempt, and browser shard 7 had a test-company cleanup error. Both passed on the failed-jobs retry. [CI attempt 2](https://github.com/paperclipai/paperclip/actions/runs/44610325309/attempts/2) - Standard Greptile scored the same revision 5/5. [Review](https://github.com/paperclipai/paperclip/pull/22349#issuecomment-7021573041) ## Risks An npm release of an allowlisted harness can reach master during its first three days through the existing automatic merge path. A compromised release can use that same path. Every added version still needs an npm publish time and a registry resolution. Review new platform package names before adding them to the allowlist. Superagent requests security review for this policy change. [Scanner finding](https://github.com/paperclipai/paperclip/pull/22349#discussion_r4634801827) ## Model Used OpenAI GPT-6 in Codex, with shell and code execution. The exact model snapshot and context window were not reported. ## 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> |
||
|
|
28043f8b93 |
Measure database and projection costs in runtime tool discovery (#22347)
## Thinking Path > - Paperclip starts agent turns with instructions for the connections the agent can use. > - The gateway reads the connected-tool catalog during prompt preparation. > - A single discovery span currently covers both database waits and descriptor construction. > - Maintainers need to distinguish these costs before changing catalog reads. > - This change records the transaction, both queries, availability checks, and descriptor construction. ## Linked Issues or Issue Description **Subsystem affected** — Runtime tool discovery and run preparation. **Problem or motivation** — The existing catalog span cannot explain time spent before a remote turn starts. **Proposed solution** — Measure the existing read in place. Record the number of entries and connections returned. **Alternatives considered** — A local microbenchmark cannot reproduce a hosted database or a deployed catalog's sizes. A change to the query would confound the measurement. **Roadmap alignment** — This adds diagnostic detail to an existing operation. Related work includes #14864, which bounded catalog memory use. **Additional context** — The PostgreSQL reads share one read-only snapshot. ## What Changed - Add a transaction span with children for the entry read and the matched-connection read. - Attach the two returned row counts to that transaction. - Time availability checks and descriptor construction under the existing catalog discovery span. - Document which preparation timings can also reach the native run event table. ## Verification - Ran the gateway listing-memory, discovery HTTP, and execution timing context suites with local PostgreSQL. All 30 tests passed. - Checked the parentage and row counts with a real OpenTelemetry exporter in memory. - Ran the standing-instruction integration suite and measured the catalog from two staging application containers with read-only database sessions. ## Risks Each recorded catalog operation adds up to five spans. The existing per-phase bound applies. Only the OTel transaction span includes the aggregate row counts. With or without OTel, the existing native preparation timing path can also persist a run event for each new phase that takes at least 50 ms, subject to its normal caps. The executor defers those writes. The database query, tool eligibility, and authorization contracts stay the same. ## Model Used OpenAI Codex directed and qualified the work. GPT-6.2 Sol implemented the instrumentation and regression test. ## 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 |
||
|
|
806440d12c |
feat(runner): relaunch a released task as the next run after a restart (#22343)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - An environment plugin can keep a warm task for an agent session. After each turn, Core releases the task's Runner, and the next run of the session resumes it > - #22288 added `resumeIdentityVersion: 1`: for a provider that stops a released Runner, Core rotates the session to the next run and the provider starts the Runner again directly as that run > - Core takes that path only while it still holds the released session in memory. After a Core restart, it recovers the released task through the older hand-off: it resumes the task as the previous run, then switches the Runner's authority to the new run > - So a provider that advertises the capability still has to keep the hand-off for every follow-up after a Core restart, and cannot drop it > - This pull request makes restart recovery take the same path when the provider advertises the capability > - The benefit is that a provider with the capability gets one start shape for a released task, before and after a Core restart, and can retire the hand-off ## Linked Issues or Issue Description Follows #22288. **What existing behavior does this improve?** The first run of a warm plugin session after a Core restart, when its task was released and its provider advertises `resumeIdentityVersion: 1`. **Subsystem affected** The native session executor and the plugin Runner task owner. **Current behavior** After a restart, Core finds the released source on disk (`inspectRemoteWarmSessionRecovery`), creates a backend that adopts the task, and calls `recoverSession`. The task owner calls `resume` without `runner`, the provider starts the Runner as the previous run, and Core hands it to the new run. **Proposed behavior** When the provider advertises the capability, Core recorded the build the task was released on, the process configuration is unchanged, and the session is not moving to another task, Core treats the recovery like a cached released session. It revalidates the recovery, loads the warm checkpoint, and opens a new backend on the same task with `relaunchReleased`. A new task owner takes over the submitted task without adopting a Runner process, prepares the claimant run with the released source as `priorIdentity`, and calls `resume` with `runner`. Every other recovery keeps the hand-off. **Reason and benefit** A provider that advertises the capability no longer needs the hand-off for its own tasks, after a restart or not. ## What Changed - Executor: a remote warm recovery with a released source, a recorded build, a reusable process configuration and no session move, on a provider that advertises the capability, revalidates the recovery and becomes a relaunch: `relaunchReleased` with the released source and build, the warm checkpoint, and no `remoteWarmRecovery` for the backend. The startup context ends as for a cached relaunch. - Executor: the relaunch's task owner can now come from the new backend (`onPluginTaskOwner`), so the unavailable-reuse fallback and the rotation revert work without a retained owner. Without an owner, no relaunch can have started, so the revert applies. - Backend: a relaunch neither stops a resumed task that has no durable binding nor resolves a `resumeFrom` task. - Task owner: an owner created with `relaunch` and the capability takes over an already submitted task, as an adopting owner does, but adopts no process: its prepare sends the released source as `priorIdentity`, and its launcher calls `resume` with `runner`. - `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md`: Core prepares the claimant run before the resume, also after a restart, and a provider must accept that prepare without state kept in memory. ## Verification - `server`: `npx vitest run src/services/native-runtime/plugin-runner-release-resume.integration.test.ts`: new `adopted restart relaunch` cases for Codex and Claude, with real runnerd processes. Core restarts while the task is released; the next run relaunches the task as itself, with no claim, one inspection and no second submit. The existing `adopted relaunch` case now relaunches both follow-ups, since the idle close also recovers through this path. - `server`: `plugin-runner-task.test.ts`: a new owner relaunches without submitting or adopting, and prepares with the released source; without the capability it prepares a new task. - `server`: `plugin-runner-release-resume.integration.test.ts` and `plugin-runner-eviction.integration.test.ts`: 61 passed. `native-session-executor.test.ts`: 1535 passed, 7 skipped. `plugin-runner-task.test.ts`: 118 passed. - Typecheck: `server` passes. - Red-green: with the executor lane turned off, both `adopted restart relaunch` cases fail. Without the task owner change, the new-owner relaunch test fails. ## Risks - Only providers that advertise `resumeIdentityVersion: 1` see a change. Recovery without a recorded build, with a changed process configuration, or for a session moving to another task keeps the hand-off. - The provider sees a `prepare` for the claimant run on a released task right after a Core restart. A provider that tracked unclaimed released tasks only in memory must handle that prepare (the doc now says so). - A Core restart in the middle of this path is still not qualified, as for the cached relaunch. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (code search, editing, local test runs). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
46dde54f52 |
fix(cloud): migrate run evidence during online preparation (#22337)
Drive bounded run-log and provider trace migration pages during online durable-data preparation. Share the page owner and settled-native archive rules with background migration, preserve active-source and storage-integrity guards, and report fresh page results. Keep canceled transfers owned and tracked until the underlying operation settles. Retain page cursors across the preparation budget. Verified 52 focused tests, including embedded PostgreSQL and object storage, server typechecking, and all 58 successful PR checks. Greptile 5/5 with no unresolved review comments. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
87ef7097b6 |
refactor(wake-queue): own blocked admission deferral (#22332)
## Thinking Path > - Paperclip runs agents in response to work on a task. > - A person can leave a comment while execution recovery holds that task. > - Wake-queue checks the recovery gate under the task lock. Heartbeat used to choose how to save the blocked input. > - The deferred-work worker later retries the saved receipt by ID. > - This change gives wake-queue responsibility for saving the input before it confirms deferral. ## Linked Issues or Issue Description **Current behavior** The gate and the write that makes a blocked wake recoverable have different owners. Heartbeat also reports an admitted deferral when an update to an existing receipt matches no row. **Proposed behavior** Let the recovery admission operation save the first receipt or update the existing one in the same transaction. Confirm admission only when the write succeeds. Keep replaceable automatic signals on their existing diagnostic path. **Reason and benefit** Changes to recovery admission can now be checked against one rule. A blocked comment must have a durable receipt and remain recoverable across delivery attempts. Related changes include [#22292](https://github.com/paperclipai/paperclip/pull/22292) and [#22290](https://github.com/paperclipai/paperclip/pull/22290). ## What Changed - Added a transaction-bound deferral operation to wake-queue recovery. It handles existing receipts, saved input, and replaceable system signals. - Scoped retry updates to the company, issue, agent, deferred status, and receipt ID. A stale receipt cannot confirm admission or cause a new receipt to be inserted. - Kept case refusals and issue state callbacks in heartbeat. A saved comment uses the existing delivery worker and post-commit effects. ## Verification - Retried a saved comment by receipt ID through the real heartbeat and run-control entry points. While the hold remained, no run started. After the hold cleared, repeated retry delivered the comment to exactly one run. - Forced a rollback after the wake-queue Postgres adapter saved a receipt. The test observed the receipt within the transaction and confirmed its absence after rollback. Tested missing receipts and receipts for another issue or agent. The admission application test covers error propagation and post-commit effects when the transaction fails. - The test-only revision `9f443f9e6b` passed 9 focused PostgreSQL and recovery checks and all 15 issue-wake admission application tests. - The preceding production revision `eb37328472` passed the server TypeScript check, the module boundary check, and 498 tests across five queue and recovery suites. Twelve pairs of ordinary comments issued the same SQL before and after that production change (42 statements for a fresh wake and 35 for a join). - Both updated test files passed in full (249 tests). [CI attempt 3](https://github.com/paperclipai/paperclip/actions/runs/44572369812/attempts/3) passed on `9f443f9e6b` after retrying interrupted jobs. [Standard Greptile review](https://github.com/paperclipai/paperclip/pull/22332#issuecomment-7014835241) scored the same commit 5/5 with no open findings. ## Risks The affected path handles blocked admissions that may race a retry or a reassignment. Existing recovery gates, saved comment IDs, receipt identity, and notifications must survive that race. This change has no migration or new worker. The healthy admission path is expected to issue the same SQL. ## Model Used OpenAI Codex with GPT-6.2 Sol for implementation and verification. Codex directed and reviewed the change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [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> |
||
|
|
417802ca87 |
fix(plugins): refresh unchanged-version bundle descriptions (#22295)
Refresh known display descriptions in same-version bundled plugin registrations only when every behavioral field matches. Compare manifests in their persisted JSON form and await bundle reconciliation before final volume-free package qualification. Verified 77 focused tests, server typechecking, and all 59 successful PR checks. Greptile 5/5 with no unresolved review comments. Co-Authored-By: Paperclip <noreply@paperclip.ing> |
||
|
|
deacaf727c |
feat(connections): guided AWS role setup with a per-connection CloudFormation template (#22233)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The AWS connector (#22195) lets agents use AWS with credentials minted per connection. Its role method stores no AWS keys > - That method needs the customer to create an IAM role that trusts exactly one Paperclip connection, but setup only offered the generic form and a doc > - The connect API also refused the draft step this method needs, so the role method could not be set up through the UI at all > - This pull request adds a guided setup screen. Paperclip saves a draft, hands the user a prompt for their own agent that creates the role, takes back the role ARN the agent reports, and tests the same draft. CloudFormation and IAM steps are there under "Or do it by hand" > - The benefit is that a person can connect AWS without stored keys and without typing account details, using a template AWS has validated ## Linked Issues or Issue Description Refs #22195. **Subsystem affected** Connections (AWS connector setup), UI, tool-access API. **Problem or motivation** The AWS role method must save a connection before AWS can trust it. The API rejected `saveDraft` for every method except custom MCP servers, so the UI could not complete this flow. There was also no screen that showed the issuer, the subject, the trust policy or a template. **Proposed solution** - The connect API accepts `saveDraft` for methods that declare `credentialMinter`. - `GET /tool-connections/:id/aws-setup` returns the setup values and a CloudFormation template generated for that connection. - A new `AwsRoleSetup` step runs between saving the draft and testing it. The role is named after the connection and CloudFormation fills in the account, so the first form no longer asks for a role ARN; the user pastes it back once the role exists. **Alternatives considered** - A one-click CloudFormation quick-create link. Rejected: AWS accepts quick-create templates only from Amazon S3, so Paperclip would need to host a public template bucket. The screen offers a download and a console link instead. - Instructions in a doc only. Rejected: too many hand-copied values. - Asking for the role ARN up front. Rejected: the role does not exist yet, so users had to invent an ARN and then match it exactly. - Letting the user's agent report the role ARN to Paperclip itself, through a short-lived link. Not done here: it needs a new unauthenticated endpoint (and a Paperclip Cloud front-door change). The user pastes the ARN instead. ## What Changed - `packages/shared`: - The `saveDraft` validation allows methods with minted credentials. - New `AwsConnectionSetup` type. - `server/src/services/connectors/aws/setup.ts` builds the setup values: - The issuer, audience and connection subject. - The provider host and the trust policy. - A CloudFormation template with an optional identity provider (`CreateIdentityProvider`), a role named `paperclip-<connection id>`, `AccessPolicyArn` (`ReadOnlyAccess` by default for read-only connections) and `AWSMCPSignInOAuthAccessPolicy`. The account comes from CloudFormation, so the template needs no edits. - The service method `getAwsSetup` and the route `GET /api/tool-connections/{connectionId}/aws-setup`: - The route requires `connections:configure`. - It returns 422 for a connection that is not an AWS role connection. - It reports whether the issuer key is published and any role ARN already saved. - It returns `available: false` (`address_changed`) when the instance address changed after the draft was saved, since a role set up for the old address could never pass the test. - It is registered in OpenAPI. - UI: - The AWS form no longer shows a Role ARN field (it is hidden with an empty default). - `AwsRoleSetup.tsx` shows, by default, only "Set it up with your agent" (a copyable prompt that checks the AWS account, deploys the template with `aws cloudformation deploy`, and reports the role ARN) and a field to paste that ARN. "Or do it by hand" reveals the CloudFormation steps (download, console link, parameter notes, IAM acknowledgement) and the IAM console / AWS CLI steps with copyable values; the CLI commands read the account ID themselves. - It shows an access-key message when AWS cannot reach the instance, and asks the user to save again when the instance address changed. - Failed tests appear in place. AWS error codes show the server's own plain message, because the shared error copy replaces every 502 with "temporarily unavailable". - `useAwsRoleSetupStep` owns the AWS sequence; `ConnectionSetupFlow` only asks it for request options, hands back results and renders its step: - The first Connect for `aws-role` saves a draft and opens the AWS step. - "Test connection" resumes the same draft with the pasted role ARN. - Back keeps the draft, so a later Connect updates it and does not create a second one. Returning to an unfinished draft reopens the step. - Docs: the `doc/connections/AWS.md` setup section and the plan's phase table. The SDK public input pins are refreshed. ## Verification - `server/src/__tests__/aws-mcp-connector.test.ts` covers a new API-level case through the real route validation: - Saving an `aws-role` draft over HTTP works without a role ARN, and stores the keys the screen uses to reopen it. - `aws-setup` returns the issuer, subject and the connection's role name. - The template's trust condition keys equal `<issuer host>:aud` and `<issuer host>:sub`. - The template provider URL equals the issuer. - After an address change it returns `address_changed`, and saving the draft again records the new address. - An access-key connection returns 422. - No response field looks like a secret. - `ui/src/features/connections/AwsRoleSetup.test.tsx` covers: - Only the agent setup shows by default; Test connection stays off until a valid role ARN is pasted, then sends it. - A saved role ARN is filled in. - The by-hand steps and CLI commands; the agent prompt for read-only and full access. - The template download (filename and object URL cleanup). - The unreachable-instance message. - The in-place error and the address-changed message. - The AWS message mapping. - `ui/src/pages/apps/AppsConnect.test.tsx` covers the full two-step flow: the form has no Role ARN field, the first Connect sends `saveDraft: true` with no role ARN and does not finish, the AWS step loads the setup, and "Test connection" resumes `aws-draft` with the pasted role ARN and finishes. A second test reopens the step for a returning draft. - Red/green: - Removing the API change fails the API test. - Removing the draft-first wiring fails the flow test. - Totals: server AWS, OpenAPI and connector tests (75), shared `app-definitions` (42), UI connections and apps pages (1108). Typecheck is clean for shared, server, UI (except Storybook's generated catalog, which this worktree has not built) and all four server test-tree layers. - Browser, on a real dev server with an HTTPS public address: - AWS appears in Connectors with its logo. - The form has only region and access level. Connect saves the draft (reusing an earlier one) and shows only the agent prompt and the role ARN field; "Or do it by hand" reveals the CloudFormation and IAM steps. - The copied prompt names the connection's role and stack, and the template. - Test connection with a pasted role ARN showed AWS's refusal in place (no such role, placeholder issuer), as expected. An earlier run found the generic 502 copy problem, which is fixed and re-checked. - AWS CloudFormation `validate-template` (dev account, read-only) accepts the current generated template (role named after the connection) and reports `CAPABILITY_NAMED_IAM`. The screen tells the user to acknowledge it. - Not run: an agent actually running the prompt and creating a stack in AWS, and Paperclip Cloud staging. ## Risks - The feature is still behind `enableAwsConnector` (off by default). No migration. - The template creates IAM resources in the customer's account, and the customer must acknowledge that. The role trusts only this connection's subject. - If the customer already has an identity provider for the issuer and leaves `CreateIdentityProvider` at true, AWS fails the stack with a clear error. The screen explains the parameter. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, the in-app browser against a local dev server, AWS CLI `validate-template` in the dev account, an exploration subagent). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
7ffc58a612 |
refactor(wake-queue): enforce recovery before task admission (#22292)
## Thinking Path > - Paperclip admits assignments and task comments while it holds the task lock. > - A task can have a recovery hold. An explicit continuation can authorize additional work. > - A wake can join an active execution after a provisional check. A fresh run must settle the continuation in the transaction that creates the run. > - Heartbeat previously received both admission functions before either check ran. > - Make the wake-queue module release each function after the corresponding recovery check passes. ## Linked Issues or Issue Description **What existing behavior does this improve?** Enforce recovery eligibility at the entry points that attach a wake to an issue execution or create a fresh run. **Subsystem affected** Wake-queue and heartbeat issue admission. **Current behavior** Heartbeat selects when to read the blocker and apply the explicit continuation before invoking the admission writers. **Proposed behavior** Wake-queue controls access to its two admission writers after the task is locked. The same recovery and continuation services decide which work may proceed. **Additional context** Depends on #22289. #22290 changes the storage cost of the blocker check in a separate layer. ## What Changed - Bind the recovery read to the issue and transaction selected by wake-queue. Read the current issue lock again after durable chat authorization when required. - Expose the busy writer after the preliminary continuation check passes. Expose the fresh writer after the transaction applies any required continuation. - Preserve heartbeat’s existing ordering for system fallback, budget and daily limits, task retry, and durable receipts. ## Verification On |
||
|
|
503268b806 |
perf(wake-queue): preflight task admission without loading execution context (#22289)
## Thinking Path > - Paperclip uses task admission to turn assignments and comments into queued work. > - Wake-queue owns the issue-admission transaction. Heartbeat previously loaded full execution context to decide whether a conversation wake could proceed. > - After the conversation preflight, task state can change before admission obtains its lock. > - Wake-queue now exposes the preflight decision and obtains only the fields it needs. It provides current task attribution from the locked row. > - Heartbeat uses the existing responsible-user and routine rules when it creates a run. ## Linked Issues or Issue Description **What existing behavior does this improve?** Admitting board assignments and saved task comments. **Subsystem affected** Server task admission. **Current behavior** Conversation preflight and fresh-run attribution load full task execution context from heartbeat, including chat joins. **Proposed behavior** Give wake-queue ownership of conversation preflight and its PostgreSQL read. Use the issue row already locked by wake-queue for fresh-run attribution. **Additional context** Builds on #22280 and #22282. #17396 covers a separate workspace inspection on task context reads. ## What Changed - Give heartbeat a preflight decision. Keep storage and the five-field query inside wake-queue. - Reuse the conversation and retry predicates for all callers. Keep the locked recheck after preflight, including durable chat authorization. - Supply the task's responsible user, parent and routine origin from the current locked row. A company-only admission supplies no issue. ## Verification On `b89bed954a`, all 307 tests passed across the wake-queue preflight and release application suites, heartbeat queue and run-preparation suites, and Slack conversation lifecycle suite. The integration suites used embedded PostgreSQL. Coverage includes the owner 403, a conversation settling before admission locks the issue, saved-comment attribution after reassignment, and routine ownership written inside the admission transaction. The layered server typecheck and module dependency check passed on the same revision. In a repeated local comparison of base `90d985b8b9` and PR head `b89bed954a`, we measured 34 samples per revision, scenario, and recovery-history state, alternating the two revisions in ABBA order. Server-side admission medians were: | Recovery history | Assignment | One comment | Two serial comments | | --- | ---: | ---: | ---: | | Empty | 23.45 → 21.80 ms | 23.95 → 23.00 ms | 47.30 → 45.40 ms | | Resolved | 23.35 → 21.30 ms | 23.70 → 22.05 ms | 46.70 → 45.40 ms | Typical SQL statements fell from 36/37/74 to 35/36/73 for the three scenarios. Lock statement counts were 2/2/6 for both revisions. Throughput varied under local contention. These are local measurements. Standard Greptile scored the exact head 5/5 with no review threads. [Greptile review](https://github.com/paperclipai/paperclip/pull/22289#issuecomment-6999578088) GitHub CI passed on the exact head after one targeted retry of the serialized server shard. The initial status-card maintenance case timed out waiting for idle, passed when run locally on the same revision, and passed in the retried shard. [CI workflow attempt 2](https://github.com/paperclipai/paperclip/actions/runs/44458613437/attempts/2) ## Risks An early decision can go stale, and the caller must preserve authenticated actor identity. The locked path retains its own eligibility checks. A regression exercises the gap between the two decisions. An attribution test inserts its evidence inside the transaction to detect a read through a different connection. ## Model Used OpenAI GPT-6.2 Sol (gpt-6.2-sol) implemented the change. OpenAI Codex reviewed and qualified it. ## 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 |