fix(consult): keep career type off significators and warm off the compute cap
The career checklist now says significators are only for strength and affliction. Chart-save warm no longer takes a heavy-compute slot. Biography severe conflicts fell from 3 to 1. One career answer still names a direction from a planet nature, so this is not accepted for merge. Not pushed.
This commit is contained in:
@@ -186,6 +186,68 @@ def test_saturated_request_returns_429_with_retry_after(limit_one_gate, monkeypa
|
||||
assert recovered.payload()["ok"] is True
|
||||
|
||||
|
||||
def test_warm_consultation_does_not_consume_the_user_slot(limit_one_gate, monkeypatch) -> None:
|
||||
"""A warm in progress must leave the only heavy-compute slot for a real question."""
|
||||
warm_entered = threading.Event()
|
||||
release_warm = threading.Event()
|
||||
user_entered = threading.Event()
|
||||
release_user = threading.Event()
|
||||
|
||||
def _compute(self, body): # noqa: ANN001
|
||||
if body.get("consult_card_warm_only") is True:
|
||||
warm_entered.set()
|
||||
assert release_warm.wait(timeout=5)
|
||||
return {"success": True, "warmed": True}
|
||||
user_entered.set()
|
||||
assert release_user.wait(timeout=5)
|
||||
return {"success": True, "endpoint": "consultation_workflow"}
|
||||
|
||||
monkeypatch.setattr(JyotishAPIHandler, "_compute_consultation_workflow", _compute)
|
||||
|
||||
warm_box: dict = {}
|
||||
user_box: dict = {}
|
||||
|
||||
def _run_warm() -> None:
|
||||
handler = _PostCaptureHandler(
|
||||
"/api/consultation_workflow",
|
||||
{"consult_card_warm_only": True},
|
||||
)
|
||||
handler.do_POST()
|
||||
warm_box["code"] = handler.status_code
|
||||
warm_box["payload"] = handler.payload()
|
||||
|
||||
def _run_user() -> None:
|
||||
handler = _PostCaptureHandler("/api/consultation_workflow", {"question": "career"})
|
||||
handler.do_POST()
|
||||
user_box["code"] = handler.status_code
|
||||
user_box["payload"] = handler.payload()
|
||||
|
||||
warm_thread = threading.Thread(target=_run_warm)
|
||||
warm_thread.start()
|
||||
assert warm_entered.wait(timeout=5)
|
||||
|
||||
user_thread = threading.Thread(target=_run_user)
|
||||
user_thread.start()
|
||||
assert user_entered.wait(timeout=5)
|
||||
|
||||
blocked = _PostCaptureHandler("/api/consultation_workflow", {"question": "again"})
|
||||
blocked.do_POST()
|
||||
assert blocked.status_code == 429
|
||||
assert blocked.payload()["error_code"] == "ERR_COMPUTE_BUSY"
|
||||
|
||||
release_user.set()
|
||||
release_warm.set()
|
||||
user_thread.join(timeout=5)
|
||||
warm_thread.join(timeout=5)
|
||||
assert not user_thread.is_alive()
|
||||
assert not warm_thread.is_alive()
|
||||
assert user_box["code"] == 200
|
||||
assert user_box["payload"]["endpoint"] == "consultation_workflow"
|
||||
assert warm_box["code"] == 200
|
||||
assert warm_box["payload"] == {"success": True, "warmed": True}
|
||||
assert "packet" not in warm_box["payload"]
|
||||
|
||||
|
||||
def test_quality_gate_runs_heavy_compute_gate() -> None:
|
||||
from scripts.run_quality_gate import CORE_PYTEST_TARGETS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user