Repository navigation
fix(probes): report a missing pg gem as a MAGIK_DEV_* diagnostic - #34
Merged
developerz-ai[bot] merged 1 commit intoNov 18, 2026
Conversation
The PostgreSQL concurrency probe required pg with a bare require, so a checkout without the gem died on a LoadError with no code and no remedy. Wrap the require and print MAGIK_DEV_PROBE_PG_MISSING on stderr with a cause and a runnable `fix: gem install pg`, exiting nonzero. stdout stays clean so the probe's --json output is unaffected, and the pg-present path is unchanged. No dependency is added to the repo or the gem. Cover both the missing and available cases with a hermetic Minitest that drives the probe as a subprocess, and document the prerequisite and the diagnostic in the runtime-verification page, the error-code page and their generated mirrors. Dz-Task-Id: tsk_9cb2b5ecb0e3bd0283d6e527cabaea09
Contributor
Author
|
Give the optional PostgreSQL probe an actionable missing-dependency error
Work landed on #34 — watching it toward merge. 3h40m · 1595 tool calls · 107 messages |
Contributor
Author
✅ Reviewed — nothing blocking0 actionable comment(s) · grounded on your code 🤖 developerz.ai — automated review, running on your model and your box. |
Contributor
Author
There was a problem hiding this comment.
Review summary — 9 file(s), 0 finding(s).
Adds a stderr diagnostic and exit 69 for an unavailable pg gem, with subprocess tests and prerequisite documentation. The supplied diff shows no actionable defects; the successful-load path remains unchanged.
🤖 developerz.ai review — automated, running on your model and your box. What is this?
developerz-ai
Bot
deleted the
dz/give-the-optional-postgresql-probe-an-actionable--9cb2b5ec
branch
November 18, 2026 06:19
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.
What
The PostgreSQL concurrency probe required pg with a bare require, so a
checkout without the gem died on a LoadError with no code and no remedy.
Wrap the require and print MAGIK_DEV_PROBE_PG_MISSING on stderr with a
cause and a runnable
fix: gem install pg, exiting nonzero. stdout staysclean so the probe's --json output is unaffected, and the pg-present path
is unchanged. No dependency is added to the repo or the gem.
Cover both the missing and available cases with a hermetic Minitest that
drives the probe as a subprocess, and document the prerequisite and the
diagnostic in the runtime-verification page, the error-code page and
their generated mirrors.
Acceptance
ruby apps/magik/scripts/probes/pg_concurrency.rbexits nonzero and printsMAGIK_DEV_PROBE_PG_MISSING:plus afix:line naminggem install pgon stderr, with nothing on stdout.ruby apps/magik/scripts/checks/shipped_mirrors.rbreports no drift between docs/architecture/12-runtime-verification.md and its packaged mirror, nor between docs/architecture/03-error-codes.md and its mirror.Changes
apps/magik/scripts/probes/pg_concurrency.rb(edit) — Replace the barerequire "pg"at line 20 with abegin/rescue LoadErrorthat prints a repo-internal diagnostic and exits nonzero:MAGIK_DEV_PROBE_PG_MISSING: the pg gem is not installed (<e.message>), then an indentedcause:naming what the probe needs andfix: gem install pg(a runnable command, matching theMAGIK_DEV_NO_RAKE/gem install rakeprecedent in docs/architecture/03-error-codes.md). Print to STDERR, never stdout: the probe has a--jsonmode (lines 52-53) and kb lesson 4 requires parser-consumed stdout stay clean. Keeprequire "json"first and the e [trimmed]apps/magik/test/scripts/pg_probe_test.rb(create) — New Minitest fileMagikScriptsPgProbeTest(path/class mirror apps/magik/test/scripts/ruby_pin_test.rb;require_relative "helper", REPO = File.expand_path("../../../..", dir)). Cover both cases hermetically by spawningruby apps/magik/scripts/probes/pg_concurrency.rbas a subprocess: (1) MISSING — GEM_HOME/GEM_PATH pointed at an empty tmpdir sorequire "pg"raises LoadError regardless of this box; assert exit status nonzero, stderr containsMAGIK_DEV_PROBE_PG_MISSINGand afix:line naminggem install pg, and stdout is empty. (2) AVAILABLE — a tmpdir on RUBYLIB holdi [trimmed]docs/architecture/12-runtime-verification.md(edit) — In the IO half (lines 50-55, where theDATABASE_URL=... ruby apps/magik/scripts/probes/pg_concurrency.rbcommands sit), state the probe's prerequisite: it needs thepggem, which is deliberately NOT a dependency of this repository or the gem (apps/magik/Gemfile lists no pg), plus a reachable DATABASE_URL — and that whenpgis absent the probe now printsMAGIK_DEV_PROBE_PG_MISSING: ...withfix: gem install pgon stderr and exits 1 instead of raising a bare LoadError. Leg 2 of this goal reads the command from this page.apps/magik/docs/architecture/12-runtime-verification.md(edit) — The GENERATED packaged mirror of docs/architecture/12-runtime-verification.md — footer at lines 308-319 says 'Generated file — do not edit' and namesruby apps/magik/scripts/checks/shipped_mirrors.rb --write. Apply the identical prose the source gains in its IO section so the mirror matches the renderer's output byte-for-byte;shipped_mirrors(read-only run) compares the two. Do not run--write(it writes across the repo); hand-edit and verify with the check.docs/architecture/03-error-codes.md(edit) — Add one row to the repo-internal (DEV namespace) table that already holdsMAGIK_DEV_NO_RUBY/MAGIK_DEV_RUBY_TOO_OLD/MAGIK_DEV_NO_RAKE(~line 269): |MAGIK_DEV_PROBE_PG_MISSING|pg_concurrency.rb| thepggem is not installed |gem install pg|. This is the documented home for repo-internal codes (scripts/README.md:121-124);gem install pgmatches the existinggem install rakefix cell in the same table. ReservedCodes reads only docs/idea/03-guardrails.md and wiki/Error-Codes.md, so this table is not a catalogu [trimmed]apps/magik/docs/architecture/03-error-codes.md(edit) — Generated packaged mirror of docs/architecture/03-error-codes.md — same byte-exact rule. Add the same row, with the probe link rewritten the way the renderer rewrites non-packaged targets to raw.githubusercontent.com URLs (see the precedent at apps/magik/docs/architecture/12-runtime-verification.md:303-304), becausescripts/is not packaged into the gem (apps/magik/test/scripts/helper.rb:5). Verify with the read-only mirrors check, never--write.CHANGELOG.md(edit) — Add an entry under the existing## [Unreleased]heading (line 17), in a Keep a Changelog section (### Fixedfits: the probe raised a bare LoadError), saying the optional PostgreSQL probe now reports the missingpgprerequisite asMAGIK_DEV_PROBE_PG_MISSINGwith a runnablefix: gem install pgand exits nonzero, that no dependency was added, and that both the missing and available cases are covered by apps/magik/test/scripts/pg_probe_test.rb. Only the six Keep a Changelog types plusNotesare accepted (scripts/checks/changelog.rb:62).apps/magik/scripts/README.md(edit) — Handoff from editor:docs: docs/architecture/03-error-codes.md now namesapps/magik/scripts/probes/as the third emitter of repo-internalMAGIK_DEV_*codes, alongsidebin/andapps/magik/scripts/checks/. — apps/magik/scripts/README.md:121-131 states the repo-internal rule as codes 'emitted by this repository's own scripts and checks' and then says a finding 'shares the token with theMAGIK_DEV_*refusalsbin/setupandbin/rakeprint' — it enumerates findings plusbin/and omits probes, so it is now an incomplete list of the emitters. Add the probe to that enumeration (e.g. thatapps/magik/llms.txt(edit) — [docs] Line 123 enumerates where the repo-internal namespace comes from: "everyMAGIK_DEV_*code, which is repo-internal — the refusalsbin/prints and the findingsapps/magik/scripts/checks/emits, both of which ship to nobody and are in no catalogue". That was exhaustive before this diff; the diff added a third emitter (MAGIK_DEV_PROBE_PG_MISSINGfrom apps/magik/scripts/probes/pg_concurrency.rb) and updated the parallel sentence in docs/architecture/03-error-codes.md:245 ("Two things" → "Three things") but not this one. Add the probes diagnostic to the enumeration. Name the [trimmed]Verification
./bin/checkpassed (exit 0) in 1m 35s.What the editors ran to see the change working, and what they saw:
ruby -Iapps/magik/lib -Iapps/magik/test apps/magik/test/scripts/pg_probe_test.rb(probe): Finished in 0.43877s — 2 tests, 23 assertions, 0 failures, 0 errors, 0 skips.T=$(mktemp -d); GEM_HOME="$T/g" GEM_PATH="$T/g" ruby apps/magik/scripts/probes/pg_concurrency.rb(probe): EXIT=1, stdout_bytes=0; stderr: "MAGIK_DEV_PROBE_PG_MISSING: the pg gem is not installed (cannot load such file -- pg)" then " cause: this probe opens one PG connection per thread to time concurrent SELECT pg_sleep(S) queries, which needs the pg gem" then " fix: gem install pg". No backtrace.RUBYLIB=<tmpdir with a stub pg.rb> DATABASE_URL=postgres://stub/none MAGIK_PROBE_SLEEP=0 MAGIK_PROBE_THREADS=2 ruby apps/magik/scripts/probes/pg_concurrency.rb(probe): EXIT=0, stdout "ruby 3.4.10 ... \n pg 0.0.0-stub, 2 threads x pg_sleep(0.0)\n elapsed 0.01s ...", stderr empty — the pg-present path is unchanged and prints no MAGIK_DEV_PROBE_PG_MISSING.Mutation: sub the begin/rescue block back to a bare 'require "pg"', then run pg_probe_test.rb against the mutant via a PROBE constant override(probe): MUTANT_EXIT=1 — "Expected "internal:.../kernel_require.rb:136:in 'Kernel#require': cannot load such file -- pg (LoadError)\n\tfrom .../pg_concurrency.rb:26:in ''\n" to include "MAGIK_DEV_PROBE_PG_MISSING:"", 2 tests, 1 failures. The missing-case test fails when the rescue is removed.ruby -c apps/magik/scripts/probes/pg_concurrency.rb; ruby -c apps/magik/test/scripts/pg_probe_test.rb; awk 'length > 120' on both(probe): Syntax OK for both; no line exceeds the repo's 120-char Layout/LineLength limit.ruby apps/magik/scripts/checks/shipped_mirrors.rb && ruby apps/magik/scripts/checks/changelog.rb(docs): shipped-mirrors: pass (173ms) — 29 packaged mirrors are current, generated from the checkout's docs/ originals; MIRRORS_EXIT=0; changelog: pass (33ms) — ../../CHANGELOG.md: 2 sections, [Unreleased] present, 0.0.1 covered; CHANGELOG_EXIT=0GEM_HOME= GEM_PATH= ruby apps/magik/scripts/probes/pg_concurrency.rb > /tmp/pg.out 2> /tmp/pg.err(docs): EXIT=1; stdout empty; stderr exactly the three lines I documented: 'MAGIK_DEV_PROBE_PG_MISSING: the pg gem is not installed (cannot load such file -- pg)' / ' cause: this probe opens one PG connection per thread to time concurrent SELECT pg_sleep(S) queries, which needs the pg gem' / ' fix: gem install pg' — so the doc block in 12-runtime-verification.md matches the shipped message byte-for-byteruby apps/magik/scripts/checks/shipped_mirrors.rb(docs): shipped-mirrors: pass (236ms) — 29 packaged mirrors are current, generated from the checkout's docs/ originals (exit 0), confirming apps/magik/docs/architecture/03-error-codes.md is byte-identical to the renderer's output for my edited source pageruby apps/magik/scripts/checks/changelog.rb(docs): changelog: pass (32ms) — ../../CHANGELOG.md: 2 sections, [Unreleased] present, 0.0.1 covered (exit 0)GEM_HOME= GEM_PATH= ruby apps/magik/scripts/probes/pg_concurrency.rb(docs): exit 1, stdout empty, stderr exactly: 'MAGIK_DEV_PROBE_PG_MISSING: the pg gem is not installed (cannot load such file -- pg)' then ' cause: this probe opens one PG connection per thread to time concurrent SELECT pg_sleep(S) queries, which needs the pg gem' and ' fix: gem install pg' — the rendered shape both my files documentNotes
Handoffs this run could not complete:
CHANGELOG.md— The optional probe apps/magik/scripts/probes/pg_concurrency.rb no longer dies with a bare LoadError when the pg gem is absent; it prints a structured MAGIK_DEV_PROBE_PG_MISSING diagnostic on stderr and exits 1. A new test file apps/magik/test/scripts/pg_probe_test.rb pins both the missing and available cases.; The task's acceptance criteria require CHANGELOG.md to carry an [Unreleased] entry for this change under a Keep a Changelog section (an entry under### Fixedor### Changed), and CHANGELOG.md is outside my file fence. Suggested line: under [Unreleased], note that the optional pg probe reports MAGIK_DEV_PROBE_PG_MISSING with a runnablefix: gem install pgon stderr instead of a bare LoadError, and that no pg dependency was added. (the editor sent to make it neither wrote it nor said why not)CHANGELOG.md— The pg probe's missing-prerequisite exit code changed from 1 to 69 (EX_UNAVAILABLE); the probe, its test and both copies of docs/architecture/12-runtime-verification.md now say 69.; The finished task requires CHANGELOG.md to carry an [Unreleased] entry under a Keep a Changelog section for this change. Outside my brief (apps/magik/scripts/, apps/magik/test/scripts/, docs/architecture/12-runtime-verification.md and its mirror),…(truncated)
Part 1/2 of a goal
🤖 Opened by developerz.ai, an automated agent, not a human, on developerz-ai/magik.
Raised automatically by a developerz.ai maintainer lane.