Repository navigation
fix(connections): keep retrying when Google does not confirm a revoked grant - #22669
cryppadotta wants to merge 15 commits into
Conversation
…d grant Owner decision 2026-11-23: when Google access must end and Google cannot be reached or confirm, the app keeps the refresh token in a pending revocation record and retries until Google answers. Paperclip Cloud still never stores provider tokens. Before this change, removing a Paperclip-managed Google connection or grant deleted the refresh token whatever Paperclip Cloud answered, so a failed or unconfirmed revoke could never be retried and Google access stayed open. - google_pending_revocations holds the token's local_encrypted material (copied from the connection secret version, never plaintext), keyed by the token hash, with company_id and no foreign key. - Removal queues the token before the broker call, so a restart during the call still resumes; a final answer deletes the row, a retryable one keeps it and the removal reports "retrying". - The google-pending-revocation delivery queue retries with a lease, 1 minute to 6 hours backoff and a 30-day hard stop, and writes an audit event and an activity entry when it ends. - Company deletion queues every managed Google token inside the delete transaction; a Cloud-removed instance queues them, then drops the connection secrets. - The removal message says Paperclip keeps trying, with no action needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l result type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mber Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Feynman Nuclear Review — 5/5Re-review of 21204beThe PR's revocation code is unchanged from the 5/5 head 45b0015: the pending-revocation worker, the access-removal flow, the admin-only durable sweep, version pinning, and the lifecycle wiring and tests all carry the same diff. The branch has since merged upstream master, which refactored The PR's adapter is correct against that refactor. A 401 (or a transient error with a remembered Residual notes, not defects: the merged Verdict: no actionable correctness, security, or reliability defects found within the stated coverage. Advisory only. Score 5 because the PR's own code is unchanged from the previously published 5/5 head and its adaptation to the merged connector refactor is correct. Evidence: the compare delta lists 54 files, but only 7 are in the PR's 31-file set; the rest are base/merge drift. Only Reviewed commit: Coverage: 31 files. Task: PAP-6439 · Run · Review history |
Ponytail Paperclip Review — 4/5What this change does: A managed Google connection removal keeps the encrypted refresh token in Prior findings: the earlier reliability, tenant, live-use, instance-removal, pinned-version, transactional-sweep, admin-gate, and activity-feed fixes remain. The refactor preserves the 401 and signed-removal behavior, and the connector tests still assert both; the PR diff against the new base is still the same 31 files. Nice to have
Verdict: ship; the two items above are optional. Not checked: tests and typecheck were not run (no dependencies or database); CI/check status was unavailable; no live broker or Google call was made; the merge and refactor were inspected but not executed. Score 4: the current head merges master and refactors the status read without changing the PR's contract. Reviewed commit: Coverage: 31 files. Task: PAP-6440 · Run · Review history |
[Critical impact] No new blocking issue was established in this review. SummaryAdds saved, encrypted Google revocations and a background worker that retries unconfirmed removal for up to 30 days.
Reviews (7) · Last reviewed commit: "chore(runner-e2e): refresh pinned source..." · Reviewed by Greptile |
…d, and act only on a confirmed instance removal A restart between the first broker call and the secret delete left the removed grant's own secret live, and the worker read it as another live holder and dropped the retry. The pending row now records its source secret and the live-holder check skips it. A 401 from Paperclip Cloud's status check no longer starts the instance removal cleanup; only a signed status: removed answer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vocation * origin/master: fix(antigravity): offer the cloud candidate in the agent picker for linux-x64 environments (#22655) fix(cloud): name every durable-data blocker in the online pass result (#22641) fix(workspaces): move a workspace with only a task warning online, as offline already does (#22650)
…dge live use by references The pending row is now unique per company and token, and settling or dropping it is filtered by company, so one company's removal can never settle another company's retry. A live holder is now a secret that a live grant or connection refers to; a stored but unused copy, or a secret whose delete failed, no longer cancels the retry. The removed instance cleanup no longer runs inside the status request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@greptileai review |
…nd limit instance cleanup to instance admins The live-use check now counts any secret with the same token that a live grant or connection uses, including the row's source secret, so a grant signed in again before the retry is never revoked under it. Rows queued for a removed instance skip the check. Only an instance admin's status check starts the removed-instance cleanup, and only one sweep runs at a time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vocation * origin/master: test(native): give the repeated-bytes provider pack tests a 60s timeout (#22663)
|
@greptileai review |
…removed-instance sweep atomically A grant that pins an older refresh-token version sends that version, so the retry now keeps the same version instead of the latest one. The removed-instance cleanup queues every company's tokens in one transaction before it drops any secret, and the status request waits for that save; the in-process single-flight guard is gone because the queue is idempotent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@greptileai review |
…nce cleanup Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nection's Activity tab Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt types Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@greptileai review |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thinking Path
Linked Issues or Issue Description
Refs #22065
What happened?
A managed Google connection was removed while Paperclip Cloud or Google was unavailable. The removal result was
not_ended, and the refresh token was deleted. Paperclip could not try again, so Google access stayed open.What did you expect?
Paperclip keeps the token only for the retry, and retries automatically until Google confirms or gives a final answer. The user sees that Paperclip keeps trying, and does not need to act.
Steps to reproduce
What Changed
google_pending_revocations(migration0502, additive,CREATE TABLEonly). It hascompany_idwith no foreign key, so a row outlives a deleted company. It stores the token as the samelocal_encryptedmaterial as the connection secret version. It never stores plaintext. It is not a company secret: it is not listed, an agent cannot bind it, and no route reads it.google-access-removal.ts: before the broker call, the app copies the sent token version into a pending row (lease 2 minutes, so a restart during the call resumes). A final outcome deletes the row. A retryable outcome (provider_revocation_failed,revocation_in_progress,broker_unavailable,broker_error,unexpected_error) keeps it, and the result is the newretrying. If the connection secret is still live after the conditional delete (for example, the user signed in again during the call), the row is deleted.google-pending-revocationdelivery queue (registerDeadlineWork; it registers the real next deadline and has no deadline when the table is empty). Each attempt takes a lease on the row and calls the broker with a 15-second timeout. Backoff is 1, 2, 4 ... minutes, up to 6 hours. The hard stop is 30 days. The worker stops without a call if a live company secret holds the same token.connection.google_access_retryaudit event and atool_connection.google_access_endedortool_connection.google_access_not_endedactivity entry (labels added to the activity feed). For a deleted company, it writes only a log line.reason = company_deleted).removed, the app queues every managed Google token (reason = instance_removed), then deletes each connection secret.ManagedGoogleAccessRemoval.resultgetsretrying(shared type and OpenAPI schema). The removal message forretrying: "Google didn't confirm that Paperclip's access has ended yet. Paperclip will keep trying automatically." It has no link and asks for no action.doc/connections/GOOGLE-WORKSPACE.md("Pending revocation"),docs/api/tool-connections.md, the help pagedocs/guides/board-operator/deleting-connection-data.md, and a dated decision row indoc/memory/google-connector-memory.md.tests/runner-e2e/source-sdk-public-inputs.jsonrefreshed for the changed shared type, aspnpm verifyasks.Verification
npx vitest run src/__tests__/google-managed-connection-removal.test.ts(embedded Postgres): 46 pass. Without the fix, 15 fail (red), with the fix all pass (green). New cases:binding_not_known,other_connections_remainandprovider_revocation_disabledstop the retry;403 INSTANCE_SUSPENDEDis retried;npx vitest run src/__tests__/paperclip-cloud-connector-status.test.ts: the removed-instance hook runs only forremoved, and a failure does not change the status.ui:npx vitest run src/features/connections/googleAccessRemoval.test.ts(7 pass, the newretryingcase is red without the change).tool-connection-content-deletion, its canary,delivery-work-coordinator,idle-local-work,packages/dbtests;servertsc --noEmit.pnpm verifyexits 2 (global doc input changed), so required CI supplies the broad coverage.Risks
CREATE TABLEand indexes on the new table):online_compatible.403and the app retries until the hard stop. The Cloud broker change that accepts it is a separate PR in the private Cloud repository.Model Used
claude-opus-5-5) through Claude Code, with tool use (shell, file edits, embedded Postgres tests), standard reasoning.Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template#NNN/github.com/paperclipai/paperclipURLs)docs/...,fix/...) and contains no internal Paperclip ticket id or instance-derived details🤖 Generated with Claude Code