test_wp09_settlement_contract.py 1.2 KB

1234567891011121314151617181920212223
  1. from pathlib import Path
  2. ROOT = Path(__file__).resolve().parents[2]
  3. MIGRATION = ROOT / "migrations/versions/20260813_498_agent_runtime_settlement.py"
  4. DEPLOYMENT = ROOT / "deployment/migrations/versions/20260813_498_agent_runtime_settlement.py"
  5. def test_wp09_settlement_migration_is_fenced_closed_and_not_public():
  6. source = MIGRATION.read_text(encoding="utf-8")
  7. assert 'revision = "20260813_498"' in source
  8. assert 'down_revision = "20260813_497"' in source
  9. for required in (
  10. "agent_runtime_settle", "lease_expires_at", "worker_id", "settlement_digest",
  11. "REVOKE ALL ON FUNCTION public.agent_runtime_authorize(jsonb) FROM PUBLIC",
  12. "REVOKE ALL ON FUNCTION public.agent_runtime_transition",
  13. "REVOKE ALL ON FUNCTION public.agent_runtime_canary_transition",
  14. "REVOKE ALL ON FUNCTION public.agent_runtime_approval_valid",
  15. "GRANT EXECUTE ON FUNCTION public.agent_runtime_settle(jsonb) TO dataops_agent_runtime",
  16. "SET search_path=pg_catalog,public", "p_payload-ARRAY", "approval agent scope denied",
  17. "approval principal scope denied", "lease_expired", "settlement fence conflict",
  18. ):
  19. assert required in source
  20. assert MIGRATION.read_bytes() == DEPLOYMENT.read_bytes()