Skip to content

An always-on second brain you talk to. Voice notes in Telegram → typed, linked knowledge in your Obsidian vault. Runs 24/7 on the Claude subscription you already have.

fix(config): expand ~ in runtime_dir and vault_path

smixsb44fe6d32375
diff --git a/src/d_brain/config.py b/src/d_brain/config.py
index cafbe6e..de0788f 100644
--- a/src/d_brain/config.py
+++ b/src/d_brain/config.py
@@ -2,7 +2,7 @@
from pathlib import Path
-from pydantic import Field
+from pydantic import Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -67,6 +67,13 @@ class Settings(BaseSettings):
description="Retry delay for a failed one-shot ('at') job",
)
+ @field_validator("runtime_dir", "vault_path", mode="after")
+ @classmethod
+ def _expand_user(cls, v: Path) -> Path:
+ # pydantic-settings keeps "~" literal; the cron CLI expanduser-s —
+ # expand here too or the bot and CLI split into different state dirs.
+ return v.expanduser()
+
@property
def cron_dir(self) -> Path:
"""Cron state dir: jobs.json + the cron session's runtime files."""
diff --git a/tests/test_config.py b/tests/test_config.py
index c24f407..e5531e2 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -46,3 +46,14 @@ def test_cron_fields_have_safe_defaults():
def test_cron_dir_lives_under_runtime_dir():
s = _settings(runtime_dir=Path("/tmp/rt"))
assert s.cron_dir == Path("/tmp/rt/cron")
+
+
+def test_tilde_paths_are_expanded():
+ # pydantic-settings does not expand ~ on its own; the cron CLI does
+ # expanduser — without this the bot and the CLI would silently use
+ # two different state dirs.
+ s = _settings(runtime_dir="~/.dbrain", vault_path="~/vault")
+ assert s.runtime_dir.is_absolute()
+ assert "~" not in s.runtime_dir.parts
+ assert s.vault_path.is_absolute()
+ assert "~" not in s.vault_path.parts