Проверено ревьюером исполнением, все восемь замечаний владельца закрыты: Чужой слот. Раньше add_account с profile_id=ag-w1 для nvidia возвращал ok=True и клал аккаунт в слот Antigravity. Теперь отказ с причиной: «Слот ag-w1 не принадлежит провайдеру nvidia». Свой слот принимается, идентификатор выдаётся верный. Группировка по провайдерам восстановлена: скрытие заголовков групп, добавленное в A48 (display:contents + display:none), убрано. Автоматическая проверка запускается при старте веб-сервера (_start_background_refresh), состояние и списки моделей больше не ждут ручного нажатия. Облачные модели Ollama: эндпоинт не выдуман — ревьюер проверил запросом, https://ollama.com/api/tags отвечает 200 и отдаёт 19 моделей (gpt-oss:20b, kimi-k2.6, glm-5.1 и другие). Локальный провайдер подписан llama.cpp вместо «Локальный сервер». Показ хода при долгом опросе честный: «может занять до минуты на этап». Конфликты с A49 разрешены сложением: правки дополняют друг друга — поле пути к хранилищу Obsidian и поле периода проверки аккаунтов, стили вкладки скиллов и стили групп провайдеров. В тесте свежести памяти взят вариант A50: коммит извлекается из файла, а не зашит. 545 passed, 1 skipped, ruff clean, релизный гейт 10/10 и на конфигурации владельца, и на пустой. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
104 lines
3.4 KiB
Python
104 lines
3.4 KiB
Python
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
SCRIPTS_DIR = REPO_ROOT / "scripts"
|
|
if str(SCRIPTS_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
|
|
from check_memory_freshness import (
|
|
check_memory_freshness,
|
|
extract_recorded_commit,
|
|
get_git_commit,
|
|
)
|
|
|
|
|
|
def test_extract_recorded_commit_formats():
|
|
assert extract_recorded_commit("Status: main = 80aab00\nDone") == "80aab00"
|
|
assert extract_recorded_commit("Canonical HEAD (main): `80aab00`\nOther text") == "80aab00"
|
|
assert extract_recorded_commit("- HEAD (main): c35bc48\n- Branch: main") == "c35bc48"
|
|
assert extract_recorded_commit("Some random text with no commit") is None
|
|
|
|
|
|
def test_check_memory_freshness_real_repo():
|
|
canonical_memory = Path("/srv/projects/AI-Memory/01_PROJECTS/hermes-hub/CURRENT_STATE.md")
|
|
|
|
if canonical_memory.exists():
|
|
recorded_commit = extract_recorded_commit(canonical_memory.read_text(encoding="utf-8"))
|
|
is_fresh, summary = check_memory_freshness(
|
|
repo_path=REPO_ROOT,
|
|
memory_file=canonical_memory,
|
|
strict=True,
|
|
)
|
|
assert is_fresh is True
|
|
assert "FRESH" in summary
|
|
recorded = extract_recorded_commit(canonical_memory.read_text(encoding="utf-8"))
|
|
assert recorded and recorded[:7] in summary
|
|
|
|
|
|
def test_check_memory_freshness_missing_file_strict_vs_non_strict(tmp_path):
|
|
missing_file = tmp_path / "NON_EXISTENT_CURRENT_STATE.md"
|
|
|
|
# Non-strict mode should return True with warning for non-server runners
|
|
is_fresh_non_strict, summary_non_strict = check_memory_freshness(
|
|
repo_path=REPO_ROOT,
|
|
memory_file=missing_file,
|
|
strict=False,
|
|
)
|
|
assert is_fresh_non_strict is True
|
|
assert "[WARNING]" in summary_non_strict
|
|
|
|
# Strict mode should return False
|
|
is_fresh_strict, summary_strict = check_memory_freshness(
|
|
repo_path=REPO_ROOT,
|
|
memory_file=missing_file,
|
|
strict=True,
|
|
)
|
|
assert is_fresh_strict is False
|
|
assert "[WARNING]" in summary_strict
|
|
|
|
|
|
def test_check_memory_freshness_stale_commit(tmp_path):
|
|
fake_memory = tmp_path / "CURRENT_STATE.md"
|
|
fake_memory.write_text("main = 0000000000000000000000000000000000000000\n", encoding="utf-8")
|
|
|
|
is_fresh, summary = check_memory_freshness(
|
|
repo_path=REPO_ROOT,
|
|
memory_file=fake_memory,
|
|
strict=True,
|
|
)
|
|
assert is_fresh is False
|
|
assert "STALE" in summary
|
|
|
|
|
|
def test_check_memory_freshness_valid_synthetic_memory(tmp_path):
|
|
head = get_git_commit(REPO_ROOT, "HEAD")
|
|
assert head is not None
|
|
|
|
synthetic_memory = tmp_path / "CURRENT_STATE.md"
|
|
synthetic_memory.write_text(f"# Current State\n\nCanonical HEAD (main): `{head[:7]}`\n", encoding="utf-8")
|
|
|
|
is_fresh, summary = check_memory_freshness(
|
|
repo_path=REPO_ROOT,
|
|
memory_file=synthetic_memory,
|
|
strict=True,
|
|
)
|
|
assert is_fresh is True
|
|
assert "FRESH" in summary
|
|
|
|
|
|
def test_cli_execution(tmp_path):
|
|
script_path = REPO_ROOT / "scripts" / "check_memory_freshness.py"
|
|
|
|
head = get_git_commit(REPO_ROOT, "HEAD")
|
|
synthetic_memory = tmp_path / "CURRENT_STATE.md"
|
|
synthetic_memory.write_text(f"main = {head[:7]}\n", encoding="utf-8")
|
|
|
|
res = subprocess.run(
|
|
[sys.executable, str(script_path), "--memory-path", str(synthetic_memory), "--strict"],
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
assert res.returncode == 0
|
|
assert "FRESH" in res.stdout
|