Repository navigation
3.x.x: a go-live gate that checks every self-check fact but legacy audit completeness while import-audits runs (#734) - #736
Conversation
…dit completeness while import-audits runs (#734) Nothing on the serving path reads a legacy row's canonical bytes, so a frontend can admit traffic before import-audits finishes storing them. In production, though, self-check stops at audit completeness and skips its other checks until the import is done (#734). That leaves no go-live gate for the hours the import takes. scripts/prism_legacy_import_admission_gate.sh checks every other fact self-check checks, from the frontend's own environment on each host: - check-config: the configuration, the pool fee settling dust and the block-submission warnings; - the heartbeat census, and the submission hold, which is reported only; - carry-forward integrity, durability and the offer standby, with self-check's own SQL; - the frontend's healthcheck, which also stands for self-check's one-shot refresh; - the highdiff floor probe. It reports legacy rows without stored bytes as pending, and fails on a native audit that self-check would count as incomplete. Every query runs read-only, and it never prints the DSN or the token. The tests run the script with a fake qbit-prism-server and a fake psql, covering every pass and fail path, the highdiff probe against a fake listener, and the DSN and token staying out of the output. A gated test migrates a fresh database with qbit-prism-server and runs the gate's SQL against it with the real psql. The migration guide notes the gate, and the 500 that /public/v1/artifacts/<sha> gives for rows not yet imported (#735). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ecdb9b5013
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…and keep the database password off command lines Review found that the first version of the gate disagreed with self-check in several places: - It probed highdiff when only PRISM_STRATUM_HIGHDIFF_BIND was set, but StratumConfig::highdiff_config() turns highdiff on only for a nonblank port. - It checked the offer standby whenever the application name was set, but config::offer_standby() turns the wait off when PRISM_OFFER_STANDBY_FLUSH_WAIT_MS is 0, and trims the name. - It looked up the probe's username under the wrong variable names. self-check uses PRISM_USERNAME_FALLBACK_ADDRESS (or the built-in test-network address), then PRISM_POOL_FEE_ADDRESS. - Its probe had no overall deadline, and it accepted difficulties and errors that probe_first_difficulty refuses. - psql received the full database URL, password included, on its command line. The gate now follows each of those rules. psql gets the URL without its password, and reads the password from PGPASSWORD. The probe gives up after 15 s in total, and refuses a difficulty that is not a positive finite number, as well as any non-null error. The census classifies heartbeats as live_instances() does, and prints self-check's HA warnings. While legacy rows are pending, the gate reports whether an import-audits session can be seen, and warns when none can. The tests cover each change: - the password is absent from every psql command line and present in PGPASSWORD; - a zero flush wait, and a bind without a port; - each username fallback; - the probe's refusals and its deadline; - the HA warnings, and the import session. The gated test also checks the census against heartbeats in a migrated schema. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6bb2798337
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…s the probe's username and bind verbatim as self-check does Bash reads a number with a leading zero as octal. So a valid PRISM_HEALTH_REFRESH_SECONDS such as 08 or 09, which Rust parses as decimal, aborted the gate before it printed a verdict. It's now read in base 10. self-check reads PRISM_SELF_CHECK_ADDRESS, PRISM_USERNAME_FALLBACK_ADDRESS and PRISM_POOL_FEE_ADDRESS through config::optional. A blank value counts as unset, and a set value is used verbatim. It reads PRISM_STRATUM_BIND through config::value, where only an unset variable takes the default. The gate trimmed these values, so it could authorize an address that self-check sends padded and the listener refuses. It now passes them through unchanged. The tests cover a refresh interval of 09, a padded probe address and blank addresses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Set VERSION and [workspace.package].version to 3.0.0-rc.5: rc.4 plus #737's fixes in #742 (fatal-state clear accepts a tip that only grew, takes --timeout-seconds, and runs the integrity report under its own statement timeout) and #744 (migration 026: the report computes each set once); the deferred share-hash backfill in #743 and #746 (migrate --defer-share-hashes, then the throttled backfill-share-hashes after go-live); #745 (migrate --offline-indexes, which composes with --defer-share-hashes); the cutover tooling merged after rc.4's tag (#728, #732, #736, #740); and #747, a test-only fix for #724. Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.5.md, dated 2026-10-08, covers: - the changes, with the report's estimated 57 to 29 s since 026, the migrate --defer-share-hashes command measured on the pair at 5 min 06 s (539d6c9, before #745), backfill-share-hashes' throttle, record of 2 and safe rerun, the evidence scripts' changes, and the offline index builds' estimated gain; - upgrading: migrate is needed again (a binary-only upgrade refuses "missing migration(s) 26", and this export refuses a database without 026), the cutover's migrate step with both flags, and finishing the backfill after go-live under #738's snapshot rule, with self-check only at low share rates. Rolling back to rc.4 at fence 2 goes only by finishing the backfill first or from the pre-migrate backup or physical copy, and each rc.4 refusal is quoted where it applies: a start meets the cursor first and says to run migrate, which rc.4's migrate refuses. The rules still in force: #737's statement timeout for rc.4's tools, 026 or not, #738's snapshot rule, and fatal-state clear --timeout-seconds, whose bound ends before the commit; - the same evidence set as rc.4's, with each PR's merge SHA, the pair's serving evidence carried, and the rehearsal's full measurements left to the cutover's go/no-go record; - the known issues: rc.4's, minus #737's F1, F2, F4 and F5, plus #737's open part, #738 (its fix planned for rc.6), #739, #741, #731 and #734, with #582 closed and #712 and #724 updated. docs/prism-rust-migration.md now says how earlier candidates refuse a database at fence 2: a start with the backfill's own refusal, whose advice to run migrate holds only for this release, and their migrate, or a start with PRISM_POSTGRES_INIT_SCHEMA=1, with the fence. The development-line notes name 3.0.0-rc.5, and they and the 3.0.0 notes link all five candidates' notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s is in progress (#734) (#808) In production, self-check returned at audit completeness before its local checks, so for the ~3 h of a union-scale import-audits it reported nothing else and could not gate a deployment. #736's admission gate script was the workaround. - self-check runs every local check before the completeness verdict, so the report is always complete. A production refusal is returned after them, as #525's pool-fee refusal is. When the local checks fail too, their error is printed on its own ERROR line, so neither failure hides the other. - audit_completeness() also counts the missing rows by kind, in the same snapshot: pending_legacy_rows (no bytes and no share snapshot, the rows the importer selects) and incomplete_native_rows (a snapshot reference, but no metadata body or no snapshot row; no import repairs these). Together they make up missing_canonical_bytes. import-audits prints both. - self-check's audit_completeness gains a status. It is complete when nothing is missing. It is legacy_import_pending only when the operator declares the import for that run with PRISM_SELF_CHECK_LEGACY_IMPORT_PENDING=1 and no native row is incomplete; the rows are then reported, with a WARNING, and are not a failure. Otherwise it is incomplete, and production fails as before: on native rows first, since import-audits doesn't repair them, and otherwise on the legacy rows, with a hint naming the declaration. An unreadable count stays null and fails. An unparsable declaration fails before anything is read. - The setting is read only by self-check, once. It is not part of the frontend Config, because it applies to one run and a frontend never needs it. It is in native-settings.txt, and `make prism-self-check` passes it into the container with `exec -e` only when it is set. - Docs: docs/prism-rust-migration.md (the #734 paragraph and the rehearsal row), the crate README, the deleted-test map, and the admission gate script's header, which still serves builds through 3.1.0. Tests (PostgreSQL-gated, new ones listed in test/prism-gated-tests.txt): - tests/audit_completeness.rs: - self_check_runs_every_local_check_while_a_legacy_import_is_pending: production self-check against the fake node, with a pending legacy row. Declared, the status is legacy_import_pending. Undeclared, it fails on the audits. Both report health, carry-forward integrity and durability, and reach the readiness probe of a frontend the test doesn't run. - self_check_reports_missing_audits_before_rpc_and_enforces_production now runs lab and production, each declared and undeclared. An undeclared pending import still fails production. Every case reaches the local checks (the RPC failure). An unparsable declaration fails. - self_check_fails_on_an_incomplete_native_row_even_with_a_declared_import: a native row lacking its body, beside a pending legacy row, fails production either way. - The counts test checks the legacy/native split and its sum. - The exact-JSON assertions in self_check_cli.rs, cutover_rehearsal.rs, live_migration_lifecycle.rs and import_audits_settlement_lock.rs include the new fields. - tests/test_makefile_lifecycle.py: the make target passes the declaration only when it is set. Co-authored-by: Claude Opus 5.5 <[email protected]>
Why
Nothing on the serving path reads a legacy audit row's canonical bytes: shares, settlement, payouts and readiness never do. So frontends can admit traffic before
import-auditsfinishes storing them. Union's history is about 618 GB of canonical bytes, about 3 h of import.In production, though,
self-checkstops at audit completeness, and skips its other checks, until the import is done (#734). That leaves no go-live gate for those hours.What
scripts/prism_legacy_import_admission_gate.shchecks every other factself-checkchecks (self_check()andself_check_local()intools.rs). Run it on each frontend host with that frontend's environment.Config::from_env, the pool fee settling dust (#525), block-submission warningsqbit-prism-server check-config, which runs all three plus every settings loaderlive_instances()does, with the same warningssubmission-hold show(report only)qbit_carry_forward_integrity_report()pg_settingsreadPRISM_OFFER_STANDBY_FLUSH_WAIT_MS≠ 0: role readable, exactly one standby, flushingpg_stat_replicationreadhealthcheck(), plus the tool coordinator's start andrefresh_once()qbit-prism-server healthcheck, the same function. It passes only once the serving frontend has passed the same startup gates and published work on the observed tipPRISM_STRATUM_HIGHDIFF_PORTset_difficultymust be a positive finite number ≥PRISM_STRATUM_HIGHDIFF_MIN_DIFFEvery query runs read-only. psql gets the database URL without its password, which it reads from
PGPASSWORD, so no credential appears in a command line or in the output. The script exits 0 only when every check passes.The migration guide gains a paragraph on the gate. It also notes that, until a legacy row is imported,
/public/v1/artifacts/<sha>answers 500 for an audit whose 2.x body can't be read on that host (#735), and the block's audit view answers 404.Tests
tests/test_prism_legacy_import_admission_gate.pyjoins CI's Python shards through discovery.qbit-prism-serverand a fakepsqlthat logs its command line:PGPASSWORD, and the token absent from the output;PRISM_TEST_DATABASE_URLandPRISM_ADMISSION_GATE_SERVER_BINare set:qbit-prism-server migrate, inserts heartbeats and legacy and native audit rows, and runs the gate with the realpsql;bash -nare clean.Refs #734, #735
🤖 Generated with Claude Code