personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4"""Tests for processing marker files (stream.updated, daily.updated)."""
5
6import time
7
8from think.utils import day_path
9
10
11def test_stream_updated_marker_created(tmp_path, monkeypatch):
12 """stream.updated marker file is created in day health directory."""
13 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path))
14 day = "20260215"
15 health_dir = day_path(day) / "health"
16 health_dir.mkdir(parents=True, exist_ok=True)
17 (health_dir / "stream.updated").touch()
18 assert (health_dir / "stream.updated").exists()
19
20
21def test_daily_updated_marker_created(tmp_path, monkeypatch):
22 """daily.updated marker file is created in day health directory."""
23 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path))
24 day = "20260215"
25 health_dir = day_path(day) / "health"
26 health_dir.mkdir(parents=True, exist_ok=True)
27 (health_dir / "daily.updated").touch()
28 assert (health_dir / "daily.updated").exists()
29
30
31def test_marker_mtime_updates(tmp_path, monkeypatch):
32 """Touching a marker file again updates its mtime."""
33 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path))
34 day = "20260215"
35 health_dir = day_path(day) / "health"
36 health_dir.mkdir(parents=True, exist_ok=True)
37 marker = health_dir / "stream.updated"
38 marker.touch()
39 mtime1 = marker.stat().st_mtime
40 time.sleep(0.05)
41 marker.touch()
42 mtime2 = marker.stat().st_mtime
43 assert mtime2 > mtime1
44
45
46def test_marker_not_created_when_day_is_none(tmp_path, monkeypatch):
47 """When day is None, no marker file should be created."""
48 monkeypatch.setenv("_SOLSTONE_JOURNAL_OVERRIDE", str(tmp_path))
49 day = None
50 if day:
51 health_dir = day_path(day) / "health"
52 health_dir.mkdir(parents=True, exist_ok=True)
53 (health_dir / "stream.updated").touch()
54
55 # No files should exist under tmp_path since day was None
56 assert not list(tmp_path.rglob("stream.updated"))