Skip to content

Drive sync depends on a heavier client stack than its API usage warrants #11

Closed

Description

@Sinity

Context

Polylogue only needs a small slice of Drive v3 functionality — list files, fetch metadata, resolve folders by name, and download bytes — but the current implementation pays for a much larger client-library surface.

The packaging symptoms are already visible. Drive support drags in multiple Google libraries, the development shells and build outputs have to accommodate them, and there is still unrelated weight in the dependency tree. There is also an auth compatibility concern: console-based OAuth flow assumptions are sensitive to library-version differences.

Separate from Drive itself, the tighter build/package loop is exposing some fragility in adjacent code paths such as stats filtering and package discovery. Those are not the main problem, but they are part of the practical scope if we touch the transport layer and the project’s packaging metadata in the same round of work.

Motivation

The project only needs a small subset of Drive v3 behavior: list files, fetch metadata, resolve folders by name, and download file bytes. Carrying the full client-library surface for that subset adds dependency weight and hides behavior that would be clearer if implemented directly with authenticated HTTP requests.

There is also a maintainability benefit to owning the request/response boundary ourselves. Pagination, metadata fields, streaming downloads, and HTTP error handling become explicit in our code instead of living inside generated client objects. That should make the Drive layer easier to debug and easier to package.

This is also a good moment to rationalize the dependency tree. If the project no longer needs client-library download helpers or unrelated Google packages, the build and dev environments should reflect that. Any refactor here should also leave the package discovery/build path in a healthy state so importer subpackages and typed stats filtering keep working during CI/Nix builds.

Scope

In scope:

  • replace generated Google Drive client usage with authenticated REST requests
  • introduce a project-defined Drive error type instead of exposing client-library exceptions
  • stream file downloads without MediaIoBaseDownload
  • keep console OAuth working across auth-library versions, including environments where run_console() is unavailable
  • reduce the dependency set in pyproject.toml, flake outputs, and dev shells accordingly
  • fix packaging/build fallout uncovered by the refactor, including package discovery and stats filter parsing

Out of scope:

  • redesigning the Drive-facing CLI UX
  • adding new Drive features beyond the existing sync/list/download needs
  • a broader persistence or schema change

Acceptance criteria

  • Drive list/get/download operations run through project-owned REST helpers using authenticated HTTP sessions rather than googleapiclient.discovery.Resource.
  • Transport failures surface through a project-defined error type with enough structured information for callers to report status cleanly.
  • The project dependency set no longer includes the Google API client library, google-auth-httplib2, or google-generativeai, and adds only the lightweight pieces needed for auth + HTTP.
  • Console OAuth still works when run_console() is absent in the installed auth library.
  • Built wheels include importer subpackages, and stats filtering continues to work in build/test environments that pass typed date or numeric filter values.

Activity

  1. added
    type:refactor
    faux-pull-request
    on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliarea:pipelinefaux-pull-requesttype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions