Masterplan Optimiser

Technical Reference

High-Availability Protocol

The two server nodes are symmetric. An external Durable Object witness serialises ownership, while Cloudflare routing follows the ownership decision.

Symmetric two-VPS high availability

The witness grants ownership. The load balancer only sends traffic to the node that can prove it is ready.

Cloudflare Load Balancer

Public HTTPS traffic and /ha/ready health checks

VPS A

Application, PostgreSQL, local node identity

Encrypted complete bundles over authenticated SSH

VPS B

Application, PostgreSQL, local node identity

Durable Object witness

One writer lease, generation, heartbeat, and short write permits

Independent external snapshot

Encrypted recovery copy plus an operator-held private identity kept away from both VPSs

Either VPS can become holder. The labels A and B identify nodes, not permanent primary and secondary roles.

Lease and write fencing

The holder sends a heartbeat every 15 seconds and obtains short-lived write permits of approximately 10 seconds. FastAPI validates authority before each mutating request, and the persistence layer checks it again before committing ORM work. A node receiving traffic without a current permit cannot become writer.

Probe or stateProvesUse
/healthProcess and local database are aliveLocal diagnosis only
/ha/readyHealth, current ownership, and generationCloudflare pool monitor and readiness
GenerationMonotonic ownership epochInvalidates stale authority after promotion
Write permitCurrent short-lived authorityRequest and commit fencing

Replication acceptance

  1. The holder builds and encrypts a complete point-in-time bundle.
  2. Authenticated SSH transfers it without replacing the peer's accepted copy.
  3. The peer validates the outer hash, receipt, encrypted manifest, cluster identity, generation, and release.
  4. It restores the database into staging and validates the staged state.
  5. Only after successful checks and witness authorisation does it atomically accept the new recovery point.
  6. The prior local database remains available for guarded rollback.

Automatic failover sequence

Promotion is deliberately gated to prevent both servers from accepting writes.

  1. 1

    Heartbeat stops

    The current holder disappears

  2. 2

    Witness waits

    Approximately five minutes

  3. 3

    Peer qualifies

    Healthy, matching release, accepted current bundle

  4. 4

    Generation advances

    Old write authority becomes invalid

  5. 5

    Peer promotes

    Database and local ownership activate

  6. 6

    Routing follows

    Cloudflare sees /ha/ready

Promotion security effects

Promotion preserves registered passkeys and durable application data. It invalidates sessions, exchange codes, incomplete passkey ceremonies, activation and reset links, public schedule links, and desktop publishing credentials. These bearer-style values are intentionally not trusted across the ownership boundary.

For commands and checkpoints, use HA Setup and Active HA Verification.