Skip to content

The agent that grows with you

test(e2e): micro-compaction display check is a plain test now that #120316 landed

teknium12b1bb70ac9b1
diff --git a/tests/e2e/core/history/_helpers.py b/tests/e2e/core/history/_helpers.py
index c33bd840dc5..b81d0ed4711 100644
--- a/tests/e2e/core/history/_helpers.py
+++ b/tests/e2e/core/history/_helpers.py
@@ -115,6 +115,18 @@ def views(hermes_home: Path, sid: str) -> tuple[list[dict], list[dict]]:
db.close()
+def model_only_identities(hermes_home: Path, model: list[dict]) -> set[tuple]:
+ """Identities of model-view rows stored as model-only (never part of the display projection)."""
+ ids = [m["_row_id"] for m in model if m.get("_row_id") is not None]
+ if not ids:
+ return set()
+ with db_connect(hermes_home) as con:
+ hidden = {r[0] for r in con.execute(
+ f"SELECT id FROM messages WHERE id IN ({','.join('?' * len(ids))}) "
+ "AND COALESCE(json_extract(display_metadata, '$.model_only'), 0) != 0", ids)}
+ return {identity(m) for m in model if m.get("_row_id") in hidden}
+
+
def row_counts(hermes_home: Path, sid: str) -> dict[str, int]:
with db_connect(hermes_home) as con:
total, active = con.execute(
@@ -616,6 +628,7 @@ class Ledger:
self.srv, self.home, self.check_inputs = srv, hermes_home, check_inputs
self.ever: dict[tuple, str] = {}
self.inputs: list[str] = []
+ self.model_only: set[tuple] = set()
self.model_view: list[dict] | None = None
self.counts: dict[str, int] | None = None
self.compaction_request_idx: list[int] = []
@@ -656,7 +669,13 @@ class Ledger:
self.ever.setdefault(identity(m), short(identity(m)))
assert_exactly_once(model, f"{where} (model view)")
assert_rows_exactly_once(self.home, sid, where)
- assert_no_loss(self.ever, display, model, where)
+ # A model-only row (micro-compaction's merged user turn) stands in for rows that ARE displayed,
+ # so it is exempt from the display no-loss check; its originals were each sent (and tracked) earlier.
+ self.model_only |= model_only_identities(self.home, model)
+ merged = self.model_only
+ for k in merged:
+ self.ever.pop(k, None)
+ assert_no_loss(self.ever, display, [m for m in model if identity(m) not in merged], where)
if self.check_inputs:
assert_inputs_shown_once(self.inputs, display, model, where)
counts = row_counts(self.home, sid)
diff --git a/tests/e2e/core/history/test_transcript_ledger.py b/tests/e2e/core/history/test_transcript_ledger.py
index ca3ada2d5a2..a831140fe2e 100644
--- a/tests/e2e/core/history/test_transcript_ledger.py
+++ b/tests/e2e/core/history/test_transcript_ledger.py
@@ -202,9 +202,7 @@ def test_transcript_ledger(world, name):
assert not [(a, b) for a in typed for b in typed if a != b and a in b], "scenario inputs must be unique"
session = InProcessSession(srv.base_url, hermes_home, f"ledger-{name}")
script.session = session
- # Micro-compaction's merged-user-row display duplication is tracked separately (strict xfail
- # below) so the scenario still guards every other invariant.
- ledger = Ledger(srv, hermes_home, check_inputs=name != "micro_compaction")
+ ledger = Ledger(srv, hermes_home)
try:
for i, (kind, arg) in enumerate(scenario(name, script)):
label = f"{i}:{kind}:{str(arg)[:24]}"
@@ -283,11 +281,6 @@ def test_transcript_ledger(world, name):
assert_usage_matches(hermes_home, lineage(hermes_home, sid), srv.requests, f"scenario {name} after resume")
[email protected](strict=True, reason=(
- "PRODUCTION BUG (opt-in micro-compaction): when a newer micro marker supersedes the old one, "
- "_merge_adjacent_user_turns persists a merged 'A\\n\\nB' user row while the originals stay "
- "compacted=1, so the resumed display history shows both user inputs twice. Flip to a plain test "
- "once the display projection (or the merge) stops duplicating them."))
def test_micro_compaction_resumed_display_shows_each_input_once(world):
srv, script, hermes_home = world["srv"], world["script"], world["hermes_home"]
write_hermes_home(hermes_home, srv.base_url,