Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/architecture/test_source_session_registry_denial.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,47 @@ def test_generic_registry_decoder_enforces_source_session_denial() -> None:
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name)
}
assert "require_runtime_compatible_project_registry" in calls


def test_cold_snapshot_rejects_routed_source_session_registry(tmp_path: Path) -> None:
import json
from types import SimpleNamespace

from loopx.control_plane.projects.registry_codec import (
ProjectRegistryProtocolError,
SOURCE_SESSION_PROFILE_ID,
)
from loopx.presentation.goal_storage_api import GoalStorageRequestMixin

invoked_registry = tmp_path / "global" / "registry.global.json"
invoked_registry.parent.mkdir(mode=0o700, parents=True)
source_registry = tmp_path / "source" / "registry.json"
source_registry.parent.mkdir(mode=0o700, parents=True)
source_registry.write_text(
json.dumps(
{
"profile_id": SOURCE_SESSION_PROFILE_ID,
"goals": [
{
"id": "cold",
"repo": str(tmp_path / "project"),
"state_file": str(tmp_path / "project" / "STATE.md"),
}
],
}
),
encoding="utf-8",
)
handler = GoalStorageRequestMixin()
handler.server = SimpleNamespace(
registry_path=invoked_registry,
runtime_root=tmp_path / "runtime",
)
with pytest.raises(ProjectRegistryProtocolError, match=SOURCE_SESSION_PROFILE_ID):
handler._storage_cold_snapshot(
"cold",
{},
{"id": "cold"},
tmp_path / "runtime",
source_registry,
)
16 changes: 10 additions & 6 deletions tests/control_plane/test_pr_wait_consumer_adoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from loopx.todos import add_goal_todo, list_goal_todos
from tests.capabilities.test_pr_wait_observation import _invoke_turn, _observation
from tests.control_plane.canonical_authority_fixture import isolate_sqlite_runtime
from tests.control_plane.host_process_fixture import assert_host_task_context
from tests.test_loopx_turn_driver import _write_live_fixture


Expand Down Expand Up @@ -80,11 +81,12 @@ def fetch(reference, **kwargs):
assert observation["checks"]["pr_dependencies"]["external_read_count"] == (2 if number == 0 else 0)

captured = []
project_decision = turn.compose_turn_decision
compose_decision = turn.compose_turn_decision

def capture(decision, **kwargs):
captured.append(copy.deepcopy(decision))
return project_decision(decision, **kwargs)
result = compose_decision(decision, **kwargs)
captured.append(copy.deepcopy(result))
return result

monkeypatch.setattr(turn, "compose_turn_decision", capture)
runner = tmp_path / "consumer.py"
Expand All @@ -95,7 +97,9 @@ def capture(decision, **kwargs):
" prompt = kwargs['prompt']\n"
" (root / 'consumer-input.txt').write_text(prompt)\n"
" request = json.JSONDecoder().raw_decode(prompt.split('Turn request:\\n', 1)[1])[0]\n"
" authority = request.get('work_contract') or request['task_context']\n"
" assert request['schema_version'] == 'loopx_turn_model_context_v0'\n"
" assert 'work_contract' not in request\n"
" authority = request['task_context']\n"
" selected = authority['selected_todo']\n"
f" assert selected['todo_id'] == {todo_id!r}\n"
" assert selected['resume_when'] == 'pr_merged:owner/repo#42'\n"
Expand Down Expand Up @@ -139,8 +143,8 @@ def capture(decision, **kwargs):
assert expected["resume_condition"]["matched_event_at"] == "2026-10-01T00:00:00Z"
assert envelope["action_signature"]["matches"] is True
prompt = (project / "consumer-input.txt").read_text()
raw_request = json.JSONDecoder().raw_decode(prompt.split("Turn request:\n", 1)[1])[0]
consumed = raw_request.get("work_contract") or raw_request["task_context"]
model_input = json.JSONDecoder().raw_decode(prompt.split("Turn request:\n", 1)[1])[0]
consumed = assert_host_task_context(model_input, full)
assert consumed["selected_todo"]["resume_condition"] == expected["resume_condition"]
assert "Require the terminal independent artifact marker." in prompt

Expand Down
Loading