Skip to content

Commit 808483a

Browse files
committed
test(todos): compare canonical reads without the time-varying envelope
loopx-project#6874 added projection_envelope to the canonical todo read with wall-clock observed_at/served_at/last_read_at values. Three tests compared consecutive whole payloads, so they now fail on the timestamps alone: the required windows-powershell lane (test_sqlite_authority_cli.py) and two tests collected by the required test-shard job (test_canonical_todo_writer_isolation.py, test_research_context_adoption.py). Use the existing assert_todo_read_unchanged helper from canonical_authority_fixture, which validates and ignores only those clock fields and compares every other envelope and body fact. Fixes loopx-project#7152 Signed-off-by: JasonBuildAI <jasonbuildai@gmail.com>
1 parent e4674e8 commit 808483a

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

‎tests/control_plane/test_canonical_todo_writer_isolation.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import pytest
1414

15-
from canonical_authority_fixture import isolate_sqlite_runtime, promoted_create_fixture
15+
from canonical_authority_fixture import assert_todo_read_unchanged, isolate_sqlite_runtime, promoted_create_fixture
1616
from test_quota_authority_settlement_journey import _source
1717
import test_quota_settlement_cli as settlement
1818

@@ -185,19 +185,19 @@ def cli(*args, succeeds=True, override=False):
185185
before = cli("todo", "list")
186186
change = ("handoff-mode", "set", "--mode", "hard_lease", "--operation-id", "original-mode")
187187
assert cli(*change, "--dry-run")["status"] == "planned"
188-
assert cli("todo", "list") == before
188+
assert_todo_read_unchanged(cli("todo", "list"), before)
189189
assert cli(*change)["changed"] is True
190190
assert cli("handoff-mode", "show", override=True)["handoff_mode"] == "hard_lease"
191191
assert cli("handoff-mode", "set", "--mode", "soft_claim", "--operation-id", "later-mode")["changed"] is True
192192
later = cli("todo", "list")
193193
replay = cli(*change)
194194
assert replay["status"] == "replayed" and replay["changed"] is False
195195
assert replay["handoff_mode"] == "hard_lease"
196-
assert cli("todo", "list") == later
196+
assert_todo_read_unchanged(cli("todo", "list"), later)
197197
assert cli("handoff-mode", "show")["handoff_mode"] == "soft_claim"
198198
mismatch = cli("handoff-mode", "set", "--mode", "soft_claim", "--operation-id", "original-mode", succeeds=False)
199199
assert mismatch["error_code"] == "coordination_operation_identity_mismatch"
200-
assert cli("todo", "list") == later
200+
assert_todo_read_unchanged(cli("todo", "list"), later)
201201
assert display.read_bytes() == original_display
202202

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

216216

217217
@pytest.mark.parametrize("provider", ["file", "sqlite"])

‎tests/control_plane/test_research_context_adoption.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from loopx.cli import main
1414
from loopx.control_plane.effect_runtime import effect_runtime_result
1515
from loopx.hosts.research_checkpoint import canonical_context, research_context, verify_context_sources, adopt_todo_context, _encoded
16-
from canonical_authority_fixture import isolate_sqlite_runtime
16+
from canonical_authority_fixture import assert_todo_read_unchanged, isolate_sqlite_runtime
1717
from loopx.control_plane.turn_driver.codex_sessions import _store_codex_cli_session
1818

1919

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

263263

264264
def _ordinary_review_and_work(run, workspace, tmp_path, todo, digest, monkeypatch, work=None):

‎tests/control_plane/test_sqlite_authority_cli.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
from loopx.control_plane.effect_runtime import effect_runtime_result
1414

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

0 commit comments

Comments
 (0)