feat(gmail): add --gmail-no-send flag to block send operations#454
Open
veteranbv wants to merge 2 commits intosteipete:mainfrom
Open
feat(gmail): add --gmail-no-send flag to block send operations#454veteranbv wants to merge 2 commits intosteipete:mainfrom
veteranbv wants to merge 2 commits intosteipete:mainfrom
Conversation
Add a CLI-layer kill switch (--gmail-no-send / GOG_GMAIL_NO_SEND=1) that blocks all send operations in the gmail command group, regardless of OAuth scopes. gmail.modify is the right scope for an agent that needs to read, label, and create drafts, but it also permits send. Google provides no scope that grants modify-level access without send capability. This flag gives agent operators a hard invariant: deploy gog with GOG_GMAIL_NO_SEND=1 and send is impossible, full stop, regardless of what the agent is told or forgets. Blocked paths: send, gmail send, gmail drafts send, gmail autoreply. Enforced centrally in Execute() using the same pattern as enforceEnabledCommands — post-parse, pre-Run(), exit code 2.
Extend the global --gmail-no-send flag with per-account control and a persistent config key, based on community feedback from @codefly. Per-account: gog config no-send set/remove/list manages a no_send_accounts map in config.json. The check runs in each send command's Run() after account resolution, since account identity isn't known until requireAccount() resolves aliases and defaults. Global config key: gog config set gmail_no_send true persists the global block in config.json without requiring an env var or CLI flag. Precedence: CLI flag > env var > config key > per-account > default. Also fixes the env var handling to use the envBool/boolString pattern (matching JSON and Plain flags) so that GOG_GMAIL_NO_SEND="" doesn't cause a Kong parse error.
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.
Motivation
gmail.modifyis the right OAuth scope for an agent that needs to read, label,and create drafts, but it also permits send. Google provides no scope that
grants modify-level access without send capability. This means there is no way
to give an AI agent read/label/draft access while maintaining a hard block on
send.
A prompt-level guardrail is not sufficient: if safety instructions are compacted
away during a long session, an agent operating on
gmail.modifycould sendemail on behalf of the user. The block needs to live in the binary itself, below
the instruction layer, where context compaction cannot reach it.
Closes #453
Summary
--gmail-no-sendglobal flag andGOG_GMAIL_NO_SENDenv vargmail_no_sendconfig key (gog config set gmail_no_send true) forpersistent global blocking without env vars
gog config no-send set/remove/list,stored as
no_send_accountsin config.jsonsend,gmail send,gmail drafts send,gmail autoreplyExecute()using the same pattern asenforceEnabledCommands(post-parse, pre-Run(), exit code 2)Run()after accountresolution via
requireAccount()Precedence: CLI flag > env var > config key > per-account config > default (allow).
Test plan
TestIsGmailSendCommand-- unit coverage for all send and non-sendcommand strings
TestGmailNoSendBlocksViaCLI-- integration test: all four send pathsblocked via
--gmail-no-sendTestGmailNoSendAllowsNonSendCommands-- non-send commands pass throughTestGmailNoSendEnvVar--GOG_GMAIL_NO_SEND=1blocks sendTestGmailNoSendNotSetAllowsSend-- without flag, send is not blockedTestGmailNoSendConfigGlobal--gmail_no_send: truein config blocksTestGmailNoSendConfigGlobalAllowsNonSend-- config global does notblock non-send commands
TestGmailNoSendGlobalOverridesPerAccount-- flag wins over per-accountTestCheckAccountNoSend_Blocked-- per-account blocks matching accountTestCheckAccountNoSend_Allowed-- per-account allows non-matchingTestCheckAccountNoSend_NoConfig-- absent config does not blockIsNoSendAccount,SetNoSendAccount,ListNoSendAccounts(with nil map, case insensitivity, empty email)go test ./...-- full suite passes, no regressionsmake lint-- clean