chore: sync latest Gitea main
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m50s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-10 23:46:02 +08:00
6 changed files with 105 additions and 8 deletions

View File

@@ -2448,11 +2448,53 @@ def test_runtime_telegram_receipt_queries_include_alert_notifications() -> None:
def test_runtime_operation_latest_queries_prioritize_latest_apply_chain() -> None:
for sql in (_RUNTIME_OPERATION_LATEST_SQL, _RUNTIME_OPERATION_LATEST_DIRECT_SQL):
assert "WITH latest_apply_chain AS" in sql
assert "AND status IN ('success', 'failed')" in sql
assert "operation_row.op_id::text = latest_apply_chain.apply_op_id" in sql
assert "operation_row.op_id::text = latest_apply_chain.check_mode_op_id" in sql
assert "operation_row.op_id::text = latest_apply_chain.candidate_op_id" in sql
def test_runtime_execution_loop_uses_terminal_apply_without_hiding_inflight_apply():
ledger = runtime_control_module._autonomous_execution_loop_ledger(
project_id="awoooi",
operation_latest_rows=[
{
"op_id": "pending-apply",
"operation_type": "ansible_apply_executed",
"status": "pending",
"automation_run_id": "pending-run",
"incident_id": "INC-PENDING",
"created_at": "2026-07-10T15:00:00Z",
},
{
"op_id": "terminal-apply",
"operation_type": "ansible_apply_executed",
"status": "failed",
"automation_run_id": "terminal-run",
"incident_id": "INC-TERMINAL",
"created_at": "2026-07-10T14:59:00Z",
},
],
verifier_latest_rows=[],
km_latest_rows=[],
telegram_latest_rows=[],
auto_repair_latest_rows=[],
latest_flow_closure={},
latest_failure_classification={},
controlled_retry_package={},
)
assert ledger["operation_id"] == "terminal-apply"
assert ledger["completion_anchor"] == "latest_terminal_apply"
assert ledger["latest_inflight_apply"] == {
"op_id": "pending-apply",
"status": "pending",
"automation_run_id": "pending-run",
"incident_id": "INC-PENDING",
"created_at": "2026-07-10T15:00:00Z",
}
def test_runtime_execution_loop_ledger_does_not_mix_unrelated_check_mode_rows():
apply_op_id = "db3f12ce-08fc-4289-8c93-338305d5850c"
readback = build_runtime_receipt_readback_from_rows(

View File

@@ -1935,6 +1935,8 @@ def test_failed_apply_retry_replay_is_no_write_and_idempotent() -> None:
assert "FOR UPDATE SKIP LOCKED" in source
assert "controlled_retry_check_mode_replay" in source
assert "build_ansible_check_mode_command" in source
assert "verifier.incident_id = coalesce(" in source
assert "apply.input ->> 'incident_id'" in source
assert "controlled_apply_allowed=True" in source
assert '"approval_required_before_apply": False' in source
assert '"owner_review_required": False' in source