Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def test_worker_has_pi_diagnosis_before_patch_protocol(): | |
| worker = (ROOT / "src" / "worker_payload.py").read_text() | |
| assert "BLOCKAGE DIAGNOSIS MODE" in worker | |
| assert "INCIDENT_BRIEF.md" in worker | |
| assert "PI_DIAGNOSIS_GOAL.md" in worker | |
| assert "REPAIR_DECISION.json" in worker | |
| assert "diagnose_failure_with_pi" in worker | |
| assert "recover_after_live_validation_failure" in worker | |
| def test_worker_allowed_actions_and_empty_logs_guardrails(): | |
| worker = (ROOT / "src" / "worker_payload.py").read_text() | |
| for action in [ | |
| "wait_for_logs", | |
| "inspect_more_logs", | |
| "factory_rebuild_same_code", | |
| "patch_code", | |
| "request_manual_hardware", | |
| "declare_technical_blocker", | |
| ]: | |
| assert action in worker | |
| assert "patch_code_blocked_without_actionable_logs" in worker | |
| assert "Logs are not actionable" in worker | |
| assert "Re-uploading the same workspace to force a same-code Space rebuild" in worker | |
| def test_patch_repair_is_only_after_decision(): | |
| worker = (ROOT / "src" / "worker_payload.py").read_text() | |
| assert "This patch is allowed only because the diagnosis decision selected `patch_code`" in worker | |
| assert "patch_allowed" in worker | |
| assert "Pi diagnosis allows a minimal code patch" in worker | |
| def test_progress_knows_blockage_protocol_steps(): | |
| py = (ROOT / "src" / "progress.py").read_text() | |
| js = (ROOT / "web" / "static" / "progress.js").read_text() | |
| for step in [ | |
| "failure_detected", | |
| "failure_diagnosis", | |
| "pi_diagnosis", | |
| "repair_decision", | |
| "wait_for_logs", | |
| "factory_rebuild", | |
| "technical_blocker", | |
| "manual_hardware_required", | |
| ]: | |
| assert step in py | |
| assert step in js | |
| assert "Repair recovery" in js | |