Skip to content

Read only cli commands#156

Merged
aprimakina merged 3 commits into
mainfrom
read-only-cli-commands
May 29, 2026
Merged

Read only cli commands#156
aprimakina merged 3 commits into
mainfrom
read-only-cli-commands

Conversation

@aprimakina

@aprimakina aprimakina commented May 18, 2026

Copy link
Copy Markdown
Contributor

Extend read-only mode enforcement to CLI commands and DB connections

Previously, read-only mode only blocked MCP tool calls. This PR extends the gate to:

  • CLI destructive commands — service create/fork/start/stop/resize/update-password/delete now call common.CheckReadOnly before any API request
  • DB connections — db connection-string and db connect now OR the --read-only flag with cfg.ReadOnly, so the global config forces read-only PostgreSQL sessions even without the flag

@ggodeke requested the change, we prefer a more locked-down experience in the tiger CLI compared to ghost

@aprimakina aprimakina marked this pull request as ready for review May 18, 2026 10:03

@nathanjcochran nathanjcochran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left two minor comments, but overall LGTM! ✅

Comment thread internal/tiger/common/errors.go Outdated
// CheckReadOnly returns ErrReadOnly if read-only mode is enabled. Callers
// should invoke this before any destructive API call.
func CheckReadOnly(cfg *config.Config) error {
if cfg != nil && cfg.ReadOnly {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what case would cfg be nil? It looks like the prior version of this function (which was moved here from the ./internal/tiger/mcp package) always assumed cfg was non-nil (which makes sense to me - I believe we usually error-out if we can't load the config). Just want to make sure we don't end up silently ignoring an error that caused the config to not load, and reporting that read-only mode is not enabled (when it actually might be).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Every caller passes cfg.Config from a successful common.LoadConfig, which already errors out on load failure, so we never reach this with a nil cfg. Dropping the check 👍

Comment thread internal/tiger/cmd/db.go
aprimakina and others added 3 commits May 29, 2026 15:52
The read_only config flag previously only refused destructive Tiger MCP
tool calls. Extend it to the equivalent CLI commands (service create,
fork, start, stop, resize, update-password, delete) so a single config
flip prevents accidental mutation through either entry point.

CheckReadOnly + ErrReadOnly move from internal/tiger/mcp/errors.go to
internal/tiger/common/errors.go so both packages share them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
tiger db connect and tiger db connection-string now OR the --read-only
flag with the global read_only config option, so flipping the config on
guarantees that any database session opened through the CLI is opened
with the tsdb_admin.read_only_connection GUC — matching how the
db_execute_query MCP tool already behaves.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aprimakina aprimakina force-pushed the read-only-cli-commands branch from 323e806 to 228eb73 Compare May 29, 2026 13:52
@aprimakina aprimakina self-assigned this May 29, 2026
@aprimakina aprimakina merged commit 9720407 into main May 29, 2026
2 of 5 checks passed
@aprimakina aprimakina deleted the read-only-cli-commands branch May 29, 2026 20:08
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.

2 participants