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
10 changes: 5 additions & 5 deletions tests/control_plane/test_canonical_todo_writer_isolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import pytest

from canonical_authority_fixture import isolate_sqlite_runtime, promoted_create_fixture
from canonical_authority_fixture import assert_todo_read_unchanged, isolate_sqlite_runtime, promoted_create_fixture
from test_quota_authority_settlement_journey import _source
import test_quota_settlement_cli as settlement

Expand Down Expand Up @@ -185,19 +185,19 @@ def cli(*args, succeeds=True, override=False):
before = cli("todo", "list")
change = ("handoff-mode", "set", "--mode", "hard_lease", "--operation-id", "original-mode")
assert cli(*change, "--dry-run")["status"] == "planned"
assert cli("todo", "list") == before
assert_todo_read_unchanged(cli("todo", "list"), before)
assert cli(*change)["changed"] is True
assert cli("handoff-mode", "show", override=True)["handoff_mode"] == "hard_lease"
assert cli("handoff-mode", "set", "--mode", "soft_claim", "--operation-id", "later-mode")["changed"] is True
later = cli("todo", "list")
replay = cli(*change)
assert replay["status"] == "replayed" and replay["changed"] is False
assert replay["handoff_mode"] == "hard_lease"
assert cli("todo", "list") == later
assert_todo_read_unchanged(cli("todo", "list"), later)
assert cli("handoff-mode", "show")["handoff_mode"] == "soft_claim"
mismatch = cli("handoff-mode", "set", "--mode", "soft_claim", "--operation-id", "original-mode", succeeds=False)
assert mismatch["error_code"] == "coordination_operation_identity_mismatch"
assert cli("todo", "list") == later
assert_todo_read_unchanged(cli("todo", "list"), later)
assert display.read_bytes() == original_display

backend = runtime / "authority" / f"{provider}-v0"
Expand All @@ -211,7 +211,7 @@ def cli(*args, succeeds=True, override=False):
assert not backend.exists() and display.read_bytes() == original_display
finally:
offline.rename(backend)
assert cli("todo", "list") == later
assert_todo_read_unchanged(cli("todo", "list"), later)


@pytest.mark.parametrize("provider", ["file", "sqlite"])
Expand Down
8 changes: 4 additions & 4 deletions tests/control_plane/test_research_context_adoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from loopx.cli import main
from loopx.control_plane.effect_runtime import effect_runtime_result
from loopx.hosts.research_checkpoint import canonical_context, research_context, verify_context_sources, adopt_todo_context, _encoded
from canonical_authority_fixture import isolate_sqlite_runtime
from canonical_authority_fixture import assert_todo_read_unchanged, isolate_sqlite_runtime
from loopx.control_plane.turn_driver.codex_sessions import _store_codex_cli_session


Expand Down Expand Up @@ -227,7 +227,7 @@ def lost_handoff(env, payload):
assert 'source-revision:'+source_context['snapshot']['provider_revision'] in inspected['evidence_refs']
assert 'Candidate 3 failed' in Path(result['artifact']).read_text()
assert 'Candidate 999' not in Path(result['artifact']).read_text()
assert source_run('todo','list','--goal-id','source','--todo-id',source_todo)==source_before
assert_todo_read_unchanged(source_run('todo','list','--goal-id','source','--todo-id',source_todo),source_before)
assert run('task-lease','inspect','--goal-id','branch','--todo-id',destination_todo)['lease']==lease['lease']
if with_knowledge and lost_response is None:
_ordinary_review_and_work(run, workspace, tmp_path, destination_todo, digest, monkeypatch)
Expand All @@ -238,7 +238,7 @@ def lost_handoff(env, payload):
if with_knowledge:
assert replay['explore_knowledge']['appended_event_count'] == 0
assert log.read_bytes() == imported_bytes
assert run('todo','list','--goal-id','branch','--todo-id',destination_todo)==after
assert_todo_read_unchanged(run('todo','list','--goal-id','branch','--todo-id',destination_todo),after)
with pytest.raises(ValueError,match='execution authority changed'):
adopt_todo_context(env,unit,digest,**{**args,'lease_version':999})
with pytest.raises(ValueError,match='already has context'):
Expand All @@ -258,7 +258,7 @@ def lost_handoff(env, payload):
moved=run('todo','list','--goal-id','branch','--todo-id',destination_todo)
with pytest.raises(ValueError,match='continuation rejected'):
adopt_todo_context(env,unit,digest,**args)
assert run('todo','list','--goal-id','branch','--todo-id',destination_todo)==moved
assert_todo_read_unchanged(run('todo','list','--goal-id','branch','--todo-id',destination_todo),moved)


def _ordinary_review_and_work(run, workspace, tmp_path, todo, digest, monkeypatch, work=None):
Expand Down
9 changes: 7 additions & 2 deletions tests/control_plane/test_sqlite_authority_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

from loopx.control_plane.effect_runtime import effect_runtime_result

from tests.control_plane.canonical_authority_fixture import initialize_canonical_authority, isolate_sqlite_runtime
from tests.control_plane.canonical_authority_fixture import (
assert_todo_read_unchanged, initialize_canonical_authority, isolate_sqlite_runtime,
)
from loopx.control_plane.coordination.runtime_shadow import build_todo_runtime_shadow_projection
from loopx.control_plane.coordination.coordination_state_contract import TODO_DOMAIN_READ_RECORD_SCHEMA_VERSION, TODO_DOMAIN_RECORD_FIELDS
from loopx.control_plane.coordination.local_authority_shadow_projection import canonical_bytes
Expand Down Expand Up @@ -238,7 +240,10 @@ def todos():
refusal = command("authority-archive", "plan-migration", "--goal-id", goal,
"--provider", "file", "--plan", str(refused_plan), expected_code=1)
assert "settled task leases" in refusal["reason"]
assert not refused_plan.exists() and todos() == before_refusal
assert not refused_plan.exists()
# The projection envelope records when each read happened; the refused
# exit must leave every other read fact unchanged.
assert_todo_read_unchanged(todos(), before_refusal)
command("task-lease", "release", "--goal-id", goal, "--todo-id", todo,
"--owner", agent, "--idempotency-key", "trial-work",
"--expected-version", str(lease["lease"]["version"]))
Expand Down
Loading