diff --git a/AGENTS.md b/AGENTS.md index 9d4dfb5..e6517c7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -80,7 +80,7 @@ Keep logic in the canonical layer. Prefer reuse over one-off branches in adapter | Skip policy (`CEDAR_PG=0`, external URL, force) | `src/core/policy.ts` (`resolveAcquireSkip`, `runIfNeeded`, `applyDatabaseUrlEnv`) | | TEMPLATE mark / clone | `src/core/template.ts` | | Lease read/write / registry | `src/core/lease.ts` | -| Host attach vs ephemeral CI start | `src/providers/host.ts` (internal; `ensureHostRunning` is **not** a public export) | +| Host attach / local recovery / ephemeral start | `src/providers/host.ts` (internal; `ensureHostRunning` is **not** a public export) | | SQL / autopg CLI / URLs / role password | `src/providers/autopg.ts` | | Shared Vite+/Nx task strings | `src/adapters/tasks.ts` (`cedarPgLifecycleTargets`, `cedarPgRunCommand`) | | Runner TEMPLATE orchestration + migrate hook | `src/adapters/template-mode.ts` → thin Jest/Vitest wrappers | @@ -89,7 +89,7 @@ Keep logic in the canonical layer. Prefer reuse over one-off branches in adapter **Migrate stays app-owned.** Stock `@cedarjs/pg/jest` / `vitest` only acquire/dispose. TEMPLATE adapters require `createGlobalSetup({ migrate })`; string-resolving the package entry without a migrate hook must throw. -**Host bootstrap stays internal.** Callers use `acquire` (and `adminUrl`). Do not re-export `ensureHostRunning` or grow a public host-options bag; ephemeral behavior is env-driven (`CI`, `CEDAR_PG_EPHEMERAL_HOST`). +**Host bootstrap stays internal.** Callers use `acquire` (and `adminUrl`). Do not re-export `ensureHostRunning` or grow a public host-options bag; ephemeral behavior is env-driven (`CI`, `CEDAR_PG_EPHEMERAL_HOST`). Liveness is a TCP accept, never `autopg status` alone. Local recovery revives the **registered** host (`autopg restart`, then `autopg install`) — an owned postmaster is ephemeral/CI-only, and `CEDAR_PG_EPHEMERAL_HOST=0` disables it everywhere. Do not add a second local Postgres port/data dir. ## Env and policy (easy to get wrong) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e1b52a..d0f56ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,10 +10,18 @@ ### Fixed +- Attach liveness is a TCP accept, never `autopg status` alone: `cedarpg acquire` no longer connects to a registered-but-stopped host (`ECONNREFUSED 127.0.0.1:25432`). +- Local host recovery brings the **registered** autopg host back: `autopg restart`, then `autopg install` if still no listener, then attach once TCP accepts (error names the registered port and lists what was tried). `restart` exiting 0 is not treated as live. Same port and `~/.autopg/data`; cedar-pg never starts a second local Postgres. +- `CEDAR_PG_EPHEMERAL_HOST=0` now has one meaning: never start an owned postmaster (even under `CI=true`) — local autopg host only, or fail. +- Ephemeral host: start detached `autopg postmaster` only. Do not run `install --no-pm2` (that rewrites `~/.autopg/admin.json` and fails with `supervisor mismatch` next to a local pm2 install). - `@cedarjs/pg/vite-plus` no longer statically imports `vite`, so the optional peer can be absent (smoke / Nx-only installs) - TEMPLATE `cloneWorkerDatabase`: default clone name is unique per call (`__