Skip to content

[MAINTENANCE] Pin the registered backend set by equality over an ordered literal - #12037

Draft
joshua-stauffer wants to merge 1 commit into
f/sql-harness/singlestore-backendfrom
f/sql-harness/registered-set-pin
Draft

[MAINTENANCE] Pin the registered backend set by equality over an ordered literal#12037
joshua-stauffer wants to merge 1 commit into
f/sql-harness/singlestore-backendfrom
f/sql-harness/registered-set-pin

Conversation

@joshua-stauffer

Copy link
Copy Markdown
Collaborator

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 project 55 → 56. SingleStore 11, SQLite 556, PostgreSQL 472, SQL Server 181 all at baseline;
tests/integration and tests/metrics collect unchanged. The whole module also passes with all nine
SQL 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.

ruff clean. mypy adds no diagnostics over an untouched-file baseline.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant