From e13eb13dabedf001cb49a5eddb5d1b19136476e2 Mon Sep 17 00:00:00 2001 From: huangruiteng Date: Thu, 22 Oct 2026 16:41:17 +0800 Subject: [PATCH] test: use canonical attention state and deterministic cleanup clocks Signed-off-by: huangruiteng --- .../personal-workspace-browser/goal-attention-fixture.py | 5 ++++- examples/personal-workspace-browser/goal-masthead.mjs | 4 ++-- tests/extensions/test_process_runtime.py | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/personal-workspace-browser/goal-attention-fixture.py b/examples/personal-workspace-browser/goal-attention-fixture.py index a04c315a1a..dd486d7400 100644 --- a/examples/personal-workspace-browser/goal-attention-fixture.py +++ b/examples/personal-workspace-browser/goal-attention-fixture.py @@ -8,6 +8,7 @@ from loopx.status import collect_status from loopx.control_plane.todos.list_readback import list_goal_todos +from loopx.control_plane.testing.canary_harness import import_fixture_authority def main() -> None: @@ -36,11 +37,13 @@ def main() -> None: "goals": [{"id": "progress-projection", "repo": str(root), "state_file": state.name, "domain": "general", "status": "active", "authority_sources": [], "adapter": {"kind": "test_v0", "status": "connected-read-only"}}]}), encoding="utf-8") + # Status reads canonical authority; Markdown is only this fixture's input. + import_fixture_authority(registry, "progress-projection") payload = collect_status(registry_path=registry, runtime_root_override=str(root / "runtime"), limit=5) item = next(item for item in payload["attention_queue"]["items"] if item["goal_id"] == "progress-projection") assert item["user_todos"]["open_count"] == 21 - assert len(item["user_todos"]["items"]) == 12 + assert len(item["user_todos"]["items"]) == 21 assert item["project_asset"]["user_todos"]["open"] == 21 assert len(item["project_asset"]["user_todos"]["items"]) == 3 if args.full: diff --git a/examples/personal-workspace-browser/goal-masthead.mjs b/examples/personal-workspace-browser/goal-masthead.mjs index de7641ba87..203dc0bb86 100644 --- a/examples/personal-workspace-browser/goal-masthead.mjs +++ b/examples/personal-workspace-browser/goal-masthead.mjs @@ -204,8 +204,8 @@ export const goalMastheadScenario = { await quiet.close(); throw error; } - // The real producer bounds the queue to 12 and its overview to three while - // retaining 21 open decisions. Pass its payload through the shipped parser + // The canonical producer retains 21 open decisions and bounds its overview + // to three. Pass its payload through the shipped parser // and adapter, rather than manufacturing a complete three-item queue. const fixtureEnv = { ...process.env, LOOPX_USAGE_PING: "0" }; if (!["LOOPX_TEST_PYTHON", "LOOPX_PYTHON_BIN", "LOOPX_PYTHON"].some(key => process.env[key])) fixtureEnv.PYTHONPATH = repoRoot; diff --git a/tests/extensions/test_process_runtime.py b/tests/extensions/test_process_runtime.py index cdbe430a8b..8f5d4344fa 100644 --- a/tests/extensions/test_process_runtime.py +++ b/tests/extensions/test_process_runtime.py @@ -160,18 +160,20 @@ def reap(*, timeout): def test_windows_exited_leader_does_not_certify_descendant_cleanup(monkeypatch): + monkeypatch.setattr(process_runtime.time, "monotonic", lambda: 0.0) process = Mock(spec=subprocess.Popen) process.poll.return_value = 0 taskkill = Mock() monkeypatch.setattr(subprocess, "Popen", taskkill) with pytest.raises(RuntimeError, match="unconfirmed after leader exit"): - process_runtime._force_terminate_windows_process_tree(process, time.monotonic() + .1) + process_runtime._force_terminate_windows_process_tree(process, .1) taskkill.assert_not_called() process.kill.assert_not_called() assert 0 <= process.wait.call_args.kwargs["timeout"] <= .1 def test_windows_force_cleanup_cannot_accept_an_unreaped_receiver(monkeypatch): + monkeypatch.setattr(process_runtime.time, "monotonic", lambda: 0.0) process = Mock(spec=subprocess.Popen) helper = Mock(spec=subprocess.Popen) helper.wait.return_value, helper.poll.return_value = 0, 0 @@ -179,7 +181,7 @@ def test_windows_force_cleanup_cannot_accept_an_unreaped_receiver(monkeypatch): monkeypatch.setattr(subprocess, "Popen", Mock(return_value=helper)) process.wait.side_effect = subprocess.TimeoutExpired("native", .1) with pytest.raises(subprocess.TimeoutExpired): - process_runtime._force_terminate_windows_process_tree(process, time.monotonic() + .1) + process_runtime._force_terminate_windows_process_tree(process, .1) process.wait.assert_called_once() assert 0 <= process.wait.call_args.kwargs["timeout"] <= .1