Skip to content

3.x.x: HA Compose overlay and database reference architecture - #304

Merged
djh58 merged 5 commits into
3.x.xfrom
djh58/prism-b9-ha-overlay
Sep 11, 2026
Merged

djh58 merged 5 commits into
3.x.xfrom
djh58/prism-b9-ha-overlay

Conversation

@djh58

@djh58 djh58 commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Refs #281

PRISM previously shipped one coordinator with fixed host ports. This adds an opt-in two-frontend Compose overlay with distinct instance IDs, separate RPC wiring, non-colliding ports and one shared database DSN, plus a live-instance section in self-check and CI validation.

Provided here and operator-supplied

Provided here: two active frontend services, the existing bundled primary plus one asynchronous standby and checked public reader, configuration tracing, and a reference architecture covering all seven deployment requirements. Self-check distinguishes live, inactive, stale, unknown and failed heartbeat observations using a database-clock sample and a 15-second freshness window.

Operator-supplied: the highly available Stratum TCP load balancer/hashrouter, independent production nodes and failure-domain placement, database replication policy, promotion authority, fencing, stable writer endpoint, storage and secrets. No load-balancer service or automatic database failover is added. The document specifies the external health-check contract and recommended rise/fall hysteresis.

Supported Compose stacks

Apply compose.prism-ha.yaml last, with the prism profile:

  1. compose.yaml + HA
  2. compose.yaml + compose.production.yaml + HA
  3. compose.yaml + compose.prism-external-db.yaml + HA
  4. compose.yaml + compose.production.yaml + compose.prism-external-db.yaml + HA

Production image/storage restrictions and external-DB dependency overrides reach both frontends. Without HA, the second service stays inactive. The lab defaults share bundled qbitd; separate production nodes remain operator-supplied.

Acceptance evidence

Checks were rerun after rebasing onto f394427, then again on review fix-ups 51b5d79 and 893141b. The base includes the ledger split and development-line banner at 1bcd61e.

Check State Evidence
docker compose -f compose.yaml -f compose.prism-ha.yaml config and new push/PR CI step executed-and-passed Exact CI shell commands ran locally.
All four stacks and nondefault effective settings executed-and-passed Distinct IDs, host/URL precedence, shared DSN, port mappings, image/storage/dependency parity; second service stays inactive without HA.
Bundled database startup with two healthy coordinators executed-and-passed Built the repository Dockerfile; real qbit regtest node; both HTTP probes and Docker health checks passed.
Self-check and runtime config validation executed-and-passed Both check-config commands passed; self-check counted b9-east and b9-west; nondefault runtime IDs, RPC wiring and ports verified; host health probes passed with both :: and 0.0.0.0, despite base loopback/disabled-port settings.
Empty / stale / failed heartbeat observations executed-and-passed Unit and real SQL tests; full-command missing-table, denied-heartbeat-read and invalid-config probes emitted the same JSON keys, null unavailable values and a nonzero exit; denied heartbeat reads retained successful local diagnostics.
cargo +1.89.0 fmt --check executed-and-passed On the final tools fix-up.
cargo +1.89.0 test --locked -p qbit-prism-server executed-and-passed Disposable PostgreSQL 16 supplied through PRISM_TEST_DATABASE_URL; includes the new SQL heartbeat test.
Existing Compose contracts executed-and-passed 34 Python tests passed, including mainnet RPC passthrough, bind/port precedence, distinct IDs and non-colliding mappings.
Seven requirement markings, D3 table and cutover checklist executed-and-passed Document inspected and assertions verified.
Production/external-DB startup and config --resolve-image-digests not executed Those stacks were rendered; the real build/startup path was used for the bundled lab.
Cargo paths gated on QBITD_BIN / PRISM_TEST_PG_BIN_DIR not executed Those variables were unset; the passing package command does not certify these gated paths.
Cross-frontend job resume not executed Pending #273.
Promotion under mining load, full D1 workload, and hashrouter/LB behavior not executed Pending #291; promotion under load is an explicit pre-production checklist item.
Strict standby-down share-ACK/cancellation behavior not executed Open D3 policy and qualification gap below.

Open D3 policy and finding for the ledger owner (A/C) and #291

Topology is decided: one primary plus one standby. Dan still needs to choose the replication level/name matching and what share ACKs do while that standby is unavailable, including the post-promotion interval with no standby. See D3: replication and ACK policy still needs a decision for the decision table and recommendation; the overlay does not select a production policy.

Finding for the ledger owner (A/C) and #291: existing writer connections force synchronous_commit=on unless already remote_apply. PostgreSQL can cancel a synchronous replication wait after local commit with a warning, so the finite statement timeout must not be assumed to enforce no positive ACKs during standby loss. Qualify the actual share path through timeout/cancellation and lost-response cases before claiming strict durability; no ledger behavior is changed here.

Coordination and remainder

Deep-review dispositions

Initial lanes reviewed frozen 16364c5: Codex medium found no actionable regressions; thermo reported 10 findings; Fable adversarial reported 3; Codex adversarial reported 3; Cursor reported 1. Including one cosmetic item from focused verification, duplicates reduce these to 14 unique findings: 13 fixed, 1 explicitly deferred, 0 rebutted. Codex medium's review of 16364c5..893141b is also clean; focused Fable verification confirmed the fixes and approved deferral, unchanged single-frontend stacks, and effective negative controls. Final documentation follow-up 8f80052 has also been pushed; Final-head CI is green: 11 workflow checks plus Cursor pass; optional Codesmith is skipped. Cursor re-reviewed 8f80052 and found no new issues; the original thread is replied to and resolved.

Finding source Disposition Evidence / owner
Thermo F1 / Fable F1 / Codex F1 / Cursor 3983515548: unreachable health bind Fixed in 51b5d79 Dedicated PRISM_HA_AUDIT_BIND, default reachable listener; rendered and live host probes pass.
Thermo F2: asymmetric frontend-1 port inputs Fixed in 51b5d79 Symmetric HA knobs retain base-name fallbacks; runtime and contract checks pass.
Thermo F3 / Fable F3: CI lacks effective assertions Fixed in 51b5d79 Four profiled JSON renders assert bind, target, IDs, DSN and ports; fixture DSN is scoped to external-DB stacks.
Thermo F4: partial failure report / skipped local checks Fixed in 893141b One typed report; heartbeat denial retains local results; ok=false always exits nonzero.
Thermo F5: shared heartbeat status contract Deferred with coordinator approval #307, owner Workstream C; changing all writers crosses concurrent ledger/coordinator/server ownership.
Thermo F6: empty single_instance=false and untyped report Fixed in 893141b Named serialized reports; no live/unknown observation yields null.
Thermo F7: combined scenarios / unnecessary reader pool Fixed in 893141b Named tests and a single read-only PgConnection; live PostgreSQL tests pass.
Thermo F8: D3 table lacks setting locations Fixed in 51b5d79 Table specifies primary reload, writer-role settings and pool reconnect behavior.
Thermo F9: no retired-ID cleanup guidance Fixed in 51b5d79 Explicit manual writer-side retirement statement, only after stopping the frontend.
Thermo F10: implicit shared audit mount Fixed in 51b5d79 Anchor comment explains legacy compatibility and PostgreSQL-canonical native audits.
Fable F2: global RPC endpoint silently replaced Fixed in 51b5d79 Per-frontend nested fallbacks preserve global host/URL; mainnet regression tests pass.
Codex F2: base audit port zero invalidates HA Fixed in 51b5d79 Dedicated nonzero PRISM_HA_AUDIT_PORT feeds listener and published target; audit-disabled HA requires an operator override/readiness contract.
Codex F3: documentation renders expose secrets Fixed in 51b5d79, refined in 8f80052 Quiet renders or explicit allowlisted fields; both projected RPC URLs are set to known fixtures, excluding inherited credential-bearing URLs/DSNs.
Focused Fable verification: projection hides configured RPC inputs Fixed in 8f80052 Shows host and URL values with explicit fixture URLs on both frontends.

Focused verification also noted that fixes needed publication and Rust validation: the commits are now pushed, local PostgreSQL-backed tests passed, and final-head Rust CI passed. Its informational DSN-equality observation is an intentional future-regression guard; no change is required.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Generated with Codex, supervised by the PRISM B Coordinator session

@djh58

djh58 commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@cursor review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread compose.prism-ha.yaml Resolved
@djh58

djh58 commented Sep 11, 2026 •

Copy link
Copy Markdown
Member Author

Deep-review dispositions on final pushed head 8f80052a80ebc0012fe962b8dede6d03f0879113:

Initial lanes reviewed frozen 16364c5: Codex medium found no actionable regressions; thermo reported 10 findings; Fable adversarial reported 3; Codex adversarial reported 3; Cursor reported 1. Including one cosmetic item from focused verification, duplicates reduce these to 14 unique findings: 13 fixed, 1 explicitly deferred, 0 rebutted. Codex medium's review of 16364c5..893141b is also clean; focused Fable verification confirmed the fixes and approved deferral, unchanged single-frontend stacks, and effective negative controls. Final documentation follow-up 8f80052 has also been pushed; Final-head CI is green: 11 workflow checks plus Cursor pass; optional Codesmith is skipped. Cursor re-reviewed 8f80052 and found no new issues; the original thread is replied to and resolved.

Finding source Disposition Evidence / owner
Thermo F1 / Fable F1 / Codex F1 / Cursor 3983515548: unreachable health bind Fixed in 51b5d79 Dedicated PRISM_HA_AUDIT_BIND, default reachable listener; rendered and live host probes pass.
Thermo F2: asymmetric frontend-1 port inputs Fixed in 51b5d79 Symmetric HA knobs retain base-name fallbacks; runtime and contract checks pass.
Thermo F3 / Fable F3: CI lacks effective assertions Fixed in 51b5d79 Four profiled JSON renders assert bind, target, IDs, DSN and ports; fixture DSN is scoped to external-DB stacks.
Thermo F4: partial failure report / skipped local checks Fixed in 893141b One typed report; heartbeat denial retains local results; ok=false always exits nonzero.
Thermo F5: shared heartbeat status contract Deferred with coordinator approval #307, owner Workstream C; changing all writers crosses concurrent ledger/coordinator/server ownership.
Thermo F6: empty single_instance=false and untyped report Fixed in 893141b Named serialized reports; no live/unknown observation yields null.
Thermo F7: combined scenarios / unnecessary reader pool Fixed in 893141b Named tests and a single read-only PgConnection; live PostgreSQL tests pass.
Thermo F8: D3 table lacks setting locations Fixed in 51b5d79 Table specifies primary reload, writer-role settings and pool reconnect behavior.
Thermo F9: no retired-ID cleanup guidance Fixed in 51b5d79 Explicit manual writer-side retirement statement, only after stopping the frontend.
Thermo F10: implicit shared audit mount Fixed in 51b5d79 Anchor comment explains legacy compatibility and PostgreSQL-canonical native audits.
Fable F2: global RPC endpoint silently replaced Fixed in 51b5d79 Per-frontend nested fallbacks preserve global host/URL; mainnet regression tests pass.
Codex F2: base audit port zero invalidates HA Fixed in 51b5d79 Dedicated nonzero PRISM_HA_AUDIT_PORT feeds listener and published target; audit-disabled HA requires an operator override/readiness contract.
Codex F3: documentation renders expose secrets Fixed in 51b5d79, refined in 8f80052 Quiet renders or explicit allowlisted fields; both projected RPC URLs are set to known fixtures, excluding inherited credential-bearing URLs/DSNs.
Focused Fable verification: projection hides configured RPC inputs Fixed in 8f80052 Shows host and URL values with explicit fixture URLs on both frontends.

Focused verification also noted that fixes needed publication and Rust validation: the commits are now pushed, local PostgreSQL-backed tests passed, and final-head Rust CI passed. Its informational DSN-equality observation is an intentional future-regression guard; no change is required.

@djh58

djh58 commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8f80052. Configure here.

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