{
  "schema": "pg36-ch22-service-requirements-v1",
  "release": "1.0-sandbox",
  "status": "service-routing-and-pooling-contract-not-production-slo",
  "target": {
    "id": "pg36-l2-vagrant/pg-test",
    "pigsty_release": "v4.4.0",
    "postgresql_observed": "18.4",
    "patroni_observed": "4.1.3",
    "pgbouncer_observed": "1.25.2",
    "haproxy_observed": "3.4.2",
    "cluster": "pg-test",
    "entry_address": "10.10.10.11",
    "members": {
      "pg-test-1": "10.10.10.11",
      "pg-test-2": "10.10.10.12",
      "pg-test-3": "10.10.10.13"
    },
    "production_data_permitted": false,
    "production_traffic_permitted": false
  },
  "services": {
    "primary": {
      "port": 5433,
      "destination": "pgbouncer:6432",
      "health_path": "/primary",
      "expected_role": "primary",
      "expected_recovery": false,
      "expected_writable": true
    },
    "replica": {
      "port": 5434,
      "destination": "pgbouncer:6432",
      "health_path": "/read-only",
      "expected_role": "replica-preferred-primary-fallback",
      "expected_recovery": true,
      "expected_writable": false
    },
    "default": {
      "port": 5436,
      "destination": "postgres:5432",
      "health_path": "/primary",
      "expected_role": "primary",
      "expected_recovery": false,
      "expected_writable": true
    },
    "offline": {
      "port": 5438,
      "destination": "postgres:5432",
      "health_path": "/replica",
      "expected_role": "offline-replica",
      "expected_member": "pg-test-3",
      "expected_recovery": true,
      "expected_writable": false
    }
  },
  "postgresql": {
    "max_connections": 500,
    "superuser_reserved_connections": 10,
    "reserved_connections": 0,
    "idle_in_transaction_session_timeout_ms": 600000,
    "statement_timeout_ms": 0,
    "max_locks_per_transaction": 500,
    "work_mem_kb": 65536,
    "temp_buffers_blocks": 1024,
    "connection_budget_interpretation": "server ceiling is not an application concurrency target"
  },
  "pgbouncer": {
    "port": 6432,
    "pool_mode": "transaction",
    "max_client_conn": 20000,
    "default_pool_size": 50,
    "reserve_pool_size": 30,
    "reserve_pool_timeout_seconds": 1,
    "query_wait_timeout_seconds": 120,
    "max_db_connections": 100,
    "max_user_connections": 100,
    "max_prepared_statements": 256,
    "server_reset_query": "DISCARD ALL",
    "server_reset_query_always": false,
    "client_tls_sslmode": "disable",
    "lab_override": {
      "default_pool_size": 2,
      "reserve_pool_size": 0,
      "query_wait_timeout_seconds": 5,
      "must_restore_original_settings_before_switchover": true
    }
  },
  "fixture": {
    "database": "test",
    "schema": "pg36_ch22",
    "table": "route_probe",
    "login_role": "test",
    "login_role_comment": "business user test",
    "login_role_source": "private reviewed Pigsty inventory",
    "login_role_owned_by_lab": false,
    "logical_service": "pg36_shop",
    "password_export_permitted": false
  },
  "pool_experiment": {
    "clients": 12,
    "server_slots": 2,
    "query_sleep_seconds": 0.25,
    "minimum_waiting_clients": 1,
    "maximum_observed_server_active": 2,
    "protocol_prepared_iterations": 12,
    "sql_prepare_must_fail_after_server_reassignment": true,
    "session_state_must_not_be_treated_as_sticky": true
  },
  "replica_read": {
    "visibility_timeout_seconds": 5,
    "claim": "one observed asynchronous read-your-writes delay, not a consistency guarantee"
  },
  "switch_probe": {
    "workers": 6,
    "duration_seconds": 24,
    "interval_seconds": 0.15,
    "warmup_seconds": 3,
    "maximum_backoff_seconds": 1.5,
    "minimum_acknowledged_attempts": 100,
    "maximum_conservative_write_gap_ms": 15000,
    "maximum_acknowledged_rows_missing": 0,
    "maximum_duplicate_tokens": 0,
    "maximum_unreconciled_unknown_outcomes": 0,
    "target_session_attrs": "read-write",
    "restore_final_leader": "pg-test-1"
  },
  "required_exception_ids": [
    "EX19-SHARED-HYPERVISOR",
    "EX19-SINGLE-ETCD",
    "EX19-SINGLE-BACKUP-TARGET",
    "EX19-VIRTUAL-STORAGE",
    "EX19-INVENTORY-SECRETS",
    "EX19-LAB-RESOURCE-FLOOR",
    "EX20-ASYNC-BASELINE",
    "EX20-WATCHDOG-OFF",
    "EX20-CLIENT-PROXY-NO-TLS",
    "EX20-PLANNED-ONLY",
    "EX22-SINGLE-HAPROXY-ENTRY",
    "EX22-ASYNC-READ-OBSERVATION",
    "EX22-SYNTHETIC-LOAD",
    "EX22-RUNTIME-POOL-OVERRIDE"
  ],
  "exceptions": [
    {
      "id": "EX22-SINGLE-HAPROXY-ENTRY",
      "reason": "the external probe enters through one node address rather than a validated VIP, DNS multi-endpoint or client multi-host configuration",
      "claim_blocked": "load-balancer entrypoint redundancy and client discovery failover"
    },
    {
      "id": "EX22-ASYNC-READ-OBSERVATION",
      "reason": "pg-test uses asynchronous replication and the lab only samples one token visibility delay",
      "claim_blocked": "read-your-writes, bounded staleness and zero-lag replica reads"
    },
    {
      "id": "EX22-SYNTHETIC-LOAD",
      "reason": "the pool and reconnect workloads are small synthetic queries on a laptop sandbox",
      "claim_blocked": "production connection capacity, queueing latency and reconnect-storm safety"
    },
    {
      "id": "EX22-RUNTIME-POOL-OVERRIDE",
      "reason": "the queue experiment temporarily changes one PgBouncer process at runtime and restores it before switching; it is not a Pigsty-declared production policy",
      "claim_blocked": "configuration-management acceptance and multi-instance policy uniformity"
    }
  ],
  "decision_boundary": {
    "sandbox_service_contract": "may-pass-with-exceptions",
    "production_ch22_gate": "pending",
    "unplanned_failover": "not-run",
    "vip_or_multi-entry_failover": "not-run",
    "tls_acceptance": "not-run",
    "production_load_test": "not-run"
  }
}
