Skip to content
Open
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
15 changes: 12 additions & 3 deletions tests/integration/test_conflict_resolver_ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,16 @@ async def clear(**kw: Any) -> ConflictResult:
assert (await _marks(ch, org))["office_location"] == 2


async def _pair(ch: Any, org: str, old: str, new: str, axis: int, *, gap: bool = True) -> None:
async def _pair(
ch: Any,
org: str,
old: str,
new: str,
axis: int,
*,
gap: bool = True,
values: tuple[str, str] = ("The office is in Paris", "The office moved to Rome"),
) -> None:
"""An older row and, a second later (or at once), a newer owed one close to it."""
from server.memory.app import after_write, conflicts
from server.memory.domain.conflicts import ConflictResult
Expand All @@ -594,10 +603,10 @@ async def clear(**kw: Any) -> ConflictResult:

with pytest.MonkeyPatch.context() as m:
m.setattr(conflicts, "check_on_commit", clear)
await _set(org, "s1", old, "The office is in Paris")
await _set(org, "s1", old, values[0])
if gap:
await _later()
await _set(org, "s2", new, "The office moved to Rome")
await _set(org, "s2", new, values[1])
await after_write.drain()
await _place(ch, org, "s1", old, _vec((axis, 1.0)), owed=False)
await _place(ch, org, "s2", new, _vec((axis, 0.8), (axis + 1, 0.6)), owed=True)
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/test_conflict_resolver_invariants_ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,16 @@ async def slow_embed(w: Any, embedder: Any = None) -> Any:

monkeypatch.setattr(write, "_set_embed", slow_embed)
for old, new, axis in _PAIRS:
await _pair(ch, org, old, new, axis, gap=old != "budget")
# A deletion refuses the same value under other keys in this namespace.
await _pair(
ch,
org,
old,
new,
axis,
gap=old != "budget",
values=(f"Earlier {old} fact", f"Current {new} fact"),
)
# Another user's row, and another tenant's, right next to the first pair.
await _set(org, "s9", "office_u2", _SECRET, user="u2")
await _place(ch, org, "s9", "office_u2", _vec((100, 1.0), (101, 0.01)), owed=False, user="u2")
Expand Down
Loading