fix(agent): prioritize live closure 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 1m12s
CD Pipeline / build-and-deploy (push) Successful in 7m23s
CD Pipeline / post-deploy-checks (push) Successful in 1m53s

This commit is contained in:
ogt
2026-07-11 15:36:37 +08:00
parent 526cb5af8c
commit aba8ff474e
4 changed files with 61 additions and 13 deletions

View File

@@ -60,9 +60,9 @@ _LIVE_RUNTIME_RECEIPT_TIMEOUT_SECONDS = 8.0
_RUNTIME_RECEIPT_LOCK_TIMEOUT_SECONDS = 0.25
_RUNTIME_RECEIPT_DB_CONTEXT_TIMEOUT_SECONDS = 1.5
_RUNTIME_RECEIPT_DB_CONTEXT_EXIT_TIMEOUT_SECONDS = 0.25
_RUNTIME_RECEIPT_QUERY_BUDGET_SECONDS = 2.0
_RUNTIME_RECEIPT_SINGLE_QUERY_TIMEOUT_SECONDS = 0.45
_RUNTIME_RECEIPT_STATEMENT_TIMEOUT_MS = 400
_RUNTIME_RECEIPT_QUERY_BUDGET_SECONDS = 3.0
_RUNTIME_RECEIPT_SINGLE_QUERY_TIMEOUT_SECONDS = 0.75
_RUNTIME_RECEIPT_STATEMENT_TIMEOUT_MS = 700
_LOG_CONTROLLED_WRITEBACK_CONSUMER_TIMEOUT_SECONDS = 4.0
_LOG_CONTROLLED_WRITEBACK_CONSUMER_READBACK_CACHE_TTL_SECONDS = 30.0
_RUNTIME_RECEIPT_READBACK_CACHE_TTL_SECONDS = 20.0
@@ -6600,18 +6600,14 @@ async def _load_ai_agent_autonomous_runtime_receipt_readback_uncached(
)
return []
operation_counts = await _safe_rows(
"operation_counts",
_RUNTIME_OPERATION_COUNTS_SQL,
retry_terminal_latest = await _safe_rows(
"retry_terminal_latest",
_RUNTIME_RETRY_TERMINAL_LATEST_SQL,
)
operation_latest = await _safe_rows(
"operation_latest",
_RUNTIME_OPERATION_LATEST_SQL,
)
retry_terminal_latest = await _safe_rows(
"retry_terminal_latest",
_RUNTIME_RETRY_TERMINAL_LATEST_SQL,
)
for chain_pass in range(2):
missing_chain_refs = _missing_runtime_operation_chain_ref_ids(
operation_latest
@@ -6636,6 +6632,10 @@ async def _load_ai_agent_autonomous_runtime_receipt_readback_uncached(
operation_latest,
operation_chain_rows,
)
operation_counts = await _safe_rows(
"operation_counts",
_RUNTIME_OPERATION_COUNTS_SQL,
)
auto_repair_counts = await _safe_rows(
"auto_repair_counts",
_RUNTIME_AUTO_REPAIR_COUNTS_SQL,
@@ -7401,6 +7401,9 @@ _RUNTIME_OPERATION_LATEST_SQL = """
FROM automation_operation_log
WHERE operation_type = 'ansible_apply_executed'
AND status IN ('success', 'failed')
AND created_at >= NOW() - (
:lookback_hours * INTERVAL '1 hour'
)
ORDER BY created_at DESC
LIMIT 1
)
@@ -7479,6 +7482,9 @@ _RUNTIME_OPERATION_LATEST_SQL = """
'ansible_executor_capability_expired',
'log_controlled_writeback_dispatched'
)
AND operation_row.created_at >= NOW() - (
:lookback_hours * INTERVAL '1 hour'
)
ORDER BY
CASE
WHEN operation_row.op_id::text IN (