Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ce47e53
fix(connections): keep retrying when Google does not confirm a revoke…
cryppadotta Nov 23, 2026
76990f1
chore(runner-e2e): refresh pinned source inputs for the Google remova…
cryppadotta Nov 23, 2026
c94975d
docs(connections): describe the broker change without a private PR nu…
cryppadotta Nov 23, 2026
9c1ceed
fix(connections): keep a retry whose own source secret is still store…
cryppadotta Nov 23, 2026
b78206f
Merge remote-tracking branch 'origin/master' into fix/retry-google-re…
cryppadotta Nov 23, 2026
b7f174a
fix(connections): scope pending Google revocations per company and ju…
cryppadotta Nov 23, 2026
6c42f80
fix(connections): treat a re-signed grant's own secret as live use, a…
cryppadotta Nov 23, 2026
1a2a985
Merge remote-tracking branch 'origin/master' into fix/retry-google-re…
cryppadotta Nov 23, 2026
8e272ad
fix(connections): keep the token version that was sent, and save the …
cryppadotta Nov 23, 2026
e8cfad4
test(connections): cover the instance-admin gate on the removed-insta…
cryppadotta Nov 23, 2026
4247d36
Merge remote-tracking branch 'origin/master' into fix/retry-google-re…
cryppadotta Nov 23, 2026
e88b151
fix(connections): show the result of a Google access retry on the con…
cryppadotta Nov 23, 2026
45b0015
chore(runner-e2e): refresh pinned source inputs for the lifecycle eve…
cryppadotta Nov 23, 2026
b5dd787
Merge remote-tracking branch 'origin/master' into fix/retry-google-re…
cryppadotta Nov 23, 2026
21204be
chore(runner-e2e): refresh pinned source inputs after merging master
cryppadotta Nov 23, 2026
aa51a30
Merge remote-tracking branch 'origin/master' into fix/retry-google-re…
cryppadotta Nov 23, 2026
0574c31
chore(runner-e2e): refresh pinned source inputs after merging master
cryppadotta Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion doc/connections/GOOGLE-WORKSPACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,62 @@ distinct tokens sent:
| Outcomes | `result` | Message |
| --- | --- | --- |
| Every token `revoked` | `ended` | Access was ended at Google |
| Any other code (failure, not known, unavailable, error) | `not_ended` | Could not end access; link to https://myaccount.google.com/connections |
| Any retryable code (`provider_revocation_failed`, `revocation_in_progress`, `broker_unavailable`, `broker_error`, `unexpected_error`) and the token was kept for a retry | `retrying` | Google has not confirmed yet; Paperclip keeps trying automatically. No link, no action. |
| Any other code (`binding_not_known`, `provider_revocation_disabled`, `revocation_not_available`, `credential_unavailable`), or a retryable code whose token could not be kept | `not_ended` | Could not end access; link to https://myaccount.google.com/connections |
| Only `other_connections_remain` | `other_connections_remain` | Other connections keep access |
| At least one `revoked`, the rest `other_connections_remain` | `ended_unconfirmed` | Access was ended; check Google if more than one account was connected; link to the same page |

### Pending revocation (retry until Google answers)

Owner decision, 2026-11-23: when access must end and Google cannot be reached
or does not confirm, the app keeps the refresh token and retries. Paperclip
Cloud still stores no provider token.

- Before the broker call, the app copies the sent token version's encrypted
material (the same `local_encrypted` ciphertext as the connection secret) into
`google_pending_revocations`, keyed by company and the token's SHA-256 (one
row per token in a company).
The row is not a company secret: it is not listed, cannot be bound to an agent
or environment, and no route reads it. `company_id` has no foreign key, so the
row outlives a deleted company. The first `next_attempt_at` is 2 minutes out,
so a restart during the call is retried by the worker.
- After the call: a final outcome (`revoked`, `other_connections_remain`,
`binding_not_known`, `provider_revocation_disabled`,
`revocation_not_available`) deletes the row. A retryable outcome keeps it and
the result is `retrying`. If a live grant or connection still uses the
connection secret after the conditional delete (for example, the user signed
in again during the call), the row is deleted, because a live sign-in now
uses the grant.
- The `google-pending-revocation` delivery queue drains due rows. Each attempt
takes a 2-minute lease on the row, then calls the broker with a 15-second
timeout. Backoff is 1, 2, 4 ... minutes, capped at 6 hours. A row stops
without a call when a company secret holds the same token and a live grant
or connection uses it (for example, the user signed in again and Google
returned the same token). A source secret that a restart left behind on a
revoked grant does not count. A row queued for a removed instance skips this
check: no connection may use the token then. After 30 days
the row is deleted without a call (`gave_up`). Google already expires a
refresh token unused for six months, and only the broker can refresh this one,
so the 30-day hard stop limits how long Paperclip holds a token nobody uses.
- When a retry ends, the connection gets a `connection.google_access_retry`
audit event (`reasonCode` `ended`, `other_connections_remain`, `not_ended` or
`gave_up`) and an activity entry `tool_connection.google_access_ended` or
`tool_connection.google_access_not_ended`. A row whose company was deleted
writes only a server log line.
- Company deletion queues every managed Google refresh token of the company in
the delete transaction (`reason = company_deleted`), before the secrets go.
- When an instance admin's Cloud connection status check gets a signed answer
that the instance is `removed` (a `401` alone does not count), the app, in
in one transaction for all companies (so the work is saved before any token
is dropped),
queues every managed Google refresh token (`reason = instance_removed`), then
deletes each connection secret. Those connections need a reconnect after a new
enrollment. The broker accepts a Google revoke from a removed instance after
the November 23 broker release; an older broker answers `403
INSTANCE_SUSPENDED`, which the app retries until the hard stop.
- The worker does no work and holds no deadline when the table is empty, and
nothing here runs on turn start or on a tool call.

The last row is the sequence the broker returns for two tokens of one Google
grant sent one at a time, but two different Google accounts can return it too.
Grants record no Google account identity (none of the 14 scopes returns one),
Expand Down
7 changes: 7 additions & 0 deletions doc/memory/google-connector-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Last updated: November 23, 2026.
| Nov 23 | **All six launch services switched to REST now** | Gmail, Drive, Docs, Sheets, Slides and Calendar are `paperclip_rest`. This replaces the Nov 17 "one service at a time after a live test" rule: live testing happens on the staging tester right after the switch deploys, and problems are fixed forward. Chat, People and Search stay on `google_mcp`. |
| Nov 23 | **Write actions default to "Allowed"** | No approval step by default, including actions labelled destructive. Operators can still set Ask first per action. |
| Nov 23 | **Images by public web address are allowed in Docs and Slides** | `insertInlineImage`, `replaceImage`, `createImage` and `replaceAllShapesWithImage` may use any public link. Links to Drive or Docs files stay refused (Nov 17 rule). Accepted risk: Google, not Paperclip, fetches the address, and Paperclip's own requests still go only to the allowed Google hosts. What remains is that an agent could put data in the address it chooses. Owner decision; do not restrict it. |
| Nov 23 | **Unconfirmed Google revocation is retried by the app, not Cloud** | When access must end and Google cannot be reached or confirm, the app keeps the token in `google_pending_revocations` and retries (1 minute up to 6 hours backoff, 30-day hard stop). Cloud still never stores provider tokens. Company deletion and a Cloud-removed instance queue the same way. The broker lets a removed instance sign a Google revoke (Cloud broker change, November 23). See [connector doc](../connections/GOOGLE-WORKSPACE.md), "Pending revocation". |

## What has shipped

Expand Down Expand Up @@ -276,6 +277,12 @@ Changes made in the broker (staging):
| Stop offering Chat, People and Search for new sessions on the verified client | They are outside the 14. Keep refresh for saved grants. |
| Do not merge the branch that adds a Gmail archive profile | `gmail.modify` is restricted and not in the submission. |

Pending revocation (November 23): the app retries an unconfirmed Google
revoke in the background and handles both brokers. With the old broker, a
removed instance's revoke is refused (`403`) and retried until the 30-day hard
stop; once that broker change is deployed, those revokes succeed. Either
deploy order is safe.

Deploy order: **app first, then broker.** If the broker narrows first, refresh
from app versions that still sign 21 scopes fails.

Expand Down
5 changes: 3 additions & 2 deletions docs/api/tool-connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ For a Google connection that Paperclip Cloud manages, the connection response ha
| `ended` | Google ended Paperclip's access for every removed grant. |
| `ended_unconfirmed` | Google ended access for at least one removed grant, and the others reported other connections. Paperclip cannot tell whether they were the same Google account. |
| `other_connections_remain` | Other Paperclip connections still use this Google account, so Google keeps the access. |
| `not_ended` | Paperclip could not end the access at Google for at least one removed grant. The user can remove it at https://myaccount.google.com/connections. |
| `retrying` | Google did not confirm yet for at least one removed grant (Paperclip Cloud or Google could not be reached, or Google failed). Paperclip keeps that token in a pending record and retries in the background; the user does not need to act. |
| `not_ended` | Paperclip Cloud gave a final answer that it cannot end the access at Google for at least one removed grant, or the token could not be kept for a retry. The user can remove it at https://myaccount.google.com/connections. |

`outcomes` has one code for each refresh token Paperclip sent, in order. The codes are for diagnosis, not for display.

A failure to end access at Google does not undo the local removal. On both routes the local removal completes first, then Paperclip asks Paperclip Cloud to end access at Google, and it never retries in the request. Revoking an organization grant whose token the connection itself still uses does not end access at Google and has no `providerAccess`; removing the connection does. The activity entry for the removal records the same `providerAccess`, and the connection's audit history gets a `connection.google_access_removal` event with it.
A failure to end access at Google does not undo the local removal. On both routes the local removal completes first, then Paperclip asks Paperclip Cloud to end access at Google once in the request. When that is not confirmed and can be retried, the result is `retrying`: a background worker retries with backoff from 1 minute up to 6 hours, for at most 30 days. When the retry ends, the connection's audit history gets a `connection.google_access_retry` event, and the activity log gets `tool_connection.google_access_ended` or `tool_connection.google_access_not_ended`. Revoking an organization grant whose token the connection itself still uses does not end access at Google and has no `providerAccess`; removing the connection does. The activity entry for the removal records the same `providerAccess`, and the connection's audit history gets a `connection.google_access_removal` event with it.

## AWS Role Setup

Expand Down
4 changes: 3 additions & 1 deletion docs/guides/board-operator/deleting-connection-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ You need permission to manage the connection.
2. Select **Also delete data read through this connection**.
3. Select **Remove connection**.

For a Google connection that Paperclip set up for you, removing the connection also asks Google to end Paperclip's access to that Google account. The message after removal tells you whether access was ended. If other Paperclip connections still use the same Google account, Google keeps Paperclip's access until you remove those too. If Paperclip could not end access at Google, remove Paperclip from your Google account's [third-party connections](https://myaccount.google.com/connections). Connections that use your own Google OAuth app are removed only in Paperclip.
For a Google connection that Paperclip set up for you, removing the connection also asks Google to end Paperclip's access to that Google account. The message after removal tells you whether access was ended. If other Paperclip connections still use the same Google account, Google keeps Paperclip's access until you remove those too. If Google could not be reached or did not confirm, the message says so and Paperclip keeps trying in the background, for up to 30 days, even if Paperclip restarts. You do not need to do anything. The connection's activity shows when access was ended, or that Paperclip stopped trying. If Google gave a final answer that Paperclip cannot end the access, the message says so, and you can remove Paperclip from your Google account's [third-party connections](https://myaccount.google.com/connections).

When you delete a company, Paperclip also ends its access at Google for every Google connection Paperclip set up for that company. This continues in the background after the company is gone. Connections that use your own Google OAuth app are removed only in Paperclip.

Deletion starts right away and continues in the background. It finishes even if Paperclip restarts while it runs. If a step fails, for example because file storage is unavailable, Paperclip keeps the request open and tries again until every step succeeds. It reports the deletion as finished only then. The connection's page shows when the data was last deleted.

Expand Down
21 changes: 21 additions & 0 deletions packages/db/src/migrations/0503_melted_meggan.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE "google_pending_revocations" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"company_id" uuid NOT NULL,
"connection_id" uuid,
"grant_id" uuid,
"source_secret_id" uuid,
"subject" text NOT NULL,
"profile" text NOT NULL,
"token_material" jsonb NOT NULL,
"token_sha256" text NOT NULL,
"reason" text NOT NULL,
"attempts" integer DEFAULT 0 NOT NULL,
"last_outcome" text,
"next_attempt_at" timestamp with time zone DEFAULT now() NOT NULL,
"give_up_at" timestamp with time zone NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE INDEX "google_pending_revocations_due_idx" ON "google_pending_revocations" USING btree ("next_attempt_at","id");--> statement-breakpoint
CREATE UNIQUE INDEX "google_pending_revocations_token_idx" ON "google_pending_revocations" USING btree ("company_id","token_sha256");
Loading