test_p_evidence_performance.py
python
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab
NXP-b DONE: independent BV-r2 pass + ISR (SD-17)
Human
minor
⚠ breaking
18 hours ago
| 1 | """Performance bounds for P-evidence append/verify (§PE.10).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import time |
| 6 | |
| 7 | from tests.fixtures.p_evidence import load_p_evidence_entry, seed_p_evidence_repo |
| 8 | from tools.honesty.ledger import append_entry, verify_ledger_file |
| 9 | from tools.honesty.status import HonestyStatusOptions, run_honesty_status |
| 10 | from tools.honesty.types import LedgerAppendOptions |
| 11 | |
| 12 | _APPEND_VERIFY_BUDGET_S = 2.0 |
| 13 | _MATCH_SCAN_BUDGET_S = 1.0 |
| 14 | |
| 15 | |
| 16 | def test_realistic_evidence_append_verify_within_bound(repo_root) -> None: |
| 17 | config = seed_p_evidence_repo(repo_root) |
| 18 | body = load_p_evidence_entry("verification-evidence-pass.json") |
| 19 | body["artifacts"].append( |
| 20 | { |
| 21 | "type": "screenshot", |
| 22 | "sha256": "d" * 64, |
| 23 | "ref": "docs/archive/verify/p-evidence-status.png", |
| 24 | } |
| 25 | ) |
| 26 | started = time.perf_counter() |
| 27 | assert ( |
| 28 | append_entry( |
| 29 | config=config, |
| 30 | repo_root=repo_root, |
| 31 | options=LedgerAppendOptions(kind="verification_evidence", body=body), |
| 32 | ).exit_code |
| 33 | == 0 |
| 34 | ) |
| 35 | assert verify_ledger_file(config=config, repo_root=repo_root).exit_code == 0 |
| 36 | elapsed = time.perf_counter() - started |
| 37 | assert elapsed < _APPEND_VERIFY_BUDGET_S |
| 38 | |
| 39 | |
| 40 | def test_match_scan_linear_no_filesystem_walk(repo_root) -> None: |
| 41 | config = seed_p_evidence_repo(repo_root) |
| 42 | for round_num in range(1, 101): |
| 43 | body = load_p_evidence_entry("verification-evidence-pass.json") |
| 44 | body["round"] = round_num |
| 45 | body["actor_session_id"] = f"bv-{round_num}" |
| 46 | append_entry( |
| 47 | config=config, |
| 48 | repo_root=repo_root, |
| 49 | options=LedgerAppendOptions(kind="verification_evidence", body=body), |
| 50 | ) |
| 51 | started = time.perf_counter() |
| 52 | result = run_honesty_status( |
| 53 | config=config, |
| 54 | repo_root=repo_root, |
| 55 | options=HonestyStatusOptions( |
| 56 | hook=None, |
| 57 | artifact=None, |
| 58 | verification_evidence="Track P / P-evidence", |
| 59 | ), |
| 60 | ) |
| 61 | elapsed = time.perf_counter() - started |
| 62 | assert result.exit_code == 0 |
| 63 | assert elapsed < _MATCH_SCAN_BUDGET_S |
File History
1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab
NXP-b DONE: independent BV-r2 pass + ISR (SD-17)
Human
minor
⚠
18 hours ago