{
  "schema_version": "d30-period-postgresql-evidence-v1",
  "existing_services_used": false,
  "cases": [
    {
      "id": "PG01-profile-and-isolation",
      "passed": true,
      "result": {
        "port": 55432,
        "version": "postgres (PostgreSQL) 18.1",
        "settings": {
          "port": "55432",
          "data_directory": "C:/Users/islam/AppData/Local/Temp/d30-stage5-period-pg18-u87vy0uu/data",
          "fsync": "on",
          "full_page_writes": "on",
          "synchronous_commit": "on",
          "server_version": "18.1"
        }
      }
    },
    {
      "id": "PG02-old-post-and-cross-month-barrier",
      "passed": true,
      "result": {
        "old_post": {
          "reason": "PERIOD_CLOSING",
          "sqlstate": "P0001"
        },
        "other_month": {
          "reason": "PERIOD_CLOSING",
          "sqlstate": "P0001"
        },
        "unchanged": {
          "head": "1",
          "holds": [],
          "journals": 1,
          "hold_events": 0
        }
      }
    },
    {
      "id": "PG03-original-post-replay",
      "passed": true,
      "result": {
        "original": {
          "status": "committed",
          "command": {
            "legs": [
              {
                "side": "debit",
                "account_id": "cash_usd",
                "amount_minor": "100000"
              },
              {
                "side": "credit",
                "account_id": "deposits_ada_usd",
                "amount_minor": "100000"
              }
            ],
            "currency": "USD",
            "entity_id": "CB-A",
            "ledger_id": "CB-CLOSE-2026",
            "journal_id": "J-FUND",
            "effective_at": "2026-09-30T12:00:00.000Z",
            "booking_period": "2026-09",
            "schema_version": "d30-journal-v1",
            "source_available_at": "2026-09-30T12:00:00.000Z",
            "business_operation_id": "OP-J-FUND"
          },
          "sequence": "1",
          "movements": [
            {
              "account_id": "cash_usd",
              "raw_delta_minor": "100000",
              "normal_delta_minor": "100000"
            },
            {
              "account_id": "deposits_ada_usd",
              "raw_delta_minor": "-100000",
              "normal_delta_minor": "100000"
            }
          ],
          "adjustment": {
            "reason": "",
            "authorized": false
          },
          "journal_id": "J-FUND",
          "debit_minor": "100000",
          "recorded_at": "2026-10-25T13:03:22.019Z",
          "credit_minor": "100000",
          "residual_minor": "0",
          "business_operation_id": "OP-J-FUND"
        },
        "replayed_while_closing": true
      }
    },
    {
      "id": "PG04-close-and-open-other-month",
      "passed": true,
      "result": {
        "close": {
          "phase": "CLOSED",
          "action": "finalize_close",
          "checks": [
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "scheduler_due_complete",
              "evidence_ref": "CHECK-SYNTHETIC-TRUSTED-0",
              "validated_at": "2026-10-25T13:03:26.287Z",
              "attestation_id": "CHECK-0",
              "booking_period": "2026-09",
              "close_generation": "1",
              "knowledge_cutoff": "2026-10-25T13:03:26.111Z",
              "frozen_head_sequence": "1"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "trial_balance",
              "evidence_ref": "CHECK-SYNTHETIC-TRUSTED-1",
              "validated_at": "2026-10-25T13:03:26.774Z",
              "attestation_id": "CHECK-1",
              "booking_period": "2026-09",
              "close_generation": "1",
              "knowledge_cutoff": "2026-10-25T13:03:26.111Z",
              "frozen_head_sequence": "1"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "intercompany_worksheet",
              "evidence_ref": "CHECK-SYNTHETIC-TRUSTED-2",
              "validated_at": "2026-10-25T13:03:27.155Z",
              "attestation_id": "CHECK-2",
              "booking_period": "2026-09",
              "close_generation": "1",
              "knowledge_cutoff": "2026-10-25T13:03:26.111Z",
              "frozen_head_sequence": "1"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "fx_revaluation",
              "evidence_ref": "CHECK-SYNTHETIC-TRUSTED-3",
              "validated_at": "2026-10-25T13:03:27.606Z",
              "attestation_id": "CHECK-3",
              "booking_period": "2026-09",
              "close_generation": "1",
              "knowledge_cutoff": "2026-10-25T13:03:26.111Z",
              "frozen_head_sequence": "1"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "balance_proof",
              "evidence_ref": "CHECK-SYNTHETIC-TRUSTED-4",
              "validated_at": "2026-10-25T13:03:28.121Z",
              "attestation_id": "CHECK-4",
              "booking_period": "2026-09",
              "close_generation": "1",
              "knowledge_cutoff": "2026-10-25T13:03:26.111Z",
              "frozen_head_sequence": "1"
            }
          ],
          "version": "7",
          "actor_id": "d30_closer",
          "closed_at": "2026-10-25T13:03:28.634Z",
          "closing_at": "2026-10-25T13:03:23.796Z",
          "generation": "1",
          "recorded_at": "2026-10-25T13:03:28.634Z",
          "operation_id": "FINAL",
          "close_version": "1",
          "approval_receipt": null,
          "frozen_head_sequence": "1",
          "journal_head_sequence": "1"
        },
        "other_open_journal": {
          "status": "committed",
          "command": {
            "legs": [
              {
                "side": "debit",
                "account_id": "cash_usd",
                "amount_minor": "100000"
              },
              {
                "side": "credit",
                "account_id": "deposits_ada_usd",
                "amount_minor": "100000"
              }
            ],
            "currency": "USD",
            "entity_id": "CB-A",
            "ledger_id": "CB-CLOSE-2026",
            "journal_id": "J-OPEN-OCT",
            "effective_at": "2026-10-20T12:00:00.000Z",
            "booking_period": "2026-10",
            "schema_version": "d30-journal-v1",
            "source_available_at": "2026-10-20T12:00:00.000Z",
            "business_operation_id": "OP-J-OPEN-OCT"
          },
          "sequence": "2",
          "movements": [
            {
              "account_id": "cash_usd",
              "raw_delta_minor": "100000",
              "normal_delta_minor": "100000"
            },
            {
              "account_id": "deposits_ada_usd",
              "raw_delta_minor": "-100000",
              "normal_delta_minor": "100000"
            }
          ],
          "adjustment": {
            "reason": "",
            "authorized": false
          },
          "journal_id": "J-OPEN-OCT",
          "debit_minor": "100000",
          "recorded_at": "2026-10-25T13:03:28.846Z",
          "credit_minor": "100000",
          "residual_minor": "0",
          "business_operation_id": "OP-J-OPEN-OCT"
        }
      }
    },
    {
      "id": "PG05-governed-reopen-new-generation-close",
      "passed": true,
      "result": {
        "approval": {
          "maker_id": "d30_reopener",
          "checker_id": "d30_checker",
          "approval_id": "AP-REOPEN",
          "approved_at": "2026-10-25T13:03:29.144Z"
        },
        "reopened": {
          "phase": "OPEN",
          "action": "reopen",
          "checks": [],
          "version": "8",
          "actor_id": "d30_reopener",
          "closed_at": null,
          "closing_at": null,
          "generation": "2",
          "recorded_at": "2026-10-25T13:03:29.356Z",
          "operation_id": "REOPEN",
          "close_version": "1",
          "approval_receipt": {
            "maker_id": "d30_reopener",
            "checker_id": "d30_checker",
            "approval_id": "AP-REOPEN",
            "approved_at": "2026-10-25T13:03:29.144Z"
          },
          "frozen_head_sequence": null,
          "journal_head_sequence": "2"
        },
        "second_close": {
          "phase": "CLOSED",
          "action": "finalize_close",
          "checks": [
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "scheduler_due_complete",
              "evidence_ref": "CHECK-G2-SYNTHETIC-TRUSTED-0",
              "validated_at": "2026-10-25T13:03:31.010Z",
              "attestation_id": "CHECK-G2-0",
              "booking_period": "2026-09",
              "close_generation": "2",
              "knowledge_cutoff": "2026-10-25T13:03:30.492Z",
              "frozen_head_sequence": "2"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "trial_balance",
              "evidence_ref": "CHECK-G2-SYNTHETIC-TRUSTED-1",
              "validated_at": "2026-10-25T13:03:32.099Z",
              "attestation_id": "CHECK-G2-1",
              "booking_period": "2026-09",
              "close_generation": "2",
              "knowledge_cutoff": "2026-10-25T13:03:30.492Z",
              "frozen_head_sequence": "2"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "intercompany_worksheet",
              "evidence_ref": "CHECK-G2-SYNTHETIC-TRUSTED-2",
              "validated_at": "2026-10-25T13:03:33.382Z",
              "attestation_id": "CHECK-G2-2",
              "booking_period": "2026-09",
              "close_generation": "2",
              "knowledge_cutoff": "2026-10-25T13:03:30.492Z",
              "frozen_head_sequence": "2"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "fx_revaluation",
              "evidence_ref": "CHECK-G2-SYNTHETIC-TRUSTED-3",
              "validated_at": "2026-10-25T13:03:34.880Z",
              "attestation_id": "CHECK-G2-3",
              "booking_period": "2026-09",
              "close_generation": "2",
              "knowledge_cutoff": "2026-10-25T13:03:30.492Z",
              "frozen_head_sequence": "2"
            },
            {
              "status": "pass",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-2026",
              "check_kind": "balance_proof",
              "evidence_ref": "CHECK-G2-SYNTHETIC-TRUSTED-4",
              "validated_at": "2026-10-25T13:03:36.251Z",
              "attestation_id": "CHECK-G2-4",
              "booking_period": "2026-09",
              "close_generation": "2",
              "knowledge_cutoff": "2026-10-25T13:03:30.492Z",
              "frozen_head_sequence": "2"
            }
          ],
          "version": "15",
          "actor_id": "d30_closer",
          "closed_at": "2026-10-25T13:03:37.451Z",
          "closing_at": "2026-10-25T13:03:29.739Z",
          "generation": "2",
          "recorded_at": "2026-10-25T13:03:37.451Z",
          "operation_id": "FINAL-G2",
          "close_version": "2",
          "approval_receipt": null,
          "frozen_head_sequence": "2",
          "journal_head_sequence": "2"
        },
        "portable_static_history_validated": true
      }
    },
    {
      "id": "PG06-authenticated-role-and-immutable-history",
      "passed": true,
      "result": {
        "denials": [
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "42501",
            "sqlstate": "42501"
          },
          {
            "reason": "SCOPE_FORBIDDEN",
            "sqlstate": "P0001"
          }
        ],
        "owner_rewrite_also_blocked": true
      }
    },
    {
      "id": "PG07-latest-failure-cancel-and-remediation",
      "passed": true,
      "result": {
        "canceled": {
          "phase": "OPEN",
          "action": "cancel_close",
          "checks": [],
          "version": "8",
          "actor_id": "d30_reopener",
          "closed_at": null,
          "closing_at": null,
          "generation": "2",
          "recorded_at": "2026-10-25T13:03:52.179Z",
          "operation_id": "CANCEL",
          "close_version": "0",
          "approval_receipt": {
            "maker_id": "d30_reopener",
            "checker_id": "d30_checker",
            "approval_id": "AP-CANCEL",
            "approved_at": "2026-10-25T13:03:51.985Z"
          },
          "frozen_head_sequence": null,
          "journal_head_sequence": "1"
        },
        "remediation_sequence": "2"
      }
    },
    {
      "id": "PG08-unchanged-correction-path-rollback-and-replay",
      "passed": true,
      "result": {
        "unchanged": {
          "head": "3",
          "holds": [],
          "journals": 3,
          "hold_events": 0
        },
        "original_pair_replayed": true
      }
    },
    {
      "id": "PG09-capture-atomic-rollback-and-hold-only-boundary",
      "passed": true,
      "result": {
        "before": {
          "head": "2",
          "holds": [
            {
              "status": "active",
              "hold_id": "H-1",
              "version": "2",
              "currency": "USD",
              "entity_id": "CB-A",
              "ledger_id": "CB-CLOSE-CAPTURE",
              "account_id": "deposits_ada_usd",
              "created_at": "2026-10-25T13:04:01.427Z",
              "expires_at": "2026-10-25T14:04:01.267Z",
              "updated_at": "2026-10-25T13:04:01.596Z",
              "captured_minor": "10000",
              "original_minor": "30000",
              "released_minor": "0",
              "remaining_minor": "20000"
            }
          ],
          "journals": 2,
          "hold_events": 2
        },
        "accepted_capture_replayed": true,
        "hold_only_reserve_allowed": true,
        "journal_head_unchanged": "2"
      }
    },
    {
      "id": "PG10-post-first-COMMIT-included-head",
      "passed": true,
      "result": {
        "blocked_observed": true,
        "writer_sequence": "2",
        "close": {
          "phase": "CLOSING",
          "action": "begin_close",
          "checks": [],
          "version": "1",
          "actor_id": "d30_closer",
          "closed_at": null,
          "closing_at": "2026-10-25T13:04:05.579Z",
          "generation": "1",
          "recorded_at": "2026-10-25T13:04:05.579Z",
          "operation_id": "RACE-CLOSE",
          "close_version": "0",
          "approval_receipt": null,
          "frozen_head_sequence": "2",
          "journal_head_sequence": "2"
        }
      }
    },
    {
      "id": "PG11-close-first-COMMIT-denies-old-writer",
      "passed": true,
      "result": {
        "blocked_observed": true,
        "uncommitted_phase_not_visible": true,
        "error": "ERROR:  P0001: PERIOD_CLOSING\nCONTEXT:  PL/pgSQL function reject(text) line 2 at RAISE\nSQL statement \"SELECT d30.reject('PERIOD_CLOSING')\"\nPL/pgSQL function period_guard_journal() line 5 at PERFORM\nSQL statement \"INSERT INTO d30.journals VALUES(h.ledger_id,h.entity_id,p->>'journal_id',p->>'business_operation_id',seq,recorded,p,answer)\"\nPL/pgSQL function post_journal(jsonb) line 78 at SQL statement\nLOCATION:  exec_stmt_raise, pl_exec.c:3937",
        "head": "1"
      }
    },
    {
      "id": "PG12-close-ROLLBACK-releases-barrier-and-identity",
      "passed": true,
      "result": {
        "blocked_observed": true,
        "phase": "OPEN",
        "version": "0",
        "posted_sequence": "2"
      }
    },
    {
      "id": "PG13-writer-ROLLBACK-no-counter-gap",
      "passed": true,
      "result": {
        "blocked_observed": true,
        "frozen_head": "1",
        "snapshot": {
          "head": "1",
          "holds": [],
          "journals": 1,
          "hold_events": 0
        }
      }
    },
    {
      "id": "PG14-concurrent-closers-one-version",
      "passed": true,
      "result": {
        "blocked_observed": true,
        "version": "1",
        "error": "ERROR:  P0001: VERSION_CONFLICT\nCONTEXT:  PL/pgSQL function reject(text) line 2 at RAISE\nSQL statement \"SELECT d30.reject('VERSION_CONFLICT')\"\nPL/pgSQL function control_period(jsonb) line 18 at PERFORM\nLOCATION:  exec_stmt_raise, pl_exec.c:3937"
      }
    },
    {
      "id": "PG15-repeatable-read-epoch-prevents-stale-bypass",
      "passed": true,
      "result": {
        "error": "ERROR:  40001: could not serialize access due to concurrent update\nCONTEXT:  SQL statement \"SELECT *        FROM d30.ledger_heads WHERE ledger_id=p->>'ledger_id' AND entity_id=p->>'entity_id' FOR UPDATE\"\nPL/pgSQL function post_journal(jsonb) line 14 at SQL statement\nLOCATION:  ExecLockRows, nodeLockRows.c:228",
        "head": "1",
        "epoch": "1"
      }
    },
    {
      "id": "PG16-controlled-restart-retains-history-and-authority",
      "passed": true,
      "result": {
        "history_identical": true,
        "close_version": "2",
        "journal_guard_active": true
      }
    },
    {
      "id": "PG17-effective-time-and-open-booking-adjustment",
      "passed": true,
      "result": {
        "accepted": {
          "status": "committed",
          "command": {
            "legs": [
              {
                "side": "debit",
                "account_id": "cash_usd",
                "amount_minor": "100000"
              },
              {
                "side": "credit",
                "account_id": "deposits_ada_usd",
                "amount_minor": "100000"
              }
            ],
            "currency": "USD",
            "entity_id": "CB-A",
            "ledger_id": "CB-CLOSE-2026",
            "journal_id": "J-LATE-EFFECTIVE",
            "effective_at": "2026-09-30T12:00:00.000Z",
            "booking_period": "2026-10",
            "schema_version": "d30-journal-v1",
            "source_available_at": "2026-09-30T12:00:00.000Z",
            "business_operation_id": "OP-J-LATE-EFFECTIVE"
          },
          "sequence": "3",
          "movements": [
            {
              "account_id": "cash_usd",
              "raw_delta_minor": "100000",
              "normal_delta_minor": "100000"
            },
            {
              "account_id": "deposits_ada_usd",
              "raw_delta_minor": "-100000",
              "normal_delta_minor": "100000"
            }
          ],
          "adjustment": {
            "reason": "Approved current-open-month adjustment",
            "authorized": true
          },
          "journal_id": "J-LATE-EFFECTIVE",
          "debit_minor": "100000",
          "recorded_at": "2026-10-25T13:04:21.574Z",
          "credit_minor": "100000",
          "residual_minor": "0",
          "business_operation_id": "OP-J-LATE-EFFECTIVE"
        },
        "closed_month_not_reopened": true
      }
    },
    {
      "id": "PG18-no-implicit-future-month-registration",
      "passed": true,
      "result": {
        "legacy_open_flag_alone_insufficient": true,
        "counter_rolled_back": true
      }
    },
    {
      "id": "PG19-trusted-watermark-clock-regression",
      "passed": true,
      "result": {
        "owner_controlled_test_watermark_restored": true,
        "system_clock_changed": false,
        "accepted_operations": "0"
      }
    }
  ],
  "limits": [
    "Synthetic trusted runner attestations exercise policy gates; this harness does not claim the five underlying accounting kernels ran. Root aggregate integration is separate.",
    "Opaque evidence refs and clocks do not authenticate external basis truth; trusted runner owns complete execution, basis binding and invalidation.",
    "Controlled restart is not hardware power-loss evidence; recorded_at and function return are not physical COMMIT timestamps.",
    "Database owner/superuser administration is outside the restricted-writer guarantee. Hold-only mutation remains allowed; all new journal writes are guarded."
  ],
  "settings": {
    "port": "55432",
    "data_directory": "C:/Users/islam/AppData/Local/Temp/d30-stage5-period-pg18-u87vy0uu/data",
    "fsync": "on",
    "full_page_writes": "on",
    "synchronous_commit": "on",
    "server_version": "18.1"
  },
  "version": "postgres (PostgreSQL) 18.1",
  "completed_groups": 19,
  "cleanup": {
    "stopped": true,
    "removed": true,
    "owned_directory_absent": true
  }
}
