Skip to content

Keep reinstalls from widening the standard env - #13

Merged
lemuelroberto merged 2 commits into
emfga:mainfrom
lemuelroberto:reinstall-standard-env
Oct 30, 2026
Merged

lemuelroberto merged 2 commits into
emfga:mainfrom
lemuelroberto:reinstall-standard-env

Conversation

@lemuelroberto

Copy link
Copy Markdown
Member

Stacked on #12. Merge #12 first. Until it lands, this diff also includes #12's commit.

Bug

The upgrade job from #12 turned this up. The core scripts (030, 060, 070) put "everything registered so far" into the standard env:

INSERT INTO cel.env_item (env, kind, ref)
SELECT 'standard', 'overload', id FROM cel.overload ...

On a fresh install that set is just the core, because the extension scripts run afterwards. But the installer is also the upgrade path. Running it over an existing schema picks up every extension's items and every consumer registration. An in-place upgrade from 0.0.2 put 139 extension overloads, 16 macros and 3 types into standard, and the consumer's own overload as well. The conformance suite stayed green, because a wider env doesn't break any corpus case. That is the "extension enabled by default in standard" failure CLAUDE.md warns about.

This hits anyone who re-runs a bundle over an installed schema. fga4postgres updating its vendored bundle is one such case.

Fix

  • cel._unclaimed(kind, ref, impl): the sweeps now pick only rows that no env claims yet and whose implementation (if there is one) lives in the cel schema.
  • Repair: the installer removes from standard anything a shipped extension env also lists. This is idempotent, and it matches nothing on a fresh install. A consumer row that an earlier reinstall swept into standard can't be told apart from one a user put there deliberately, so those are left alone.
  • scripts/upgrade-check.sh now asserts that after an upgrade, standard contains neither the consumer overload nor any item that another env also lists.

Rds-distribution decision 7 (an origin column) is still the general fix. This guard covers the gap until that lands.

Verified locally

  • Fresh install and upgraded 0.0.2 → 0.0.3 (plain and pg_tle) now have identical env_item counts per env. The upgraded database has one extra row, the consumer's.
  • Without this fix, the new assertion fails with 158 leaked items. With it, both channels pass.
  • go test ./... passes against the fresh database and both upgraded databases. shellcheck and build-release.sh both pass.

A consumer who installed 0.0.2 upgrades by running the next
artifact over it, and nothing so far checked that this works or
that it leaves their own registrations alone. Releasing without
that check is how the first broken upgrade reaches a database
nobody can reinstall casually.

The upgrade workflow installs the latest published release through
each shipped channel, registers a consumer overload, upgrades to
the build at hand -- psql over the old schema, or pg_tle's ALTER
EXTENSION UPDATE through a registered update path -- and then runs
the whole suite against the upgraded database, since an upgraded
install has to be exactly as conformant as a fresh one. CI runs it
on every pull request so a breaking change is caught where it is
made, and the release workflow's publish job needs it, so no tag is
cut without it.

The upgrade is the idempotent installer alone. The delta-script
convention for drops and signature changes stays unbuilt until a
release needs one; this job is what will say so.
The core scripts enable "every overload, type and macro registered
so far" in standard. On a fresh install that is the core alone,
because the extension scripts run afterwards. But the installer is
also the upgrade, and run over an installed schema the same sweep
picks up every extension's items and every consumer registration:
upgrading 0.0.2 in place put 139 extension overloads, 16 macros and
3 types into standard, plus the consumer's own overload. The suite
stayed green, because a wider env breaks no corpus case -- which is
exactly the failure CLAUDE.md warns about.

The sweep now takes only rows no env claims yet whose implementation
lives in the cel schema, and the installer drops from standard what
a shipped extension env also lists, repairing schemas already
reinstalled. A consumer row swept in earlier cannot be told from one
put in standard on purpose, so it stays. The upgrade check asserts
standard comes out of an upgrade as narrow as it went in.

The origin column of rds-distribution decision 7 is the general fix;
this guard is what the installer needs until it lands.
@lemuelroberto
lemuelroberto merged commit be0340d into emfga:main Oct 30, 2026
3 checks passed
@lemuelroberto
lemuelroberto deleted the reinstall-standard-env branch October 30, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant