mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 10:07:24 +01:00
e18fe61c8feb54509fb3a7e0102a14ca5bf3f213
2755
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
168253f74d |
fix(telemetry): send agent.task_completed when a native run closes a task (#22963)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip sends product telemetry, and the `agent.task_completed`
event counts each task that an agent finishes
> - Only the REST issue update route (`server/src/routes/issues.ts`)
sent `agent.task_completed` when an agent moved a task to `done`
> - Native runs close tasks through `commitNativeStatusDecision` in
`server/src/services/native-runtime/status-decision-committer.ts`, which
bypasses the REST route and therefore sent `agent.task_run` without ever
sending `agent.task_completed`
> - Deployments where agents close tasks through native runs
consequently under-report completed tasks
> - This pull request supersedes #21206 (rebased onto current `master`),
sending `agent.task_completed` once after a committed native transition
into `done` without blocking finalization, with full company/person
telemetry scope and underlying Paperclip runner harness `adapter_type`
resolution
> - The benefit is accurate, deduplicated `agent.task_completed`
telemetry across both API and native completion paths
## Linked Issues or Issue Description
Refs #21206
**What happened?**
A native run closes a task through `commitNativeStatusDecision` in
`server/src/services/native-runtime/status-decision-committer.ts`. The
task moves to `done` and the run sends `agent.task_run`, but no
`agent.task_completed` event is sent because the only sender is
`server/src/routes/issues.ts` and native completion does not go through
that route.
**Expected behavior**
Paperclip sends one `agent.task_completed` event each time an agent
moves a task into `done`, on both the REST issue route and native status
commits. The event carries the same dimensions, runner harness
`adapter_type`, company scope, and person attribution as the issue
route. Replayed commits and tasks that were already `done` send nothing.
**Steps to reproduce**
1. Seed a native run ready to commit a `done` status decision on an
`in_progress` task.
2. Call `commitNativeStatusDecision` (or `finalizeNativeRun`) with a
`done` decision.
3. Observe that the task moves to `done`, while
`trackAgentTaskCompleted` is called 0 times.
**Paperclip version or commit**
`master` at `2d065677959b585065ff3fec8718156a4cf6f41d`.
## What Changed
- `server/src/services/agent-task-run-telemetry.ts`: add
`emitAgentTaskCompleted`. It loads the agent within the task's
`companyId`, resolves the underlying runner harness with
`telemetryAdapterType(agent)`, resolves person attribution with
`resolveTelemetryPerson`, wraps `trackAgentTaskCompleted` in
`withTelemetryActor({ companyId, person }, ...)`, and never throws.
- `server/src/services/native-runtime/status-decision-committer.ts`:
select `originRun.responsibleUserId` alongside `originRun.agentId`,
capture the completion payload only when the committed transaction
transitions `issue.status` from non-`done` to `done` with an origin
agent, and invoke `void emitAgentTaskCompleted(input.db, completedTask)`
after commit when `!committed.replayed` so slow lookups cannot block run
finalization.
-
`server/src/services/native-runtime/native-task-completed-telemetry.test.ts`:
add embedded-Postgres regression tests covering single emission (with
company scope, person attribution, and underlying runner harness
`adapter_type`), no duplicate on replay, non-blocking commit while
telemetry is pending, and no emission when the task was already `done`.
- `server/src/__tests__/agent-task-run-telemetry.test.ts`: add unit/DB
coverage for `emitAgentTaskCompleted` (company/person scope, runner
harness `adapterType`, cross-company agent isolation, and error
swallowing).
-
`server/src/services/native-runtime/native-run-finalizer-telemetry.test.ts`:
add an end-to-end `finalizeNativeRun` integration test verifying a real
native run completion emits `agent.task_completed` once through the real
`trackAgentTaskCompleted` path and emits no duplicates on replay or
reconciliation.
Note: this PR supersedes #21206 (whose fork branch had merge conflicts
with pruned test suites and predated `withTelemetryActor` /
`telemetryAdapterType` on `master`, and whose fork repository did not
allow maintainer pushes from this account).
## Verification
- **RED (before fix on `2d065677959b585065ff3fec8718156a4cf6f41d`):**
`pnpm --dir server exec vitest run
src/services/native-runtime/native-task-completed-telemetry.test.ts`
Result: 1 failed | 1 passed — `sends agent.task_completed once with
company, person, and harness adapter_type when the runner closes a task`
failed with `AssertionError: expected "vi.fn()" to be called 1 times,
but got 0 times`.
- **GREEN (after fix):**
`pnpm --dir server exec vitest run
src/services/native-runtime/native-task-completed-telemetry.test.ts
src/__tests__/agent-task-run-telemetry.test.ts
src/services/native-runtime/native-run-finalizer-telemetry.test.ts
src/__tests__/heartbeat-status-preserving-telemetry.test.ts
src/__tests__/issue-telemetry-routes.test.ts`
Result: **5/5 files, 106/106 tests passed**
(`native-task-completed-telemetry.test.ts` 3/3,
`agent-task-run-telemetry.test.ts` 55/55,
`native-run-finalizer-telemetry.test.ts` 42/42 including end-to-end
`finalizeNativeRun`, `issue-telemetry-routes.test.ts` 5/5,
`heartbeat-status-preserving-telemetry.test.ts` 1/1).
- **Typecheck:** `pnpm --filter @paperclipai/server typecheck` —
**PASS** (0 errors across all layers).
- **Test budget:** `node scripts/check-test-budget.mjs --files
server/src/services/native-runtime/native-task-completed-telemetry.test.ts
server/src/__tests__/agent-task-run-telemetry.test.ts
server/src/services/native-runtime/native-run-finalizer-telemetry.test.ts`
— **PASS** (110 nightly suites validated, 3 test files checked).
- **Broader suite:** `pnpm verify --base
|
||
|
|
702368ffaf |
feat(github): graduate GitHub review bots out of experimental (#22996)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - GitHub Code Review Bot connects an agent to a dedicated GitHub App so it reviews pull requests and responds to GitHub mentions > - The feature was gated behind the default-off `enableGitHubReviewBots` experimental instance setting, hiding the catalog card, setup routes, identity links, and channel creation > - People had to find and flip an instance-level experimental switch before they could connect a GitHub review agent > - This pull request graduates GitHub review bots to a normal always-on feature, keeping `enableGitHubReviewBots` only as a deprecated compatibility key that always resolves to `true` > - The benefit is that every Paperclip instance exposes GitHub Code Review Bot setup, discovery, and management by default without requiring feature flags ## Linked Issues or Issue Description **What existing behavior does this improve?** GitHub Code Review Bot discovery, catalog visibility, setup/management routes, identity-link endpoints, and Agent Channels visibility (`enableGitHubReviewBots`). **Subsystem affected** Cross-cutting (`packages/shared`, `server/`, `ui/`, Storybook, E2E specs, docs). **Current behavior** GitHub Code Review Bot is hidden from Connectors, `connections_search`, chat-endpoint creation, identity-link confirmation, and UI setup/settings routes until an instance admin turns on **Settings → Experimental → GitHub review bots** (`enableGitHubReviewBots`). **Proposed behavior** GitHub Code Review Bot is always available as a standard feature on every instance (self-hosted and Cloud), matching AgentMail and graduated features such as Assistant connections (`enablePublicMcp`) and the AWS connector (`enableAwsConnector`). `enableGitHubReviewBots` stays in schemas and the feature catalog only as a deprecated compatibility key that always normalizes to `true`, ignores stored or Cloud-managed `false` values, and does not reject legacy `false` patches. Experimental chat providers (Slack, Discord, Microsoft Teams, Telegram, iMessage Photon, Speko) remain gated by `enableChatConnectors`. **Reason and benefit** Users can connect and manage GitHub review agents directly from Connectors without an admin enabling an experimental flag first, and Cloud stacks no longer require managed feature-flag overrides to expose GitHub review bots. **Breaking changes** No schema migration or breaking API change. Existing rows, API patches, and Cloud managed configs that still carry `enableGitHubReviewBots` continue to parse cleanly, while the effective value is always `true`. Instances that previously kept `enableGitHubReviewBots` off now display GitHub Code Review Bot in Connectors and allow authorized managers (`tools:manage_connections`) to create GitHub review bot endpoints. ## What Changed - `packages/shared`: marked `enableGitHubReviewBots` as a deprecated compatibility key in types, Zod defaults (`true`), and `INSTANCE_FEATURE_CATALOG` (`cloudDefault: true`, `selfHostedDefault: true`); updated `channelMethodEnabled` in `connector-availability.ts` so `github` is always enabled alongside `agentmail`. - `server` instance settings and Cloud staging: `normalizeExperimentalSettings` always returns `enableGitHubReviewBots: true`; `applyManagedExperimentalOverlay` and `updateExperimental` ignore retired `enableGitHubReviewBots` entries so Cloud managed configs cannot turn it off and legacy `false` patches are not rejected; removed `enableGitHubReviewBots` from `CLOUD_STAGING_EXPERIMENTAL_KEYS`. - `server` chat channels, discovery, and OpenAPI: allowed `github` in `assertChatProviderEnabledForCreate`, `assertIdentityProviderEnabled`, `assertIdentityLinkAccess`, and `connection-intents` discovery without experimental flags while keeping `enableChatConnectors` enforcement for experimental chat providers; updated the OpenAPI endpoint description. - `ui` and Storybook: removed the **GitHub review bots** Experimental settings toggle card; simplified `useChatConnectorsEnabled` and `chatProviderVisible` so `github` and `github-code-review-bot` are always visible; bypassed experimental loading wait for `provider=github` in `ChatConnectorsExperimentalGate`; made the classic Agent Detail Channels tab and `AgentChannelsPanel` empty-state copy always reflect available agent identities; updated `canEnterAppsConnect`, `Browse`, `ConnectionSetupFlow`, and `github-connections.stories.tsx`. - Tests, E2E, runner-e2e, docs, and maps: updated unit, integration, managed-overlay, runner-e2e, and Playwright E2E specs; refreshed `tests/runner-e2e/source-sdk-public-inputs.json`; updated `doc/connections/GITHUB.md`, `doc/connections/GITHUB-REVIEW-BOT.md`, and `maps/feature-map/chat-channels.md`. ## Verification - `pnpm --filter @paperclipai/shared build && pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter @paperclipai/ui typecheck` — passed. - `node scripts/check-maps.mjs && node scripts/storybook-catalog.mjs` — passed. - `pnpm vitest run packages/shared/src/validators/instance.test.ts packages/shared/src/connector-availability.test.ts packages/shared/src/feature-catalog.test.ts server/src/__tests__/instance-settings-service.test.ts server/src/__tests__/instance-settings-managed-overlay.test.ts server/src/__tests__/instance-settings-cloud-defaults.test.ts server/src/routes/chat-channels.identity.test.ts server/src/__tests__/connection-intents-service.test.ts server/src/__tests__/chat-channels/slack-ingress-and-threads.integration.test.ts server/src/__tests__/chat-channels/github-setup-and-access.integration.test.ts` — all passed. - `pnpm vitest run ui/src/pages/apps/app-connect-policy.test.ts ui/src/components/chat/ExternallyConnectedTaskBanner.test.tsx ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx` — 3 files, 62 tests passed. - `pnpm --dir tests/runner-e2e vitest run github-review-journey.test.ts` — 56 tests passed. - `pnpm verify --explain` — confirmed `tests/runner-e2e/source-sdk-public-inputs.json` is current; exited 2 for broad CI coverage (handled by required GitHub CI gates on this PR). ## Risks - Behavioral shift: instances that had `enableGitHubReviewBots` off now show GitHub Code Review Bot in Connectors and allow authorized users with `tools:manage_connections` to configure GitHub review bots. Existing permission boundaries (`tools:manage_connections`, company scoping, GitHub App OAuth/installation consent) are unchanged. - `useIssueChatBinding` now queries `/api/issues/:issueId/chat-binding` for normal tasks even when `enableChatConnectors` is off so GitHub-bound task banners remain visible; experimental chat bindings remain filtered out by `chatProviderVisible` while `enableChatConnectors` is off. - No database migration is required; stored `enableGitHubReviewBots` JSON values become inert. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Google Gemini (high reasoning) in Antigravity, with tool use (shell, file edits, test execution). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
73369c5d46 |
feat(connections): AWS connector out of experimental; role ARN comes back from the agent (#22994)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The AWS connector lets agents work in an AWS account through AWS's hosted MCP server, with a per-connection role and short-lived credentials (#22083, #22195, #22233, #22626) > - It has been behind the `enableAwsConnector` experimental setting. It is now proven on paperclip.staging: a connection was set up end to end, and the daily QA routine's agent uses it to read private test evidence from S3 > - On the role step, the person still had to paste the role ARN back, even when their own agent created the role and reported the ARN in its live checklist > - This pull request takes the connector out of experimental and has the page pick up the role ARN from the agent, keeping the field for people who set the role up by hand > - The benefit is AWS available to everyone, with a setup that is "paste a prompt, press Test connection" ## Linked Issues or Issue Description Refs #22233 (role setup), #22626 (live agent checklist). **Subsystem affected** Connections (AWS app definition, role setup UI), instance experimental settings. **Problem or motivation** - The AWS connector works, but is hidden unless an operator turns on an experimental flag. - The setup page always showed a Role ARN field, and the person had to copy the ARN from the agent's summary into it. **Proposed solution** - Remove `experimentalFeatureKey` from the AWS app definition. `enableAwsConnector` becomes a compatibility key: stored and Cloud-managed values are ignored, and old clients' writes are accepted (same pattern as `enableMcpAggregators` and `enablePublicMcp`). - Move the Role ARN field into "Or do it by hand". When the agent finishes, take the ARN from its finish summary, accepting only an IAM role ARN for this connection's own role name (`paperclip-<connectionId>`), so a summary cannot point the connection at another role. "Test connection" then works with nothing to paste. The by-hand section opens on its own when a test fails or the agent finished without a usable ARN. **Alternatives considered** - Letting the agent save the ARN through the checklist API: more surface on a token-only route. Reading it from the finish summary needs no new API, and the test still proves the role trusts only this connection. - Removing the field entirely: people who use CloudFormation or IAM by hand still need it. ## What Changed - `packages/shared/src/app-definitions/aws.json`, `scripts/app-definition-overrides/aws.json`: no `experimentalFeatureKey`. - `packages/shared/src/feature-catalog.ts`, `validators/instance.ts`: `enableAwsConnector` is "(compatibility)", default on. - `server/src/services/instance-settings.ts`: always on; Cloud-managed values skipped; old clients' writes accepted. - `ui/src/pages/InstanceExperimentalSettings.tsx`: the AWS toggle is removed. - `ui/src/features/connections/aws-role-arn.ts` (new): the role ARN rule and `roleArnFromAgentSummary`. - `ui/src/features/connections/AwsRoleSetup.tsx`: Role ARN under "Or do it by hand", auto-filled from the agent's summary, with copy updated ("hands back the role when it finishes", "the Role ARN field below"). - `doc/connections/AWS.md`: no longer described as experimental. ## Verification - Server: `aws-mcp-connector.test.ts` (connects even with a stored `enableAwsConnector: false`), `instance-settings-managed-overlay.test.ts` (stays on with stored and Cloud-managed false; an old client's false write is accepted), `instance-settings-service.test.ts`: 68 passed. The 4 new flag tests fail against master's source (red/green). - Shared: `app-definitions.test.ts` 43 passed; `scripts/app-definition-overrides.test.mjs` 3 passed. - UI: `aws-role-arn.test.ts` 3 passed (this connection's ARN from a summary, including role paths and a trailing period; another role, a longer name, a short account and no ARN are rejected). UI typecheck clean. - Storybook (headless Playwright, current branch): the default view has no Role ARN field; "agent done" shows "Your agent's role is ready. Test the connection to finish." with Test connection enabled; "test failed" opens "Or do it by hand" with the field at its end. No page errors. - Live: the connector was set up end to end on paperclip.staging (Test connection passed) and is in daily use by the QA routine. To re-check after deploy without the flag. ## Risks - Every instance now shows the AWS connector. It was already proven on staging; access is per connection and read-only connections are capped by AWS's `ReadOnlyAccess`. - The ARN auto-fill trusts only an ARN naming this connection's own role, and Test connection still verifies AWS accepts it, so a wrong or foreign ARN cannot be saved silently. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, Storybook with headless Playwright, the live staging instance). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8e8c1b9f4d |
fix(sandbox): scope staged provider-pack assets per provider and default Daytona disk to 20 GiB (#22981)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Native agents run inside remote Daytona sandboxes that require a
verified Runner provider pack
> - When a sandbox stages the provider pack into its workspace,
Paperclip copies, transfers, and verifies every
`provider-assets/<provider>` closure (~1.6 GB across pi, cursor,
copilot, kimi, and antigravity) even when the run only uses Claude,
Codex, OpenCode, or one provider
> - New image-backed Daytona sandbox environments also default to a 10
GiB disk, which leaves too little headroom for repository installs and
tests
> - This pull request stages and verifies only the
`provider-assets/<provider>` tree needed by the active run and raises
the Daytona plugin default disk size from 10 GiB to 20 GiB
> - The benefit is significantly more free workspace disk space, smaller
pack transfers, and safer default disk sizing without changing the
provider-pack archive format or breaking multi-provider workspace reuse
## Linked Issues or Issue Description
- Fixes: #19367
- Refs #19484
- Related: #19500 (ENOSPC fail-fast and full-sandbox recovery already
merged in #22068, #22239, #22383, #22466, and #22837), #22241
(deduplicated repeated bytes in staged packs)
## What Changed
- `server/src/services/native-runtime/provider-pack-compatibility.ts`:
add `requiredProviderAssetNames`, `isProviderAssetPathIncluded`, and
`providerAssetExcludeArgs` helpers that resolve the required
`provider-assets/<provider>` subset for a `PackProvider` (returning
unfiltered behavior when `provider` is omitted).
- `server/src/services/native-runtime/provider-pack-layers.ts`: filter
large layer entries by required provider assets before running the
remote reuse script and transferring missing layers, preserve
cross-provider image-twin reuse so core files can still reuse identical
bytes from excluded provider paths in the base image, and pass
`--exclude` flags to GNU `tar` for `overlay.tar.zst`.
- `server/src/services/native-runtime/provider-pack-archive.ts` and
`provider-pack-upload.ts`: forward `provider` and `manifest` into v1 and
v2 archive staging and exclude unused `provider-assets/*` during
extraction.
-
`server/src/services/native-runtime/remote-provider-pack-verification.ts`:
scope candidate asset tree digest checks to the active provider when
`provider` is passed and include `requiredAssets` in the verification
seal key so a pack verified for one provider cannot satisfy a seal check
for a different provider.
- `server/src/services/native-runtime/native-session-executor.ts` and
`server/src/services/kimi-connection-probe.ts`: pass the active
`PackProvider` to `prepareRemoteProviderPackOnTarget` and
`verifyRemoteProviderPackIdentity`.
- `packages/plugins/sandbox-providers/daytona/src/manifest.ts` and
`package.json`: raise the default `disk` allocation from `10` to `20`
GiB and bump the plugin version from `0.1.10` to `0.1.11` so
bundled-plugin boot reconciliation refreshes persisted manifests.
- Added unit and end-to-end tests in
`packages/plugins/sandbox-providers/daytona/src/plugin.test.ts`,
`server/src/services/native-runtime/provider-pack-archive.test.ts`,
`server/src/services/native-runtime/remote-provider-pack-verification.test.ts`,
and updated `server/src/__tests__/kimi-connection-probe.test.ts`.
## Verification
- **RED (before production edits):**
- `cd packages/plugins/sandbox-providers/daytona && npx vitest run
--config vitest.config.ts -t "bumps the plugin version|pre-fills
sizing|validates and passes the default 20 GiB"` — 3 failed (`0.1.10 !==
0.1.11`, `10 !== 20`).
- `cd server && npx vitest run
src/services/native-runtime/provider-pack-archive.test.ts -t "omits all
provider-assets|stages only the selected provider"` — 2 failed (unused
`provider-assets` staged on disk).
- `cd server && npx vitest run
src/services/native-runtime/remote-provider-pack-verification.test.ts -t
"verifies only the selected provider"` — 1 failed (`candidate_digest`
rejected Claude when `provider-assets/` was absent).
- **GREEN (after fix):**
- `cd server && npx tsc --noEmit -p tsconfig.json` — passed.
- `cd server && npx vitest run
src/services/native-runtime/provider-pack-archive.test.ts` — **56/56
passed**, including an end-to-end upload+verify test proving unfiltered
staging writes >= 6 MiB of provider assets, Claude staging omits all 6
MiB (< 256 KiB total) and verifies cleanly, and switching the same
workspace to Cursor rejects the Claude seal (`candidate_digest`) and
re-stages only Cursor (2 MiB, excluding Kimi and Pi).
- `cd server && npx vitest run
src/services/native-runtime/remote-provider-pack-verification.test.ts
src/services/native-runtime/remote-provider-pack.test.ts
src/services/native-runtime/retained-provider-pack-source.test.ts
src/__tests__/kimi-connection-probe.test.ts` — all passed
(`remote-provider-pack-verification.test.ts` 34/34,
`remote-provider-pack.test.ts` 60/60, `kimi-connection-probe.test.ts`
39/39, `retained-provider-pack-source.test.ts` all passed).
- `cd packages/plugins/sandbox-providers/daytona && pnpm typecheck &&
npx vitest run --config vitest.config.ts` — typecheck passed; all 15
offline test files passed (641 passed, 8 live tests skipped;
`archive-stream-window.test.ts` timed out once during parallel CPU
contention and passed in 6.17s when re-run).
- `node scripts/check-test-budget.mjs --files
server/src/services/native-runtime/provider-pack-archive.test.ts
server/src/services/native-runtime/remote-provider-pack-verification.test.ts
server/src/__tests__/kimi-connection-probe.test.ts` — passed (110
nightly suites validated, 3 test files checked).
- `pnpm verify --base
|
||
|
|
87fadcb108 |
feat(annotations): one-tap reactions on artifact comments (#22989)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - People review agent artifacts (plans, documents, routine descriptions, and case documents) with inline annotation comments > - Today a person must type a full reply to say "done", "checked", "looks good", or "I have a question" > - This slows down quick review feedback, and a question inside a reply does not automatically bring the assignee back > - This pull request adds four one-tap reactions to each annotation comment: Done, Check, Thumbs up, and Question > - A person's first Question reaction on an open task saves a durable wake receipt and wakes the task's assignee in a dedicated follow-up run to reply in that comment's thread (respecting chat ownership and wake rate limits) > - The benefit is fast review feedback without extra typing, while agents can read and set the same reactions through the API ## Linked Issues or Issue Description Refs #21637 (supersedes on current `master` with renumbered Drizzle migration, OpenAPI/experimental route contracts, durable wake receipts, chat ownership and rate-limit hardening, and current UI test suite) Refs #9336 (agent wake notifications for document annotation threads) Refs #9674 (agents cannot read inline document review comments) **What problem does this solve?** A reviewer cannot quickly acknowledge or question an annotation comment on an artifact. A short answer requires a typed reply, and nothing tells the agent that a person has a question about a comment. **Proposed solution** Add four fixed reactions per annotation comment: `done`, `check`, `thumbs_up`, and `question`. One tap adds a reaction and a second tap removes it. Each person or agent can add each reaction once per comment. A person's first `question` reaction on an open task commits a durable wake receipt in the same transaction and wakes the assignee once in a dedicated follow-up turn, with the comment included in the wake context. **Alternatives considered** Free-form emoji reactions. Fixed named reactions keep the API contract stable for agents and avoid storing arbitrary emoji strings on the server. ## What Changed - `packages/db`: Added `document_annotation_comment_reactions` table (`company_id`, `comment_id`, `reaction`, `actor_type`, `actor_id`, `created_at`, `removed_at`) with check constraints, cascade delete on comment deletion, and unique `(comment_id, reaction, actor_type, actor_id)` index. Generated online-compatible migration `0510_clear_speedball.sql`, refreshed Drizzle snapshot `0510_snapshot.json`, and pruned `0505_snapshot.json`. - `packages/shared`: Added `DOCUMENT_ANNOTATION_COMMENT_REACTIONS`, `DocumentAnnotationCommentReactionName`, `DocumentAnnotationCommentReactionActor`, `DocumentAnnotationCommentReactionSummary`, optional `reactions` on `DocumentAnnotationComment`, and `documentAnnotationCommentReactionSchema`. - `server`: Added `setCommentReaction` in `document-annotations.ts` using soft-delete (`removed_at`) and upsert revival (`(xmax = 0)` for `firstAdd`), and attached reaction summaries (`count`, `actors`, `reactedByMe`) to thread/comment reads. - `server` routes & contracts: Added `PUT` and `DELETE .../annotations/:threadId/comments/:commentId/reactions/:reaction` for issues, routines, and cases, registered them in `openapi.ts`, `experimental-api-metadata.ts`, and `experimental-api-paths.ts`, and logged activity (`*.document_annotation_comment_reaction_added` / `_removed`) only when a row changes. - `server` durable wake, chat ownership, rate limits & `packages/adapter-utils`: - A person's first `question` reaction on an open assigned issue inserts a recoverable `deferred_issue_execution` receipt in `agent_wakeup_requests` in the same DB transaction (`annotation-question-reaction:<id>`), passes `executionWaitRequestId` to `heartbeat.wakeup` (`reason: "issue_commented"`, `allowRunCoalescing: false`), resumes via `resumeDeferredExecutionReceipts` if immediate wake fails, and defers behind busy turns without duplicating receipts. - Recognized human annotation question reactions (`isHumanAnnotationQuestionWake`) as an independent wake cause for idle waiting agent chats while strictly enforcing chat ownership (`!conversationAgentId || conversationUserId === actorId`) across service, route, wake preflight, locked admission, and recovery queries. - Bounded distinct-comment question wakes under `issues ... FOR UPDATE` to at most 1 pending/in-flight wake per `(companyId, issueId, agentId)` and at most 3 original question receipts (`idempotency_key LIKE 'annotation-question-reaction:%'`) per `(companyId, issueId, user)` in a rolling 10-minute window. - `renderPaperclipWakePrompt` instructs the agent to answer the question in the annotation thread. - `ui`: Added four one-tap reaction buttons (`✅`, `✔️`, `👍`, `❓`) under each non-optimistic annotation comment in `DocumentAnnotationPanel` / `DocumentAnnotationPopover`, with counts, `aria-pressed`, hover tooltips naming actors, optimistic updates, client-scoped write serialization across panel/popover remounts (`WeakMap<QueryClient, Map<string, TargetReactionState>>`), live-update refetch overlay preservation, deferred invalidation while writes are pending, and updated Storybook fixture. - `docs/api` & `tests/runner-e2e`: Documented the reaction endpoints and wake bounds in `docs/api/issues.md` and `docs/api/routines.md`, and refreshed `tests/runner-e2e/source-sdk-public-inputs.json`. ## Verification - `pnpm --filter @paperclipai/db run check:migrations` and `migration-compatibility.ts`: `0510_clear_speedball.sql` classified `online_compatible`. - `pnpm --filter @paperclipai/db exec vitest run src/migration-snapshot-drift.test.ts src/migration-compatibility.test.ts`: passed (117/117). - `pnpm --filter @paperclipai/adapter-utils exec vitest run src/server-utils.test.ts -t "question reaction"`: passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/document-annotations-service.test.ts` (20/20, embedded Postgres — covering durable wake recovery, idle waiting-chat wake, busy-turn deferral, non-owner chat wake denial, and rolling-window + pending-backlog wake bounds across full queue admission), `src/__tests__/document-annotation-routes.test.ts` (20/20), `src/__tests__/routine-document-annotation-routes.test.ts`, `src/modules/wake-queue/application/issue-wake-admission.test.ts` (15/15), and `src/modules/wake-queue/domain/policy.test.ts`: all passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/openapi-routes.test.ts`: passed (59/59). - `pnpm --filter @paperclipai/ui exec vitest run src/hooks/useDocumentAnnotationMutations.test.tsx`: passed (9/9, covering optimistic updates, serialized writes across remounts, live-update refetch preservation, deferred invalidation across comments, and rendered `ThreadCard` DOM buttons/toggles). - Package typechecks (`@paperclipai/shared`, `@paperclipai/db`, `@paperclipai/adapter-utils`, `@paperclipai/server` all 7 layers, `@paperclipai/ui` + Storybook catalog): all passed. - `pnpm check:token-gates`, `node scripts/check-module-boundaries.mjs`, and `node scripts/check-test-budget.mjs`: all passed. - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check`: in sync (`inputs: 579, changed: false`). - Full-stack Playwright verification against a throwaway local server + embedded PostgreSQL: created a task, `plan` document, and annotation thread; verified invalid reaction returns `400`; clicked `thumbs_up` and `question` in the real document viewer; reloaded to prove PostgreSQL persistence; toggled `thumbs_up` off and reloaded to verify removal persisted. - PR CI on `4d892c8067`: 83/83 executed checks passing (including `ci / verify`, `ci / e2e` + all 16 E2E shards, all General/Serialized server shards, `Build`, `Typecheck + Release Registry`, `Verify Paperclip Runner`, `Superagent Security Scan`, and `Greptile Review` 5/5 with 0 unresolved threads). ## Risks - Low risk. Migration `0510_clear_speedball.sql` only creates a new table and its indexes (`online_compatible`), so running releases are unaffected. - `reactions` is optional on `DocumentAnnotationComment`, preserving backward compatibility for existing clients. - Question wakes are bounded by soft-delete revival (`firstAdd`), chat ownership enforcement, single pending/in-flight wake per `(companyId, issueId, agentId)`, and at most 3 original question wakes per `(companyId, issueId, user)` per 10-minute window. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Google Gemini (`gemini-3-pro` / Antigravity agentic coding environment with shell execution, file editing, embedded PostgreSQL, and Playwright verification), rebasing and extending prior work originally authored with Claude Opus 5.5 in #21637. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: lucktastic <13757243+lucktastic@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
0f52d90993 |
fix(github): detect writes outside GitHub App installations and stop advising Refresh access (#22978)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Agents use managed GitHub App connections through the tool gateway
to open issues, post comments, and perform approved writes on GitHub
repositories.
> - A GitHub App user-to-server token can write only to repositories
inside accounts where the Paperclip GitHub App is installed; even on a
public third-party repository, GitHub rejects writes with `403 Resource
not accessible by integration`.
> - Previously, Paperclip did not check the App's installed accounts
before posting an approval card, mapped every `403 Resource not
accessible by integration` to `github_access_denied`, and told both the
user ("Manage GitHub access") and the agent ("select Refresh access") to
repair access through a flow that cannot reach third-party
organizations.
> - This wastes human approvals on doomed writes and sends operators
into a dead-end permission refresh loop.
> - This pull request adds a pre-check before posting approval cards for
managed GitHub App writes outside installed accounts, distinguishes
`github_repo_outside_app_installations` and
`github_app_installation_suspended` from `github_access_denied` across
server classification, MCP routes, and continuation delivery, and
renders accurate UI guidance without a misleading "Manage GitHub access"
link for external repositories.
> - The benefit is that unreachable external-org writes fail immediately
with actionable alternatives (post directly on GitHub, use a PAT
connection, or have an org admin install the App and refresh access),
suspended installations get explicit unsuspend guidance, and missing
repository grants on installed organizations keep the existing "Manage
GitHub access" and "Refresh access" repair flow.
## Linked Issues or Issue Description
No public issue exists. Refs #19315, #19655, #20141.
**What happened?**
When an agent requested an approval-gated GitHub write targeting a
public repository owned by an external organization where the Paperclip
GitHub App was not installed, Paperclip posted a normal approval card.
After the user approved it, GitHub returned `403 Resource not accessible
by integration`, and both the failed approval card and agent
continuation instructions advised clicking "Manage GitHub access" and
"Refresh access", which cannot grant write access to a third-party
organization.
**Expected behavior**
Paperclip should check managed GitHub App write targets against the
grant's installed accounts before posting an approval card, fail
unreachable external-organization writes cleanly without wasting an
approval, preserve suspended installations separately with unsuspend
guidance, keep incomplete webhook-invalidated snapshots on
`github_access_denied` until refreshed, and present accurate
alternatives in both the UI card and agent continuation instructions.
**Steps to reproduce**
1. Connect GitHub via the managed GitHub App installed on one
organization (for example `acme`), with an approval policy on GitHub
writes.
2. Ask an agent to run `create_issue` or `add_issue_comment` targeting a
repository in an external organization where the App is not installed
(for example `external-org/public-repo`).
3. Previously, Paperclip posted an approval card, executed it upon
approval, received `403 Resource not accessible by integration`, and
showed "GitHub access needed" / "Manage GitHub access" plus "Refresh
access" instructions.
**Paperclip version or commit**
`2d065677959b` (`master`, merged cleanly with `331e1a9fd3`)
**Deployment mode**
Local / Paperclip Cloud managed GitHub App connection
## What Changed
- `server/src/services/tool-access/github-access-discovery.ts`,
`packages/db/src/schema/tool_access.ts`,
`packages/shared/src/types/tool-access.ts`,
`packages/shared/src/validators/tool-access.ts`: Preserved suspended
installation owner logins separately in optional
`suspendedInstallationOwnerLogins` so active `installationOwnerLogins`
stays unchanged while suspended orgs are distinguishable from
uninstalled orgs. Added `github_repo_outside_app_installations` to
`ToolAccessReasonCode` and updated
`tests/runner-e2e/source-sdk-public-inputs.json`.
- `server/src/services/tool-access/github-access-errors.ts`: Added
`github_repo_outside_app_installations`,
`github_app_installation_suspended`, `isGitHubAccessErrorCode`,
`extractGitHubTarget` (`owner`+`repo`, `repository: "owner/repo"`,
`organization`/`org`, `fork_repository` destination-only handling, and
GitHub API URL fallback), `suspendedManagedGitHubOwner`,
`findUnreachableManagedGitHubTarget`,
`githubOutsideAppInstallationsInstructions`,
`githubSuspendedInstallationInstructions`, and
`githubAccessErrorInstructions`. Webhook-invalidated/incomplete
snapshots (`bindingSync` set or `installationIds` ahead of
`installationOwnerLogins` with `repositories` cleared) skip pre-check
blocking and stay on `github_access_denied` on runtime `403` until
access is refreshed.
- `server/src/services/tool-access-policy.ts` and
`server/src/services/tool-gateway.ts`: Reused the already-resolved
remote tool context from `resolveGovernedToolCall` (avoiding redundant
connection/grant lookups for non-GitHub providers), routed unreachable
approval-requiring managed GitHub writes through the canonical policy
denial path with `{ claimIdempotencyKey: false }` (inserting
`idempotencyKey: null` atomically in the single `INSERT` so retries
after installing the App are never falsely replayed), and propagated
`github_repo_outside_app_installations` /
`github_app_installation_suspended` (HTTP 403) without echoing raw
provider text into trusted instructions.
- `server/src/routes/tool-gateway.ts`,
`server/src/services/tool-action-delivery.ts`,
`server/src/services/continuation-cause.ts`,
`server/src/services/agent-task-run-telemetry.ts`: Treated all GitHub
access error codes as MCP `tools/call` `isError: true` results, routed
continuation wakes through `githubAccessErrorInstructions`, and
registered `github_repo_outside_app_installations` and
`github_app_installation_suspended` as person-owned `missing_access`
failure codes.
- `ui/src/components/IssueThreadInteractionCard.tsx` and
`ui/storybook/stories/questions-and-approvals/connection-reviews.stories.tsx`:
Added dedicated alert states for `github_repo_outside_app_installations`
("Repository outside GitHub App access", omitting dead-end "Manage
GitHub access") and `github_app_installation_suspended` ("GitHub App
installation suspended", with unsuspend guidance and "Manage GitHub
access"), using existing design tokens only, while keeping "GitHub
access needed" for `github_access_denied`.
- `doc/connections/GITHUB.md`: Documented pre-check, suspended
installation, incomplete webhook snapshot, and error classification
behavior.
- Added unit, UI component, and embedded-Postgres integration tests in
`server/src/services/tool-access/github-access-errors.test.ts`,
`server/src/__tests__/github-grant-metadata.test.ts`,
`server/src/__tests__/tool-gateway.test.ts`,
`server/src/__tests__/tool-gateway-action-approvals.test.ts`, and
`ui/src/components/IssueThreadInteractionCard.test.tsx`.
## Verification
- `pnpm vitest run
server/src/services/tool-access/github-access-errors.test.ts
server/src/services/tool-access/github-default-owner.test.ts
server/src/__tests__/github-grant-metadata.test.ts
ui/src/components/IssueThreadInteractionCard.test.tsx`: 4 files, 140/140
passed.
- `pnpm vitest run server/src/__tests__/tool-gateway.test.ts -t
"GitHub"`: 13/13 passed (covers pre-check blocking with atomic
`idempotencyKey: null`, installed-org missing-repo
`github_access_denied`, direct + MCP HTTP route `isError: true`,
approved-card runtime 403 URL classification, post-install retry,
suspended installation `github_app_installation_suspended`, and
webhook-invalidated `bindingSync` snapshot pass-through).
- `pnpm vitest run
server/src/__tests__/tool-gateway-action-approvals.test.ts -t "tells the
agent how to recover from"`: 9/9 passed (including
`github_repo_outside_app_installations` and
`github_app_installation_suspended` continuation wakes).
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/db typecheck && pnpm --filter @paperclipai/server typecheck
&& pnpm --filter @paperclipai/ui typecheck`: passed (0 errors across all
7 server layers, shared, db migration safety/compatibility, and UI +
Storybook catalog).
- `pnpm check:token-gates`: all 4 gates clean.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs
|
||
|
|
38e3a71669 |
fix(connections): use Slack MCP user OAuth flow and surface OAuth errors in setup UI (#22976)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Apps and Connections let operators connect external providers
through remote MCP servers and OAuth.
> - Slack's curated `mcp-oauth` method pins Slack's bot install
endpoints (`oauth/v2/authorize` and `oauth.v2.access`) while sending
user-only scopes (`search:read.public`, `search:read.private`, etc.) in
`scope`, so Slack rejects sign-in with `"Invalid permissions
requested"`.
> - In addition, when OAuth fails or returns an error for a
customer-owned OAuth app like Slack, `ConnectionSetupFlow`'s `KeyStep`
drops `oauthError` completely, hiding the failure banner, and
`OAuthClientFields` hides the method's `guidanceMd` prerequisites.
> - This pull request switches Slack's `mcp-oauth` method to Slack's
documented MCP user OAuth endpoints (`oauth/v2_user/authorize` and
`oauth.v2.user.access`), propagates allowlisted RFC OAuth
`providerError` codes without reflecting untrusted provider prose,
displays OAuth errors and popup fallback links on `KeyStep`, and renders
setup prerequisites (`guidanceMd`) beside customer OAuth fields.
> - The benefit is that customer-owned Slack MCP sign-in succeeds
(including when resuming pre-fix drafts) and any OAuth error or Slack
MCP prerequisite is clearly shown to the user.
## Linked Issues or Issue Description
Fixes: #13935
Refs #17258
Refs #14037
Builds on #17258 (`fix/slack-mcp-user-oauth-flow`) and adds the missing
customer-OAuth error surface and setup guidance in
`ConnectionSetupFlow`.
## What Changed
- Updated `packages/shared/src/app-definitions/slack.json` and
`scripts/ingest-app-definitions.mjs` so Slack's `mcp-oauth` method uses
`https://slack.com/oauth/v2_user/authorize` and
`https://slack.com/api/oauth.v2.user.access`, and added Slack MCP
prerequisites (`User Token Scopes`, callback URL, and `Model Context
Protocol`) to `guidanceMd`.
- Updated `server/src/routes/tool-access.ts` to propagate allowlisted
RFC `providerError` codes (`normalizeOAuthProviderError`, excluding
`unrecognized`) via `provider_error` on OAuth recovery redirects and
connection-intent postMessages, while continuing to never read or
reflect untrusted `error_description` or `error_uri`.
- Updated `ui/src/features/connections/ConnectionSetupFlow.tsx` and
`ui/src/lib/oauthWindowOutcome.ts` so:
- `KeyStep` renders `oauthError` (not only `connectMutation.error`) and
the `"Open sign-in in a new tab"` fallback link when popups are blocked.
- `oauthCallbackErrorMessage` and `oauthFailureMessage` map allowlisted
`providerError` values (such as `invalid_scope`, `invalid_redirect_uri`,
`invalid_client`) and Paperclip failure codes (including
`slack_mcp_access_disabled`) to actionable Paperclip-authored copy.
- Opener popup polling reads same-origin failure `code` and
`provider_error` details from the returned callback URL.
- `OAuthClientFields` renders `method.guidanceMd` for required
customer-owned OAuth apps whose client secret is optional.
- Updated `tests/runner-e2e/source-sdk-public-inputs.json` for the
changed `@paperclipai/shared` sources.
- Updated Slack OAuth test fixtures in
`server/src/__tests__/tool-access-service.test.ts` and
`server/src/services/tool-access/oauth/client-settings.test.ts`, and
added regressions in `packages/shared/src/app-definitions.test.ts`,
`server/src/__tests__/tool-access-service.test.ts`,
`ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts`, and
`ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx`.
## Verification
- Shared, UI, and OAuth client-settings unit + DOM tests (95/95 passed):
- `pnpm exec vitest run packages/shared/src/app-definitions.test.ts
ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts
ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx
ui/src/features/connections/ConnectionSetupFlow.architecture.test.ts
server/src/services/tool-access/oauth/client-settings.test.ts`
- Embedded-Postgres server OAuth start + legacy-draft upgrade + callback
error redirect + redaction tests:
- `pnpm exec vitest run server/src/__tests__/tool-access-service.test.ts
-t "uses Slack user OAuth endpoints even for legacy drafts|starts OAuth
from|refreshes|personal|slack"` (33 passed)
- `pnpm exec vitest run
server/src/__tests__/generic-mcp-connection.test.ts -t "returns browser
denials|denied and cancelled callbacks|redacts"` (9 passed)
- Typechecks & guardrails:
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/server typecheck && pnpm --filter @paperclipai/ui
typecheck` (all passed)
- `node scripts/check-test-budget.mjs --files
packages/shared/src/app-definitions.test.ts
server/src/__tests__/tool-access-service.test.ts
server/src/services/tool-access/oauth/client-settings.test.ts
ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts
ui/src/features/connections/ConnectionSetupFlow.slack-oauth.test.tsx`
(PASS)
- `pnpm verify --base
|
||
|
|
227c2f794f |
fix(runner): align request_human_input title and prompt limits with server (#22977)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents ask humans for answers or approvals with the runner's `request_human_input` tool, which creates an interaction card on the active task > - The runner tool schema advertised `title` up to 300 characters and `prompt` up to 10,000 characters > - The server's `createIssueThreadInteractionSchema` enforces `title` at most 240 characters and `summary` / `payload.prompt` at most 1,000 characters across all five interaction kinds > - An agent that sends a 241–300 character title or a 1,001–10,000 character prompt passes the runner tool schema but fails server validation, causing wasted retries > - Open PR #20134 addressed the mismatch on an older base, but conflicted with `master` and left `native-execution-seeded.json` and `protocol/manifest.json` stale > - This pull request defines shared constants inside `packages/paperclip-runner`, aligns both runner tool catalogs to 240 / 1,000, regenerates every derived catalog and manifest file, and adds cross-package parity tests for all five interaction kinds > - The benefit is that agents receive the exact server limits in the tool schema before calling `request_human_input`, preventing avoidable validation failures and retries ## Linked Issues or Issue Description Supersedes #20134 (rebased cleanly onto `master`, resolves catalog conflicts, regenerates `native-execution-seeded.json` and `protocol/manifest.json`, and tests all five interaction kinds). Refs #19405 **What happened?** An agent called `request_human_input` with a `prompt` longer than 1,000 characters (or a `title` longer than 240 characters). The call passed the runner's advertised schema (`title` max 300, `prompt` max 10,000), but failed server validation in `createIssueThreadInteractionSchema` (`title <= 240`, `summary <= 1000`, `payload.prompt <= 1000`). **What did you expect to happen?** The runner's `request_human_input` schema should advertise the exact character limits that the server accepts (`title` max 240, `prompt` max 1,000), so invalid inputs fail at the tool schema boundary instead of failing server validation. **Steps to reproduce** 1. Inspect `capabilitySemanticToolDescriptor("request_human_input").inputSchema` and `paperclipSemanticAction("request_human_input").inputSchema`. 2. Build an interaction input at the advertised `title.maxLength` and `prompt.maxLength` and validate it with `createIssueThreadInteractionSchema.safeParse(...)`. 3. Before this fix, all five interaction kinds fail server validation with `too_big` (`maximum: 240` on `title`, `maximum: 1000` on `summary` and `payload.prompt`). ## What Changed - Exported `REQUEST_HUMAN_INPUT_TITLE_MAX_LENGTH = 240` and `REQUEST_HUMAN_INPUT_PROMPT_MAX_LENGTH = 1000` from `packages/paperclip-runner/src/protocol-actions/request-human-input.ts` and updated its live descriptor to use them. - Reused those constants in `packages/paperclip-runner/src/catalog/semantic-action-catalog.ts` so both runner catalogs share one source of truth. - Regenerated `packages/paperclip-runner/generated/semantic-action-catalog.json`, `packages/paperclip-runner/generated/capability/semantic-tool-contracts.json`, `packages/paperclip-runner/protocol/fixtures/evals/native-execution-seeded.json`, and `packages/paperclip-runner/protocol/manifest.json`. - Added a runner catalog parity test in `packages/paperclip-runner/src/catalog/semantic-action-catalog.test.ts` and a cross-package contract test in `server/src/__tests__/request-human-input-bounds.test.ts` covering all five interaction kinds (`ask_user_questions`, `request_confirmation`, `request_checkbox_confirmation`, `request_item_verdicts`, `suggest_tasks`) at `max` and `max + 1`. ## Verification - `pnpm exec vitest run server/src/__tests__/request-human-input-bounds.test.ts` (failed 5/6 before the fix with `too_big` 240/1000; passed 6/6 after the fix) - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/catalog/semantic-action-catalog.test.ts src/catalog/protocol-action-contracts.test.ts src/protocol-actions/core-contracts.test.ts src/contracts/tool-input-variants.test.ts src/evals/native-execution.test.ts src/semantic-tools/semantic-tools.test.ts` (passed) - `pnpm --filter @paperclipai/paperclip-runner run build` and `pnpm --filter @paperclipai/paperclip-runner run check:static` (passed; confirmed generated contracts, seeded catalog digest, and protocol manifest match) - `pnpm --filter @paperclipai/server typecheck` and `pnpm --filter @paperclipai/paperclip-runner run typecheck:typescript` (passed) - `pnpm exec vitest run server/src/services/native-runtime/paperclip-runner-tool-authority.test.ts -t "advertised (choice|text|mixed) question|checkbox interactions"` (4/4 embedded-Postgres tests passed) - `cargo test --manifest-path packages/paperclip-runner/runner/Cargo.toml --locked -p paperclip-runner-core acpx_tool_failure_feedback` and `cargo test --manifest-path packages/paperclip-runner/runner/Cargo.toml --locked -p paperclip-runner-core --test acpx_provider_resolutions` (7 unit + 12 integration tests passed, confirming field-level Zod validation feedback reaches the agent cleanly) - `node scripts/check-test-budget.mjs --files server/src/__tests__/request-human-input-bounds.test.ts` (passed) ## Risks - Low risk. Narrowing the runner schema matches the trimmed character limits that the server already enforces (`title` <= 240, `prompt` <= 1,000); raw inputs padded with extra leading or trailing whitespace that exceed those raw lengths are conservatively rejected at the tool schema boundary. - Agents that need longer body text in a question card should put it in `payload.questionSet.description` (up to 100,000 characters) or `detailsMarkdown` on confirmation/checkbox/item-verdict payloads (up to 20,000 characters). ## Model Used - Claude Opus 4.6 (`claude-opus-4-6`), Anthropic, with extended thinking, tool use, and code execution in an agent harness. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
560765988d |
fix(recovery): unblock hermes_gateway holds, classify 429/529 transient, and isolate binding_mismatch (#22969)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Task execution recovery prevents failed, timed-out, or interrupted runs from leaving tasks permanently blocked. > - Three concrete recovery gaps still leave tasks stuck: `hermes_gateway` is omitted from `CONVERSATION_ADAPTER_TYPES` (so timed-out/cancelled runs stick in `legacy_execution_requires_reconciliation`), terminal `hermes_gateway` 429/529 failures omit `errorFamily` (so bounded transient retry never fires), and automatic continuation after a non-retryable workspace `binding_mismatch` chooses `writer_ended` (reusing the broken workspace in a loop) while stranded notices omit the saved failure reason. > - Users cannot unblock `hermes_gateway` tasks via Retry or board comments, transient provider rate limits park tasks indefinitely, and `binding_mismatch` tasks exhaust the hourly retry cap with only a generic chat notice. > - This pull request adds `hermes_gateway` to conversation continuation and explicit continuation admission (delegating terminal stop proof to the Hermes adapter), classifies terminal `hermes_gateway` 429/529/5xx/quota/gateway-shutdown failures with `errorFamily` and `retryNotBefore`, switches automatic continuation to `fresh_isolated_workspace` on non-retryable `binding_mismatch`, and surfaces the Core-owned failure reason in stranded no-running-execution notices. > - The benefit is that stuck `hermes_gateway` holds clear cleanly when stopped, transient upstream errors retry automatically, and `binding_mismatch` continuations start in a fresh isolated workspace with clear user-facing diagnostics. ## Linked Issues or Issue Description - Fixes: #17196 - Fixes: #17526 - Refs #21289 (extends non-retryable `binding_mismatch` fresh-workspace handling from manual board Retry to automatic continuation fallback and stranded recovery notices) - Related open PRs checked during dedup search (no overlap): #22756, #22810, #22738 ## What Changed - **`hermes_gateway` conversation continuation and hold clearing (#17196)**: - Add `"hermes_gateway"` to `CONVERSATION_ADAPTER_TYPES` in `server/src/services/conversation-continuation.ts` so failed, interrupted, and acknowledged-cancelled `hermes_gateway` runs receive `conversationContinuation` policy and matching holds retire cleanly. - Export `hasHermesGatewayTerminalStopProof` from `@paperclipai/hermes-paperclip-adapter/gateway/server` (`packages/adapters/hermes/src/gateway/server/terminal-failure.ts`) and consume its boolean result in `server/src/services/explicit-native-continuation.ts` so pre-existing `legacy_execution_requires_reconciliation` holds for remote `hermes_gateway` runs clear `process_identity_missing` only when the Hermes adapter confirms a terminal gateway response or pre-fetch configuration error, while unconfirmed `hermes_gateway` timeouts fail closed. - **`hermes_gateway` terminal transient/quota classification (#17526)**: - Extract terminal error classification into `packages/adapters/hermes/src/gateway/server/terminal-failure.ts` and wire it in `packages/adapters/hermes/src/gateway/server/execute.ts` (`extractErrorMessage`, `classifyTerminalFailure`, `mapFinalResultForTest`) to classify terminal provider 429/529/5xx/rate-limit/overload errors (including camelCase `statusCode`/`httpStatus`, `HTTP/x.y` status lines, and `Bad Gateway`/`Gateway Timeout` phrases) as `errorFamily: "transient_upstream"`, structured/message quota errors (including `insufficient_quota`) as `errorFamily: "provider_quota"`, and forward range-checked `retryNotBefore` from `retry_not_before` / `retry_after`. - Map unexpected `hermes_gateway` shutdown/restart interruptions (`status: "cancelled"` with shutdown/restart wording) to retryable failed outcomes (`errorCode: "hermes_gateway_run_failed"`, `signal: null`, `errorFamily: "transient_upstream"`, `resultJson: { status: "interrupted", gateway_status: "cancelled" }`) while keeping deliberate cancels as `cancelled`, keeping HTTP 400/403 errors (even with rate-limit/overloaded text) non-transient, and never forging `connectionFailure` from remote text. - **Automatic continuation `binding_mismatch` isolation and saved failure cause**: - Export `readWorkspaceProviderFailure` and `workspaceProviderFailureMessage` in `server/src/services/workspace-provider-failure.ts` using only Core-owned closed messages (no raw provider text). - Update `server/src/services/fresh-continuation-fallback.ts` to choose `isolation: "fresh_isolated_workspace"` instead of `"writer_ended"` strictly when `run.resultJson.workspaceProviderFailure?.retryable === false && workspaceProviderFailure.reason === "binding_mismatch"`, clearing `issues.executionWorkspaceId` and tagging `freshContinuationIsolation` while preserving `"writer_ended"` for retryable and non-binding errors (e.g. `storage_pending`, `credential_unavailable`). - Update `buildNoRunningExecutionNoticeSeed` and `buildImmediateExecutionPathRecoveryNoticeSeed` in `server/src/services/recovery/stranded-notice.ts` to accept typed `WorkspaceProviderFailureSummary | PluginWorkspaceOperationFailureReason | null` (resolving once and dropping unknown strings) and pass `readWorkspaceProviderFailure(latestRun?.resultJson)` from `server/src/services/recovery/service.ts` (minimal argument additions at existing escalation call sites). - **Regression and embedded-Postgres E2E tests**: - Added tests to existing test suites (`packages/adapters/hermes/src/gateway/server/execute.test.ts`, `server/src/services/conversation-continuation.test.ts`, `server/src/services/fresh-continuation-fallback.test.ts`, `server/src/__tests__/workspace-provider-failure.test.ts`, `server/src/__tests__/heartbeat-retry-scheduling.test.ts`, `server/src/services/heartbeat/run-completion.test.ts`) without adding new test files. ## Verification - **Hermes adapter unit tests**: `pnpm --filter @paperclipai/hermes-paperclip-adapter exec vitest run src/gateway/server/execute.test.ts` — 122/122 passed. - **Hermes adapter typecheck**: `pnpm --filter @paperclipai/hermes-paperclip-adapter typecheck` — passed. - **Server typecheck**: `pnpm --filter @paperclipai/server typecheck` — passed (all 7 project layers). - **Module boundaries**: `node scripts/check-module-boundaries.mjs` — passed. - **Server recovery, retry scheduling, `completeRun`, and embedded-Postgres E2E suites**: - `pnpm --filter @paperclipai/server exec vitest run --hookTimeout=60000 src/services/conversation-continuation.test.ts src/__tests__/workspace-provider-failure.test.ts` — 11/11 passed. - `pnpm --filter @paperclipai/server exec vitest run --hookTimeout=60000 src/services/fresh-continuation-fallback.test.ts -t "binding_mismatch|workspaceProviderFailure"` — 3/3 passed. - `pnpm --filter @paperclipai/server exec vitest run --hookTimeout=60000 src/services/heartbeat/run-completion.test.ts -t "hermes_gateway shutdown"` — 1/1 passed. - `pnpm --filter @paperclipai/server exec vitest run --hookTimeout=60000 src/__tests__/heartbeat-retry-scheduling.test.ts -t "hermes_gateway 429"` — 1/1 passed. - **Test budget check**: `node scripts/check-test-budget.mjs --files server/src/services/conversation-continuation.test.ts server/src/services/fresh-continuation-fallback.test.ts server/src/__tests__/workspace-provider-failure.test.ts server/src/__tests__/heartbeat-retry-scheduling.test.ts server/src/services/heartbeat/run-completion.test.ts` — passed. ## Risks - Low risk; no database schema migrations or breaking API changes. - `hermes_gateway` holds without a confirmed terminal gateway response (such as unconfirmed client-side timeouts) intentionally fail closed with `process_identity_missing` to prevent overlapping remote execution. - Only `binding_mismatch` workspace provider failures trigger `fresh_isolated_workspace` on automatic continuation; retryable and non-binding non-retryable failures keep `writer_ended` so usable task workspaces are not discarded. - Stranded recovery notices render only Core-owned closed failure messages and drop unrecognized values, preventing raw provider error strings from reaching issue threads. ## Model Used - Google Gemini (Antigravity agent with tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) |
||
|
|
bff0f6dab5 |
fix(redaction): preserve SigV4 presigned upload URLs in tool results (#22959)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Tool results flow through `validateToolContent`, `redactSensitiveText`, and `redactCommandText` before reaching the agent > - `COMMAND_ENV_SECRET_ASSIGNMENT_RE` matched `X-Amz-Credential` and `X-Amz-Security-Token` inside AWS SigV4 presigned URLs and consumed the rest of the URL, wiping `X-Amz-Signature` > - Agents received truncated upload URLs and could not execute signed S3/R2 `PUT` uploads returned by MCP tools > - This pull request extracts a focused SigV4 helper that temporarily sets aside validated `X-Amz-Credential` and `X-Amz-Security-Token` parameters inside complete HTTPS SigV4 presigned queries before command redaction, while keeping request-identity hashing and approval encryption sensitive for those URLs > - The benefit is that agents receive usable short-lived presigned upload links while percent-encoded or malformed secrets, other secret parameters, secret-named assignments, incomplete queries, placeholder collisions, and retried write idempotency keys remain safe ## Linked Issues or Issue Description - Refs #14014 ## What Changed - Extracted `packages/adapter-utils/src/sigv4-presigned-url.ts` to detect complete HTTPS SigV4 presigned queries (`X-Amz-Algorithm=AWS4-HMAC-SHA256`, valid SigV4 `X-Amz-Credential` scope, `X-Amz-Date`, numeric `X-Amz-Expires`, `X-Amz-SignedHeaders`, and 64-hex `X-Amz-Signature`), including single- and double-escaped `\u0026` query separators and trailing markdown/prose delimiters. - Validated raw and iteratively percent-decoded `X-Amz-Credential` and `X-Amz-Security-Token` values against canonical decoded shapes and shared standalone secret token patterns (`sk-`, `gh*_`, `github_pat_`, Stripe `sk_`/`rk_` keys, JWTs), failing closed on malformed/deeply nested percent-encoding and private-use placeholder collisions. - Updated `packages/adapter-utils/src/command-redaction.ts` to delegate SigV4 parameter protection to `protectSigV4PresignedUrlParameters` and keep `collectDiagnosticEnvironmentSecrets` treating SigV4 presigned URLs as private. - Updated `server/src/services/tool-content-guards.ts` (`containsSensitiveToolArguments`) to keep SigV4 presigned URLs classified as sensitive for `toolRequestIdentityHash` (preserving HMAC `side_effect:v2` idempotency keys across deploys) and `signToolArguments` (keeping v2 A256GCM encryption at rest). - Added unit and end-to-end tests in `packages/adapter-utils/src/command-redaction.test.ts` and `server/src/__tests__/tool-content-guards.test.ts` covering complete SigV4 URLs, percent-encoded/double-encoded/malformed smuggled secrets, sibling secret redaction, model-classifier parity, and HMAC identity/approval encryption stability. ## Verification - `pnpm vitest run packages/adapter-utils/src/command-redaction.test.ts server/src/__tests__/tool-content-guards.test.ts server/src/__tests__/redaction.test.ts server/src/__tests__/remote-mcp-redaction.test.ts` — passed (`4` files, `143` tests). - `pnpm --filter @paperclipai/adapter-utils typecheck && pnpm --filter @paperclipai/adapter-utils build && pnpm --filter @paperclipai/server typecheck` — passed (all 7 server typecheck layers). - `pnpm verify` — exited with code `2` because graph worker `@paperclipai/server` hit `SIGKILL` under local memory pressure; required CI covers the broad suite. - Verified end-to-end via `validateToolContent` (`server/src/services/tool-content-guards.ts`) with a realistic MCP presigned upload response: complete S3 SigV4 URLs arrive intact while sibling `apiKey`/`Authorization: Bearer` secrets and percent-encoded smuggled secrets are redacted, and `toolRequestIdentityHash` / `signToolArguments` remain HMAC-keyed and v2-encrypted. ## Risks - Complete HTTPS SigV4 presigned URLs remain visible in tool results, audit summaries, and transcripts until their short expiry window (`X-Amz-Expires`). Incomplete SigV4 queries, non-SigV4 parameters, secret-named assignments/CLI flags/JSON keys, percent-encoded/malformed smuggled tokens, and placeholder collisions fail closed. ## Model Used - Antigravity AI coding assistant (Google DeepMind agentic runtime, extended reasoning with local tool execution and verification). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
64bef50be0 |
feat(cloud): add Cloud starter inference proxy, migration modal, and PostHog A/B telemetry (#22966)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Hosted Cloud onboarding currently requires new users to connect a model provider subscription or API key before their first agent can run > - That upfront credential step creates drop-off before a new user sees their first agent do real work > - We need an opt-in, managed Cloud capability that runs the first agent right away through a server-side proxy, keeps the raw provider key out of sandboxes and browsers, prompts the user to connect their own provider when starter inference runs out, and measures treatment vs. control in PostHog > - This pull request adds the default-off `enableCloudTrialInference` managed feature, the server-side OpenRouter reverse proxy with ephemeral per-run tokens, the blocking model-connection and agent-migration modal with Storybook stories, and Cloud-only PostHog A/B cohort and funnel telemetry > - The benefit is zero-friction first-agent onboarding on Cloud stacks enrolled in the experiment, with automatic migration to the user's own model provider and clean A/B observability ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting (`packages/shared`, `packages/paperclip-runner`, `server/`, `ui/`) **Problem or motivation** New Cloud users must connect an AI subscription or API key before they can run their first agent. We want to A/B test letting eligible Cloud workspaces start their first agent right away with managed starter inference (OpenCode / GPT-6 Luna in Paperclip Runner) without exposing any raw upstream API key to the sandbox, database, or browser, and then guide the user to connect their own model provider when starter inference runs out. **Proposed solution** Add an experimental managed feature flag (`enableCloudTrialInference`, off by default on both Cloud and self-hosted) that: - Routes starter-inference runs through a server-side OpenRouter reverse proxy (`/api/internal/cloud-inference/v1/*`) authenticated with ephemeral per-run bearer tokens so the raw OpenRouter key never leaves server memory. - Enforces the configured starter model, detects upstream HTTP 402 exhaustion, invalidates active run tokens, reports exhaustion back to the Cloud control plane, and broadcasts `cloud_trial.status.updated` over live events. - Displays a blocking modal (`CloudTrialExhaustedModal`) when starter inference runs out while agents still depend on it, lets the user connect their own model provider, automatically migrates trial agents to that provider's default harness and model, clears incompatible provider sessions, and resumes paused work. - Stamps the `cloud-trial-inference` (`treatment` / `control`) cohort onto Cloud-only server and browser PostHog telemetry and records Cloud-only funnel events (`$feature_flag_called`, `cloud_trial.started`, `cloud_trial.key_issued`, `cloud_trial.exhausted`, `cloud_trial.modal_shown`, `cloud_trial.migrated`, `cloud_trial.migration_failed`) without affecting self-hosted telemetry. **Alternatives considered** - Passing a capped OpenRouter API key directly into the agent sandbox environment: rejected because a sandboxed agent or user could read and reuse the raw key outside Paperclip. - Showing starter dollar amounts or a usage progress bar in the UI: rejected in favor of a simple prompt asking the user to connect a model provider to continue. **Roadmap alignment** Supports hosted onboarding activation experiments while staying strictly gated behind a default-off managed feature flag (`cloudDefault: false`, `selfHostedDefault: false`) so self-hosted installs and unflagged Cloud stacks see zero behavior change. **Additional context** Paired with the private Cloud control plane key-management service PR that provisions per-stack capped OpenRouter child keys and enforces single-trial caps across accounts. ## What Changed - **Shared contracts & feature flag (`packages/shared`)**: - Added `enableCloudTrialInference` (`tier: "managed"`, `cloudDefault: false`, `selfHostedDefault: false`) to `feature-catalog.ts`, `types/instance.ts`, and `validators/instance.ts`. - Added `packages/shared/src/cloud-inference.ts` with trial status types, migration schemas, provider-to-harness migration defaults, and telemetry event validation. - Added `cloud_trial.status.updated` to `LIVE_EVENT_TYPES`, `cloudTrialInference` to `agentRuntimeConfigSchema`, and optional `cloudTrialInferenceEnabled` to `browserAnalyticsConfigSchema`. - **Paperclip Runner (`packages/paperclip-runner`)**: - Updated OpenCode server driver (`opencode-server-driver.ts`) and `configured-environment.ts` to accept `PAPERCLIP_OPENROUTER_PROXY_URL` and `PAPERCLIP_OPENROUTER_PROXY_TOKEN`. - Updated `provider-failure.ts` to classify HTTP 402 as quota exhaustion and redact `sk-or-` key material. - **Server proxy, migration, and onboarding (`server/`)**: - Added `server/src/services/cloud-trial-inference.ts` and `server/src/routes/cloud-inference.ts` for server-memory key custody, ephemeral per-run proxy tokens, model guard, HTTP 402 exhaustion handling, agent migration, blocked-run resume, and company-scoped status/migrate/telemetry routes. - Wired proxy mounting in `server/src/app.ts`, runtime env & cleanup in `heartbeat.ts` / `execution-configuration.ts`, `cloud_trial_exhausted` error code in `run-completion.ts`, and starter-agent seeding in `onboarding-seed.ts`. - **PostHog A/B telemetry (`server/`, `ui/`)**: - Resolved `cloudTrialInferenceEnabled` from `PAPERCLIP_MANAGED_CONFIG` in `cloud-posthog-config.ts` and `cloud-posthog-browser.ts`. - Stamped `cloud_trial_inference_enabled` and `$feature/cloud-trial-inference` on `workspace` groups, `cloud.workspace_started`, direct server PostHog events, and browser PostHog super-properties plus `$set_once.cloud_trial_inference_cohort`. - Added Cloud-only direct PostHog helpers (`trackCloudPostHogEvent`, `trackCloudTrialExposure`) in `server/src/telemetry.ts` and wired exposure + lifecycle funnel events (no-op on self-hosted). - **UI & Storybook (`ui/`)**: - Added `ui/src/api/cloud-inference.ts`, `CloudTrialExhaustedModal.tsx`, `CloudTrialGate.tsx`, and optional `hideCancel` / `hideProviderHeading` props on `AiProviderSetup.tsx`. - Wired `CloudTrialGate` into `Layout.tsx` / `Layout.production.tsx`, live-event invalidation into `LiveUpdatesProvider.tsx`, starter onboarding card into `OnboardingWizard.tsx`, and the experimental card into `InstanceExperimentalSettings.tsx`. - Added Storybook stories in `ui/storybook/stories/onboarding/cloud-trial-exhausted-modal.stories.tsx` covering single agent, multiple agents, migrating, migration succeeded, and migration error states. ## Verification - `pnpm --filter @paperclipai/shared build`: passed. - `pnpm --filter @paperclipai/paperclip-runner build`: passed (TypeScript, protocol manifest, Cargo release build, replay golden parity). - `pnpm --filter @paperclipai/ui typecheck` & `node scripts/storybook-catalog.mjs --check`: passed (372 files, 3484 stories). - `pnpm --filter @paperclipai/server exec tsc --noEmit`: passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/cloud-trial-inference.test.ts src/__tests__/cloud-posthog-config.test.ts src/__tests__/cloud-posthog-browser.test.ts src/__tests__/posthog-direct-event-shape.test.ts src/__tests__/posthog-direct-telemetry.test.ts src/__tests__/auth-routes.test.ts`: 6 files, 144/144 passed. - `pnpm --filter @paperclipai/ui exec vitest run src/lib/analytics/product-analytics.test.ts src/lib/analytics/product-analytics-events.test.ts`: 2 files, 14/14 passed. - Verified Storybook stories interactively in the embedded browser (`ExhaustedSingleAgent`, `ExhaustedMultipleAgents`, `MigrationSucceeded`) with passing `play()` interactions and zero console errors, plus live end-to-end onboarding → exhaustion → blocking modal → provider connect → agent migration flow against a mock OpenRouter server. ## Risks - **Default-off isolation**: `enableCloudTrialInference` defaults to `false` everywhere, and Cloud stacks hide `instance.experimental.*` controls by default, so existing self-hosted and unflagged Cloud stacks have zero behavior change. - **Key custody boundary**: Raw OpenRouter keys stay strictly in server process memory; sandboxes only receive short-lived per-run proxy tokens invalidated on run exit or exhaustion. - **PostHog direct contract**: Existing self-hosted collector envelopes remain unchanged; `posthog-direct-event-shape.test.ts` and `product-analytics-events.test.ts` verify event shape and ownership invariants. - **CI coverage**: Broad workspace suites and E2E lanes were not run locally and will run on PR CI. ## Model Used - Google Gemini (Antigravity agentic assistant) with code editing, terminal execution, browser verification, and test tools. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
304854ee99 |
fix(antigravity): resolve the hosted runtime in one place and report sign-in failures plainly (#22990)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can sign in with a Google subscription. On hosted public deployments the server starts the pinned Antigravity runtime and relays the pasted loopback redirect (#22932). > - The server looked for that runtime only in the server package's vendored assets and the OS-account cache. The Docker image keeps the verified closure in the build-owned provider pack (`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH`). > - So every hosted attempt failed before the runtime started, and the page showed "Google sign-in did not complete. Start sign-in again." with no sign-in link. Every failure reason became that one message, and nothing was logged. > - #22983 added the pack lookup as an option that each caller had to pass. That leaves several search paths that can drift: installation verification still used none. > - This pull request moves the pack lookup into the one canonical resolver, gives sign-in failures a typed reason with one plain-language message each, and logs a secret-free reason code. > - The benefit is that sign-in, model discovery and installation verification always find the same verified runtime, and a server without the runtime says why. ## Linked Issues or Issue Description Refs #22932, Refs #22983 **Describe the bug** On a hosted authenticated public deployment, the user chooses Google Antigravity and then "Google Subscription". The page immediately shows "Google sign-in did not complete. Start sign-in again." `POST .../ai-connections/local/attempts` returns 201, and every `POST .../ai-connections/local/check` returns `sign_in_required` with the same message and no `authorizationUrl`. **Steps to reproduce** 1. Run the standard image as an authenticated public deployment. Do not create an Antigravity runtime cache in the server account. 2. Create an agent with Google Antigravity and choose Google Subscription. 3. See the error before any sign-in step runs. **Expected behavior** The server starts the pinned runtime from the image's provider pack and shows the Google sign-in link. If the server has no runtime, the message says so in plain language and does not tell the user to start again. **Root cause** `antigravityNativeDistributionSpec()` resolved `<server>/dist/vendor/paperclip-runner/provider-assets/antigravity/<target>` and then `$HOME/.paperclip/runtimes/antigravity/<target>/<closure>`. The image ships the closure at `$PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH/provider-assets/antigravity/linux-x64`. `startAntigravityBrowserLogin` caught every failure with a bare `catch` and showed the generic message. The #22932 tests mocked both the runtime resolution and the installation check. ## What Changed - Runner: `antigravityNativeDistributionSpec` is the one resolver for every caller. The search order is: the runner package's own assets (runnerd binds Runner children to the selected pack with `PAPERCLIP_ACPX_PROVIDER_PACKAGE_ROOT`), then the deployment provider pack from `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH`, then the OS-account cache. The pack root must be a normalized absolute path. The pack goes through the manifest and link checks of `resolveRunnerProviderAssetsRoot` from #22983. The pinned closure digest check is unchanged. - Runner: the `providerPackageRoot` option on `startAntigravityBrowserLogin`, `discoverAntigravityModels` and `antigravityNativeDistributionSpec` is removed. The server no longer reads the pack path. - Runner: sign-in failures have a typed reason (`runtime_unavailable`, `start_failed`, `login_incomplete`, `aborted`). One table maps each reason to its message. A missing runtime reports "This server does not have the current Google Antigravity runtime, so Google sign-in cannot start. Use a Google API key instead, or update Paperclip on this server." - Runner: model discovery throws `AntigravityRuntimeUnavailableError` when the runtime is missing. The server shows a plain-language message for it instead of "Could not load models for this Google account". - Server: sign-in failures, except cancelled attempts, are logged with a secret-free code such as `ANTIGRAVITY_SIGN_IN_RUNTIME_UNAVAILABLE`. A missing runtime during model discovery is logged as `ANTIGRAVITY_RUNTIME_UNAVAILABLE`. ## Verification - Red on master, green on this branch: - `antigravity-installation.test.ts`: pack resolution, precedence, cache fallback, link and path refusal, and one test that binds sign-in, model discovery and `verifyAntigravityInstallation` to the same pack with no vendored assets. - `antigravity-auth.test.ts`: one test for each failure reason and its message. - `antigravity-models.test.ts`: a missing runtime gives `AntigravityRuntimeUnavailableError` without a launch. - `pnpm --filter @paperclipai/paperclip-runner exec vitest run` on the antigravity auth, stream-order, installation, models and provider-assets-root suites: 76 of 76 pass. - `server/src/__tests__/local-ai-browser-login-google.test.ts`, `antigravity-connection-models.test.ts` and `antigravity-local-ai-login.test.ts`: 33 of 33 pass. - The runner `tsc --noEmit` and the server `tsc --noEmit` pass. - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` reports no registry change. - `pnpm verify` returned exit 2 (runner test files are outside the resolved test graphs). Required CI supplies the broad coverage. - Not run: a live Google sign-in against the real closure in a hosted image. That needs a deploy and a real Google account. ## Risks - Low risk. The pack is used only when the packaged assets are absent and the pack contains the target. A modified pack still fails the pinned closure check. - A pack root that is relative or contains `..` now fails as "runtime unavailable" instead of being ignored silently. - Error text changes only for failures before the runtime initializes. > 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> |
||
|
|
362bdc1117 |
fix(antigravity): resolve hosted login and model discovery from configured provider pack (#22983)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip supports Google Antigravity through Paperclip Runner, including server-hosted Google sign-in and account-bound model discovery. > - In Docker and hosted deployments, the server ships Antigravity's verified Linux runtime closure inside the build-owned provider pack at `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH`, not under `server/dist/vendor/paperclip-runner/`. > - Because `startAntigravityBrowserLogin` and `discoverAntigravityModels` only checked `import.meta.url` and `PAPERCLIP_ACPX_PROVIDER_PACKAGE_ROOT`, hosted Google sign-in and subscription model discovery failed immediately on container deployments. > - This pull request adds an explicit `providerPackageRoot` option to the Runner asset-root and Antigravity helpers and forwards the normalized `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` from the server without mutating `process.env`. > - The benefit is that hosted Google Antigravity sign-in and model discovery resolve the verified build-owned closure cleanly on Docker and Cloud deployments while keeping all manifest, symlink, and closure-integrity checks intact. ## Linked Issues or Issue Description Refs #22932 **What happened?** On a Docker/hosted server where `hostedGoogleAiLoginSupported` is `true` and `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH=/opt/paperclip-runner/provider-pack`, starting Google Subscription sign-in returned `HTTP 201` on `POST /ai-connections/local/attempts` and then immediately failed on `/ai-connections/local/check` with `Google sign-in did not complete. Start sign-in again.` and no OAuth URL. `discoverAntigravityModels` hit the same missing asset lookup in container deployments. **Expected behavior** Hosted Google Antigravity sign-in and account-bound model discovery resolve the verified `provider-assets/antigravity/linux-x64` closure from the server's configured `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` provider pack, return the PKCE loopback authorization URL for hosted redirect relay, and load the account's model catalog. **Steps to reproduce** 1. Run the Paperclip Docker image (`node server/dist-runtime/index.mjs`) with `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH=/opt/paperclip-runner/provider-pack`. 2. Open the Google Antigravity and Gemini connector and start a `Google Subscription` sign-in attempt. 3. Observe `/ai-connections/local/check` immediately returning `Google sign-in did not complete. Start sign-in again.` without an authorization URL. **Paperclip version or commit** `1fca3a6d8c5a2be455f1240e96ff8d12387ad688` (on `master`) **Deployment mode** Docker ## What Changed - Added an optional `RunnerProviderAssetsRootOptions` (`{ providerPackageRoot?, providerPackageManifest? }`) parameter to `resolveRunnerProviderAssetsRoot` in `packages/paperclip-runner/src/drivers/acpx/provider-assets-root.ts` so callers can pass an explicit package root without mutating `process.env`, reusing the same manifest, symlink, containment, and TOCTOU verification checks and failing closed on invalid roots. - Threaded optional `{ providerPackageRoot }` through `antigravityNativeDistributionSpec`, `startAntigravityBrowserLogin`, and `discoverAntigravityModels`. - Updated `server/src/services/local-ai-browser-login.ts` and `server/src/services/antigravity-connection-models.ts` to normalize `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` (stripping trailing slashes and rejecting non-normalized or relative paths) and pass `{ providerPackageRoot }` when configured. - Added unit tests covering explicit `providerPackageRoot` resolution for bundled server paths, fail-closed validation on invalid roots, and server forwarding in `provider-assets-root.test.ts`, `antigravity-connection-models.test.ts`, and `local-ai-browser-login-google.test.ts`. ## Verification - `pnpm --filter @paperclipai/paperclip-runner build:typescript` — passed. - `pnpm --filter @paperclipai/server typecheck` — passed. - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/acpx/provider-assets-root.test.ts src/drivers/acpx/antigravity-auth.test.ts src/drivers/acpx/antigravity-models.test.ts` — passed (52/52 tests across 3 files). - `pnpm exec vitest run server/src/__tests__/antigravity-connection-models.test.ts server/src/services/local-ai-browser-login-google.test.ts server/src/__tests__/antigravity-local-ai-login.test.ts` — passed (31/31 tests across 3 files). - `node --test packages/paperclip-runner/scripts/contracts/contract-fingerprints.test.mjs` — passed (11/11 tests). ## Risks - Low risk. When `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` is unset (ordinary local development), all call sites keep their existing single-argument behavior. When set, the path must be normalized and absolute and still passes `resolveRunnerProviderAssetsRoot`'s full `package.json` and symlink-containment checks plus `verifyNativeAcpxInstallation`'s pinned SHA-256 closure verification. No contract fingerprints or database schemas change. ## Model Used - Google Gemini (Antigravity agent with tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [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> |
||
|
|
331e1a9fd3 |
perf(ci): shard native-server and chat lanes and split >85s Vitest files (#22974)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI runs Vitest suites across five lanes: Runner native server, general chat, general server, serialized server, and Runner package tests. > - Even after pre-baked AMIs and 8-vCPU runners, single-shard `vitest native server`, 2-shard `general-chat`, and several oversized single-file Vitest specs still exceed the 85s per-shard ceiling and dominate pull request wall-clock time. > - Splitting those oversized test files and expanding AWS sharding where needed lowers the slowest Vitest shard under the sub-3-minute pull request budget while preserving every test case and keeping `ubuntu-latest` fallback fan-out compact. > - This pull request shards `vitest native server` (`1 -> 2` on AWS, `1` on hosted runners) and `general-chat` (`2 -> 3` on AWS, `1` on hosted runners), splits the remaining `>85s` single-file Vitest tails across all five lanes into focused `<1,000 LOC` sibling test files with shared harnesses, and refreshes the four Vitest timing manifests. > - The benefit is faster pull request feedback with lower tail variance across every Vitest lane and zero deleted tests. ## Linked Issues or Issue Description Refs #22916 **What existing behavior does this improve?** Pull request Vitest shard wall-clock time across `vitest native server`, `general-chat`, `general server`, `serialized server`, and `Runner vitest package`. **Current behavior** Single-shard `vitest native server`, 2-shard `general-chat`, and several monolithic test files still run above 85s on 8-vCPU AWS PR runners, holding back pull request CI completion. **Proposed behavior** Expand AWS sharding for `vitest native server` (`1 -> 2` with `release_crate: true` on both, `1` compacted shard on `ubuntu-latest`) and `general-chat` (`2 -> 3` on AWS, `1` on `ubuntu-latest`), split the remaining oversized single-file Vitest suites into focused sibling files under 1,000 LOC with shared test harnesses, and refresh the four Vitest shard duration manifests so LPT packing balances the split files immediately. **Reason and benefit** Cuts Vitest critical-path wall clock under 95s per shard while preserving 100% of test coverage, lane ownership boundaries, and compact 33-job `ubuntu-latest` fallback fan-out. **Breaking changes** None. Pure test-file refactoring and shard matrix configuration. ## What Changed - Expanded AWS sharding in `.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`, and `scripts/run-vitest-stable.mjs`: - `Verify Paperclip Runner (vitest native server)`: `1 -> 2` shards on AWS (`release_crate: true` on both), `1` shard on `ubuntu-latest` via `HOSTED_SHARD_COUNTS["ci:runner-vitest"] = 1` and `nativeServerLanePattern`. - `General tests (chat)`: `2 -> 3` shards on AWS, `1` shard on `ubuntu-latest`. - Split the remaining `>85s` single-file Vitest tails across all five lanes into focused `<1,000 LOC` sibling test files with shared harnesses (zero deleted tests, zero cross-test-file imports, anchor filenames and lane ownership preserved): - Runner package lane (`packages/paperclip-runner`): split oversized daemon/provider integration files. - Native server lane: split `native-ingress-bootstrap-retry` while keeping `native-ingress-bootstrap-retry-opencode` strictly in `native-runner`. - Chat lane: split oversized Telegram/GitHub/connection-management integration tests. - General server lane: split `tool-gateway-service.test.ts` and `attention-service` tests using shared harnesses. - Serialized server lane: split `heartbeat-dependency-scheduling` / `native-wakes` and `agent-adapter-validation` tests, keeping serialized ownership intact. - Refreshed all four Vitest shard duration manifests (`packages/paperclip-runner/scripts/vitest-lane-durations.json`, `scripts/chat-shard-durations.json`, `scripts/general-server-shard-durations.json`, `scripts/serialized-shard-durations.json`) and updated CI contract tests. ## Verification - Ran all CI contract suites after rebasing onto `origin/master`: - `node --test .github/scripts/tests/ci-plan.test.mjs scripts/ci/runner-release-crate-cache.test.mjs scripts/ci/run-vitest-stable-shard.test.mjs scripts/ci/run-vitest-stable-pr-mode.test.mjs scripts/ci/runner-vitest-package-lanes.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/e2e-shard.test.mjs scripts/ci/check-test-budget.test.mjs` - `node scripts/check-test-budget.mjs` - `node scripts/check-maps.mjs` - Verified every new test file is under 1,000 LOC, zero cross-test-file imports exist, zero files are missing from the four timing manifests, and `ubuntu-latest` remains strictly at 33 jobs. ## Risks - Low risk: pure test-file refactoring and shard matrix expansion with zero production code changes. - Reverted cleanly by a single `git revert` if any shard balance or manifest adjustment is needed. ## Model Used - Google Gemini (Antigravity / Gemini 4 Neon (High), tool use and code execution enabled). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
1c36d24d0c |
perf(ci): parallelize Runner Rust checks, Runner build, and typecheck lane (#22957)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Live 8-core PR runs (`45667106472`, `45665466678`, `45668834558`) showed two critical-path stragglers on Rust- and TypeScript-heavy PRs: > 1. `Verify Paperclip Runner (rust)` (`206s` step): ran a redundant `cargo check --workspace` (`8.1s`) before `cargo test --release`, executed all 44 compiled Rust test binaries **sequentially** (`119.2s` vs `~50s` parallel!), and then re-invoked `cargo test --release` twice more for `check:conformance-parity` and `check:replay-parity` (`~8s`). > 2. `Typecheck + Release Registry` (`100s–147s` step): ran `CLI guidance safety` (`2.9s`) and `typecheck @paperclipai/paperclip-runner` (`5.6s`) serially before `prepare:runner-vendor`, ran `packages/paperclip-runner` `build` (`17.1s` hit / `51.0s` miss) serially across 12 steps, and scheduled lighter `7–10s` test projects ahead of the 4 `17–25s` server test layers. > - This pull request parallelizes `check:runner` (`run-check-runner.mjs`), `packages/paperclip-runner` `build` (`run-build.mjs`), and `scripts/ci-typecheck-lane.mjs` cleanly across 8 cores with full process-group signal cleanup (`stopActiveChildren`), exact `CARGO_BIN_EXE_*` / `CARGO_MANIFEST_DIR` fidelity, fail-closed parity assertions, exact `record-build-inputs --begin/--finish` bracketing, and 100% check parity. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Execution wall-clock of `Verify Paperclip Runner (rust)`, `Typecheck + Release Registry`, and `Build` on 8-core runners. **Subsystem affected** packages/paperclip-runner/ and scripts/ — Rust test orchestration, Runner package build, and monorepo typecheck DAG **Current behavior** `check:runner` runs `cargo check`, 44 Rust test binaries sequentially, and 2 redundant parity re-runs; `packages/paperclip-runner` `build` executes 12 build/check steps serially; `ci-typecheck-lane.mjs` blocks `prepare:runner-vendor` behind serial `prepare` steps and under-utilizes 8-core / 32 GiB runners. **Proposed behavior** Execute `check:runner` with overlapped `acpx-profiles` / `cargo fmt --check` / `cargo test --release --no-run` followed by LPT-ordered concurrent execution of all 44 test binaries + `--doc` + fail-closed parity verification; parallelize `packages/paperclip-runner` `build` into race-free pre-dist / build / staging / post-dist phases; parallelize `CLI guidance safety` and `typecheck @paperclipai/paperclip-runner` in `ci-typecheck-lane.mjs`, LPT-order post-declaration tasks, and tune 8-core / >=24 GiB concurrency (`laneConcurrency: 8`, `serverDeclCheckers: 6`). ## What Changed - **`packages/paperclip-runner/scripts/run-check-runner.mjs` & `run-check-runner.test.mjs`:** - Overlaps `check:acpx-profiles` and `cargo fmt --all -- --check` with `cargo test --release --locked --workspace --no-run --message-format=json-render-diagnostics`. - Parses all 44 compiled test binaries with exact `CARGO_BIN_EXE_*` and per-crate `CARGO_MANIFEST_DIR`, executes them concurrently in LPT order (`codex_provider` first, `acpx_sidecar_stopped_time` isolated in its own detached process group with `--test-threads=1`, plus `cargo test --release --workspace --doc`). - Verifies both `runs_the_mock_core_path_with_stable_output` and `replay_fixture_parity` passed in the workspace run (failing closed if missing or ignored), eliminating 2 redundant `cargo test` re-invocations. - **`packages/paperclip-runner/scripts/run-build.mjs` & `run-build.test.mjs`:** - Preserves exact `record-build-inputs.mjs --begin` / `--finish` bracketing from the same parent PID, overlaps `eval-kernel + tsc`, `cargo build --release` (honoring `PAPERCLIP_RELEASE_RUNNER_ARTIFACTS_DIR`), and all 9 pure source-only pre-dist checks, stages disjoint `dist/` outputs in parallel, and runs all 5 `dist/`-importing checks (`check:runner-workflow-traceability`, `check:protocol-coverage`, `check:semantic-contracts`, `check:replay-goldens`, `check:semantic-action-catalog`) in parallel post-dist. - **`scripts/ci-typecheck-lane.mjs`, `scripts/__tests__/ci-typecheck-lane.test.mjs`, & `.github/scripts/tests/ci-plan.test.mjs`:** - Moved `CLI guidance safety` and `typecheck @paperclipai/paperclip-runner` (`needs: [PREPARE_RUNNER_VENDOR]` when `runServer`) out of serial `prepare` into `tasks`. - Ordered post-declaration tasks LPT (`tests/runner-e2e` -> 4 `server layer test-*` -> smaller projects) and tuned 8+ core / >=24 GiB runners to `laneConcurrency: 8`, `serverDeclCheckers: 6`. - **`packages/paperclip-runner/scripts/run-check-static.mjs`, `run-prep-tests.mjs`, & `package.json`:** - Shared `stopActiveChildren` / process-group runner helpers across `run-check-static.mjs`, `run-check-runner.mjs`, and `run-build.mjs`; wired `run-build.test.mjs` and `run-check-runner.test.mjs` into `PREP_TEST_FILES`. ## Verification - `node --test .github/scripts/tests/*.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/check-test-budget.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs` — **855/855 PASS** - `node --test scripts/run-check-runner.test.mjs scripts/run-build.test.mjs scripts/run-check-static.test.mjs scripts/build-inputs.test.mjs scripts/stage-runner-binary.test.mjs` (in `packages/paperclip-runner`) — **32/32 PASS** - `node scripts/check-test-budget.mjs --base origin/master` and `node scripts/check-maps.mjs` — **PASS** - Live Linux Cargo/Runner and monorepo Typecheck/Build execution verified end-to-end by PR CI. ## Risks - Low risk: all 9 pre-dist checks were verified pure source read-only while all 5 `dist/`-importing checks run strictly after `tsc` and asset staging; Rust parity checks fail closed if either test is absent or ignored; process-group cancellation ensures zero orphaned test processes. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`server-prune`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] 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 |
||
|
|
a336e295f6 |
feat(ui): turn Connectors into a Plugins marketplace (#22869)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents reach outside tools through connectors, which people add on the Connectors page > - That page is one long list. Each row mixes the catalog entry with its accounts, so it is hard to scan and hard to tell what is installed > - Some connectors also bring skills, but the page does not show them > - This pull request renames the page to Plugins and changes the browse view into a marketplace of small cards grouped by category. Each card opens a plugin page that holds the accounts, the skills and the tool permissions > - The benefit is a catalog that people can scan fast, with one place per connector for its accounts and its skills. Connector behavior does not change ## Linked Issues or Issue Description **Subsystem affected** UI: the Connectors (Apps catalog) pages under `ui/src/pages/apps/` and the navigation labels that point to them. **Problem or motivation** The Connectors browse page is a vertical list of large rows. A row shows the catalog entry and every account under it. People must expand rows to see what is connected. The page does not show which skills come with a connector. **Proposed solution** - Rename the page from Connectors to Plugins in the navigation, the breadcrumbs, and the page titles. A single app is still called a connector. - Remove the Browse / Review rail. The page header carries the title, a Review shortcut, and an Add menu for a custom MCP server, a pasted config, or an assistant connection. - Show the catalog as a marketplace under one "All" tab: "Most used" and "New and noteworthy" for first-party connectors, then one block per category. Composio and Arcade connectors sit in the same blocks. A block shows at most nine plugins, its total, and a "See all" link to a category page at `/apps/category/:categoryId`. - Use a compact card: logo, name, description, and one corner control. The control is a plus to connect, a check when connected, or a warning when an account needs attention. - Open a plugin page at `/apps/plugin/:pluginKey` from each card. The page has Connect in its header and groups Accounts, Connector, Skills, Tool permissions, and Information as blocks. Tool permissions shows a connected account's actions as Reads and Writes, each with a group policy and per-action policies. - Start sign-in straight from the card for a one-click connector: one OAuth method that Paperclip can start itself, with nothing to fill in and no warning to read. The success screen states who can use the connection and links to where that changes. - Search reads plugin titles only. - Keep the account list on the Installed filter. **Related pull requests** A search of open and closed pull requests for the Connectors browse page, a plugins or connectors marketplace, connector categories, and one-click sign-in found no duplicate. #22863 compresses connector logo files and does not overlap with these pages. **Alternatives considered** - An experimental setting that keeps the old page. The product owner chose to replace the page for everyone. - A new backend link between connectors and catalog skills. This pull request stays in the front end. The pairing for GitHub is a constant in `PluginSkills.tsx`. - Real categories for Composio apps. Its public catalog file has names only, so those apps are sorted by keywords in the name and the rest go to "Other". Arcade's catalog states a category, which is now carried through `AggregatorAppCatalogEntry.category`. ## What Changed - `Browse.tsx`: keeps all data loading, connect logic, and dialogs. The render now has five views: marketplace, category page, flat results grid, Installed list, and plugin page. The default source is `all`; the `paperclip` source is removed. - `PluginMarketplace.tsx` (new): `PluginTile`, `PluginShelf` (count and "See all"), `PluginCategories`, and the category labels. - `PluginsHeader.tsx` (new): page title, Review shortcut with the pending count, and the Add menu. - `PluginPageSections.tsx` (new): plugin page header, Connector row, and Information facts read from the app definition. - `PluginPermissions.tsx` (new): Reads and Writes blocks for a connected account. Saves go through `useConnectionPermissionSave` and restate agent access exactly as the per-connection page does. The four helpers it shares with that page moved from `AppDetail.tsx` to `app-detail/saved-permissions.ts` with no behavior change. - `PluginSkills.tsx` (new): lists built-in connector skills, skills that a connected server publishes, and paired catalog skills. "Add skill" calls the existing catalog install endpoint. - `plugin-categories.ts` (new): maps Arcade categories onto the Plugins categories and guesses a category from the name for apps that state none. - `features/connections/one-click-oauth.ts` (new): the one-click rule and the hand-over of the sign-in window from the card's click to the connect flow. A browser only opens that window during a click, so the card opens it and `ConnectionSetupFlow` takes it over. If the window is blocked, or the page is reloaded, the ordinary confirmation screen shows. - `ConnectionSetupFlow.tsx`: takes the handed-over window, starts sign-in when the app qualifies, and adds a "Change" link beside the stated default on the success screen. - `apps-rail.ts` (new), `AppsSidebar*.tsx`, `Layout*.tsx`: the marketplace pages have no second rail. Chat setup and detail keep theirs, and the developer pages keep one while a developer tab is on. - `ConnectorCard`: new `variant="page"` that renders the accounts as one block with "Add account" at the bottom. - `ConnectorsToolbar.tsx`: source filters first, a wider "Search plugins" field on the right. - `App.tsx`, `Layout.tsx`, `Layout.production.tsx`: new `apps/plugin/:pluginKey` and `apps/category/:categoryId` routes and reserved subpaths. - Navigation and breadcrumb labels: "Connectors" becomes "Plugins" in 19 files, and the instance plugin system becomes "System plugins". - `packages/shared/src/aggregator-app-catalog.ts`: optional `category` on a catalog entry, set from Arcade's catalog. - `ui/storybook/prototypes/ConnectorCatalogNavigation.tsx`: keeps its own five-source list so the older prototype still builds. - Tests: label renames in the specs and stories that named Connectors or "Search connectors". Seven specs now reach the custom-server setup through the Add menu. New specs: `one-click-connect`, `plugins-browse`. `apps-prosumer-mcp-flow` also covers the plugin page permissions and the success-screen link. Kept on purpose, so current flows and specs continue to work: the `Connector list` list label, `data-app-slug` and `data-connected` on each card, and the `<Verb> <App name>` button names. ## Verification - `cd ui && pnpm typecheck`: pass. - `pnpm run check:token-gates`: pass. - `cd ui && npx vitest run`: 564 files, 7,059 tests pass, 1 skipped. - `cd packages/shared && npx vitest run src/aggregator-app-catalog.test.ts`: 9 tests pass. - `PAPERCLIP_RUNNER_BINARY=/usr/bin/true npx playwright test --config tests/e2e/playwright.config.ts` for the 15 spec files under `tests/e2e/*.spec.ts` that touch the Plugins pages, plus `one-click-connect` and `plugins-browse`: all pass (3 skipped by their own conditions). - Storybook: built this branch and master and ran the interaction tests of the 253 stories in the files that mount the browse page. Master passes 230; this branch passes the same 230. The 23 that fail do so on master too. - Manual: opened Plugins, a category page, a plugin page, the Installed filter, and Review on a local instance. - Not run locally: `execution-recovery/recovery.spec.ts`, `in-feed-native/connections.spec.ts`, the runner e2e tests, and the repo-wide typecheck (it needs the Rust toolchain). A real provider sign-in was not completed; the one-click test stops at the point the flow starts. `pnpm verify` exits 2 and names CI as the source of broad coverage. ## Risks - The page changes for every user. People who know the old list must learn the new layout. The Installed filter keeps the old account list. - The instance plugin system is renamed "System plugins" in the settings navigation, breadcrumbs, and its management page, so the two areas no longer share a name. URLs and lower-case mentions of "plugin" inside sentences are unchanged. - One-click connect skips the screen that states the access default ("Connects for everyone in your organization, available to all agents") and offers Change. The default is applied without being shown first; the success screen states it and links to the permissions page. - Most Composio apps (about 1,100 of 1,583) land in "Other", and the keyword guess is sometimes wrong. Correct categories need category data in the catalog file. - The plugin page can now save action permissions. It uses the same save path and access derivation as the per-connection page and waits for all four reads before it enables the controls. The account picker for several accounts and the read-only view have no test. - The Smoke Lab developer page has no link from the browse page; it is reachable by URL. - e2e specs that this pull request did not run locally can fail on selectors. CI must confirm them. - "New and noteworthy" is a fixed list in code. The catalog has no date to sort by. - Skill pairing is a front-end constant. Nothing records that a skill came from a connector, so removing a connector does not remove the skill. - The per-connection permissions page is not restyled in this pull request. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Fable 5.2 (`claude-fable-5-2`) through Claude Code, with tool use, code execution, and subagents for read-only code search. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
1fca3a6d8c |
fix(github): silence anonymous sandbox launchers and auto-request GitHub connection on unconfigured git auth failures (#22954)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Sandboxed runs wrap `git` and `gh` with broker launchers so agents do not inherit ambient host credentials, and task feeds use `connection_intent` cards to let users connect services inline. > - When a workspace has no GitHub connection configured, anonymous sandbox launchers logged `Paperclip: GitHub capability_missing; continuing without managed credentials.` on every `git` or `gh` call, and failed local `gh --version`/`--help` commands. > - In addition, when an agent tried to clone a private GitHub repository, push to GitHub, or run `gh` without a GitHub connection configured, the task feed did not prompt the user with a GitHub connection card. > - Both issues hurt first-run clarity: noisy `capability_missing` warnings look like broken infrastructure, while unconfigured git auth failures leave users without an inline path to connect GitHub. > - This pull request marks intentional anonymous sandbox launchers silent, treats local `gh` version/help commands as local, and automatically attaches a `github` `connection_intent` card in the task feed when a run hits an unambiguous unconfigured GitHub auth failure. > - The benefit is clean anonymous git/gh execution and a one-click inline GitHub setup card when a task needs private GitHub access. ## Linked Issues or Issue Description **What happened?** In sandboxes without a GitHub connection configured, running `git` (such as `git --version` or public clones) logged `Paperclip: GitHub capability_missing; continuing without managed credentials.` and `gh --version` / `gh --help` attempted broker resolution. When an agent tried an authenticated GitHub operation (such as cloning a private repository, pushing, or running `gh`), the run failed or reported the auth error without showing a GitHub connection card in the task feed. **Expected behavior** Anonymous unconfigured sandbox launchers should run public/local `git` and local `gh` commands silently without emitting `capability_missing` warnings, while keeping `capability_missing` diagnostics for genuinely missing or failed-bridge broker configs. When an agent hits an unconfigured GitHub authentication failure during a task run or workspace clone, Paperclip should attach a `github` connection card in the task feed and mark run liveness as blocked waiting for the user. **Steps to reproduce** 1. Run an agent in a sandbox with no GitHub connection configured. 2. Execute `git --version`, `gh --version`, and `git clone https://github.com/<org>/<private-repo>.git`. 3. Observe `Paperclip: GitHub capability_missing; continuing without managed credentials.` on stdout/stderr and no GitHub connection card in the task feed after the private clone fails. **Paperclip version or commit** `a0d5f275af` (`master`) **Deployment mode** Other (sandboxed Paperclip Runner and local server) ## What Changed - Added explicit `anonymous` mode to GitHub broker launchers (`packages/adapter-utils/src/github-launcher.ts`, `packages/adapter-utils/src/execution-target.ts`, `server/src/services/heartbeat-github-launchers.ts`) and supported `"anonymous": true` in `broker.json` so intentionally unconfigured sandboxes stay quiet while missing/broken broker bridges still emit `capability_missing`. - Treated local `gh` commands (`--version`, `--help`, `-h`, `version`, `help`) as local in the `gh` launcher without contacting the credential broker. - Added `server/src/services/git-auth-connection-detection.ts` to detect unambiguous `github.com` auth failures in failed command execution events (`tool.execution.completed` and `item.completed`) and structured workspace clone failures while ignoring `exitCode === 0`, assistant prose, non-GitHub remotes, transient 5xx errors, and local non-auth git errors. - Added controller-only `connectionIntentService(db).requestForRunGitHubAuthFailure(runId, resultJsonOverride?)` in `server/src/services/connection-intents.ts` (with `completed_git_auth` run-context mode) to create a `github` `connection_intent` card in the task feed when GitHub is not already configured/usable, skipping `host` auth mode, closed tasks, non-latest runs, existing pending cards, and declined continuations. - Wired `requestForRunGitHubAuthFailure` into `classifyAndPersistRunLiveness` (`server/src/services/heartbeat/run-lifecycle.ts`) and added `githubConnectionRequested` support to `classifyRunLiveness` (`server/src/services/run-liveness.ts`) to classify the run as `blocked` (`Waiting for GitHub connection`). - Added unit and embedded-Postgres integration tests in `packages/adapter-utils/src/github-launcher.test.ts`, `server/src/services/heartbeat-github-launchers.test.ts`, and `server/src/__tests__/github-connection-auto-request.test.ts`. ## Verification - `pnpm vitest run packages/adapter-utils/src/github-launcher.test.ts` (41/41 passed) - `pnpm vitest run packages/adapter-utils/src/github-launcher-environment.test.ts --testTimeout=15000` (40 passed, 1 skipped) - `pnpm vitest run server/src/services/heartbeat-github-launchers.test.ts server/src/services/native-runtime/native-github-access.test.ts` (passed) - `pnpm vitest run server/src/__tests__/github-connection-auto-request.test.ts server/src/__tests__/connection-intents-service.test.ts server/src/__tests__/ai-auth-failure.test.ts server/src/services/heartbeat/run-comment-selection.test.ts` (86/86 passed) - `pnpm vitest run server/src/__tests__/run-liveness.test.ts` (21/21 passed) - `pnpm vitest run server/src/__tests__/heartbeat-process-recovery.test.ts -t "clone|connection|GitHub"` (6/6 passed) - `pnpm --filter @paperclipai/adapter-utils typecheck && pnpm --filter @paperclipai/server typecheck` (0 errors) ## Risks - Low risk. No database migrations or UI schema changes are required; the auto-created card reuses the existing `connection_intent` interaction kind (`serviceSlug: "github"`). - False-positive card creation is guarded by strict `github.com` host matching, non-zero command exit requirements, `githubAuthenticationMode !== "host"`, active-identity checks (`usableConnectionForAgent` and `resolveManagedGitHubIdentitySelection`), idempotent pending-card checks, and decline respect. ## Model Used - Google Gemini (Antigravity agent) with tool use and local code/test execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
2538dce415 |
Split heartbeat-process-recovery.test.ts into 4 balanced serialized suites (#22955)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Release and master verification run serialized server integration suites across sharded CI jobs (`release-verify.yml`) > - `server/src/__tests__/heartbeat-process-recovery.test.ts` (17,926 lines, 466 expanded tests) takes ~6m 28s in a single file, so Vitest cannot shard it across runners even with 9 serialized shards (#22946) > - Because one file sets a hard floor on the serialized verification lane, release readiness stays slower than necessary after every merge > - This pull request moves the shared suite body into `server/src/__tests__/heartbeat-process-recovery.helper.ts` with four disjoint `part` slices and adds four thin test entrypoints (`heartbeat-process-recovery-part-{1..4}.test.ts`) > - The benefit is balanced shard distribution across serialized runners, cutting the single-file serialized ceiling by ~4.5 minutes while keeping all 466 test cases intact ## Linked Issues or Issue Description Refs #22946 **Area** CI / Test Infrastructure **Current Behavior** `server/src/__tests__/heartbeat-process-recovery.test.ts` runs as a single 17,926-line Vitest file (~344s recorded, ~388s in recent release runs), bounding `Serialized tests` even across 9 shards. **Proposed Improvement** Partition the suite into four thin entrypoint files (`heartbeat-process-recovery-part-{1..4}.test.ts`) backed by a shared `heartbeat-process-recovery.helper.ts`, with measured proportional shard weights in `scripts/serialized-shard-durations.json` and `scripts/ci/nightly-only-suites.json`. **Motivation / Use Case** Shorten master and release verification wall-clock latency without dropping or weakening any recovery test coverage. ## What Changed - Renamed `server/src/__tests__/heartbeat-process-recovery.test.ts` to `server/src/__tests__/heartbeat-process-recovery.helper.ts` exporting `registerHeartbeatProcessRecoverySuite(part: 1 | 2 | 3 | 4)`, hoisting `withTempPaperclipHome` to shared scope, making `beforeAll`'s `authUsers` seed `.onConflictDoNothing()` for shared `PAPERCLIP_TEST_DATABASE_URL` safety, routing dynamic `run-dispatch` imports through `../modules/run-dispatch/index.js`, and updating the two stack-trace file-name assertions to `.helper.ts`. - Added four 3-line entrypoints: `server/src/__tests__/heartbeat-process-recovery-part-{1,2,3,4}.test.ts`. - Updated `scripts/run-vitest-stable.mjs`, `scripts/serialized-shard-durations.json`, and `scripts/ci/nightly-only-suites.json` with the four part paths and measured proportional shard weights (`88511`, `102168`, `72141`, `81197` ms; sum `344017` ms). - Updated `.github/workflows/runner-chaos-evals.yml` (with `--no-file-parallelism` to preserve serial execution in that job), `maps/feature-map/recovery.md`, `packages/paperclip-runner/spec/evals/stress-workflow-traceability.json`, and `scripts/ci/test-selection.integration.test.mjs`. ## Verification - Executed all four split suites locally via Vitest against embedded Postgres — **466/466 tests passed** (0 failed, 0 skipped): - `heartbeat-process-recovery-part-1.test.ts`: 116/116 passed (199.67s under 4-way local contention) - `heartbeat-process-recovery-part-2.test.ts`: 103/103 passed (230.48s) - `heartbeat-process-recovery-part-3.test.ts`: 87/87 passed (162.74s) - `heartbeat-process-recovery-part-4.test.ts`: 160/160 passed (183.17s) - Verified brace-depth exhaustiveness across `heartbeat-process-recovery.helper.ts`: 0 top-level `it`/`it.each`/`describe` blocks outside `if (part === N)` guards. - `node scripts/check-module-boundaries.mjs` — passed. - `node scripts/check-maps.mjs` — passed. - `node scripts/check-test-budget.mjs --base origin/master` — passed. - `node --test scripts/check-test-budget.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/ci/test-selection.integration.test.mjs` — passed. ## Risks - Low risk: test-only partition; zero production runtime files changed. - Adding a future test to `heartbeat-process-recovery.helper.ts` outside an `if (part === N)` guard would not register in any part; documented the placement rule directly on `registerHeartbeatProcessRecoverySuite`. ## Model Used - Google Gemini (Antigravity agent with tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
9f570837cb |
perf(runner): commit each provider batch with one durable save (#22829)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - `paperclip-runnerd` delivers provider output to the controller through a durable outbox in `runner-state.json` > - Each save rewrites the whole state, then syncs the file and its directory > - runnerd saved once for every provider event in a poll, so a burst of k events paid k saves before any of them could leave > - #20217 made the provider state save once per poll. runnerd's own outbox still saved once per event > - This pull request commits each polled batch with one save > - The benefit is fewer syncs and full-state rewrites whenever events arrive together, on every disk, with no change to what recovery can replay ## Linked Issues or Issue Description Refs #20217 (the same change for the provider state file) Related: #17514 (closed; the same per-event rewrite on the controller side) **What existing behavior does this improve?** runnerd's commit of provider events into its durable outbox. **Subsystem affected** Paperclip Runner (`packages/paperclip-runner/runner/crates/runner-core/src/durable`). **Current behavior** `commit_executor_events` saves the full durable state once for each new event in a poll. A poll that returns k events costs k saves before the provider can release them. Each save writes the full state and calls `fsync` twice. **Proposed behavior** runnerd adds a polled batch (up to 128 events) to the outbox in memory. Then it saves once, and then it acknowledges the batch to the provider. A poll that returns k events costs one save. **Reason and benefit** Every save is a full rewrite and two syncs, so the save count sets the cost of durable delivery. On a local macOS APFS disk, one save takes about 10 ms. With 8 events per round, the cost drops from about 10.7 ms to about 2.4 ms per event. The change helps on any storage. It does not change what recovery can replay. **Breaking changes** None. The state file format does not change. Older and newer Runners read the same file. ## What Changed - `commit_executor_events` (group commit): - It adds each polled batch to the outbox and saves once. Only then does it acknowledge the batch to the provider. - The batch stays at 128 events, below the 256-receipt window. A crash between the save and the provider acknowledgement still replays every retained event exactly. - If an event is rejected (oversized, or over capacity), runnerd still saves and acknowledges the events before it. The provider keeps the rejected event and everything after it, as before. - If the save fails, runnerd acknowledges nothing. The provider keeps the whole batch. - Cumulative ACK persistence does not change. runnerd saves when an ACK empties the outbox, and after every 16 advances. - `DurableStateStore` counts saves in test builds only. - `DURABLE_TRANSPORT.md` describes the batch commit. An earlier revision of this pull request also let an outbox-emptying ACK wait for the next save. It was removed. Recovery treats an empty outbox on disk as fully delivered. `runnerd-acpx-source-reconciliation.test.ts` showed that a Runner stopped shortly after a completed run then started its provider once more on recovery. ## Verification - `cargo test -p paperclip-runner-core --lib durable::`: 136 pass, including 2 new tests in `src/durable/tests/batched_saves.rs`: - `provider_batch_commits_with_one_durable_save`: batches of 8 and 48 events each need one save. The reloaded file holds every event. - `a_streamed_round_saves_its_batch_once_and_its_emptying_ack_once`: 10 rounds of 1 or 8 events need 20 saves either way. The reloaded file has an empty outbox. - Existing tests that cover the accepted prefix, a failed save, backpressure, and receipts pass unchanged: - `event_batch_acknowledges_only_bounded_durable_prefixes` - `event_batch_never_acknowledges_a_failed_durable_save` - `disconnected_ingestion_keeps_durable_prefix_and_resumes_after_backpressure_ack` - `receipt_survives_outbox_ack_and_prevents_duplicate_delivery` - `cargo test -p paperclip-runner-core --test durable_recovery --test acpx_park_preparation --test acpx_park_readiness --test acpx_provider_suspend --test acpx_warm_attachment`: all pass. - With a freshly built runnerd: `vitest run src/live/runnerd-acpx-source-reconciliation.test.ts` (17 pass) and `vitest run src/live/runnerd-codex-transport.test.ts -t "replaces an owned v1 runner with fresh v2 authorization"` (pass). - `cargo fmt --all -- --check`: clean. - Local measurement: a release build on macOS APFS, 200 events of `item.delta`, not committed. | Events per round | Saves before | Saves after | Time before | Time after | | --- | --- | --- | --- | --- | | 1 | 400 | 400 | 3.9 s | 3.8 s | | 8 | 225 | 50 | 2.1 s | 0.49 s | ## Risks - Low risk. The file holds the same data after each batch as before. Only the number of intermediate saves changes. - A failed save inside a batch leaves the in-memory state ahead of the file, as a failed per-event save did before. The error stops the loop, as before. - The provider state file (ACPX, Codex and others) keeps its own save policy. This change touches only runnerd's state file. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, through Claude Code with tool use (shell, file editing, test execution). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0175300a48 |
perf(runner): save ACPX provider state once per poll instead of once per output (#22840)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - ACPX chat turns (Claude, Codex, and the other ACP agents) run through runnerd. runnerd reads the ACPX sidecar output in order and keeps the run's provider state in a durable file > - For each sidecar output that it read, runnerd rewrote the full provider state file. Each save did a JSON rewrite, a file `fsync`, a rename, and a directory `fsync` > - runnerd reads the sidecar again only after the controller acknowledges the events that it sent. Streamed text collects in the sidecar pipe during that round trip, so one poll usually reads several outputs > - #20217 made the Codex provider save once per poll. ACPX still saved once per output > - This pull request makes the ACPX executor save the outputs of one poll once, before anything that depends on them leaves the executor > - The benefit is fewer full state rewrites and `fsync` pairs during a streamed turn, on any disk. In a replay of a real Claude stream, runnerd made 49% fewer ACPX state saves ## Linked Issues or Issue Description Refs #20217 (the same change for the Codex provider) Related: #22829 (the same change for runnerd's own state file) Related: #16817 (a broader change. It also merges text deltas into fewer events, changes the sidecar contract, and records expired tool results. This pull request changes only when the ACPX executor saves, and does not change the event stream or the contract.) **What existing behavior does this improve?** The number of durable ACPX provider state saves during a streamed turn. **Subsystem affected** Runner (`paperclip-runner-core`, ACPX provider backend). **Current behavior** `poll_provider_events` calls `save_state` after each sidecar output that returns events. One ACP update, for example one streamed text chunk, becomes one sidecar output. Each save rewrites the full `acpx-provider-state.json` file and does two `fsync` calls. **Proposed behavior** The executor keeps the effects of ordinary outputs in memory and saves them once at the end of the poll. Outputs that drive an effect outside the stream save at once, as before. **Reason and benefit** The save count during a streamed turn no longer grows with the number of chunks in a poll. This removes disk writes and `fsync` calls on every platform. **Breaking changes** None. The state file format does not change. ## What Changed - The ACPX executor marks state as unsaved after an ordinary sidecar output. It saves once when the poll ends, also when the poll stops with an error. A poll returns events only after that save, so no event, command result, or reply to the sidecar leaves before the state that it depends on is on disk. - Each unsaved output still applies the state transition that a save applies (`leave_finished_provider_turn_wait`). The order of the events does not change. - These outputs still save at once: a turn terminal, a tool call, a lost provider turn, and a provider transport failure. The goal read at a terminal keeps its own save. - The session holds a tool rejection that it sends to the sidecar inside `poll_output` (the "too many tool calls in flight" case). The executor saves the outputs read before the rejection, then sends it. - The event acknowledgement (`acknowledge_events`) still saves at once. Recovery reads an empty queue on disk as fully delivered, so that save must not wait. - The transport-failure handling moves into one helper, `fail_polled_provider`. The poll loop and the held-rejection path both use it. - `runner/DURABLE_TRANSPORT.md` now describes when the ACPX executor saves. ## Verification Measurement (macOS, APFS, debug runnerd). I recorded the arrival times of one real Claude ACP turn from `claude-agent-acp` (323 updates in 15.4 s, median gap 33 ms). A temporary build of the fake sidecar replayed that timing in `runnerd-acpx-source-reconciliation.test.ts` ("claude" case, two turns). That test runs a real runnerd against the in-process controller. Temporary counters in the backend recorded the outputs per poll and each state save. These counters are not in this pull request. | | Polls with output | Outputs per poll (mean) | ACPX state saves | Time in saves | | --- | --- | --- | --- | --- | | Before | 84 | 7.7 | 749 | 8.1 s | | After | 182 | 3.6 | 379 | 4.3 s | - One save took about 10 ms (median) in both runs. - Before the change, 642 of 650 outputs came in polls with more than one output. - After the change, the remaining saves are about one per poll plus one per acknowledgement. Polls come more often because each cycle spends less time in saves. Tests: - New lib tests in `src/tests/acpx_poll_state_saves.rs`: - 48 outputs in one poll need one state write. The file on disk then equals the state in memory. - Polled outputs survive a restart once: a new executor retains exactly the unacknowledged suffix, with no duplicate event ids. - An output that ends the turn, or calls a tool, is saved at once. - The sidecar receives a held tool rejection only after the outputs read before it are on disk. - With the old per-output save restored, the tests fail with 48, 26, and 21 writes. Without the hold, the rejection test fails. - `cargo test -p paperclip-runner-core --lib acpx` (122 passed) and `--lib durable` (162 passed). - `cargo test -p paperclip-runner-core --test acpx_park_preparation --test acpx_park_readiness --test acpx_warm_attachment --test durable_recovery` (47, 8, 7, 4 passed). - `cargo test -p paperclip-runner-core --test acpx_provider_session --test acpx_provider_turns --test acpx_quiet_turn_continuation --test acpx_provider_resolutions` (13, 31, 14, 12 passed). - With a freshly built runnerd: `vitest run src/live/runnerd-acpx-source-reconciliation.test.ts` (17 passed). - `cargo fmt --check` is clean. `cargo clippy` shows no new warnings in the changed files. - I did not run `pnpm verify` or the full Rust suite locally. CI supplies that coverage. ## Risks - Crash window: if runnerd stops before the end-of-poll save, it loses the unsaved outputs of that poll. Nothing derived from them has left the executor, so recovery is the same as a stop before runnerd read them. Turn terminals, tool calls, lost provider turns, and failures keep their immediate save. - The executor adds no save to `retained_events`, `execute`, `host_park_ready`, or `prepare_for_park`. Unsaved state does not outlive one poll call. If the end-of-poll save fails, the existing persistence latch blocks all later work. - A held tool rejection reaches the sidecar after one more state save. Its order relative to other sidecar requests does not change. - Low risk overall. The state file format and the acknowledgement path do not change. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, through Claude Code with tool use (shell, file edits, local builds and tests). ## 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> |
||
|
|
c5107f12fe |
feat(runner): flip Google Antigravity ACPX profile to qualified (#22939)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip Runner executes native ACPX providers using release-verified profiles, capability declarations, and provider packs > - Google Antigravity is wired across Runner, server routes, UI pickers, and remote provider packs, but its ACPX profile remained `qualificationStatus: "pending"` behind operator candidate grants > - The owner waived the paid-key `runner-e2e-paid` gate on 2026-11-25 so Google Antigravity can ship to staging and be tested there live > - This pull request flips the Google Antigravity ACPX profile from `pending` to `qualified` (profile revision 2), updates its capability declaration while keeping `recovery: "unverified"`, enables ordinary server/UI/pack admission without candidate grants, and updates tests and qualification docs honestly > - The benefit is that Google Antigravity enters the default `linux-x64` remote provider pack and ordinary board setup/execution flows on staging, while candidate-era v1 saved sessions are cleanly rejected and unverified recovery/paid-key evidence remains honestly labeled ## Linked Issues or Issue Description Refs #22923 Refs #22935 (merge after #22935 `fix/per-turn-harness-on-warm-environment`) **What existing behavior does this improve?** Google Antigravity native ACPX profile qualification, remote provider-pack assembly, and Paperclip Runner agent setup/admission across `packages/paperclip-runner`, `packages/adapter-utils`, `packages/adapters/codex-local`, `server`, `ui`, and `tests/runner-e2e`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** `packages/paperclip-runner/acpx-profiles.json` declares `antigravity` at `agentProfileVersion: 1` with `qualificationStatus: "pending"`. `PAPERCLIP_RUNNER_ACPX_PROFILES` marks `antigravity.qualified = false`, remote `linux-x64` provider packs exclude Antigravity unless built with `--candidate-providers=antigravity`, and server/Runner admission requires a short-lived operator candidate grant. **Proposed behavior** Remove `qualificationStatus: "pending"` from `antigravity` and bump `agentProfileVersion` from `1` to `2` so candidate-era v1 saved state is refused permanently as `provider_state_incompatible`. Flip `PAPERCLIP_RUNNER_ACPX_PROFILES.antigravity.qualified` to `true`, mark `ACPX_CAPABILITY_PROFILES.antigravity` as `qualified` with `models: "explicit-provider-verified"` while keeping `recovery: "unverified"`, require an explicit provider model in config builders and server validation, and admit qualified Antigravity through the ordinary ACPX path without candidate grants. **Reason and benefit** Unblocks staging deployment and live testing of Google Antigravity under the 2026-11-25 owner waiver of `runner-e2e-paid`, including default `linux-x64` provider pack inclusion (local `darwin-arm64` continues to use `paperclipai runtime setup antigravity`). **Breaking changes** Any candidate-era v1 Google Antigravity saved session state is intentionally refused as `provider_state_incompatible` due to the `agentProfileVersion` bump (`1` -> `2`). ## What Changed - **Runner profile & generated contracts**: - `packages/paperclip-runner/acpx-profiles.json`: removed `qualificationStatus: "pending"` on `antigravity` and bumped `agentProfileVersion` from `1` to `2`. - Regenerated `packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts` and `packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs` (`qualification_pending: false`). - `packages/paperclip-runner/src/drivers/acpx/capability-profiles.ts`: set `antigravity.qualification` to `"qualified"` and `models` to `"explicit-provider-verified"` when released; kept `recovery: "unverified"` (never claiming `session-load` without live proof). - **Adapter utils & config builder**: - `packages/adapter-utils/src/paperclip-runner-permissions.ts`: flipped `PAPERCLIP_RUNNER_ACPX_PROFILES.antigravity.qualified` to `true`. - `packages/adapters/codex-local/src/ui/build-config.ts`: added `"antigravity"` to the explicit-provider-model validation check. - **Server admission & routes**: - `server/src/services/native-runtime/provider-profile.ts`: added `antigravity: null` to `DEFAULT_ACPX_RUNNER_MODELS`, included `antigravity` in explicit-model-required and qualified ACPX checks. - `server/src/services/native-runtime/acpx-qualification.ts`: short-circuited `resolveAntigravityCandidateAdmission` to return `undefined` once `qualificationStatus !== "pending"`. - `server/src/routes/agents.ts`: allowed qualified `antigravity` without `experimental.enableNativeRunner` (matching Copilot and UI rules), preserved empty model on provisional setup draft transitions, and allowed `setupOnly` draft creation before model selection. - **Tests**: - Updated Runner TS/Rust tests (`profile-compatibility.test.ts`, `candidate-provider-pack.test.mjs`, `release-provider-pack.test.mjs`, `antigravity-provider-pack-smoke.test.mjs`, `candidate-admission*.test.ts`, `antigravity-models.test.ts`, `acpx-runtime-sidecar.test.ts`, `runner-core` Rust unit/integration tests). - Updated `@paperclipai/adapter-utils`, `@paperclipai/adapter-codex-local`, `@paperclipai/server`, `@paperclipai/ui`, and `tests/runner-e2e` (`catalog.test.ts`, `controller-rolling-deployment.test.ts`) tests for qualified Antigravity behavior. - **Documentation & maps**: - `doc/plans/2026-11-22-antigravity-qualification.md`, `doc/plans/2026-11-25-antigravity-cloud-rollout.md`, and `packages/paperclip-runner/README.md`: recorded the 2026-11-25 owner waiver of `runner-e2e-paid` for staging verification while keeping all `NOT RUN` paid-key rows honestly marked `NOT RUN` / deferred. - Minimal in-place accuracy updates in `maps/feature-map/instance-operations.md` and `maps/agent-access-map/instance-operations.md` (`node scripts/check-maps.mjs` passing). ## Verification - `pnpm --filter @paperclipai/paperclip-runner build` (TS + Rust release binary + `check:acpx-profiles`, `generate-antigravity-models --check`, `check:protocol-types`, capability/attestation/traceability/replay-golden checks) — passed. - `pnpm --filter @paperclipai/paperclip-runner test:typescript:prep` (468 tests) and focused Runner Vitest suites (`acpx-runtime-sidecar.test.ts` 127/127, `antigravity-models.test.ts` 22/22, `candidate-admission*.test.ts`, `profile-compatibility.test.ts`, `runnerd-codex-transport-antigravity-release.test.ts`, pack script tests) — passed. - Rust tests in `packages/paperclip-runner/runner`: `cargo fmt --all -- --check`, `paperclip_process_table` (3/3), `paperclip_runner_core --lib` (670/670, skipping macOS-incompatible `task_memory::tests::monitor_*`), `paperclip-runnerd` bin tests (11/11), and `acpx_provider_resolutions` (12/12) — passed. - `packages/adapter-utils` (`paperclip-runner-permissions.test.ts` 50/50) and `packages/adapters/codex-local` (`build-config.test.ts` 64/64) — passed. - `scripts/__tests__/prepare-runner-release-image.test.mjs`, `node scripts/check-maps.mjs`, and `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` — passed. - Server suites: `adapter-routes.test.ts` (36/36), `registry.test.ts` (67/67), `agent-adapter-validation-routes.test.ts` (`Antigravity|YAML`), `antigravity-connection-probe.test.ts`, `antigravity-save-refusal.test.ts`, `antigravity-release.test.ts` (10/10), `acpx-qualification.test.ts` (39/39), `antigravity-candidate-admission.test.ts`, `remote-provider-pack.test.ts` (60/60), `native-session-executor.test.ts` (`Antigravity|provider pack`), `plugin-runner-credentials.test.ts`, `plugin-runner-credential-names.test.ts`, `antigravity-plugin-task-credential-writeback.test.ts` — passed. - CLI (`runtime.test.ts`, `runtime-setup.test.ts` 15/15), UI (6 Antigravity/setup suites 58/58 + `AgentConfigForm.render.test.tsx`), and `tests/runner-e2e` (`catalog.test.ts`, `controller-rolling-deployment.test.ts`, `antigravity-qualification.test.ts`, `eval-gateway-drain.test.ts`, and 690+ unit files) — passed. - Typechecks: `@paperclipai/adapter-utils`, `@paperclipai/adapter-codex-local`, `@paperclipai/paperclip-runner`, `@paperclipai/server` (all 7 layers), `@paperclipai/ui`, and `pnpm test:e2e:runner:typecheck` — all passed. - **Not run locally**: Live paid-key `runner-e2e` suites (`antigravity-qualification`, `antigravity-model-lineup`, `antigravity-agent-journey`) were waived by the owner on 2026-11-25 to enable staging testing and remain marked `NOT RUN` / deferred in the qualification docs. Rust `task_memory::tests::monitor_*` cgroup tests require Linux CI. ## Risks - **Merge sequencing**: Merge after #22935 (`fix/per-turn-harness-on-warm-environment`) so warm environments keep Antigravity on its per-turn lifecycle. - **Deferred live qualification**: Paid-key `antigravity-qualification` cells have not run in CI; `ACPX_CAPABILITY_PROFILES.antigravity.recovery` remains `"unverified"` until live multi-turn and restart continuity are verified on staging. - **Profile version reset**: Bumping `agentProfileVersion` from `1` to `2` intentionally rejects any candidate-era v1 saved sessions as `provider_state_incompatible`; new runs start a clean replacement conversation in the same workspace. - **Remote provider pack targets**: Remote provider packs intentionally target `linux-x64` (Core Docker images and Linux sandboxes); local `darwin-arm64` hosts continue to provision via `paperclipai runtime setup antigravity`. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Google Gemini (Antigravity agent with 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 --------- Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
1bea1eeaed |
fix(ai-connections): delete the saved Google Antigravity sign-in on disconnect (#22931)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - AI connections let a company sign in to a model provider, and Google Antigravity uses a Google account sign-in with a long-lived refresh token > - When a user disconnected that account, or removed its connection, Paperclip marked the grant revoked but kept the saved sign-in in its database > - The obvious fix, revoking the token at Google, is unsafe here: the sign-in uses the OAuth client of Google's own Antigravity runtime, and Google revocation removes the grant for that whole client > - A revoke would sign the person out of their own Antigravity app or CLI and out of every other Paperclip connection for that Google account > - This pull request deletes Paperclip's saved sign-in on disconnect and removal, does not call Google, and says plainly that the sign-in stays valid at Google until the person removes it there > - The benefit is that "disconnect" does what the person expects in Paperclip, never breaks their other tools, and never leaves a usable token behind in Paperclip ## Linked Issues or Issue Description No issue exists. This follows the feature request template. **Subsystem affected** AI connections: Google Antigravity subscription sign-in, its disconnect and connection removal paths, the connection removal transaction, and the disconnect messages in the UI and activity log. **Problem or motivation** Disconnecting a Google Antigravity subscription account marked the connection grant revoked in Paperclip only. The saved sign-in (an encrypted company secret that holds the refresh token) was not deleted. Connection removal kept it too, because removal only deletes secrets in the app-owned key namespace. Separately, connection removal revoked the grants and then released usage-limit holds in two separate writes, so a failure between them left the grants revoked while held work kept waiting. **Proposed solution** On disconnect or removal, delete Paperclip's saved sign-in and record the result in plain words. Do not call Google's token revocation. Keep a saved sign-in that another grant or target still uses. If the delete fails, keep the reference and let the next disconnect retry. Never delete a sign-in that a reconnect saved in the meantime. Commit the grant revocation and the hold release in one transaction, as the single-grant revoke already does. **Alternatives considered** Revoking the refresh token at `https://oauth2.googleapis.com/revoke` (the first revision of this pull request). The saved credential always uses client `1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com` (`sanitizeAntigravityCredential` rejects any other), which belongs to Google's own Antigravity runtime that Paperclip runs for sign-in. Google's OAuth guide for installed apps ("Token revocation") says revocation "removes all OAuth 2.0 scopes previously granted to a project" and invalidates tokens for all clients registered under that project. So a revoke would sign the person out of every Antigravity sign-in for that account, not only Paperclip's. Paperclip has no client of its own for this sign-in, so it cannot revoke only its own access. **Roadmap alignment** This is work item 5 of the merged plan `doc/plans/2026-11-25-antigravity-cloud-rollout.md` (gap G10). This pull request updates G10, item 5 and the security table there to record the decision. ## What Changed - `server/src/services/antigravity-access-removal.ts`: for a Google Antigravity subscription connection, deletes the grant's own saved sign-in (the private `ai-<grant>` or `ai_<grant>` slot only). It keeps a sign-in that a live grant or connection elsewhere, a secret binding or user-secret declaration on another target, or another consumer (agent profile, routine trigger, secret proposal) still uses. On connection removal, other grants of the same connection do not count. The delete passes the saved version, and the grant must still be revoked, so a reconnect that saved a new version is never deleted. A failed delete keeps the grant's reference so the next disconnect retries, and the retry finds a sign-in that is already marked deleted and finishes the purge. It also clears the quota-recovery file for that grant. - New `server/src/services/connection-secret-consumers.ts`: one `findSecretConsumers` check for "is this secret used elsewhere?". Connection removal (`classifyConnectionSecrets`), managed Google removal (`secretsHeldElsewhere`) and this change use it. Removal keeps its rule that any grant or connection counts; the two Google paths count only live ones. Managed Google removal now also respects bindings, declarations and other consumers, which only keeps more secrets. - `packages/shared`: new `AiSignInRemoval` result (`savedSignIn: deleted | kept_shared | not_deleted`, `providerSignIn: still_valid`) on the grant revocation result and the connection removal summary. - `grants.ts`, `removal.ts`, `routes/tool-access.ts`: return and log the result. Removal does not clear a grant reference whose delete failed, and its final reference clear only touches revoked grants, so a reconnect that lands during removal keeps its sign-in. - `removal.ts`: the grant revocation and the usage-limit hold release now commit in one transaction. - `ai-connections.ts`: a personal reconnect reuses the grant's existing secret definition only if the owner created it, it is live, and it is a Paperclip-managed local definition. Otherwise the reconnect is refused in plain words and no token is written. - UI: the AI account disconnect shows a toast, and connection removal and the audit feed show the result in plain words, for example "Paperclip deleted its saved Google sign-in. The sign-in stays valid at Google until you remove it in your Google account's third-party connections. Removing it there also signs this Google account out of Antigravity everywhere." A failed delete says "Paperclip couldn't delete its saved Google sign-in. Disconnect again to retry." - Docs: `doc/connections/AI-CONNECTIONS.md` and the rollout plan. - The first revision's direct Google call and its retry branch in the Google revocation queue are removed. `google-pending-revocation.ts` is unchanged from `master`. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed pins for the changed shared export. ## Verification - `npx vitest run src/__tests__/antigravity-disconnect-sign-in.test.ts` (server, embedded Postgres, network calls fail the test): 17 cases. Disconnect through the route deletes the sign-in, makes no network call, logs the result with no token, and the owner can reconnect. Connection removal deletes it, also when a second grant of the same connection references it. It is kept when a grant on another live connection, a binding on another target, a declaration on another target, or a routine trigger uses it. A failed delete (forced by a database trigger) is reported, keeps the reference, and the next disconnect deletes it, for disconnect and removal, and also when the failure comes after the sign-in was marked deleted. A reconnect during the delete, or during connection removal, keeps its sign-in. A personal reconnect is refused when the slot was created by someone else, deleted, or moved to another provider, and no token is written. A hold-release failure during removal leaves every grant active and the sign-in saved. - Red/green: with `master`'s `grants.ts`, `removal.ts`, `ai-connections.ts` and `routes/tool-access.ts`, the disconnect and removal cases fail. Each guard was also removed on its own, and its case failed: the saved-version check, the revoked-only final clear, the half-deleted retry, the same-connection exclusion, and the definition ownership check. - `ui`: `npx vitest run src/features/connections/googleAccessRemoval.test.ts` (13 pass, 5 new). - Connection removal and managed Google tests pass: `tool-connection-removal`, `tool-access-service`, `google-managed-connection-removal`, `google-pending-revocation`, `ai-connections`, and the browser-use, client-credentials, generic MCP, Braintrust, 1Password and remote MCP connection suites. - Server typecheck passes. UI `tsc` shows no errors in changed files. `pnpm verify` selects about 1,900 test files for this change (removal is widely imported), so required CI supplies that broad coverage. ## Risks - The Google sign-in stays valid at Google after a disconnect. The UI and activity log say so and link to the Google account page. This is deliberate; see Alternatives considered. - A reconnect still keeps older versions of a rotated shared secret, as before this change. - Company deletion does not change here. - No schema change and no migration. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, test runs, web reading of Google's OAuth documentation). ## 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> |
||
|
|
aa85bcb518 |
feat(plugins): carry a Google sign-in to plugin Runners for Google Antigravity (#22933)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugin environments (for example, an agent computer) run agents as plugin Runner tasks. Core sends each task one typed credential, and gets refreshed sign-ins back through the task's `credentials` snapshot. > - #22930 let a Google Antigravity task carry a Gemini API key. A Google subscription sign-in was still refused with "Google sign-in is not supported." > - The Cloud rollout plan (#22923) needs both routes. This is gaps G3 and G4 and work item 2: deliver the sign-in, and save a rotated refresh token safely, as Codex does. > - This pull request sends the saved, sanitized sign-in as the `antigravity` `provider-env` credential under `PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`. It saves a refreshed token from the snapshot only after the generation, epoch and Google account checks. > - The benefit is that a plugin (for example, the Cloud agent computer) can run an Antigravity task with a person's Google sign-in, and token refreshes are not lost or saved to the wrong account. The picker, Test and save refusals for plugin targets (item 6) and the qualification flip (item 8) stay out of scope. ## Linked Issues or Issue Description Refs #22923 Refs #22930 **What problem does this solve?** A plugin Runner task cannot use a Google sign-in for Google Antigravity. Core refuses it at run start. There is also no path to save a refresh token that the Runner rotated on the plugin's computer. **Proposed solution** Add the sign-in variable as a second `antigravity` key set in `provider-env`. Core reads the sign-in from the run's private managed home, runs it through `sanitizeAntigravityCredential`, and sends that exact output. Core saves the write-back binding (grant, secret, session epoch, and a SHA-256 of the starting sign-in) on the lease. When the task stops, Core reads the snapshot and saves a new token only if all checks pass. **Alternatives considered** A new credential type for the sign-in. `provider-env` already has the exact-set check, the credential binding contract and the cross-check against the Runner's allowlists. The Cloud plan already describes the Launcher row as "`GEMINI_API_KEY` or the sign-in key". ## What Changed - `packages/plugins/sdk/src/environment-tasks.ts`: the `antigravity` key sets are now `GEMINI_API_KEY` or `PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`. A mix of both stays rejected. - `server/src/services/native-runtime/plugin-runner-credentials.ts`: with no Gemini API key, Core reads `antigravity-acp/acp_token.json` from the selected managed home and sends the sanitizer's complete output (client ID, client secret, refresh token, token URI, `scopes`, and `project_id` when present). It never sends an access token or the account email. The task needs write-back authority. A sign-in supplied through the environment is refused. An unreadable or invalid saved sign-in fails with "The selected Google Antigravity account is unavailable. Reconnect the Google account, then retry." No error contains credential text. - `server/src/services/ai-connection-runtime.ts`: a Google subscription run now returns a write-back binding with `google.credentialSha256` of the starting sign-in. - `server/src/services/managed-ai-credential-writeback.ts`: new `syncManagedAntigravityCredential`. It requires an active grant, the same secret reference and session epoch, a Google subscription connection, and a saved sign-in that still hashes to the starting generation. It verifies a changed token with the existing account check (`prepareAntigravityCredentialWriteback`) in a private temporary home, then rechecks all of the above under the account lock before it rotates the secret. It writes `ai_connection.credential_refreshed` on save. For a different account, or a connection with no saved account, it saves nothing, writes `ai_connection.credential_refresh_refused` with a plain reason, and settles as `account_refused`. - `server/src/services/plugin-task-credential-writeback.ts`: a handoff with a Google binding takes the snapshot's `provider-env` `antigravity` sign-in and uses the Google write-back. Codex is unchanged. - `server/src/services/native-runtime/native-session-executor.ts`: a sign-in credential needs a Google write-back binding, and a Codex credential needs a non-Google one. - `server/src/services/native-runtime/antigravity-runner-credentials.ts`: the account mismatch is a typed error. The message is unchanged. - Docs: `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and `doc/plugins/PLUGIN_RUNNER_EXECUTION.md` describe the sign-in credential, where the Runner stages it, and the snapshot that the plugin must return. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the changed SDK source. ## Verification - Red first: with the source changes removed, 22 of the new and updated tests failed (the refusal, no write-back binding, no Google write-back). - Green after the change: - `cd server && npx vitest run src/__tests__/antigravity-plugin-task-credential-writeback.test.ts` (11 passed, embedded PostgreSQL): delivery of the exact sanitized sign-in; same-account rotation saved and logged; a second rotation during the account check saved; a different account refused and recorded in plain words; unchanged token with no Google call; reconnect (new generation and epoch) and a revoked grant discard the write-back without an export; a Google outage keeps the handoff pending and the next cleanup saves it; Codex, API-key and invalid snapshots refused. No token, client secret or access token in lease metadata, activity rows or errors. - `cd server && npx vitest run src/services/native-runtime/plugin-runner-credentials.test.ts src/__tests__/plugin-runner-credential-names.test.ts` (39 passed). The names test checks that the Runner forwards the sign-in variable to the sidecar and keeps it out of the provider process. - `cd packages/plugins/sdk && npx vitest run tests/environment-task-release-resume.test.ts tests/environment-tasks.test.ts` (104 passed) - `cd server && pnpm typecheck` (clean) - `pnpm verify` (see the CI run for broad coverage) - No live run, no Google login and no real token was used. All Google calls are fixtures. ## Risks - Low for current users. Plugin targets still refuse Antigravity in the picker, Test and save (item 6), so no existing agent reaches this path until item 6 merges. - The lease now stores a SHA-256 of the starting sign-in. It is a one-way digest of a high-entropy token, and it is the same kind of generation value that Core already derives for the local route. - If Google rotates the token during the account check and the database save then fails, the cleanup retries from the plugin's snapshot. Google does not normally rotate these refresh tokens, so this matches the local route's exposure without its recovery journal. - The Launcher must return the Runner's `auth-refresh.json` (or `acp_token.json` before lease close) in the snapshot. A Launcher that returns the starting sign-in only records `unchanged`, so no token is lost on the Core side, but a rotation on the computer would not be saved. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edits, test runs). Standard context window, 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> |
||
|
|
57bd302c81 |
feat(antigravity): add hosted Google loopback-relay sign-in (#22932)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Google Antigravity supports Google account sign-in through Paperclip Runner's pinned, isolated `agy_acp_server.par` process. > - On `authenticated + public` deployments (including hosted Cloud instances), `supportsLocalAiLogin` returns `false`, and the user's browser cannot directly reach the server's `127.0.0.1:<ephemeral_port>` loopback callback listener. > - Because `client_secret` lives only inside `agy_acp_server.par` and uses PKCE with a one-shot `127.0.0.1` listener, hosted deployments need an authenticated relay path instead of an anonymous callback route or extracted secret. > - This pull request adds an authenticated loopback-relay flow across Runner, server policy/routes/redaction, and the UI so users on hosted deployments can sign in with Google, copy the `127.0.0.1` redirect URL from their address bar, and paste it to complete authentication. > - The benefit is that Google Antigravity subscription sign-in works on hosted public deployments while keeping Claude, OpenAI, and Grok server-host login disabled and preventing SSRF, secret leakage, or cross-tenant access. ## Linked Issues or Issue Description Refs #22923 **Subsystem affected** Cross-cutting (packages/paperclip-runner, packages/shared, server/, ui/) **Problem or motivation** Google Antigravity sign-in launches Paperclip's pinned, isolated `agy_acp_server.par` closure, which opens a one-shot `127.0.0.1:<ephemeral_port>` OAuth callback listener. On hosted `authenticated + public` deployments, server-host login routes are blocked and the user's browser cannot connect to the server's loopback interface, so users cannot sign in with a Google account on Cloud or remote instances. **Proposed solution** Add an authenticated loopback-relay flow: 1. Runner exposes a single-use `submitRedirect(rawRedirectUrl)` handler on `AntigravityBrowserLoginState` that validates the pasted URL (length, printable ASCII, `http://127.0.0.1:<expectedPort>/`, no credentials/hash, no duplicate `state`/`code`, no `error` param, `timingSafeEqual` state check, bounded 5-attempt bad-paste cap, SHA-256 reused-code tracking) and issues an SSRF-proof reconstructed `GET` to `expectedRedirect.origin` with `redirect: "manual"`. 2. Server adds `supportsHostedGoogleAiLogin` (exposed on `/api/health` as `hostedGoogleAiLoginSupported`), permits Google through the authenticated `/api/companies/:companyId/ai-connections/local/*` routes while keeping `anthropic`/`openai`/`xai` blocked on public deployments, accepts up to 4096-character redirect URLs on `/code` while preserving Claude's 512-byte limit, runs the loopback relay outside DB transactions, falls back cleanly when a stack has no active `local` environment row, and redacts `browserCode`/`redirectUrl` and marks `/code` secret-sensitive. 3. UI enables Google sign-in for `antigravity_runtime` on non-local environments when `hostedGoogleAiLoginSupported` is true, renders the external Google sign-in link plus plain-language `127.0.0.1` copy/paste instructions with analytics masking/no-capture markers, and triggers an immediate status check after submission. **Alternatives considered** - Adding an anonymous public OAuth callback route on the server: rejected because it widens the unauthenticated attack surface and cannot change the loopback `redirect_uri` bound inside `agy_acp_server.par`. - Extracting Google OAuth `client_secret` out of `agy_acp_server.par`: rejected by policy; secrets remain owned solely inside the pinned closure. ## What Changed - `packages/paperclip-runner/src/drivers/acpx/antigravity-auth.ts` & `packages/paperclip-runner/src/index.ts` & `server/src/vendor/paperclip-runner/index.ts`: add single-use `submitRedirect` on `AntigravityBrowserLoginState` with strict validation, `timingSafeEqual` state verification, 5-attempt cap, bounded SHA-256 reused-code set, and SSRF-proof loopback relay. - `packages/shared/src/ai-connections.ts`: add `LOCAL_AI_LOGIN_CODE_MAX_LENGTH` (4096), `localAiLoginCodeSchema`, and `submitLocalAiLoginCodeSchema` while preserving Claude's 512-byte `BROWSER_CODE_MAX_LENGTH` and `browserCodeSchema`. - `server/src/services/local-ai-login-policy.ts` & `server/src/routes/health.ts`: add `supportsHostedGoogleAiLogin` and expose `hostedGoogleAiLoginSupported` on `/api/health`. - `server/src/services/local-ai-browser-login.ts`, `server/src/services/local-ai-login.ts`, `server/src/routes/ai-connections.ts`: permit hosted Google sign-in on authenticated public deployments while keeping Claude/OpenAI/Grok blocked; enforce `Cache-Control: no-store`, owner/company/active/expiry checks, and Claude's 512-byte cap; run Google `submitRedirect` outside any DB transaction; fall back cleanly to an active environment or savepoint-wrapped `ensureLocalEnvironment` when no active `local` environment row exists. - `server/src/middleware/redact-sensitive.ts`, `server/src/middleware/http-log-redaction.ts`, `server/src/middleware/http-log-policy.ts`: redact `browserCode`/`redirectUrl`/`redirect_url` unconditionally and classify `/api/companies/:companyId/ai-connections/local/attempts/:sessionId/code` as secret-sensitive (`local_ai_login_code`). - `ui/src/api/health.ts`, `ui/src/components/ai-connections/useLocalAiLogin.ts`, `ui/src/components/AdapterLoginChrome.tsx`, `ui/src/components/new-agent/AgentProviderConnection.tsx`, `ui/src/components/ai-connections/AiConnectionCredentialStep.tsx`, `ui/src/components/OnboardingWizard.tsx`: enable hosted Google sign-in for `antigravity_runtime` on hosted/non-local environments, render the hosted `127.0.0.1` redirect paste flow with `ANALYTICS_MASK_CLASS` and `ANALYTICS_NO_CAPTURE_CLASS`, preserve retryable paste errors inline, and trigger immediate status re-check on submit. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the updated `packages/shared/src/ai-connections.ts` schema. - Unit, integration, and UI tests across `antigravity-auth.test.ts`, `local-ai-login-policy.test.ts`, `health.test.ts`, `health-dev-server-token.test.ts`, `redact-sensitive.test.ts`, `http-log-policy.test.ts`, `antigravity-local-ai-login.test.ts`, `ai-connections.test.ts`, `AdapterLoginChrome.test.tsx`, `useLocalAiLogin.test.tsx`, and `AgentProviderConnection.test.tsx`. ## Verification - `pnpm --filter @paperclipai/shared build && pnpm --filter @paperclipai/shared typecheck && pnpm --filter @paperclipai/paperclip-runner typecheck && pnpm --filter @paperclipai/server typecheck && pnpm --filter @paperclipai/ui typecheck` — passed. - `pnpm --filter @paperclipai/shared exec vitest run src/validators/claude-setup-token-session.test.ts` — 15/15 passed. - `pnpm --filter @paperclipai/paperclip-runner exec vitest run src/drivers/acpx/antigravity-auth.test.ts src/drivers/acpx/antigravity-auth-stream-order.test.ts` — 33/33 passed (including real `127.0.0.1` loopback HTTP relay with fake ACP peer, bad-paste cap, reused-code rejection, single-use, and non-200 failure). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/local-ai-login-policy.test.ts src/__tests__/health.test.ts src/__tests__/health-dev-server-token.test.ts src/__tests__/redact-sensitive.test.ts src/__tests__/http-log-policy.test.ts src/__tests__/antigravity-local-ai-login.test.ts` — all passed. - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/ai-connections.test.ts` — 167/167 passed against embedded PostgreSQL (including hosted Google end-to-end route test, redaction of activity and HTTP logs, and continued blocking of Anthropic/OpenAI/xAI on hosted public deployments). - `pnpm --filter @paperclipai/ui exec vitest run src/components/AdapterLoginChrome.test.tsx src/components/ai-connections/useLocalAiLogin.test.tsx src/components/new-agent/AgentProviderConnection.test.tsx` — 30/30 passed. - `pnpm verify --explain` returned exit 2 (`tests/runner-e2e/source-sdk-public-inputs.json` broad input); required CI supplies full-repo coverage. - Note: live end-to-end sign-in against real `agy_acp_server.par` and Google OAuth on a live Cloud stack was not run in this unit/integration environment and remains a live-staging verification step. ## Risks - Low-to-moderate risk. All hosted Google sign-in endpoints stay authenticated, company-scoped, owner-bound, and `Cache-Control: no-store`; `localAiLoginSupported` remains `false` on `authenticated + public` deployments so Claude, OpenAI, and Grok server-host login stay blocked. - Loopback relay runs strictly against the validated `127.0.0.1:<ephemeral_port>` origin printed by `agy_acp_server.par` with `redirect: "manual"` and a 5-second timeout, outside any database transaction. - No database migrations are required. ## Model Used - Google Gemini (Antigravity agent with tool use and code execution) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [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> |
||
|
|
07d444a717 |
feat(plugins): carry a Gemini API key to plugin Runners for Google Antigravity (#22930)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Plugin environments (for example, an agent computer) run agents as plugin Runner tasks. Core sends each task one typed credential. > - The typed `provider-env` credential carries API keys for Grok, Copilot and OpenCode. It has no entry for Google Antigravity. > - So an Antigravity agent cannot get its Gemini API key on a plugin Runner task. This is gap G3 and work item 1 in the Antigravity Cloud rollout plan (#22923). > - This pull request adds `antigravity` to `provider-env`, with the single variable set `GEMINI_API_KEY`. It follows the Copilot pattern from #22359. > - The benefit is that a plugin (for example, the Paperclip Cloud agent computer) can now accept a Gemini API key for an Antigravity task. Google sign-in, the plugin-target refusal and the qualification flip stay out of scope. ## Linked Issues or Issue Description Refs #22923 Refs #22359 **What problem does this solve?** A plugin Runner task cannot carry a Gemini API key. `provider-env` accepts only `grok`, `copilot` and `opencode`, and Core throws "Plugin Runner does not support the selected credential provider" for Antigravity. **Proposed solution** Add `antigravity: [["GEMINI_API_KEY"]]` to the published key sets and to the `provider-env` provider enum. Core transfers only that key. Core refuses a Google sign-in or a missing key with a plain message. **Alternatives considered** A new credential type only for Gemini. The generic `provider-env` type already has the exact-set check, the binding contract and the cross-check against the Runner's allowlists, so a new type adds no value. ## What Changed - `packages/plugins/sdk/src/environment-tasks.ts`: `ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS` has `antigravity: [["GEMINI_API_KEY"]]`. The `provider-env` provider enum accepts `antigravity`. Mixed, partial and extra variable sets stay rejected. - `server/src/services/native-runtime/plugin-runner-credentials.ts`: for provider `antigravity`, Core sends only `GEMINI_API_KEY`. Core refuses a Google sign-in document (`PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`) or a missing or blank key with "Plugin Runner supports Google Antigravity only with a Gemini API key. Google sign-in is not supported." No key value is in any error message. - Tests: SDK schema cases (accept the key; reject a sign-in document, a key mixed with a sign-in document, `GOOGLE_API_KEY`, extra routing variables, empty values, and the key under another provider). Core transfer and refusal cases. Dispatch only for the matching `antigravity` harness, with no key in persisted lease metadata or in a worker error. A Runner check that the Antigravity process gets the key and no `GOOGLE_*` or other `GEMINI_*` variable. - Docs: `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and `doc/plugins/PLUGIN_RUNNER_EXECUTION.md` list the new set, the binding requirement and the sign-in refusal. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the changed SDK source. ## Verification - Red first: the new tests failed before the change (the schema rejected `antigravity`, and Core threw "does not support the selected credential provider"). - Green after the change: - `cd packages/plugins/sdk && npx vitest run tests/` (322 passed) - `cd server && npx vitest run src/__tests__/plugin-runner-credential-names.test.ts src/services/native-runtime/plugin-runner-credentials.test.ts src/__tests__/environment-task-runtime.test.ts` (94 passed) - `cd packages/plugins/sdk && npx tsc --noEmit -p .` and `cd server && npx tsc --noEmit -p .` (clean) - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` (no change) - `pnpm verify` asks for broad CI coverage (exit 2) because an SDK test file changed. Required CI supplies that coverage. - No live run. Antigravity on a plugin target stays refused by Core until a later change lifts that refusal, so this change is not reachable in a run yet. ## Risks - Low risk. The change adds one enum value and one key set. Existing providers keep the same behavior. - Plugins that validate with an older SDK reject an `antigravity` credential. This is the expected fail-closed result. - The key reaches the Runner only through the typed credential. The Runner still requires a matching `PAPERCLIP_ACPX_CREDENTIAL_BINDING` and still removes other `GOOGLE_*` and `GEMINI_*` variables. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits) and extended thinking. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [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> |
||
|
|
4622965a25 |
fix(github): recover response requests that ran out of retries; restore lost regression tests (#22906)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull request threads, and each request's comment must end in a real reply or an honest final notice > - After #22672, #22710, #22798 and #22807, new review-bot comments on staging settle: 0 of 85 comments since the deploy are stuck > - Two older "Working on this…" comments (PRs #22649 and #22676) still did not settle. Before those fixes, their requests spent all acknowledgement retries and were left `failed`, a state no recovery path reads again > - Separately, the chat-channels split (#22838) was built from an older copy of the monolith and dropped the regression tests those fixes added > - This pull request adds a one-time recovery migration for exhausted requests and restores the lost regression tests > - The benefit is that the last stuck comments settle, and the settle rules stay covered by tests that run on every PR ## Linked Issues or Issue Description Refs #22672, #22710, #22798, #22807, #22838 **Describe the bug** Two GitHub request comments from 2026-11-23 still read "Working on this…" on staging after the settle fixes deployed. Before #22798, an unsettled reply made each acknowledgement attempt fail with "GitHub reply is still being resolved", so these requests spent all 8 retries and stayed `failed` with `retryable: false`. Neither the acknowledgement sweep (retryable only) nor the terminal sweep (processed only) reads them again. **Steps to reproduce** 1. A request's acknowledgement fails 8 times and is left `failed`, `retryable: false`, with its comment still "Working on this…". 2. Deploy the settle fixes. Nothing reads the request again. **Expected behavior** Such a request settles with the current decision once. ## What Changed - Migration `0509_recover_exhausted_github_responses.sql`: one UPDATE that returns failed, non-final `github_response_comment` rows that already hold a posted comment to `processed` (code `recovered_after_exhausted_retries`, wait key and retry time cleared), so the terminal sweep settles them. Marked `online_compatible`. - Restored regression tests dropped by the split, in `server/src/__tests__/chat-channels/github-review-workflow.integration.test.ts`: published review kept in the main comment (ended / paused), older status settles against a newer placeholder, back-to-back runs settle, waited thread links a later response (including a different-PR guard), inline-only review link, waited thread settles when the task finishes, refused reply settles. - New tests: a failed run whose automatic retry finished the task (inline and issue threads), and the exhausted-retries recovery. ## Verification - `github-review-workflow.integration.test.ts` restored + new tests: 11 passed locally. The recovery test shows the comment stuck before the migration and settled after it. - Test tree typecheck (`src/__tests__/tsconfig.json`) is clean. - After deploy: the two remaining placeholders on #22649 and #22676 should settle within a sweep pass; I will check them on staging. ## Risks - The migration updates only failed, non-final GitHub request rows that have a posted comment; on staging that is a handful of rows. Each is read once by the terminal sweep and then settles or waits under the current rules. - Restored tests add a few seconds to the GitHub review workflow suite. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4aaa77e6fc |
perf(ci): split 6 single-file Vitest stragglers across runner, chat, server, and serialized lanes (#22916)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Profiling live 8-core PR runs (`45592683902`, `45578886514`, `45591289735`, `45587659461`) showed that every single top Vitest critical-path straggler across all 4 Vitest lanes was caused by **single-file tail pinning**—one massive file running solo while 4–6 CPU cores sat idle—rather than insufficient shard counts: > - `Verify Paperclip Runner (vitest package 1/6)` (`245s` job): `runnerd-codex-transport.test.ts` = `190.9s` solo > - `Verify Paperclip Runner (vitest package 2/6)` (`236s` job): `runnerd-codex-transport-deadlines.test.ts` = `181.3s` solo > - `Verify Paperclip Runner (vitest package 3/6)` (`185s` job): `runnerd-codex-transport-settlement.test.ts` = `123.6s` solo > - `General tests (chat 1/2)` (`229s` job): `github-review-workflow.integration.test.ts` = `179.2s` solo > - `General tests (server 1/20)` (`209s` job): `connection-management.integration.test.ts` = `160.1s` solo > - `Verify serialized server suites (1/9)` (`190s` job): `issue-queued-comments-routes.test.ts` = `132.8s` solo > - Instead of bloating shard counts, this pull request splits those 6 single-file tails into 20 focused sibling suites (`<925 LOC` per new file) with shared non-test harness helpers so existing 8-core workers execute them in parallel, keeps all 6 original anchor filenames intact so every existing `maps/` and contract reference remains valid, and refreshes all 4 Vitest LPT duration manifests from live 8-core measurements. > - Every single original test case is preserved (`694/694` live pass across the 20 split suites, zero deleted assertions) while shaving `60–105s` off every Vitest lane's critical-path tail. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Parallel wall-clock execution time of the slowest shards across `Verify Paperclip Runner (vitest package)`, `General tests (chat)`, `General tests (server)`, and `Verify serialized server suites`. **Subsystem affected** packages/paperclip-runner/, server/, and scripts/ — Vitest integration test layout, sequencer priorities, and LPT shard duration manifests **Current behavior** Six oversized test files (`123s–191s` solo each) pin the tail of the slowest shard in every Vitest lane while peer workers on the 8-core runner sit idle. **Proposed behavior** Split those 6 single-file stragglers into 20 parallelizable sibling suites (retaining all 6 original anchor filenames and extracting shared non-test harnesses) and refresh `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `scripts/chat-shard-durations.json`, `scripts/general-server-shard-durations.json`, and `scripts/serialized-shard-durations.json` plus `packages/paperclip-runner/scripts/vitest-sequencer.mjs`. ## What Changed - **Split all 6 single-file stragglers (31 files changed: 11 modified, 20 new; every new file `<925 LOC`, 100% of test cases preserved):** 1. `packages/paperclip-runner/test/runnerd-codex-transport-deadlines.test.ts` (`181.3s` CI) → 3 files (`anchor` + `-lease-expiry` + `-cold-admission`, 9/9 tests) 2. `packages/paperclip-runner/test/runnerd-codex-transport-settlement.test.ts` (`123.6s` CI) → 2 files (`anchor` + `-settlement-revocation`, 19/19 tests) + 3 non-test support harnesses (`runnerd-settlement-assertions.ts`, `runnerd-settlement-harness.ts`, `runnerd-settlement-fixture.ts`) 3. `packages/paperclip-runner/test/runnerd-codex-transport.test.ts` (`190.9s` CI) → 4 files (`anchor` + `-backlog-proxy` + `-held-calls` + `-provider-turns`, 337/337 tests) 4. `server/src/__tests__/chat-channels/github-review-workflow.integration.test.ts` (`179.2s` CI) → 4 files (`anchor` + `-finding-threads` + `-response-maintenance` + `-publications`, 89/89 tests) + `github-review-harness.ts` 5. `server/src/__tests__/connection-management.integration.test.ts` (`160.1s` CI) → 4 files (`anchor` + `-providers` + `-delegated-policy` + `-gateways`, 92/92 tests) + `helpers/connection-management-harness.ts` 6. `server/src/__tests__/issue-queued-comments-routes.test.ts` (`132.8s` CI) → 3 `*routes*` files (`anchor` + `-steering-routes` + `-dispatch-routes`, 148/148 tests, all matching `routeTestPattern` in the `serialized` lane) + `helpers/issue-queued-comments-harness.ts` - **Updated sequencer & LPT duration manifests:** - Updated `packages/paperclip-runner/scripts/vitest-sequencer.mjs` and refreshed `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `scripts/chat-shard-durations.json`, `scripts/general-server-shard-durations.json`, and `scripts/serialized-shard-durations.json` from live 8-core PR run `45592683902` with exact `coverage` reconciliation. ## Verification - Live execution of all 20 split suites: **20/20 files, 694/694 tests PASS** (`deadlines` 9/9 in `81.1s` parallel, `settlement` 19/19 in `105.4s` parallel, `transport` 337/337 in `109.2s` parallel, `github-review` 89/89 under shared PG, `connection-management` 92/92 under shared PG, `issue-queued-comments` 148/148 under shared PG) - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (105 nightly suites, 11 test files checked, 0 violations) - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capability IDs aligned) - `pnpm --filter @paperclipai/paperclip-runner exec tsc --noEmit` — **PASS** (0 errors) - `pnpm --filter @paperclipai/paperclip-runner exec vitest run scripts/vitest-sequencer.test.mjs` — **5/5 PASS** - `node --test` across `native-completion-source-contract`, `run-vitest-stable-shard`, `run-vitest-stable-pr-mode`, `runner-vitest-package-lanes`, `test-selection-pr-timings`, `test-selection-timings`, `e2e-shard`, `check-test-budget`, and `ci-plan` — **121/121 PASS** ## Risks - Low risk: all 6 original anchor filenames remain intact, zero `.github/**` or `CODEOWNERS` files are touched, zero cross-test-file imports were introduced (shared setup lives in non-test harness modules), and full CI will execute all 20 split suites live before merge. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`vitest-runner`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
007d1c2ef1 |
perf(runner): parallelize static checks and memoize contract fingerprinting (#22912)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - On 8-core PR runners (`45592683902`, `45578886514`), `Verify Paperclip Runner (static checks)` was the #3 PR critical-path straggler at `192s–222s` (`142s–178s` inside `check:static`) because `check:static` ran every build, contract check, prep test, and API-authority Vitest suite serially on a single chain—rebuilding `@paperclipai/paperclip-eval-kernel` 4 times, repeating `acpx-profiles`/`protocol-types`/`tsc` twice, re-parsing Rust files uncached in `contract-fingerprints.mjs` (`26s`), running a duplicate contract test behind a serial `&&` barrier (`52s`), and running `check-api-authority.mjs` (`75s`) without `--project @paperclipai/server` or shared-PG `fsync=off`. > - This pull request eliminates every redundant rebuild/check inside `packages/paperclip-runner`, memoizes `contract-fingerprints.mjs` by content hash (`sha1`, bit-for-bit identical digest, `10x` faster), consolidates `test:typescript:prep` into one parallel `node:test` runner, wires `check-api-authority.mjs` to `--project @paperclipai/server` + disposable shared PostgreSQL while preserving standalone self-contained execution for `release-verify.yml`, and orchestrates `check:static` via a race-free 5-phase DAG (`run-check-static.mjs`) that overlaps disjoint builds and tests across available CPU cores. > - All changes stay strictly within `packages/paperclip-runner/` and preserve 100% of original static, protocol, build, prep-test, and API-authority checks. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Execution speed of `pnpm --filter @paperclipai/paperclip-runner run check:static` (`Verify Paperclip Runner (static checks)` CI job) on multi-core runners. **Subsystem affected** packages/paperclip-runner/ — static checks, contract fingerprinting, and prep/authority test orchestration **Current behavior** `check:static` chains `check:eval-kernel && check:protocol-without-vitest && check:api-authority` serially, rebuilding `paperclip-eval-kernel` 4x, running `tsc` and protocol checks 2x, re-stripping/re-parsing Rust sources uncached in `contract-fingerprints.mjs`, running `acpx-message-boundaries-package-contract.test.mjs` twice across a serial `&&` barrier, and running `check-api-authority.mjs` without `--project @paperclipai/server` or disposable shared PG. **Proposed behavior** Memoize Rust comment-stripping/parsing in `contract-fingerprints.mjs` with bit-for-bit identical digest parity, merge `test:typescript:prep` into one deduplicated parallel runner (`run-prep-tests.mjs`), add `--project @paperclipai/server` + disposable shared PostgreSQL + `--skip-build` to `check-api-authority.mjs`, and execute `check:static` via a race-free 5-phase parallel DAG (`run-check-static.mjs`). ## What Changed - **Memoized contract fingerprinting (`packages/paperclip-runner/scripts/contracts/contract-fingerprints.mjs`, `contract-fingerprints.test.mjs`):** - Added content-addressed (`sha1`) caches for `stripRustComments`, `withoutTestModules`, `rustSerdeItems`, per-file string constants, and `#[cfg(test)] mod` declarations, plus compact `probeCache` keys (`16.23s -> 1.63s` locally = `10.0x` speedup, bit-for-bit identical digest `sha256:bacaefb049aa9a0841fe782fefb11ede1f99222d15151873e92194e2aab9c608`). - **Deduplicated parallel prep test runner (`packages/paperclip-runner/scripts/run-prep-tests.mjs`):** - Removed duplicate `test/acpx-message-boundaries-package-contract.test.mjs` and merged the 8 Copilot `node:test` files plus `run-check-static.test.mjs` into one parallel `node-test.mjs` invocation (`44` unique suites, no serial `&&` barrier). - **Optimized API-authority verification (`packages/paperclip-runner/scripts/check-api-authority.mjs`):** - Scoped Vitest to `--project @paperclipai/server`, wrapped with `scripts/ci/vitest-shared-postgres.mjs` when no external test PG URL is supplied, and added `--skip-build` / `--dry-run` while keeping standalone `pnpm run check:api-authority` (used by `release-verify.yml`) 100% self-contained. - **Race-free 5-phase parallel `check:static` orchestrator (`packages/paperclip-runner/scripts/run-check-static.mjs`, `run-check-static.test.mjs`, `packages/paperclip-runner/package.json`):** - Phase 1: `check:eval-kernel` (builds & tests `eval-kernel` once). - Phase 2 (parallel, read-only): `acpx-profiles`, `antigravity-models`, `protocol-manifest`, 6 `node --check` checks, 4 `protocol-types` checks (each once). - Phase 3 (3 disjoint parallel chains): (A) TS builds + entrypoints + copilot assets + replay goldens, (B) serialized Cargo debug then release builds (zero `target/.cargo-lock` contention), (C) `plugin-sdk ensure-build-deps`. - Phase 4: `stage-runner-binary.mjs` after A and B complete. - Phase 5 (parallel): `run-prep-tests.mjs --skip-build` alongside `check-api-authority.mjs --skip-build` with buffered per-step output and signal forwarding. ## Verification - Verified exact digest parity: `sha256:bacaefb049aa9a0841fe782fefb11ede1f99222d15151873e92194e2aab9c608` (unchanged) - `node --test packages/paperclip-runner/scripts/contracts/contract-fingerprints.test.mjs packages/paperclip-runner/scripts/run-check-static.test.mjs packages/paperclip-runner/scripts/build-inputs.test.mjs packages/paperclip-runner/scripts/stage-runner-binary.test.mjs` — **35/35 PASS** (`2.46s`) - `node packages/paperclip-runner/scripts/run-check-static.mjs --dry-run` and `node packages/paperclip-runner/scripts/check-api-authority.mjs --dry-run` — **PASS** - `node scripts/check-test-budget.mjs --base origin/master`, `node scripts/check-maps.mjs`, `node --test scripts/check-test-budget.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs .github/scripts/tests/ci-plan.test.mjs` — **PASS** - Live Linux execution of `Verify Paperclip Runner (static checks)` (including embedded PG `check-api-authority.mjs` and Copilot asset installation) will be verified end-to-end on PR CI. ## Risks - Low risk: all changes are scoped strictly to `packages/paperclip-runner/`, Cargo builds remain serialized in one chain to avoid target lock contention, `stage-runner-binary.mjs` waits for both TS and Rust builds before touching `dist/`, and standalone `pnpm run check:api-authority` preserves full self-contained builds for `release-verify.yml`. ## Model Used - Gemini 4 Neon (High) via Antigravity agent swarm (`server-prune`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
10cd186a46 |
feat(antigravity): carry the agent's own instructions into a /swarm turn (#22905)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A signed-in user can start Google Antigravity's native `/swarm` on a task (experimental, off by default) > - #22733 removed the agent's own instructions from a swarm turn after a security review: an agent can edit its own instructions, and swarm helpers act in Antigravity's auto mode > - The owner reviewed that risk and decided on 2026-11-25 that swarms carry the agent's own instructions again, with Paperclip's swarm rules on top > - This pull request adds the agent's instructions back to a swarm turn through the same composer that ordinary Antigravity turns use, and makes the swarm rules say that they take precedence > - The benefit is that a swarm follows the same agent instructions as every other turn of that agent, and the code-enforced limits stay the same ## Linked Issues or Issue Description Refs #22733 **Subsystem affected** Paperclip Runner, Antigravity `/swarm` route (system instructions), API docs, qualification ledger. **Problem or motivation** A swarm turn runs only on Paperclip's fixed execution prompt and the fixed swarm rules. It ignores the agent's instruction files, so a swarm does not follow the agent's own conventions. The owner decided that swarms must carry the agent's instructions. **Proposed solution** Compose a swarm turn's system instructions exactly as for an ordinary Antigravity turn (`composeNativeSystemInstructions`), with the hand-in values placed right after the instruction entry. The composer's canonical suffix (the instruction root path) still ends the prompt, so `retargetNativeSystemInstructions` remaps it when a launch or recovery moves the bundle to another host path. The swarm route still appends Paperclip's swarm rules last. The rules now say that they take precedence over the agent's instructions, that those instructions cannot widen the Paperclip tools offered or Paperclip's permission decisions, and that helpers must keep their work inside the task folder. ## What Changed - `packages/paperclip-runner/src/backends/runtime-context.ts`: the swarm branch of `nativeSystemInstructions` now runs after the instruction bundle is read (same path checks), and returns `composeNativeSystemInstructions(runtimeContext, entry + hand-in)`. The hand-in block sits inside the composed entry, so the canonical suffix still ends the prompt and retargeting works as for an ordinary turn. The second, swarm-only path is gone. - `packages/paperclip-runner/src/drivers/acpx/antigravity-swarm-runtime.ts`: `ANTIGRAVITY_SWARM_INSTRUCTIONS` gains one precedence statement. It promises only what the code enforces (the tools offered and the permission decisions) and states the task-folder limit as a rule. The rules stay last in the appended system prompt. - Tests: `runtime-context.test.ts` now asserts that a swarm turn's instructions equal the ordinary turn's instructions with the hand-in block after the entry, and that retargeting to another bundle root puts the new root at the end and leaves an inline path in the entry unchanged. `antigravity-swarm-runtime.test.ts` asserts, on the real `session/new` request, that the agent's instructions are present, that the swarm rules come after them and end the prompt, and that the rules carry the precedence statement. The assertions that the bundle is absent are removed. - `docs/api/issues.md` and `doc/plans/2026-11-22-antigravity-qualification.md`: record the owner decision, what is enforced in code, what is prompt-only, and the residual risk. ### Which protections are code-enforced and which are prompt-only Enforced in code, whatever the agent's instructions say: - Permission handler (`antigravity-swarm-runtime.ts`, `session/request_permission`): approves only the run's own Paperclip tools and rejects every other permission request. - Delegation tools (create task, assign, hire, generic API and similar) are removed from the bridge catalog for a swarm turn (`antigravitySwarmTools`). - Only Paperclip's own tool server is accepted; the session must be in the task folder (guard `sessionRequest`, runtime open checks). - A helper started with `share` or `branch` stops the swarm (`antigravitySwarmWorkspaceEscape`). - A visible change outside the task folder in a reported tool call stops the swarm (`antigravityOutsideChange`). This is a best-effort detector, not a boundary. - A changed model, thinking level or auto mode fails the run (guard `assertStable`). Plan mode, a restored session and extra tool servers are refused. Not enforced by Paperclip: helper shell commands. Helper tool calls do not reach the client, so they can write wherever Antigravity's own sandbox allows (the task folder and temp directories). This is unchanged by this pull request. Prompt-only: the precedence statement itself, handing in once, naming files by task-folder path, and not mentioning the rules. Residual risk, accepted by the owner: an agent that can edit its own instructions can influence what its swarm helpers do inside the task folder. ## Verification - Red: with only the test changes, `npx vitest run src/backends/runtime-context.test.ts src/drivers/acpx/antigravity-swarm-runtime.test.ts` (in `packages/paperclip-runner`) failed 2 tests: the swarm instructions lacked the agent's text, and the `session/new` system prompt did not contain it. - Green: with the change, `npx vitest run src/backends src/drivers/acpx src/live/runner-provider-launch.test.ts src/cli/acpx-runtime-sidecar.test.ts` passed (one timing-sensitive launcher test failed once under load and passed on re-run). - Retarget red/green: with the hand-in appended after the canonical suffix, the swarm composition test fails; with it inside the entry, it passes. - `pnpm typecheck` in `packages/paperclip-runner`: passed. - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`: unchanged. - `pnpm verify` exited 2 (docs are a global CI input), so required CI supplies broad coverage. - No live swarm run. ## Risks - Security: agent-editable instructions now reach a swarm whose helpers act in auto mode. The owner reviewed and accepted this. The code-enforced limits above are unchanged. - Behavior: a swarm now fails like an ordinary turn when the agent's instruction entry is missing or outside its bundle. - The system prompt is larger by the size of the agent's instructions. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (file edits, shell, tests). ## 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> |
||
|
|
95ffa0c855 |
fix(agents): state the follow-up request plainly and keep run ids out of the prompt (#22899)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - When a user comments on a finished task, Paperclip starts a
follow-up turn. The agent gets a prompt with the fresh-session history,
the wake payload, and the task context.
> - On Google Antigravity follow-ups after a swarm, the agent spent 3 to
6 minutes and 1 to 2.7 million cached tokens on a one-line file edit.
> - The agent took the run id of the previous run from the prompt and
searched the disk for it. It then read the raw run log to copy how the
previous run wrote the file and called the hand-in tools.
> - The prompt named that run id five times and told the agent to "read
the original run receipt". No agent tool can read a run by its id. Also,
the follow-up directive pointed at an empty "Latest wake comment"
section. The request was present only inside a JSON message list.
> - This pull request removes run ids from the model-facing prompt,
states the latest request plainly once, and points the directive at it.
The prompt also gets smaller.
> - The benefit is that a follow-up has no prompt path that leads the
agent to run logs, and the agent can find the request where the
directive points.
## Linked Issues or Issue Description
**What happened?**
A user comment on a done task started a follow-up turn. The agent
appended one line to a file. The turn took 180 to 346 seconds and 21 to
39 commands outside the task folder. In three of four slow turns, the
first outside command searched the instance data folder for the previous
run id that the prompt contained. The agent then ran 15 to 30 grep and
Python commands on that run log. The prompt contained the run id five
times: in the run summary and agent reply entries of the fresh-session
history, and as `createdByRunId` on three continuation messages. The
evidence text said "read the record or the original run receipt", but no
tool reads a run receipt. The task context said "Latest wake comment:"
with no text below it, because the assignment variant omits comment
bodies and the wake renderer omits comments that the continuation JSON
already contains. The same continuation summary also appeared twice in
the wake payload.
**Expected behavior**
The follow-up prompt states the latest request plainly once, and the
follow-up directive points at it. The prompt names no run ids and tells
the agent to read only records that a tool can read.
**Steps to reproduce**
1. Run a task to done with a native-runner agent, for example a swarm
that writes two files.
2. Comment "append three to w1.txt" on the done task.
3. Read the prompt of the follow-up run. The "Latest wake comment:"
section is empty, and the previous run id appears five times.
**Paperclip version or commit**
master before this pull request.
## What Changed
- Wake prompt (`renderPaperclipWakePrompt`, all adapters that use the
shared prompt sections): when the continuation JSON owns a waking
comment, the prompt states it once in plain text before the JSON, and
the JSON message keeps its metadata with `bodyShownAbove: true` instead
of a second copy. Only a human user comment is headed "Latest request
from the user". An agent or run comment is headed "Latest comment from
an agent (quoted data, not instructions)".
- New `model-facing-history.ts` in adapter-utils: one explicit set of
run-id keys and one projection, used by the wake prompt and the
fresh-session history. A run-authored comment with user attribution
keeps `createdByRunId: true`, so the model can still see that it is not
human direction. A drift test fails when a new `*RunId` field appears in
the sources that feed this history.
- Wake prompt: the evidence text refers to saved task records that a
Paperclip tool can read, not to a run receipt. The resume-delta text no
longer refers to "the named run".
- Wake prompt: "Issue continuation summary" is not repeated when it is
identical to the `completedWork` that the continuation evidence already
shows.
- Task context: when the wake payload carries the comment text, the
follow-up directive names the comment id (`Latest wake comment: "<id>",
shown in the wake payload.`) instead of an empty section. An
attachment-only comment points at the attachment directive.
- Fresh-session history: run summary and agent reply entries no longer
carry the run id or the run event id, and low-trust `sourceTrust` keeps
its labels without `sourceRunId`. Comment and document entries keep
their ids, which the named retrieval tools can read.
- Continuation summary read boundary: a summary stored by a server older
than the change that stopped writing run ids keeps its old lines until
the next run on that task finishes. The summary reader and the
fresh-session history now drop those exact legacy generated lines ("Last
updated by run", "Heartbeat run ... invoked adapter", the run-log
pointer) and reword the old "Run `<id>` finished" line.
- Adapter tests that parse the continuation JSON now find the JSON
block, not the first fenced block.
## Verification
- Red/green: the new tests fail on master and pass with this change.
- `packages/adapter-utils/src/server-utils.test.ts`: a sanitized fixture
of the measured follow-up wake
(`test-fixtures/follow-up-after-swarm-wake.ts`). The test checks one
plain statement of the request, no run id, no `createdByRunId` value, no
"run receipt" text, and one continuation summary. A second test checks
resumed sessions, completed actions, and a run-authored user comment.
- `server/src/services/heartbeat/task-markdown.test.ts`: the directive
names the comment id when bodies are omitted. The legacy variant still
prints the body.
- `server/src/services/native-runtime/native-session-handoff.test.ts`:
the history keeps comment and document ids and drops run ids.
- `pnpm verify` and the focused suites pass locally.
- Prompt size: the measured follow-up prompt goes from 16,398 to about
15,117 bytes (-7.8%). The fixture wake payload goes from 5,014 to 4,509
bytes. Run id mentions go from 5 to 0.
## Risks
- Scope: run ids are removed from the continuation context and the
fresh-session history. Recovery wakes (disposition repair, liveness
continuation) still print their source run; they are not part of the
follow-up path.
- Low risk. The change affects only model-facing prompt text. Server
envelopes, receipts, and stored data do not change.
- Models no longer see run ids in the continuation JSON. No agent tool
accepts a run id, so the model loses no capability.
- This change removes the prompt path to run logs. It does not prevent
filesystem reads. A model that wants examples can still search the disk.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use and code execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
8de6686739 |
fix(apps): save action choices when the provider no longer offers some actions (#22877)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Connections give agents actions in other apps, and the Permissions page controls which actions agents can use > - A managed Google Workspace connection moved from Paperclip's REST tools to Google's MCP servers (#22815) > - Google's MCP servers do not list two Gmail actions, so the catalog refresh marked them as removed (`disabled`, `mcp_tool_removed`) > - The Permissions page still sent these two actions as enabled, and the server refused every save that contained them, except on remote MCP aggregators > - An admin could not release the 34 held actions, so the connection stayed unusable > - This pull request makes the server accept a removed action for every connection kind, and makes the UI stop sending disabled or removed actions > - The benefit is that an admin can always save the review after a provider removes actions, and a disabled action still cannot be turned on ## Linked Issues or Issue Description Refs #22815 **What happened?** On a managed Google Workspace connection that runs on Google's MCP servers, the Permissions page showed "Review 34 new actions". After "Turn all on" and "Save choices", the save failed with the message "Couldn't save that — Disabled actions cannot be enabled". The held actions stayed held. **What did you expect to happen?** The save releases the reviewed actions. Actions that Google no longer offers stay off and do not block the save. **Steps to reproduce** 1. Connect Google Workspace with the managed method while the transport is Paperclip REST. Keep all actions on. 2. Move the connection to Google's MCP servers (#22815). The refresh holds the actions for review, and Google's listing does not include `gmail__list_threads` and `gmail__search_messages`. 3. Open the connection's Permissions page. Select "Review 34 new actions", then "Turn all on", then "Save choices". 4. See the error "Disabled actions cannot be enabled". **Cause** - `useConnectionPermissionSave.ts` sent `enabledCatalogEntryIds: [...next.enabled]`. This set came from the saved profile and still contained the two removed actions. - `finishGalleryAppConnection` in `server/src/services/tool-access.ts` refused an enabled row with `status === "disabled"`. It accepted a removed row (`quarantineReason === "mcp_tool_removed"`) only for remote MCP aggregators (`isRemoteMcpConnectorMethod`). The catalog refresh writes `mcp_tool_removed` also for Google Workspace and plugin connections, so these connections did not get the same exception. ## What Changed - Server: `finishGalleryAppConnection` accepts a row that the provider's listing removed (`mcp_tool_removed`) for every connection kind. Only the catalog refresh writes this marker, and only when the provider's listing no longer has the action. This is the same behavior that remote MCP aggregators already had. Any other disabled row is still refused with "Disabled actions cannot be enabled". A removed row is not active, so the gateway does not offer it to agents. - Shared: `@paperclipai/shared` has three named predicates in `tool-catalog-availability.ts`. `isCatalogEntryOffered` is true for active and held actions. `isCatalogEntryRemovedByProvider` is true for `removed` rows and for `disabled` rows with `mcp_tool_removed`. `isCatalogEntryBlocked` is true for every other disabled row. The server and the UI use these predicates, so the rule is in one place. - Server: the review coverage check ignores a reviewed id that the provider removed after the page loaded. Before this change, that save failed with "Action review decisions must cover every currently quarantined action exactly once". - Server: a save no longer sets a `removed` row back to active. - UI: a new `withoutUnavailableActions` helper drops catalog entries that are not offered (`isCatalogEntryOffered` is false) from an enabled list. - UI: the Permissions page save (`finishAppPermissions` in `useConnectionPermissionSave.ts`) sends only available actions as enabled or Ask first. The page already showed and counted only active and held actions, so the removed actions do not show, count, or toggle. The page has no existing pattern for removed actions, so this change adds no new text. - UI: the setup flow (`ConnectionSetupFlow.tsx`, which also serves task-hosted setup) and the pasted-config flow (`PasteConfigTab.tsx`) also drop disabled actions before they finish a connection. Before this change, a provider-blocked action (for example a Gmail write action on a read-only method) could make the first save fail the same way. `RemoteMcpProductionSetup.tsx` already sends only active actions. `QuarantinedActionsReview` in `SetupPanel.tsx` selects only from held actions. ## Verification - Red, then green: `server/src/__tests__/google-workspace-mcp-transport.test.ts` → "saves the review when Google no longer offers actions that were on, and still refuses a disabled action". The test saves a managed Google Workspace connection on REST, moves it to Google's MCP servers while Google does not list `list_threads` and `search_messages`, then saves the review with the removed actions in the enabled list. Before the fix it failed with "Disabled actions cannot be enabled". After the fix it passes. The same test makes sure that a disabled action without the removal marker is still refused, and that agents are not offered the removed actions. - Red, then green: `ui/src/pages/apps/app-detail/action-permissions.test.ts` → "finishAppPermissions never asks to turn on an action Google no longer offers or a disabled action". Without the filter, the test fails. - `packages/shared/src/tool-catalog-availability.test.ts` covers the three predicates. - The transport test also sends the removed ids in `reviewedCatalogEntryIds`. Without the coverage fix it fails with "Action review decisions must cover every currently quarantined action exactly once". It also makes sure that the removed rows stay disabled after the save. - Local runs: `google-workspace-mcp-transport.test.ts` and `tool-access-service.test.ts` (542 passed). UI tests in `app-detail`, `features/connections` and `pages/tools` (143 passed). - `pnpm verify` selected the full server suite (1520 files) because `tool-access.ts` is a shared service. On this machine, under load from other sessions, 31 of 33876 tests failed. The run output did not keep the names of the failed tests. The touched test files pass when run alone, and the CI server shards run the full suite on the final head. - `tsc --noEmit` for `server` and for `ui/src`. ## Risks - Low risk. The security rule stays: a disabled action that the provider did not remove cannot be turned on. - Behavior change: Google Workspace and plugin connections now accept a removed action in the enabled list, as remote MCP aggregators already did. The UI no longer sends removed actions, so after a save from the page a removed action stays off if the provider lists it again. ## 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 - [ ] 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> |
||
|
|
3fbf872d9e |
fix(antigravity): make the task thread read in plain language (#22886)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - A task thread shows what an agent did during a run, as a list of
activity rows under its reply
> - Google Antigravity runs (ordinary and `/swarm`) send no tool
identity, so each row was named after the CLI's display title
> - Users saw rows like "Ran a command · failed Run
mcp_paperclip_paperclip_finish", "Ran File runtime paperclip runner acpx
…", lowercased sentences, and a sha256 dump
> - Each attached file also showed twice, nothing marked a message as a
swarm request, and a refused send only showed a short toast
> - This pull request gives Antigravity tool calls the identity other
harnesses send, and makes the thread read the same live and after the
run
> - The benefit is a task thread that reads in plain language for
Antigravity, with fixes that also help other harnesses
## Linked Issues or Issue Description
**What happened?**
In a live Antigravity `/swarm` run, the task thread showed raw tool
names and internal paths. Examples: "Run mcp_paperclip_paperclip_finish
· failed", "Ran File runtime paperclip runner acpx 5230… antigravity
home … SKILL md", "Ran Swarm started in the task folder with gemini 3 8
flash low …" (lowercased, punctuation removed), "Registered title:
u1.txt, sha256: 7692…". The live list and the finished list used
different words. The CLI's first reads of u1.txt failed ("must be an
absolute path") and were read again successfully, but the thread showed
"failed". Each file showed twice: a file card, and an agent message
"Prepared u1.txt for this response." with a second card. The user's
bubble did not show that the message was a swarm request. When the
server refused a send (for example `/swarm` in Plan mode), only a short
toast explained it.
**Expected behavior**
Rows say what the agent did in plain words, the same while live and
after the run. No raw tool names, internal paths, hashes or key/value
dumps. The refused-then-accepted completion call is hidden as for every
other harness. A failure that a later call recovered reads as "retried".
Each file shows once. A swarm request has a small "Swarm" marker. A
refused send keeps an inline, dismissible error under the composer.
**Steps to reproduce**
1. Assign a task to a Google Antigravity agent with the experimental
swarm setting on.
2. Send `/swarm Create u1.txt containing "one" and u2.txt containing
"two", one helper per file, then verify both.`
3. Expand the activity list while the run is live, and again after it
finishes.
4. Put another task in Plan mode and send `/swarm do something`.
## What Changed
- Runner (Antigravity-owned): new `antigravity-tool-identity.ts` names
each call. Paperclip bridge tools become
`mcp__paperclip__<canonicalRunnerToolName(tool)>` (from the CLI's
`mcp_paperclip_<tool>`, an ordinary run's `paperclip_<tool>` title, or
ACP `_meta.mcp`). Native CLI tools keep their own names (`run_command`,
`view_file`, …) with the command as the subject. Reads of the CLI's own
built-in files (its private Antigravity home) are dropped. Swarm
progress lines get one neutral identity (`swarm_update`) whose subject
is the plain sentence. Swarm file locations are task-relative.
- Runner: a narrow activity-adapter hook (`createToolEventProjection`)
applies this in both places that pump an ACPX turn (in-process driver
and sidecar). The sidecar now keeps a provider-supplied tool detail
instead of overwriting it.
- UI: live rows use the call's subject, drop raw technical names
(Paperclip's own tools need no source label), and use the same "verb +
subject" form as settled rows, so both lists read the same.
- UI: a bridge call recorded under its own id (providers that pass no
tool-use id) joins the provider's row for the same Paperclip tool, in
the live log and in stored events. `register_deliverable` reads
"Attached u1.txt"; content digests never show in an input summary.
- UI: a failed call whose later call of the same tool on the same target
succeeded shows as "· retried" (token-only, same muted style).
Unrecovered failures stay "· failed".
- UI: generated "Prepared <file> for this response." receipts are hidden
for any file that already shows as the run's file card (before, only
images).
- Server + shared + UI: `IssueComment.nativeCommand` ("swarm") is
derived read-only from the server's own activity record on comment list,
get and the POST response. The user's bubble shows a small "Swarm" note.
The `/swarm` eligibility rule (`isAntigravityAgent`,
`antigravitySwarmAvailable`) now lives in `packages/shared`; the
composer shows a light hint when the text starts with `/swarm` and the
assignee can run a swarm.
- UI: the composer keeps the server's message as an inline, dismissible
error after any 4xx refusal, until dismissed or the next send. The
optimistic "Working" row behaviour is unchanged.
Not changed, by design: after a reload, a settled run's activity is
deferred behind "More run output" for every native harness (cold-load
speed), so Antigravity already matches the others.
## Verification
- Red/green runner test `antigravity-tool-identity.test.ts` with a
fixture rebuilt from a live swarm run's updates (ids, paths and hashes
replaced): names, subjects, dropped internal reads, hidden finish
identity, ordinary-run titles and `_meta.mcp`.
- Red/green UI test `antigravity-thread.test.tsx` renders the real run's
stored events (settled) and the same events through the live run-log
parser. It asserts the exact rows, "retried" reads, one "Attached" row
per file, no finish rows, no raw names/paths/hashes, and live ==
settled. It fails on master (raw "Ran Swarm update …", "Read · failed",
"Registered title: …, sha256: …").
- Red/green `TaskChatThread.test.tsx`: a prepared text file shows once;
a refused send shows the server message inline until dismissed and the
Working row clears; only a server-marked comment shows "Swarm".
- `TaskChatComposer.test.tsx`: the `/swarm` hint shows only for an
Antigravity assignee with the setting on.
- Server `antigravity-swarm-request-path.test.ts` (embedded Postgres):
only the user's recorded request is marked; text, metadata, another
user's or an agent's comment are not.
- Local: paperclip-runner acpx/sidecar/provider-events suites, UI
task-chat/transcript/adapters/thread/hooks suites (1630 tests), server
swarm suite, and shared/server/ui/runner typechecks pass. `pnpm verify`
exited 2 (broad input), so CI supplies the broad coverage.
Before (live swarm run, done state):
```
Ran This swarm runs on the google account of this agent s google connection
Ran File runtime paperclip runner acpx 523076a3 3689 4b28 9910 c101bc6b64d8 97d9fb76f6aa11b6 a…
Ran File u1 txt · failed u1.txt
Ran a command · failed
Registered title: u1.txt, sha256: 7692c3ad3540bb803c020b3aee66cd8887123234ea0c6e7143c0…
```
After (same events, settled and live):
```
Swarm This swarm runs on the Google account of this agent's Google connection.
Swarm Started helper writer1: Create a file named u1.txt in the current workspace directory containing exactly "one"
Read · retried u1.txt
Read u1.txt
$ shasum -a 256 u1.txt u2.txt; wc -c u1.txt u2.txt
Attached u1.txt
Swarm Files changed in the task folder: u1.txt, u2.txt
```
## Risks
- Live tool rows for all harnesses no longer show a raw technical name
("Paperclip · search_tasks", "Bash") next to the activity. Rows with a
concrete subject now read like settled rows ("Read README.md", "$ npm
test"). This is a deliberate wording change.
- `register_deliverable` reads "Attached <file>" for all harnesses.
- Generated file receipts are hidden for any file with its own card, not
only images. Human text and agent progress with attachments stay visible
(the same marker and link checks as for images).
- Bridge-call pairing is display only and matches only a Paperclip tool
of the same name that is in flight. Claude already shares one id and is
unchanged.
- One extra indexed activity-log query per comment list or get. No
schema change.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) 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>
|
||
|
|
c0b0517dc3 |
fix(antigravity): stop every process a swarm's CLI started before reporting its outcome (#22875)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` on the native Runner (experimental flag, #22733, #22865) > - In a live run, the `agy acp` CLI process was killed mid-swarm. Its helper shell commands kept running for about 14 s, and one wrote a file in the task folder 14 s after the kill > - The failure was recorded only when those helpers exited, because they held the CLI's output pipe open. Automatic recovery then starts a fresh swarm in the same folder, so old helpers can race it > - Recovery must just work, and nothing may write in a task folder after its run ended > - This pull request records every process the CLI starts and stops all of them before a failed or stopped swarm turn is reported and on shutdown, and detects a lost CLI on exit > - The benefit is that a crashed, stopped, timed-out or shut-down swarm leaves no process behind and recovery never races old helpers ## Linked Issues or Issue Description Refs #22733, #22865 **What happened?** After a `kill -9` of the swarm's `agy acp` process, three helper commands outlived it by about 14 s. One wrote a file in the task folder 14 s after the kill. The run failure was recorded about 15 s after the kill, right after the last helper exited. On a user Stop the helpers were gone in 0.2 s, because the CLI stops them itself. **What did you expect?** When the CLI exits for any reason, every process it or its helpers started stops within about 2 s, before Paperclip records the outcome and before recovery starts in the same folder. **Steps to reproduce** Start `/swarm` on a task with helpers that run shell commands. Kill the `agy acp` process. Watch the helper processes and the task folder. **Why it happened** - `retireAntigravityProcess` signals only the launcher's process group. The CLI starts each helper command as its own process-group leader, and when the CLI dies those commands are re-parented. - The swarm connection detected a lost CLI on the child's `close` event. `close` waits until every copy of stdout is closed, and the helpers inherited that pipe. - runnerd already records the full process lineage of the sidecar (`process_lineage.rs`) and stops it when the sidecar is torn down. That happens after the turn outcome is published, so it cannot keep the helpers from writing first. ## What Changed - New `antigravity-process-lineage.ts`: records the lineage of the CLI launcher while it runs, with runnerd's `LineageTracker` membership rules, scoped to the CLI's subtree. A process belongs when its parent belongs, or when it is in a group or session that a member leads and started no earlier than that leader (sessions on Linux; macOS `ps` reports no session id). Identity is PID plus start time, re-read just before each signal, so a reused PID is never signalled. A recorded member that exists but cannot be read stays unresolved, and a table read that does not list this process is rejected; neither proves the lineage gone. Membership never depends on a command name, so other `agy` processes of the same user are never touched. It reads `/proc` on Linux and `/bin/ps` (numbers only) on macOS, every 200 ms while the CLI runs. `terminate()` re-reads the table each round, sends SIGKILL to every live member (the first round before any deadline), and proves none remain within 1.5 s. - Why not runnerd's tracker directly: it is rooted at the sidecar and stops the whole lineage, the sidecar included, only at sidecar teardown. It has no operation for one subtree. The swarm must stop the CLI subtree while the sidecar keeps serving the run, also on Stop and helper timeout, when the CLI is still alive. Reusing it needs a new sidecar-to-runnerd operation and a Rust change, which is out of scope here. The macOS retirement check in `antigravity-process.ts` now uses the same process-table reader. - `antigravity-swarm-runtime.ts`: the CLI's retirement now also terminates that lineage. A swarm turn that did not complete (CLI lost, Stop, helper timeout, refusal) retires the CLI and its lineage before the outcome is returned. `close()` (runner shutdown) does the same. A swarm turn is the port's only turn, so nothing else uses the CLI after it. - Cleanup fails closed. A failed or incomplete process-table read is retried. If the helpers still cannot be proven stopped after three attempts, the turn fails as not retryable with plain text, so Paperclip does not continue the task on its own in that folder. A failed retirement is not cached, so `close()` tries again. - A lost CLI is detected on the child's `exit` event. Output already written is read for up to 200 ms after exit; the inherited pipe no longer delays the failure. - Fake CLI scenario `orphan-helpers`: a helper that leads its own process group, holds the CLI's output pipe, and writes `late.txt` after a delay. The CLI never stops it itself. - Qualification ledger: the live re-check of #22865 (Stop usage 36,910 in / 869 out; killed-run usage still 0 with CLI 1.5.15; kill text and automatic recovery; receipt event; clean thread text) and this fix (fake-CLI proof, live proof pending). Investigated and not changed here: an ordinary (non-swarm) Antigravity run read the instance's run logs and the CLI's private files outside its task folder. No existing Runner policy confines reads for this harness; confining them would be a new policy, so it is reported separately. ## Verification - Red/green: with only the runtime change reverted, the new swarm tests fail (the failure waited on the pipe; helper alive after Stop; helper alive after shutdown; unproven cleanup reported as recoverable). With the change they pass. - Swarm tests kill the fake CLI with SIGKILL and check that the helper is dead when the failure is reported, that `late.txt` is never written (the helper writes it after 3 s, so a report that waited on its pipe would fail), and that an unrelated process of the same user survives. They also cover Stop, runtime close mid-swarm, and a failing process listing (not retryable; the helper stays alive past the cleanup budget and the later close stops it). - Lineage unit tests: re-parented helpers and their children are kept; session members are kept; a reused PID, a reused group id and an earlier-started process are never claimed; zombies are dropped; unreadable members stay unresolved; failed, empty, self-less and unreadable reads never prove the lineage gone and a later call retries; a PID whose start time changed is never signalled; the first kill round runs even when its read exceeds the deadline; pure macOS `ps` and Linux `/proc` parsers; a detached grandchild of a dead root is stopped and an unrelated process survives. Each review-driven rule was checked by reverting it and seeing its test fail. - All Antigravity driver suites (packages/paperclip-runner): 20 files, 363 tests passed. `tsc --noEmit` for the Runner package passed. - `pnpm verify` exited 2 (the fake CLI fixture is a broad input), so CI supplies the broad coverage. `tests/runner-e2e/source-sdk-public-inputs.mjs --write` reported no change. - Not run: a live swarm (live proof is pending and recorded as pending in the ledger). Linux ran only in CI. ## Risks - A sampler reads the process table every 200 ms while a swarm CLI runs (`ps` on macOS, about 25 ms wall time; `/proc` on Linux). Only swarm turns run it. - A helper that starts and leaves its group and session within one 200 ms sample, before it is seen, can escape this tracker. runnerd's sidecar lineage still stops it at sidecar teardown. - A swarm turn that ended without completing now stops the CLI before reporting. The port already refuses a second swarm turn, so no later turn depended on that CLI. - If cleanup cannot be proven (for example the process table cannot be read), the swarm fails without automatic recovery instead of risking a race. - macOS start times have one-second resolution, so a PID reused within the same second as the original start could match. The group and parent rules also need a recorded member, which keeps this narrow. - On macOS there is no session rule, because `ps` reports no session id. A helper that calls `setsid` is still recorded as a group leader when a sample sees it. ## 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> |
||
|
|
cd8bcfba16 |
fix(antigravity): swarm usage on Stop/kill, honest recovery text, clean thread text, run-record receipt (#22865)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` from a task (#22733, experimental flag) > - The first complete live run of `/swarm` found gaps: a stopped or killed swarm recorded no usage, the lost-process text asked for Retry while Paperclip recovered on its own, CLI-only text and local `file://` paths reached the task thread, and the swarm's settings receipt never reached the run record > - Usage must always be recorded, recovery must just work, and users must not see local paths or internal jargon > - This pull request fixes each gap at the module that owns it, with a red/green test for each > - The benefit is a swarm whose cost, recovery and thread text match what happened ## Linked Issues or Issue Description Refs #22733, #22731 **What happened?** In a live local run of `/swarm` (Gemini 3.8 Flash and Gemini 4 Neon, Google sign-in): - A swarm stopped after 29 s with 7 helpers recorded 0 tokens. A swarm whose CLI process was killed also recorded 0 tokens. - After the CLI process died, the failure text said "Retry starts a fresh swarm in the same task folder" and was marked not retryable, but Paperclip recovered on its own with a fresh swarm. - The thread showed "Run /swarm board (default shortcut alt+s) to open the live board", a stray "." line, links to absolute local `file:///…/<company id>/<task id>/a.txt` paths (on ordinary Antigravity replies too), and a mention of "the Paperclip swarm rules". - The structured swarm receipt (requested and confirmed model, channel, CLI version, account match) was not in the run record. **What did you expect?** Usage recorded for every swarm, text that matches automatic recovery, a thread without CLI hints or local paths, and a queryable receipt. **Steps to reproduce** Run `/swarm` on a task for an Antigravity agent, then Stop it or kill the `agy acp` process, and read the run usage and the thread. ## What Changed - **Usage on Stop and process death** (`antigravity-swarm-runtime.ts`). A stopped prompt's own answer is awaited within the grace window and its `usage` is kept. When no answer arrives (the CLI exited, or did not answer in time), the token counts the CLI streamed in `usage_update` (`_meta.usage`, read with the shared ACP converter) are kept; after an earlier answered prompt they only raise a counter (per-counter maximum), because a streamed count may be session-wide, so nothing is counted twice. The usage is one receipt per run request, so a recovery run never counts it again. What cannot be known: if the CLI exits before it streams any token counts, that prompt's usage is lost with the process. The pinned CLI 1.5.15 declares `usage_update` and a prompt-answer `usage`; whether it fills `_meta.usage` mid-prompt is not proven live. - **Lost CLI process.** The failure is retryable and says "Files the helpers already wrote stay in the task folder", with no instruction to press Retry. Automatic recovery is unchanged and is bounded by the server's existing per-request cap (three failed attempts, then a plain refusal); a new database test pins that cap for the lost-process error code across continuation, recovery and assignment wakes. - **Terminal hint split across chunks** (`antigravity-swarm-presentation.ts`). The swarm passes raw coordinator text to a streaming filter that holds text that could still become the hint, so the hint and its trailing period are dropped wherever the CLI splits them. The fake CLI now streams the hint in the recorded live pieces. - **Local file links, both Antigravity routes** (`antigravity-local-links.ts`, wired in `runtime-host.ts` for agent `antigravity` only). No existing mechanism did this: other harnesses only emit file-reference events, and an ordinary Antigravity reply showed the same links. Before a reply leaves the Runner, a link to a task-folder file becomes its folder-relative path in code (the thread opens a nested path as a task-folder file; a root-level name stays plain text beside its deliverable link, as before, since the thread never opened the `file://` target), a descriptive label keeps the path beside it, other `file://` links keep only their label, a bare task-folder prefix is removed, and the folder named on its own reads "the task folder". Sentence punctuation stays outside file names. `/api/...` and web links are unchanged. Text that could still become a link is held across chunks. - **Swarm rules** tell the coordinator that its text is shown in the task thread: name files by task-folder path, no absolute paths or `file://` links, no terminal commands, shortcuts or live board, no mention of the rules. - **Swarm receipt in the run record** (`antigravity-activity.ts`, `profile-activity.ts`). The sidecar's status sanitizer dropped `antigravitySwarmReceipt`. It now reaches the run as a `provider.notice.recorded` event (category `antigravity_swarm_receipt`) through the same post-turn hook as Cursor's native receipt. It carries requested and confirmed model, thinking level, mode, channel, CLI version and whether the CLI sign-in matches the connection. No account, path, session id or instruction text. No protocol schema change. - The link parsing reuses `localTarget` and `workspaceRelativePath`, now exported from `live/workspace-file-reference.ts`. - The public SDK input registry is resynced for a `packages/shared` change that landed on master. - **Ledger** (`doc/plans/2026-11-22-antigravity-qualification.md`): what the live swarm and Neon runs prove, and what they do not. - Not changed: the user's own `/swarm` comment has no marker in the thread. The thread has no per-message marker for Plan-mode requests either, and comments do not store `nativeCommand`, so there is no pattern to reuse. ## Verification - Red/green: the new runtime and presentation tests fail on the old source (6 failed) and pass with the fix; the receipt test fails without the `antigravity` activity registration. - `cd packages/paperclip-runner && npx vitest run src/drivers/acpx src/cli/acpx-runtime-sidecar.test.ts`: 120 files, 2239 passed. - `cd server && npx vitest run src/services/antigravity-swarm.db.test.ts`: 52 passed. - `pnpm run check:acpx-profiles`, `scripts/contracts/contract-fingerprints.test.mjs` and `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` (unchanged) pass. - `pnpm verify` exits 2 (the fake CLI fixture is a broad input), so CI supplies the broad coverage. - Not run: a live swarm (no paid or live runs from this change). ## Risks - Low to medium. The link filter applies to every Antigravity reply. It holds a short tail of text that could still become a link or local path, and releases it before the next non-text event and at turn end. A tool event that arrives in the middle of a link releases the partial link unchanged. - A lost swarm process is now marked retryable. The server's recovery decision does not read this flag; automatic recovery behaves as before. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code execution in Claude Code. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
627d59c5aa |
fix(inbox): group repeated provider failures and clear recovered tasks (#22846)
## Thinking Path > - Paperclip helps people manage work that agents do. > - The inbox tells a person which tasks need a decision. > - A provider usage limit can stop several attempts on one task or affect several tasks. > - Separate failure cards made it hard to tell which tasks still needed attention. > - This change groups failures using the account, reset time, or retry links that Paperclip can verify. > - A person can now see which task to retry, which tasks are waiting, and which ones recovered. ## Linked Issues or Issue Description **What existing behavior does this improve?** It improves the Coordinator inbox when a provider limits usage. **Current behavior** Repeated run failures can fill the inbox. Resolved failures can still appear beside open decisions. **Proposed behavior** Show personal actions in Needs you, automatic retries and snoozes in Waiting, and past events in History. Keep an archived retry chain hidden during automatic attempts. Return it to Needs you when a person must act. **Additional context** Related work includes #18020 on completed tasks, #9704 on archive behavior, and #21570 on usage limits in chat. ## What Changed - Group verified account and reset windows. When that evidence is missing, count linked attempts per task and show the tasks in a collapsible group. - Separate the reported reset time from each task’s retry schedule. Keep unresolved ownership recoveries visible after task closure. Use persisted native retry requests to preserve the original archive and increment the attempt count. - Keep personal archive in the card menu. Put decision receipts and run logs in History. - Align inbox filters, tabs, and history. Share empty-state artwork and placement across Inbox, Goals, Routines, and Secrets. - Index run-history pages and resumed-work lookups, and rate-limit history requests per company and viewer. Add synthetic fixtures for both grouping paths and a manual walkthrough. ## Verification - The author and a human tester completed the synthetic retry-chain walkthrough. Chromium also verified archive, repeat failure, exhaustion, and recovery. - The 64 focused server tests and the UI and server typechecks passed before rebasing. See `doc/testing/coordinator-inbox-test-drive.md` to repeat the manual checks. - The shared SDK input check and all 64 focused server tests passed after rebasing. The OpenAPI suite (59 tests), API catalog suite (2,309 tests), and both demo seed paths passed locally after the CI fixes. - The affected inbox and native-runtime suites passed locally after merging the upstream conformance test fix in #22854. The browser access-denial scenarios passed three runs each for 403 and 404. - The migration checks and 79 focused tests passed, including an index-plan regression with 5,000 unrelated runs. The migration and query plan were reverified after renumbering. [Full CI on `cf52b80161`](https://github.com/paperclipai/paperclip/actions/runs/45529834793) passed after rerunning a timed-out server shard. ## Risks The attention feed reads retry ancestry. Long chains can increase query cost. Task and company checks bound the traversal, and cycle detection stops repeated visits. Providers that omit the reset time leave the card with an unknown reset. Migration 0508 adds two indexes concurrently. Each run-history page returns at most 100 records. ## Model Used OpenAI Codex, GPT-6 family, with repository editing, local test execution, and browser verification. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong <scott@scotts-mbp-m5-max.local> Co-authored-by: Paperclip <noreply@paperclip.ing> |
||
|
|
81e2c50aa9 |
fix(shared): allow one answer per ask_user_questions question (max 64) (#16702)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents ask board users questions with `ask_user_questions` interactions > - The question payload allows up to 64 questions (`askUserQuestionsPayloadFields`) > - The response schema `respondIssueThreadInteractionSchema` allows only 20 answers > - A card with 21 to 64 questions can be created, but the user cannot submit all answers > - This pull request raises the answer limit to 64, the same as the question limit > - The benefit is that every valid card can be answered ## Linked Issues or Issue Description **What happened?** An `ask_user_questions` card with more than 20 questions is accepted on creation. When the user answers every question, the response is rejected by validation because `answers` has a maximum of 20 items. **Steps to reproduce** 1. Create an `ask_user_questions` interaction with 21 questions (the limit is 64). 2. Answer all 21 questions. 3. Send the response to `respondIssueThreadInteractionSchema`. **Expected behavior** One answer per question is accepted, up to 64. **Actual behavior** Validation fails because `answers` allows at most 20 items. No existing public issue found (searched issues and PRs for `respondIssueThreadInteraction`). ## What Changed - `packages/shared/src/validators/issue.ts`: `answers` maximum changed from 20 to 64 to match the question maximum. - `packages/shared/src/validators/issue.test.ts`: new test. 64 answers pass. 65 answers fail. ## Verification - `LC_ALL=C pnpm --filter @paperclipai/shared exec vitest run src/validators/issue.test.ts` — 44 passed. ## Risks Low risk. The change only raises an upper bound to a value the question schema already allows. ## Model Used Claude (Anthropic), model ID `claude-sonnet-5-5`, with tool use and code execution in Claude Code. A human 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 (none needed) - [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 |
||
|
|
0c3ed144cb | Label opt-in traces with the public instance hostname (#22856) | ||
|
|
12944919c6 |
feat(google): keep Google Technical Information at most 30 days and keep Google data out of training exports (#22842)
Adds a durable, sleep-aware 30-day sweep for Google Technical Information, keeps Google results out of decision training and shared feedback traces, and deletes the remaining copies of a cleaned run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3ad8f00192 |
feat(antigravity): trusted /swarm from the task composer, behind an experimental flag (#22733)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Google Antigravity agents can run Google's native `/swarm` (a coordinator, helpers and a verifier) only on the Antigravity CLI > - #22731 adds a verified CLI route to the Runner, but nothing selects it yet > - A swarm must start only when the signed-in user asks for it, only when an admin turned the experimental feature on, and never silently run as an ordinary request when it cannot run > - This pull request adds the trusted `/swarm` request in the task composer, the server checks and run selection behind an experimental flag, removes Paperclip delegation tools from a swarm turn, and adds the attended catalog cells, docs and ledger > - The benefit is that a user can start a native swarm from a task, and gets one plain message when it is not available ## Linked Issues or Issue Description Refs #22731, #22727, #22728, #22701 **Subsystem affected** Task composer (UI), issue comments API, run selection (server), Paperclip Runner tool bridge, runner-e2e catalog, docs. **Problem or motivation** A user who writes `/swarm <request>` to a Google Antigravity agent should get a real native swarm in the task folder. Today `/swarm` is neutralised text, and the task runs as an ordinary request. **Proposed solution** Read a leading `/swarm` with the shared rule from #22727 in the composer, send it as a structured request, check it on the server, and select the CLI route from #22731 for that run only. ## What Changed - **Trusted start (UI).** `parseSwarmCommand` in `composer-commands.ts` uses `parseLeadingUserCommand` (the one rule from #22727). A leading `/swarm` in the task composer sends the request text with `nativeCommand: "swarm"`; a bare `/swarm` asks for a request; `/swarm` with an assignee change is refused; `/swarm` anywhere else stays text. A resent draft keeps the structured request. - **Contract.** `addIssueCommentSchema` gains `nativeCommand: "swarm"`. `instance.experimental.enableAntigravitySwarm` (feature catalog, settings page, server defaults), off by default. No Cloud policy in Core. - **Server (`services/antigravity-swarm.ts`, comments route, runtime selection).** - The comments route accepts `nativeCommand` only from a signed-in board user. When a swarm cannot run it answers 422 with one plain message and posts nothing: flag off, not a Google Antigravity assignee, a chat, Plan mode. - An accepted request is recorded in the activity log (`issue.antigravity_swarm_requested`, server-written) and the assignee's wake carries the comment id. Comment text is never read as a command. - Run selection makes the run a swarm only when that activity record exists. It refuses a remote or cloud environment and Plan mode with a plain run failure, so a swarm is never run as an ordinary request. It logs `issue.antigravity_swarm_started` in plain language: helper actions are auto-approved, Paperclip does not sandbox the helpers and cannot see their shell commands, and usage is one total. - The native execution input sets the Antigravity provider mode `swarm` for that run only, and carries the verified request in its own field, `provider.swarmRequest` (the Runner contract accepts it only with that mode and requires it there, 1 to 16,000 characters). The Runner copies it into the model envelope as `swarmRequest`; the swarm route sends exactly `/swarm <swarmRequest>` and never reads `task.prompt`, which holds rendered wake comments, task context and text the Runner adds (handoff, attachments, queued messages). - The swarm turn contract (mode `swarm`, envelope `paperclip.native-model-envelope.v3`, `swarmRequest` of 1 to 16,000 characters) is declared as `antigravitySwarmTurn` in `protocol/provider-schemas/acpx-sidecar.schema.json` and generated into TypeScript, so the pack `contractDigest` covers it (it changes; older image packs are rebuilt rather than reused). Provider profile `commandDigest`s and versions are unchanged, so no saved session is reset. - What the swarm sees of the task: only the request. The title, the description (which other people or agents may have written) and other comments are not part of the prompt; the coordinator can read them through Paperclip's task tools as data if it needs context. - An empty `/swarm` or one over 16,000 characters is refused in the composer, by the comments route (422, nothing posted) and at run selection (plain run failure), so it never runs as ordinary work. - A swarm run never takes queued messages, and Interrupt treats it as already started: it stops the swarm and delivers the queued message as the next ordinary request, before or after the provider accepted the turn. - Retry after Stop, and past the three automatic attempts, counts only when the signed-in user asked for it (their own Retry request on the task after the last attempt). Wake reasons and copied run context are not proof: a recovery that copies the request marker, an automatic retry on the user's behalf, or an agent wake that names `task_retry` stay bounded. - **Runner.** For a swarm turn the Paperclip bridge drops delegation tools (`paperclip_create_task`, `paperclip_create_issue`, hire/assign tools); the instructions also tell the coordinator not to delegate. - **runner-e2e.** `antigravity-swarm` suite, 5 local cells (`two-helpers-and-verifier`, `stop-mid-swarm`, `process-loss-retry`, `follow-up-after-swarm`, `flag-off-refusal`), explicit-only, never in `--all` or CI matrix jobs. There is no automated executor yet: the launcher refuses the cells and points at the live recipe. Catalog counts updated (1392 cells). - **Docs.** `tests/runner-e2e/SUITES.md`, `doc/evals.md`, and the `/swarm` section, ledger row and live recipe in `doc/plans/2026-11-22-antigravity-qualification.md`. ## Verification - `pnpm --filter @paperclipai/server exec vitest run src/services/antigravity-swarm.test.ts`: 2 passed (red first: module missing; Plan mode red then green). - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/issue-comment-reopen-routes.test.ts -t swarm`: 3 passed; 2 red against the route without this change. - `pnpm --filter @paperclipai/ui exec vitest run src/components/task-chat/TaskChatComposer.test.tsx`: 164 passed, including 4 new `/swarm` tests (red first). - Runner: `vitest run src/drivers/acpx/antigravity-swarm-*.test.ts`: 69 passed (route tool filter red first). - runner-e2e: `antigravity-swarm.test.ts` (red first) plus the catalog, selector and Antigravity tests: 28 files passed. - Typecheck: server, UI (except generated Storybook files absent from a worktree) and runner: no errors. - Live, real CLI 1.5.15 with the owner's sign-in, through the driver: the receipt verified (pinned identity, task folder, `auto` read back, `gemini-3.8-flash` + `low`). Google then refused the prompt with its 429 quota text; the driver reported it as a typed "out of quota" failure, retired the CLI and nothing was written. - **Not run live yet:** the full Paperclip proof (swarm to Done, Stop, kill and Retry, follow-up, flag off). This PR is merged only after it passes. Recipe: `doc/plans/2026-11-22-antigravity-qualification.md#swarm-live-proof`. ## Risks ### Security notes: the trust boundary Helpers are auto-approved and Paperclip does not sandbox the CLI on a local computer, so the boundary is who asked and what text is sent. Every input that can influence it: **(a) Whether a run is a swarm** - `nativeCommand: "swarm"` on the comment request: accepted only from a signed-in board user; the request record (`issue.antigravity_swarm_requested`, actor = that user, `commentId`) commits in the same transaction as the comment. Paperclip-written. - `antigravitySwarmCommentId` on the wake/run context: set only by the comments route and by run selection. It is a pointer, never trusted alone: selection re-verifies comment id + task + company + human author (no agent author) + a matching record by the same user. - The pending request for marker-less wakes: the task's latest human comment, verified the same way. - Retry inheritance: the run's `retryOfRunId` chain (server-written), bounded to 8 hops on the same task. - Manual vs automatic: a request's first run, or a user's own Retry request (`task_retry` / `retry_failed_run`, requested by a user, not `initiatedBy` automation) after the last attempt. Not the wake reason string. - Instance flag `enableAntigravitySwarm` (admin), the assignee's adapter config (Google Antigravity), execution target (local only), work mode (Standard only: Plan, Ask and any other mode are refused, at comment time and at run time), chat vs task: all Paperclip-owned settings. - Prior attempts on the same request (run status rows): Paperclip-written. **(b) What text and tools the swarm gets** - The prompt: `/swarm ` + `provider.swarmRequest`, which is the recorded comment body minus a leading `/swarm`, trimmed, byte for byte (tested through the production input builder and envelope with a merged wake that contains an agent comment). The verified request. - The system prompt append: only Paperclip-authored text: Paperclip's fixed execution prompt, the run's hand-in values (the server-written completion revision and criterion IDs that `paperclip_finish`/`paperclip_block` require; never a criterion's requirement text), and the fixed swarm rules. **The swarm runs without the agent's own instructions**: the instruction bundle and connection instructions are left out, because an agent with an editable instructions folder can rewrite its instructions in an earlier ordinary run, the helpers act under auto mode, and Paperclip keeps no user-approved copy of those instructions to trust instead. - Tools: only Paperclip's own MCP bridge (any other assigned tool server refuses the swarm), with delegation, hiring, routing and generic API operations removed. Paperclip's permission handler approves a CLI permission request only when its tool name is `mcp_paperclip_<tool>` and `<tool>` is one the run's bridge admits; everything else is refused, and the CLI then ends the turn. Tool descriptions are Paperclip-authored; tool results (for example other comments) are data the coordinator reads, not the request. - Model and mode: the agent's configured model, Antigravity's `auto` mode, both read back and pinned by the receipt. - Not sent: task title, description, wake comments, continuation events, attachments, queued messages, handoff text. Known residual: a Retry or recovery run that has not yet been selected (still preparing) does not carry the request marker, so an Interrupt in that short window keeps the message for the turn boundary instead of stopping the run; the message is delivered after the run ends. - Off by default and local only. With the flag on, helpers act under Antigravity's `auto` mode. **Paperclip does not sandbox them on a local computer**, and their tool calls never reach Paperclip, so helper shell commands can write outside the task folder where the CLI's own sandbox allows (workspace plus temp directories). The settings text, the activity log and the plan doc say so. - On macOS the CLI uses its own Google sign-in from the login keychain, not Paperclip's stored connection. - Google's consumer terms have a clause about third-party tools that access the service. A legal read is pending; this PR does not claim compliance. - `/swarm` as the first word of a composer message is now a swarm request for every agent; for agents other than Google Antigravity the server refuses it with a plain message. To send the literal text, put other text first. - The new runner-e2e cells are attended only and have no automated executor. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. Review round 2 (head |
||
|
|
8c04793a4a |
feat(google): delete content read from Google when access ends (#22836)
Every way a Google connection ends now starts the durable connection content deletion on its own, and Paperclip never resumes a cleaned harness session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
de4b60fc54 |
refactor(test): prune 28 completed migration, prose-grep, and Storybook fixture tests (#22832)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Over recent sprints, the test suite accumulated completed one-time SQL migration backfill tests, brittle static prose-matching guidance tests, and non-production Storybook fixture/prototype/feasibility-probe tests that add compile and CI maintenance cost without testing live behavioral invariants. > - Core database migration guards, active runtime migration services, security/safety static guards, and active adapter suites must stay intact. > - This pull request deletes 28 audited low-value test files (-1,894 LOC), preserves the one genuine schema validation assertion from `chat-communication-guidance.test.ts` inside `packages/shared/src/validators/chat-channels.test.ts`, prunes the 5 deleted server test keys from `scripts/general-server-shard-durations.json`, and refreshes `tests/runner-e2e/source-sdk-public-inputs.json`. > - The benefit is cleaner, higher-signal test coverage with zero lost invariants and synchronized SDK public source pins. ## Linked Issues or Issue Description Refs #22804 **What existing behavior does this improve?** Test suite signal-to-noise ratio and maintenance overhead across `packages/db`, `packages/shared`, `packages/skills-catalog`, `server`, `ui/storybook`, `scripts`, and `tests/speko-voice-proof`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** 28 test files test already-shipped one-time migrations/dead backfills, static markdown/copy wording, non-production Storybook fixtures/prototypes, or a superseded voice feasibility probe. **Proposed behavior** Remove the 28 low-value test files while preserving all core migration integrity suites, active runtime migration services, security static guards, live adapter suites, and the genuine `updateChatEndpointSchema` assertion. ## What Changed - **Completed one-time migrations & dead backfills (3 files deleted, 444 LOC):** - Deleted `packages/db/src/better-auth-account-issuer-migration.test.ts`, `packages/db/src/chat-telegram-draft-ids-migration.test.ts`, and `server/src/__tests__/tool-oauth-legacy-backfill.test.ts` (zero production callers outside barrel re-export). - Retained all core DB migration guards (`check-migration-safety`, `migration-compatibility`, `migration-snapshot-drift`, `check-pr-migration-order`) and active runtime migration/legacy-recovery services. - **Brittle static prose/wording grep tests (9 files deleted, 317 LOC):** - Deleted `packages/shared/src/connection-intent-guidance.test.ts`, `packages/shared/src/telemetry/readme-contract.test.ts`, `packages/skills-catalog/src/release-content-cases-contract.test.ts`, `server/src/__tests__/secret-entry-guidance.test.ts`, `server/src/__tests__/primary-agent-guidance.test.ts`, `server/src/services/chat-communication-guidance.test.ts`, `server/src/services/onboarding-greeting.test.ts`, `ui/src/lib/agent-onboarding-prompt.test.ts`, and `ui/src/lib/grok-bot-setup-prompt.test.ts`. - Moved the one genuine schema validation assertion (`updateChatEndpointSchema` `communicationInstructions`) into `packages/shared/src/validators/chat-channels.test.ts`. - Retained `cli-invocation-safety.test.ts` and all real security/auth/prompt-injection guards. - **Non-production Storybook fixture / prototype / feasibility-probe tests (16 files deleted, 1,182 LOC):** - Deleted 10 Storybook fixture/prototype/mock-API tests, 2 unreferenced Storybook audit script tests, and 4 superseded `tests/speko-voice-proof/*.test.mjs` feasibility probe tests. - **Manifest & SDK pin hygiene:** - Pruned the 5 deleted server test keys and reconciled coverage counts in `scripts/general-server-shard-durations.json`. - Synced `tests/runner-e2e/source-sdk-public-inputs.json` via `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --write` (0 files deleted under `tests/runner-e2e/`). ## Verification - `node scripts/check-maps.mjs` — **PASS** (35 areas, 192 capabilities aligned) - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (588 nightly suites validated) - `pnpm exec vitest run` on retained suites (`chat-channels`, `telemetry`, `skills-catalog`, `check-migration-safety`, `migration-compatibility`, `migration-snapshot-drift`, `runner-api`) — **15/15 files, 2,532/2,532 PASS** - `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse HEAD) --check` and `vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs` — **PASS (13/13)** - `node --test scripts/typecheck-test-programs.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/storybook-catalog.test.mjs` — **103/103 PASS** - Typecheck (`@paperclipai/shared`, `@paperclipai/db` incl. `check:migrations`, `@paperclipai/skills-catalog`, `node scripts/ci-typecheck-lane.mjs --typecheck-ui`) — **PASS (0 errors)** ## Risks - Low risk: zero production code changed, zero core DB migration or auth/security guards removed, and zero dangling references across `maps/`, `scripts/`, `.github/`, or `tsconfig*.json`. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local test execution (`typecheck-opt`, `verifier`, `ci-pipeline`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
c9edffe605 |
fix(claude-local): label ACP usage rows from the run's AI connection (#20955)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A `claude_local` agent can run on a managed AI connection. The connection supplies the credentials and the routing, for example OpenRouter or a gateway. > - Each run writes usage rows to the cost ledger. The rows carry a provider, a biller, a billing type and a model. > - The ACP lane of the Claude adapter finds the billing identity from the agent environment only. It treats a run as API-billed only when `ANTHROPIC_API_KEY` is set. > - A managed connection with bearer auth sets `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_BASE_URL`. It does not set `ANTHROPIC_API_KEY`. The run is therefore labeled `anthropic` with the subscription billing type, and the ledger records zero cost. > - The ACP bridge also reports its own model alias (for example `opus`) as the current model. The usage row then names that alias, not the model that the endpoint received. > - This pull request resolves the billing identity from the managed AI connection first. It also names the requested model on usage rows for those runs. > - The benefit is that runs on an api_key connection show as metered API usage with the correct provider and model in Costs. ## Linked Issues or Issue Description Refs #18540 This pull request fixes the labels for the ACP lane. The Claude CLI lane (`resolveClaudeBillingType`) and the price estimate stay open. Related pull requests that I found. None of them changes the ACP billing identity: - #12000 (`fix(claude-local): distrust gateway-reported costs`) is open. It touches the Claude CLI lane and the cost estimate. - #11420 (`fix(pi-local): report a real billing type instead of hardcoding unknown`) is open. It fixes the same kind of label problem in the Pi adapter. The report in #18540 also names a second problem. Claude Code estimates the price with Anthropic list prices. This pull request does not change that estimate. ## What Changed - `claude-local/src/server/acp-billing.ts` (new): `resolveManagedApiKeyBilling` reads the managed AI connection. For an `api_key` connection it returns the billing type `metered_api`. The provider and the biller are the connection provider. Bedrock routing bills `aws_bedrock`. `resolveEnvBillingIdentity` holds the existing env-based classification, moved out of `acp.ts` unchanged. This keeps `acp.ts` under 1,000 lines. - `claude-local/src/server/acp.ts`: `resolveClaudeAcpBillingIdentity` tries the managed connection first. Other runs, subscription connections included, keep the env-based result. - `adapter-utils/src/acpx-engine/execute.ts`: the ACPX billing identity gets an optional `preferRequestedModel` flag. The two accounting-model calls pass it on. - `adapter-utils/src/acpx-engine/accounting-model.ts`: `acpxAccountingModel` takes an options argument. With `preferRequested`, it returns the requested model, or `null` when the run requested none. - Tests: `acp.test.ts` covers gateway, OpenRouter, local, Bedrock and subscription connections. `accounting-model.test.ts` covers the new option. `execute.test.ts` checks that the usage row and the result name the requested model with the flag, and the bridge model without it. ## Verification - `corepack pnpm install --frozen-lockfile`: succeeded. - `corepack pnpm vitest run src/acpx-engine/accounting-model.test.ts src/acpx-engine/execute.test.ts` (in `packages/adapter-utils`): 2 files, 271 tests passed. - `corepack pnpm vitest run src/server/acp.test.ts` (in `packages/adapters/claude-local`): 1 file, 46 tests passed. - `corepack pnpm --filter @paperclipai/adapter-utils typecheck`: passed. - `corepack pnpm --filter @paperclipai/adapter-claude-local typecheck`: passed. - I did not run the full repository test suite. I did not run a live run against OpenRouter. ## Risks - Low risk. The new path applies only when the run config has a managed `api_key` connection. All other runs keep their current labels. A test checks the subscription case. - A run on an api_key connection whose config names no model now records no model on its usage row. Before, the row carried the bridge alias. - A connection that projects `ANTHROPIC_API_KEY` resolved to `api` before and resolves to `metered_api` now. `normalizeLedgerBillingType` in `server/src/services/heartbeat/run-state.ts` maps both values to `metered_api`, and the Anthropic and Codex pricing accept both. The ledger result is the same. - Runs on an api_key connection change from `subscription_included` to `metered_api`. Their cost is no longer forced to zero. Claude Code still supplies the cost estimate. For a routed model, that amount can differ from the amount that the provider bills. > 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 Code (Anthropic) with tool use (shell, file edits, test runs). Claude Fable 5.2 (`claude-fable-5-2`) directed the work. Claude Sonnet 5.5 (`claude-sonnet-5-5`) ported the change to current master and ran the tests. Claude Opus 5.5 (`claude-opus-5-5`) reviewed 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 - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
ecef06d246 |
fix(agents): reject a blank taskKey on reset-session instead of resetting all task state (#19282)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Operators can reset an agent's runtime session with `POST /agents/:id/runtime-state/reset-session` > - A `taskKey` scopes the reset to one task. No key resets all task state. > - The schema accepted a whitespace-only `taskKey`, and the route changed it to `null` > - So a blank key took the full-reset path, and the activity entry recorded `taskKey: null` > - This pull request makes the schema trim the key and reject a blank key with a 400 > - The benefit is that a scoped reset request can never become a full reset by accident ## Linked Issues or Issue Description Fixes #19080 Refs #19005 (the parent issue that #19080 was split out of) I searched open and closed PRs for `19080`, `reset-session` and `resetAgentSessionSchema`. I found no related PR. ## What Changed - `resetAgentSessionSchema.taskKey` is now `z.string().trim().min(1).optional().nullable()`. A blank or whitespace-only key fails validation with a 400. An omitted key or `null` still requests the full reset. - The route uses the parsed `taskKey` directly. The schema already trims it, so the route no longer has its own trim-and-null step. - Added tests in `packages/shared/src/validators/agent.test.ts` for omitted, `null`, trimmed and blank keys. ## Verification - `pnpm exec vitest run packages/shared/src/validators/agent.test.ts`: 16 tests pass. - `pnpm exec vitest run cli/src/__tests__/agent-lifecycle.test.ts`: 4 tests pass. The CLI parses its payload with the same schema. - `pnpm --filter @paperclipai/shared typecheck` passes. - I ran the server `tsc` locally. It reported no errors in `server/src/routes/agents.ts`. My local Windows setup cannot build `@paperclipai/paperclip-runner`, so the full server typecheck depends on CI. ## Risks - Low risk. A client that sends `taskKey: ""` or a whitespace-only key now gets a 400 instead of a full reset. The board UI sends `null` or an issue id, and the CLI omits the key when `--task-key` is not set. Neither caller sends a blank key. ## Model Used - Claude Opus 5.5 (Anthropic, model ID `claude-opus-5-5`), used through Claude Code with tool use (shell, file editing). It assisted with code reading, the change, tests and this description. I reviewed the change. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
4401962e69 |
feat(google-workspace): run the six launch services on Google's MCP servers again (#22815)
Gmail, Drive, Docs, Sheets, Slides and Calendar go back to google_mcp because of Google's Workspace AI Tools Addendum; the REST tool set stays as the fallback. The REST argument checks that need no request to Google run before each MCP call, a Calendar delete reads the event first and refuses a recurring series, and a refresh that replaces saved REST definitions holds nothing for review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
71ff1c8600 |
fix(runner): read an assigned skill by its short name (#22813)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use saved company skills; on the native runner they read a
skill's files with `read_assigned_skill`
> - The daily QA staging smoke test `saved-skill-use` has been failing:
the agent finishes the task, but no skill read is recorded
> - The private run events show why: the agent called
`read_assigned_skill` with the skill's short name (`qa-saved-skill-…`),
the name the task gives it (`/qa-saved-skill-…`) and the skill's own
frontmatter `name`. The runner matches only the full company key
(`company/<id>/qa-saved-skill-…`) or the runtime name
(`qa-saved-skill-…--<hash>`), so it answered `runner_skill_not_assigned`
for a skill that was assigned. The agent then read the file with bash
> - This pull request lets the runner find an assigned skill by its
short name too
> - The benefit is that agents read saved skills through the verified,
pinned path the first time, instead of falling back to the filesystem
## Linked Issues or Issue Description
**Subsystem affected**
Native runner bridge tools (`read_assigned_skill`).
**Problem or motivation**
In the November 24 QA staging smoke run, `saved-skill-use` failed. Run
events (private QA evidence) show `read_assigned_skill` with
`{"skill":"qa-saved-skill-journey-…","path":"SKILL.md"}` returning
`{"outcome":"failed","code":"runner_skill_not_assigned"}`, followed by a
`bash` read of the same SKILL.md. The skill was in the agent's desired
skills and on disk.
**Proposed solution**
After the exact key/runtime-name match, accept the key's last part (with
or without a leading `/`) when exactly one assigned skill has it.
**Alternatives considered**
- Changing the task text or the test to pass the runtime name: the agent
is told `/short-name`; the product should accept what it tells agents.
- Matching the frontmatter `name`: the short name is already the key's
last part for company skills, and needs no file read before the lookup.
## What Changed
- `server/src/services/native-runtime/runner-bridge-tools.ts`:
`assignedSkillByName` finds an assigned skill by key, runtime name, or
unique short name; `readAssignedSkill` uses it.
- `server/src/services/native-runtime/runner-bridge-tools.test.ts`: the
short name (and `/short-name`) reads the skill; a short name two
assigned skills share names neither; the runtime name still
disambiguates.
## Verification
- `runner-bridge-tools.test.ts`: the new cases fail on master with
`runner_skill_not_assigned` and pass with the fix (red/green); 11
passed.
- Not run locally: server typecheck (this worktree's local
`paperclip-runner` build is stale; unrelated errors in other files). CI
typechecks the change.
- After deploy: the next QA staging smoke run's `saved-skill-use` should
record a native skill read.
## Risks
- Low. Lookup only widens to a unique short name among skills already
assigned to this run; it grants no access to unassigned skills, and
every file read keeps its manifest and digest checks.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, AWS CLI read of the private QA evidence, file edits).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
94510d7b26 |
fix(github): settle request comments after deliberate waits and refused replies (#22798)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Review agents answer GitHub pull request threads; each request's comment must end in a real reply or an honest final notice > - After #22672 and #22710, 13 of 85 new review-bot comments on staging still ended as status notices, and 10 old placeholders on merged PRs never settled > - Run data on staging shows two causes: runs that yield on purpose to wait for a response (`external_chat_response_waiting`), and runs whose final reply was refused (`responsePublication.state = failed`) > - The first marked inline threads "ended without publishing" while a later run posted the review; the second looked like presentation still pending, forever > - This pull request makes both settle: link the latest response, wait while the task is open, and use the honest notice only when nothing was published > - The benefit is that every request comment ends in a useful final state ## Linked Issues or Issue Description Refs #22672, #22710 **Describe the bug** - On #22732 the author replied on five review threads at once. Each reply woke its own run; those runs yielded with `external_chat_response_waiting`, and a later run posted the review. Four threads still ended with "This turn ended without publishing a final response." - On #22658 (and the other merged PRs with stuck "Working on this…"), the request's run finished `succeeded`/`committed` with no presentation decision because its final reply publication failed after 6 attempts (`publication_refused`). The settle logic treated that as presentation pending and never settled the thread. **Steps to reproduce** 1. An inline request's run yields with a response-wake continuation; a later run publishes a review. 2. Or: an inline request's run finishes with `responsePublication.state = "failed"` and no presentation decision. 3. The thread says "ended without publishing" (1) or stays "Working on this…" forever (2). **Expected behavior** The thread links the latest published response, waits while the task is still open, and otherwise ends with an honest notice. ## What Changed - `githubLatestTaskResponseUrl`: the latest processed GitHub publication (comment, formal review, assessment) for the task after the request arrived. - `githubResponseExecution`: when the request's run did not reply, link that latest response if any. An inline request whose run deliberately waits keeps waiting while the task is open. A run whose reply was refused says so. The main PR comment keeps its passive-wait cancellation (`mainPullResponse`). - `nativePresentationPending` is false when `responsePublication.state = failed`; new `responsePublicationFailed` column. - Terminal sweep decision version is now `v3`, so requests parked under v2 are read again once. ## Verification - New integration tests (red on master, green here): links a waited thread to a later response; settles a waited thread when the task finishes with no response; settles a thread whose run's reply could not be published. - Updated `keeps per-request fallback outside the main GitHub PR review wait`: waits while the task is open, then settles when done. - `keeps native presentation idle until its committed GitHub outcome` (main PR passive) still passes. - `server/src/services/chat-channels/github/` and response comment tests: 67 passed. GitHub integration group: 538 passed before the main-PR scoping fix; the two affected tests pass after it. - After deploy: re-measure the stuck rate on staging for comments created after the deploy. ## Risks - One extra indexed query per request that settles without its own reply (to find the latest response). Settled requests leave the backlog. - A waited inline thread stays "Working on this…" while its task is open and nothing was published yet; that is the honest state. - Separate, not fixed here: why the native finalizer refuses some final replies (`publication_refused`). ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
cffd17e78a |
perf(ci): Phase 3 PR CI under 3m — 4x Runner support, 12x E2E, incremental TS 7 cache, pure-Node postinstall, and rebalanced shards (#22804)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI verifies every change before merge across build, typecheck, server tests, Runner tests, and Playwright E2E shards. > - After Phase 1 (#22679) and Phase 2 (#22729), full-fanout PR CI still takes 9m45s wall-clock on 4-core AWS runners because of five bottlenecks: an unsharded 7m22s `Runner support suite`, stale server/chat/Runner shard duration manifests plus newly landed SSH/soak whales, 28s of `pnpm -r run postinstall` replay on every job, cold server/UI typecheck and single-build overhead, and 3 oversized (>180s) Playwright E2E specs across 8 shards with double-start Postgres template boot. > - Docs-only prose edits under `doc/**` and `docs/**` also fanned out to 66 CI jobs because only three doc paths bypassed global dependencies. > - This pull request shards `Runner support suite` 4 ways with `pool: "threads"`, shards E2E 12 ways after splitting the 3 oversized specs and removing double-start Postgres boot, adds pure-Node workspace postinstall replay, adds read-only master-warmed incremental TS 7 and Runner dist caches, rebalances all server/chat/Runner duration manifests, demotes 48 new non-invariant soak whales to nightly, and routes audited prose docs without triggering 66-job storms. > - The benefit is driving ordinary PR CI toward under 3 minutes wall-clock while preserving every invariant check, cache boundary, and full master/nightly test coverage. ## Linked Issues or Issue Description Refs #22679 Refs #22729 **What existing behavior does this improve?** Pull request CI wall-clock latency across `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`, `.github/actions/setup-ci-dependencies/action.yml`, typecheck orchestration, Vitest/Runner lanes, and Playwright E2E shards. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Full-fanout PR CI takes 9m45s on 4-core runners (run `45440355579`), dominated by `Runner support suite` (7m22s), `e2e shards` (5m02s–6m24s), `General tests (server/chat)` (5m37s–6m01s), `Verify Paperclip Runner (vitest package)` (6m25s on stale manifests), `Typecheck` (4m13s–6m30s), `Build` (~4m), and 28s of `pnpm -r postinstall` per job. Prose edits under `doc/**` trigger 66 jobs. **Proposed behavior** Shard `Runner support suite` (4x) and `e2e_shards` (12x), split the 3 oversized E2E specs, boot disposable E2E Postgres in a single non-durable start, replay workspace `postinstall` in pure Node (<1s), cache prebuilt Runner dist and TS 7 `.tsbuildinfo` from canonical `master` pushes (read-only in PRs), use emit-only server compile in ordinary PR `Build`, rebalance all shard duration manifests, demote 48 new non-invariant soak whales to nightly, and route audited prose docs cleanly. ## What Changed - **Pure-Node postinstall replay (`scripts/replay-workspace-postinstall.mjs`, `.github/actions/setup-ci-dependencies/action.yml`):** Replaces the 28s `pnpm -r --if-present run postinstall && pnpm run postinstall` call on every CI job with a pure-Node parallel runner (~0.84s locally) with fallback for older checkouts. - **4-way sharded `Runner support suite` + `threads` pool (`.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`, `tests/runner-e2e/run-unit.mjs`, `tests/runner-e2e/vitest.config.ts`):** Shards Vitest and `node:test` suites 4 ways (`--shard-index 0..3 --shard-count 4`) and switches `tests/runner-e2e` to `pool: "threads"` with CPU-aware `maxWorkers` while preserving `isolate: true`. - **12-way E2E shards, single-start E2E Postgres boot, and 3 oversized spec splits (`tests/e2e/start-e2e-server.ts`, `tests/e2e/*.spec.ts`, `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/ci-task-matrix.json`):** Boots cold ephemeral E2E Postgres in one `initdb --no-sync` + non-durable `postgresql.conf` start overlapped with server module import; splits `agent-chat-projects`, `chat-adapters-ui-providers`, and `chat-adapters-ui-messaging` cleanly with zero tests removed; balances all 54 specs across 12 shards (6.8s spread). - **Incremental TS 7 typecheck & Runner dist caching (`server/scripts/typecheck-layers.mjs`, `scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/typecheck-test-projects.mjs`, `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`):** Preserves portable `.tsbuildinfo`/`.d.ts` with `layer-map.json` invalidation and stale-declaration pruning, wires read-only `runner-dist-v1` and `typecheck-incremental-v1` restores in `pr-trusted.yml` (zero `actions/cache/save`) paired with canonical-`master`-only guarded writers in `release-verify.yml`, skips redundant Runner Rust `cargo check` on TS-only shared PRs, and uses LPT scheduling with concurrency 3 (4-core) / 4 (8-core). - **Emit-only PR `Build` & audited prose doc routing (`.github/workflows/pr-trusted.yml`, `.github/scripts/ci-inputs.mjs`):** Passes `PAPERCLIP_TSC_EMIT_ONLY=1` on ordinary PR `Build` jobs (full `pnpm build` on `full-ci` / `master`), and classifies audited prose Markdown under `doc/**` and `docs/**` as `guidance` / `historical` while keeping `docs/api/**`, JSON/TS fixtures, `maps/**`, and unknown files fail-closed. - **Rebalanced shard manifests & new soak demotions (`scripts/ci/nightly-only-suites.json`, `scripts/*-shard-durations.json`, `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `packages/paperclip-runner/vitest.config.ts`, `packages/paperclip-runner/scripts/vitest-sequencer.mjs`):** Demotes 48 newly landed/grown non-invariant soak suites (including 4 real-SSH integration suites) to nightly, refreshes all 4 timing manifests from live CI measurements (0.1s–0.6s LPT skew), and scales Runner package Vitest CI `maxWorkers` to 3 on 4-core / 6 on 8-core. ## Verification - `node --test .github/scripts/tests/*.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/runner-vitest-package-lanes.test.mjs scripts/typecheck-test-programs.test.mjs scripts/check-test-budget.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/test-selection-timings.test.mjs` — **973/973 PASS** - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (`609` nightly suites validated, zero protected invariants demoted) - `node scripts/check-maps.mjs` — **PASS** - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs tests/runner-e2e/unit-launcher.test.mjs` — **PASS** - `pnpm --filter @paperclipai/paperclip-runner exec vitest run scripts/vitest-sequencer.test.mjs` — **PASS** - `cd server && node ../node_modules/vitest/vitest.mjs run scripts/typecheck-layers.test.mjs scripts/typecheck-layers-incremental.test.mjs` — **56/56 PASS** (real TS 7.0.2 incremental soundness tests) - `node scripts/run-tsc.mjs -p tests/e2e/tsconfig.json --noEmit && node scripts/run-tsc.mjs -p tests/tsconfig.playwright.json --noEmit && pnpm run test:e2e:runner:typecheck` — **0 errors** - Live Playwright smoke passed across all 6 split E2E spec files on the cold non-durable Postgres boot path (`PAPERCLIP_TEST_POSTGRES_TEMPLATE=0`). - Live sharded `tests/runner-e2e` runs passed under `pool: "threads", maxWorkers: 4` (shard `1/4` 172/172 PASS; shard `2/4` all Vitest + 65/65 `node:test` PASS). ## Risks - **Cache invalidation on incremental typecheck / Runner dist:** Mitigated by exact-key hashing (including `packages/{shared,adapter-utils,plugins/sdk}/src/**` and `packages/paperclip-runner/spec/**`) with no `restore-keys:` on `runner-dist-v1`, SHA-256 self-validation inside `prepare-runner-vendor.mjs`, `layer-map.json` invalidation + stale `.d.ts` pruning in `typecheck-layers.mjs`, and read-only PR restores (only canonical `master` pushes save caches). - **Shard rebalancing & soak demotions:** All demoted suites remain in `nightly-only-suites.json` and run on `full-ci` / `master` / nightly; `check-test-budget.mjs` enforces zero protected invariants are demoted. - **Workflow security boundaries:** `ci-routing.yml`, `pr.yml`, `CODEOWNERS`, and all `runs-on:` expressions are unchanged; `pr-trusted.yml` performs zero `actions/cache/save` calls. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local code/test execution across 6 parallel worker roles (`ci-pipeline`, `vitest-runner`, `server-prune`, `e2e-opt`, `typecheck-opt`, `verifier`). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge |
||
|
|
3ca9b6d471 |
refactor(plugin-sdk): remove archivedState from the resume result (#22443)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native Runner sessions can run in a remote environment task that a plugin provider owns > - A provider can relaunch a parked Runner as the next run, and it reports the result to Core > - The resume result could carry `archivedState`, so Core could check that the park was a settled cut > - #22442 makes the provider the authority on the park, and Core stops reading `archivedState` > - This pull request removes the field from the SDK result schema > - The benefit is a smaller provider contract with no unused fields ## Linked Issues or Issue Description Refs #22442 **What existing behavior does this improve?** The environment task resume result contract in the plugin SDK. **Subsystem affected** `packages/plugins/sdk` (environment tasks), and the tests in `server/src/services/native-runtime` that build resume results. **Current behavior** After #22442, a resumed relaunch result can carry an optional `archivedState`. Core accepts it and does not read it. **Proposed behavior** The resume result has no `archivedState` field. The strict schema refuses it. **Reason and benefit** The field has no reader. Removing it keeps the contract to the fields that Core uses. **Breaking changes** A provider that still sends `archivedState` on a resume result fails the schema check, and the relaunch fails. Deploy this with or after the provider change that stops sending the field. **Additional context** Stacked on #22442. ## What Changed - SDK: removed `archivedState` from the `resume` result schema, and simplified the relaunch check in `parseEnvironmentTaskResult`. - SDK test: a relaunch result with `archivedState` now fails; one without it passes. - `plugin-runner-task.test.ts`: removed the field from the fixtures, and removed the test that checked Core ignores it. - `plugin-runner-release-resume.integration.test.ts`: the fixture provider no longer returns the field. - `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md`: removed the note about the field. ## Verification - `pnpm run typecheck` in `server` (builds all dependent packages): pass. - `pnpm vitest run src/services/native-runtime/plugin-runner-task.test.ts` in `server`: 116 passed. - `pnpm vitest run tests/environment-task-release-resume.test.ts` in `packages/plugins/sdk`: 48 passed. - I did not run the embedded-Postgres integration suite locally. CI runs it. ## Risks - A provider that still sends the field makes the relaunch fail. Deploy this with or after the provider change that stops sending it. It can ship in the same deploy as #22442. - Low risk otherwise: the change removes an unused optional field. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (shell, file edit, code search). Extended thinking on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0b2acfb956 |
refactor(runner): let the provider decide whether a released Runner relaunches (#22442)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Native Runner sessions can run in a remote environment task that a plugin provider owns > - After a turn, the provider can park the Runner, and the next run can relaunch it from the saved state > - Core kept its own local record of each released Runner, and the provider kept its park record too > - Core lost its copy when the local session directory was not durable. Then Core restored from a checkpoint although a park existed, and the turn was slower > - This pull request makes the provider the only authority on the park. Core resumes the source from its durable checkpoint, and the provider answers "resumed" or "unavailable" > - The benefit is fewer missed relaunches, and less code in Core ## Linked Issues or Issue Description **What existing behavior does this improve?** The relaunch of a parked Runner for the next run of a native session. **Subsystem affected** Native runtime: `server/src/services/native-runtime`, the Runner control plane in `packages/paperclip-runner`, and the environment task SDK. **Current behavior** Core writes a released-Runner record (source identity, task id and scope digest) to the local session directory when a release completes. Core relaunches a parked Runner only when that record exists. Core also checks the archived Runner state on the provider's relaunch reply. When the local directory is gone (for example, after the server process restarts on a new host), Core restores from a checkpoint into a fresh task, although the provider still has the park. **Proposed behavior** Core resumes the source identity from its durable controller checkpoint on the lease's current task. The provider decides from its own park record. When no park of that source exists, the provider answers `unavailable`, and Core starts a fresh task from the saved session, as it does today for other unavailable answers. **Reason and benefit** One record for one fact. Core no longer needs local state to relaunch, so more runs relaunch. The change removes about 160 lines. **Breaking changes** A provider must answer `unavailable` when it has no park for the requested source. A provider that answers with an error instead makes the resume fail. The `archivedState` field on a resumed relaunch result becomes optional. Providers can continue to send it; Core does not read it. **Additional context** Reattach to a live Runner process in the same server is not changed. A relaunch after a restart still requires the process configuration to match, because the relaunch reuses the parked launch. A changed configuration starts a fresh task. ## What Changed - Removed the local released-Runner record: its writer, its readers, the scope digest, and the resume and retire callbacks that cleared it. - Derived the relaunch source from the durable Runner identity. Kept the check that the task is the lease's current task. - After a restart, Core takes the released source from the durable identity for every provider that releases tasks: one that relaunches the parked Runner, and one that hands it over. - Added a test that a checkpoint saved with the old released-Runner record still loads. - When a restart recovery resumes a released source and the provider answers `unavailable` with the task stopped and its state saved, Core now starts a fresh task from the saved session, as it does for a relaunch. The fallback finishes the old task's startup context before it inspects the replacement task. An executor test covers this path. - Updated the SDK source pin in `tests/runner-e2e/source-sdk-public-inputs.json`. - Stopped the check of the archived state on the relaunch reply. Removed `isSettledReleasedRunnerCut` and the resume `settled` hook. - SDK: a resumed relaunch result no longer requires `archivedState`. - Updated `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and the tests. ## Verification - `pnpm run typecheck` in `server` (builds all dependent packages): pass. - `pnpm vitest run src/services/native-runtime/plugin-runner-task.test.ts src/services/native-runtime/remote-warm-session-recovery.test.ts` in `server`: 147 passed. - `pnpm vitest run src/services/native-runtime/native-session-executor.test.ts -t "releases settled|accepts only the attached|released|relaunch|warm|unavailable|recover"` in `server`: 594 passed. - `runnerd-codex-transport.test.ts` in `packages/paperclip-runner`: 337 passed. - SDK release and resume tests in `packages/plugins/sdk`: 48 passed. - `runnerd-codex-transport-release-resume.test.ts -t relaunched` in `packages/paperclip-runner`: 3 passed. `pnpm run typecheck` in `packages/paperclip-runner`: pass. - `tests/runner-e2e/source-sdk-public-inputs.test.mjs`: 13 passed. - `plugin-runner-release-resume.integration.test.ts -t "completes claude runs through a retained adopted process"`: pass. I did not run the rest of the two embedded-Postgres integration suites locally. CI runs them. ## Risks - A provider that does not answer `unavailable` for a missing park makes the resume fail. Deploy the provider change first, or in the same deploy before this Core version takes traffic. This PR and #22443 are one stack and can ship in one deploy. - A server restart now relies on the existing unavailable-reuse fallback to start a fresh task. Tests cover this path. - Medium risk overall: the change is in the warm-session path. The cold path is not changed. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), through Claude Code with tool use (shell, file edit, code search). Extended thinking on. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8b616b949d |
fix(connections): drop MCP wording and the MCP guide link from Google Workspace setup (#22793)
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Agents use Google Workspace through the built-in Google Workspace connection > - Since #22634, Gmail, Drive, Docs, Sheets, Slides, and Calendar run on Paperclip's own REST tools, not on Google's hosted MCP servers > - The connect screen still showed "Secure MCP sign-in" and a "Review requirements" link to Google's MCP servers guide > - This text is wrong for this connection, it is internal jargon, and Google's OAuth reviewers read this screen > - This pull request removes the MCP wording and the MCP guide link from Google Workspace setup and from its audit details > - The benefit is that users and reviewers see only true, plain text for this connection ## Linked Issues or Issue Description Refs #22634 **What happened?** On a Cloud workspace, the Google Workspace connect page showed the subtitle "Secure MCP sign-in" while the sign-in opened and after it failed to open. The setup page also showed a "Review requirements" link to `developers.google.com/workspace/guides/configure-mcp-servers`. On a self-hosted instance, the "How to set up a Google OAuth client" link went to the same MCP servers guide. Audit details for a Google REST call showed "Transport: mcp_remote" and "MCP method: tools/call". **What did you expect to happen?** The connect page says "Secure sign-in". The Paperclip-managed method on Cloud has no requirements link, because the user has no requirements to review. On a self-hosted instance, the customer-owned client method links to Google's OAuth client guide. Audit details for a Google REST call do not show MCP terms. **Steps to reproduce** 1. Turn on the Google Workspace connector in **Settings → Experimental**. 2. Open **Apps** and choose **Google Workspace**. 3. Start the sign-in, then close or block the sign-in window. 4. Before this change: the header shows "Secure MCP sign-in", and the setup step shows "Review requirements" with a link to Google's MCP servers guide. ## What Changed - `ui/src/features/connections/ConnectionSetupFlow.tsx`: `OAuthConnectStateScreen` shows "Secure sign-in" for a curated app. A server that the user pasted as an MCP server keeps "Secure MCP sign-in". This is generic: there is no Google-specific code. - `packages/shared/src/app-definitions/google-workspace.json`: remove the top-level `docsUrl` (the MCP servers guide). The Paperclip-managed method now has no "Review requirements" link. The customer-owned method's `consoleLinks.docs` is now Google's OAuth client guide (`create-credentials#oauth-client-id`). The "Review requirements" link and the self-hosted "How to set up a Google OAuth client" link both use it. Its guidance text names the Gmail, Drive, Docs, Sheets, Slides, and Calendar APIs instead of "the Google Workspace MCP APIs". This file is a reviewed definition: `scripts/ingest-app-definitions.mjs` copies it as-is, so a regeneration keeps the fix. - `server/src/services/tool-gateway.ts`: an audit record for a Google Workspace REST call no longer has `mcpMethod`. - `ui/src/pages/tools/AuditTab.tsx`: audit details show the connection type label ("Remote HTTP") as "Type" instead of the raw `mcp_remote` value. This uses the same label as the connection's "Connection details". - `doc/connections/GOOGLE-WORKSPACE.md`: the self-hosted section links Google's OAuth client guide. - `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed pinned inputs. ## Verification - Red first, then green: - `packages/shared/src/google-workspace-setup-links.test.ts`: no Google Workspace method links the MCP servers guide, the managed method has no requirements link, the customer method links the OAuth client guide, and method text has no "MCP". It failed 4/4 before the fix. - `ui/src/features/connections/OAuthConnectStateScreen.google.test.tsx`: in the preparing, opening, and "couldn't open the sign-in window" states, the Google Workspace screen shows "Secure sign-in", no "MCP", and no link to `configure-mcp-servers`. A pasted server keeps "Secure MCP sign-in". It failed 3/4 before the fix. - `server/src/__tests__/google-workspace-rest-transport.test.ts`: the Gmail REST audit record has no `mcpMethod`. It failed without the server change. - `npx vitest run` for shared app definition tests (67 passed), `ui/src/pages/tools` and `ui/src/pages/apps/app-detail` (121 passed), and the server REST transport file (53 passed). - `tsc --noEmit` for `server` and `ui`: no new errors. - `pnpm verify` exits 2 because a doc under `doc/connections` is a global CI input. Required CI supplies the broad coverage. ## Risks - Low risk. Text and link changes only, plus one optional audit field. - Other curated OAuth apps now show "Secure sign-in" instead of "Secure MCP sign-in" on the sign-in state screen. The new text is true for every curated app. - Audit details for all connectors show "Type: Remote HTTP" instead of "Transport: mcp_remote". - Saved Google Workspace connections still show `https://workspacemcp.googleapis.com/mcp/v1` as the address in "Connection details". It is the stored connection identity. This pull request does not change stored data. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Claude Code agent with tool use and code execution. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |