fix(agent): accept JSON null pre-decision evidence
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 1m38s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped

This commit is contained in:
ogt
2026-07-10 21:51:20 +08:00
parent cbb064b083
commit 7b08df3bdb
4 changed files with 12 additions and 2 deletions

View File

@@ -188,7 +188,10 @@ async def verify_ansible_candidate_pre_decision_evidence(
FROM incident_evidence
WHERE id = :snapshot_id
AND incident_id = :incident_id
AND post_execution_state IS NULL
AND (
post_execution_state IS NULL
OR CAST(post_execution_state AS jsonb) = 'null'::jsonb
)
AND sensors_succeeded > 0
AND NULLIF(recent_logs, '') IS NOT NULL
AND EXISTS (

View File

@@ -967,7 +967,11 @@ async def _load_pre_decision_context_runtime_stage_receipts(
ON candidate.op_id = CAST(:candidate_op_id AS uuid)
WHERE evidence.incident_id = CAST(:incident_id AS varchar(30))
AND evidence.collected_at <= candidate.created_at
AND evidence.post_execution_state IS NULL
AND (
evidence.post_execution_state IS NULL
OR CAST(evidence.post_execution_state AS jsonb)
= 'null'::jsonb
)
AND (
NULLIF(evidence.recent_logs, '') IS NOT NULL
OR evidence.mcp_health IS NOT NULL

View File

@@ -198,6 +198,7 @@ async def test_predecision_verifier_casts_json_health_to_jsonb(
assert verified is True
assert "CAST(mcp_health AS jsonb)" in statements[0]
assert "CAST(post_execution_state AS jsonb) = 'null'::jsonb" in statements[0]
@pytest.mark.asyncio

View File

@@ -2037,6 +2037,8 @@ def test_ansible_context_receipts_reference_pre_decision_evidence_without_conten
loader_source = inspect.getsource(_load_pre_decision_context_runtime_stage_receipts)
assert "evidence.collected_at <= candidate.created_at" in loader_source
assert "evidence.post_execution_state IS NULL" in loader_source
assert "CAST(evidence.post_execution_state AS jsonb)" in loader_source
assert "= 'null'::jsonb" in loader_source
def test_ansible_context_receipt_rejects_zero_success_mcp_attempts() -> None: