fix(api): ignore stale cd failure after production readback
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 38s
CD Pipeline / build-and-deploy (push) Successful in 6m11s
CD Pipeline / post-deploy-checks (push) Successful in 1m55s

This commit is contained in:
ogt
2026-07-01 21:16:19 +08:00
parent 140d8142fd
commit 3c9f648963
3 changed files with 225 additions and 33 deletions

View File

@@ -799,6 +799,81 @@ def test_awoooi_priority_work_order_readback_normalizes_runtime_source_truth(
assert "f426522" not in current_truth
def test_awoooi_priority_work_order_readback_does_not_reopen_stale_cd_failure_after_production_readback(
monkeypatch: pytest.MonkeyPatch,
):
runtime_sha = "b4dc407ce05c68a3908b993437a61b869d83810f"
runtime_short_sha = runtime_sha[:10]
monkeypatch.setenv("AWOOOI_BUILD_COMMIT_SHA", runtime_sha)
monkeypatch.setenv("AWOOOI_DESIRED_API_IMAGE_TAG", runtime_sha)
payload = load_latest_awoooi_priority_work_order_readback()
apply_harbor_registry_controlled_recovery_preflight(
payload,
_harbor_registry_ready(),
)
executor = json.loads(
json.dumps(load_latest_ai_agent_log_controlled_writeback_executor_readback())
)
executor["agent_consumption_context"]["current_blocker_execution_queue"][0].update(
{
"deployment_closure_state": (
"blocked_latest_visible_cd_failure_after_registry_ready"
),
"deploy_marker_readback_required": True,
"current_cd_run_id": "4258",
"current_cd_run_status": "Failure",
"current_cd_commit_sha": "06819ea96c058e7987811e853242390eaced7f91",
"cd_failed_after_registry_ready": True,
}
)
apply_ai_loop_current_blocker_execution_queue(
payload,
executor,
)
state = payload["mainline_execution_state"]
evidence = payload["in_progress_or_blocked_in_priority_order"][0]["evidence"]
blockers = state["active_p0_live_active_blockers"]
assert state["current_main_cd_run_status"] == "production_readback_verified"
assert state["ai_loop_current_blocker_deploy_marker_readback_required"] is False
assert state["ai_loop_current_blocker_cd_failed_after_registry_ready"] is False
assert (
state["ai_loop_current_blocker_deploy_marker_resolved_by_production_readback"]
is True
)
assert state["ai_loop_current_blocker_current_cd_run_status"] == (
"production_readback_verified"
)
assert state["ai_loop_current_blocker_current_cd_run_id"] == (
f"production_readback:{runtime_short_sha}"
)
assert state["ai_loop_current_blocker_historical_current_cd_run_id"] == "4258"
assert state["ai_loop_current_blocker_historical_current_cd_run_status"] == (
"Failure"
)
assert "deploy_marker_readback_required_after_registry_ready" not in blockers
assert "current_cd_failure_after_registry_ready" not in blockers
assert evidence["ai_loop_current_blocker_deploy_marker_readback_required"] is False
assert evidence["ai_loop_current_blocker_cd_failed_after_registry_ready"] is False
assert evidence[
"ai_loop_current_blocker_historical_deploy_marker_readback_required"
] is True
assert evidence["ai_loop_current_blocker_historical_current_cd_run_status"] == (
"Failure"
)
assert payload["summary"][
"ai_loop_current_blocker_deploy_marker_resolved_by_production_readback"
] is True
assert payload["summary"]["ai_loop_current_blocker_current_cd_run_status"] == (
"production_readback_verified"
)
assert all(
"P0-006-CD-DEPLOY-MARKER-READBACK" not in item
for item in payload["next_execution_order"]
)
def test_awoooi_priority_work_order_readback_rejects_reordered_active_p0(tmp_path):
operations_dir = tmp_path / "docs" / "operations"
operations_dir.mkdir(parents=True)