From d6429ce9daec2f2c82d21f4a7f9d404658da6800 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sat, 7 Nov 2026 00:23:18 +0800 Subject: [PATCH] test(cli): isolate source-entrypoint machine transport and telemetry fixtures Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- tests/control_plane/test_source_cli_entrypoint.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/control_plane/test_source_cli_entrypoint.py b/tests/control_plane/test_source_cli_entrypoint.py index 3939709a61..247e74e56c 100644 --- a/tests/control_plane/test_source_cli_entrypoint.py +++ b/tests/control_plane/test_source_cli_entrypoint.py @@ -47,7 +47,10 @@ def run_entry( return subprocess.run( [sys.executable, "-c", script], cwd=REPO_ROOT, - env={**os.environ, "PYTHONPATH": str(REPO_ROOT), "LOOPX_USAGE_PING": "0", **(env or {})}, + # This caller consumes machine JSON; keep the parent's model-facing + # context transport intact, with explicit native overrides still allowed. + env={**os.environ, "PYTHONPATH": str(REPO_ROOT), "LOOPX_USAGE_PING": "0", + "LOOPX_CONTEXT_DELIVERY": "off", **(env or {})}, text=True, capture_output=True, check=False, @@ -192,8 +195,9 @@ def replace_process(*args): @pytest.mark.parametrize("entry", ["module", "console"]) +@pytest.mark.parametrize("parent_context", ["on", "off"]) def test_outer_controller_scope_preserves_reads_other_goals_and_recovery( - tmp_path: Path, entry: str, + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, entry: str, parent_context: str, ) -> None: from examples.control_plane.quota_plan_fixtures import ( SCOPED_AGENT_ID, write_cli_fixture, write_codex_heartbeat_fixture, @@ -203,6 +207,7 @@ def test_outer_controller_scope_preserves_reads_other_goals_and_recovery( load_scheduler_state, ) + monkeypatch.setenv("LOOPX_CONTEXT_DELIVERY", parent_context) registry, runtime, _project = write_cli_fixture(tmp_path / "fixture", scoped_agents=True) prefix = ["--registry", str(registry), "--runtime-root", str(runtime), "--format", "json"] env = {"CODEX_HOME": str(tmp_path / "codex-home"), "CODEX_THREAD_ID": "", @@ -280,6 +285,7 @@ def selected_ack(goal: str) -> list[str]: assert json.loads(recovered.stdout)["scheduler_state_mutated"] is True assert load_scheduler_state(runtime, goal_id="needs-operator", agent_id=SCOPED_AGENT_ID, state_key=state_key) is not None + assert os.environ["LOOPX_CONTEXT_DELIVERY"] == parent_context def test_source_module_observes_usage_once_and_preserves_failure_result() -> None: @@ -323,6 +329,8 @@ def test_source_first_usage_disclosure_keeps_json_pure_and_does_not_send(tmp_pat from loopx import usage_ping for key in ("CI", "DO_NOT_TRACK", "LOOPX_USAGE_PING", "LOOPX_USAGE_POLICY"): os.environ.pop(key, None) +# Disposable telemetry state requires explicit qualification to numeric loopback. +os.environ["LOOPX_USAGE_PING"] = "1" os.environ["LOOPX_USAGE_PING_ENDPOINT"] = "http://127.0.0.1:1/v1/ping" usage_ping.select_default_runtime_root = lambda: Path({str(state)!r}) sent = []