Files
PaperClipAI/doc/plans/2026-11-17-google-workspace-code-fixes.md
DottaandClaude Opus 5.5 6385c171fa fix(connections): show only the privacy policy link in the Google Workspace picker (#22795)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The built-in Google Workspace connection lets agents use Gmail,
Drive (with Docs, Sheets and Slides) and Calendar
> - Before Google consent, the user chooses services in the "Connect
Google Workspace" picker
> - On Nov 17, #21998 added two text sections to this picker: "What
agents can do" and "How your data is used"
> - On Nov 24, the owner decided that this screen must show only the
privacy policy link and no other explanatory text
> - This pull request removes the two sections and keeps the privacy
policy link directly under the service rows
> - The benefit is a short picker that matches the owner decision, for
new setup and reconnect, in the Apps flow and the task-hosted flow

## Linked Issues or Issue Description

Refs #22634

**What happened?**
The "Connect Google Workspace" picker shows a "What agents can do"
section and a "How your data is used" section with bullet sentences. The
text changes with the selected services. The owner does not want this
text on the screen.

**What did you expect to happen?**
The picker shows the title, the three service rows (each with its access
select and switch), the privacy policy link, and Cancel / Continue. It
shows no other explanatory text for any selection.

**Steps to reproduce**
1. Open Apps and start a Google Workspace connection, or reconnect an
existing one.
2. Look at the service picker with all services on, with read only, and
with one service on.
3. See the two text sections above the footer.

## What Changed

- `ui/src/features/connections/GoogleWorkspaceServices.tsx`: remove the
`DataUseDisclosure` block. The privacy policy link ("Read our privacy
policy, including how we meet Google's Limited Use requirements",
`https://paperclip.ing/privacy`, new tab) now sits directly under the
service rows for every selection, including no selection. The "Select at
least one service to continue." status stays. The screen-reader
description "Choose the Google services to connect." stays. The URL
constant `GOOGLE_WORKSPACE_PRIVACY_POLICY_URL` moves into this file.
- `ui/src/features/connections/googleWorkspaceDisclosure.ts`: deleted.
Nothing else used the copy builder.
- `ui/src/features/connections/GoogleWorkspaceServices.test.tsx` (new;
the earlier suite was removed in #22729): for all services read & write,
all read only, one service, and no service, the dialog has no section
headings, no lists and none of the removed sentences. The link has its
text, href and new-tab target. The dialog keeps its accessible
description. Continue stays disabled with no service and submits the
chosen services.
-
`ui/storybook/stories/connection-setup/google-workspace-services.stories.tsx`:
the `ProductionPickerReadOnly` play test now checks that the removed
text is absent and the link is present.
- Docs: `doc/memory/google-connector-memory.md` gets a dated Nov 24
decision row with the risk.
`doc/plans/2026-11-17-google-workspace-production-checklist.md` no
longer claims a disclosure in the picker.
`doc/plans/2026-11-17-google-workspace-code-fixes.md` item 1 records the
removal.

The dialog now contains, from top to bottom: the Google Workspace logo
and the title "Connect Google Workspace"; Gmail, Drive ("Docs, Sheets,
and Slides") and Calendar rows, each with a "Read only / Read & write"
select and a switch; the privacy policy link; the empty-selection status
(only with no service on); Cancel and Continue in one footer row.

## Verification

- Red first: the new test ran against the old picker and 4 of 5 tests
failed (removed text present; link absent with no selection). After the
change all 5 pass.
- `cd ui && npx vitest run src/features/connections
src/pages/apps/AppDetail.test.tsx src/pages/apps/AppsConnect.test.tsx`:
8 files, 55 tests pass.
- `cd ui && node ../scripts/run-tsc.mjs -b`: no errors.
- `node scripts/check-token-gates.mjs`: all gates clean. `node
scripts/check-test-budget.mjs --files
ui/src/features/connections/GoogleWorkspaceServices.test.tsx`: pass.
`node scripts/storybook-catalog.mjs`: pass.
- `pnpm verify` exits 2 (a global CI input changed:
`doc/memory/google-connector-memory.md`). Required CI supplies the broad
coverage.
- Headless Playwright against Storybook dev, `ProductionPicker` at
1280x900 (dark and light) and `ProductionPickerMobile` at 375x812: the
dialog text is only the title, the rows, the link, and Cancel /
Continue. No horizontal scroll at 375 px. The link sits under the last
row with the normal dialog gap, and the footer follows it.
- Before: see the screenshots in #21998. After: the same dialog without
the two text sections.

## Risks

- Policy risk: Google's user data policy may expect a disclosure inside
the product, before consent, that says what data the app uses and how. A
privacy policy link alone may not satisfy a Google reviewer. This is a
recorded owner decision. If a reviewer asks, restore a short statement
above the link. The memory doc and the production checklist record this
risk.
- Low code risk. The change is UI-only. Selection, requested scopes,
OAuth and saved state 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, in Claude Code with
tool use (shell, file edits, headless browser).

## 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>
2026-11-24 11:47:32 -06:00

376 lines
19 KiB
Markdown

# Google Workspace connector: code fixes before submission
Started November 17, 2026. Temporary working plan; delete it once the items
land. It covers section 2 of the
[production checklist](2026-11-17-google-workspace-production-checklist.md).
Based on a read of master at `56654adecd`. Items marked **confirmed** were seen
in the code. Items marked **to check** are suspected gaps that need a look
before any change. Fixes 1 to 4 and 6 landed on November 17. Fix 9 has every
tool built but no service switched on. Fix 10 is done in the app. Fixes 5, 7
and 8 are not started.
Each fix is its own pull request with a failing test first. For the scope
change in fix 2, the deploy order is app first, then broker (see fix 10).
## Order
| # | Fix | Size | Blocks submission | Status |
| --- | --- | --- | --- | --- |
| 1 | Data-use disclosure in the picker | Small | Yes | Done, [#21998](https://github.com/paperclipai/paperclip/pull/21998); removed Nov 24 by owner decision |
| 2 | Lock the managed scope set to 14 | Small to medium | Yes | Done in the app, [#22001](https://github.com/paperclipai/paperclip/pull/22001) |
| 3 | Take `gmail.modify` off the Paperclip-managed client | Small | Yes | Done, [#22001](https://github.com/paperclipai/paperclip/pull/22001) |
| 4 | Confirm injection screening on Google results | Check, then small | Yes | Done, [#21999](https://github.com/paperclipai/paperclip/pull/21999) |
| 5 | Revoke at Google on last disconnect | Medium | Likely | Not started |
| 6 | Retention and deletion of Google content | Audit, then unknown | Yes | Done with limits, [#22010](https://github.com/paperclipai/paperclip/pull/22010) |
| 7 | Security scan findings | Unknown | Yes (assessment) | Not started |
| 8 | Remove the experimental gate | Small | No, release step | Not started |
| 9 | REST-backed tool set | Large | Yes | All 36 tools and the switch merged; none switched on |
| 10 | Scope cleanup across code, Cloud and Console | Medium | Yes | App done; broker and Console open |
## 1. Data-use disclosure in the picker
**Done** (Nov 17, [#21998](https://github.com/paperclipai/paperclip/pull/21998)).
Every Google Workspace sign-in start now goes through the picker, including
four sign-in paths on the app page. The Gmail read & write line says Google's
screen also mentions sending and that Paperclip does not send. The plan below
is kept for reference.
**Removed** (Nov 24) by owner decision. The picker keeps only the privacy
policy link, which names Google's Limited Use requirements.
**Confirmed gap.** `ServicePicker` in
`ui/src/features/connections/GoogleWorkspaceServices.tsx` shows three service
rows and Cancel / Continue. Its only description is screen-reader text. Google
requires a disclosure inside the app, immediately before consent, that says
what data is accessed and how it is used and shared; a privacy-policy link
alone does not count.
- Add a short visible block above the footer, built from the current selection:
what Paperclip will be able to read and change for the chosen services, that
agents send this content to the model provider configured for the workspace
to do the tasks they are given, that it is not used to train general models,
and where results are stored.
- Link the privacy policy and the Limited Use statement.
- The copy changes with the selection (read only versus read & write; Gmail
write says "create drafts", never "send").
- Show it for new setup and for reconnect, in both the Apps flow and the
task-hosted flow (both use `GoogleWorkspaceServicesDialog`).
- Tests in `GoogleWorkspaceServices.test.tsx`: disclosure present for each
selection, absent wording for unselected services, links present.
- Update the Storybook story under
`ui/storybook/stories/connection-setup/google-workspace-services.stories.tsx`.
- Follow `DESIGN.md` (tokens only, form footer rules).
Link to <https://paperclip.ing/privacy> (section 4.1 holds the Limited Use
statement). The disclosure wording must agree with that policy, so the policy
edits listed in the working memory land first or together. Dotta signs off
the wording.
## 2. Lock the managed scope set to 14
**Done in the app** (Nov 17, [#22001](https://github.com/paperclipai/paperclip/pull/22001)).
`GOOGLE_WORKSPACE_SUBMITTED_SCOPES` is the hand-written list of 14 and
`workspace.all` uses it. Requests outside the 14 are rejected; scopes Google
reports on a saved grant are capped to the 14 instead of failing it. The
broker change is in fix 10. The plan below is kept for reference.
**Confirmed.** The selector derives scopes from
`GOOGLE_WORKSPACE_SERVICE_GROUPS` in
`packages/shared/src/google-workspace-connectors.ts`, which yields 14 scopes
across all modes. But the `workspace.all` profile is still the 21-scope legacy
union (Chat, Contacts, Directory, profile and `calendar.readonly` included),
and `isGoogleWorkspaceScopeGrant` accepts any subset of those 21.
- Add a test that the union of every selectable combination equals an explicit
list of the 14 scopes, so a new scope cannot slip in unnoticed. Today's tests
pin 9 (default) and 21 (legacy) only.
- Add a server test that an authorization request for the unified connection
carrying any scope outside the 14 is rejected, for both the managed and the
customer-owned path.
- Narrow `isGoogleWorkspaceScopeGrant` for the unified connection to the 14.
**To check first:** whether saved grants or the broker's sealed envelopes
depend on the 21-scope definition (the code comment says the union is kept
stable for the broker contract). If so, add a separate 14-scope constant and
leave the legacy definition for old grants.
- Companion change in the Cloud broker registry so the production client
cannot be asked for the other 7. App first, then broker (fix 10).
## 3. Take `gmail.modify` off the Paperclip-managed client
**Done** (Nov 17, [#22001](https://github.com/paperclipai/paperclip/pull/22001)).
Gmail archive, Chat, People and Workspace Search managed methods are no longer
offered for new setup or reconnect; saved connections keep refreshing and
running. The broker has no `gmail.archive` profile. The plan below is kept for
reference.
**Confirmed.** `packages/shared/src/app-definitions/gmail.json` has a
`paperclip-archive` method ("Connect with Paperclip", profile `gmail.archive`)
that requests `gmail.modify`, a restricted scope that is not in the
submission. If the production broker ever enables that profile, the verified
client requests an undeclared restricted scope.
- Remove the `paperclip-archive` method, or gate it so it can never use the
Paperclip-managed client. Keep `customer-archive-oauth` (the customer's own
Google client is outside our verification).
- Keep `server/src/services/gmail-archive-tool-policy.ts` working for saved
connections.
- **To check:** whether any saved connection uses `paperclip-archive`, and
whether the production or staging broker has `gmail.archive` enabled.
- Do the same inventory for every other "Connect with Paperclip" Google method
in `packages/shared/src/app-definitions/google-*.json` and `gmail.json`
(Chat, People, Workspace Search and the per-service cards): each one that can
reach the managed client either stays within the 14 scopes or loses its
managed method.
- Test: no app definition with the managed strategy lists a scope outside the 14.
## 4. Confirm injection screening on Google results
**Done** (Nov 17, [#21999](https://github.com/paperclipai/paperclip/pull/21999)).
Every path was traced and tested. The one unscreened path, resource reads
through a named gateway, is now screened for every connector. What screening
does and does not cover is in `doc/prompt-injection-prevention.md`. The plan
below is kept for reference.
**To check.** Tool-result screening exists
(`doc/prompt-injection-prevention.md`): built-in detection is always on, and a
model check is optional per company. Not yet confirmed that every Google
Workspace tool result passes through it, in particular email bodies and file
content fetched through the unified connection.
- Trace a `gmail__get_message` and a `drive__read_file_content` call from the
gateway to the runner and confirm the guard runs on the result.
- Add a test with an injected instruction inside an email body and inside a
document, expecting `prompt_injection_blocked`.
- Fix any path that skips the guard.
- Write two paragraphs for the submission describing what the screening does
and does not protect against.
## 5. Revoke at Google on last disconnect
**Confirmed behavior, likely gap.** Removing a managed Google connection is
local only, because Google's revoke ends every grant for that user on the
client and would break their other Google connections
(`doc/connections/GOOGLE-WORKSPACE.md`). With one unified connection that
reasoning mostly goes away, and reviewers expect disconnect to end access.
- When a user removes their last grant on the Paperclip-managed Google client,
call Google's revoke endpoint through the broker.
- If other grants for the same Google account remain, stay local and say so in
the confirmation text.
- Tests: last grant revokes; one of two does not; a revoke failure still
removes the local credential and reports the failure.
- Needs a broker endpoint; broker first.
## 6. Retention and deletion of Google content
**Done, with limits** (Nov 17, [#22010](https://github.com/paperclipai/paperclip/pull/22010)).
Any connection's page has "Delete data", and removing a connection offers the
same. It clears previews, approval cards, results passed to later runs, app
views and the whole transcript of each settled run that used the connection.
It keeps call records without content. Deleting a task or a company runs
the same cleanup, including run logs and saved files in storage. Limits:
content agents wrote into tasks stays until the task is deleted; "Delete data"
skips runs in progress. The help page is
`docs/guides/board-operator/deleting-connection-data.md`. The inventory is in
the working memory under "Where Google content is kept". Revoking at Google is
fix 5. The plan below is kept for reference.
**To check.** Email and file content returned by tools is stored in task
comments, run history, tool results and attachments. Disconnecting does not
delete any of it. Google requires that users can delete their data and that we
document how.
Audit findings (Nov 17, as reported) are in the working memory under "Where
Google content is kept". The planned fix is a "delete data read through this
connection" action.
- Inventory where Google tool results are stored and for how long.
- Confirm that deleting a task or a workspace removes them.
- Decide with the privacy owner whether an explicit "delete data from this
connection" action is needed. If the answer is yes, that becomes its own plan.
- Write the user help page either way.
## 7. Security scan findings
- Run the static and dynamic scans used for the CASA self-assessment against
the server, the broker and the reviewer instance.
- Triage findings into fix now, accepted with reason, and not applicable.
- One pull request per finding class.
## 8. Remove the experimental gate (release step, last)
**Confirmed.** `enableGoogleWorkspaceConnector` defaults to off
(`packages/shared/src/validators/instance.ts`, set on the app definition in
`google-workspace.json`, enforced in `tool-gateway.ts`,
`connection-intents.ts` and `setup-policy.ts`).
- After Google approves: default it on, or remove the key and its checks.
- Update `doc/connections/GOOGLE-WORKSPACE.md` and the release notes.
- Decide what happens to the aggregator Google apps that appear while the gate
is off.
## 9. REST-backed tool set (chosen November 17)
Decision: launch on our own tools over Google's REST APIs, designed so we can
switch to Google's hosted MCP servers later, kept in one folder so it can be
deleted cleanly. Part 1 is
[#22000](https://github.com/paperclipai/paperclip/pull/22000) (merged Nov 17): the
folder and Gmail `get_message`, `search_threads` and `create_draft`. Its README
records the dispatch trace and the recommended in-process seam.
Status (Nov 17, night):
| Service | Implemented | Switched on | PRs |
| --- | --- | --- | --- |
| Gmail | 9 of 9 | No | [#22000](https://github.com/paperclipai/paperclip/pull/22000), [#22014](https://github.com/paperclipai/paperclip/pull/22014) |
| Calendar | 9 of 9 | No | [#22017](https://github.com/paperclipai/paperclip/pull/22017) |
| Drive | 8 of 8 | No | [#22028](https://github.com/paperclipai/paperclip/pull/22028) |
| Docs | 2 of 2 | No | [#22029](https://github.com/paperclipai/paperclip/pull/22029) |
| Sheets | 6 of 6 | No | [#22027](https://github.com/paperclipai/paperclip/pull/22027) |
| Slides | 2 of 2 | No | [#22029](https://github.com/paperclipai/paperclip/pull/22029) |
The per-service switch and in-process dispatch landed in
[#22016](https://github.com/paperclipai/paperclip/pull/22016). Every service is
still on Google's MCP. The gateway calls the REST tools in process, as the
trace in #22000 recommended. The gateway also sets the size limit for REST
results (999,885 bytes, matching what it accepts from Google's MCP servers);
see "Result size" in the folder README.
Remaining work:
- Refuse inserting an image by public web address in Docs and Slides before
they are switched on (Google fetches an address the agent chose).
- Create the staging tester and run live acceptance there.
- Switch services to REST one at a time, each after its live test.
- Record a `tools/list` and sample answers from Google's servers for the
contract test, and compare `read_doc` and `read_presentation` content.
- Check `copy_file` under `drive.file` on a file the app never opened.
- Removal test (step 4 below).
### The seam
Today the unified connection sends each tool call, with the user's Google
access token, to a Google MCP endpoint chosen by a closed registry in
`packages/shared/src/google-workspace-connectors.ts` (`serverUrl` per service).
Everything above that point (picker, scopes, grant checks, allowlist, approval,
audit, injection screening) only knows tool names and required scopes.
So the replacement is **an MCP server of our own that exposes the same tools
as Google's**: same names, same input fields, same result shape, backed by
REST. The rest of the system keeps speaking MCP to it and cannot tell the
difference. Switching to Google's MCP later is changing which endpoint the
registry returns.
### Layout
One folder inside the existing server, not a new package. No new dependency,
workspace or release change.
```
server/src/google-workspace-rest-tools/
index.ts the only entry point: create the server / handle a call
server.ts MCP wiring (list tools, call tool); thin
google-http.ts the one place that calls googleapis.com: auth header,
allowed hosts, errors mapped to MCP errors, retry rules
tools.ts, tool.ts the tool list and the shared tool shape
errors.ts
README.md boundary rules, dispatch trace, differences from Google
gmail/ one file per tool, plus schemas and helpers
drive/ (later) args in, REST request out,
docs/ REST response in, MCP result out
sheets/
slides/
calendar/
```
### Boundary rules
- **One switch.** The registry gains a transport choice per service
(`google_mcp` or `paperclip_rest`). That choice, plus registering the
folder, is the only Google-REST knowledge outside the folder.
- **No REST types leave the folder.** Its public surface is MCP tool
definitions and MCP results. A boundary test limits its imports to its own
files, Node built-ins, the MCP SDK and `zod`.
- **Nothing in the folder knows about Paperclip.** No company, connection,
grant, policy or audit code. It receives a tool name, arguments and an
access token, and returns a result. Authorization, scope checks, approval,
audit and injection screening stay with their current owners in the gateway.
- **It stores nothing.** No tokens, no content, no cache.
- **The allowlist stays where it is.** `toolScopes` in
`google-workspace-connectors.ts` remains the single list of allowed tools;
the folder implements exactly that list, and a test fails if the two differ.
- **Removal test.** Deleting the folder and setting the switch to `google_mcp`
leaves a build that passes. Add this as a checklist item for the removal PR.
### Parity
- Tool names and schemas come from Google's published MCP tool reference, not
from our guess. A contract test compares our definitions with a recorded
listing from Google's servers (we can record it on our enrolled internal
account).
- Where REST cannot match an MCP tool's behavior exactly, write the difference
in the folder's README rather than hiding it.
### Order of work
1. Trace the dispatch path and confirm the seam. Traced in #22000's README:
an in-process call, because the egress guard refuses a loopback address on
public deployments.
2. Folder skeleton, `google-http.ts`, and Gmail `get_message`,
`search_threads` and `create_draft` (#22000, merged). Then the switch, end to
end on the staging tester. The demo depends on Gmail.
3. Rest of Gmail, then Calendar, Drive, Docs, Sheets, Slides (done Nov 17).
4. Contract and removal tests.
Tools to build (36): Gmail 9, Drive 8, Docs 2, Sheets 6, Slides 2, Calendar 9.
### To check
- Whether a Google client marked for AI agents may call the REST APIs.
- Each Cloud project needs the six REST APIs enabled.
- Speed: this sits in the tool-call path. Measured: the adapter adds about
15 µs per call; the result size check adds about 5 µs for a 4 KB result.
### Lessons
- **Address parsing:** patching a split-on-commas parser case by case kept
breaking (comments, groups, IPv6 literals); write one RFC 5322 tokenizer with
table-driven tests from the start.
- **No new package:** the server is published, so a new package it depends on
would also need publishing; a folder inside the server avoids that.
## 10. Scope cleanup across code, Cloud and Console
Decision (November 17): what we ask for, what the code accepts, what the
Cloud broker allows and what the Console declares must be the same 14 scopes.
Fixes 2 and 3 cover this repository and are done. Still needed in the Cloud
broker (`paperclip-cloud`, registry at `src/connections/providers.ts`, as
reported by the Nov 17 audit):
- Limit `workspace.all` to the 14.
- On refresh and claim, cap reported scopes to the 14 instead of failing, and
keep accepting the old 21-scope refresh binding until older app versions are
gone.
- Stop offering Chat, People and Search for new sessions on the verified
client.
- Do not merge the branch that adds a Gmail archive profile.
- Deploy order: app first, then broker.
Also needed:
- Compare the Console declaration for both Google apps with the 14 (needs the
project owner's sign-in).
- Keep the working memory's "Scopes" and "Cloud broker" sections current.
Read & write Calendar now also requests `calendar.events.freebusy` (Nov 17).
It is one of the 14 and the broker accepts any nonempty subset of
`workspace.all`, so neither the broker nor the Console needs a change for it.
## Not code, but needed by these fixes
- Published privacy policy and Limited Use statement URLs (fix 1).
- Sign-off on disclosure wording (fix 1).
- Broker changes in the Cloud repository (fixes 5 and 10).
- Current broker profile settings for staging and production (fixes 2, 3).