test_p_deploy_e2e.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
20 hours ago
| 1 | """End-to-end P-deploy Mode C CLI tests (§PD.9).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | from pathlib import Path |
| 7 | |
| 8 | from cli.kit_root import kit_root |
| 9 | from tests.fixtures.p_deploy import ( |
| 10 | FIXTURES, |
| 11 | copy_p_deploy_entries, |
| 12 | load_p_deploy_entry, |
| 13 | seed_p_deploy_repo, |
| 14 | ) |
| 15 | from tests.support import git_status_runner, muse_mirror_status_runner, run_cli, seed_muse_substrate |
| 16 | |
| 17 | |
| 18 | def _append_evidence(tmp_path: Path, body_name: str) -> int: |
| 19 | copy_p_deploy_entries(tmp_path) |
| 20 | payload = tmp_path / "payload.json" |
| 21 | payload.write_text(json.dumps(load_p_deploy_entry(body_name)), encoding="utf-8") |
| 22 | return run_cli( |
| 23 | ["ledger", "append", "--kind", "verification_evidence", "--file", "payload.json"], |
| 24 | cwd=tmp_path, |
| 25 | runner=git_status_runner(), |
| 26 | kit=kit_root(), |
| 27 | ) |
| 28 | |
| 29 | |
| 30 | def test_e2e_mode_b_may_match_mode_c_misses_then_deploy_health_last_wins( |
| 31 | tmp_path: Path, capsys |
| 32 | ) -> None: |
| 33 | seed_p_deploy_repo( |
| 34 | tmp_path, |
| 35 | require_deploy_health="require", |
| 36 | require_verification_evidence="require", |
| 37 | ) |
| 38 | assert _append_evidence(tmp_path, "verification-test-output-only.json") == 0 |
| 39 | |
| 40 | code_b = run_cli( |
| 41 | [ |
| 42 | "honesty-status", |
| 43 | "--verification-evidence", |
| 44 | "Track P / P-deploy", |
| 45 | "--json", |
| 46 | ], |
| 47 | cwd=tmp_path, |
| 48 | runner=git_status_runner(), |
| 49 | kit=kit_root(), |
| 50 | json_mode=True, |
| 51 | ) |
| 52 | assert code_b == 0 |
| 53 | payload_b = json.loads(capsys.readouterr().out) |
| 54 | assert payload_b["verification_evidence"]["matched_entry_hash"] is not None |
| 55 | assert "deploy_health" not in payload_b |
| 56 | |
| 57 | code_c_miss = run_cli( |
| 58 | ["honesty-status", "--deploy-health", "Track P / P-deploy", "--json"], |
| 59 | cwd=tmp_path, |
| 60 | runner=git_status_runner(), |
| 61 | kit=kit_root(), |
| 62 | json_mode=True, |
| 63 | ) |
| 64 | assert code_c_miss == 34 |
| 65 | payload_miss = json.loads(capsys.readouterr().out) |
| 66 | assert payload_miss["error"] == "missing_deploy_health" |
| 67 | assert "verification_evidence" not in payload_miss |
| 68 | |
| 69 | body = load_p_deploy_entry("verification-with-deploy-health.json") |
| 70 | second = tmp_path / "second.json" |
| 71 | second.write_text(json.dumps(body), encoding="utf-8") |
| 72 | assert run_cli( |
| 73 | ["ledger", "append", "--kind", "verification_evidence", "--file", "second.json"], |
| 74 | cwd=tmp_path, |
| 75 | runner=git_status_runner(), |
| 76 | kit=kit_root(), |
| 77 | ) == 0 |
| 78 | |
| 79 | code_c = run_cli( |
| 80 | [ |
| 81 | "honesty-status", |
| 82 | "--deploy-health", |
| 83 | "Track P / P-deploy", |
| 84 | "--frozen-spec", |
| 85 | "docs/archive/phases/PHASE-TRACK-P-P-DEPLOY.md", |
| 86 | "--json", |
| 87 | ], |
| 88 | cwd=tmp_path, |
| 89 | runner=git_status_runner(), |
| 90 | kit=kit_root(), |
| 91 | json_mode=True, |
| 92 | ) |
| 93 | assert code_c == 0 |
| 94 | payload_c = json.loads(capsys.readouterr().out) |
| 95 | ledger = (tmp_path / ".overseer" / "honesty" / "VERDICT-LEDGER.jsonl").read_text(encoding="utf-8") |
| 96 | last_line = json.loads(ledger.strip().splitlines()[-1]) |
| 97 | assert payload_c["deploy_health"]["matched_entry_hash"] == last_line["entry_hash"] |
| 98 | |
| 99 | |
| 100 | def test_skill_normative_deploy_pass_includes_deploy_health() -> None: |
| 101 | fixture = json.loads((FIXTURES / "skill-pass-body.json").read_text(encoding="utf-8")) |
| 102 | body = load_p_deploy_entry("verification-with-deploy-health.json") |
| 103 | assert body["bv_verdict"] == fixture["bv_verdict"] |
| 104 | types = {item["type"] for item in body["artifacts"]} |
| 105 | for required in fixture["required_artifact_types_for_deploy_pass"]: |
| 106 | assert required in types |
| 107 | |
| 108 | |
| 109 | def test_e2e_git_only_and_muse_regime_unsigned_mode_c(tmp_path: Path) -> None: |
| 110 | for regime in ("config-git-only.yaml", "config-muse-git-mirror.yaml"): |
| 111 | repo = tmp_path / regime |
| 112 | repo.mkdir() |
| 113 | seed_p_deploy_repo(repo, require_deploy_health="require", regime_config=regime) |
| 114 | if "muse" in regime: |
| 115 | seed_muse_substrate(repo) |
| 116 | copy_p_deploy_entries(repo) |
| 117 | payload = repo / "payload.json" |
| 118 | payload.write_text( |
| 119 | json.dumps(load_p_deploy_entry("verification-with-deploy-health.json")), |
| 120 | encoding="utf-8", |
| 121 | ) |
| 122 | runner = muse_mirror_status_runner(repo) if "muse" in regime else git_status_runner() |
| 123 | assert run_cli( |
| 124 | ["ledger", "append", "--kind", "verification_evidence", "--file", "payload.json"], |
| 125 | cwd=repo, |
| 126 | runner=runner, |
| 127 | kit=kit_root(), |
| 128 | ) == 0 |
| 129 | assert run_cli( |
| 130 | ["honesty-status", "--deploy-health", "Track P / P-deploy", "--json"], |
| 131 | cwd=repo, |
| 132 | runner=runner, |
| 133 | kit=kit_root(), |
| 134 | json_mode=True, |
| 135 | ) == 0 |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
20 hours ago