Skip to content

test(ci): offline HoopDb Cloud SQL two-login upgrade fixture (#578) - #620

Open
kjgbot wants to merge 3 commits into
mainfrom
test/hoopdb-cloudsql-two-login-fixture
Open

kjgbot wants to merge 3 commits into
mainfrom
test/hoopdb-cloudsql-two-login-fixture

Conversation

@kjgbot

@kjgbot kjgbot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Refs #578

Scope

An offline Infra CI fixture for the two-login upgrade assertion in #578 (spec comments 7256860270 and 7257799942). The new suite is ci/hoopdb-cloudsql-two-login-upgrade/, run by a new hoopdb-two-login-upgrade job in lint.yml. It covers both login baselines, effective-access probes, the refusal cases and drift refusals on a disposable PostgreSQL 16. The positive upgrade case is explicitly pending, because no supported Pipeline upgrade sequence exists at the pin.

This PR changes no chart, guide, values note or Pipeline SQL, and bumps no version. It never connects to a real database, Cloud SQL instance or cluster.

How the starting state is built

The suite follows the same path a real Cloud SQL install takes through docs/gcp-install/cloud-sql-setup.sh:

  1. Guide pre (HoopDb part), run as the Cloud SQL administrator:
    • CREATE DATABASE hoopdb, pg_trgm and btree_gin.
    • The pinned cloudsql_migration_roles.sql.
    • The guide's ownership transaction, copied verbatim: the role-creator trampoline creates hoopdb_owner, sessions_pipeline_runtime and search_consumer_runtime, takes ownership, creates the schemas and applies cloudsql_owner_function_default_revoke.sql.
    • The four pinned role bootstraps.
    • The guide's check that no protected role has a membership edge.
  2. The pinned migrator (src/hoopdb/migrate.ts, 126 migrations) runs as hoopdb_owner. It uses the GCP chart's migration profile from values-gcp.yaml worker.migrations: cloudsql, no shim, no role bootstrap, runtime sessions_pipeline_runtime LOGIN, global-default-revoke.
  3. bulls96_legacy_export_privacy is removed to model an install that predates it (see "Emulated" below).
  4. Guide post-roles: the guide's exact statements promote bulls96_read_api and bulls96_session_ingest to LOGIN NOINHERIT:
    • ingest: statement_timeout=5s, lock_timeout=2s, idle_in_transaction_session_timeout=10s
    • reader: statement_timeout=2s, default_transaction_read_only=on
  5. Guide post (dedicated-owner layout), run as hoopdb_owner:
    • The filtered session_read_api_role.sql and session_ingest_role.sql, with the same sed and refusal as the guide.
    • GRANT CONNECT.
    • The pinned session_read_api_role_verify.sql, session_ingest_role_verify.sql and session_ingest_verify.sql.
    • A login check for each runtime login.

Passwords for every login are generated at runtime and stored in a mode-700 temp dir. They reach psql only by environment name (docker exec -e NAME, \getenv), never on a command line, and log_min_error_statement=panic. After setup, every login uses scram-sha-256, and the suite checks that a wrong password is rejected. Before finishing, the suite greps every artifact and the server log for each generated password and fails if one is found.

Emulated vs real

Real (pinned):

  • The Pipeline bootstrap SQL, migrator, migrations and verifiers at 60980e0e.
  • The guide's ownership transaction, promotion statements, filtering and post steps.
  • PostgreSQL 16.16, including the PG16+ CREATEROLE/ADMIN semantics.
  • scram-sha-256 password logins for every role.

Emulated:

  • cloudsqladmin is the bootstrap superuser (POSTGRES_USER), so PG16's automatic creator edges name it as grantor, as on Cloud SQL. On Cloud SQL it is Google-internal. Here the fixture logs in as it to set up the cluster, inject drift and read catalogs.
  • cloudsqlsuperuser is a NOLOGIN CREATEROLE CREATEDB role. The administrator postgres is a non-superuser LOGIN CREATEROLE CREATEDB member of it.
  • Cloud SQL's own extensions to what cloudsqlsuperuser members may do are not emulated. On vanilla PG16 the administrator holds no ADMIN option on the trampoline-created roles. The guide's ALTER ROLE ... LOGIN promotion as the administrator is therefore refused with 42501 permission denied to alter role. The suite records this as an observation and runs the guide's exact statements as cloudsqladmin. Whether real Cloud SQL accepts the promotion from the administrator is not established here.
  • bulls96_legacy_export_privacy absent: the pinned bootstrap creates it and migration 062030 requires it. The suite therefore removes it (DROP OWNED, DROP ROLE) after the pinned migrate. A real older install never had the role, and its schema would be an older migration prefix. No older Pipeline pin is used.

Not emulated:

  • TLS (verify-full), IAM and private services access.
  • The Kubernetes Jobs and the services image.
  • The relaycontrol and relaycast databases.
  • The vector extension (no pinned migration needs it).
  • Cloud SQL flags.
  • The Pipeline proofs pin Cloud SQL to PG17; this fixture runs PG16, as this issue asks.

Pins

ci/hoopdb-cloudsql-two-login-upgrade/pipeline.pin and pipeline-files.sha256. fetch-pipeline.sh clones into a new, empty directory and verify-pipeline.sh refuses any mismatch. Dependencies are installed with bun install --frozen-lockfile --ignore-scripts inside the pinned Bun container.

  • relayhistory-pipeline commit 60980e0eb5a7632a188a293aa37452cee0c3885c; trees supabase/migrations 57ef3b92de4529827314422efaf8806ca11be094, supabase/bootstrap 54189b06ea9a52faa3a888558d0b4a29675726b0
  • sha256:
    • cloudsql_migration_roles.sql 18c9b73e5b2c17cf0044e69cfb110e62a18382d370d330581fda314f9491b614
    • legacy_export_privacy_roles.sql fb9160f576b316ce49b99590267c7945305eb866b9f9e6e1f41b1d922b61c62e
    • session_ingest_verify.sql df835f634acc621d0a89a4cc6c63b21777e480800b35272b934de457101bdb6c
    • session_read_api_role_verify.sql 0779e4521f6912a8e2d03da7fd65a894f869dfb70ae61ef6e073edd642b2a0f6
    • session_ingest_role_verify.sql b25f1c1bf6e1eb75c5e0132d09c46310ab25d2e0b2c2de156369ef5fbf9ebaf3
    • session_ingest_role.sql b944c30a609fd8ad63d6c86424180c67a23fd8978d949b6e0340bb7b0a9e41a9
    • session_read_api_role.sql 8ab1906b39358947d2f4b6203d5daaf0fb9996bf3c57a4b7a4dba242c40de057
    • session_ingest_roles.sql ff516c34423d7e445fcbfa4f1c6ef04f7a177b94486274b3b6a8458787084553
    • session_read_api_roles.sql 0ab86087d53e1afbfbc1b71ce2131252760aa5f5b91024c02b475729115f2598
    • session_directory_search_worker.sql fadb75e2fb1371d7c139122d2231cc2683da4ed685da715f48668ea848e9cac2
    • session_token_verifier.sql b6a96e9e6328db192041b6f507fe848cc3bc4691747b27f1dd8f714d584425cd
    • cloudsql_owner_function_default_revoke.sql d630b68e6e15824178eb6ed315c2f6a63a7b28329cfbe9c89bcb4546372b1bbb
    • src/hoopdb/migrate.ts f5c6b91f9840ff7d349a7bfd5909b6928e94942b3f0fda11ffe038e1b3b0cdee
    • src/hoopdb/sessions-function-acl.json b7ae24d77c07f62e961b9028af8822a539f7b80949ce4a3ec7e129cdff631d47
    • bun.lock e2f636ed5e955b8653e57444095eecf10d123152eded3589a508bd6d7481eaca
  • Images (multi-platform index digests): postgres:16@sha256:07abc3f43c9395b0bdbbab36bc25ddb0e8d83cd4fcafb5fb7d6abe14ff156dd8, the same digest as the existing RDS eraser test, and oven/bun:1.4.2@sha256:9114c058aeae42162ee16dd5084b95fe9473970bb6bcb5b232ab1630f0546895.

Baseline (per login, separately)

snapshot.sql builds a normalized catalog snapshot by name, with no OIDs and no password material, and compares it exactly with expected/<role>.json. The snapshot covers:

  • Role attributes: LOGIN, NOINHERIT, every privilege-bearing flag false, connlimit and valid-until.
  • Settings: role-wide and per-database, compared exactly.
  • Memberships in both directions, with grantor and admin/inherit/set options.
  • Ownership: objects owned by the role.
  • Default ACL entries naming the role.
  • Effective privileges, including PUBLIC-derived ones:
    • database privileges
    • schema privileges
    • table, column and sequence privileges
    • grant options
    • EXECUTE on every non-extension function, with its SECURITY DEFINER flag
    • a count of extension functions
  • Explicit ACL entries that name the role, so the PUBLIC-derived difference is visible.
  • RLS: applicable policies and per-relation row-security state.

The baseline check fails if any of these layers fails:

  • invariants
  • exact-settings: ingest idle_in_transaction_session_timeout=10s, lock_timeout=2s, statement_timeout=5s; reader default_transaction_read_only=on, statement_timeout=2s. These are exact, not containment.
  • snapshot: exact diff against the expected file.
  • definer-execute: EXECUTE only on SECURITY DEFINER functions.
  • definer-execute-allowlist (ingest): exactly the 81 entries of the pinned verifier's v_allowed.
  • pinned-verifier.

Cases and expected results

# Case Expected
1 Baseline bulls96_session_ingest pass
2 Baseline bulls96_read_api pass
3 Ingest probe: session settings 5s/2s/10s, ingest_turn_capability('{}') returns registered-v1; SELECT session_index.session_id and an INSERT raise 42501 pass
4 Reader probe: settings 2s / read-only; sees only its synthetic tenant's session_id (tenant A, tenant B, unbound, mixed); SELECT title raises 42501; a write raises 25006 pass
5 (a) Full bootstrap rerun as the administrator on the activated baseline raises 55000. The error names exactly the two logins' LOGIN and role-settings problems. bulls96_legacy_export_privacy is still absent, no trampoline is left, and both logins' snapshots are unchanged pass
6 Pinned standalone legacy_export_privacy_roles.sql as the non-superuser administrator is refused 42501 (caller may not create it); the role is still absent pass
7 (b) Whole-table SELECT on sessions.session_index granted to the reader fails the baseline pass (refused by snapshot and pinned verifier)
8-9 (c) CREATEROLE on ingest, and on the reader, fails the baseline and is still refused after the bootstrap rerun, which preserves the drift pass
10-11 (c) Membership in cloudsqlsuperuser for ingest, and for the reader, fails the baseline and is still refused after the rerun pass
12 Extra per-database setting on the reader fails the baseline pass (refused by exact-settings and snapshot; the pinned reader verifier alone accepts it)
13 Extra role-wide setting on ingest fails the baseline pass
14 Ingest EXECUTE on a definer function outside the pinned allowlist fails the baseline pass
15 A PUBLIC-derived SELECT (sessions.turn_writers TO PUBLIC) fails the ingest baseline pass
16 Positive upgrade: a supported Pipeline sequence creates bulls96_legacy_export_privacy NOLOGIN NOINHERIT with no elevated flags, settings or membership edges, then both logins' baselines and probes are rerun pending: "needs a pinned supported Pipeline upgrade sequence; see #578"
17 Final: both baselines and probes still hold after every case; the privacy role is still absent pass

Every drift case reverts and requires the baseline to pass again before the next case runs.

The pending case is recorded as pending in results.json, raises a ::warning annotation and appears in the step summary. The suite exits non-zero unless exactly one case is pending and none failed, so the pending case can never become a silent pass. When Pipeline pins a sequence, set UPGRADE_SEQUENCE to a file of <admin|owner> <pipeline-relative .sql> lines and the positive case runs its checks. As a sanity check, running locally with an empty sequence correctly fails it, because the role is still absent.

Results

Local (Docker Desktop, PostgreSQL 16.16 container capped at 768 MB, Bun container at 768 MB/1 GB, through the shared heavy queue): 16 passed, 0 failed, 1 pending, 1 observation. No generated password appears in any artifact or in the server log.

CI, on the hoopdb-two-login-upgrade job in lint.yml (GitHub-hosted runner, PostgreSQL 16 service container, no published port):

  • Head 8589d665, job 141401045258: 16 passed, 0 failed, 1 pending, 1 observation on PostgreSQL 16.16 with Pipeline 60980e0e. No generated password appears in any artifact or the server log. The case table is in the job's step summary, and results.json and per-case logs are in the hoopdb-two-login-upgrade artifact.
  • The first head failed static only because fast-path.yml was stale. That file is regenerated here with scripts/ci/render-fast-path.py, and static passes on the later heads.

The suite also runs from fast-path.yml's generated lint-hoopdb-two-login-upgrade job.

Review follow-up (Greptile): the final case now requires bulls96_legacy_export_privacy to exist when UPGRADE_SEQUENCE is set, and to be absent otherwise.

🤖 Generated with Claude Code

Disposable PostgreSQL 16 shaped like Cloud SQL (non-superuser CREATEROLE/
CREATEDB administrator in cloudsqlsuperuser) runs the pinned
relayhistory-pipeline 60980e0e bootstrap, migrator and verifiers, activates
bulls96_session_ingest and bulls96_read_api the way the GCP guide does, with
bulls96_legacy_export_privacy absent, then checks each login's normalized
catalog baseline and effective access, the refused bootstrap rerun (55000),
the refused standalone privacy-role script (42501) and drift refusals. The
positive upgrade case is reported pending: no supported Pipeline sequence
exists at this pin.

Refs #578

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kjgbot kjgbot added the merge-train:hold Do not merge without Khaliq's direct OK label Nov 29, 2026
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3044bfe-b764-4e12-87d1-05f39127396a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The latest change appears safe to merge and addresses the previous finding.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The latest change appears safe to merge and addresses the previous finding.

Summary

Adds an offline PostgreSQL 16 fixture for the HoopDb Cloud SQL two-login upgrade checks.

  • The fixture checks both HoopDb logins against a pinned Cloud SQL-style setup.
  • CI runs the two-login fixture and saves its results.

Reviews (3) · Last reviewed commit: "test(ci): final two-login case expects t..." · Reviewed by Greptile

kjgbot and others added 2 commits November 29, 2026 07:39
Output of scripts/ci/render-fast-path.py after the new lint.yml job.

Refs #578

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ade sequence

With UPGRADE_SEQUENCE set, the final case requires
bulls96_legacy_export_privacy to exist (its shape is checked by the positive
case); without it, the role must still be absent.

Refs #578

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AgentRelayBot pushed a commit that referenced this pull request Nov 29, 2026
…-logins; renumber to agent-relay 0.7.97

Takes main's registry and requirements doc, adds this branch's row as
agent-relay 0.7.97, and says what the #578 evidence covers: a Pipeline
source review and a plain PostgreSQL 16 fixture (#620), no Cloud SQL run,
so Cloud SQL administrator behavior stays unverified.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-train:hold Do not merge without Khaliq's direct OK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant