Parent
#26
What to build
A new deep module that loads ~/.config/fafycat/config.toml and feeds path overrides into AppConfig. Affects every command (serve, import, init, and the future query commands). Independent of the CLI surface work — can ship in parallel.
- Public interface:
load_config_file(path: Path | None) -> dict[str, str].
- Format: TOML via stdlib
tomllib. No new dependency.
- Schema: a
[paths] table with optional keys data_dir, db_url, model_dir, export_dir. All keys are optional; missing keys fall through to the next precedence layer.
- Resolution precedence (highest wins):
--data-dir CLI flag > env var (FAFYCAT_DATA_DIR, FAFYCAT_DB_URL, etc.) > config file > built-in default (platformdirs).
FAFYCAT_CONFIG env var overrides the config-file location.
- Missing config file is silent — fall through.
- Unknown keys produce a warning to stderr; do not crash.
- Malformed TOML or invalid path syntax fails loudly with a clear error.
- No auto-creation of the file on first run.
AppConfig is modified so its _default_* factories consult the loader between env vars and the platformdirs default.
Acceptance criteria
Blocked by
None - can start immediately.
Parent
#26
What to build
A new deep module that loads
~/.config/fafycat/config.tomland feeds path overrides intoAppConfig. Affects every command (serve,import,init, and the future query commands). Independent of the CLI surface work — can ship in parallel.load_config_file(path: Path | None) -> dict[str, str].tomllib. No new dependency.[paths]table with optional keysdata_dir,db_url,model_dir,export_dir. All keys are optional; missing keys fall through to the next precedence layer.--data-dirCLI flag > env var (FAFYCAT_DATA_DIR,FAFYCAT_DB_URL, etc.) > config file > built-in default (platformdirs).FAFYCAT_CONFIGenv var overrides the config-file location.AppConfigis modified so its_default_*factories consult the loader between env vars and the platformdirs default.Acceptance criteria
load_config_file()returns an empty dict when the config file does not exist.load_config_file()returns the declared[paths]keys as a flat dict when the file is present and valid.[paths]produce a stderr warning naming the key; the loader still returns the recognised keys.{"error": "..."}exit 1.FAFYCAT_CONFIG=/some/path/config.tomlcauses the loader to read that path instead of the default.AppConfigresolves paths in the documented order: CLI flag > env > config file > default.AppConfig.database.url.fafycat serve,fafycat import,fafycat initcontinue to work unchanged when the config file is absent.capsys/caplog), malformed TOML.Blocked by
None - can start immediately.