Add Google Drive metadata search - #292
Open
ndisidore wants to merge 6 commits into
Open
Conversation
ndisidore
force-pushed
the
feat/gk-google-drive-search
branch
from
August 21, 2026 22:46
a876b09 to
c33aa40
Compare
A code review of the Drive expansion found one blocker class and several correctness gaps. This is the remediation pass. Nothing here changes what the feature does; it changes what it is allowed to reach and what it admits, and it removes a duplicated admission path. Grants are now recorded rather than inferred. `grantedResourcesFromScopes` reported a resource as granted when every one of its OAuth scopes was held, so any account that had ever connected a Doc or a Sheet reported the whole-account Drive pattern as already granted: `ensureResources` would then skip consent entirely and `hasDriveResourceGrant` would pass. The account now persists the resource set the user actually consented to, and the scope-derived list is frozen to the resources that predate recording. Drive's batch `files.get` no longer reads a stale token as a denial. The batch POST returns 200 when a subrequest 401s, so `fetchWithAuthRetry`'s one-shot refresh never saw it and every file came back inaccessible, permanently. The batch now forces the same cache invalidation the helper uses and replays once. Parts are placed by their echoed Content-ID rather than by arrival order, since these booleans gate observer admission and a swapped pair admits the wrong collaborator. `corpora`/`driveId` became one `DriveCorpus` value: a `driveId` without `corpora: "drive"` silently falls back to the user corpus, and a shared-drive binding's whole boundary is those two travelling together. Observer verification is capped again. `maxTrackedSets: null` was justified as safe for bulk verifiers because their per-open RPC count stays bounded, but the work behind that RPC is not: a bulk Drive check issues ceil(N/100) sequential subrequests, per observer, on every open. The staged-observer rollback also never fired, because it compared a deserialized KV value against the in-memory stub by reference; it now turns on a nonce. Drive observer admission is one path for all three scopes. A file binding forked in four places and hand-rolled its own verify, which duplicated the tracker's semantics and did not get the rollback fix above. A shared-drive or single-file binding is now seeded with the set its scope already names, so the tracker handles every scope and `addObserver`/`removeObserver` are one-liners. The factory takes `verifyBatch` rather than a verifier type, which keeps `drive-session.ts` independent of the worker entrypoint and makes the seeding invariant testable for the first time. `getScope()` refuses a provider id that disagrees with the binding, rather than labelling the binding with another drive's or file's name. `search()` refuses a single-file binding outright: Drive `q` has no `id =` clause, so it would have scanned the whole account and post-filtered. Documentation is matched to the code on the surfaces that describe authority. Account scope is not limited to My Drive, and reads by ID are not scope-checked, so the README and `DriveScope` say so. The model-facing type now records that `fullTextContains` reaches body text, description and OCR - the README already said it, but the agent never reads the README. A parity test pins all six `*-types.txt` files to their `.d.ts`, following the `mcp-shared/base-types` precedent; only `drive-types` had been checked, and by nothing. Verified: `pnpm build`, `pnpm lint:check` (0 errors), `pnpm test` across the workspace, and the release manifest golden test.
ndisidore
marked this pull request as ready for review
August 24, 2026 18:03
Member
|
Few GPT findings: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds read-only Google Drive metadata search for a connected account, one organization-owned shared drive, or one file. Agents can find files and folders, inspect their metadata, and page through results without receiving file contents or changing anything in Drive. Each binding stays within its selected scope, and shared workspaces recheck access to every file they have seen. The change also adds resource pickers, OAuth scope mapping, the public TypeScript API, and coverage for queries, pagination, scopes, and sharing.