personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4import importlib
5from pathlib import Path
6
7from solstone.think.utils import day_path
8from tests.conftest import copytree_tracked
9
10FIXTURES = Path("tests/fixtures")
11
12
13def copy_day(tmp_path: Path, monkeypatch) -> Path:
14 monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path))
15 dest = day_path("20240101")
16 src = FIXTURES / "journal" / "chronicle" / "20240101"
17 copytree_tracked(src, dest)
18 talents_dir = dest / "talents"
19 talents_dir.mkdir(exist_ok=True) # Allow existing directory
20 (talents_dir / "schedule.json").write_text("[]")
21 return dest
22
23
24def test_scan_day(tmp_path, monkeypatch):
25 mod = importlib.import_module("solstone.think.talents")
26 day_dir = copy_day(tmp_path, monkeypatch)
27 monkeypatch.setenv("SOLSTONE_JOURNAL", str(tmp_path))
28
29 info = mod.scan_day("20240101")
30 assert "talents/schedule.json" in info["processed"]
31 assert "talents/daily_schedule.json" in info["repairable"]
32
33 (day_dir / "talents" / "daily_schedule.json").write_text("[]")
34 info_after = mod.scan_day("20240101")
35 assert "talents/daily_schedule.json" in info_after["processed"]
36 assert "talents/daily_schedule.json" not in info_after["repairable"]