mirror of
https://github.com/razzant/ouroboros.git
synced 2026-10-03 04:07:04 +00:00
Isolate the custody-sweep tests from process-global stop flags and re-anchor two pins
In the full battery other tests of the same xdist worker leave the process-global stop/restart events set, so the off-thread custody pass ended before its first step and six startup-failure tests went red only there: the sweep helper and the off-thread module now run with their own latch and their own flags. The eligibility test that used the deleted fence-wait round as its stop now stops on the unchanged quiescence wait; the loop_delivery handle declaration gains the final seal's writer.
This commit is contained in:
parent
16f32b404a
commit
08bd187027
4 changed files with 13 additions and 11 deletions
|
|
@ -800,7 +800,7 @@ def _run_real_sweep(monkeypatch, manager, order: list) -> list:
|
|||
from ouroboros import server_maintenance as sm
|
||||
from supervisor import queue
|
||||
|
||||
monkeypatch.setattr(sm, "_CUSTODY_SWEEP_LOCK", __import__("threading").Lock()) # own latch: a pass may outlive a test
|
||||
for _name, _fresh in (("_CUSTODY_SWEEP_LOCK", __import__("threading").Lock()), ("_restart_requested", __import__("threading").Event()), ("_supervisor_stop", __import__("threading").Event())): monkeypatch.setattr(sm, _name, _fresh) # process-global state another test may have left busy/set
|
||||
threads = _track_sweep_threads(monkeypatch)
|
||||
monkeypatch.setattr(sm, "_LAST_CANCEL_INTENT_SWEEP", [time.time()]) # 20 s cadence idle
|
||||
monkeypatch.setattr(sm, "_installed_skill_names", lambda: None)
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ LEAVES: dict[str, tuple[str, str, frozenset[str]]] = {
|
|||
"_project_child_result_dispositions", "_publish_delivery_candidate",
|
||||
"_replace_delivery_candidate", "_resolve_delivery_control",
|
||||
"_run_task_acceptance_review_once", "_service_finalization_evidence",
|
||||
"_supersede_delivery_acceptance_binding",
|
||||
"_set_acceptance_decision", "_supersede_delivery_acceptance_binding",
|
||||
"_supersede_task_acceptance_for_evidence_change",
|
||||
"_supersede_task_acceptance_for_owner_followup",
|
||||
"_task_acceptance_owner_generation_changed",
|
||||
|
|
|
|||
|
|
@ -279,10 +279,12 @@ def test_typed_retry_root_defers_self_review_and_is_host_eligible(
|
|||
return result
|
||||
|
||||
monkeypatch.setattr(loop_mod, "_task_acceptance_eligible", capture_eligible)
|
||||
# Stop the gate right after eligibility, before any reviewer slot is resolved: an
|
||||
# unanswered fence no longer buys a wait round, a live subtree still does.
|
||||
monkeypatch.setattr(loop_mod, "_begin_task_acceptance_fence", lambda *_a, **_k: (False, None))
|
||||
monkeypatch.setattr(
|
||||
loop_mod,
|
||||
"_begin_task_acceptance_fence",
|
||||
lambda *_args, **_kwargs: (False, None),
|
||||
loop_mod, "_task_acceptance_subtree_snapshot",
|
||||
lambda *_a, **_k: (False, [{"task_id": "child", "status": "running"}]),
|
||||
)
|
||||
assert loop_mod._run_task_acceptance_review_once(
|
||||
tools=registry,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ def _fresh_custody_sweep_latch(monkeypatch):
|
|||
from ouroboros import server_maintenance
|
||||
|
||||
monkeypatch.setattr(server_maintenance, "_CUSTODY_SWEEP_LOCK", threading.Lock())
|
||||
# The stop/restart flags are process-global too: another test in this worker may have left one set,
|
||||
# which would end every pass here before its first step.
|
||||
monkeypatch.setattr(server_maintenance, "_restart_requested", threading.Event())
|
||||
monkeypatch.setattr(server_maintenance, "_supervisor_stop", threading.Event())
|
||||
|
||||
|
||||
def _track_threads(monkeypatch) -> list:
|
||||
|
|
@ -258,7 +262,6 @@ def test_a_stop_in_flight_makes_the_sweep_gateway_attach_only(tmp_path, monkeypa
|
|||
from ouroboros import claudexor_daemon as daemon_mod
|
||||
from ouroboros import delegate_custody as dc
|
||||
from ouroboros import delegate_recovery, server_maintenance as sm
|
||||
from ouroboros.server_process import _restart_requested
|
||||
from supervisor import queue
|
||||
|
||||
monkeypatch.setattr(sm, "DATA_DIR", tmp_path)
|
||||
|
|
@ -280,9 +283,6 @@ def test_a_stop_in_flight_makes_the_sweep_gateway_attach_only(tmp_path, monkeypa
|
|||
sm._reconcile_delegated_runs(lambda: set(), stop_event=stop)
|
||||
assert used[-1] == ("attach", {}), "a closed generation never ensures"
|
||||
|
||||
_restart_requested.set()
|
||||
try:
|
||||
sm._reconcile_delegated_runs(lambda: set())
|
||||
finally:
|
||||
_restart_requested.clear()
|
||||
sm._restart_requested.set() # this test's own flag (the fixture replaced the process-global one)
|
||||
sm._reconcile_delegated_runs(lambda: set())
|
||||
assert used[-1] == ("attach", {}), "a restart in flight never ensures either"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue