Persistent databases#4
Merged
Merged
Conversation
- Provision one persistent Postgres via devenv services.postgres instead of pg-ephemeral spinning up a throwaway server per benchmark, per test suite, and a separate initdb cluster for pg-regress. The server starts with `devenv up`. - Recreate every benchmark instance, the main test database, and en57_regress as initialDatabases seeded from db/schema and db/seeds, replacing database.toml. - Connect over the service's unix socket via plain postgres:///name URLs, letting the devenv-exported PGHOST drive the connection. - Since databases now persist between runs, the benchmark runner resets each instance to its baseline before running: truncate for en57/RES scenarios, truncate-and-reseed for the seeded instance. - Point pg-regress at the shared server, dropping its temporary cluster bootstrap.
- en57_regress was redundantly namespaced; the database already lives on the project's dedicated Postgres server.
- `devenv tasks run test` only runs tasks; it never starts services, so postgres was absent in CI and any DB-touching test had no server to reach. - Switch the CI step to `devenv test`, which starts the postgres process, waits for it to be healthy, runs enterTest, then tears it down. - Add an enterTest hook delegating to the existing test task namespace so the suite runs under the started service.
This reverts commit c4c06b7.
- Note that `devenv shell` does not start the postgres service, and show `devenv up` / `devenv up -d` to bring services up before running DB-backed code. - Document `devenv test` as the one-step start-wait-run-teardown command and update the CI line to match. - Correct the `test:pg` row: it now targets the running postgres service, not an ephemeral instance.
- Both the Claude Code Stop hook and the pi onStop hook ran `devenv tasks run test`, which never starts services and so silently relied on a postgres instance being up already. - Switch both to `devenv test` so the hook owns the service lifecycle: start postgres, wait for health, run the suite, tear down. Agents no longer depend on a manual `devenv up`. - Caveat: a concurrent `devenv up` can clash with the instance `devenv test` starts.
- Point the treefmt ruby formatter at the bin/stree binstub instead of a bare `stree`, so formatting always uses the Bundler-pinned syntax_tree gem rather than whatever stree happens to be on PATH. - Resolves relative to the project root, which treefmt uses as its working directory, so the dev:format task, the Claude format hook, and the .pi edit hook all pick it up.
- Replace the static initialDatabases list (13 named DBs reset with TRUNCATE) with three golden templates: golden_en57, golden_res, and golden_en57_seeded. The seeded golden bakes its 1M-row seed in at provisioning time. - Add En57::EphemeralDatabase.with(template:), which clones a golden via CREATE DATABASE ... TEMPLATE (PostgreSQL's fastest copy — file-level, not row-by-row), yields a database_url, and drops it WITH (FORCE) when the block ends. No TRUNCATE. - IntegrationTest now clones golden_en57 per test and drops it on teardown, isolating every test; pools connect lazily. Benchmarks clone per scenario instead of resetting. - The seeded benchmark clones the 1M-row golden (~1s) instead of re-INSERTing the seed on every run (~16s). - Ignore EphemeralDatabase#execute in mutant: the receiver->self mutation runs Kernel#exec on multi-word SQL and replaces the worker, so it cannot be killed. - Adopting this needs a one-time Postgres data-dir reset so devenv provisions the goldens (devenv up and devenv test use separate state dirs); the old named databases are obsolete.
- Keep explanations in commit messages and rely on clear names instead of inline comments. - Drop the redundant "run treefmt after editing" rule; the treefmt hook already runs on edit.
- Provision the golden_en57 clone and connection pools once at suite load and drop the database in Minitest.after_run, instead of per example. - Reset state between examples with TRUNCATE ... RESTART IDENTITY; with no parallelism yet, per-example databases only added createdb/dropdb and pool-rebuild overhead. - Integration suite drops from ~3.3s to ~1s.
- Add pkgs.rubyPackages.syntax_tree (6.3.0, same version as the lockfile, so formatting output is unchanged) and point the treefmt ruby formatter at its store-path stree binary. - Referencing the absolute nix path (like scripts.pg-regress does for postgres) avoids a stale bundle-installed stree shadowing it on PATH. - Drop syntax_tree from the Gemfile and its bin/stree binstub; formatting no longer depends on the project bundle.
This reverts commit 7314af0.
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.
No description provided.