fix(runtime): bound Runs readback polling
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 47s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped

This commit is contained in:
ogt
2026-07-15 02:30:30 +08:00
parent 99499bd533
commit 0f681ca277
8 changed files with 229 additions and 78 deletions

View File

@@ -2497,7 +2497,9 @@ def test_awoooi_priority_work_order_readback_endpoint_returns_snapshot(
app.include_router(router, prefix="/api/v1")
client = TestClient(app)
response = client.get("/api/v1/agents/awoooi-priority-work-order-readback")
response = client.get(
"/api/v1/agents/awoooi-priority-work-order-readback?live_overlays=true"
)
assert response.status_code == 200
data = response.json()
@@ -2750,7 +2752,9 @@ def test_awoooi_priority_work_order_readback_endpoint_returns_static_fallback_on
app.include_router(router, prefix="/api/v1")
client = TestClient(app)
response = client.get("/api/v1/agents/awoooi-priority-work-order-readback")
response = client.get(
"/api/v1/agents/awoooi-priority-work-order-readback?live_overlays=true"
)
assert response.status_code == 200
data = response.json()
@@ -2768,6 +2772,34 @@ def test_awoooi_priority_work_order_readback_endpoint_returns_static_fallback_on
assert "priority_work_order_live_overlay_timeout" in data["active_blockers"]
def test_awoooi_priority_work_order_readback_defaults_to_source_backed_order(
monkeypatch: pytest.MonkeyPatch,
):
async def live_overlay_must_not_run() -> dict:
raise AssertionError("default priority readback must not launch live overlays")
monkeypatch.setattr(
agents,
"_build_awoooi_priority_work_order_readback_with_live_overlays",
live_overlay_must_not_run,
)
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
data = response.json()
assert data["summary"]["priority_work_order_live_overlay_status"] == (
"delegated_to_dedicated_readbacks"
)
assert data["summary"]["priority_work_order_live_overlay_included"] is False
assert data["mainline_execution_state"][
"priority_work_order_runtime_truth_source"
] == "dedicated_runtime_readbacks"
def test_priority_live_overlay_resolves_ai_runtime_before_secondary_sources() -> None:
source = inspect.getsource(
agents._build_awoooi_priority_work_order_readback_with_live_overlays
@@ -2816,7 +2848,9 @@ def test_awoooi_priority_work_order_readback_endpoint_redacts_ai_loop_queue(
app.include_router(router, prefix="/api/v1")
client = TestClient(app)
response = client.get("/api/v1/agents/awoooi-priority-work-order-readback")
response = client.get(
"/api/v1/agents/awoooi-priority-work-order-readback?live_overlays=true"
)
assert response.status_code == 200
assert "192.168.0.110" not in response.text

View File

@@ -0,0 +1,76 @@
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[3]
def _read(relative_path: str) -> str:
return (REPO_ROOT / relative_path).read_text(encoding="utf-8")
def test_runs_page_uses_single_flight_completion_based_polling() -> None:
source = _read("apps/web/src/app/[locale]/awooop/runs/page.tsx")
assert "const AUTO_REFRESH_INTERVAL = 90_000" in source
assert "fetchRunsInFlightRef.current" in source
assert "completed ? AUTO_REFRESH_INTERVAL : BUSY_RETRY_INTERVAL" in source
assert "setInterval(" not in source
assert 'qualityParams.set("limit", "8")' in source
def test_runs_page_keeps_last_good_readback_on_transient_failures() -> None:
source = _read("apps/web/src/app/[locale]/awooop/runs/page.tsx")
assert "setAiRouteStatus(null)" not in source
assert "setDossierCoverage(null)" not in source
assert "setEventRecurrence(null)" not in source
assert "setAutomationQualitySummary(null)" not in source
def test_autonomous_receipt_panel_serializes_bounded_readbacks() -> None:
source = _read(
"apps/web/src/components/awooop/autonomous-runtime-receipt-panel.tsx"
)
assert "const AUTO_REFRESH_INTERVAL = 90_000" in source
assert "refreshInFlightRef.current" in source
assert "window.setTimeout(() => void poll(), AUTO_REFRESH_INTERVAL)" in source
assert "window.setInterval(" not in source
assert "if (priority) setPriorityPayload(priority);" in source
assert "if (consumer) setConsumerPayload(consumer);" in source
assert (
"if (telegramVerifier) setTelegramVerifierPayload(telegramVerifier);" in source
)
assert (
"if (telegramCoverage) setTelegramCoveragePayload(telegramCoverage);" in source
)
def test_quality_summary_cache_outlives_one_ui_poll_cycle() -> None:
source = _read("apps/api/src/services/awooop_truth_chain_service.py")
assert 'os.getenv("AWOOOP_QUALITY_SUMMARY_CACHE_TTL_SECONDS", "120")' in source
def test_priority_work_order_defaults_to_source_backed_readback() -> None:
source = _read("apps/api/src/api/v1/agents.py")
assert "live_overlays: bool = False" in source
assert "if not live_overlays:" in source
assert '"delegated_to_dedicated_readbacks"' in source
assert '"dedicated_runtime_readbacks"' in source
def test_runtime_readback_caches_outlive_one_ui_poll_cycle() -> None:
consumer_source = _read(
"apps/api/src/services/ai_agent_log_controlled_writeback_consumer_readback.py"
)
runtime_source = _read(
"apps/api/src/services/ai_agent_autonomous_runtime_control.py"
)
assert "_CONSUMER_READBACK_CACHE_TTL_SECONDS = 120.0" in consumer_source
assert (
"_LOG_CONTROLLED_WRITEBACK_CONSUMER_READBACK_CACHE_TTL_SECONDS = 120.0"
in runtime_source
)
assert "_RUNTIME_RECEIPT_READBACK_CACHE_TTL_SECONDS = 60.0" in runtime_source