Repository navigation
PGBot for macOS (desktop/macos) + pgbot sql run - #171
Open
alexshapalov wants to merge 8 commits into
Open
alexshapalov wants to merge 8 commits into
alexshapalov wants to merge 8 commits into
Conversation
Executes one or more statements inside a single BEGIN READ ONLY transaction that is always rolled back, so the server itself refuses writes and DDL. Before anything is sent, pgbot refuses statements that could end or escape the transaction (COMMIT/BEGIN/SAVEPOINT/…), reach outside the database (COPY, dblink, large-object file I/O) or act on other sessions or the server (pg_terminate_backend, pg_reload_conf, stats resets, replication slots, VACUUM, LOCK). Each statement goes over the extended protocol, so one call carries exactly one statement. Statement and lock timeouts bound every statement and --max-rows stops fetching server-side. Output is psql-style aligned text, or JSON with --json (sql_run_schema_version 1.0.0), which the desktop app's PSQL mode decodes. Tests: statement splitting (quotes, E'', dollar quoting, nested comments), the refusal list, the aligned renderer, the JSON contract, refusal before connecting, and an integration test (PGBOT_TEST_SUPERUSER_DSN) proving that writes and DDL never land even for a superuser, plus types, NULL, max-rows, statement timeout and error positions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The headless half of PGBot for macOS (desktop/macos), with no SwiftUI so all of it is checkable from the command line: - Engine adapter over the bundled pgbot binary: typed calls for inspect, ask, sql explain, sql run, logs, activity, why, diff and init. The DSN goes in PGBOT_DATABASE_URL and SQL over stdin (never argv), the child environment is allow-listed, stderr is redacted, and runs are bounded by a timeout, SIGTERM→SIGKILL cancellation and a concurrency limit. - Codable mirror of the Context JSON contract, the engine's health-score formula with a completeness gate, and the id+object finding diff with an announcement ledger so a finding is never re-announced. - Keychain secrets (AfterFirstUnlockThisDeviceOnly), SQLite persistence (0600, no password field), a per-bot scheduler with backoff and sleep/wake, OAuth 2.0 + PKCE via an auth broker, and demo data. - PSQL mode: psql meta-commands (\d, \dt, \l, \dn, \df, \du, \dx, \x, …) translated to catalog queries with patterns quoted safely; shell, file and session commands refused. Checks: `swift run PGBotKitChecks` (49 unit checks; Command Line Tools ship no XCTest), plus 8 live checks with PGBOT_TEST_DSN and PGBOT_ENGINE_PATH. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One bot per PostgreSQL database, built on PGBotKit and the bundled engine: - Chat per database with health reports, findings, plans and tables; answers from `pgbot ask` behind an explicit per-provider consent sheet. - PSQL mode (+ → PSQL Mode, ⌘⇧P): a read-only psql console in the chat with history, psql Return semantics, typed result tables, \x records, copy as TSV/CSV/Markdown and psql-style errors with a caret. - Metrics charts, logs with filters, notification center, menu bar extra, and macOS notifications with per-category, severity, quiet-hours and per-database settings. - Settings: appearance (theme, accent, text size, density, message style, avatars), new-database defaults, monitoring, AI providers, privacy. - Demo mode (clearly labelled), onboarding and add-database flows with the read-only role setup SQL. scripts/build-app.sh builds the universal engine and assembles a signed PGBot.app; launch scenarios support screenshots and UI automation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs on macos-14 (Swift 5.10) when desktop/, cmd/, internal/ or the Go module change: PGBotKit unit checks, live engine checks against a Homebrew PostgreSQL 17 (including PSQL mode's read-only guarantees), the sql run superuser integration test, and a PGBot.app build whose bundle, universal engine and signature are verified. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…database Adding a database posts its first health report. The once-a-minute daily report timer then saw a bot that had never had a daily report, past its report hour (09:00 by default), and ran a second inspection, so the chat showed the same report twice. The first report now counts as today's full report, and the due rule moves to AnnouncementLedger.isDailyReportDue, covered by a new check. Verified in the built app: one report after 2.5 minutes, where there used to be two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The composer mode was only reachable from the + menu or ⌘⇧P, and nothing near the input said which mode was on. A two-segment Chat | PSQL switch now sits next to +: the active mode is a raised pill (green for PSQL) that slides between segments, with tooltips and accessibility labels. Also: the \? help rendered its Markdown table as raw pipes (chat messages don't render tables); it is a list now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
A native SwiftUI app for macOS under
desktop/macos: one chat-first bot per PostgreSQL database, built entirely on the existing engine's machine contracts. It also adds one engine command,pgbot sql run, which powers the app's new PSQL mode.Commits
feat(sql): pgbot sql runruns your own SQL read-only. Output is psql-style aligned text, or--json(sql_run_schema_version1.0.0).BEGIN READ ONLYtransaction that is always rolled back.pg_terminate_backend,pg_reload_conf, stats resets, replication slots, VACUUM and LOCK.--max-rows.feat(desktop): PGBotKitis the headless core, with no SwiftUI:feat(desktop): PGBot for macOSis the SwiftUI app:scripts/build-app.shbuilds a signedPGBot.appwith the universal engine.ci: macOS jobadds.github/workflows/desktop-macos.yml.Each commit builds on its own.
Read-only guarantees
Tests
TestSplitSQLStatements,TestRefuseStatement,TestRenderSQLRunText*,TestSQLRunJSONContract(pins the keys the app decodes) andTestExecuteSQLRunRefusesBeforeConnecting.TestIntegration_sqlRun(PGBOT_TEST_SUPERUSER_DSN) checks that writes and DDL never land, plus types, NULL, max-rows, statement timeout and error position. The existingintegrationjob picks it up on PG 14–19.swift run PGBotKitCheckshas 49 unit checks, plus 8 live checks withPGBOT_TEST_DSNandPGBOT_ENGINE_PATH. The live checks cover inspect scoring against the CLI, error classification, and PSQL mode typed rows, the 25006 block, the COMMIT refusal, and\dt/\dagainst the real catalog.sql runintegration test, and aPGBot.appbuild. It verifies the bundle, the arm64+x86_64 engine and the code signature.Verified locally on a clean checkout of the branch:
go vetclean,golangci-lint0 issuesgo test ./...passesNot in this PR
CHANGELOG.mdor top-levelREADME.mdentry forsql runyet.desktop/macos/README.md.🤖 Generated with Claude Code