diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6582b6faf7..46bcddb128 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,10 @@ jobs: - uses: actions/checkout@v4 - name: Worker unit tests (node:test) run: node --test dist/pgboxdb.com/install-worker.test.js + - name: Legacy-domain transition redirect Worker (node:test) + run: | + node --test dist/legacy-domain-redirect/redirect-worker.test.js + node --test dist/legacy-domain-redirect/install/legacy-install-worker.test.js release-workflow: name: release workflow and distribution names runs-on: ubuntu-24.04 diff --git a/Cargo.lock b/Cargo.lock index f889135b8e..86784f9ea2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13774,7 +13774,7 @@ dependencies = [ [[package]] name = "pgboxdb" -version = "0.1.3" +version = "0.2.0" dependencies = [ "crossterm", "libc", diff --git a/README.md b/README.md index 2e3fda065c..fd91971470 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ npx pgboxdb@latest

- Open source · Free · v0.1.3 · For disposable databases, not production data + Open source · Free · v0.2.0 · For disposable databases, not production data

PGBoxDB is a database runtime for short-lived Postgres databases: agent @@ -275,8 +275,8 @@ session end → branch dropped ## Status -PGBoxDB is at **v0.1.3**, an early release with known limitations listed in the -[release notes](https://github.com/pgrundev/pgboxdb/releases/tag/v0.1.3). It +PGBoxDB is at **v0.2.0**, an early release with known limitations listed in the +[release notes](https://github.com/pgrundev/pgboxdb/releases/tag/v0.2.0). It already powers PGBoxDB branches in [PGRun](https://pgrun.dev), which adds the control plane around it: safe masked copies of a source database, sealed templates, one branch per agent, PR or CI job, routing, access and @@ -384,7 +384,7 @@ activated and your permissions allow it. | Cursor | hooks installed; `pgboxdb agent exec --` when `PGBOXDB_ISOLATION` is unset | env propagation pending live verification | | Codex | `pgboxdb agent exec -- codex` (Codex hooks cannot set environment) | wrapper verified | -Requires PGBoxDB 0.1.2 or newer; the Skill checks the installed version before it +Requires PGBoxDB 0.2.0 or newer; the Skill checks the installed version before it does anything. [`pgrundev/pgboxdb-plugin`](https://github.com/pgrundev/pgboxdb-plugin) holds only the plugin (about 110 KB, generated from this repository), so the install takes seconds; adding this repository itself as the marketplace diff --git a/crates/bin/pgboxdb/Cargo.toml b/crates/bin/pgboxdb/Cargo.toml index 38feebee11..f626169702 100644 --- a/crates/bin/pgboxdb/Cargo.toml +++ b/crates/bin/pgboxdb/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pgboxdb" -version = "0.1.3" +version = "0.2.0" edition.workspace = true publish.workspace = true description = "PGBoxDB command-line interface: a lightweight Postgres-compatible database runtime for AI agents" diff --git a/crates/bin/pgboxdb/tests/lifecycle.rs b/crates/bin/pgboxdb/tests/lifecycle.rs index 7cde86dac7..cf35b8b98a 100644 --- a/crates/bin/pgboxdb/tests/lifecycle.rs +++ b/crates/bin/pgboxdb/tests/lifecycle.rs @@ -147,12 +147,14 @@ fn init_with_run_dir_override_accepts_long_home() { let p = Pgboxdb::with_home(long); let run_dir = common::scratch_root().join(format!("rd{}", p.port)); let port = p.port.to_string(); - let r = common::output_locked( - p.cmd(&["init", "--port", &port]) - .env("PGBOXDB_RUN_DIR", &run_dir), - ) - .unwrap(); - let r = common::Run::from(r); + let r = p.output_retrying_pub( + || { + let mut c = p.cmd(&["init", "--port", &port]); + c.env("PGBOXDB_RUN_DIR", &run_dir); + c + }, + "pgboxdb init", + ); assert_eq!(r.code, 0, "{}", r.all()); assert_eq!(p.config()["run_dir"], run_dir.to_string_lossy().as_ref()); let _ = std::fs::remove_dir_all(run_dir); @@ -478,22 +480,26 @@ fn serve_runs_in_foreground_and_initialises() { fn init_honors_pgboxdb_password_env() { let p = Pgboxdb::new(); let port = p.port.to_string(); - let r = common::output_locked( - p.cmd(&["init", "--port", &port]) - .env("PGBOXDB_PASSWORD", "supersecret123"), - ) - .unwrap(); - assert_eq!(common::Run::from(r).code, 0); + let r = p.output_retrying_pub( + || { + let mut c = p.cmd(&["init", "--port", &port]); + c.env("PGBOXDB_PASSWORD", "supersecret123"); + c + }, + "pgboxdb init", + ); + assert_eq!(r.code, 0, "{}", r.all()); assert_eq!(p.config()["password"], "supersecret123"); // too short is rejected let p2 = Pgboxdb::new(); let port2 = p2.port.to_string(); - let r = common::Run::from( - common::output_locked( - p2.cmd(&["init", "--port", &port2]) - .env("PGBOXDB_PASSWORD", "short"), - ) - .unwrap(), + let r = p2.output_retrying_pub( + || { + let mut c = p2.cmd(&["init", "--port", &port2]); + c.env("PGBOXDB_PASSWORD", "short"); + c + }, + "pgboxdb init", ); assert_eq!(r.code, 2, "{}", r.all()); assert!(r.stderr.contains("too short"), "{}", r.stderr); diff --git a/crates/bin/pgboxdb/tests/top_tty.rs b/crates/bin/pgboxdb/tests/top_tty.rs index 7a34088bd3..cad79d947a 100644 --- a/crates/bin/pgboxdb/tests/top_tty.rs +++ b/crates/bin/pgboxdb/tests/top_tty.rs @@ -115,13 +115,22 @@ impl Tty { self.master.flush().unwrap(); } - /// Wait until the screen output (after `from` bytes) contains `needle`. + /// Wait until `needle` appears after `from` bytes of output: either in the + /// bytes written since then, or on the reconstructed screen when it was not + /// on the screen at `from`. The second form matters because the renderer + /// sends only changed cells: a redraw of "appeared_later" over a cell that + /// already held an "r" does not resend that "r", so the byte stream alone + /// can miss text that is plainly on the screen. fn expect(&self, needle: &str, from: usize, secs: u64) { let deadline = Instant::now() + Duration::from_secs(secs); + let before = { + let raw = self.raw(); + screen(&raw[..from.min(raw.len())]).contains(needle) + }; loop { let raw = self.raw(); let tail = strip_ansi(&String::from_utf8_lossy(&raw[from.min(raw.len())..])); - if tail.contains(needle) { + if tail.contains(needle) || (!before && screen(&raw).contains(needle)) { return; } if Instant::now() > deadline { @@ -205,6 +214,117 @@ impl Drop for Tty { } } +/// The text of the terminal screen after `raw`, as rows joined by newlines: a +/// minimal emulator for what the TUI emits (cursor positioning, line and screen +/// erase, the alternate screen, printable characters; colours are ignored). +fn screen(raw: &[u8]) -> String { + let s = String::from_utf8_lossy(raw); + let mut grid: Vec> = Vec::new(); + let (mut row, mut col) = (0usize, 0usize); + let put = |grid: &mut Vec>, r: usize, c: usize, ch: char| { + if grid.len() <= r { + grid.resize(r + 1, Vec::new()); + } + let line = &mut grid[r]; + if line.len() <= c { + line.resize(c + 1, ' '); + } + line[c] = ch; + }; + let mut it = s.chars().peekable(); + while let Some(ch) = it.next() { + match ch { + '\x1b' => match it.next() { + Some('[') => { + let mut params = String::new(); + let mut fin = '\0'; + for d in it.by_ref() { + if ('@'..='~').contains(&d) { + fin = d; + break; + } + params.push(d); + } + let private = params.starts_with('?'); + let nums: Vec = params + .trim_start_matches('?') + .split(';') + .map(|n| n.parse().unwrap_or(0)) + .collect(); + let n = |i: usize, dflt: usize| { + nums.get(i).copied().filter(|v| *v > 0).unwrap_or(dflt) + }; + match fin { + 'H' | 'f' => { + row = n(0, 1) - 1; + col = n(1, 1) - 1; + } + 'A' => row = row.saturating_sub(n(0, 1)), + 'B' => row += n(0, 1), + 'C' => col += n(0, 1), + 'D' => col = col.saturating_sub(n(0, 1)), + 'G' => col = n(0, 1) - 1, + 'd' => row = n(0, 1) - 1, + 'J' if nums.first().copied().unwrap_or(0) >= 2 => grid.clear(), + 'J' => { + if let Some(line) = grid.get_mut(row) { + line.truncate(col); + } + grid.truncate(row + 1); + } + 'K' => { + if let Some(line) = grid.get_mut(row) { + line.truncate(col); + } + } + 'h' | 'l' if private && params.contains("1049") => grid.clear(), + _ => {} + } + } + Some(']') => { + while let Some(d) = it.next() { + if d == '\x07' || (d == '\x1b' && it.peek() == Some(&'\\')) { + if d == '\x1b' { + it.next(); + } + break; + } + } + } + _ => {} + }, + '\r' => col = 0, + '\n' => row += 1, + '\x08' => col = col.saturating_sub(1), + c if c.is_control() => {} + c => { + put(&mut grid, row, col, c); + col += 1; + } + } + } + grid.iter() + .map(|l| l.iter().collect::()) + .collect::>() + .join("\n") +} + +#[test] +fn screen_model_sees_text_drawn_over_unchanged_cells() { + // "appeared_later" drawn over "xxxxxrxxxxxxxx": the renderer skips the + // unchanged "r", so the byte stream holds "appea" and "ed_later" only. + let first = b"\x1b[?1049h\x1b[3;5Hxxxxxrxxxxxxxx"; + let second = b"\x1b[3;5Happea\x1b[3;11Hed_later"; + let mut all = first.to_vec(); + all.extend_from_slice(second); + assert!(!strip_ansi(&String::from_utf8_lossy(second)).contains("appeared_later")); + assert!(screen(&all).contains("appeared_later")); + assert!(!screen(first).contains("appeared_later")); + // Erase to end of line, and a full clear. + assert!(!screen(b"\x1b[1;1Habcdef\x1b[1;3H\x1b[K").contains("cdef")); + assert!(screen(b"\x1b[1;1Habc\x1b[2Jxyz").trim() == "xyz"); +} + fn strip_ansi(s: &str) -> String { let mut out = String::with_capacity(s.len()); let mut it = s.chars().peekable(); diff --git a/dist/install.sh b/dist/install.sh index e0037db426..a705fb6237 100755 --- a/dist/install.sh +++ b/dist/install.sh @@ -4,7 +4,7 @@ # $PGBOXDB_BIN_DIR. No root, no system PostgreSQL. # # curl -fsSL https://pgboxdb.com/install | sh -# PGBOXDB_VERSION=0.1.0 PGBOXDB_BIN_DIR=~/.local/bin sh install.sh +# PGBOXDB_VERSION=0.2.0 PGBOXDB_BIN_DIR=~/.local/bin sh install.sh # # Environment: # PGBOXDB_VERSION version to install (default: latest release) diff --git a/dist/legacy-domain-redirect/README.md b/dist/legacy-domain-redirect/README.md new file mode 100644 index 0000000000..bcb74554ad --- /dev/null +++ b/dist/legacy-domain-redirect/README.md @@ -0,0 +1,86 @@ +# The previous domain (pgx.dev) during and after the transition + +Two Cloudflare Workers answer every request to `pgx.dev`. The domain itself +is never transferred, released or deleted. + +| Worker | Route | Source | +|---|---|---| +| `pgx-dev-redirect` | `pgx.dev/*` (every path) | `redirect-worker.js`, `wrangler.toml` | +| `pgx-install` | `pgx.dev/install` | `install/` | + +## Timeline + +| | UTC | +|---|---| +| Transition activated (first 301) | **2026-11-19 19:58:36** | +| Authorised until (activation + 90 days) | 2027-02-17 19:58:36 | +| `REDIRECT_UNTIL`, enforced in code by both Workers | **2027-02-17 19:58:29** | + +## Until `REDIRECT_UNTIL` + +* `https://pgx.dev/*` and `http://pgx.dev/*` answer 301 to `https://pgboxdb.com`. + * `/`, `/index.html`, `/llms.txt` and `/robots.txt` keep their path; these + are the pages that exist on both sites. Every other path goes to the home + page. The query string is always kept. + * `Cache-Control: public, max-age=3600`, so browsers re-check hourly and do + not keep the 301 after the transition. +* `https://pgx.dev/install` serves the previous product's installer script + (tag `v0.1.3`). It is unchanged except for one line after the shebang that + defaults its version to `0.1.3`. Without that line, the script would pick + "the newest release", which from v0.2.0 on is a PGBoxDB release with other + asset names, and `curl -fsSL https://pgx.dev/install | sh` would fail. A + version the user sets still wins. +* There is no `www.pgx.dev` record, so there is nothing to redirect there. + +## From `REDIRECT_UNTIL` on + +Both Workers answer **`410 Gone`** (plain text, no branding) on every path, +`/install` included. They do this without any redeploy, and also if the +deadline variable is missing or invalid. The redirect Worker never forwards a +request to the origin, so the previous website can't be served again. +`curl -fsSL https://pgx.dev/install | sh` then fails (`curl -f` stops on the +410, and `sh` gets an empty script). + +**Keep both Workers deployed after the deadline.** The previous site is still +deployed as the Worker `pgx`. Only the `pgx.dev/*` route keeps it unreachable, +so deleting `pgx-dev-redirect` would bring it back. To retire the old site for +good, remove the `pgx` Worker's domain or route as a separate step that needs +approval. That is not a domain transfer or deletion. + +## Why the two routes can't conflict + +* Cloudflare uses the most specific matching route, so `pgx.dev/install` (with + any query string) reaches `pgx-install`. Verified live: 200, + `text/x-shellscript`, `x-pgx-install-version: 0.1.3`. +* If the redirect Worker ever receives `/install` anyway, it hands the + request to `pgx-install` through the `INSTALLER` service binding, never to + the origin or to `pgboxdb.com`. +* `/install/` and every other path go to the redirect Worker: 301 until the + deadline, then 410. No path reaches the old site. Verified live: `/` answers + 301, not the old page. +* Both Workers read the same `REDIRECT_UNTIL`, so they stop together. +* The tests (`redirect-worker.test.js`, `install/legacy-install-worker.test.js`, + run in CI) fail if the redirect Worker forwards to the origin, if `/install` + is redirected, or if anything other than 410 is served after the deadline. + +## Deployments + +| Worker | Version | Deployed (UTC) | Note | +|---|---|---|---| +| `pgx-dev-redirect` | `5c43142a-18c3-4385-942a-7b98cf8632c7` | 2026-11-19 19:58:36 | first version (activation) | +| `pgx-install` | `d1cc0c44-9283-4fd3-9fce-07c9ef118396` | 2026-11-19 20:04:41 | v0.1.3 script, version pinned | +| `pgx-install` | `f7c5157b-6261-4250-9501-a59715f43c0e` | 2026-11-19 20:23 | + 410 after the deadline | +| `pgx-dev-redirect` | `5d1fab37-4514-412c-98e7-0daa5c826709` | 2026-11-19 20:23:25 | + 410 after the deadline, `INSTALLER` binding | + +Before the transition, `pgx-install` was `44d28964-e04c-4899-927a-105f9e6202ed` +(tag v0.1.0's script, unpinned). + +## Change + +```sh +node --test redirect-worker.test.js install/legacy-install-worker.test.js +(cd install && npx wrangler deploy) # the binding target first +npx wrangler deploy +``` + +Never set `REDIRECT_UNTIL` later than `2027-02-17T19:58:36Z` in either file. diff --git a/dist/legacy-domain-redirect/install/legacy-install-worker.js b/dist/legacy-domain-redirect/install/legacy-install-worker.js new file mode 100644 index 0000000000..0eb3643ee1 --- /dev/null +++ b/dist/legacy-domain-redirect/install/legacy-install-worker.js @@ -0,0 +1,57 @@ +// Cloudflare Worker `pgx-install` for https://pgx.dev/install (the previous +// domain's installer endpoint, kept working for existing instructions). +// +// It serves the previous product's installer exactly as tagged (INSTALL_REF, +// e.g. v0.1.3), with one line added after the shebang: a default for its +// version variable (LEGACY_VERSION). Without it the script would install "the +// newest release", which is a PGBoxDB release from v0.2.0 on, whose assets have +// different names, so `curl … | sh` would fail. An explicit version set by the +// user still wins. The installer itself is not changed in any other way. +// +// It serves only during the authorised transition: from REDIRECT_UNTIL on (or +// if that is missing or invalid) every request gets 410 Gone, so the previous +// product's installer stops with the rest of pgx.dev. +const REPO = "pgrundev/pgboxdb"; +const REF_RE = /^v\d+\.\d+\.\d+[0-9A-Za-z.-]*$/; +const VERSION_RE = /^\d+\.\d+\.\d+[0-9A-Za-z.-]*$/; +const VERSION_VAR = "PGX_VERSION"; // the variable the tagged installer reads + +export function pin(script, version) { + const nl = script.indexOf("\n"); + if (!script.startsWith("#!") || nl < 0) return null; + const line = `${VERSION_VAR}="\${${VERSION_VAR}:-${version}}" # pinned by the pgx.dev /install Worker\n`; + return script.slice(0, nl + 1) + line + script.slice(nl + 1); +} + +const text = (status, msg) => + new Response(msg + "\n", { status, headers: { "content-type": "text/plain; charset=utf-8" } }); + +export default { + async fetch(request, env, _ctx, now = Date.now()) { + const end = Date.parse(env && env.REDIRECT_UNTIL); + if (!Number.isFinite(end) || now >= end) return text(410, "410 Gone"); + const url = new URL(request.url); + if (url.pathname !== "/install") return text(404, "not found"); + if (request.method !== "GET" && request.method !== "HEAD") return text(405, "method not allowed"); + const ref = env && env.INSTALL_REF; + const version = env && env.LEGACY_VERSION; + if (!ref || !REF_RE.test(ref) || !version || !VERSION_RE.test(version)) { + return text(500, "installer misconfigured: INSTALL_REF and LEGACY_VERSION must be pinned"); + } + const upstream = await fetch(`https://raw.githubusercontent.com/${REPO}/${ref}/dist/install.sh`, { + cf: { cacheTtl: 300, cacheEverything: true }, + }); + if (!upstream.ok) return text(502, `installer unavailable (upstream ${upstream.status} for ref ${ref})`); + const body = pin(await upstream.text(), version); + if (body === null) return text(502, `installer unavailable (unexpected script at ${ref})`); + return new Response(body, { + status: 200, + headers: { + "content-type": "text/x-shellscript; charset=utf-8", + "cache-control": "public, max-age=300", + "x-pgx-install-ref": ref, + "x-pgx-install-version": version, + }, + }); + }, +}; diff --git a/dist/legacy-domain-redirect/install/legacy-install-worker.test.js b/dist/legacy-domain-redirect/install/legacy-install-worker.test.js new file mode 100644 index 0000000000..db4a397daf --- /dev/null +++ b/dist/legacy-domain-redirect/install/legacy-install-worker.test.js @@ -0,0 +1,65 @@ +// node --test dist/legacy-domain-redirect/install/legacy-install-worker.test.js +import { test } from "node:test"; +import assert from "node:assert/strict"; +import worker, { pin } from "./legacy-install-worker.js"; + +const SCRIPT = '#!/bin/sh\nset -eu\nversion="${PGX_VERSION:-}"\n'; +const END = "2027-02-17T19:58:29Z"; +const env = { INSTALL_REF: "v0.1.3", LEGACY_VERSION: "0.1.3", REDIRECT_UNTIL: END }; +function stub(status = 200, body = SCRIPT) { + const calls = []; + globalThis.fetch = async (u) => { calls.push(String(u)); return new Response(body, { status }); }; + return calls; +} + +test("serves the tagged script with the version default after the shebang", async () => { + const calls = stub(); + const r = await worker.fetch(new Request("https://pgx.dev/install"), env); + assert.equal(r.status, 200); + assert.match(r.headers.get("content-type"), /text\/x-shellscript/); + assert.equal(r.headers.get("x-pgx-install-version"), "0.1.3"); + const lines = (await r.text()).split("\n"); + assert.equal(lines[0], "#!/bin/sh"); + assert.match(lines[1], /^PGX_VERSION="\$\{PGX_VERSION:-0\.1\.3\}"/); + assert.equal(lines[2], "set -eu"); + assert.deepEqual(calls, ["https://raw.githubusercontent.com/pgrundev/pgboxdb/v0.1.3/dist/install.sh"]); +}); + +test("an explicit version from the user still wins (shell semantics)", () => { + assert.ok(pin(SCRIPT, "0.1.3").includes('PGX_VERSION="${PGX_VERSION:-0.1.3}"')); +}); + +test("refuses anything that is not a shell script", () => { + assert.equal(pin("", "0.1.3"), null); +}); + +test("misconfiguration fails loudly", async () => { + stub(); + for (const e of [{ REDIRECT_UNTIL: END }, { ...env, INSTALL_REF: "main" }, { ...env, LEGACY_VERSION: "latest" }]) { + assert.equal((await worker.fetch(new Request("https://pgx.dev/install"), e)).status, 500); + } +}); + +test("upstream failure or non-script body is a 502, never an empty 200", async () => { + stub(404, ""); + assert.equal((await worker.fetch(new Request("https://pgx.dev/install"), env)).status, 502); + stub(200, "oops"); + assert.equal((await worker.fetch(new Request("https://pgx.dev/install"), env)).status, 502); +}); + +test("only GET/HEAD on /install", async () => { + stub(); + assert.equal((await worker.fetch(new Request("https://pgx.dev/other"), env)).status, 404); + assert.equal((await worker.fetch(new Request("https://pgx.dev/install", { method: "POST" }), env)).status, 405); +}); + +test("from the deadline on, or without one: 410 Gone, upstream never fetched", async () => { + const calls = stub(); + const at = Date.parse(END); + for (const [e, now] of [[env, at], [env, at + 86400000], [{ ...env, REDIRECT_UNTIL: undefined }, at - 1000]]) { + const r = await worker.fetch(new Request("https://pgx.dev/install"), e, {}, now); + assert.equal(r.status, 410); + assert.equal(await r.text(), "410 Gone\n"); + } + assert.equal(calls.length, 0); +}); diff --git a/dist/legacy-domain-redirect/install/package.json b/dist/legacy-domain-redirect/install/package.json new file mode 100644 index 0000000000..8898b26241 --- /dev/null +++ b/dist/legacy-domain-redirect/install/package.json @@ -0,0 +1 @@ +{ "type": "module", "private": true } diff --git a/dist/legacy-domain-redirect/install/wrangler.toml b/dist/legacy-domain-redirect/install/wrangler.toml new file mode 100644 index 0000000000..0dbe88c8b3 --- /dev/null +++ b/dist/legacy-domain-redirect/install/wrangler.toml @@ -0,0 +1,16 @@ +# Updates the existing Worker `pgx-install` (route pgx.dev/install). It keeps +# `curl -fsSL https://pgx.dev/install | sh` installing the previous product's +# last release, also after PGBoxDB releases exist (see legacy-install-worker.js). +name = "pgx-install" +main = "legacy-install-worker.js" +compatibility_date = "2026-11-01" +workers_dev = false +routes = [ + { pattern = "pgx.dev/install", zone_name = "pgx.dev" }, +] + +[vars] +INSTALL_REF = "v0.1.3" +LEGACY_VERSION = "0.1.3" +# Same deadline as ../wrangler.toml: 410 Gone from this instant on. +REDIRECT_UNTIL = "2027-02-17T19:58:29Z" diff --git a/dist/legacy-domain-redirect/package.json b/dist/legacy-domain-redirect/package.json new file mode 100644 index 0000000000..8898b26241 --- /dev/null +++ b/dist/legacy-domain-redirect/package.json @@ -0,0 +1 @@ +{ "type": "module", "private": true } diff --git a/dist/legacy-domain-redirect/redirect-worker.js b/dist/legacy-domain-redirect/redirect-worker.js new file mode 100644 index 0000000000..bf1ee2f5c6 --- /dev/null +++ b/dist/legacy-domain-redirect/redirect-worker.js @@ -0,0 +1,57 @@ +// The previous domain, pgx.dev: every path is answered here (route pgx.dev/*). +// +// Until REDIRECT_UNTIL (the authorised 90-day transition): +// * 301 to https://pgboxdb.com, keeping the path where pgboxdb.com has the +// same page (else the home page) and always the query string, with a +// bounded Cache-Control so browsers re-check; +// * /install goes to the installer Worker through the INSTALLER service +// binding, so the shell script is never redirected to an HTML page, and no +// route ordering can send it anywhere else. +// From REDIRECT_UNTIL on, or if the deadline is missing or invalid: +// * 410 Gone for every path, /install included. The previous website is never +// served again (the Worker never forwards to the origin). + +const TARGET = "https://pgboxdb.com"; +// Paths that exist on both sites (checked 2026-11-19). +const SAME_PATH = new Set(["/", "/index.html", "/llms.txt", "/robots.txt"]); +const CACHE_SECONDS = 3600; + +export function redirectEnd(env) { + const t = Date.parse(env && env.REDIRECT_UNTIL); + return Number.isFinite(t) ? t : null; +} + +export function target(url) { + const path = SAME_PATH.has(url.pathname) ? url.pathname : "/"; + return TARGET + path + url.search; +} + +export function gone() { + return new Response("410 Gone\n", { + status: 410, + headers: { + "content-type": "text/plain; charset=utf-8", + "cache-control": `public, max-age=${CACHE_SECONDS}`, + }, + }); +} + +export default { + async fetch(request, env, _ctx, now = Date.now()) { + const url = new URL(request.url); + const end = redirectEnd(env); + if (end === null || now >= end) return gone(); + if (url.pathname === "/install") { + if (!env.INSTALLER) return gone(); + return env.INSTALLER.fetch(request); + } + return new Response(null, { + status: 301, + headers: { + location: target(url), + "cache-control": `public, max-age=${CACHE_SECONDS}`, + "x-redirect-until": new Date(end).toISOString(), + }, + }); + }, +}; diff --git a/dist/legacy-domain-redirect/redirect-worker.test.js b/dist/legacy-domain-redirect/redirect-worker.test.js new file mode 100644 index 0000000000..4fe8009be0 --- /dev/null +++ b/dist/legacy-domain-redirect/redirect-worker.test.js @@ -0,0 +1,80 @@ +// node --test dist/legacy-domain-redirect/redirect-worker.test.js +import { test } from "node:test"; +import assert from "node:assert/strict"; +import worker, { target } from "./redirect-worker.js"; + +const END = "2027-02-17T19:58:29Z"; +const before = Date.parse(END) - 1000; +const after = Date.parse(END); + +function installer() { + const calls = []; + return { + calls, + fetch: async (req) => { + calls.push(new URL(req.url).pathname); + return new Response("#!/bin/sh\n", { status: 200, headers: { "content-type": "text/x-shellscript" } }); + }, + }; +} +// Any fetch to the origin would expose the previous site: fail the test. +globalThis.fetch = async () => { + throw new Error("must never forward to the origin"); +}; +const run = (u, env, now = before) => worker.fetch(new Request(u), env, {}, now); +const env = () => ({ REDIRECT_UNTIL: END, INSTALLER: installer() }); + +test("home page: 301 to pgboxdb.com, query kept, bounded cache", async () => { + const r = await run("https://pgx.dev/?utm_source=x&a=1", env()); + assert.equal(r.status, 301); + assert.equal(r.headers.get("location"), "https://pgboxdb.com/?utm_source=x&a=1"); + assert.equal(r.headers.get("cache-control"), "public, max-age=3600"); + assert.equal(r.headers.get("x-redirect-until"), "2027-02-17T19:58:29.000Z"); +}); + +test("http is redirected to https on the new domain", async () => { + const r = await run("http://pgx.dev/llms.txt", env()); + assert.equal(r.headers.get("location"), "https://pgboxdb.com/llms.txt"); +}); + +test("paths that exist on both sites are kept, others go home", () => { + for (const p of ["/", "/index.html", "/llms.txt", "/robots.txt"]) { + assert.equal(target(new URL("https://pgx.dev" + p)), "https://pgboxdb.com" + p); + } + assert.equal(target(new URL("https://pgx.dev/docs/x?q=1")), "https://pgboxdb.com/?q=1"); +}); + +test("/install goes to the installer Worker (service binding), never redirected", async () => { + const e = env(); + const r = await run("https://pgx.dev/install", e); + assert.equal(r.status, 200); + assert.match(r.headers.get("content-type"), /shellscript/); + assert.deepEqual(e.INSTALLER.calls, ["/install"]); +}); + +test("/install/ and other near misses are redirected, not served from the origin", async () => { + const r = await run("https://pgx.dev/install/", env()); + assert.equal(r.status, 301); +}); + +test("at and after the deadline: 410 for every path, /install included", async () => { + const e = env(); + for (const p of ["/", "/llms.txt", "/install", "/anything?x=1"]) { + const r = await run("https://pgx.dev" + p, e, after); + assert.equal(r.status, 410, p); + assert.equal(await r.text(), "410 Gone\n"); + } + assert.equal(e.INSTALLER.calls.length, 0); +}); + +test("missing or invalid deadline, or missing binding: 410, never the old site", async () => { + assert.equal((await run("https://pgx.dev/", {})).status, 410); + assert.equal((await run("https://pgx.dev/", { REDIRECT_UNTIL: "soon" })).status, 410); + assert.equal((await run("https://pgx.dev/install", { REDIRECT_UNTIL: END })).status, 410); +}); + +test("redirect target never points back at pgx.dev (no loop)", () => { + for (const p of ["/", "/a", "/install-x", "//pgx.dev/"]) { + assert.equal(new URL(target(new URL("https://pgx.dev" + p))).host, "pgboxdb.com"); + } +}); diff --git a/dist/legacy-domain-redirect/wrangler.toml b/dist/legacy-domain-redirect/wrangler.toml new file mode 100644 index 0000000000..7272e3b91c --- /dev/null +++ b/dist/legacy-domain-redirect/wrangler.toml @@ -0,0 +1,24 @@ +# Transition redirect https://pgx.dev/* → https://pgboxdb.com/* (301). +# Authorised for at most 90 days. From REDIRECT_UNTIL on it answers 410 Gone for +# every path. KEEP it deployed after that: deleting it would bring the previous +# site back. Never moves, releases or deletes the domain. +name = "pgx-dev-redirect" +main = "redirect-worker.js" +compatibility_date = "2026-11-01" +workers_dev = false + +# pgx.dev/install has its own, more specific route (Worker pgx-install), and /install +# is also handed to it through the INSTALLER binding below: never redirected. +routes = [ + { pattern = "pgx.dev/*", zone_name = "pgx.dev" }, +] + +# /install is answered by the installer Worker through this binding, so the +# script is served whichever route matches first. +services = [ + { binding = "INSTALLER", service = "pgx-install" }, +] + +[vars] +# Prepared at 2026-11-19T19:58:29Z; activation + 90 days at the latest. +REDIRECT_UNTIL = "2027-02-17T19:58:29Z" diff --git a/dist/npm/README.md b/dist/npm/README.md index 85a10266b9..6b8540fc38 100644 --- a/dist/npm/README.md +++ b/dist/npm/README.md @@ -13,8 +13,8 @@ a default `app` database and prints its connection URL: ```console $ npx pgboxdb@latest -pgboxdb: downloading PGBoxDB 0.1.0 (darwin-arm64) from https://github.com/pgrundev/pgboxdb/releases/download/v0.1.0/pgboxdb-0.1.0-darwin-arm64.tar.gz -pgboxdb: installed PGBoxDB 0.1.0 to /Users/you/.pgboxdb/dist/0.1.0 +pgboxdb: downloading PGBoxDB 0.2.0 (darwin-arm64) from https://github.com/pgrundev/pgboxdb/releases/download/v0.2.0/pgboxdb-0.2.0-darwin-arm64.tar.gz +pgboxdb: installed PGBoxDB 0.2.0 to /Users/you/.pgboxdb/dist/0.2.0 PGBoxDB is ready. postgres://postgres:…@127.0.0.1:5432/app @@ -42,7 +42,7 @@ npx pgboxdb --json ls # machine-readable (for agents) npx pgboxdb stop ``` -`npm install -g pgboxdb` puts both `pgboxdb` and `pgboxdb` on your PATH. +`npm install -g pgboxdb` puts `pgboxdb` on your PATH. ## How it works diff --git a/dist/npm/package.json b/dist/npm/package.json index ced474844c..b34b9fd4a9 100644 --- a/dist/npm/package.json +++ b/dist/npm/package.json @@ -1,6 +1,6 @@ { "name": "pgboxdb", - "version": "0.1.3", + "version": "0.2.0", "description": "PGBoxDB: a lightweight Postgres-compatible database runtime for AI agents. `npx pgboxdb` installs the native binary and starts a local, disposable database.", "license": "AGPL-3.0", "repository": { diff --git a/dist/release-notes.md b/dist/release-notes.md index 919cd4db7b..9989facda0 100644 --- a/dist/release-notes.md +++ b/dist/release-notes.md @@ -3,11 +3,7 @@ A self-contained, relocatable, PostgreSQL 18 compatible runtime for local development, CI and disposable databases. No system PostgreSQL required. -## PGBoxDB vNEXT — the first release under the PGBoxDB name - - +## PGBoxDB v0.2.0 — the first release under the PGBoxDB name This runtime is now **PGBoxDB**: a lightweight Postgres-compatible database runtime for AI agents. Home: https://pgboxdb.com · documentation: @@ -33,6 +29,12 @@ pgboxdb --version as aliases; they are reported, and `pgboxdb agent install`, `pgboxdb git init` and `pgboxdb git install-shell` replace the previous entries in place. Guide: docs/pgboxdb/local-dev/upgrading.md. +- **New: `pgboxdb top`**, a read-only live terminal monitor of the local + runtime: every database grouped by project, Git branch and agent session, + with connections, TTL countdowns, lifecycle and size, refreshed every + second. `pgboxdb top --demo` shows a simulated session without a runtime, + and `pgboxdb --json top --snapshot` gives one collection as JSON. Guide: + docs/pgboxdb/local-dev/top.md. - **Docker:** the image runs as user `pgboxdb` (uid 10001, unchanged) with its volume at `/var/lib/pgboxdb`. A volume from the previous image works when mounted there. diff --git a/dist/test/dist_consistency_test.sh b/dist/test/dist_consistency_test.sh index 167e5b1f09..5c8871f9c2 100755 --- a/dist/test/dist_consistency_test.sh +++ b/dist/test/dist_consistency_test.sh @@ -96,5 +96,8 @@ crate="$(sed -n 's/^version *= *"\(.*\)"/\1/p' crates/bin/pgboxdb/Cargo.toml | h npm="$(sed -n 's/^ *"version": *"\(.*\)",*$/\1/p' dist/npm/package.json | head -1)" [ "$crate" = "$npm" ] && ok "crate and npm versions agree ($crate)" || bad "crate $crate vs npm $npm" +# 10. The Worker serves the installer of the version being released. +[ "$ref" = "v$crate" ] && ok "Worker INSTALL_REF is v$crate" || bad "Worker INSTALL_REF $ref is not v$crate (bump it with the version)" + echo "$((N - FAILS))/$N checks passed" [ "$FAILS" -eq 0 ] diff --git a/docs/pgboxdb/local-dev/agents.md b/docs/pgboxdb/local-dev/agents.md index ddd2a99558..f21a257d3d 100644 --- a/docs/pgboxdb/local-dev/agents.md +++ b/docs/pgboxdb/local-dev/agents.md @@ -36,15 +36,15 @@ the Skill is activated and the host's permissions allow it. ## Versions -`pgboxdb agent` and the Skill need **PGBoxDB 0.1.2 or newer** -([release](https://github.com/pgrundev/pgboxdb/releases/tag/v0.1.2): linux-amd64, -linux-arm64, darwin-arm64 with SHA-256 checksums). 0.1.2 is the first -release in which Claude Code subagents get their own branches: 0.1.1 -isolated sessions but let subagents share the parent's branch, and the -published 0.1.0 has no `pgboxdb agent`. The Skill's `scripts/check-pgboxdb.sh` -verifies the installed binary from `pgboxdb --json version` and refuses older -ones with a hint naming what they lack. npm `pgboxdb@0.1.2` follows the GitHub -release through the repository's staged publishing process. +`pgboxdb agent` and the Skill need **PGBoxDB 0.2.0 or newer** +([release](https://github.com/pgrundev/pgboxdb/releases/tag/v0.2.0): linux-amd64, +linux-arm64, darwin-arm64 with SHA-256 checksums), the first release under +the PGBoxDB name. It includes per-session branches, separate branches for +Claude Code subagents, and the Git integration. The Skill's +`scripts/check-pgboxdb.sh` verifies the installed binary from +`pgboxdb --json version` and refuses older ones with a hint naming what they +lack. npm `pgboxdb@0.2.0` follows the GitHub release through the +repository's staged publishing process. ## What you get diff --git a/docs/pgboxdb/local-dev/claude-plugin.md b/docs/pgboxdb/local-dev/claude-plugin.md index 5cc1d27ee5..6b6b697214 100644 --- a/docs/pgboxdb/local-dev/claude-plugin.md +++ b/docs/pgboxdb/local-dev/claude-plugin.md @@ -66,7 +66,7 @@ Then, in a project with a database: `pgboxdb:pgboxdb` is the skill's name under the plugin's namespace. You can also just describe database work ("add a column and run the tests"); Claude selects the skill when it is relevant. Both routes run the same Skill: detect the -project, check for PGBoxDB 0.1.2 or newer and offer to install it, prepare a +project, check for PGBoxDB 0.2.0 or newer and offer to install it, prepare a schema-only template, `pgboxdb agent setup`, then work inside the session's branch. See [agents.md](agents.md) for what that gives you. diff --git a/docs/pgboxdb/local-dev/git.md b/docs/pgboxdb/local-dev/git.md index 1534e74da4..1dda994d4d 100644 --- a/docs/pgboxdb/local-dev/git.md +++ b/docs/pgboxdb/local-dev/git.md @@ -4,7 +4,7 @@ plain `git switch`; PGBoxDB clones a copy-on-write database for each new branch from the latest validated snapshot of your main database, gives it back when you return to the branch, and never touches a branch database when main moves -on. PGBoxDB Git needs **PGBoxDB 0.1.3 or newer**. +on. PGBoxDB Git is in every PGBoxDB release (0.2.0 or newer). ```sh cd my-project diff --git a/docs/pgboxdb/local-dev/install.md b/docs/pgboxdb/local-dev/install.md index 60d4800f06..4d545e452a 100644 --- a/docs/pgboxdb/local-dev/install.md +++ b/docs/pgboxdb/local-dev/install.md @@ -21,8 +21,8 @@ runs start in well under a second. `pgboxdb@X.Y.Z` installs PGBoxDB `X.Y.Z`, so `@latest` is the latest PGBoxDB release. `PGBOXDB_VERSION`, `PGBOXDB_INSTALL_DIR` and `PGBOXDB_BASE_URL` override the version, -cache directory and download base. `npm install -g pgboxdb` provides both -`pgboxdb` and `pgboxdb` on your PATH. Node.js 18+ is required. Supported: Apple +cache directory and download base. `npm install -g pgboxdb` puts +`pgboxdb` on your PATH. Node.js 18+ is required. Supported: Apple silicon Macs and Linux (arm64, x86-64); Intel Macs and Windows are not supported (see the platform table below). diff --git a/docs/pgboxdb/local-dev/top.md b/docs/pgboxdb/local-dev/top.md index f2341d4af0..a0fe0d92cf 100644 --- a/docs/pgboxdb/local-dev/top.md +++ b/docs/pgboxdb/local-dev/top.md @@ -22,7 +22,7 @@ simulated**, which the `DEMO / SIMULATED` badge says; real mode never shows that badge. ```text - PGBoxDB TOP DEMO / SIMULATED ● LIVE 1s PGBoxDB 0.1.3 + PGBoxDB TOP DEMO / SIMULATED ● LIVE 1s PGBoxDB 0.2.0 Runtime: RUNNING PID 73136 Port 5433 Uptime 00:42:59 MEM [█░░░░░░░░░░░░░░░░░░░░░░░░] 194 MB RSS (whole runtime) CPU n/a DATABASES 6 AGENT DBS 5 SESSIONS 1 CONNS 7 ISSUES 0 sort:name tree @@ -193,7 +193,7 @@ One object, the same collector and model the screen uses: "mode": "live", "simulated": false, "collected_at": "2026-11-11T20:00:00Z", - "pgboxdb_version": "0.1.3", + "pgboxdb_version": "0.2.0", "runtime": {"status": "running", "running": true, "pid": 1234, "port": 5433, "uptime_seconds": 2538, "rss_bytes": 201326592, "rss_scope": "whole runtime process", "cpu_percent": null, diff --git a/plugins/pgboxdb/.claude-plugin/plugin.json b/plugins/pgboxdb/.claude-plugin/plugin.json index da2dc3780d..6ecad9825a 100644 --- a/plugins/pgboxdb/.claude-plugin/plugin.json +++ b/plugins/pgboxdb/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "pgboxdb", "displayName": "PGBoxDB — Postgres for Agents", - "version": "0.1.3", + "version": "0.2.0", "description": "Isolated, disposable PostgreSQL-compatible databases for AI coding agents.", "author": { "name": "PGRunDev", diff --git a/plugins/pgboxdb/README.md b/plugins/pgboxdb/README.md index c5b8b07952..d0dc36c41a 100644 --- a/plugins/pgboxdb/README.md +++ b/plugins/pgboxdb/README.md @@ -10,7 +10,7 @@ your project's database, so parallel agents, migrations and test runs never touch your real PostgreSQL and never overwrite one another. The plugin contains instructions and integration logic only. The PGBoxDB database -runtime (the `pgboxdb` binary, **PGBoxDB 0.1.2 or newer**) is installed separately, +runtime (the `pgboxdb` binary, **PGBoxDB 0.2.0 or newer**) is installed separately, and a project still needs a one-time `pgboxdb agent setup` before its sessions are isolated. Both steps are walked through by the skill the first time you use it in a project. diff --git a/plugins/pgboxdb/skills/pgboxdb/SKILL.md b/plugins/pgboxdb/skills/pgboxdb/SKILL.md index 4d5da0e65b..af7189a385 100644 --- a/plugins/pgboxdb/skills/pgboxdb/SKILL.md +++ b/plugins/pgboxdb/skills/pgboxdb/SKILL.md @@ -14,7 +14,7 @@ description: > license: AGPL-3.0 metadata: author: pgrundev - version: "0.1.3" + version: "0.2.0" homepage: https://pgboxdb.com repository: https://github.com/pgrundev/pgboxdb --- @@ -95,9 +95,9 @@ PGBoxDB database), `none` (no database yet), `remote` (another host), ### 2. Make sure PGBoxDB is available -PGBoxDB **0.1.2 or newer** is required. 0.1.1 isolates sessions but not Claude -Code subagents (they shared the parent's branch); 0.1.0 has no `pgboxdb agent` -at all. Run the check script next to this file: +PGBoxDB **0.2.0 or newer** is required: 0.2.0 is the first release under the +PGBoxDB name, and every PGBoxDB release isolates sessions, Claude Code +subagents and Git branches. Run the check script next to this file: ```sh bash .claude/skills/pgboxdb/scripts/check-pgboxdb.sh # or .agents/skills/pgboxdb/scripts/check-pgboxdb.sh, diff --git a/plugins/pgboxdb/skills/pgboxdb/references/git-integration.md b/plugins/pgboxdb/skills/pgboxdb/references/git-integration.md index cd06f5a634..ab621ac57f 100644 --- a/plugins/pgboxdb/skills/pgboxdb/references/git-integration.md +++ b/plugins/pgboxdb/skills/pgboxdb/references/git-integration.md @@ -13,9 +13,8 @@ feature/auth ─ pgboxdb__auth_ the developer's branch database ## Version -`pgboxdb git` needs **PGBoxDB 0.1.3 or newer**. On 0.1.2 `pgboxdb git` is an unknown -command (exit 2); the agent features (`pgboxdb agent …`) still work there, so -only offer PGBoxDB Git after `pgboxdb --json version` reports 0.1.3 or newer. +`pgboxdb git` is in every PGBoxDB release (0.2.0 or newer, the same floor as +the rest of this skill: `scripts/check-pgboxdb.sh`). ## Detect diff --git a/plugins/pgboxdb/skills/pgboxdb/references/installation.md b/plugins/pgboxdb/skills/pgboxdb/references/installation.md index 14347f02b6..9c1f2bc976 100644 --- a/plugins/pgboxdb/skills/pgboxdb/references/installation.md +++ b/plugins/pgboxdb/skills/pgboxdb/references/installation.md @@ -7,18 +7,17 @@ command -v pgboxdb && pgboxdb --json version # {"pgboxdb_version":"0.1.x", pgboxdb --json status # exit 3 when initialised but stopped; hooks start it on demand ``` -The skill needs **PGBoxDB 0.1.2 or newer** -(https://github.com/pgrundev/pgboxdb/releases/tag/v0.1.2): the first release -in which Claude Code subagents get their own branches (0.1.1 isolated -sessions only and let subagents share the parent's branch; 0.1.0 has no -`pgboxdb agent` command group). +The skill needs **PGBoxDB 0.2.0 or newer** +(https://github.com/pgrundev/pgboxdb/releases/tag/v0.2.0): the first release +under the PGBoxDB name. Every PGBoxDB release has `pgboxdb agent` (sessions +and Claude Code subagents get their own branches) and `pgboxdb git`. `scripts/check-pgboxdb.sh` decides: exit 0 compatible, 3 missing, 2 too old, 4 malformed, always with one JSON line. It compares `pgboxdb --json version` → `pgboxdb_version` as semver (`PGBOXDB_MIN_VERSION` overrides the floor). Do not use `pgboxdb agent --help` as the test: `--help` prints the global help on every version. An older binary: upgrade with the method it was installed with (`npm i -g pgboxdb@latest`, or the installer again) and run the check again; -if the upgrade still reports 0.1.0, the newer package is not yet on that +if the upgrade still reports an older version, the newer package is not yet on that channel and the user should install from the GitHub release. ## Install, in order of preference @@ -27,7 +26,7 @@ channel and the user should install from the GitHub release. `~/.local/bin/pgboxdb`, Homebrew, or `~/.pgboxdb/dist//bin/pgboxdb`). Prefer it; do not download twice. 2. **npm**, when Node.js 18+ is present: `npm i -g pgboxdb` installs the - `pgboxdb` and `pgboxdb` commands; the first run downloads the native release + `pgboxdb` command; the first run downloads the native release tarball into `~/.pgboxdb/dist/`. `npx pgboxdb@latest` works without a global install but gives you `npx pgboxdb …` instead of `pgboxdb …`. 3. **The official installer**: `curl -fsSL https://pgboxdb.com/install | sh`. diff --git a/plugins/pgboxdb/skills/pgboxdb/references/troubleshooting.md b/plugins/pgboxdb/skills/pgboxdb/references/troubleshooting.md index 6a83d7c305..47ec5fcce2 100644 --- a/plugins/pgboxdb/skills/pgboxdb/references/troubleshooting.md +++ b/plugins/pgboxdb/skills/pgboxdb/references/troubleshooting.md @@ -23,7 +23,7 @@ Start with `pgboxdb agent doctor` (project state, this session) and `pgboxdb doc | Codex commands cannot connect, `CODEX_SANDBOX_NETWORK_DISABLED=1` | Sandbox blocks loopback. | `sandbox_workspace_write.network_access = true` (user's decision). | | Rails created `agent-…-0/1/2` databases | Parallel tests. | Harmless; `PARALLEL_WORKERS=1` or `pgboxdb drop` them. | | `ActiveRecord::EnvironmentMismatchError` after a green test run | The branch's `ar_internal_metadata` says `development`; Rails' `db:test:prepare` refuses to purge it. | Harmless; ignore. Never `db:environment:set` inside a branch. | -| Rails re-ran every migration on a fresh branch and failed on an existing table | The template was imported schema-only with an older `pgboxdb copy` that dropped `schema_migrations` rows. | Re-import with PGBoxDB 0.1.1 or newer (its `--schema-only` keeps migration bookkeeping) or insert the rows into the template once. | +| Rails re-ran every migration on a fresh branch and failed on an existing table | The template was imported schema-only with an older `pgboxdb copy` that dropped `schema_migrations` rows. | Re-import with any PGBoxDB release (its `--schema-only` keeps migration bookkeeping) or insert the rows into the template once. | | Port conflict on first run | Another service on the chosen port. | `pgboxdb doctor`; `PGBOXDB_PORT= pgboxdb run` on a fresh home only; never `init --force`. | Logs: `~/.pgboxdb/log/` (runtime and supervisor); `~/.pgboxdb/agent/hooks.log` (one diff --git a/plugins/pgboxdb/skills/pgboxdb/scripts/check-pgboxdb.sh b/plugins/pgboxdb/skills/pgboxdb/scripts/check-pgboxdb.sh index 9e3a0f0f5c..5a4a4a0717 100755 --- a/plugins/pgboxdb/skills/pgboxdb/scripts/check-pgboxdb.sh +++ b/plugins/pgboxdb/skills/pgboxdb/scripts/check-pgboxdb.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # check-pgboxdb.sh: is a compatible PGBoxDB on PATH? Prints one JSON object and exits -# 0 compatible (version >= MIN) {"ok":true,"version":"0.1.2","path":"…"} +# 0 compatible (version >= MIN) {"ok":true,"version":"0.2.0","path":"…"} # 3 pgboxdb not found {"ok":false,"reason":"missing",…} -# 2 too old {"ok":false,"reason":"too_old","version":"0.1.1",…} +# 2 too old {"ok":false,"reason":"too_old","version":"0.1.9",…} # 4 unreadable version output {"ok":false,"reason":"malformed",…} # `pgboxdb agent --help` exits 0 on every PGBoxDB version (global help), so only the # structured `pgboxdb --json version` output counts. set -u -MIN=${PGBOXDB_MIN_VERSION:-0.1.2} +MIN=${PGBOXDB_MIN_VERSION:-0.2.0} esc() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; } path=$(command -v pgboxdb 2>/dev/null || true) if [ -z "$path" ]; then @@ -28,12 +28,7 @@ vcmp() { # returns 0 if $1 >= $2 if vcmp "$ver" "$MIN"; then printf '{"ok":true,"version":"%s","path":"%s","min":"%s"}\n' "$ver" "$(esc "$path")" "$MIN"; exit 0 fi -# Too old. Say what the installed version lacks: 0.1.1 isolated sessions but -# let Claude Code subagents share the parent's branch; anything older has no -# `pgboxdb agent` at all. Either way: upgrade, do not run database work. -if vcmp "$ver" "0.1.1"; then - why="PGBoxDB $ver isolates sessions only: Claude Code subagents would share the parent's branch" -else - why="PGBoxDB $ver has no pgboxdb agent" -fi +# Too old: 0.2.0 is the first PGBoxDB release, so an older `pgboxdb` is a +# development or CI build. Upgrade; do not run database work with it. +why="PGBoxDB $ver predates 0.2.0, the first PGBoxDB release" printf '{"ok":false,"reason":"too_old","version":"%s","path":"%s","min":"%s","hint":"%s; upgrade to %s or newer with the method it was installed with (npm i -g pgboxdb@latest, or the installer again)"}\n' "$ver" "$(esc "$path")" "$MIN" "$why" "$MIN"; exit 2 diff --git a/reports/PGBOXDB_BRANDING_AUDIT.md b/reports/PGBOXDB_BRANDING_AUDIT.md new file mode 100644 index 0000000000..3b6329dd17 --- /dev/null +++ b/reports/PGBOXDB_BRANDING_AUDIT.md @@ -0,0 +1,86 @@ +# PGBoxDB branding audit (before v0.2.0) + +Date: 2026-11-19. The official brand is **PGBoxDB**: CLI and npm `pgboxdb`, +env `PGBOXDB_*`, repository `pgrundev/pgboxdb`, site `pgboxdb.com`, docs +`pgbox.dev/db`. + +Searched: `release/v0.2.0` (every tracked file, case-insensitive `pgx`, +`pgxdb`, `pgx.dev` and `pgbox` not followed by `db`, plus wrong-cased brand +variants); the CLI's `--version` and `--help` output; the 0.2.0 release +artifacts; GitHub metadata of both repositories, their releases and the org; +the npm registry; the live `pgboxdb.com` and `pgx.dev`. + +## Fixed in this audit + +| Where | Was | Now | +|---|---|---| +| GitHub `pgrundev/pgboxdb` description | "PGBox — Lightweight Postgres…" | "PGBoxDB — Lightweight Postgres…" | +| GitHub `pgrundev/pgboxdb-plugin` | no description or homepage | PGBoxDB description, `https://pgboxdb.com`, topics | +| Docs, Skill, plugin README, npm README, `install.sh` example | version floors 0.1.x (only ever shipped as PGX); "`pgboxdb` and `pgboxdb`" (a leftover of "`pgx` and `pgxdb`"); 0.1.0 samples | 0.2.0; one command; 0.2.0 samples (`4cef79193a`) | + +## Clean (no change needed) + +* **CLI**: `--version` and every `--help` print PGBoxDB/`pgboxdb` only; the + upper-case hits are `PGBOXDB_*` variables. +* **Release artifacts (0.2.0 rehearsal, run 44603543571)**: the asset names are + `pgboxdb-0.2.0-.tar.gz`. Each holds `bin/pgboxdb` and + `share/pgboxdb/dist.json` (`pgboxdb_version`), with no `pgx` paths. The + release title will be "PGBoxDB v0.2.0" (`release.yml`). +* **npm `pgboxdb`**: name, bin, description, repository, homepage, bugs and + README are all PGBoxDB. Not yet published (the registry answers 404). +* **Installer, Worker `pgboxdb.com/install`, Docker** (user `pgboxdb`, + `/opt/pgboxdb`, `PGBOXDB_*`), **workflows, Skill, plugin package**: checked by + `dist/test/dist_consistency_test.sh` in CI. +* **Repository site source** `dist/pgboxdb.com/site/`: titled "PGBoxDB — …". +* **GitHub org** `pgrundev` ("PGRun"): no product name. + +## Remaining references, and why they stay + +### 1. History (preserved by decision) + +* GitHub releases `v0.1.0-beta.1`, "PGX v0.1.0" … "PGX v0.1.3", and the + "Earlier releases (as PGX)" section of `dist/release-notes.md`. +* Git history and tags, including the PGRun production engine tag + `pgx-v0.1-beta.1`, which is immutable and referenced by PGRun. +* Dated records: `docs/**/validation/**`, `docs/superpowers/**`, + `benchmarks/**/results/**`, `reports/**`. + +### 2. Compatibility during the approved migration + +* Detection of an installation from before the rename, which is never an + alias: `crates/bin/pgboxdb/src/legacy.rs`, `pgboxdb migrate` + (`~/.pgx`, `.pgx.toml`, `PGX_*`), `share/pgx/dist.json` in `install.sh` + and the npm wrapper, `/var/run/pgx` in the Docker entrypoint, replacement + of old `pgx agent hook` / `pgx git` hook blocks, and their tests. + `docs/pgboxdb/local-dev/upgrading.md` explains these. +* GitHub's automatic redirects from `pgrundev/pgx` and `pgrundev/pgx-plugin` + (option A). +* `pgx.dev`: a 301 to `pgboxdb.com`, while `/install` keeps serving the PGX + 0.1.3 installer for existing instructions. Both answer 410 from + 2027-02-17 19:58:29 UTC (`dist/legacy-domain-redirect/`). + +### 3. Technical identifiers, not branding + +* The Go driver `jackc/pgx` (docs, test app, Skill detection). +* PostgreSQL's SP-GiST box opclass `spgbox` (engine, fuzzers), and the engine's + Rust type `PgBox` (a memory-context `Box`). +* PGRun production names: `pgx-agent`, Go package `pgxdb`, `/opt/pgx`, + `script/pgx/`, `PGX_ENGINE_SHA`, `PGX_BINARY_SHA256` (out of scope by rule). +* Lab infrastructure: the ZFS dataset `tank/pgx-bench`, `PGXBENCH_WORKDIR`. +* The Cloudflare Worker names `pgx-install` and `pgx-dev-redirect` belong to the + `pgx.dev` zone and are not shown to users. +* npm `pgxdb` (PGX, latest 0.1.3): it stays published and unchanged pending + legal review, and no new version is published under it. + +## Requires manual action + +| # | Item | Why I could not or should not do it | Severity | +|---|---|---|---| +| M1 | **`pgbox.dev` is not registered** (the `.dev` registry RDAP answers 404). The README links the docs to `pgbox.dev/db`, and the live `pgboxdb.com/llms.txt` tells agents to run `curl -fsSL https://pgbox.dev/install \| sh`. Whoever registers the domain controls that script. | Registering a domain is an account action | **Blocker**: register `pgbox.dev` now, or remove every `pgbox.dev` reference | +| M2 | **The live `pgboxdb.com` is branded "PGBOX"** (22× on the page, all of `llms.txt`), and `llms.txt` gives wrong commands: `pgbox run`, `--skill pgbox`, `/plugin install pgbox@pgbox-plugin`, `PGBOX_PASSWORD`, `docker build -t pgbox`. `pgx.dev` now redirects there. | Its source is not in this repository, and I couldn't find the Worker that serves it. Replacing a live site needs your approval | **Blocker** for the announcement: fix its source, or deploy `dist/pgboxdb.com/site` (PGBoxDB-branded) instead | +| M3 | `pgrundev/pgboxdb-plugin` still contains the PGX plugin (README "PGX — Postgres for Agents", `pgx@pgx-plugin`). | Syncing before `pgboxdb` is on npm would break new installs. It needs a plugin-sync secret (runbook step 9) | Right after the npm publish | +| M4 | The npm name `pgbox` belongs to a third party (created 2026-03-20, "PostgreSQL emulator"). Using "PGBox" anywhere invites confusion with it. | A legal and brand matter | Note for legal | +| M5 | PGRun PR pgrundev/pgrun#49 (GitHub and site links → PGBoxDB) | Merging and deploying PGRun needs your approval | Before 2027-02-17 | +| M6 | The old site is still deployed as the Cloudflare Worker `pgx`. It is unreachable while the `pgx.dev/*` route exists. | Removing its domain or route is a separate approval | After the transition | +| M7 | The repository's social-preview image can't be read through the API. | Check it in Settings → Social preview | Check | +| M8 | npm `pgxdb`: optionally `npm deprecate pgxdb "renamed to pgboxdb"` after 0.2.0 | Needs your approval (and legal) | Optional | diff --git a/reports/PGBOXDB_RELEASE_CHECKLIST.md b/reports/PGBOXDB_RELEASE_CHECKLIST.md index c6ee69bdb2..2818e6f3ca 100644 --- a/reports/PGBOXDB_RELEASE_CHECKLIST.md +++ b/reports/PGBOXDB_RELEASE_CHECKLIST.md @@ -1,128 +1,130 @@ # PGBoxDB v0.2.0: final release checklist -Everything under "Requires approval" is an external or irreversible action. -None of it was performed, and each item needs its own explicit go-ahead. +Updated 2026-11-17. Exact commands: `PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md`. Readiness and risks: `PGBOXDB_V0.2.0_READINESS.md`. -## Done locally (not pushed) - -Branch `rebrand/pgboxdb` (base `pgx/main` `56177328d7`): - -- [x] Rename implemented: crate, binary, npm package, env, paths, docs, Skill, - plugin, workflows, Docker, installer, Worker (`PGBOXDB_RENAME_AUDIT.md`) -- [x] Compatibility layer and `pgboxdb migrate` with rollback - (`PGBOXDB_COMPATIBILITY_MATRIX.md`); trailing project-file comments - converted too (`66e5b67e37`) -- [x] **`release.yml` asset-wipe bug fixed** (`3891435c18`). The draft job - checks out before downloading, `dist/release/collect.sh` requires and - verifies every asset, `fail_on_unmatched_files` is set, and the - version is resolved once and must match crate and npm. The - dispatch-run bug (version `main`) is fixed too. -- [x] **Regression coverage**: `dist/test/release_workflow_test.rb` - replays the draft job, fails on the old workflow, and runs in CI - (`release-workflow` job) -- [x] **One-name consistency** across npm, release assets, installer, - Worker and Docker: `dist/test/dist_consistency_test.sh` (in CI). The - Worker is pinned to `v0.2.0` (`130d8a56ba`). -- [x] **Crash test harness** false failure fixed (`a24f804b33`) -- [x] **PGRun dev change prepared**: `reports/pgrun-dev/` (before/after - files and a tested `apply.sh` with rollback). No PGRun repository - change is needed. -- [x] **`PGX_AGENT_TOKEN` investigated**: not in git, in an ignored `0600` - file. Rotation is optional, and the procedure is in PGRun migration §F. -- [x] Local test matrix green on macOS arm64 (`PGBOXDB_TEST_REPORT.md` §2, §7) - -Branch `release/v0.2.0` (`5fbbfd079f`, on top of `130d8a56ba`): - -- [x] Version 0.2.0 in crate, `Cargo.lock`, npm, plugin, Skill and README; - release notes `v0.2.0` (with `pgboxdb top`); Skill floor 0.2.0. - Tested: unit, lifecycle, databases, clone, agent_install, git, - Skill e2e and unit, plugin, npm, and the consistency test (42/42) - against an assembled 0.2.0 distribution. - -## Decisions - -- [ ] **Legal review** of the remaining uses of the previous name - (compatibility matrix, "Legal review" items 1–6) -- [x] Release notes: v0.1.x kept as published (PGX), under "Earlier releases - (as PGX)"; PGBoxDB starts at v0.2.0 (`1fc2afb8b5`) -- [x] npm `pgxdb` and pgx.dev: unchanged, pending legal review -- [x] `PGX_AGENT_TOKEN` rotation: a separate production maintenance task -- [ ] `SECURITY.md` / issue templates for the public launch (they need a - reporting contact) - -## CI validation (done, 2026-11-17) - -- [x] `rebrand/pgboxdb` pushed; draft PR #50. CI run 44017542703 green: - Linux amd64 and arm64, macOS, Docker amd64 and arm64, npm, Worker, - Skill, plugin, release-workflow -- [x] Release workflow on GitHub: run 44017561323 (`workflow_dispatch`). - All 4 builds passed with packaged tests; `draft-dry-run` listed - exactly 7 files; no release or tag was created -- [x] `release/v0.2.0` contains every rebrand commit (merge, local) - -**The exact release commands are in `PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md`.** +## Done + +- [x] Rebrand, compatibility layer, `pgboxdb migrate`, release-workflow fix + and regression test, consistency test, crash-test fix, PGRun dev + change, reports (`rebrand/pgboxdb`) +- [x] CI green on the final head `c8d3551a70` (run 44025347562): Linux + amd64 and arm64, macOS, Docker amd64 and arm64, npm, Worker, Skill, + plugin, `release-workflow` +- [x] Release workflow verified on GitHub as a dry run (run 44017561323): + 7 files, no release, no tag +- [x] **PR #50 merged** (approved 2026-11-17): `pgx/main` = `75112dad28`, a + merge commit, so the GitHub history is preserved +- [x] `release/v0.2.0` brought up to date with `pgx/main` (merge, local, not + pushed). Its diff against `main` is only the version bump (19 files) + plus 3 report files (checklist, runbook, PR body) and one test fix +- [x] **CI on `main` after the merge** (run 44034607732): every job green + except Linux arm64, which hit a test-harness flake. One lifecycle test + spawned the binary without the harness retry and got ETXTBSY ("Text + file busy"); the same tree passed on the PR. The failed job was re-run, + and `5a6db56443` on `release/v0.2.0` routes the three affected tests + through the retrying spawn (lifecycle 27/27 locally) +- [x] Re-tested on `release/v0.2.0`: release replay 31/31, consistency 42/42, + `version.sh push v0.2.0` → `0.2.0`, npm 22/22, Skill suite +- [x] **`npm-publish` environment**: 1 required reviewer (`alexshapalov`). + `publish` is the only job that uses it, and it runs only in + `pgrundev/pgboxdb`. See "Open points" for the branch policy +- [x] **Repository references**: every workflow, the installer, the npm + wrapper, the Worker, the Docker files, the Skill and the plugin + reference `pgrundev/pgboxdb` (or `pgrundev/pgboxdb-plugin`). The old + slug remains only in history: the v0.1.x release notes (kept as + published), dated validation logs and plans, and these reports +- [x] Historical release notes preserved as "Earlier releases (as PGX)" + +## Legal decision on GitHub's redirects: option A chosen (2026-11-19) + +Renaming `pgrundev/pgx` → `pgrundev/pgboxdb` keeps the history, the 718 +stars, 37 forks, issues, PRs and releases. GitHub then redirects every old +URL (web, `git clone`, release downloads, raw files) to the new name, with +no expiry. Only creating a new repository named `pgrundev/pgx` ends the +redirect. Facts that bear on the decision: + +* **What depends on the redirect today:** + * npm `pgxdb@0.1.3` downloads from `github.com/pgrundev/pgx/releases`; + * the live pgx.dev Worker serves `raw.githubusercontent.com/pgrundev/pgx/…/install.sh`; + * PGRun's dev `engine.pin` clones `git@github.com:pgrundev/pgx.git`; + * existing clones and the Claude Code marketplace `pgrundev/pgx-plugin`. +* **The options:** + * **A. Rename and keep the redirects** (the runbook's plan). Nothing + breaks. The old name keeps resolving to PGBoxDB on github.com. + * **B. Rename, then end the redirects** by creating placeholder + repositories `pgrundev/pgx` and `pgrundev/pgx-plugin`, with an empty + README or a notice. Everything in the list above breaks: `pgxdb` and + pgx.dev installs fail, and old clones point at the placeholder. Do it + only together with deprecating `pgxdb` and retiring pgx.dev, which are + currently held for legal. + * **C. Do not rename.** Create `pgrundev/pgboxdb` fresh and push the full + git history to it. The commits and tags are preserved; the issues, PRs, + stars and releases stay on `pgrundev/pgx`. No redirect exists. +* **Repository settings carried over by a rename:** homepage + `https://pgx.dev` and the description "PGX — Lightweight Postgres…". Both + need updating (`gh repo edit`). The homepage change is part of the pgx.dev + decision. ## Requires approval: in this order -1. [ ] **Push `rebrand/pgboxdb`** to the `pgx` remote and open the PR against - `main`. CI must be green, including the jobs that never ran - locally: Linux `cli` (amd64, arm64), `docker` (amd64, arm64), and - the new `release-workflow` job. Review, then merge. `prod` is - untouched. -2. [ ] **Rename the GitHub repository** `pgrundev/pgx` → `pgrundev/pgboxdb`, - then `git remote set-url pgx git@github.com:pgrundev/pgboxdb.git` - locally. Do it before step 5: every download URL points at - `pgrundev/pgboxdb`. Do steps 2–6 close together (readiness, risk 4). -3. [ ] **Rename `pgrundev/pgx-plugin`** → `pgrundev/pgboxdb-plugin` and sync - it from `plugins/pgboxdb` (`publish-plugin.yml`, dry run first). -4. [ ] **Release PR**: push `release/v0.2.0`, open it against `main`, then - wait for CI and merge. -5. [ ] **Tag and release**: push tag `v0.2.0` on the merged `main` commit, - then watch `release.yml`. The guard prints `0.2.0`. The draft must - list `pgboxdb-0.2.0-{darwin-arm64,linux-amd64,linux-arm64}.tar.gz`, - their `.sha256` files and `checksums.txt` (7 files, no darwin-amd64). - Download one tarball, run `shasum -a 256 -c`, then publish the draft. -6. [ ] **npm**: create the trusted publisher for the **new** package - `pgboxdb` (OIDC, `npm-publish.yml`, environment `npm`). It is a first - publish of a new name, so use staged publishing (the default) and - approve with 2FA. Then check `npx pgboxdb@0.2.0 --version` from a - clean HOME. -7. [ ] **Installer Worker**: `wrangler deploy` (it is already pinned to - `v0.2.0`) on the account that owns the `pgboxdb.com` zone. Check - `curl -fsSL https://pgboxdb.com/install | sh`. -8. [ ] **DNS / site**: point `pgboxdb.com` at `dist/pgboxdb.com/site`, and - `pgbox.dev/db` at the documentation. -9. [ ] **Docker**: if images are published, use the `pgboxdb` name only (and - first add `ARG PGBOXDB_VERSION`; readiness, risk 6). -10. [ ] **Claude Code marketplace**: announce installing `pgboxdb` and - uninstalling `pgx`. -11. [ ] **PGRun**: each developer runs `reports/pgrun-dev/apply.sh - ` after installing `pgboxdb`, then migrates their - home by hand (§B3). Update the marketing links (§C) once - `pgboxdb.com` serves. +1. [x] **Legal**: option A (rename, keep GitHub's redirects, no placeholders) +2. [x] **Rename** (done 2026-11-19 19:53:30 UTC) `pgrundev/pgx` → `pgrundev/pgboxdb` and `pgrundev/pgx-plugin` + → `pgrundev/pgboxdb-plugin`; update the description and homepage; + `git remote set-url`. Check the redirects (runbook step 2) +3. [ ] **Release PR**: #52 open (pushed 2026-11-19); CI, then merge +4. [ ] **Tag** `v0.2.0` on the merged `main`; check the draft (7 files, + `shasum -c`) +5. [ ] **Publish the GitHub Release** (separate approval). This starts + `npm-publish.yml` +6. [ ] **npm**: stage-only `NPM_TOKEN`; approve the `npm-publish` + environment; **approve the staged package with 2FA** (separate + approval); registry clean-machine check; switch to the trusted + publisher; delete and revoke the token +7. [ ] **Worker** `wrangler deploy` (separate approval) +8. [x] **pgx.dev 301 → pgboxdb.com**: live since 2026-11-19 19:58:36 UTC, + ends by itself 2027-02-17 19:58:29 UTC; delete the Worker then + (`dist/legacy-domain-redirect/README.md`). `/install` is not redirected +9. [ ] Clean-install verification (runbook step 8) +10. [ ] Plugin repository sync secrets and `publish-plugin.yml`; Docker + naming; PGRun developers run `reports/pgrun-dev/apply.sh` (PGRun + production is not touched) + +## Open points (no blocker) + +* The `npm-publish` environment has **no deployment-branch policy**, so a + run from any branch could request it. The reviewer gate and npm's 2FA + approval still hold. Suggest restricting it to tags `v*` after the rename: + `gh api -X PUT repos/pgrundev/pgboxdb/environments/npm-publish` with + `deployment_branch_policy`, plus a tag rule (runbook step 5.0). +* `prevent_self_review` is off. You are the only reviewer, so it must stay + off, or nobody could approve. +* `plugin-publish` has no reviewers. +* Branch protection on `main` requires the Linux and macOS `cli` checks and + Docker amd64. `release-workflow` is not required; consider adding it. +* `SECURITY.md` and issue templates are still missing for the public launch. ## Post-release verification - [ ] `npx pgboxdb@latest` on a machine with no previous install: `run`, `ls`, `top --demo`, `stop` -- [ ] On a machine with `~/.pgx`: `pgboxdb` refuses with the migrate hint. - Then `pgboxdb migrate`, `migrate --apply` and `start` must keep every - database, and `migrate --rollback --apply` must return to the old - state. +- [ ] On a machine with `~/.pgx`: `pgboxdb` refuses with the migrate hint; + `migrate`, `migrate --apply` and `start` keep every database; + `migrate --rollback --apply` restores the old state - [ ] `curl -fsSL https://pgboxdb.com/install | sh` verifies the checksum - [ ] `/plugin install pgboxdb@pgboxdb-plugin` in a fresh Claude Code config -- [ ] The Skill's `check-pgboxdb.sh` reports `{"ok":true,"version":"0.2.0"…}` +- [ ] `check-pgboxdb.sh` reports `{"ok":true,"version":"0.2.0"…}` +- [ ] `pgxdb@0.1.3` and the pgx.dev install still work through the redirect + (option A) ## Rollback | Step | Rollback | |---|---| -| merge to `main` | revert the merge commit (a PR); `prod` and PGRun are unaffected | -| repository rename | rename it back (GitHub keeps redirects until the name is reused) | -| release / tag | set the release back to draft or delete it, and delete the tag (both outward, need approval) | -| npm `pgboxdb` | `npm deprecate pgboxdb@0.2.0`, or unpublish within 72 h (npm policy) | +| merge to `main` (done) | revert merge `75112dad28` with a PR; `prod` and PGRun are unaffected | +| repository rename | rename it back (works while nobody has created the old name) | +| release / tag | set the release back to draft or delete it, and delete the tag | +| npm `pgboxdb` | reject an unapproved staged version; once live, `npm deprecate`, or unpublish within 72 h | | Worker | `wrangler rollback` | | user data | `pgboxdb migrate --rollback --apply` (tested) | | PGRun dev files | `reports/pgrun-dev/apply.sh --rollback` (tested) | -| these branches locally | `git worktree remove .worktrees/pgboxdb`, `git branch -D rebrand/pgboxdb release/v0.2.0` (deletes local work; ask first) | diff --git a/reports/PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md b/reports/PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md index f9cc023eba..af1d09af97 100644 --- a/reports/PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md +++ b/reports/PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md @@ -33,7 +33,11 @@ approval.** Nothing here has been run. Run them from the PGBoxDB worktree are unchanged for now; `PGX_AGENT_TOKEN` rotation is a separate production task. -## 1. Merge the rebrand +## 1. Merge the rebrand: DONE 2026-11-17 + +PR #50 merged as `75112dad28` (merge commit) after CI run 44025347562 was +green on head `c8d3551a70`. `release/v0.2.0` then merged `pgx/main` +(local). The commands that were run: ```sh gh pr ready 50 -R pgrundev/pgx @@ -42,7 +46,14 @@ gh pr merge 50 -R pgrundev/pgx --merge # merge commit, as for #49 gh run list -R pgrundev/pgx --branch main --limit 3 # CI on main green ``` -## 2. Rename the repositories +## 2. Rename the repositories: DONE 2026-11-19 19:53:30 UTC (option A) + +Both repositories were renamed. Their IDs, stars (728), forks (37), issues, +PRs and releases are unchanged. Verified afterwards through the old names: +the web pages, issue and PR pages, release downloads, `releases/latest`, +the API, raw files (served directly), and HTTPS and SSH clones. No +placeholder repositories were created. The local remote is +`git@github.com:pgrundev/pgboxdb.git`. The commands that were run: Do steps 2–6 close together. Between the rename and the 0.2.0 release, `install.sh` without a version picks v0.1.3, whose assets are named `pgx-…`, @@ -54,19 +65,26 @@ git remote set-url pgx git@github.com:pgrundev/pgboxdb.git gh repo view pgrundev/pgboxdb --json nameWithOwner,url gh repo rename pgboxdb-plugin -R pgrundev/pgx-plugin --yes + +# Settings carried over from the old name (the homepage waits for the pgx.dev decision): +gh repo edit pgrundev/pgboxdb --description "PGBoxDB — Lightweight Postgres for AI agents. Written in Rust. Thousands of isolated databases in one runtime" +gh repo edit pgrundev/pgboxdb --homepage https://pgboxdb.com # only when approved + +# The redirects the old installs depend on (legal option A): +curl -fsSIL https://github.com/pgrundev/pgx/releases/download/v0.1.3/pgx-0.1.3-darwin-arm64.tar.gz.sha256 | grep -i '^HTTP' | tail -1 # 200 +curl -fsSL https://raw.githubusercontent.com/pgrundev/pgx/v0.1.3/dist/install.sh | head -1 # #!/bin/sh ``` -## 3. Release PR (version 0.2.0) +## 3. Release PR (version 0.2.0): OPEN as #52 (2026-11-19) ```sh git fetch pgx git switch release/v0.2.0 git merge --no-edit pgx/main # brings in the merge commit of #50 -git diff pgx/main --stat # only the version-bump files +git diff pgx/main --stat # the version bump (19 files), 3 report files, tests/lifecycle.rs git push -u pgx release/v0.2.0 gh pr create -R pgrundev/pgboxdb --base main --head release/v0.2.0 \ - --title "release: PGBoxDB v0.2.0" \ - --body "Version 0.2.0 in crate, npm, plugin, Skill and README; release notes v0.2.0; Skill floor 0.2.0. See reports/PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md." + --title "release: PGBoxDB v0.2.0" --body-file reports/pgboxdb-v0.2.0-pr-body.md gh pr checks -R pgrundev/pgboxdb --watch gh pr merge -R pgrundev/pgboxdb --merge ``` @@ -103,6 +121,19 @@ D=$(mktemp -d) && gh release download v0.2.0 -R pgrundev/pgboxdb -D "$D" -p 'pgb npm can't configure a trusted publisher for a package that doesn't exist yet. So the first version is staged with a short-lived token: +0. Optional hardening: the environment has 1 required reviewer but no + deployment-branch policy. Restrict it to `v*` tags: + ```sh + gh api -X PUT repos/pgrundev/pgboxdb/environments/npm-publish --input - <<'EOF' + {"reviewers":[{"type":"User","id":REVIEWER_ID}], + "deployment_branch_policy":{"protected_branches":false,"custom_branch_policies":true}} + EOF + gh api -X POST repos/pgrundev/pgboxdb/environments/npm-publish/deployment-branch-policies -f name='v*' -f type=tag + ``` + (`REVIEWER_ID` comes from `gh api users/alexshapalov --jq .id`. The + registry check in step 4 is a `dry_run` and never enters the + environment.) + 1. On npmjs.com, create a granular access token that is **stage-only** (read and write, all packages, short expiry). Then add it: ```sh @@ -152,6 +183,11 @@ curl -fsSI https://pgboxdb.com/install | grep -i x-pgboxdb-install-ref # v0.2 ## 7. DNS / site +`pgx.dev/*` 301 → `pgboxdb.com` is LIVE since 2026-11-19 19:58:36 UTC. It +ends by itself at 2027-02-17 19:58:29 UTC; see +`dist/legacy-domain-redirect/README.md`. `pgx.dev/install` is not redirected. +`pgboxdb.com` already serves its landing page, and its DNS was not changed. + Point `pgboxdb.com` at `dist/pgboxdb.com/site`, and `pgbox.dev/db` at the documentation. @@ -213,7 +249,7 @@ documents). | Step | Command | |---|---| -| 1 merge | `gh pr create` a revert of the merge commit | +| 1 merge | `gh pr create` a revert of merge `75112dad28` | | 2 rename | `gh repo rename pgx -R pgrundev/pgboxdb --yes` (and the plugin repository) | | 4 tag / draft | `gh release delete v0.2.0 -R pgrundev/pgboxdb --yes` and `git push pgx :refs/tags/v0.2.0` | | 5 npm | a staged version that isn't approved never goes live (reject it). Once live: `npm deprecate pgboxdb@0.2.0 ""`, or unpublish within 72 h | diff --git a/reports/pgboxdb-v0.2.0-pr-body.md b/reports/pgboxdb-v0.2.0-pr-body.md new file mode 100644 index 0000000000..ba1b20dab6 --- /dev/null +++ b/reports/pgboxdb-v0.2.0-pr-body.md @@ -0,0 +1,28 @@ +The first release under the PGBoxDB name. The rebrand itself is #50; this PR +only sets the version. + +## Changes +- Version 0.2.0 in `crates/bin/pgboxdb/Cargo.toml`, `Cargo.lock`, + `dist/npm/package.json`, the plugin manifest, Skill metadata and README. +- Release notes: "PGBoxDB v0.2.0 — the first release under the PGBoxDB + name". The v0.1.x sections stay as published, under "Earlier releases (as + PGX)". +- The Skill requires PGBoxDB 0.2.0 or newer (`check-pgboxdb.sh`, SKILL.md, + references, docs). 0.1.x only ever shipped as PGX. +- `dist_consistency_test.sh` also checks that the Worker `INSTALL_REF` + equals `v` (`v0.2.0`). +- `tests/lifecycle.rs`: three init tests now retry a transient spawn failure + (ETXTBSY on the arm64 runner), like the rest of the harness. +- Reports: the final release checklist and the runbook. + +## Checks +- CI on this PR. +- Locally: release replay 31/31, consistency 42/42, + `dist/release/version.sh push v0.2.0` → `0.2.0`, npm 22/22, Skill suite. + +## After merge (separately approved) +Tag `v0.2.0` on the merge commit, then follow +`reports/PGBOXDB_V0.2.0_RELEASE_RUNBOOK.md` step 4 onward. The release is +created as a draft and is not published automatically. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) diff --git a/skills/pgboxdb/SKILL.md b/skills/pgboxdb/SKILL.md index 4d5da0e65b..af7189a385 100644 --- a/skills/pgboxdb/SKILL.md +++ b/skills/pgboxdb/SKILL.md @@ -14,7 +14,7 @@ description: > license: AGPL-3.0 metadata: author: pgrundev - version: "0.1.3" + version: "0.2.0" homepage: https://pgboxdb.com repository: https://github.com/pgrundev/pgboxdb --- @@ -95,9 +95,9 @@ PGBoxDB database), `none` (no database yet), `remote` (another host), ### 2. Make sure PGBoxDB is available -PGBoxDB **0.1.2 or newer** is required. 0.1.1 isolates sessions but not Claude -Code subagents (they shared the parent's branch); 0.1.0 has no `pgboxdb agent` -at all. Run the check script next to this file: +PGBoxDB **0.2.0 or newer** is required: 0.2.0 is the first release under the +PGBoxDB name, and every PGBoxDB release isolates sessions, Claude Code +subagents and Git branches. Run the check script next to this file: ```sh bash .claude/skills/pgboxdb/scripts/check-pgboxdb.sh # or .agents/skills/pgboxdb/scripts/check-pgboxdb.sh, diff --git a/skills/pgboxdb/references/git-integration.md b/skills/pgboxdb/references/git-integration.md index cd06f5a634..ab621ac57f 100644 --- a/skills/pgboxdb/references/git-integration.md +++ b/skills/pgboxdb/references/git-integration.md @@ -13,9 +13,8 @@ feature/auth ─ pgboxdb__auth_ the developer's branch database ## Version -`pgboxdb git` needs **PGBoxDB 0.1.3 or newer**. On 0.1.2 `pgboxdb git` is an unknown -command (exit 2); the agent features (`pgboxdb agent …`) still work there, so -only offer PGBoxDB Git after `pgboxdb --json version` reports 0.1.3 or newer. +`pgboxdb git` is in every PGBoxDB release (0.2.0 or newer, the same floor as +the rest of this skill: `scripts/check-pgboxdb.sh`). ## Detect diff --git a/skills/pgboxdb/references/installation.md b/skills/pgboxdb/references/installation.md index 14347f02b6..9c1f2bc976 100644 --- a/skills/pgboxdb/references/installation.md +++ b/skills/pgboxdb/references/installation.md @@ -7,18 +7,17 @@ command -v pgboxdb && pgboxdb --json version # {"pgboxdb_version":"0.1.x", pgboxdb --json status # exit 3 when initialised but stopped; hooks start it on demand ``` -The skill needs **PGBoxDB 0.1.2 or newer** -(https://github.com/pgrundev/pgboxdb/releases/tag/v0.1.2): the first release -in which Claude Code subagents get their own branches (0.1.1 isolated -sessions only and let subagents share the parent's branch; 0.1.0 has no -`pgboxdb agent` command group). +The skill needs **PGBoxDB 0.2.0 or newer** +(https://github.com/pgrundev/pgboxdb/releases/tag/v0.2.0): the first release +under the PGBoxDB name. Every PGBoxDB release has `pgboxdb agent` (sessions +and Claude Code subagents get their own branches) and `pgboxdb git`. `scripts/check-pgboxdb.sh` decides: exit 0 compatible, 3 missing, 2 too old, 4 malformed, always with one JSON line. It compares `pgboxdb --json version` → `pgboxdb_version` as semver (`PGBOXDB_MIN_VERSION` overrides the floor). Do not use `pgboxdb agent --help` as the test: `--help` prints the global help on every version. An older binary: upgrade with the method it was installed with (`npm i -g pgboxdb@latest`, or the installer again) and run the check again; -if the upgrade still reports 0.1.0, the newer package is not yet on that +if the upgrade still reports an older version, the newer package is not yet on that channel and the user should install from the GitHub release. ## Install, in order of preference @@ -27,7 +26,7 @@ channel and the user should install from the GitHub release. `~/.local/bin/pgboxdb`, Homebrew, or `~/.pgboxdb/dist//bin/pgboxdb`). Prefer it; do not download twice. 2. **npm**, when Node.js 18+ is present: `npm i -g pgboxdb` installs the - `pgboxdb` and `pgboxdb` commands; the first run downloads the native release + `pgboxdb` command; the first run downloads the native release tarball into `~/.pgboxdb/dist/`. `npx pgboxdb@latest` works without a global install but gives you `npx pgboxdb …` instead of `pgboxdb …`. 3. **The official installer**: `curl -fsSL https://pgboxdb.com/install | sh`. diff --git a/skills/pgboxdb/references/troubleshooting.md b/skills/pgboxdb/references/troubleshooting.md index 6a83d7c305..47ec5fcce2 100644 --- a/skills/pgboxdb/references/troubleshooting.md +++ b/skills/pgboxdb/references/troubleshooting.md @@ -23,7 +23,7 @@ Start with `pgboxdb agent doctor` (project state, this session) and `pgboxdb doc | Codex commands cannot connect, `CODEX_SANDBOX_NETWORK_DISABLED=1` | Sandbox blocks loopback. | `sandbox_workspace_write.network_access = true` (user's decision). | | Rails created `agent-…-0/1/2` databases | Parallel tests. | Harmless; `PARALLEL_WORKERS=1` or `pgboxdb drop` them. | | `ActiveRecord::EnvironmentMismatchError` after a green test run | The branch's `ar_internal_metadata` says `development`; Rails' `db:test:prepare` refuses to purge it. | Harmless; ignore. Never `db:environment:set` inside a branch. | -| Rails re-ran every migration on a fresh branch and failed on an existing table | The template was imported schema-only with an older `pgboxdb copy` that dropped `schema_migrations` rows. | Re-import with PGBoxDB 0.1.1 or newer (its `--schema-only` keeps migration bookkeeping) or insert the rows into the template once. | +| Rails re-ran every migration on a fresh branch and failed on an existing table | The template was imported schema-only with an older `pgboxdb copy` that dropped `schema_migrations` rows. | Re-import with any PGBoxDB release (its `--schema-only` keeps migration bookkeeping) or insert the rows into the template once. | | Port conflict on first run | Another service on the chosen port. | `pgboxdb doctor`; `PGBOXDB_PORT= pgboxdb run` on a fresh home only; never `init --force`. | Logs: `~/.pgboxdb/log/` (runtime and supervisor); `~/.pgboxdb/agent/hooks.log` (one diff --git a/skills/pgboxdb/scripts/check-pgboxdb.sh b/skills/pgboxdb/scripts/check-pgboxdb.sh index 9e3a0f0f5c..5a4a4a0717 100755 --- a/skills/pgboxdb/scripts/check-pgboxdb.sh +++ b/skills/pgboxdb/scripts/check-pgboxdb.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # check-pgboxdb.sh: is a compatible PGBoxDB on PATH? Prints one JSON object and exits -# 0 compatible (version >= MIN) {"ok":true,"version":"0.1.2","path":"…"} +# 0 compatible (version >= MIN) {"ok":true,"version":"0.2.0","path":"…"} # 3 pgboxdb not found {"ok":false,"reason":"missing",…} -# 2 too old {"ok":false,"reason":"too_old","version":"0.1.1",…} +# 2 too old {"ok":false,"reason":"too_old","version":"0.1.9",…} # 4 unreadable version output {"ok":false,"reason":"malformed",…} # `pgboxdb agent --help` exits 0 on every PGBoxDB version (global help), so only the # structured `pgboxdb --json version` output counts. set -u -MIN=${PGBOXDB_MIN_VERSION:-0.1.2} +MIN=${PGBOXDB_MIN_VERSION:-0.2.0} esc() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; } path=$(command -v pgboxdb 2>/dev/null || true) if [ -z "$path" ]; then @@ -28,12 +28,7 @@ vcmp() { # returns 0 if $1 >= $2 if vcmp "$ver" "$MIN"; then printf '{"ok":true,"version":"%s","path":"%s","min":"%s"}\n' "$ver" "$(esc "$path")" "$MIN"; exit 0 fi -# Too old. Say what the installed version lacks: 0.1.1 isolated sessions but -# let Claude Code subagents share the parent's branch; anything older has no -# `pgboxdb agent` at all. Either way: upgrade, do not run database work. -if vcmp "$ver" "0.1.1"; then - why="PGBoxDB $ver isolates sessions only: Claude Code subagents would share the parent's branch" -else - why="PGBoxDB $ver has no pgboxdb agent" -fi +# Too old: 0.2.0 is the first PGBoxDB release, so an older `pgboxdb` is a +# development or CI build. Upgrade; do not run database work with it. +why="PGBoxDB $ver predates 0.2.0, the first PGBoxDB release" printf '{"ok":false,"reason":"too_old","version":"%s","path":"%s","min":"%s","hint":"%s; upgrade to %s or newer with the method it was installed with (npm i -g pgboxdb@latest, or the installer again)"}\n' "$ver" "$(esc "$path")" "$MIN" "$why" "$MIN"; exit 2 diff --git a/skills/tests/pgboxdb/check-pgboxdb.test.sh b/skills/tests/pgboxdb/check-pgboxdb.test.sh index f79ec0e8eb..8205a67677 100755 --- a/skills/tests/pgboxdb/check-pgboxdb.test.sh +++ b/skills/tests/pgboxdb/check-pgboxdb.test.sh @@ -9,11 +9,11 @@ mk() { # name version-json-or-garbage run() { PATH="$1:/usr/bin:/bin" bash "$chk"; } set +e out=$(PATH=/usr/bin:/bin bash "$chk"); rc=$?; [ $rc = 3 ] && [[ $out == *'"reason":"missing"'* ]] && ok "missing → 3" || bad "missing: rc=$rc $out" -d=$(mk old '{"pgboxdb_version":"0.1.0","os":"darwin"}'); out=$(run "$d"); rc=$?; [ $rc = 2 ] && [[ $out == *'"too_old"'* ]] && [[ $out == *"no pgboxdb agent"* ]] && ok "0.1.0 → 2 (too old) even though agent --help exits 0" || bad "old: rc=$rc $out" -d=$(mk sess '{"pgboxdb_version":"0.1.1","os":"darwin"}'); out=$(run "$d"); rc=$?; [ $rc = 2 ] && [[ $out == *'"too_old"'* ]] && [[ $out == *subagents* ]] && ok "0.1.1 → 2 (session isolation only; the hint names subagents)" || bad "0.1.1: rc=$rc $out" -d=$(mk cur '{"pgboxdb_version":"0.1.2","os":"darwin"}'); out=$(run "$d"); rc=$?; [ $rc = 0 ] && [[ $out == *'"ok":true'* ]] && ok "0.1.2 → 0" || bad "current: rc=$rc $out" +d=$(mk old '{"pgboxdb_version":"0.1.0","os":"darwin"}'); out=$(run "$d"); rc=$?; [ $rc = 2 ] && [[ $out == *'"too_old"'* ]] && [[ $out == *"first PGBoxDB release"* ]] && ok "0.1.0 → 2 (too old) even though agent --help exits 0" || bad "old: rc=$rc $out" +d=$(mk dev '{"pgboxdb_version":"0.1.3","os":"darwin"}'); out=$(run "$d"); rc=$?; [ $rc = 2 ] && [[ $out == *'"too_old"'* ]] && [[ $out == *'"min":"0.2.0"'* ]] && ok "0.1.3 (a build from before the first release) → 2" || bad "0.1.3: rc=$rc $out" +d=$(mk cur '{"pgboxdb_version":"0.2.0","os":"darwin"}'); out=$(run "$d"); rc=$?; [ $rc = 0 ] && [[ $out == *'"ok":true'* ]] && ok "0.2.0 → 0" || bad "current: rc=$rc $out" d=$(mk env '{"pgboxdb_version":"0.1.1","os":"darwin"}'); out=$(PGBOXDB_MIN_VERSION=0.1.1 PATH="$d:/usr/bin:/bin" bash "$chk"); rc=$?; [ $rc = 0 ] && ok "PGBOXDB_MIN_VERSION override still works" || bad "override: rc=$rc $out" -d=$(mk new '{"pgboxdb_version":"0.2.0","os":"linux"}'); out=$(run "$d"); rc=$?; [ $rc = 0 ] && ok "0.2.0 → 0" || bad "newer: rc=$rc $out" +d=$(mk new '{"pgboxdb_version":"0.3.1","os":"linux"}'); out=$(run "$d"); rc=$?; [ $rc = 0 ] && ok "0.3.1 → 0" || bad "newer: rc=$rc $out" d=$(mk ci '{"pgboxdb_version":"0.0.0-ci.abc","os":"linux"}'); out=$(run "$d"); rc=$?; [ $rc = 2 ] && ok "0.0.0-ci → 2" || bad "ci build: rc=$rc $out" d=$(mk bad 'not json at all'); out=$(run "$d"); rc=$?; [ $rc = 4 ] && [[ $out == *'"malformed"'* ]] && ok "garbage → 4 (malformed)" || bad "malformed: rc=$rc $out" d=$(mk empty ''); out=$(run "$d"); rc=$?; [ $rc = 4 ] && ok "empty → 4" || bad "empty: rc=$rc $out" diff --git a/skills/tests/pgboxdb/run.sh b/skills/tests/pgboxdb/run.sh index 0a7e4e8625..97cd9590cc 100755 --- a/skills/tests/pgboxdb/run.sh +++ b/skills/tests/pgboxdb/run.sh @@ -80,7 +80,7 @@ check empty "d['framework']=='unknown' and d['database_config']['classification' check sensitive "d['database_config']['classification']=='sensitive'" check empty "d['pgboxdb']['installed']==False" check remote-ssl "d['database_config']['classification']=='sensitive'" -grep -q '0.1.2 or newer' "$skill/SKILL.md" && ! grep -q '0.1.1 or newer' "$skill/SKILL.md" && ! grep -qE 'pgboxdb agent --help. must succeed' "$skill/SKILL.md" && ok "SKILL.md gates on PGBoxDB 0.1.2, not on --help" || bad "SKILL.md must gate on version 0.1.2 (0.1.1 shares the parent's branch with subagents; pgboxdb agent --help exits 0 on old binaries)" +grep -q '0.2.0 or newer' "$skill/SKILL.md" && ! grep -qE '0\.1\.[0-9] or newer' "$skill/SKILL.md" && ! grep -qE 'pgboxdb agent --help. must succeed' "$skill/SKILL.md" && grep -q 'MIN=${PGBOXDB_MIN_VERSION:-0.2.0}' "$skill/scripts/check-pgboxdb.sh" && ok "SKILL.md and check-pgboxdb.sh gate on PGBoxDB 0.2.0, not on --help" || bad "SKILL.md and check-pgboxdb.sh must gate on 0.2.0, the first PGBoxDB release (pgboxdb agent --help exits 0 on old binaries)" grep -q 'scripts/detect-project.sh' "$skill/SKILL.md" && grep -qE '\.claude/skills/pgboxdb/scripts/detect-project\.sh|\.agents/skills/pgboxdb/scripts/detect-project\.sh' "$skill/SKILL.md" && ok "SKILL.md names the installed script paths" || bad "SKILL.md must name the installed script paths" # Secrets never leak into the output. for f in django prisma node sensitive remote-ssl; do