From 74387b08c1a5ddf06379ea5c867bbf6f9c1dfbcd Mon Sep 17 00:00:00 2001 From: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Date: Tue, 29 Sep 2026 22:38:16 +0800 Subject: [PATCH 1/2] refactor: keep status read imports on runtime leaf owners Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> --- .../coordination/legacy_writer_fence.py | 2 +- loopx/operator_gate.py | 3 ++- loopx/state_refresh.py | 5 +---- .../test_control_plane_import_boundaries.py | 17 +++++++++++++++++ .../test_run_artifact_reservation.py | 10 ++++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/loopx/control_plane/coordination/legacy_writer_fence.py b/loopx/control_plane/coordination/legacy_writer_fence.py index c1f420f26a..69e8fe2cb0 100644 --- a/loopx/control_plane/coordination/legacy_writer_fence.py +++ b/loopx/control_plane/coordination/legacy_writer_fence.py @@ -17,7 +17,7 @@ from ..effect_runtime import effect_runtime_result from ...file_lock import exclusive_cross_runtime_file_lock -from ...history import load_registry +from ..projects.registry_codec import load_registry from ...paths import resolve_runtime_root from ...registry import registry_goals, resolve_state_file from ..goals.active_state_metadata import parse_state_frontmatter diff --git a/loopx/operator_gate.py b/loopx/operator_gate.py index 562c93920f..31ae28e679 100644 --- a/loopx/operator_gate.py +++ b/loopx/operator_gate.py @@ -9,7 +9,8 @@ from .paths import resolve_runtime_root from .registry import registry_goals from .runtime import validate_goal_id_path_segment -from .state_refresh import now_local, run_file_stem +from .control_plane.runtime.time import now_local_iso as now_local +from .control_plane.runtime.run_artifacts import run_file_stem from .control_plane.runtime.shared_runtime_material_projection import ( finalize_material_projection, prepare_material_projection_route, diff --git a/loopx/state_refresh.py b/loopx/state_refresh.py index 83ebdb851c..02d7f10deb 100644 --- a/loopx/state_refresh.py +++ b/loopx/state_refresh.py @@ -8,6 +8,7 @@ from typing import Any from .control_plane.runtime.time import chronology_key, now_local_iso +from .control_plane.runtime.run_artifacts import run_file_stem as run_file_stem from .control_plane.work_items.delivery_history import require_consistent_delivery_claim from .control_plane.work_items.delivery_batch_scale import ( DELIVERY_BATCH_SCALE_CHOICES as DELIVERY_BATCH_SCALE_CHOICES, @@ -131,10 +132,6 @@ def now_local() -> str: return now_local_iso() -def run_file_stem(generated_at: str) -> str: - return re.sub(r"[^0-9A-Za-z-]+", "-", generated_at).strip("-") - - def parse_frontmatter(text: str) -> dict[str, str]: if not text.startswith("---"): return {} diff --git a/tests/architecture/test_control_plane_import_boundaries.py b/tests/architecture/test_control_plane_import_boundaries.py index acdd362bff..ae71e1d304 100644 --- a/tests/architecture/test_control_plane_import_boundaries.py +++ b/tests/architecture/test_control_plane_import_boundaries.py @@ -247,6 +247,23 @@ def test_periodic_report_hook_does_not_break_cold_imports() -> None: assert completed.returncode == 0, completed.stderr +def test_read_adapters_do_not_load_writeback_facades_for_leaf_helpers() -> None: + # Run independently: an earlier test importing a writer must not hide an + # accidental cold-start dependency of a read-only entrypoint. + for module, unrelated in ( + ("loopx.control_plane.coordination.local_authority", "loopx.history"), + ("loopx.cli_commands.status", "loopx.state_refresh"), + ): + completed = subprocess.run( + [sys.executable, "-c", ( + f"import sys; import {module}; " + f"assert {unrelated!r} not in sys.modules, {unrelated!r}" + )], + cwd=REPOSITORY_ROOT, capture_output=True, check=False, text=True, + ) + assert completed.returncode == 0, completed.stderr + + def test_core_does_not_import_experiments() -> None: forbidden_edges = { (_module_name(path), dependency) diff --git a/tests/control_plane/test_run_artifact_reservation.py b/tests/control_plane/test_run_artifact_reservation.py index dd20907750..4a629136d1 100644 --- a/tests/control_plane/test_run_artifact_reservation.py +++ b/tests/control_plane/test_run_artifact_reservation.py @@ -29,3 +29,13 @@ def test_run_artifact_reservation_is_atomic_across_processes(tmp_path: Path) -> assert len(markdown_names) == worker_count assert {path.name for path in tmp_path.glob("*.json")} == json_names assert all((tmp_path / name).stat().st_size == 0 for name in json_names) + + +def test_run_filename_facades_reuse_the_runtime_codec() -> None: + from loopx import operator_gate, state_refresh + from loopx.control_plane.runtime.run_artifacts import run_file_stem + + assert operator_gate.run_file_stem is run_file_stem + assert state_refresh.run_file_stem is run_file_stem + assert run_file_stem("2026-09-29T14:00:00.123+08:00") == "2026-09-29T14-00-00-123-08-00" + assert run_file_stem("../🧪/2026-09-29/") == "2026-09-29" From f7e019444bba44d33182f5a11ee0be2adb6a6ebe Mon Sep 17 00:00:00 2001 From: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Date: Tue, 29 Sep 2026 22:43:07 +0800 Subject: [PATCH 2/2] chore: refresh registry I/O source locations Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> --- loopx/semantics/project_registry_io_manifest_v1.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loopx/semantics/project_registry_io_manifest_v1.json b/loopx/semantics/project_registry_io_manifest_v1.json index 8ff61d780d..b888446622 100644 --- a/loopx/semantics/project_registry_io_manifest_v1.json +++ b/loopx/semantics/project_registry_io_manifest_v1.json @@ -1847,7 +1847,7 @@ }, { "site": "loopx/operator_gate.py::.record_operator_gate::codec_read:load_registry#1", - "line": 315, + "line": 316, "column": 16, "kind": "codec_read", "api": "load_registry", @@ -1959,7 +1959,7 @@ }, { "site": "loopx/state_refresh.py::.refresh_state_run::codec_read:load_registry#1", - "line": 903, + "line": 900, "column": 16, "kind": "codec_read", "api": "load_registry",