test_honesty_ledger.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
9 hours ago
| 1 | """Integration tests for honesty ledger append and status.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | |
| 7 | from tests.support import honesty_artifact_hash, load_honesty_config, load_honesty_entry |
| 8 | from tools.honesty.ledger import append_entry, show_entries, verify_ledger_file |
| 9 | from tools.honesty.status import HonestyStatusOptions, run_honesty_status |
| 10 | from tools.honesty.types import LedgerAppendOptions |
| 11 | |
| 12 | |
| 13 | def test_append_verify_round_trip(repo_root) -> None: |
| 14 | config = load_honesty_config(repo_root) |
| 15 | body = load_honesty_entry(repo_root, "verdict-pass.json") |
| 16 | code = append_entry( |
| 17 | config=config, |
| 18 | repo_root=repo_root, |
| 19 | options=LedgerAppendOptions(kind="verdict", body=body), |
| 20 | ).exit_code |
| 21 | assert code == 0 |
| 22 | verify = verify_ledger_file(config=config, repo_root=repo_root) |
| 23 | assert verify.exit_code == 0 |
| 24 | |
| 25 | |
| 26 | def test_first_append_auto_genesis(repo_root) -> None: |
| 27 | config = load_honesty_config(repo_root) |
| 28 | body = load_honesty_entry(repo_root, "verdict-pass.json") |
| 29 | append_entry( |
| 30 | config=config, |
| 31 | repo_root=repo_root, |
| 32 | options=LedgerAppendOptions(kind="verdict", body=body), |
| 33 | ) |
| 34 | ledger = repo_root / ".overseer" / "honesty" / "VERDICT-LEDGER.jsonl" |
| 35 | lines = ledger.read_text(encoding="utf-8").strip().splitlines() |
| 36 | assert len(lines) == 2 |
| 37 | first = json.loads(lines[0]) |
| 38 | assert first["kind"] == "genesis" |
| 39 | |
| 40 | |
| 41 | def test_missing_ledger_status_20(repo_root) -> None: |
| 42 | config = load_honesty_config(repo_root) |
| 43 | result = run_honesty_status( |
| 44 | config=config, |
| 45 | repo_root=repo_root, |
| 46 | options=HonestyStatusOptions(hook="board_done", artifact="artifacts/sample.txt"), |
| 47 | ) |
| 48 | assert result.exit_code == 20 |
| 49 | |
| 50 | |
| 51 | def test_co_requirement_pass(repo_root) -> None: |
| 52 | config = load_honesty_config(repo_root) |
| 53 | body = load_honesty_entry(repo_root, "verdict-pass.json") |
| 54 | append_entry( |
| 55 | config=config, |
| 56 | repo_root=repo_root, |
| 57 | options=LedgerAppendOptions(kind="verdict", body=body), |
| 58 | ) |
| 59 | result = run_honesty_status( |
| 60 | config=config, |
| 61 | repo_root=repo_root, |
| 62 | options=HonestyStatusOptions(hook="handoff", artifact="artifacts/sample.txt"), |
| 63 | ) |
| 64 | assert result.exit_code == 0 |
| 65 | assert result.json_payload.matched_verdict_hash is not None |
| 66 | |
| 67 | |
| 68 | def test_ledger_show_missing_empty(repo_root) -> None: |
| 69 | config = load_honesty_config(repo_root) |
| 70 | result = show_entries(config=config, repo_root=repo_root, last_n=5) |
| 71 | assert result.exit_code == 0 |
| 72 | assert result.stdout_lines == [] |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
9 hours ago