Custom login selection rollout
This procedure prepares digest-bound admission for custom login selection and describes its rollback. Apply it to a compatible candidate release. Release documentation and isolated tests do not prove that an installation has completed enrollment or activation: the responsible operator must retain actual installation-specific evidence and authorize cutover.
The repository user page docs/user/login-selection.md describes sign-in behavior.
A source inventory distinguishes inspected tests
from runtime evidence and records remaining acceptance work. Publishing these pages does
not enable the feature or certify a deployment.
Roles and schema
Section titled “Roles and schema”Load operator credentials into DATABASE_URL through the installation’s protected environment.
Never put a connection string, password, cookie or signing secret in a command, issue or receipt.
The cluster commands use those credentials and the database selected by -d.
Converge schema using the release’s supported module upgrade/schema procedure before starting
its native server. Core DDL installs the feature tables and capability column; authentication
inserts auth.login_principal, version 1, disabled only when absent. Repeated synchronization
preserves activation, enrollment, approvals, counters and trust. Initial schema migration can require
table locks and belongs before serving; repeated converged node DDL checks catalogs before column
changes and leaves the membership and feature tables unlocked. Validation examines the actual
principal CHECK/index definitions and helper identities, rather than trusting a version setting.
The candidate needs explicit first helper provisioning/publication before serving, including when selection stays disabled. Ordinary runtime grants alone are insufficient. The supported release and clone preparation paths call the shared deployment helper. Schema migration must finish first. For an installation managed separately from these scripts, the equivalent explicit DBA sequence below remains available.
Provision an isolated maintenance role through the database administrator:
CREATE ROLE erp_node_feature_maint NOLOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;It must not own the tables, reach the database owner, or have business/session data privileges. Request and heartbeat roles must not reach it through INHERIT, SET or ADMIN paths. Keep those roles distinct. Do not substitute a LOGIN/operator role if publication fails. The trusted application owner needs one-way maintenance-role membership for repeat ownership management; the maintenance role must never inherit the application owner.
Publish ordinary runtime/heartbeat grants, then the narrow feature helpers:
erp cluster login-selection publish -d <db> --maintenance-role <maint> --request-role <runtime>Publication validates fixed helper bodies and execution attributes, grants request EXECUTE, transfers ownership to the maintenance role, and installs an ALWAYS INSERT/UPDATE row trigger. Request receives no node/feature relation rights. Heartbeat receives no feature-state or auth data rights. Re-publish after role-policy changes; inherited or column grants crossing these boundaries need explicit reconciliation.
The deployment-only sidecar login-selection-publication.toml has exactly these keys:
database = "tenant_database"maintenance_role = "tenant_login_helpers"provisioner_role = "tenant_role_provisioner"operator_database_url_file = "login-publication-operator-url"Keep both files private (mode 600 regular files, no symlinks), outside git and outside the serving container’s mounts. The operator URL must name that database at the same endpoint as the owner/runtime/heartbeat credentials. The application owner remains NOCREATEROLE. The shared release preparation will create an absent safe role or validate an existing role, then use the candidate’s ordinary and feature publication commands before switching or clone startup. Clone preparation must rewrite every credential binding to its isolated tenant and use a clone-specific maintenance role. The original tenant is never an implicit fallback.
Use a dedicated non-superuser CREATEROLE provisioner with CONNECT to this tenant. Its URL is read only for first provisioning/publication. After a valid maintenance role and owner membership exist, the file can be removed: repeat publication probes and uses only the application owner. PostgreSQL gives the creator an ADMIN-only membership in a created role, without INHERIT or SET, issued by the bootstrap superuser. The limited creator cannot revoke that grant. This residual is allowed only for the dedicated CREATEROLE administrator. The application owner gets INHERIT+SET without ADMIN. An extra owner grant carrying ADMIN is refused even if a separate safe owner grant exists; reconcile it explicitly rather than expecting publication to repair it. Request/heartbeat roles cannot reach creator, owner or maintenance through any membership path. Never grant runtime roles membership in the provisioner.
A failed or timed-out preparation never authorizes switching. Earlier steps may have committed;
inspect the protected login-selection-publication.log (written by the helper command and by the
release preparation, and named in the error message; its first line is a UTC timestamp so a stale
log is recognizable), reconcile catalog state, and repeat the same policy. Do not drop roles or
reset counters, approvals, enrollment, generation or trust. Every publication re-checks that no
feature is enabled and no digest is approved after each publication step, not only on the
version-1 rollback path. This step never enables selection.
Version-1 rollback remains supported with a known recovery limit: its publisher and startup
require broad runtime access, so the runtime role can write retained feature tables during that
period. Disable features and remove digest approvals before rollback. Restore, grant reassertion and activation of a v1 artifact over active v2 save the exact bounded feature and
digest rows in the mode-600 login-selection-rollback.json before invoking v1 grants. Keep this
file outside runtime mounts. Roll-forward compares it before publication, revokes broad grants,
republishes helpers as owner, and checks state again before switching. Changed state refuses
with Login feature state changed during v1 rollback; operator reconciliation required.
Do not delete or overwrite a damaged/mismatched guard to bypass this refusal. Reconcile changes
with the responsible operator. Every publication, including repeats and guarded roll-forward,
requires disabled, unapproved feature state. Even an exact fingerprint cannot admit enabled
or approved rows in this rollout. Preserve the guard until successful narrowing; publication clears it afterward.
--activate also refuses, before anything is published or switched, a candidate whose runtime
grant contract is older than the active release’s (for example v2 over v3 or v4) and a
pre-contract candidate over a release that declares a contract. Use --rollback to a recorded
previous release, or reconcile with the operator.
For a return to the identical already-migrated v2 artifact after v1 rollback, retain its verified
package and original successful forward-migration receipt, then use
python3 -I scripts/human-release.py <same-40-hex-source> --activate. This repeats publication
and identity validation without rerunning migrations or rewriting installed receipts. A fresh
candidate still uses the normal clone/migration gates. Do not rerun the first-upgrade wrapper
against an OLD preimage after candidate receipts have already been stamped. Missing or changed
artifacts, receipt, source kind, migration witnesses or registry state require reconciliation.
The clone migration gate creates separate clone LOGIN roles and credential files, restores under its own owner, and records a clone-specific publication policy. The coordinated/package clone steps reuse those bindings. No dev/testing serving role is granted clone membership. The trusted provisioner retains PostgreSQL’s ADMIN-only creation grants on its newly created clone roles. No source tenant is a fallback.
Each clone keeps all of its private files in its own directory, STATE/clones/CLONE/ (mode
0700, created exclusively): server.toml, login-selection-publication.toml, the owner, request
and node URL files, operator-url, and the clone’s own rollback guard and
login-selection-publication.log. A clone therefore never reads or writes the dev/testing guard or
log, and a second creation for the same clone name refuses until the directory is removed. The
clone’s operator-url (the role-creation credential) is consumed by the first helper publication
on the clone, which in the deployment chain is the human-clone-start.py --phase pre startup
rehearsal (the package and coordinated clone steps do the same when they publish first; that
rehearsal also writes a failed publication’s diagnostic to the clone’s
login-selection-publication.log): it is removed once first provisioning commits, and
only when it lives in that clone directory (the dev/testing credential is never touched by this
path). A failed provisioning keeps it so the step can be retried.
human-clone-upgrade.py SHA --drop and --replace remove the clone’s database, its four
roles (owner, request, node, maintenance) and its directory, plus any file of the earlier
STATE/clone-SHA8-* layout. Dropping the roles needs the dev/testing provisioner credential.
When the credential is missing, the files are still removed, the command prints the roles that
remain and exits nonzero (Clone database dropped; clone roles remain (...); the provisioner credential is unavailable: restore it and rerun --drop). When the credential is present but the
drop fails, the exit message says so and names the protected diagnostic
clone-cleanup-SHA8.log in the state directory; the remaining roles hold passwords nobody
knows, so rerun --drop after reconciling. A file that cannot be removed is reported the same
way after the JSON record is printed. A leftover clone directory refuses new clone steps with
Clone directory exists; run human-clone-upgrade.py SHA --drop or --replace; after a
role-creation failure whose outcome is unknown (roles may exist) a plain rerun is refused or
fails on the existing roles, so rerun with --replace or --drop. A clone left in the earlier layout makes the new
clone steps refuse with Legacy clone layout found; run human-clone-upgrade.py SHA --drop first. If the final --drop of human-deploy-host.sh fails, the release is already active:
the script prints release SHA is active; gate clone cleanup incomplete; rerun human-clone-upgrade.py SHA --drop and exits nonzero. The coordinated path keeps its clone for
validation and recovery; run --drop when done. The package grants step prints a JSON record
(clone-grants or grants) like every other step.
Operational limits, accepted for the dev/testing cluster:
- Role passwords are created with
CREATE ROLE ... PASSWORD '<hex>'. Withlog_statement=ddlthe cluster’s server log can contain them. Clone roles are short-lived and removed by--drop; a client-side SCRAM verifier would need a native login proof and is a possible follow-up. Child diagnostics are scrubbed of password literals (also truncated ones) and 64-hex tokens. - The helper strips
PGSSLMODEand the other libpq variables, and every endpoint is loopback. A TLS requirement needs a reviewed policy key; until then the helper is for loopback endpoints. - The rollback guard fingerprints the feature and digest rows, not catalog objects. The pinned v1 publisher grants no TRIGGER or ALL PRIVILEGES (a test checks the fixture), and rules and policies need ownership; privileges issued by the v1 helper functions that the fixture does not extract are unverified.
Enrollment before first activation
Section titled “Enrollment before first activation”Membership cannot discover an older standalone Auth service. Before confirmation, inventory all
serving processes and endpoints, drain/retire old endpoints, fence legacy LOGIN roles and every
inherited credential path, and close their existing database sessions. A password rotation alone
does not close existing sessions. Retain actual evidence. An empty erp_node listing proves
nothing about standalone clients. The isolated role-fencing test is a rehearsal of this procedure,
not proof that an installation has completed it.
Start compatible binaries with selection disabled. The native binary contributes the fixed capability to its combined digest; a runtime flag cannot manufacture support. Native registration precedes Auth composition; readiness follows composition. Startup failure shuts down its new membership with a bounded cleanup. Registry refresh creates a fresh binding; a changed local addon catalogue requires draining and restarting membership.
Installed package archives are part of that catalogue even when their source directories are absent from the release’s addons paths. Startup verifies the stored packages against their lifecycle audit, capabilities and component declarations before registering membership. Composition rechecks the catalogue after loading the registry, before publishing authentication, RPC or assets. Install, upgrade or removal that changes package identity requires draining and restarting the native membership; a same-name archive replacement is also an identity change. Ordinary registry refresh with unchanged package identity remains supported. Never bypass this refusal by approving an unverified digest or disabling the registry coverage check.
Before deploying a startup-admission change, rehearse readiness and login on an isolated clone with the installation’s actual installed addons and packages. A migration-only clone check does not establish startup acceptance. Preserve the existing private rollback guard for roll-forward; this catalogue correction does not enable login selection.
A bound credential override currently refuses authentication/identity verification with a SESSION message, including while disabled. The legacy unbound base constructor remains available for its existing use. Selection plus credential composition remains unsupported until SESSION. Account for this native compatibility limit when choosing addons for the candidate release.
Inspect, approve and enable
Section titled “Inspect, approve and enable”erp cluster login-selection status -d <db>erp cluster nodes -d <db>erp cluster login-selection approve -d <db> --digest <exact-combined-digest>erp cluster login-selection enable -d <db> --confirm-legacy-drained-and-fencedStatus reports enabled state, generation, required version, approved digests and the count of incompatible fresh/recent non-stopped memberships in one observation. Missing or malformed state is an error. Activation names an offending node/digest when membership is incompatible.
Approve only a fresh registered candidate with the exact required capability. Approval is
idempotent while disabled; disable before changing approvals. There are at most 32 approvals per
feature and eight registered feature keys per database. Activation requires an approval and
rejects incompatible starting, ready, unready, dev and stopping peers, including recently expired
rows within their own lease horizon. Draining alone does not establish quiescence. Ordinary
cluster rollout windows remain necessary for distinct compatible digests and cannot authorize
this feature themselves.
The confirmation flag records the operator’s external drain/fencing acknowledgement. The command cannot perform or attest that inventory automatically. After enable, verify each service’s serving admission, alias-to-canonical session behavior and shared principal budget using actual endpoints. Retain exact source/artifact identities, commands and raw output. An old-statement test is SQL emulation; only an actual retained executable can support an old-binary claim.
Disable and rollback
Section titled “Disable and rollback”erp cluster login-selection disable -d <db>erp cluster login-selection status -d <db>Await confirmed disable. It holds exclusive feature protection and waits for earlier protected finalizations. A hash still in flight cannot subsequently publish a session against the old generation, even after re-enable. Already committed sessions retain their normal semantics. Completed failed guesses retain authoritative accounting after disable or caller cancellation. A caller that disconnects after its password was accepted does not cancel the login: the verdict runs to completion in its own task (the session is written once and the table guard is released), so a cancelled request can still leave a valid session that nobody received.
Disabling does not rewrite an addon’s selection hooks into base hooks. Custom-selection services refuse new sign-ins while disabled; arrange compatible base-login services before promising users that ordinary stored-login sign-in has resumed.
If helper publication returns a COMMIT/store error, its outcome is not a success acknowledgement. Inspect catalog ownership/attributes through the supported startup validation and re-publish the same isolated role policy before serving; do not infer rollback from a lost acknowledgement.
An actual enabled-state change increments generation once; repeated enable/disable is idempotent. A lost COMMIT acknowledgement is unknown, never success or confirmed rollback. Reconcile status before acting again. Store failures retain their internal cause; public login responses use the existing safe error mapping.
Then drain/replace custom-selection services before admitting an older release. Use that release’s own compatible grant publication and startup checks. Keep the feature schema, counters and trust rows. Do not reset security data or invent historical alias-to-uid backfill. Keep actual rollback results separate from plans, and verify the restored release before it serves.
Operational limits
Section titled “Operational limits”Principal counters and trust are tenant-local PostgreSQL state. While active, bound canonical base login and aliases share the selected uid budget across services. Disabling and successful login clear no counters. GC and secret-rotation semantics remain those of the existing auth system; this procedure introduces no retention or rotation schedule.
The database gate protects the supported binary/role protocol. It does not attest hostile native code or retrofit undiscovered old clients. The database owner remains trusted. Product latency, allocation, memory and throughput evidence is DEFERRED_PERFORMANCE under ADR 0065. Functional security, admission bounds and semantic query/flight contracts remain required.
The sidecar pins the nonsecret provisioner_role name. Repeat policy validation allows the
ADMIN-only creation grant only for that exact role, even after its URL file is removed; an
unrelated CREATEROLE member is refused. The supplied first-use URL must match that name.
Creating a new clone requires role-creation authority again, and so does dropping its roles
(--drop, --replace). If the provisioner URL was removed after live first publication, restore
it temporarily through the protected operator procedure for clone provisioning and cleanup, then
remove it again. The normal repeat publication path still requires no
creation credential. Clone backup/restore needs PostgreSQL 18 clients matching the supported
server; do not silently use an older pg_dump.