Files
hermes-webui/tests/test_issue_edit_regenerate_absolute_keep_count.py
T
4d03578192 fix(#6611): make regeneration start atomic (#6677)
* fix(#6611): make regeneration transaction canonical

* fix(#6611): close cross-provider regeneration blockers

* fix(#6611): harden regeneration transaction boundaries

* fix(#6611): bind canonical context and fork lineage

* fix(#6611): restore active turn token stamping

* test(#6611): make regeneration regressions CI portable

* test(#6611): preserve the tracked regeneration error fixture

* fix(#6611): preserve extracted session harness contracts

* fix(regeneration): preserve concurrent and imported turn ownership (#6611)

* fix(regeneration): honor imported turn ownership safely (#6611)

* test(regeneration): cover both session lock outcomes (#6611)

* test(regeneration): clear unused transaction fixtures (#6611)

* fix(#6611): consume public active-turn marker

* ci: re-trigger (Playwright install hung ~2.5h on GH runners, warm-cache retry)

---------

Co-authored-by: nesquena-hermes <nesquena+hermes@gmail.com>
Co-authored-by: n <a@n>
2026-08-19 11:11:53 +00:00

44 lines
1.5 KiB
Python

"""Regression: edit/regenerate use absolute keep_count (#2184 pattern)."""
import re
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
UI_JS = (REPO / "static" / "ui.js").read_text(encoding="utf-8")
def _function_body(src: str, name: str) -> str:
needle_async = f"async function {name}"
start = src.index(needle_async)
brace = src.index("{", start)
depth = 0
for i in range(brace, len(src)):
if src[i] == "{":
depth += 1
elif src[i] == "}":
depth -= 1
if depth == 0:
return src[start : i + 1]
raise AssertionError(f"function {name!r} body not found")
def test_submit_edit_uses_absolute_keep_count():
body = _function_body(UI_JS, "submitEdit")
assert re.search(r"absoluteKeepCount\s*=\s*_oldestIdx\s*\+\s*msgIdx", body)
assert "keep_count: absoluteKeepCount" in body
def test_regenerate_delegates_to_atomic_start_without_client_truncation():
body = _function_body(UI_JS, "regenerateResponse")
assert "await startRegeneration(initialSid, S.session.regeneration_revision)" in body
assert "/api/session/truncate" not in body
assert "await send()" not in body
def test_submit_edit_captures_absolute_before_await():
body = _function_body(UI_JS, "submitEdit")
cap = re.search(r"absoluteKeepCount\s*=\s*_oldestIdx\s*\+\s*msgIdx", body)
assert cap
first_await = re.search(r"\bawait\b", body)
assert first_await and cap.start() < first_await.start()