feat(agent): project ai loop blocker into work order
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 35s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

This commit is contained in:
Your Name
2026-06-30 22:47:22 +08:00
parent 7be629d733
commit 2736ca9149
4 changed files with 243 additions and 0 deletions

View File

@@ -336,6 +336,7 @@ from src.services.awoooi_gitea_onboarding_warning_step_template_copy_receipt imp
load_latest_awoooi_gitea_onboarding_warning_step_template_copy_receipt,
)
from src.services.awoooi_priority_work_order_readback import (
apply_ai_loop_current_blocker_execution_queue,
apply_harbor_registry_controlled_recovery_preflight,
apply_stockplatform_public_api_controlled_recovery_preflight,
apply_stockplatform_public_api_runtime_readback,
@@ -1114,6 +1115,10 @@ async def get_awoooi_priority_work_order_readback() -> dict[str, Any]:
payload,
harbor_recovery,
)
log_executor = await asyncio.to_thread(
load_latest_ai_agent_log_controlled_writeback_executor_readback
)
apply_ai_loop_current_blocker_execution_queue(payload, log_executor)
return redact_public_lan_topology(payload)
except FileNotFoundError as exc:
raise HTTPException(

View File

@@ -498,6 +498,146 @@ def apply_harbor_registry_controlled_recovery_preflight(
)
def apply_ai_loop_current_blocker_execution_queue(
payload: dict[str, Any],
executor_readback: dict[str, Any],
) -> None:
"""Overlay the AI Loop current blocker queue onto the ordered work board."""
if payload.get("status") != (
"p0_006_blocked_harbor_registry_controlled_recovery_preflight"
):
return
context = _dict(executor_readback.get("agent_consumption_context"))
queue = list(_list(context.get("current_blocker_execution_queue")))
if not queue:
return
first_item = _dict(queue[0])
blocker_id = str(first_item.get("blocker_id") or "")
controlled_recovery_package = str(
first_item.get("controlled_recovery_package") or ""
)
post_apply_verifier = str(first_item.get("post_apply_verifier") or "")
learning_targets = _strings(first_item.get("learning_writeback_targets"))
target_batches = _strings(first_item.get("target_batches"))
external_blocker = str(first_item.get("external_control_path_blocker") or "")
runtime_write_gate = str(first_item.get("runtime_write_gate") or "")
state = _dict(payload.setdefault("mainline_execution_state", {}))
state["active_p0_state"] = "blocked_ai_loop_current_blocker_execution_queue"
state["next_executable_mainline_workplan_id"] = (
"P0-006-AI-LOOP-CURRENT-BLOCKER-EXECUTION-QUEUE"
)
state["next_executable_mainline_state"] = (
"ai_loop_current_blocker_queue_waiting_110_control_path_readback"
)
state["ai_loop_current_blocker_execution_queue_count"] = len(queue)
state["ai_loop_current_blocker_id"] = blocker_id
state["ai_loop_current_blocker_control_path_blocker"] = external_blocker
state["ai_loop_current_blocker_runtime_write_gate"] = runtime_write_gate
state["ai_loop_current_blocker_learning_target_count"] = len(learning_targets)
state["active_p0_live_active_blockers"] = _unique_strings(
_strings(state.get("active_p0_live_active_blockers"))
+ ["ai_loop_current_blocker_execution_queue"]
+ ([blocker_id] if blocker_id else [])
+ ([external_blocker] if external_blocker else [])
)
for item in _list(payload.get("in_progress_or_blocked_in_priority_order")):
workplan = _dict(item)
if workplan.get("workplan_id") != "P0-006":
continue
evidence = _dict(workplan.setdefault("evidence", {}))
evidence["ai_loop_current_blocker_execution_queue_count"] = len(queue)
evidence["ai_loop_current_blocker_id"] = blocker_id
evidence["ai_loop_current_blocker_queue_item_id"] = str(
first_item.get("queue_item_id") or ""
)
evidence["ai_loop_current_blocker_runner_label"] = str(
first_item.get("runner_label") or ""
)
evidence["ai_loop_current_blocker_registry_v2_status"] = first_item.get(
"registry_v2_status"
)
evidence["ai_loop_current_blocker_controlled_recovery_package"] = (
controlled_recovery_package
)
evidence["ai_loop_current_blocker_post_apply_verifier"] = (
post_apply_verifier
)
evidence["ai_loop_current_blocker_runtime_write_gate"] = runtime_write_gate
evidence["ai_loop_current_blocker_control_path_blocker"] = external_blocker
evidence["ai_loop_current_blocker_learning_writeback_targets"] = (
learning_targets
)
evidence["ai_loop_current_blocker_target_batches"] = target_batches
evidence["ai_loop_current_blocker_metadata_only_writeback_ready"] = bool(
first_item.get("metadata_only_writeback_ready") is True
)
evidence["ai_loop_current_blocker_runtime_dispatch_performed"] = bool(
first_item.get("runtime_dispatch_performed") is True
)
evidence["ai_loop_current_blocker_raw_payload_required"] = bool(
first_item.get("raw_payload_required") is True
)
workplan["status"] = "blocked_ai_loop_current_blocker_execution_queue"
workplan["safe_next_step"] = str(first_item.get("safe_next_step") or "")
workplan["reason"] = (
"The Harbor / 110 blocker is now visible as an AI Loop execution "
"queue item with metadata-only KM/RAG/MCP/PlayBook/AI Agent "
"writeback targets. The next action is not generic manual triage; "
"it is 110 control-path readback plus the bounded local recovery "
"package and post-apply verifier."
)
professional_fix = _dict(workplan.setdefault("professional_fix", {}))
professional_fix["action"] = (
"Run the AI Loop current blocker package in order: verify 110 "
"control path, execute "
f"{controlled_recovery_package}, run {post_apply_verifier}, then "
"rerun Harbor queue / registry /v2/ / deploy-marker readbacks and "
"write metadata-only KM/RAG/MCP/PlayBook receipts. Do not restart "
"Docker daemon, reboot hosts, drain nodes, switch registry "
"provider, trigger workflows, or read runner tokens from this lane."
)
professional_fix["owner"] = (
"AI Loop current blocker queue plus P0-006 Harbor/110 control path"
)
payload["status"] = "p0_006_blocked_ai_loop_current_blocker_execution_queue"
payload["next_execution_order"] = [
(
"P0-006-AI-LOOP-CURRENT-BLOCKER-EXECUTION-QUEUE: execute the "
f"{blocker_id} queue item through 110 control-path readback, "
"bounded recovery package check-mode, post-apply verifier, and "
"metadata-only KM/RAG/MCP/PlayBook writeback."
),
(
"P0-006-HARBOR-REGISTRY-CONTROLLED-RECOVERY-PREFLIGHT: after the "
"AI Loop queue item verifies 110 control path, rerun Harbor "
"watchdog check-mode / repair-once and registry /v2/ readback."
),
(
"P0-006-CD-DEPLOY-MARKER-READBACK: after registry /v2/ is 200/401, "
"let the next Gitea CD run build/push/deploy and then verify "
"delivery-closure-workbench, priority work order, and production "
"marker advance."
),
]
_refresh_rollups_after_stockplatform_overlay(payload, state)
summary = _dict(payload.setdefault("summary", {}))
summary["ai_loop_current_blocker_execution_queue_count"] = len(queue)
summary["ai_loop_current_blocker_id"] = blocker_id
summary["ai_loop_current_blocker_control_path_blocker"] = external_blocker
summary["ai_loop_current_blocker_controlled_recovery_package"] = (
controlled_recovery_package
)
summary["ai_loop_current_blocker_post_apply_verifier"] = post_apply_verifier
summary["ai_loop_current_blocker_learning_target_count"] = len(learning_targets)
def _harbor_registry_next_state(*, status: str, candidate_packaged: bool) -> str:
if candidate_packaged and "upstream_502" in status:
return (