test_p_deploy_integration.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
1 day ago
| 1 | """Integration tests for P-deploy Mode C honesty-status (§PD.9).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import yaml |
| 6 | |
| 7 | from tests.fixtures.p_deploy import load_p_deploy_entry, seed_p_deploy_repo |
| 8 | from tools.honesty.ledger import append_entry |
| 9 | from tools.honesty.status import HonestyStatusOptions, run_honesty_status |
| 10 | from tools.honesty.types import LedgerAppendOptions |
| 11 | |
| 12 | |
| 13 | def test_mode_c_require_missing_exit_34(repo_root) -> None: |
| 14 | config = seed_p_deploy_repo(repo_root, require_deploy_health="require") |
| 15 | result = run_honesty_status( |
| 16 | config=config, |
| 17 | repo_root=repo_root, |
| 18 | options=HonestyStatusOptions( |
| 19 | hook=None, |
| 20 | artifact=None, |
| 21 | deploy_health="Track P / P-deploy", |
| 22 | ), |
| 23 | ) |
| 24 | assert result.exit_code == 34 |
| 25 | assert result.json_payload.error == "missing_deploy_health" |
| 26 | assert result.json_payload.deploy_health is not None |
| 27 | assert result.json_payload.verification_evidence is None |
| 28 | |
| 29 | |
| 30 | def test_mode_c_matching_deploy_health_exit_0(repo_root) -> None: |
| 31 | config = seed_p_deploy_repo(repo_root, require_deploy_health="require") |
| 32 | body = load_p_deploy_entry("verification-with-deploy-health.json") |
| 33 | append_entry( |
| 34 | config=config, |
| 35 | repo_root=repo_root, |
| 36 | options=LedgerAppendOptions(kind="verification_evidence", body=body), |
| 37 | ) |
| 38 | result = run_honesty_status( |
| 39 | config=config, |
| 40 | repo_root=repo_root, |
| 41 | options=HonestyStatusOptions( |
| 42 | hook=None, |
| 43 | artifact=None, |
| 44 | deploy_health="Track P / P-deploy", |
| 45 | frozen_spec="docs/archive/phases/PHASE-TRACK-P-P-DEPLOY.md", |
| 46 | ), |
| 47 | ) |
| 48 | assert result.exit_code == 0 |
| 49 | assert result.json_payload.deploy_health["matched_entry_hash"] is not None |
| 50 | assert result.json_payload.verification_evidence is None |
| 51 | |
| 52 | |
| 53 | def test_mode_c_test_output_only_does_not_satisfy(repo_root) -> None: |
| 54 | config = seed_p_deploy_repo(repo_root, require_deploy_health="require") |
| 55 | body = load_p_deploy_entry("verification-test-output-only.json") |
| 56 | append_entry( |
| 57 | config=config, |
| 58 | repo_root=repo_root, |
| 59 | options=LedgerAppendOptions(kind="verification_evidence", body=body), |
| 60 | ) |
| 61 | result = run_honesty_status( |
| 62 | config=config, |
| 63 | repo_root=repo_root, |
| 64 | options=HonestyStatusOptions( |
| 65 | hook=None, |
| 66 | artifact=None, |
| 67 | deploy_health="Track P / P-deploy", |
| 68 | ), |
| 69 | ) |
| 70 | assert result.exit_code == 34 |
| 71 | assert result.json_payload.error == "missing_deploy_health" |
| 72 | |
| 73 | |
| 74 | def test_mode_c_warn_missing_exit_0_with_warning(repo_root) -> None: |
| 75 | config = seed_p_deploy_repo(repo_root, require_deploy_health="warn") |
| 76 | result = run_honesty_status( |
| 77 | config=config, |
| 78 | repo_root=repo_root, |
| 79 | options=HonestyStatusOptions( |
| 80 | hook=None, |
| 81 | artifact=None, |
| 82 | deploy_health="Track P / P-deploy", |
| 83 | ), |
| 84 | ) |
| 85 | assert result.exit_code == 0 |
| 86 | assert "warning:" in result.stderr_extra |
| 87 | assert "deploy_health" in result.stderr_extra |
| 88 | |
| 89 | |
| 90 | def test_mode_c_off_not_enforced(repo_root) -> None: |
| 91 | config = seed_p_deploy_repo(repo_root, require_deploy_health="off") |
| 92 | result = run_honesty_status( |
| 93 | config=config, |
| 94 | repo_root=repo_root, |
| 95 | options=HonestyStatusOptions( |
| 96 | hook=None, |
| 97 | artifact=None, |
| 98 | deploy_health="Track P / P-deploy", |
| 99 | ), |
| 100 | ) |
| 101 | assert result.exit_code == 0 |
| 102 | assert result.json_payload.ok is True |
| 103 | assert result.json_payload.deploy_health["matched_entry_hash"] is None |
| 104 | assert result.json_payload.error is None |
| 105 | |
| 106 | |
| 107 | def test_mode_a_b_c_combined_exit_1(repo_root) -> None: |
| 108 | config = seed_p_deploy_repo(repo_root) |
| 109 | result = run_honesty_status( |
| 110 | config=config, |
| 111 | repo_root=repo_root, |
| 112 | options=HonestyStatusOptions( |
| 113 | hook="board_done", |
| 114 | artifact="artifacts/sample.txt", |
| 115 | deploy_health="Track P / P-deploy", |
| 116 | ), |
| 117 | ) |
| 118 | assert result.exit_code == 1 |
| 119 | |
| 120 | result_bc = run_honesty_status( |
| 121 | config=config, |
| 122 | repo_root=repo_root, |
| 123 | options=HonestyStatusOptions( |
| 124 | hook=None, |
| 125 | artifact=None, |
| 126 | verification_evidence="Track P / P-deploy", |
| 127 | deploy_health="Track P / P-deploy", |
| 128 | ), |
| 129 | ) |
| 130 | assert result_bc.exit_code == 1 |
| 131 | |
| 132 | |
| 133 | def test_mode_a_and_b_unchanged_without_mode_c(repo_root) -> None: |
| 134 | from tests.support import load_honesty_config |
| 135 | |
| 136 | config = load_honesty_config(repo_root) |
| 137 | mode_a = run_honesty_status( |
| 138 | config=config, |
| 139 | repo_root=repo_root, |
| 140 | options=HonestyStatusOptions(hook="board_done", artifact="artifacts/sample.txt"), |
| 141 | ) |
| 142 | assert mode_a.exit_code == 20 |
| 143 | assert mode_a.json_payload.deploy_health is None |
| 144 | assert mode_a.json_payload.verification_evidence is None |
| 145 | |
| 146 | config_b = seed_p_deploy_repo(repo_root, require_verification_evidence="require") |
| 147 | mode_b = run_honesty_status( |
| 148 | config=config_b, |
| 149 | repo_root=repo_root, |
| 150 | options=HonestyStatusOptions( |
| 151 | hook=None, |
| 152 | artifact=None, |
| 153 | verification_evidence="Track P / P-deploy", |
| 154 | ), |
| 155 | ) |
| 156 | assert mode_b.exit_code == 33 |
| 157 | assert mode_b.json_payload.deploy_health is None |
| 158 | assert mode_b.json_payload.verification_evidence is not None |
| 159 | |
| 160 | |
| 161 | def test_honesty_disabled_mode_c_exit_4(repo_root) -> None: |
| 162 | seed_p_deploy_repo(repo_root, require_deploy_health="require") |
| 163 | cfg_path = repo_root / ".overseer" / "config.yaml" |
| 164 | data = yaml.safe_load(cfg_path.read_text(encoding="utf-8")) |
| 165 | data["honesty"]["enabled"] = False |
| 166 | data["modules"]["honesty"]["enabled"] = False |
| 167 | cfg_path.write_text(yaml.safe_dump(data), encoding="utf-8") |
| 168 | from adapters.config import load_config |
| 169 | |
| 170 | config = load_config(cfg_path) |
| 171 | result = run_honesty_status( |
| 172 | config=config, |
| 173 | repo_root=repo_root, |
| 174 | options=HonestyStatusOptions( |
| 175 | hook=None, |
| 176 | artifact=None, |
| 177 | deploy_health="Track P / P-deploy", |
| 178 | ), |
| 179 | ) |
| 180 | assert result.exit_code == 4 |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
1 day ago