fix(test): align governance self_failure assertions with nested payload schema
Codex commitsdedb1208+b710f3f3(governance enrich + normalize) 把 _alert("governance_self_failure", ...) 的 payload structure 重構成嵌套: {status, impact: {failed_checks, total_checks, errors}, remediation, actionable} (governance_agent.py:604-624,2026-04-29 critic M6 修), 但 3 個 test 還用舊路徑 `payload["total_checks"]` 直讀,KeyError 後 RuntimeError 模擬 cascading 失敗。 修法:3 個 assertion 改為讀正確嵌套路徑: - test_governance_agent.py:601 → payload["impact"]["total_checks"|"failed_checks"] - test_wave8_remaining_blockers.py:223 → 同 - test_wave8_remaining_blockers.py:268 → 同 Tests: 30 passed (test_governance_agent + test_wave8_remaining_blockers 全部) 效果:解開dedb1208/b710f3f3/a38d9112三個 commit 因 governance test fail 被擋在 build-and-deploy 之前的卡點,恢復 CD 鏈通暢。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -619,9 +619,11 @@ class TestRunSelfCheckGlobalFailureAlert:
|
||||
governance_failure_calls = [c for c in calls if c[0][0] == "governance_self_failure"]
|
||||
assert len(governance_failure_calls) >= 1
|
||||
|
||||
# 2026-05-03 Claude Opus 4.7 + 統帥 ogt:對齊 governance_agent.py:604-624 的嵌套 payload structure
|
||||
# (critic M6 修:{status, impact, remediation, actionable}),原本直接讀 payload["total_checks"] 會 KeyError
|
||||
payload = governance_failure_calls[0][0][1]
|
||||
assert payload["total_checks"] == 5
|
||||
assert len(payload["failed_checks"]) == 5
|
||||
assert payload["impact"]["total_checks"] == 5
|
||||
assert len(payload["impact"]["failed_checks"]) == 5
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_two_checks_fail_does_not_trigger_governance_self_failure(self):
|
||||
|
||||
@@ -240,9 +240,10 @@ class TestB8GovernanceFailureAlert:
|
||||
agent._alert.assert_awaited_once()
|
||||
call_args = agent._alert.await_args
|
||||
assert call_args[0][0] == "governance_self_failure"
|
||||
# 2026-05-03 Claude Opus 4.7 + 統帥 ogt:對齊 governance_agent.py:604-624 嵌套 payload structure
|
||||
payload = call_args[0][1]
|
||||
assert payload["total_checks"] == 5
|
||||
assert len(payload["failed_checks"]) >= 3
|
||||
assert payload["impact"]["total_checks"] == 5
|
||||
assert len(payload["impact"]["failed_checks"]) >= 3
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_two_failures_no_alert(self):
|
||||
@@ -282,5 +283,6 @@ class TestB8GovernanceFailureAlert:
|
||||
await agent.run_self_check()
|
||||
|
||||
agent._alert.assert_awaited_once()
|
||||
# 2026-05-03 Claude Opus 4.7 + 統帥 ogt:對齊 governance_agent.py:604-624 嵌套 payload structure
|
||||
payload = agent._alert.await_args[0][1]
|
||||
assert len(payload["failed_checks"]) == 5
|
||||
assert len(payload["impact"]["failed_checks"]) == 5
|
||||
|
||||
Reference in New Issue
Block a user