refactor(pchome): extract controlled drift verifier
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
This commit is contained in:
@@ -5,6 +5,7 @@ from services.pchome_mapping_backlog import (
|
||||
artifacts,
|
||||
contracts,
|
||||
controlled_apply_executor,
|
||||
controlled_apply_verifier,
|
||||
evidence,
|
||||
policies,
|
||||
)
|
||||
@@ -95,7 +96,46 @@ def test_controlled_apply_executor_core_is_no_write_without_apply_request(tmp_pa
|
||||
assert result["safety"]["writes_artifact_count"] == 0
|
||||
|
||||
|
||||
def test_legacy_facade_is_smaller_after_second_p0_extraction():
|
||||
def test_controlled_apply_drift_verifier_core_is_no_write(tmp_path):
|
||||
replay = {
|
||||
"result": "DIRECT_MAPPING_RETRY_EXCEPTION_CONTROLLED_APPLY_RECEIPT_REPLAYED",
|
||||
"summary": {
|
||||
"target_selector_count": 1,
|
||||
"post_apply_readback_count": 1,
|
||||
"post_apply_readback_pass_count": 1,
|
||||
"executor_receipt_hash_match_count": 1,
|
||||
"missing_artifact_count": 0,
|
||||
},
|
||||
"post_apply_readbacks": [
|
||||
{
|
||||
"selector_id": "selector-1",
|
||||
"momo_icode": "MOMO-1",
|
||||
"expected_pchome_id": "PCH-1",
|
||||
"actual_pchome_id": "PCH-1",
|
||||
"passed": True,
|
||||
"writes_database": False,
|
||||
}
|
||||
],
|
||||
"receipt_replay": {"run_id": "run-1"},
|
||||
"missing_artifacts": [],
|
||||
}
|
||||
|
||||
result = controlled_apply_verifier.build_controlled_apply_drift_verifier_from_replay(
|
||||
replay,
|
||||
root=tmp_path,
|
||||
source_receipt_replay=replay,
|
||||
)
|
||||
|
||||
assert result["result"] == "DIRECT_MAPPING_RETRY_EXCEPTION_CONTROLLED_APPLY_DRIFT_VERIFIED"
|
||||
assert result["success"] is True
|
||||
assert result["summary"]["drift_count"] == 0
|
||||
assert result["summary"]["drift_verified_count"] == 1
|
||||
assert result["all_checks_passed"] is True
|
||||
assert result["safety"]["writes_database_count"] == 0
|
||||
assert result["safety"]["writes_artifact_count"] == 0
|
||||
|
||||
|
||||
def test_legacy_facade_is_smaller_after_third_p0_extraction():
|
||||
facade = ROOT / "services/pchome_mapping_backlog_service.py"
|
||||
|
||||
assert sum(1 for _ in facade.open(encoding="utf-8")) < 44_000
|
||||
assert sum(1 for _ in facade.open(encoding="utf-8")) < 43_850
|
||||
|
||||
Reference in New Issue
Block a user