-
Notifications
You must be signed in to change notification settings - Fork 600
feat(drive): changes serve — receive Drive push notifications and trigger callbacks #689
Copy link
Copy link
Open
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:securityThis issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.This issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:securityThis issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.This issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Motivation
gog drive changes watchalready registers an HTTPS webhook channel against the Drive Changes API. The receiving side — the HTTPS endpoint Google posts to — is left as an exercise for the user. Meanwhile, the Gmail side ships a complete push handler atgog gmail watch serve(seeinternal/cmd/gmail_watch_server.go). The Drive equivalent is missing, which means anyone wanting real-time change events has to roll their own HTTPS receiver, deal with cert/tunnel setup, parseX-Goog-Channel-*headers, persist thepageTokenbetween events, and renew the channel before its TTL expires.This is the missing half of
drive changes watch. With it, end-to-end automation ("fire a script every time something changes on this doc") works out of the box.Pairs with
comments list --since=<RFC3339>— Drive'schanges.watchfires on file mutations but does not carry which comment changed. The canonical pattern ischanges.watch→ on event, callcomments.list?startModifiedTime=<last-seen>to enumerate new/edited comments. Without feat(comments): add --since=<RFC3339> filter on docs/drive comments list #688, the on-change handler has to list-all-and-filter-client-side, which is wasteful at scale.docs comments locate— once a comment event fires, the consumer typically wants to act on the comment's anchor text.comments locateis the resolver that turns the event into an actionable(startIndex, endIndex)for the next batchUpdate.drive changes poll— strict alternative toservefor environments that cannot host an HTTPS endpoint (firewalls, ephemeral laptops). Both subcommands sharestate-filesemantics and the--on-changecallback shape.Together these four close the comment-driven edit loop:
serve(orpoll) detects the change,comments list --sinceenumerates what is new,comments locateresolves the anchor, and an existing surgical command (delete / format / insert-person etc.) acts on the resolved range.Repro
Proposed surface
Payload format for
--on-change:{ "channelId": "...", "resourceState": "change", "messageNumber": 17, "resourceUri": "...", "changes": [{"fileId":"...","time":"...","removed":false}] }Mirrors
gog gmail watch servestructure: ServeHTTP authenticates byX-Goog-Channel-Token, callschanges.list, optionally invokes the user callback, persists the new token.Acceptance criteria
X-Goog-Channel-Token; returns 401 on mismatch.--on-changeis invoked once per notification with the JSON payload on stdin.--auto-renewre-issueschanges.watchat least--renew-beforeahead of expiration and rolls over the channel id cleanly.--filter-file=<id>short-circuits before callingon-changewhen the changes list does not include the target file.References
changes.watchreference: https://developers.google.com/workspace/drive/api/reference/rest/v3/changes/watchchanges.listreference: https://developers.google.com/workspace/drive/api/reference/rest/v3/changes/listinternal/cmd/gmail_watch_server.go(Pub/Sub push handler),internal/cmd/drive_changes.go(watch + stop)