Skip to content

custom(google-disconnect-forget): forget Google data on disconnect, 30-day limit on mail and event text - #4

Merged
Old-G merged 9 commits into
customfrom
Old-G/google-disconnect-forget
Nov 25, 2026
Merged

Old-G merged 9 commits into
customfrom
Old-G/google-disconnect-forget

Conversation

@Old-G

@Old-G Old-G commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Disconnecting a Google account (or the HQ mailbox) now removes what Orca+ kept from it, and Google mail/event text stops living forever in HQ's ledger and in automation run history. This follows the Google Workspace AI tools terms: no user data kept after a disconnect, nothing derived from it kept past 30 days.

What changes

HQ mailbox (gmail:disconnect, also a client change in importGmailClient)

  • Ledger mail threads (gmail:<thread>) keep only their id, project, chat and times. Letters, subjects, senders, the model's gist and drafts, a reply copied into a waiting, and the guess's reason are removed. secure_delete plus a WAL checkpoint so the bytes leave the file.
  • The mail intake's message ids (slack-scout/mail-state.json → seen: [], lastCheckAt kept) and the mail reader's cursor are reset. A reader pass that was mid-read when the mailbox went sends no more letters to the model and writes nothing, even if the same address is connected again meanwhile. An intake pass that began before the disconnect (say, waiting on ClickUp) drops the ids it wrote once its writes are done.
  • Done / project events logged under gmail:<thread> move to the forgotten key, so the thread id leaves event history too.
  • Every 6 h, checked on the mail reader's 2-minute poll (no timer of its own), a mail thread quiet for 30 days is forgotten the same way. Older letters also leave threads that are still active, and such a thread's title (the first letter's subject or the model's gist of it) becomes Mail thread (older letters removed).
  • The model's project guess on a letter runs with --no-session-persistence, so it leaves no Claude transcript.

Bot Google accounts (google.disconnect: Settings, CLI and phone)

  • forgetGoogleAccount(email) runs after the sign-in file is removed. It drops the account's Gmail history id, calendar sync tokens and bots' listening times from orca-google-triggers.json, and its Drive text from the paging cache (a Drive read still converting at that moment doesn't put its text back). Registered listeners drop the account's run history and retire the trigger checker.
  • The trigger checker is retired, not edited: its schedules, timers and backoff go with it, and a check still waiting on Google when the account went can neither start a bot nor write its old state back. A fresh checker runs right away over the scrubbed state and sets the other accounts' Calendar timers again; the run path drops repeat events.
  • default-account.enc is removed when it names the removed address, so the last account leaves no address behind. A pick this host can't read is kept, as before.

Automation run history

  • forgetAutomationRunGoogleEvents by account: a finished run loses event, eventKeys, outputSnapshot and actor/place. An unfinished run loses only the text fields, so it still folds and dedupes.
  • For 6 hours after a disconnect, each tick scrubs that account's runs again, so a run going at the disconnect, or an event already on its way into a run, loses its words once it settles. Only events from before the disconnect: the same address connected again keeps its new runs. A repeat scrub writes nothing when nothing changed.
  • By date: once an hour, finished runs whose Google event is older than 30 days lose the event. The run's times, status and source stay.

Not changed (on purpose)

  • The OAuth clients (~/.orca/google/client.enc, <profile>/gmail/client.enc). They are the app's own key, not user data, and reconnecting needs them.
  • Bot.googleAccounts and the accounts named in automation rules. These are settings: which bot may use which account.
  • Files a bot downloaded with --download at the user's request, bot memory, and chat transcripts. These need a separate decision.
  • A Google event copied into a bot chat (launch prompt, automationRun metadata, a not-started card that Send again replays). The chat journal is its own subsystem; left for a decision (Codex P1, round 1).

Known limits

  • A Gmail or Calendar run still going at disconnect finishes and saves its output; its words leave on the next tick after it settles if that is within 6 hours and Orca was not restarted meanwhile (the repeat scrub lives in memory), otherwise at the 30-day sweep.
  • An event already inside the run path at the moment of disconnect can still start its bot a few seconds later; the run's history line is scrubbed by the 6-hour repeat.
  • The gmail:% forget also reaches threads the separate Gmail MCP writes under the same prefix: it removes more than needed, never less.
  • After a reconnect inside the Calendar grace window a bot may get the same meeting again (the forget drops the run's dedupe keys along with its Google words).
  • A second runtime sharing ~/.orca/google (orca serve beside the desktop app) doesn't hear a disconnect made in the other one; its run history is cleaned by the 30-day sweep.
  • Claude transcripts of the HQ mail classifier made before this PR (it now runs with --no-session-persistence) are not removed; telling them apart from other sessions needs its own change.
  • A meeting of another account that starts during the few seconds of the fresh check after a disconnect can miss its zero-minute trigger.

Testing

  • New tests: google-account-forget (also a Drive read in flight), google-connect-disconnect (real files under a temporary home: sign-in and trigger state gone, the other account kept), google-default-account (last account leaves no default), google-trigger-retire (a check waiting on Google at disconnect starts no bot and writes no state), automation-run-google-forget, pulse-ledger-forget (incl. the trimmed thread's title), hq-mail-forget (an intake pass in flight at a disconnect keeps no ids), hq-mail-ledger-reader (disconnect mid-pass, reset vs. in-flight pass with the same address), hq-task-questions-no-transcript. The mock-only Gmail listener test from the first round is dropped.
  • Ran 23 test files (new plus existing google/, pulse-db, pulse-ledger, hq-mail-intake, hq-task-questions): 155 passed. With each new guard reverted, its test fails (retire, ledger generation, Drive in-flight, 6-hour repeat scrub, mid-pass stop, event key move, intake in flight).
  • oxlint and oxfmt --check are clean on the touched files; the max-lines ratchet no longer reports any file of this PR. No local typecheck per the project's Mac rule; CI runs it.

Performance

None, because the new work runs only on a disconnect, on each tick for 6 hours after one (a repeat scrub of that account that writes nothing when nothing changed), once an hour (run history sweep) and every 6 hours (mail ledger sweep, checked on the existing mail reader poll), each a single indexed pass over local data; the trigger checker is recreated only on a disconnect, and its first check, run at once, rebuilds the coming-day schedules once (one Calendar read per watched calendar).

Risk

  • Only data from Google is removed. Each forget step is wrapped: if one fails it logs a warning and the disconnect still completes.
  • Upstream files touched minimally, each change marked // Custom build (google-disconnect-forget): google-connect, google-credential-store, google-drive-text-cache, google-trigger-runtime, automation-persistence. google-trigger-checker.ts is unchanged from upstream; the retire wrapper lives in the new google-trigger-retire.ts.
  • Riskiest part: retiring the checker on a disconnect also drops the other accounts' in-memory schedules and backoff. The fresh checker checks right after the disconnect and sets them again (a meeting starting within those seconds can be missed); the run path drops a repeat.

Level: Medium

  • The profile-state SQLite (run history) has no secure_delete, so freed pages can hold old bytes until SQLite reuses them.

How to revert

git revert the nine custom(google-disconnect-forget) commits. No schema or file-format changes; the files and tables keep their shape.

🤖 Generated with Claude Code

Old-G and others added 9 commits November 25, 2026 10:57
… mail, and mail text 30 days after a thread goes quiet

Disconnecting Gmail (or importing a different client) now drops what HQ took from that mailbox: the
ledger's mail threads keep only their id, project, chat and times (letters, subjects, senders, gist,
drafts, a reply copied into a waiting, the model's reason are removed, with secure_delete and a WAL
checkpoint so the bytes leave the file), the mail intake's message ids, and the mail reader's cursor;
a pass that was reading when the mailbox went writes nothing. Every 6 hours a mail thread quiet for
30 days is forgotten the same way, and older letters leave threads still going. The model's guess on
a letter runs with --no-session-persistence, so the letter's text leaves no Claude transcript.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Gmail and Calendar words of an account or of events older than 30 days

A Gmail or Calendar run kept the mail's subject and snippet, the sender, the meeting's title, place
and link, with no age limit. forgetAutomationRunGoogleEvents (on the store) drops them: by account,
a finished run loses its event, folded keys, output snapshot and who/where, and an unfinished run
loses only the words so it still folds and dedupes; by date, finished runs whose event is older than
the cutoff lose the event. The run, its times, status and source stay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ets what Orca kept from it — trigger cursors, Drive text, timers, run history, the default pick

GoogleConnect.disconnect (Settings, CLI and phone all call google.disconnect) now calls
forgetGoogleAccount after the sign-in file goes: the account's Gmail history point, calendar sync
tokens and bots' listening times leave orca-google-triggers.json, its Drive text leaves the paging
cache, and listeners drop the trigger checker's meetings and timers and the account's run history.
A default-account file naming the removed address is removed too, so the last account leaves no
address behind. Each automation tick drops Gmail and Calendar words older than 30 days from run
history, once an hour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aves the waiting's event snapshots

waiting.replied / waiting.updated / waiting.replyDelivered events carry the whole waiting, so the
reply text, author, link and ts copied from a letter stayed in the events table after the waiting row
was cleared. Those snapshot fields are nulled for answers from the forgotten letters, on disconnect
and for letters past 30 days (found by the automated security review of the branch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gger checker, so a check still waiting on Google can't start a bot or write its old state back

The checker is upstream's file again: its forgetAccount and the max-lines
suppression are gone (the CI ratchet rejected the suppression). Instead the
runtime holds a retirable checker; on disconnect the old one stops, its
memory (schedules, timers, backoff) goes with it, and its runForEvent and
writeState become no-ops for any check still in flight. The next tick runs
a fresh checker over the scrubbed state; the run path drops repeat events.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rive read in flight and a long mail thread's first subject no longer bring back what a disconnect or the 30 days removed

- HQ mail ledger: a pass begun before a reset ingests nothing and saves no
  guess, even when the same address is connected again meanwhile.
- Drive text cache: a read still converting when an account is forgotten
  does not put its text back into the cache.
- A mail thread still going once its first letters age out gets a neutral
  title; the old one was that letter's subject or the model's gist of it.
- The disconnect test now checks real files under a temporary home (sign-in
  and trigger state gone, the other account kept) instead of mocked calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… lose their Google words too, and the mail ledger stops reading the old mailbox at once (Codex review, round 2)

- Run history: for 6 hours after a disconnect, each tick scrubs that
  account's runs again, so a run going at the disconnect, or an event
  already on its way into a run, loses its words once it settles. Only
  events from before the disconnect: the same address connected again
  keeps its new runs. Asking again writes nothing when nothing changed.
- HQ mail ledger: a mailbox gone mid-pass sends no more letters to the
  model, and Done / project events logged under `gmail:<thread>` move to
  the forgotten key, so the thread id leaves event history.
- The trigger-state test asserts the surviving entries as literals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nnect keeps none of the old mailbox's ids, and the 30-day mail sweep runs on the mail reader's poll instead of a timer of its own (Codex review, round 3)

- HQ mail intake: a pass that began before a disconnect drops the ids it
  wrote once its writes are done, so a pass waiting on ClickUp at the
  disconnect cannot bring the old mailbox's ids back. A forget writes
  through its own temp file, so it cannot collide with the intake's.
- The 30-day mail sweep is checked on each poll of the mail reader (at
  most every 6 hours) and adds no `setInterval` of its own.
- The Gmail disconnect test that only counted mock calls is gone; an
  invariant test of the in-flight intake takes its place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er check at once, so another account's Calendar timer due before the next tick is set again instead of skipped (Codex review, round 3)

Retiring the checker cancels every pending Calendar timer. A meeting of
another account with a zero-minute trigger that starts before the next
tick was then skipped, since the next check sees it already started.
The fresh checker now checks right after the disconnect; its tick guard
keeps it from overlapping the service's own tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Old-G
Old-G merged commit b11c606 into custom Nov 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant