fix(agent): retain shadow policy on stale replay
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / build-and-deploy (push) Has been cancelled
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / tests (push) Has been cancelled

This commit is contained in:
ogt
2026-07-15 02:19:52 +08:00
parent 58b3d2178c
commit e3acc321a7
2 changed files with 77 additions and 0 deletions

View File

@@ -56,6 +56,20 @@ _CONTROLLED_RETRY_ERROR_BACKOFF_MIN_SECONDS = 15
_CONTROLLED_RETRY_ERROR_BACKOFF_MAX_SECONDS = 30
_STDIN_BOUNDARY_REPLAY_WINDOW_HOURS = 7 * 24
_CATALOG_REPAIR_REPLAY_WINDOW_HOURS = 72
_STALE_CLAIM_REPLAY_CONTROL_FIELDS = (
"bounded_execution_scope",
"catalog_drift_replay",
"catalog_repair_of_apply_op_id",
"catalog_replay_revision",
"previous_catalog_revision",
"previous_check_mode_playbook_path",
"replay_of_check_mode_op_id",
"semantic_repair_of_apply_op_id",
"semantic_route_reconciliation",
)
_HISTORICAL_SHADOW_REPLAY_TAGS = frozenset(
{"catalog_drift_replay", "semantic_catalog_reconciliation"}
)
_STDIN_BOUNDARY_TERMINAL_PROJECTION_BATCH_LIMIT = 5
_EXECUTION_CAPABILITY_MIN_TTL_SECONDS = 300
_EXECUTION_CAPABILITY_MAX_TTL_SECONDS = 1_800
@@ -1136,6 +1150,24 @@ def _claim_from_stale_check_mode_row(
"incident_semantic_route_rechecked": incident_routing_evaluated,
}
)
for field_name in _STALE_CLAIM_REPLAY_CONTROL_FIELDS:
if field_name in input_payload:
claim_input[field_name] = input_payload[field_name]
row_tags = {
str(tag)
for tag in (row.get("tags") or [])
if isinstance(tag, str)
}
historical_shadow_replay = bool(
row_tags & _HISTORICAL_SHADOW_REPLAY_TAGS
)
if (
historical_shadow_replay
or input_payload.get("historical_projection_backfill") is True
or input_payload.get("telegram_provider_delivery") == "shadow_only"
):
claim_input["historical_projection_backfill"] = True
claim_input["telegram_provider_delivery"] = "shadow_only"
return AnsibleCheckModeClaim(
op_id=str(row.get("op_id") or ""),
source_candidate_op_id=source_candidate_op_id,
@@ -7443,6 +7475,7 @@ async def claim_stale_pending_check_modes(
SELECT
check_mode.op_id,
check_mode.parent_op_id,
check_mode.tags,
coalesce(
check_mode.incident_id::text,
check_mode.input ->> 'incident_id'