Skip to content

Agent-safety features: least-privilege login, access token, introspection, confirmation gate, suggest-time - #230

Merged
omriariav merged 117 commits into
mainfrom
claude/charming-brahmagupta-jhwxir
Nov 25, 2026
Merged

omriariav merged 117 commits into
mainfrom
claude/charming-brahmagupta-jhwxir

Conversation

@omriariav

@omriariav omriariav commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Five features prompted by a comparison with Google's official gwscli, plus a README positioning update. No version bump here — that goes in the release PR.

  • Least-privilege login (closes feat(auth): incremental and read-only login (per-service scopes, --readonly) #225) — gws auth login --readonly requests only read-only scopes; --add --services X extends the existing authorization instead of replacing it (same account required, previous scopes re-requested and verified, unrequested scopes rejected). Per-service access levels (full, readonly, partial, partial-readonly) are recorded in granted_access.json, bound to the stored token, and shown by auth status. Insufficient-scope errors carry a hint naming the login that grants the missing access.
  • Introspection (closes feat(infra): --show-scopes and --schema introspection on every command #226) — global --schema and --show-scopes print JSON describing a command and exit. They call no Google API and need no credentials. --schema reports sensitive / sensitive_when for the confirmation gate. Scope output is per service, not per command.
  • External access token (closes feat(auth): accept an externally managed access token (GWS_ACCESS_TOKEN / --access-token) #227) — GWS_ACCESS_TOKEN / --access-token are used as-is (no refresh, nothing stored, never printed) and take precedence over the stored login and the service-account modes. Read only from the flag and the environment, never the config file.
  • Confirmation gate (closes feat(infra): opt-in confirmation gate for sensitive actions (send, share, delete) #228) — opt-in via GWS_CONFIRM_SENSITIVE / confirm_sensitive. Commands that send, share, delete or destroy data prompt on stderr and show the invocation; --yes skips the prompt; without a terminal the command fails closed with confirmation required. Off by default, so existing automation is unchanged.
  • gws calendar suggest-time (closes feat(calendar): suggest-time — find free meeting slots across calendars #229) — finds free windows across calendars and attendees inside working hours, built on the free/busy query. Unreadable calendars fail the command unless --allow-partial is given.
  • README — retitled as the unofficial Go CLI, install moved above the fold, a comparison with gwscli and googleworkspace/cli, and a Disclaimer section. Existing command documentation and the license notice are unchanged.

Behaviour changes to review

  • Token refresh needs the login lock. An expired stored token is refreshed under a lock in the config directory. If the lock cannot be taken (read-only or full directory), the command now fails with "the login lock is unavailable" instead of refreshing unlocked. A still-valid token is unaffected.
  • Locking is OS-held. On Linux, macOS, BSD and Windows the token/login lock is a flock / LockFileEx lock on a .flock file, held for the whole operation; the .lock file older versions understand is still created and honoured, so mixed versions exclude each other. Other platforms keep the lock-file scheme and now report a stale lock instead of removing it. The Windows path is compiled but was not run.
  • auth logout returns "revoked": true only when Google confirmed the revocation, otherwise "revoked": false with instructions; local credentials are removed either way.
  • A supplied-but-empty access token is an error for every command (except version and completion), never a fallback to the stored login. A blank GWS_ACCESS_TOKEN= in a shell profile must be unset.
  • With an external token: chat build-cache, chat find-group and chat find-space refuse to run, chat members skips its name cache and enrichment, and gws hooks adds no Workspace context.
  • Read-only scope table introduces scope strings not previously requested, including spreadsheets.readonly, drive.metadata.readonly, the Chat *.readonly set and calendar.acls.readonly.
  • Root PersistentPreRun became PersistentPreRunE (required-flag validation, the empty-token check and the gate run there).
  • An unscoped full login still requests auth.AllScopes, exactly as before.
  • New direct dependencies golang.org/x/term v0.44.0 and golang.org/x/sys v0.46.0, both already in the module graph; the Go 1.25 toolchain requirement is unchanged.

Testing

  • go vet ./..., go test ./... and golangci-lint run pass; cross-compiles for linux, darwin, windows and solaris.
  • New unit tests cover the gate, introspection, login scope resolution and access merging, the access-token paths, token refresh and locking, and the slot-finding logic (including DST and midnight-crossing clock changes).
  • Not tested against a live Google account: the interactive --readonly / --add consent flow (including whether Google accepts calendar.acls.readonly), and suggest-time against real free/busy data.

Review notes

  • The Codex finding "a null free/busy entry crashes calendar suggest-time" was declined as not reproducible; see the PR comment and TestQueryBusySpans_NullEntriesDoNotPanic.

Skills

skills/auth and skills/calendar (SKILL.md and references/commands.md) are updated, with the Codex mirrors re-synced.

🤖 Generated with Claude Code

https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh

…spection, confirmation gate, suggest-time

- auth login --readonly requests only read-only scopes; --add merges
  services into the existing authorization (incremental auth). Per-service
  access levels are recorded and shown by auth status, and an
  insufficient-scope failure on a read-only service prints the login that
  grants write access. (#225)
- --schema and --show-scopes describe any command as JSON without running
  it or needing credentials. (#226)
- GWS_ACCESS_TOKEN / --access-token use an externally managed access token
  as-is, taking precedence over the stored login and service-account
  modes. (#227)
- Opt-in confirmation gate (GWS_CONFIRM_SENSITIVE / confirm_sensitive) for
  commands that send, share or delete; --yes skips it, and without a
  terminal the command fails closed instead of hanging. (#228)
- calendar suggest-time finds free meeting slots across calendars inside
  working hours. (#229)

Adds golang.org/x/term for terminal detection.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time, which finds meeting slots from Google Calendar free/busy data.

The shallow checkout hid the merge base. I verified that origin/main matches the merge commit’s first parent and reviewed the diff between those two trees. git diff --check passed. make test stopped before running tests because the filesystem blocked creation of the Go build cache.

What looks good

  • calendar suggest-time follows the Cobra registration and printer patterns, appears in commands_test.go, and is documented in the README and Calendar skill reference.
  • External-token status avoids printing the credential. The tests also check that the external token takes precedence over service-account configuration.
  • The confirmation gate writes prompts to stderr and has unit coverage for approval, rejection, and non-interactive input.

Issues found

  1. Critical — Read-only login can retain a write-capable refresh token. When a replacement login returns no refresh token, auth.MergeToken reuses the previous one. After a full-to-read-only login, the access token can initially be read-only while a later refresh uses the previous full grant. Local metadata still reports read_only: true. Require a refresh credential for the new grant when replacing authorization. cmd/auth.go

  2. Critical — The confirmation gate misses Calendar permission changes. calendar update-acl can promote an existing principal to writer, but the gate only lists Calendar share and unshare. With GWS_CONFIRM_SENSITIVE=1, that permission change can proceed without approval, and --schema omits the sensitive marker. Add update-acl to the gate and test its coverage. cmd/confirm.go

  3. Critical — Introspection can silently suppress normal command execution. The raw argument scan treats a flag value as a standalone option. For example, gws gmail send --to a@example.com --subject Hi --body --schema uses --schema as the body under normal flag parsing, but the new scan switches to introspection and exits successfully without sending. Resolve the introspection flags with Cobra’s flag parsing before deciding whether to intercept execution. cmd/introspect.go

  4. Warning — Large numeric meeting durations can overflow. The numeric branch checks that the minute count is positive before multiplying by time.Minute. A sufficiently large value can wrap to a negative duration and produce a suggestion whose end predates its start. Check the upper bound before multiplying. cmd/calendar_suggest.go

  5. Warning — suggest-time lacks an HTTP-backed command test. The tests cover registration, flags, and scheduling helpers. Add an httptest case that exercises the command and verifies the Freebusy request, per-calendar errors, and structured output. cmd/calendar_suggest_test.go

…kspace CLI

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, an opt-in confirmation gate, and gws calendar suggest-time.

The shallow checkout prevented Git from finding a merge base. I reviewed git diff origin/main HEAD after verifying that origin/main matched the base recorded in the PR merge commit.

What looks good

  • calendar suggest-time follows the Cobra flag and printer conventions. It has command registration coverage, an httptest FreeBusy mock, and updates to the README and Calendar command reference.
  • The external-token factory path uses a static token source, and the auth-status test checks that output omits the token value.

Issues found

  1. Critical — Read-only login can retain write access after refresh. The login flow unconditionally merges the new token with the saved token. If Google omits a refresh token during auth login --readonly, the CLI keeps the previous refresh token. If that token carries write scopes, refreshing can restore write access while auth status still reports read_only: true. A login that reduces access needs a refresh credential for the reduced grant. cmd/auth.go

  2. Critical — The confirmation gate misses Calendar ACL changes. The new allowlist covers calendar share and calendar unshare but omits calendar update-acl. With the gate enabled, changing an existing ACL rule’s role can expand access without prompting. The allowlist test verifies that listed commands exist, so it cannot catch this omission. cmd/confirm.go

  3. Warning — Auth status reports requested access as granted access. runLogin computes access from the requested flags and locally saved metadata before Google returns the token. If the user grants only some scopes or signs into a different account during --add, the command can still report and persist access the resulting token lacks. Derive the reported access from the scopes Google granted. cmd/auth.go

  4. Warning — Introspection mistakes string flag values for global options. The raw argument scan treats every standalone --schema or --show-scopes token as an option without checking whether the preceding flag consumes it. For example, gws gmail send --to a@example.com --subject "--schema" --body Hello prints schema and exits successfully without sending the email. Parse flag boundaries before dispatching to introspection. cmd/introspect.go

make test stopped before running tests because the read-only environment prevented Go from creating its build cache.

…sing, duration bound

- A replacing login no longer falls back to the previous refresh token,
  so narrowing access (e.g. --readonly) cannot keep refreshing with the
  old, wider grant. Only --add may reuse it.
- Confirmation gate now covers calendar update-acl and chat update-member.
- --schema / --show-scopes are detected with real flag parsing on a
  throwaway flag set, so a flag value that reads "--schema" still runs
  the command, and the command's own flag state is untouched.
- suggest-time rejects durations over 24h before multiplying, closing an
  overflow into a negative duration.
- Free/busy handling is extracted into queryBusySpans with httptest
  coverage for the request, per-calendar errors, API errors and
  malformed periods.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
The consent screen lets a user untick scopes, so the access recorded at
login is now checked against the token response's scope list: a full
request that only received read-only scopes is recorded as read-only, and
a service that received neither is dropped with a warning.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and opt-in confirmation for sensitive operations. It also adds calendar suggest-time, which finds meeting slots using Calendar free/busy data.

The shallow checkout had no merge base. I verified that origin/main matched the PR merge commit’s first parent and reviewed the diff from that parent to HEAD. git diff --check passed. make test could not start because the filesystem prevented Go from creating its build cache.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has a command structure test, mocked FreeBusy coverage via httptest, and documentation in the README and both calendar skill references.
  • External tokens use a static token source, and auth status reports the authentication mode without exposing the token or claiming it has been verified.
  • The confirmation prompt writes to stderr, preserving structured stdout. For commands covered by the gate, noninteractive invocations fail immediately when confirmation is required.

Issues found

  1. Critical — Incremental login can change identity or lose newly granted scopes on refresh. loginTokenToStore reuses the previous refresh token whenever an --add exchange returns no refresh token. The new consent flow can select another Google account, and the code never checks that it matches the stored account. When the new access token expires, refresh can silently return to the previous account. Even for the same account, the code has no evidence that the old refresh token can mint the newly requested scopes. Require a usable refresh token before persisting the new grant, or verify that the retained refresh token belongs to the same account and can mint the combined scopes. cmd/auth.go:171

  2. Critical — Destructive commands bypass the enabled confirmation gate. The allowlist omits commands such as docs delete-object, docs delete-table-row, and slides delete-object. Those commands can delete user data in unattended runs even with GWS_CONFIRM_SENSITIVE=1, contrary to the README’s promise. The current test checks whether listed commands exist, so it cannot catch omitted commands. Expand the coverage and test representative destructive commands across services. cmd/confirm.go:60

  3. Warning — Logout leaves authorization metadata behind. DeleteGrantedMetadata has no caller. After logout, auth login --add can still read the previous login’s access map and report those services as granted, including when the next login uses a different account. Clear both metadata files on logout and only merge metadata when a corresponding stored authorization exists. internal/auth/token.go:193 cmd/auth.go:112

  4. Warning — External-token failures can produce a misleading OAuth upgrade hint. When an external token gets an insufficient-scope response, the root command still consults the stored OAuth grant. It can tell the user to run auth login --add even though the external token will continue to take precedence. Use the active authentication mode to decide whether to emit the hint. cmd/root.go:120

@github-actions

Copy link
Copy Markdown

Summary

PR #230 adds read-only and incremental OAuth login, externally managed access tokens, command introspection, and an opt-in confirmation gate. It also adds gws calendar suggest-time to find meeting slots using Calendar free/busy data.

The shallow checkout prevented the three-dot diff from resolving. I reviewed the merge commit against its recorded first parent, which matches origin/main. git diff --check passed. make test could not initialize the Go build cache on the read-only filesystem.

What looks good

  • suggest-time follows the Cobra registration, required-flag, and printer conventions. The PR adds a command structure test, mocked FreeBusy coverage, and documentation in the README and calendar skill references.
  • The confirmation prompt goes to stderr, preserving structured stdout. Tests cover approval, rejection, non-interactive use, and --yes.

Issues found

  1. Critical — Incremental login can pair credentials from different Google accounts. If Google returns no refresh token, --add unconditionally reuses the stored one. A user who selects a different account in the browser can receive an access token for that account and keep a refresh token for the previous one. After expiry, commands can silently run as the previous account. Require a new refresh token or verify that both credentials belong to the same account and that the retained grant covers the access being recorded. cmd/auth.go

  2. Critical — suggest-time can stall at a midnight DST transition. The loop advances a local-midnight time.Time with AddDate. When the next date skips midnight, Go can resolve that wall time to 23:00 on the preceding date. Subsequent iterations then advance from the wrong wall-clock hour and can skip a day’s working window. Track the civil date independently of the local timestamps used for working hours, and add a regression case spanning a midnight transition. cmd/calendar_suggest.go

  3. Warning — The confirmation gate leaves destructive commands uncovered. The README describes the gate as covering commands that delete data, but gws sheets clear can erase an entire supplied range without prompting. The current test catches stale entries in the allowlist and cannot detect omissions. Add coverage for destructive commands such as sheets clear, or narrow the documented guarantee and list the covered commands. cmd/confirm.go

  4. Warning — Scope recovery hints can point to credentials the command never used. After an insufficient-scope error, the CLI consults stored OAuth grants even if an external access token or service account made the request. The suggested auth login --add cannot fix that active credential. Only emit the stored-login hint when the request used the stored OAuth token. cmd/root.go

@github-actions

Copy link
Copy Markdown

Summary

This PR adds read-only and incremental OAuth login, externally managed access tokens, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time, which uses Calendar free/busy data to find meeting slots.

The three-dot diff failed because the checkout is shallow. I compared HEAD against its recorded first parent, which matches origin/main, to isolate the PR changes. git diff --check passed. make test could not initialize the Go build cache on the read-only filesystem.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has command-structure coverage, mocked Calendar API tests, and entries in the README and both calendar command references.
  • External-token status reports that a token is configured without printing its value. The confirmation prompt writes to stderr, keeping structured output on stdout.

Issues found

  1. Critical — Incremental login can mix credentials from different accounts. If Google returns an access token without a refresh token, --add copies the refresh token from the previous local login without verifying the Google account or OAuth client. A user who selects a different account in the browser can run commands as that account until the access token expires, then silently switch back to the previous account on refresh. Require a new refresh token or verify the identity, client, and grant before reusing the old one. cmd/auth.go

  2. Critical — The confirmation gate misses destructive commands. The new command list omits slides delete-object and the trashing form of drive update --trashed. Both can modify data with confirmation enabled and without --yes. Add coverage for these paths and test that they fail closed in noninteractive execution. cmd/confirm.go

  3. Warning — Logout leaves grant metadata behind. The new DeleteGrantedMetadata helper has no caller. After logout, --add can still seed its access map from the previous login. If the token response omits scope, stale entries can be saved as current grants. Clear the metadata with the token and require a current login before using it for an incremental grant. internal/auth/token.go · cmd/auth.go

  4. Warning — --working-hours any misses slots that cross midnight. The search splits availability into daily windows even when both days are eligible. With an empty calendar and a range from 23:00 Monday to 01:00 Tuesday, a 90-minute meeting fits, but the command returns no suggestions. Keep adjacent eligible windows contiguous when working hours are unrestricted. cmd/calendar_suggest.go

…ive commands by name, clear metadata on logout

- Every login, including --add, must return its own refresh token. The
  previous one is never reused: it could carry a wider grant, lack the
  newly added scopes, or belong to a different account.
- The confirmation gate now covers every command whose name starts with
  delete, trash, remove, clear, empty or batch-delete, in addition to the
  explicit list of send and access-changing commands. A tree-walking test
  keeps new destructive commands from being added ungated.
- Logout removes the granted-services and granted-access metadata, and
  --add ignores metadata when no authorization is stored.
- The read-only upgrade hint is only printed when the stored OAuth login
  is the credential in use (not an external token or service account).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time to find meeting slots from Calendar free/busy data.

What looks good

  • calendar suggest-time follows the Cobra registration, RunE, and printer conventions. It has command structure tests, mocked FreeBusy tests, and documentation in the README and Calendar command references.
  • External tokens use a static token source, and auth status reports the credential mode without exposing the token.

Issues found

  1. Critical — The confirmation gate misses Chat space setup with members. chat setup-space --members ... sends memberships in the setup request and can grant other users access to a space. The new gate matches neither the command name nor its effect, so it proceeds with confirmation enabled and --schema omits the sensitivity marker. Cover this path and test that it requires confirmation. cmd/confirm.go
  2. Warning — Incremental login can underreport write access. deriveGrantedAccess only checks full scopes when the requested or locally recorded level was already full. If Google returns previously granted write scopes during --add --readonly and local metadata is absent, the CLI reports readonly even when the token carries the full scope set. Derive the reported level from the returned scopes and test this flow with no local metadata. cmd/auth.go
  3. Warning — Midnight DST transitions can skip valid meeting slots. In zones such as America/Santiago, constructing midnight on a spring-forward date can resolve to 23:00 on the previous date. The day loop can then reach the intended date at 23:00 and stop before checking valid working hours earlier that day. Iterate over civil dates independently of local midnight and add a regression test for a midnight transition. cmd/calendar_suggest.go

The shallow checkout prevented a three-dot diff. I verified that origin/main matched the merge commit’s first parent and reviewed the diff against that parent. git diff --check passed. make test could not start because the read-only filesystem prevented Go from creating its build cache.

…rive update --trashed

- suggest-time tracks civil dates instead of stepping a local-midnight
  timestamp, so a DST change that skips midnight cannot shift or drop a
  day's working window.
- Touching daily windows are merged, so with --working-hours any a slot
  can span midnight between two eligible days.
- The confirmation gate covers `drive update --trashed`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds gws calendar suggest-time, which uses Calendar free/busy data to propose meeting slots.

What looks good

  • calendar suggest-time follows the Cobra registration and printer patterns, adds httptest coverage and a command registration test, and updates the README and Calendar skill references.
  • External-token status output omits the token. The confirmation prompt goes to stderr, keeping structured stdout clean.

Issues found

  1. Critical — auth status can report read_only: true for a token that still has write access. Google’s incremental authorization can return previously granted write scopes for services absent from the local metadata, such as after the local token has been removed without revoking the Google grant. deriveGrantedAccess only examines services in the requested map, so those write scopes are ignored. Derive read_only from the complete scope set Google returned. cmd/auth.go
  2. Warning — The confirmation gate misses calendar rsvp --message. That command sends an attendee update through SendUpdates("all"), but its name matches neither the explicit command map nor the destructive prefixes. Gate the notification path and add a test for it. cmd/confirm.go
  3. Warning — A date-only --to can produce the wrong cutoff in zones where a DST transition skips midnight. time.ParseInLocation can normalize the date to an adjacent hour or day, and adding one day to that instant carries the normalization into the exclusive cutoff. Compute the cutoff from the next civil date and test a midnight transition. cmd/calendar_suggest.go
  4. Warning — --duration accepts fractional seconds, but the output truncates the slot end to whole seconds and reports whole minutes. A 500ms meeting therefore appears with identical start and end timestamps and duration_minutes: 0. Reject durations that the output cannot represent or preserve their precision. cmd/calendar_suggest.go
  5. Suggestion — Remove the stale comment that says --add can reuse the old refresh token. The implementation requires a fresh refresh token for every login. cmd/auth.go

The shallow checkout prevented the three-dot diff. I compared HEAD directly with origin/main after verifying that origin/main is the synthetic merge commit’s first parent. git diff --check passed. make test could not start because the filesystem is read-only and Go could not initialize its build cache.

…d scopes

- The confirmation gate covers commands that are sensitive only when a
  flag is used: chat setup-space --members, calendar create --attendees,
  calendar update --add-attendees, and drive update --trashed, driven by
  one table with a test that every rule resolves and triggers.
- The recorded access level follows the granted scopes in both
  directions, so an incremental read-only login that returns previously
  granted write scopes is reported as full.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access-token support, command introspection, an opt-in confirmation gate, and calendar suggest-time. The shallow checkout had no merge base with origin/main, so I reviewed the merge commit against its recorded base parent, 793396c.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. The PR adds command structure tests, mocked FreeBusy requests, and documentation in the README and calendar skill references.
  • The confirmation prompt writes to stderr, preserving structured stdout, and requires explicit approval in noninteractive sessions.
  • External tokens use a static token source, with tests covering precedence over stored credentials and service-account configuration.

Issues found

  1. Critical — Read-only login can still authorize subscription changes. The Events read-only scope set includes chat.messages.readonly and other scopes that authorize creating Workspace Events subscriptions for the corresponding resources. The documentation promises that commands that create or change data will fail after read-only login, but Google can accept those subscription writes. Enforce that boundary for subscription commands or document the exception wherever the guarantee is made. Scope configuration · Auth skill

  2. Warning — Conditional confirmation rules are missing from --schema. Introspection parses into a throwaway flag set and discards the triggering flag values before commandSchema calls sensitiveEffect. As a result, even calendar create --attendees a@example.com --schema omits the sensitivity marker, though executing the same invitation with the gate on requires confirmation. Expose the triggering flag and its effect in the schema. Schema generation

  3. Warning — A successful login can leave access metadata that describes the previous token. The login saves the new token first and treats metadata write failures as warnings. If granted_access.json remains readable with its old contents after a failed write, auth status and scope hints can describe the previous grant. Overlapping logins can also interleave these writes. Persist the token and its grant metadata as a single consistent record. Login persistence

git diff --check passed. make test could not start because the sandbox prevented Go from creating its build cache.

…y boundaries, whole-minute durations

- Access levels are derived from the complete scope set Google returned,
  across every service, so write scopes from an earlier grant are never
  hidden behind read_only: true.
- Date-only --from/--to and whole-day windows use the first real instant
  of a civil date, so a DST change that skips midnight no longer moves
  the range cutoff.
- --duration must be a whole number of minutes, matching what the output
  can represent.
- The confirmation gate covers calendar rsvp --message.
- Removed a stale comment about refresh-token reuse.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
…tional sensitivity in --schema, keep access metadata consistent

- Workspace Events subscriptions are authorized by read scopes, so the
  read-only guarantee is now stated with that exception in the README,
  the auth skill and the --readonly help text.
- --schema reports `sensitive_when` (flag and effect) for commands that
  need confirmation only when a flag is used.
- Granted-access metadata is written atomically, and if recording it
  fails after a login both metadata files are removed rather than left
  describing the previous token.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time, which finds meeting slots using Calendar free/busy data.

The requested three-dot diff failed because the checkout had no visible merge base. I compared HEAD with its first parent, which matched origin/main, and limited the review to that diff.

What looks good

  • calendar suggest-time follows the Cobra registration, flag validation, and printer conventions. It includes an httptest free/busy mock, an entry in commands_test.go, and documentation in the README and both skill reference copies.
  • External tokens use a static token source. auth status reports the authentication mode without exposing the token.
  • Formatting and git diff --check passed. make test stopped before running tests because the filesystem is read-only and Go could not initialize its build cache.

Issues found

  1. Critical — Some RSVP messages bypass the confirmation gate. flagIsSet treats false and [] as empty for every flag type. For calendar rsvp --message, both are valid nonempty messages. The RSVP handler sends attendee updates for either value, while the gate lets the command proceed without confirmation. Check the flag according to its type and add regression cases for these literal messages. confirm.go

  2. Warning — Partial OAuth grants can be reported as read-only even when they permit writes. If Google grants gmail.readonly and gmail.send but omits another Gmail scope, deriveGrantedAccess records Gmail as readonly. If all other recorded services are read-only, auth status then reports read_only: true even though the token can send mail. Track partial write grants explicitly and derive read_only from the scopes Google actually returned. auth.go

  3. Warning — Both auth guides contradict the new refresh-token behavior. The token-management sections still say refresh tokens are preserved across re-authentication. The new login path requires a fresh refresh token and rejects the login if Google omits it. Update both copies to describe that behavior. Auth skill · Plugin auth skill

@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access-token support, command introspection, opt-in confirmation for sensitive operations, and calendar suggest-time. The checkout is shallow, so the requested merge-base diff failed. I compared the PR merge commit directly with origin/main after verifying that origin/main is its first parent.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has command structure tests, httptest coverage for FreeBusy responses, and documentation in the README and Calendar skill reference.
  • The confirmation prompt uses stderr, preserving structured stdout. Covered commands fail closed when stdin has no terminal unless the caller supplies --yes.
  • External access tokens take precedence in the client factory and stay out of the stored OAuth token and auth status output.

Issues found

  1. Warning — A valid RSVP message can bypass confirmation. The shared flag check treats the literal strings false and [] as unset. For calendar rsvp --message=false, the RSVP handler sees a nonempty message and sets SendUpdates("all"), but the confirmation gate sees an unset flag. Evaluate each flag according to its type and the handler’s trigger condition. cmd/confirm.go
  2. Warning — Incremental login can omit an existing full Sheets grant from its access metadata. deriveGrantedAccess uses the lengths of the full and read-only scope lists to distinguish them. Sheets has one scope in each list, spreadsheets and spreadsheets.readonly, plus the shared userinfo scope. If Google returns a previously granted spreadsheets scope and local metadata lacks a full Sheets entry, neither branch records the grant. Compare the scope sets by membership and test this case with missing local metadata. cmd/auth.go
  3. Warning — A spring-forward transition can produce suggestions outside working hours. atDayOffset passes nonexistent wall times directly to time.Date. In America/New_York on March 8, 2026, a working window starting at 02:30 resolves to 01:30 EST, so the command can suggest a meeting before the requested lower bound. Handle nonexistent working-hour boundaries explicitly and add a regression test for a transition after midnight. cmd/calendar_suggest.go

git diff --check passed. make test stopped before running tests because Go could not initialize its build cache on the read-only filesystem.

…resh-token docs

- Flag-conditional gate rules judge a flag by its type, so an RSVP
  message of "false" or "[]" still requires confirmation.
- A service that holds some write scopes but not the full set is recorded
  as "partial" and never as read-only, so read_only: true means no write
  scope was granted anywhere.
- The auth skill's token-management notes describe the new refresh-token
  behaviour.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
…oundaries out of DST gaps

- A service's full and read-only scope sets are compared by membership
  rather than length, so a previously granted `spreadsheets` scope is
  recorded as full Sheets access.
- Working-hour and day boundaries that fall in a spring-forward gap move
  forward to the first real instant, so a suggestion can never start
  before the requested lower bound.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, an opt-in confirmation gate, and calendar suggest-time. The three-dot diff failed because the shallow checkout had no merge base. I compared origin/main with HEAD after verifying that origin/main matches the merge commit’s recorded first parent.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has command structure tests, httptest coverage, and updates to the README and calendar command references.
  • Introspection uses a separate flag set to preserve Cobra’s execution state. Confirmation prompts go to stderr, preserving stdout for structured output.
  • External access tokens bypass stored credentials and are neither persisted nor printed by auth status.

Issues found

  1. Critical — Meeting suggestions can overlap unchecked busy time. The command accepts RFC3339 timestamps with fractional seconds, then formats the FreeBusy query bounds with time.RFC3339, which drops that precision. A --to of 10:30:00.900Z queries only through 10:30:00Z, while slot calculation still uses the original bound. Output formatting also drops fractional seconds from slot starts, which can move a reported start into a busy period. Preserve precision in both the API request and output, and add a fractional-second regression test. cmd/calendar_suggest.go
  2. Warning — auth login --add can request full access to every service. With no --services flag or configured service list, the new incremental flow falls back to auth.AllScopes. Require a service selection for --add so an omitted flag cannot broaden the consent request to every service. cmd/auth.go
  3. Warning — Drive approval requests bypass the confirmation gate. drive start-approval sends a request to named reviewers, and drive reassign-approval can add or replace reviewers. Neither command is in the new confirmation table or matches a destructive prefix, so both can proceed with GWS_CONFIRM_SENSITIVE=1 and no --yes. Add both commands to the gate and cover them in the confirmation tests. cmd/confirm.go

git diff --check passed. make test stopped before running tests because the read-only filesystem prevented Go from creating its build cache.

@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time, which uses Google Calendar free/busy data to find meeting slots.

What looks good

  • suggest-time follows the Cobra registration, handler, and printer conventions. It includes HTTP-mocked coverage and a command structure test.
  • The README and Calendar skill references document the new command and how to interpret unavailable calendars.
  • External tokens use a static token source, and auth status reports the authentication mode without printing the token.

Issues found

  • Warning — Scope metadata can describe the wrong token. Login saves the token, granted services, and access levels in separate operations. If two logins overlap, one can write its metadata after the other has saved its token. An interruption after the token write can also leave the previous grant’s metadata in place. This affects auth status and scope diagnostics. Persist the token and metadata as a single record, or verify that the metadata belongs to the current token before using it. cmd/auth.go
  • Warning — A partial read-only grant can suppress the scope recovery hint. deriveGrantedAccess omits a service when Google grants only some of its read scopes and none of its write scopes. For example, if a user grants Chat message-read access but declines membership-read access, Chat is omitted and the hint lookup has no entry to use when a command fails for insufficient scopes. Preserve evidence of partial read grants and use it to suggest the appropriate login. cmd/auth.go · cmd/introspect.go

Both three-dot diff attempts failed because the checkout is shallow. I compared the PR merge commit’s tree against origin/main, which matches the base SHA recorded in the merge commit. git diff --check passed. make test could not start because the filesystem prevented Go from creating its build cache.

…s, gate Drive approval requests

- suggest-time works in whole seconds end to end: the range is shrunk
  inward and busy periods widened outward, so the free/busy query, the
  slot calculation and the RFC3339 output always agree.
- auth login --add requires a service selection, so it cannot fall back
  to requesting full access to every service.
- The confirmation gate covers drive start-approval and
  reassign-approval.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

PR #230 adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation prompt for sensitive actions. It also adds gws calendar suggest-time to find meeting slots using Calendar free/busy data.

What looks good

  • suggest-time follows the Cobra flag registration and printer conventions. It has command structure tests, httptest coverage for the free/busy request, and documentation in the README and calendar skill references.
  • The confirmation gate has tests for noninteractive failure, explicit approval, and flag-dependent actions. The external-token status output keeps the credential out of the response.

Issues found

  1. Critical — An empty --services value makes incremental login request every service. gws auth login --add --services= passes the guard because Cobra marks the flag as changed. With no configured service list, resolveServices then returns every valid service, and the default login requests full access to all of them. Validate that --add has a nonempty service selection before falling back to all services. cmd/auth.go
  2. Warning — Concurrent logins can leave the saved token and reported access levels out of sync. The token, service list, and access levels are written separately. One login can save its token while another finishes writing its metadata, leaving auth status and scope diagnostics describing a different grant. Store the token and its metadata together, or coordinate their reads and writes under a shared lock. cmd/auth.go
  3. Warning — Working-hour boundaries can use the second occurrence of an ambiguous local time. civilInstant promises the first occurrence, but returns time.Date’s choice as soon as the wall time matches. Go may choose either occurrence during a fall-back transition. If a working-hours end falls in the repeated hour, suggestions can extend past the intended cutoff. Add a fall-back test and resolve ambiguous boundaries explicitly. cmd/calendar_suggest.go

The shallow checkout had no merge base, so I reviewed the diff from the PR merge commit’s verified first parent, origin/main. git diff --check passed. make test could not initialize the Go build cache on the read-only filesystem.

…al read grants

- The granted-access record carries a fingerprint of the refresh token
  it describes and is ignored unless it matches the stored token, so
  metadata left by an interrupted or concurrent login can never describe
  a different grant.
- A requested service that received only some of its read scopes is
  recorded as partial-readonly, so the scope hint still fires for it; the
  login as a whole still counts as read-only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds gws calendar suggest-time, which uses Google Calendar’s FreeBusy API to suggest meeting slots.

What looks good

  • suggest-time follows the Cobra registration and printer conventions. It has command structure tests, httptest coverage for FreeBusy responses, and documentation in the README and calendar skill references.
  • The confirmation prompt uses stderr and fails closed when stdin is non-interactive. Tests cover approval, refusal, and the --yes override.

Issues found

  1. Critical — An empty --services value bypasses the incremental login guard. gws auth login --add --services= passes the Changed("services") check. Without a configured service list, resolveServices then falls back to every service, so the command requests full scopes across all services. This can happen when a script expands an unset variable. Validate that --add has a nonempty explicit or configured service selection before applying the all-services default. cmd/auth.go
  2. Warning — --show-scopes can lead users to replace their existing authorization. The generated login and login_readonly commands omit --add. Following either command to enable one service can replace the stored grant and break previously authorized services. Include an incremental login command or label the generated commands as replacing the stored grant. cmd/introspect.go

The shallow checkout prevented the three-dot diff. I reviewed the diff from origin/main, the verified first parent of the PR merge commit, to HEAD. git diff --check passed. make test could not start because the filesystem blocked creation of the Go build cache.

…guous times, token-bound service list

- A blank --services value (`--services=`, `--services ,`) is no
  selection: --add rejects it, and it never widens a login to every
  service.
- civilInstant explicitly returns the first occurrence of a wall-clock
  time repeated by a fall-back change, so a working-hours end in the
  repeated hour cannot extend the window.
- The scope-warning service list is read from the token-bound access
  record when one exists.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
…isclaimer

New title and intro, install above the fold, a comparison with Google's
gwscli and googleworkspace/cli, a note on the shared gws binary name,
and a Disclaimer section. Command documentation, flags and the license
notice are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

PR #230 adds read-only and incremental OAuth login, external access-token support, command introspection, an opt-in confirmation gate, and calendar suggest-time. It also changes token-refresh locking and updates the README and agent skills.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has HTTP mock coverage, a command-structure test, and entries in both the README command table and the Calendar skill reference.
  • External tokens bypass stored-token refresh, and Chat cache commands refuse to mix data from an external identity into the stored login’s cache.

Issues found

  1. Warning — Mixed-version processes can still race during token refresh. The compatibility lock is taken on the login-state path, but older binaries refresh before calling SaveToken, which locks the token path only for the write. An older binary and this version can therefore exchange the same expired refresh token concurrently and race to save the result. Document that the refresh guarantee requires upgrading every binary that shares the config directory. Refresh locking · Legacy lock compatibility

  2. Warning — suggest-time requires Google to return an explicit empty busy array. A calendar entry with no errors and an omitted busy field is marked unavailable, causing the default command to fail. The tests require an explicit "busy":[] for a free calendar. Verify the empty-calendar response against Google and cover the actual wire format in the HTTP mock. Response handling · Mock response

  3. Suggestion — Qualify the static-binary claim. The README advertises a static binary, but the documented Go install and build paths do not force CGO_ENABLED=0. A build with cgo enabled can link system libraries. “One Go binary” preserves the installation point. README.md

The shallow merge checkout had no merge base with origin/main, so I reviewed the three-dot diff against the PR’s verified head commit, e908510. Its tree matches the checked-out merge commit. git diff --check passed. make test stopped before running tests because the sandbox could not create the Go build cache.

@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time, serializes stored-token refreshes, and updates the README and agent skills.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has command-structure coverage in commands_test.go, an HTTP-mocked command test, and entries in both the README and Calendar command reference.
  • Calendar availability checks fail when a calendar’s availability is unknown unless the caller explicitly opts into partial results. Partial output identifies the calendars that could not be checked.
  • External-token handling skips the Chat caches and Workspace hook context that belong to the stored login.

Issues found

  1. Critical — auth logout can revoke a different account’s authorization. auth status reports external-token mode when GWS_ACCESS_TOKEN or --access-token is set, but auth logout still revokes and deletes the stored OAuth login. With an external token for account B and a stored login for account A, logout revokes A and leaves B’s token usable. The README’s list of external-token exceptions omits this behavior. Require an explicit selection of the stored login before revoking it, and add a regression test covering both credential sources. cmd/auth.go · README.md
  2. Warning — auth status reports authenticated: true even when Google rejects the stored token. The result is initialized as authenticated, and a failed user-info request only changes the user field. A revoked token with a future expiry can therefore pass a script’s authentication check even after Google returns HTTP 401. Report rejection as unauthenticated and distinguish it from a transient lookup failure. cmd/auth.go
  3. Warning — The auth skill overstates what --show-scopes verifies. It tells external-token users to check the scopes a command needs with --show-scopes. That flag lists the service’s login scopes and any known endpoint-specific additions. It does not inspect the token or determine the minimum scopes for the invocation. Mirror the README’s wording in both copies of the skill. Source auth skill · Plugin auth skill

The shallow checkout prevented the three-dot diff. I verified that origin/main matched the merge commit’s recorded base parent and used git diff origin/main HEAD. git diff --check passed. make test stopped before running tests because Go could not create its build cache on the read-only filesystem.

…jected token

auth logout acts on the stored login and now refuses to run while an
external access token is in use. auth status reports authenticated:
false when Google rejects the stored token with 401. The skill's
--show-scopes note matches the README.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds read-only and incremental OAuth login, external access tokens, serialized token refresh, command introspection, and an opt-in confirmation gate. It also adds calendar suggest-time and updates the README and skill references.

What looks good

  • calendar suggest-time follows the Cobra registration, RunE, and printer conventions. It has httptest coverage, an entry in commands_test.go, and documentation in the README and Calendar command references.
  • Empty external tokens fail before command execution, and Chat cache commands reject external tokens to keep data from different accounts out of the same cache.
  • The confirmation gate checks required flags before prompting and omits --access-token from the displayed invocation.

Issues found

  1. Warning — Calendar range boundaries can resolve to the wrong occurrence of a repeated local time. civilInstant promises the first occurrence but only checks offsets within three hours and in 15-minute increments. In Pacific/Kwajalein, the September 30, 1969 rollback repeated 23 hours. A zone-less boundary such as 1969-09-30 14:00 can resolve to the later occurrence, shifting the search range by 23 hours. Use the timezone transition’s actual offsets to find both candidates and add a regression test. cmd/calendar_suggest.go
  2. Warning — The auth skill’s quick reference overstates what --show-scopes returns. “Scopes a command needs” implies an endpoint’s required scopes. The implementation returns the service-wide scopes requested by gws auth login, with command-specific exceptions where recorded. An agent provisioning an external token from that table could request unnecessary write access. Update the quick reference in both skill copies. skills/auth/SKILL.md

git diff --check passed. The shallow checkout prevented the requested three-dot diff, so I compared HEAD with origin/main after verifying that origin/main was the merge commit’s recorded first parent. make test could not start because the Go build cache could not be created on the read-only filesystem.

…ill wording

civilInstant now finds the first occurrence of a local time even when
the repeated stretch is nearly a day long (Kwajalein, 1969). The auth
skill's quick reference describes --show-scopes accurately.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

This PR adds read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also adds gws calendar suggest-time to find meeting slots across multiple calendars.

What looks good

  • calendar suggest-time follows the Cobra registration, RunE, and printer conventions in CLAUDE.md. It has a command structure test, mocked FreeBusy coverage, and documentation in both the README command table and the Calendar skill reference.
  • The external-token path bypasses the stored OAuth token and avoids reading or populating the Chat caches tied to the stored login.

Issues found

  1. Critical — The confirmation gate fails open when the config cannot be read. A user who enables confirm_sensitive: true in YAML can lose the gate if that file becomes malformed or unreadable. initConfig prints a warning and continues, so the new pre-run hook can see confirmation as disabled and let a sensitive command execute. Preserve the config-load error and block sensitive commands when the confirmation policy cannot be loaded. Add an execution-path test that verifies the handler is never called in this case. cmd/root.go · cmd/root.go
  2. Warning — A date-only --to can include slots on the following date when clocks roll back across midnight. In America/St_Johns on October 31, 2010, Sunday ran from 00:00 to 00:01 before the clock returned to Saturday. The code extends Saturday’s cutoff to include the repeated hour, but the slot search then also includes that first minute of Sunday. With --working-hours any --include-weekends, a suggestion can start on Sunday or cross into it despite a Saturday cutoff. Limit eligible windows to civil dates through the requested end date and add a slot-level regression test. cmd/calendar_suggest.go · cmd/calendar_suggest.go

The shallow checkout prevented the three-dot diff. I verified that origin/main matches the merge commit’s first parent and reviewed the diff against that parent. git diff --check passed. make test stopped before running tests because Go could not create its build cache on the read-only filesystem.

…on its dates

If the config file exists but cannot be loaded, sensitive commands are
refused unless the policy is set in the environment or --yes is given,
so a broken file cannot silently switch the confirmation gate off. With
a date-only --to, no slot falls on a later date even where that date
begins before the end of the requested day.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds calendar suggest-time, read-only and incremental OAuth login, external access tokens, and refresh locking. It also adds command introspection and an opt-in confirmation gate for sensitive operations.

What looks good

  • calendar suggest-time follows the Cobra registration, runXxx, and printer conventions. It has command structure tests, httptest coverage, and documentation in the README and calendar skill command references.
  • External access tokens are excluded from confirmation prompts and hook subprocess environments. The Chat changes also prevent external-token commands from mixing their data into the stored login’s caches.

Issues found

  1. Critical — An invalid confirmation setting silently disables the gate. With confirm_sensitive: true in the config, an environment override such as GWS_CONFIRM_SENSITIVE=treu takes precedence and Viper’s boolean conversion yields false. A sensitive command can then run without approval. When the config is unreadable, even an empty environment variable bypasses confirmPolicyUnknown, because it checks only for the variable’s presence. Validate the override before treating the policy as known, and add regression tests for invalid values and for an empty override with unreadable config. config.go · root.go
  2. Warning — A null group entry panics in calendar suggest-time. If the free/busy response contains "groups": {"team@example.com": null}, the map lookup succeeds but group.Calendars dereferences a nil pointer. Treat the group as unavailable so strict mode reports an error and --allow-partial can still use other readable calendars. calendar_suggest.go

The shallow checkout prevented the three-dot diff. I used git diff origin/main HEAD after verifying that origin/main matches the PR merge commit’s recorded first parent. The diff passed git diff --check. make test could not start because the Go build cache directory was read-only.

GWS_CONFIRM_SENSITIVE and confirm_sensitive accept only unambiguous
on/off values. Anything else (a typo, an empty override) leaves the
policy unknown: sensitive commands are refused until it is corrected or
--yes is given, and the gate itself treats it as on.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds gws calendar suggest-time, read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also changes how stored credentials are refreshed and locked, and updates the README and agent skills.

What looks good

  • calendar suggest-time uses Cobra registration and the shared printer. It has command-structure and httptest coverage, and the README and both Calendar command references document it.
  • Calendar suggestions fail when availability is incomplete unless the caller explicitly allows partial results. Partial output identifies the unavailable calendars.
  • External-token mode skips the stored login’s Chat caches and cached Workspace hook context, reducing the risk of mixing data across accounts.
  • git diff --check and gofmt -l passed for the changed files.

Issues found

  • Warning — Mixed-version processes can still race on the credential lock. The new process checks whether the legacy .lock file is stale and then removes it by path. An older process can replace that file between the check and removal because it never takes the new .flock lock. The new process can then remove the older process’s live lock and enter the credential update while the older process is still running. Decline automatic takeover of stale legacy locks unless the competing writer can be ruled out. internal/auth/lock_os.go
  • Warning — The read-only login docs omit how --add affects existing write access. The README says --readonly requests only read-only scopes, but --add explicitly re-requests all previously granted scopes. For example, gws auth login --add --services calendar --readonly preserves an existing Gmail write grant. Document that --readonly limits the newly requested access in an incremental login. README.md · cmd/auth.go

The shallow checkout prevented the requested three-dot diff. I compared HEAD with origin/main after verifying that origin/main exactly matched the PR merge commit’s first parent. make test stopped before running tests because the read-only filesystem prevented Go from creating its build cache.

@github-actions

Copy link
Copy Markdown

Summary

The PR adds Calendar meeting-time suggestions, external OAuth access tokens, incremental and read-only login, command introspection, and an opt-in confirmation gate. It also changes how OAuth refreshes and grant metadata are persisted.

What looks good

  • calendar suggest-time follows the Cobra registration, RunE, and printer conventions in CLAUDE.md. It includes httptest coverage, a command structure test, and updates to the README and Calendar skill reference.
  • The Calendar command fails when availability is incomplete unless the caller opts into partial results. Even then, it reports unavailable calendars and requires at least one readable calendar.
  • The external-token path uses a static token source and prevents Chat cache commands from reading or writing the stored login’s space cache.

Issues found

  • Critical — An empty YAML setting silently disables confirmation. Viper 1.19’s InConfig returns false for a null value, so confirm_sensitive: and confirm_sensitive: null take the same path as an absent setting. With no environment override, a sensitive command can then run without confirmation. Detect key presence independently of its value and add an end-to-end test that verifies a sensitive command is blocked for both YAML forms. internal/config/config.go
  • Warning — Drive approval responses with messages bypass confirmation. The new gate covers approval comments, starts, and reassignments, but drive approve --message and drive decline --message can submit a reviewer message without prompting, even with confirm_sensitive enabled. Add coverage for both message-bearing invocations. cmd/confirm.go

I reviewed the diff from origin/main to HEAD after verifying that origin/main is the PR merge commit’s first parent. The shallow checkout prevented Git from computing the three-dot diff. git diff --check passed. make test could not start because the filesystem is read-only and Go could not create its build cache.

…gate approval messages

confirm_sensitive written with no value (or null) is now detected in the
config file itself and leaves the policy unknown, so sensitive commands
are refused. drive approve, decline and cancel-approval need
confirmation when they carry a --message.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds calendar suggest-time, read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also serializes stored-token refreshes and updates the README and skill documentation.

What looks good

  • calendar suggest-time follows the Cobra and printer conventions. It has httptest coverage, a command registration test in commands_test.go, and entries in the README and Calendar skill references.
  • The external-token path keeps credentials out of the stored login and skips Chat caches and Workspace hook context that may belong to another account.
  • The Calendar command reports unreadable calendars explicitly and requires --allow-partial before returning suggestions based on incomplete availability.

Issues found

  1. Critical — The confirmation gate can silently turn off for a valid Viper config. configFileValue reopens the config and always parses it as YAML. With --config settings.toml containing confirm_sensitive = true, Viper loads the setting successfully, but the YAML lookup reports it absent. A command such as gmail send can then run without confirmation. A failed reread after a successful initial load has the same effect. Resolve the policy once from the same config snapshot and format Viper loads, preserve explicit-null detection, and add a regression test for an enabled TOML config. internal/config/config.go · cmd/root.go

git diff --check passed. The shallow checkout prevented a three-dot diff, so I compared the PR merge commit with its verified first parent, origin/main. make test stopped before running tests because the Go build cache was on a read-only filesystem.

The setting comes from viper's own snapshot (YAML, TOML or JSON); the
YAML file is consulted directly only to tell an empty key from an absent
one. A TOML or JSON config that enables the gate is honoured again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

The PR adds calendar suggest-time, read-only and incremental OAuth login, external access tokens, command and scope introspection, and an opt-in confirmation gate. It also changes how OAuth refreshes are coordinated and stored.

What looks good

  • calendar suggest-time follows Cobra registration and printer conventions, with command structure tests and an httptest integration test. The README command table and Calendar skill references document the command, including how partial availability is reported.
  • The new auth tests cover concurrent refreshes and refresh-token rotation. The confirmation tests cover noninteractive calls and unreadable policy configuration.

Issues found

  • Warning — Chat reactions bypass the confirmation gate. gws chat react posts a reaction visible to other participants and can notify the message author. The new policy covers chat unreact but omits chat react, so the latter can post with GWS_CONFIRM_SENSITIVE=1 and no approval. Add it to the policy and test that a noninteractive invocation without --yes stops before the API call. cmd/confirm.go

The three-dot diff failed because the shallow checkout had no merge base. I reviewed the diff between origin/main and HEAD after verifying that origin/main matched the merge commit’s recorded first parent. git diff --check passed. make test could not start because the Go build cache was on a read-only filesystem.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

This PR adds calendar suggest-time, expands OAuth with read-only and incremental login and external access tokens, and introduces command introspection and an opt-in confirmation gate. It also updates the README and service skills.

What looks good

  • suggest-time follows the Cobra registration and printer conventions in CLAUDE.md. It has command structure tests, httptest coverage, and entries in both the README command table and the Calendar skill reference.
  • The scheduling command requires explicit --allow-partial before suggesting times from incomplete availability data and reports which calendars were unavailable.

Issues found

  1. Critical — A null JSON setting silently disables confirmation. With --config pointing to a JSON file containing {"confirm_sensitive": null}, Viper treats the key as absent. The fallback only checks YAML files, so the policy returns false, nil and a sensitive command can proceed without confirmation. Preserve explicit null values for supported config formats and add a JSON regression case alongside the YAML cases. internal/config/config.go
  2. Warning — Confirmation policy is read twice before execution. The pre-run hook first checks whether the policy is valid, then reads it again to decide whether to prompt. If an explicit null YAML setting appears between those reads, the second call converts the policy error into an enabled gate and an interactive user can proceed by answering y, despite the documented requirement to fix the setting or pass --yes. Resolve the policy once and use that result for both validation and prompting. cmd/root.go

The shallow checkout had no merge base. I compared origin/main directly with the PR merge snapshot after verifying that origin/main matched the base commit named in the merge message. git diff --check passed. make test stopped before running tests because the filesystem is read-only and Go could not create its build cache.

@github-actions

Copy link
Copy Markdown

Summary

The PR adds calendar suggest-time, read-only and incremental OAuth login, external access tokens, command introspection, and an opt-in confirmation gate. It also changes how stored credentials are refreshed and locked.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has command-structure coverage in commands_test.go, mocked FreeBusy tests using httptest, and documentation in the README command table and both Calendar skill references.
  • The external-token path takes precedence in the client factory and skips the Chat caches and hook context associated with the stored login.

Issues found

  • Warning — A crashed process can still block subsequent logins, logouts, and token refreshes. The kernel releases the OS lock when the holder dies, but the compatibility .lock file remains. The next process acquires the OS lock and then waits on that marker, so it can hit the five-second lock timeout until the marker reaches the 30-second stale threshold. Add a process-exit test and recover abandoned markers from current versions while preserving compatibility with older clients. internal/auth/lock_os.go
  • Warning — The README presents gws auth login --readonly as requesting scopes for every service. With services set in config.yaml, the command requests scopes only for the configured services. Qualify the example so users can tell which scopes the command will request. README.md

The shallow checkout had no merge base. I reviewed git diff origin/main HEAD after verifying that origin/main is the merge commit’s first parent. The diff whitespace check passed. make test could not start because the read-only sandbox prevented Go from creating its build cache.

A marker written under the OS lock can only belong to a process that no
longer holds it, so the next holder replaces it immediately instead of
waiting for it to go stale. README: --readonly follows a configured
services list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GB34RWVbYYwb6ihVx6xzh
@github-actions

Copy link
Copy Markdown

Summary

PR #230 adds calendar suggest-time, read-only and incremental OAuth login, externally managed access tokens, command introspection, and an opt-in confirmation gate. It also serializes stored-token refreshes and updates the README and skill references.

What looks good

  • calendar suggest-time follows the Cobra registration and printer conventions. It has command structure coverage in commands_test.go, an httptest integration test, and documentation in the README and calendar command reference.
  • Availability checks fail closed by default. With --allow-partial, the output identifies calendars whose availability is unknown.
  • The external-token path skips stored-login caches, rejects explicitly empty tokens, and omits the token flag from confirmation prompts.

Issues found

  1. Warning — auth status can overstate read-only protection. Incremental login preserves every scope from the previous grant, but allReadOnly checks only the access levels derived from the built-in service tables. If a legacy grant holds gmail.readonly and https://mail.google.com/, adding Tasks with --readonly preserves full Gmail access while login and status can both report read_only: true. Derive that field from the complete granted scope list and treat unclassified scopes as unknown. Add a regression test for a preserved scope outside the built-in tables. cmd/auth.go
  2. Warning — Two refresh-token rotations can make an unchanged login look replaced. sameAuthorization recognizes only the current refresh-token fingerprint and its immediate predecessor. If a long-running command holds token A while other invocations rotate the same grant from A to B to C, its next refresh returns ErrLoginChanged. Bind refreshes to a stable authorization identifier that survives rotation and changes on a new login. internal/auth/token.go

git diff --check and the formatting check passed. make test stopped before running tests because the read-only filesystem prevented Go from creating its build cache. The shallow checkout lacked a merge base, so I compared HEAD with origin/main after verifying that origin/main was the PR merge commit’s first parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment