// db.go is `carlos db`: a member reads an app's database from its replica, // with no box access and no AWS credentials (spec 2026-09-02). // // It never connects to the running database. The console serves the // replica's LTX files by coordinate (internal/console/apidb.go); this side // restores them, with litestream's own restore and a client that has no // write methods (internal/dbdoor), into a private 0700 directory, proves the // result with lease.CheckDB, and then either copies it to --out (pull) or // opens it read-only and runs one query (query). The console never executes // tenant SQL and never holds a restored database. // // Read-only is enforced, not assumed (spec §4): mode=ro and query_only. A // copy is harmless to write to; the point is that nobody, person or agent, // can come away believing a write reached production. // // Unit 1 of three (spec §13): ls and its freshness fields, then shell, // follow. package main import ( "context" "errors" "flag" "fmt" "io" "log" "os" "os/signal" "slices" "sort" "strings" "syscall" "time" "github.com/carlosframework/platform/internal/dbdoor" "github.com/carlosframework/platform/internal/dbquery" "github.com/carlosframework/platform/internal/dbreads" ) const dbUsage = `usage: carlos db --app [--instance ] [flags] pull --out restore a copy of the instance's database and save it at , which must not exist yet (saved 0600) query --sql restore a copy and run one read-only query against it; rows go to stdout, tab-separated, with a header row Add --at