> python verify.py
test_auth_and_cross_account (test_ledger.ApiTests.test_auth_and_cross_account) ... ok
test_export_and_csv_formula_safety (test_ledger.ApiTests.test_export_and_csv_formula_safety) ... ok
test_invalid_and_static_paths (test_ledger.ApiTests.test_invalid_and_static_paths) ... ok
test_roles (test_ledger.ApiTests.test_roles) ... ok
test_adjustment_target_and_duplicate_posting_rejected (test_ledger.LedgerTests.test_adjustment_target_and_duplicate_posting_rejected) ... ok
test_canonical_idempotency_and_conflicting_duplicate (test_ledger.LedgerTests.test_canonical_idempotency_and_conflicting_duplicate) ... ok
test_close_idempotency_and_restart_export (test_ledger.LedgerTests.test_close_idempotency_and_restart_export) ... ok
test_close_wins_ingest_race_pending (test_ledger.LedgerTests.test_close_wins_ingest_race_pending) ... ok
test_closed_export_frozen_after_late_event_and_correction (test_ledger.LedgerTests.test_closed_export_frozen_after_late_event_and_correction) ... ok
test_concurrent_duplicate_ingest_once (test_ledger.LedgerTests.test_concurrent_duplicate_ingest_once) ... ok
test_correction_cannot_link_other_account (test_ledger.LedgerTests.test_correction_cannot_link_other_account) ... ok
test_correction_chain_requires_latest_revision (test_ledger.LedgerTests.test_correction_chain_requires_latest_revision) ... ok
test_correction_replay_and_conflict (test_ledger.LedgerTests.test_correction_replay_and_conflict) ... ok
test_corrupt_cache_detected_before_close (test_ledger.LedgerTests.test_corrupt_cache_detected_before_close) ... ok
test_empty_period_close (test_ledger.LedgerTests.test_empty_period_close) ... ok
test_exact_precision_and_no_float (test_ledger.LedgerTests.test_exact_precision_and_no_float) ... ok
test_immutable_storage_guards (test_ledger.LedgerTests.test_immutable_storage_guards) ... ok
test_ingest_wins_close_race_included (test_ledger.LedgerTests.test_ingest_wins_close_race_included) ... ok
test_large_integer_totals_remain_exact (test_ledger.LedgerTests.test_large_integer_totals_remain_exact) ... ok
test_open_correction_is_linked_reversal_and_replacement (test_ledger.LedgerTests.test_open_correction_is_linked_reversal_and_replacement) ... ok
test_posting_cutoff_excludes_previously_ingested_unposted_events (test_ledger.LedgerTests.test_posting_cutoff_excludes_previously_ingested_unposted_events) ... ok
test_reordered_import_duplicates_reconcile (test_ledger.LedgerTests.test_reordered_import_duplicates_reconcile) ... ok
test_same_identity_separate_accounts (test_ledger.LedgerTests.test_same_identity_separate_accounts) ... ok
test_timestamp_timezone_sets_utc_period (test_ledger.LedgerTests.test_timestamp_timezone_sets_utc_period) ... ok

----------------------------------------------------------------------
Ran 24 tests in 2.539s

OK

{"command": "python verify.py", "tests": 24, "passed": 24, "failures": 0, "errors": 0, "skipped": 0, "success": true, "elapsed_seconds": 2.54, "python": "3.12.14"}


> python demo.py
{
  "fixture": "synthetic January and February 2026 usage",
  "timezone": "UTC",
  "rule_version": "usage-v1",
  "events": 6,
  "ledger_entries": 7,
  "closed_versions": 2,
  "late_and_correction_adjustments": 2,
  "pending_after_approval": 0,
  "january_compute_minutes": "19.750",
  "january_api_calls": "1250",
  "february_compute_minutes": "9.375",
  "february_components": {
    "late_usage": "3.125",
    "correction_net": "-2.000",
    "current_usage": "8.250"
  },
  "export_hashes": {
    "2026-01": "ab6b4b56bcd199dc98049d771a3d32d441e2796b8d7734aa2cec0df66ff0c79d",
    "2026-02": "6fedc1947e61419ea88b694ba42ce45d80e163e74907177d9535d978c3c8e1a7"
  },
  "assertions": {
    "january_export_unchanged": true,
    "duplicate_not_recounted": true,
    "both_reconciliations_match": true,
    "both_exports_digest_verified": true
  },
  "reconciliations": {
    "2026-01": {
      "period": "2026-01",
      "matches": true,
      "rebuilt": {
        "api_call": {
          "quantity": "1250",
          "base_units": "1250",
          "precision": 0
        },
        "compute_minute": {
          "quantity": "19.750",
          "base_units": "19750",
          "precision": 3
        }
      },
      "cached_base_units": {
        "api_call": "1250",
        "compute_minute": "19750"
      }
    },
    "2026-02": {
      "period": "2026-02",
      "matches": true,
      "rebuilt": {
        "compute_minute": {
          "quantity": "9.375",
          "base_units": "9375",
          "precision": 3
        }
      },
      "cached_base_units": {
        "compute_minute": "9375"
      }
    }
  }
}


> python operations_rehearsal.py
PASS crash.ingest: Abrupt exit before ingest commit leaves every business table empty
PASS crash.response: Committed ingest survives process exit and replay creates no extra quantity
PASS load.idempotency: Eight concurrent writers turn 800 requests into 400 source events
PASS load.exact-total: Concurrent exact quantities sum without rounding
PASS load.corrections: Ten corrections append reversals and replacements with the expected net
PASS close.rollback: Crash before close commit leaves period open and no frozen version
PASS close.immutability: Late event and correction leave the frozen January digest unchanged
PASS api.isolation: Other-account read and viewer mutation are rejected
PASS api.boundary: Foreign Host and Origin are rejected
PASS api.storage: Storage failure returns HTTP 503 without inventing success
PASS restore.frozen-export: Restored January export matches every frozen row and digest
PASS restore.point-in-time: Snapshot correctly excludes the two records received after backup
PASS restore.source-replay: Stable upstream identities restore two lost records exactly once
PASS restore.carry-forward: Recovered late usage and correction close February at 2.625 minutes
PASS restore.closed-digest: Recovery and carry-forward preserve the January digest
PASS restore.corruption: Modified snapshot is rejected before destination creation
PASS restore.no-overwrite: Existing restore destination is preserved
PASS integrity.final: Recovered database passes integrity and foreign-key checks
PASS backup.schedule: Finite scheduler creates two checked snapshots and stops
{"checks": 19, "passed": 19, "elapsed_seconds": 1.685}


