Repository navigation
@plexus-ms/test-postgres: a throwaway PostgreSQL from the pinned binary - #142
Merged
davidjalbers merged 43 commits intoNov 30, 2026
Merged
Conversation
An empty @plexus-ms/test-postgres, with the conda:postgresql pin its own tests need and POSTGRES_MAJOR, the major they ask for, as an input of its test task. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e it Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ts drop (red) Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ller Co-Authored-By: Claude Fable 5.2 <[email protected]>
…o fallback (red) Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…s caller The supervisor waits for the end of its stdin, which the caller's stop() closes and the kernel closes when the caller dies, SIGKILL included. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The root fixture reads the postmaster's pid from postmaster.pid: the backend of the query that asked for it has gone by the time ps looks. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…by hand The maintainer's decision: nothing in test may need Docker. The root path stays and the header says that no test covers it; the Docker variables leave the package's turbo.json. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Measured with 18.6 and the loop removed: eight copies at once from one template all succeed (25 ms), and a session on the template is waited for about five seconds before the copy fails with 55006 (a 3 s session: the copy succeeds after 2.7 s; a 9 s session: it fails after 5.0 s). Co-Authored-By: Claude Fable 5.2 <[email protected]>
…red) The package's source and a caller in one file, as a bundler makes it. The caller logs every process that runs the file and stops three levels down, so that the chain this reproduces stays small; the test removes what it left. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…vironment The supervisor is the package's own file run on its own. Bundled into the caller's file, that file is the caller's program, so each supervisor ran the caller again and started the next. startPostgres now refuses unless its file is the package's own (the nearest package.json names it), and the entry guard tests an environment variable the package sets on the supervisor, not the command line. A marker alone was not enough: tried by hand, the bundle's supervisor began its cluster directory before the bundle's caller code failed, and the directory was left. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
fixtures/psql.ts becomes fixtures/support.ts, with startThatFails(): the start under a TMPDIR of its own, its error and what it left there. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…red) Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…(red) Co-Authored-By: Claude Fable 5.2 <[email protected]>
A supervisor whose start failed also lets go of its stdin, so that it exits rather than wait for a caller that will not close it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ing (red) Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…es (red) The stand-ins on the PATH now answer postgres --version with a version of the test's choosing, and initdb leaves a file when it runs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…types The settings are checked in the caller's process, before anything starts. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The server listens on 127.0.0.1 only with its socket in its own directory; a caller that ends without stop() is not held up and leaves nothing; a SIGINT or a SIGKILL to the caller's process group leaves nothing; the drop test's session outlasts the five seconds PostgreSQL waits; the environment's PG variables do not change where the calls connect; an install without psql fails with the pin; a lower and a higher major both fail. These pass as they are; each was seen to fail with its condition broken. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…re ended The failed-start test now also asserts that the supervisor exits, and the test of a caller ending without stop() ends a caller that is held up, so that both fail cleanly with their condition broken instead of hanging the run. The process list moves into the shared fixtures. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… now Co-Authored-By: Claude Fable 5.2 <[email protected]>
The name the repo-turbo template sets, by the maintainer's decision. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…(red) Co-Authored-By: Claude Fable 5.2 <[email protected]>
A signal that reaches the supervisor while the cluster starts used to give the caller the URL of a server that was already going. The supervisor now stops the cluster once it is up, reports an error that names the signal, and lets go of its stdin so that it exits. The test also asserts that the supervisor exits, so that a supervisor left waiting fails it rather than hanging the run. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The bundled test runs twice: in an app of its own, and in a directory whose package.json names this package, where the own-file check passes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…eaves nothing The own-file check is not widened. The supervisor lets a caller bundled into its file run first; that caller's startPostgres() writes the bundled message to the supervisor's stdout before it throws, and the supervisor, seeing the refusal, creates nothing. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…s own is for The supervisor's own session keeps a SIGKILL to the caller's process group from reaching it; a Ctrl-C would not take it down without the session, since it handles SIGINT itself. Co-Authored-By: Claude Fable 5.2 <[email protected]>
With the refusal check in the supervisor removed, the suite passed: a caller that lets the error end its process ends the supervisor before the check matters. A caller that catches it and lives on is where the check counts; the test watches the cluster directory while the bundle runs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
davidjalbers
deleted the
davidjalbers/plx-177-plexus-mstest-postgres-a-throwaway
branch
November 30, 2026 16:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new package,
@plexus-ms/test-postgres: a throwaway PostgreSQL server for tests, started from the binary on thePATHand removed afterwards (Decisions § 2.1, § 2.5).It installs nothing; the server comes from the repo's
conda:postgresqlpin.How it works, what it refuses to do and what no test covers is in the header of
packages/test-postgres/src/index.ts.Shared files touched: the
conda:postgresql = "18.6"pin andPLX_POSTGRES_MAJOR = "18"in the rootmise.toml, the lockfile, and a package-levelpackages/test-postgres/turbo.jsonthat declaresPLX_POSTGRES_MAJORas an input of this package'stest(§ 2.4, § 1.12).Nothing in
testneeds Docker.Decisions the issue did not make
startPostgres({ major, settings }),createDatabase(url, { template })with the template as a database name (PostgreSQL's own term), anddropDatabase(url), which decodes the name in the URL's path. The server URL names thepostgresdatabase as thepostgresrole.stop()leaves nothing behind. A SIGKILL of the supervisor itself cannot be handled and leaves the server running. The session of its own is what keeps a SIGKILL to the caller's process group from reaching the supervisor; the test of that SIGKILL is what holds the header's sentence, since the supervisor's own SIGINT handler would survive a Ctrl-C without the session.startPostgresrefuses unless its file's nearestpackage.jsonis this package's, the supervisor is marked by an environment variable rather than its command line, and a marked process refuses to start another server. A marker alone was not enough: by hand, the bundle's supervisor began its cluster directory before the bundle's caller code failed. A bundle placed inside the package's own directory does get past the own-file check and starts one supervisor; that supervisor lets the bundled caller run first, the caller's refusal is reported to the supervisor's caller with the bundled message, and nothing is created, also when the bundled caller catches the refusal and lives on.nobody(not apostgresuser where one exists), switched to by Node'sspawnuid/gid, sorunuser,setprivandsuare not needed. An installnobodycannot run (one under/root) fails with a message that says so; the package never changes its permissions. No test covers this path, by the maintainer's decision;src/fixtures/as-root.tsis a script to run by hand as root, its header says how.--locale=C --locale-provider=builtin --builtin-locale=C.UTF-8, so text sorts and cases alike on macOS and Linux. This needs PostgreSQL 17 or later (17.12 and 18.6 tried), and an older server is refused beforeinitdbruns.fsync=off. Port, address and socket go intopostgresql.conf, not throughpg_ctl -o, so no shell sees a value.settings: an option for server parameters, because the code this ports from runs withmax_connections=400. The package's own three settings and values that are not a string or a number on one line are refused.initdbon thePATH, withpg_ctl,postgresandpsqlrequired in the same directory.createDatabaseanddropDatabaseuse thepsqlof that install, with the environment'sPG*variables removed.server.login its error and leaves no directory.pg_ctl -m immediate, since the directory is removed right after.PLX_POSTGRES_MAJOR(the name therepo-turbotemplate sets), set beside the pin inmise.toml. These are two literal lines, guarded by the wrong-major failure. mise can derive one from the other through[vars](tried), but I assumed the update bot cannot bump a templated version, and did not check that.minorchangeset, so the first version is 0.1.0.Not covered by a test
initdbruns); a SIGKILL of the supervisor is not, since it cannot be handled.libraries:Evidence
Each behaviour was committed as a failing test, then as the code that passes it; the
(red)commits fail for the reason named.The tests added for conditions that already held were each seen to fail with their condition broken in a copy of the source.
After:
mise run verifypasses, 31 of 31 tests in this package.pnpm packand the tarball installed into an empty project whosePATHhasconda:postgresql18.6 from a scratchMISE_DATA_DIR, a script started a server, made two databases and a copy of one, queried each, dropped one and stopped it; the directory was gone afterwards.By hand: no binaries on the
PATH, a wrong major, andkill -9of the caller each fail cleanly or leave nothing.The packed
dist/index.jsand a caller concatenated into one file fail with the message to keep the package external, and start no supervisor, cluster or directory.A real bundler (esbuild) was not run here; the reviewer's esbuild bundle is what found the problem, and the test reproduces it without one.
Merge Danger
Door: two-way until the first publish, then one-way: a published npm version cannot be taken back.
Blast Radius: contained. No consumer exists yet, and
stdandconfigare untouched.🤖 Generated with Claude Code