From 0708602c00f9e42855e8b30da830d2add0e28fd8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 30 Jun 2026 23:01:05 +0800 Subject: [PATCH] fix(agent): surface work order recovery readbacks --- .../awoooi_priority_work_order_readback.py | 29 ++++++--- ...awoooi_priority_work_order_readback_api.py | 60 ++++++++++++++++++- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/apps/api/src/services/awoooi_priority_work_order_readback.py b/apps/api/src/services/awoooi_priority_work_order_readback.py index 65abf295..2df1e074 100644 --- a/apps/api/src/services/awoooi_priority_work_order_readback.py +++ b/apps/api/src/services/awoooi_priority_work_order_readback.py @@ -550,6 +550,18 @@ def apply_ai_loop_current_blocker_execution_queue( 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["ai_loop_current_blocker_local_console_phase_count"] = len( + local_console_plan + ) + state["ai_loop_current_blocker_local_console_phase_ids"] = ( + local_console_phase_ids + ) + state["ai_loop_current_blocker_post_recovery_readback_command_count"] = len( + post_recovery_readback_commands + ) + state["ai_loop_current_blocker_forbidden_runtime_action_count"] = len( + forbidden_runtime_actions + ) state["active_p0_live_active_blockers"] = _unique_strings( _strings(state.get("active_p0_live_active_blockers")) + ["ai_loop_current_blocker_execution_queue"] @@ -622,13 +634,12 @@ def apply_ai_loop_current_blocker_execution_queue( ) 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." + "Run the AI Loop current blocker package in order: " + f"{', '.join(local_console_phase_ids)}, 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" @@ -639,8 +650,8 @@ def apply_ai_loop_current_blocker_execution_queue( ( "P0-006-AI-LOOP-CURRENT-BLOCKER-EXECUTION-QUEUE: execute the " f"{blocker_id} queue item through 110 control-path readback, " - "ordered local-console phases, bounded recovery package check-mode, " - "post-apply verifier, and metadata-only KM/RAG/MCP/PlayBook writeback." + f"{len(local_console_plan)} ordered local-console phases, post-recovery " + "readback commands, and metadata-only KM/RAG/MCP/PlayBook writeback." ), ( "P0-006-HARBOR-REGISTRY-CONTROLLED-RECOVERY-PREFLIGHT: after the " diff --git a/apps/api/tests/test_awoooi_priority_work_order_readback_api.py b/apps/api/tests/test_awoooi_priority_work_order_readback_api.py index 123a1763..5b8fdd3c 100644 --- a/apps/api/tests/test_awoooi_priority_work_order_readback_api.py +++ b/apps/api/tests/test_awoooi_priority_work_order_readback_api.py @@ -127,6 +127,55 @@ def test_awoooi_priority_work_order_readback_endpoint_returns_snapshot( assert "reboot SLO scorecard is blocked" in data["next_execution_order"][0] +def test_awoooi_priority_work_order_readback_endpoint_redacts_ai_loop_queue( + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, +): + monkeypatch.setattr( + agents, + "load_latest_stockplatform_public_api_runtime_readback", + _stockplatform_runtime_ready, + ) + + def _harbor_registry_upstream_502() -> dict: + return load_latest_harbor_registry_controlled_recovery_preflight( + route_source_path=_harbor_route_source(tmp_path), + watchdog_source_path=_harbor_watchdog_source(tmp_path), + probe=_harbor_upstream_502_probe, + ) + + monkeypatch.setattr( + agents, + "load_latest_harbor_registry_controlled_recovery_preflight", + _harbor_registry_upstream_502, + ) + app = FastAPI() + app.include_router(router, prefix="/api/v1") + client = TestClient(app) + + response = client.get("/api/v1/agents/awoooi-priority-work-order-readback") + + assert response.status_code == 200 + assert "192.168.0.110" not in response.text + data = response.json() + in_progress = data["in_progress_or_blocked_in_priority_order"][0] + evidence = in_progress["evidence"] + assert data["status"] == ( + "p0_006_blocked_ai_loop_current_blocker_execution_queue" + ) + assert evidence["ai_loop_current_blocker_post_recovery_readback_commands"] == [ + "read-public-gitea-actions-queue.py --json", + "curl -k https://registry.wooo.work/v2/", + "curl host:public-gateway/registry/v2/", + ] + assert len( + evidence["ai_loop_current_blocker_local_console_execution_plan"] + ) == 5 + assert "read_runner_registration_token_or_runner_file" in evidence[ + "ai_loop_current_blocker_forbidden_runtime_actions" + ] + + def test_awoooi_priority_work_order_readback_overlays_harbor_deploy_blocker( tmp_path: Path, ): @@ -264,6 +313,14 @@ def test_awoooi_priority_work_order_readback_overlays_ai_loop_current_blocker_qu assert evidence["ai_loop_current_blocker_metadata_only_writeback_ready"] is True assert evidence["ai_loop_current_blocker_runtime_dispatch_performed"] is False assert evidence["ai_loop_current_blocker_raw_payload_required"] is False + assert evidence["ai_loop_current_blocker_post_recovery_readback_commands"] == [ + "read-public-gitea-actions-queue.py --json", + "curl -k https://registry.wooo.work/v2/", + "curl http://192.168.0.110:5000/v2/", + ] + assert "workflow_dispatch_from_this_endpoint" in evidence[ + "ai_loop_current_blocker_forbidden_runtime_actions" + ] assert "not generic manual triage" in in_progress["reason"] assert "Do not restart Docker daemon" in in_progress["professional_fix"]["action"] assert payload["summary"]["ai_loop_current_blocker_execution_queue_count"] == 1 @@ -276,10 +333,11 @@ def test_awoooi_priority_work_order_readback_overlays_ai_loop_current_blocker_qu ] == 3 assert payload["summary"][ "ai_loop_current_blocker_forbidden_runtime_action_count" - ] >= 5 + ] == 6 assert payload["next_execution_order"][0].startswith( "P0-006-AI-LOOP-CURRENT-BLOCKER-EXECUTION-QUEUE" ) + assert "5 ordered local-console phases" in payload["next_execution_order"][0] def test_awoooi_priority_work_order_readback_overlays_live_stockplatform_drift():