The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(install-e2e): lock files are recorded by kind, never read
teknium17d86a30b7eb7
diff --git a/tests/install/e2e-assets/verify-user-state.py b/tests/install/e2e-assets/verify-user-state.pyindex 7a598f6b3fa..5b420d92f06 100644--- a/tests/install/e2e-assets/verify-user-state.py+++ b/tests/install/e2e-assets/verify-user-state.py@@ -277,9 +277,17 @@ def _env_line_summary(path: str) -> dict:def _entry_record_unless_vanished(rel: str, abs_path: str) -> dict | None:- """A SQLite sidecar can vanish between listdir and its digest (a live gateway closes- the connection): record what exists, never crash on that race. Anything else raises."""+ """Volatile entries are recorded by kind only, never read.++ A SQLite sidecar can vanish between listdir and its digest (a live gateway closes the+ connection), and a lock file's bytes are unreadable while its owner holds it (Windows+ byte-range locks: Errno 13). Anything else vanishing still raises.+ """try:+ if _volatile_sidecar(rel) and not _is_link(abs_path):+ if not _lexists(abs_path):+ return None+ return {"kind": "dir" if os.path.isdir(abs_path) else "file"}return _entry_record(abs_path)except FileNotFoundError:if _volatile_sidecar(rel):@@ -441,8 +449,11 @@ def _volatile_sidecar(rel: str) -> bool:live sees them; they disappear when it closes, and the report then says theupgrade DELETED user state (observed: cron/executions.db-shm and -wal). Thedatabase itself stays judged -- state.db by row counts -- so real loss still fails.+ Lock files (``*.lock``, ``.lock``) are the same kind of hardware: the running gateway+ holds its own (and, serving every profile, each profile's gateway.lock)."""- return rel.endswith(("-wal", "-shm", "-journal"))+ name = rel.rsplit("/", 1)[-1]+ return rel.endswith(("-wal", "-shm", "-journal")) or name.endswith(".lock")def _rows_shrank(rel: str, before: dict, after: dict) -> bool:@@ -544,7 +555,7 @@ def _render(report: dict) -> str:continuelines.append(f" tolerated (config rewrite) {rel}")for rel in report.get("tolerated_deleted", []):- lines.append(f" tolerated (sqlite sidecar) {rel}")+ lines.append(f" tolerated (sidecar or lock) {rel}")advisory = report["advisory"]for label, key in (("advisory deleted", "deleted"), ("advisory modified", "modified")):for rel in advisory[key]:diff --git a/tests/scripts/test_verify_user_state.py b/tests/scripts/test_verify_user_state.pyindex c116ec98b90..c1883dac458 100644--- a/tests/scripts/test_verify_user_state.py+++ b/tests/scripts/test_verify_user_state.py@@ -409,13 +409,34 @@ def test_a_sidecar_vanishing_mid_walk_is_not_a_scan_crash(tmp_path, monkeypatch)monkeypatch.setattr(vus, "_entry_record", racing)snap = vus.snapshot_home(str(home))assert "cron/jobs.json" in snap["entries"]- assert "cron/executions.db-journal" not in snap["entries"]+ # Never opened at all: recorded by kind, so the digest race cannot happen.+ assert snap["entries"]["cron/executions.db-journal"] == {"kind": "file"}gone.add("jobs.json")with pytest.raises(FileNotFoundError):vus.snapshot_home(str(home))+def test_a_held_lock_file_is_recorded_without_reading_it(tmp_path, monkeypatch):+ """Windows: a gateway's msvcrt-held gateway.lock raises Errno 13 on read (live on the leg)."""+ home = tmp_path / "home"+ (home / "profiles" / "p").mkdir(parents=True)+ (home / "profiles" / "p" / "gateway.lock").write_text("1", encoding="utf-8")+ real = vus._sha256_file++ def locked(path):+ if path.endswith(".lock"):+ raise PermissionError(13, "Permission denied", path)+ return real(path)++ monkeypatch.setattr(vus, "_sha256_file", locked)+ snap = vus.snapshot_home(str(home))+ assert snap["entries"]["profiles/p/gateway.lock"] == {"kind": "file"}+ os.remove(home / "profiles" / "p" / "gateway.lock")+ report = vus.verify_home(str(home), snap)+ assert report["ok"] is True and report["tolerated_deleted"] == ["profiles/p/gateway.lock"]++def test_the_running_gateways_state_record_may_change_but_not_vanish(tmp_path):"""The update restarts the gateway, so gateway_state.json's pid/start_time must move."""home = tmp_path / "home"