[MAINTENANCE] Pin the registered backend set by equality over an ordered literal - #12037
Draft
joshua-stauffer wants to merge 1 commit into
Draft
[MAINTENANCE] Pin the registered backend set by equality over an ordered literal#12037joshua-stauffer wants to merge 1 commit into
joshua-stauffer wants to merge 1 commit into
Conversation
The registry had no assertion over its full membership. Two existing tests prove label ordering, but each re-registers a named subset inside the test isolation seam, so neither says anything about what the real registry holds. This names all nine registered backends in one ordered literal and asserts equality. The shape is the point. A subset, membership or count check would let a tenth backend register and pass silently; equality makes registering a config and extending this literal one change with one failure signal, rather than a widening nobody notices until something downstream quietly sees one more backend than it expected. It reads the registered set from a snapshot taken when this module is imported, because the module's own isolation fixture clears the registry around every test - a call-time read inside a test body would compare nine named classes against an empty tuple. Worth being precise about what this proves on top of the module importing at all. The lane running it installs no SQL driver, and a backend module that fails to import takes the package down with it, so importability is established by the import statement rather than by any assertion. What this adds is that all nine modules actually registered: importing a module and enrolling from it are separate events, and only the second is observable here. The two neighbouring subset literals are left alone. They look alike - same classes, same trailing comments - so a note now points at which one has to grow when a backend is added.
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.
Stacked on #12036 — review the earlier PRs in this series first. This PR shows only its own commit;
GitHub retargets it as its parents merge.
The registry had no assertion over its full membership. Two existing tests prove label ordering, but
each re-registers a named subset inside the test isolation seam, so neither says anything about
what the real registry holds.
This names all nine registered backends in one ordered literal and asserts equality.
The shape is the point
A subset, membership or count check would let a tenth backend register and pass silently. Equality
makes "register the config" and "extend this literal" one change with one failure signal, rather than
a widening nobody notices until something downstream quietly sees one more backend than it expected.
Proven in all three directions rather than asserted: removing a class fails it, reordering two
classes fails it, and — the case a subset check would miss — registering a tenth backend into the
real registry, at the same moment a real backend module's decorator would run, fails it too.
Reading the registry without reading nothing
The pin reads a snapshot taken when the module is imported, because the module's own isolation
fixture clears the registry around every test. Measured directly from inside a test body: the
snapshot holds 9 while a live read returns 0. The naive shape here isn't merely weaker, it's
impossible.
What this proves, precisely
The lane running it installs no SQL driver. But a backend module that fails to import takes the whole
package down with it, so importability is established by the import statement — every test in the
module carries that. What this assertion adds is that all nine modules actually registered:
importing a module and enrolling from it are separate events, and only the second is observable here.
That distinction was checked rather than assumed, by blocking a single backend submodule and
observing that collection dies rather than the assertion failing. The docstring states the narrower,
true claim.
A note left for the next editor
The four-class subset literal further up the module looks almost identical to this one — same
classes, same trailing label comments — and only this one has to grow when a backend is added. A
comment now says so. That confusion is not hypothetical: it produced two false "the pin doesn't
fail" results during this change's own verification before the mutations were re-targeted by line.
Verification
-m project55 → 56. SingleStore 11, SQLite 556, PostgreSQL 472, SQL Server 181 all at baseline;tests/integrationandtests/metricscollect unchanged. The whole module also passes with all nineSQL driver packages made unimportable.
MySQL could not be exercised in this run — its container shares a port with SingleStore's — so it is
covered by the earlier PRs in this series and by CI.
ruffclean.mypyadds no diagnostics over an untouched-file baseline.