diff --git a/.gitea/workflows/e2e-health.yaml b/.gitea/workflows/e2e-health.yaml index 37c4f68a..ea800552 100644 --- a/.gitea/workflows/e2e-health.yaml +++ b/.gitea/workflows/e2e-health.yaml @@ -78,6 +78,7 @@ jobs: --allow-existing-apply \ --refresh-if-stale-days 6 \ --refresh-work-item-id "${SOURCE_CANARY_WORK_ITEM_ID}" \ + --verify-refresh-candidate \ --reviewer-id gitea_e2e_source_link_canary \ --operator-note "T122 rolling source-correlation canary refresh; append-only status-chain proof" diff --git a/scripts/awooop_source_correlation_apply_smoke.py b/scripts/awooop_source_correlation_apply_smoke.py index 4fc6b4fe..228e8a85 100644 --- a/scripts/awooop_source_correlation_apply_smoke.py +++ b/scripts/awooop_source_correlation_apply_smoke.py @@ -290,6 +290,17 @@ def _select_refresh_work_item( ) +def _refresh_candidate_result(item: dict[str, Any]) -> dict[str, Any]: + return { + "refresh_candidate_status": "ready", + "refresh_candidate_work_item_id": _source_review_work_item_id(item), + "refresh_candidate_latest_provider_event_id": item.get( + "latest_provider_event_id" + ), + "refresh_candidate_alertname": item.get("alertname"), + } + + def _apply_source_correlation_item( *, args: argparse.Namespace, @@ -453,6 +464,11 @@ def run(args: argparse.Namespace) -> dict[str, Any]: refresh_if_stale_days=args.refresh_if_stale_days, ) if not refresh_reason: + refresh_candidate: dict[str, Any] = {} + if args.verify_refresh_candidate: + refresh_candidate = _refresh_candidate_result( + _select_refresh_work_item(recurrence, args=args) + ) return { **existing, "apply_status": existing_apply.get("apply_status"), @@ -461,6 +477,7 @@ def run(args: argparse.Namespace) -> dict[str, Any]: ), "refresh_if_stale_days": args.refresh_if_stale_days, "refresh_reason": None, + **refresh_candidate, } previous_latest_applied_link_at = str( existing.get("latest_applied_link_at") or "" @@ -539,6 +556,14 @@ def parse_args(argv: list[str]) -> argparse.Namespace: action="store_true", help="When refresh is needed, use the latest unapplied canary/smoke/codex work item.", ) + parser.add_argument( + "--verify-refresh-candidate", + action="store_true", + help=( + "Even when the existing applied link is still fresh, verify that " + "the configured refresh work item exists and is safe to apply later." + ), + ) parser.add_argument("--dry-run", action="store_true") return parser.parse_args(argv)