fix(config): Settings.data_dir default is relative Path("data") instead of spec-required ~/.cleveragents — runtime data directory diverges from spec #3645

Open
opened 2026-04-05 21:04:09 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/settings-data-dir-default-path
  • Commit Message: fix(config): correct Settings.data_dir default to Path.home() / ".cleveragents"
  • Milestone: (none — backlog)
  • Parent Epic: #397

Background and Context

The specification (docs/specification.md, section "Global Configuration Keys", core.data-dir) states:

core.data-dir | string | ~/.cleveragents | CLEVERAGENTS_DATA_DIR | Root directory for all CleverAgents persistent state: database, logs, cache, sessions, checkpoints, and backups.

The ConfigService registry correctly defaults core.data-dir to "~/.cleveragents" (line 134 in config_service.py), but the Settings class — which is used by the runtime — uses a different, incorrect default. This inconsistency means the runtime and the config registry disagree on where persistent state lives.

Current Behavior

The Settings class in src/cleveragents/config/settings.py (lines 132–135) has:

data_dir: Path = Field(
    default_factory=lambda: Path("data"),
    validation_alias=AliasChoices("CLEVERAGENTS_DATA_DIR"),
)

The default is Path("data") — a relative path that resolves to <current working directory>/data. This is incorrect in two ways:

  1. It is a relative path, not an absolute path.
  2. It points to data/ not ~/.cleveragents.

Similarly, storage_base_path (lines 136–139) also defaults to Path("data").

Steps to reproduce:

  1. Unset CLEVERAGENTS_DATA_DIR env var.
  2. Instantiate Settings().
  3. Check settings.data_dir — it returns Path("data") (relative) instead of Path.home() / ".cleveragents".

Expected Behavior

When CLEVERAGENTS_DATA_DIR is not set, Settings().data_dir should return Path.home() / ".cleveragents" — an absolute path matching the spec and the ConfigService registry default.

Impact

  1. When CLEVERAGENTS_DATA_DIR is not set, the application stores data in <cwd>/data/ instead of ~/.cleveragents/.
  2. Data is scattered across different directories depending on where the CLI is invoked.
  3. The CleanupService uses settings.data_dir to locate checkpoints and backups — these will be in the wrong location.
  4. The runtime Settings default and the ConfigService registry default are inconsistent, violating the spec as the source of truth.

Subtasks

  • Change default_factory=lambda: Path("data") to default_factory=lambda: Path.home() / ".cleveragents" for the data_dir field in src/cleveragents/config/settings.py (line 133)
  • Evaluate whether storage_base_path (line 137) should also be updated to ~/.cleveragents or if it serves a different purpose; update accordingly
  • Update any Behave unit tests that assert data_dir default is Path("data")
  • Verify nox -e typecheck passes
  • Verify nox -e unit_tests passes
  • Verify nox -e coverage_report passes with coverage >= 97%
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • Settings().data_dir returns Path.home() / ".cleveragents" when CLEVERAGENTS_DATA_DIR is not set
  • Settings default matches ConfigService registry default for core.data-dir
  • Behave unit tests updated to reflect the correct default
  • All nox stages pass
  • Coverage >= 97%
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Backlog note: This issue was discovered during autonomous operation
on milestone v3.5.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/settings-data-dir-default-path` - **Commit Message**: `fix(config): correct Settings.data_dir default to Path.home() / ".cleveragents"` - **Milestone**: *(none — backlog)* - **Parent Epic**: #397 ## Background and Context The specification (`docs/specification.md`, section "Global Configuration Keys", `core.data-dir`) states: > `core.data-dir` | string | **`~/.cleveragents`** | `CLEVERAGENTS_DATA_DIR` | Root directory for all CleverAgents persistent state: database, logs, cache, sessions, checkpoints, and backups. The `ConfigService` registry correctly defaults `core.data-dir` to `"~/.cleveragents"` (line 134 in `config_service.py`), but the `Settings` class — which is used by the runtime — uses a different, incorrect default. This inconsistency means the runtime and the config registry disagree on where persistent state lives. ## Current Behavior The `Settings` class in `src/cleveragents/config/settings.py` (lines 132–135) has: ```python data_dir: Path = Field( default_factory=lambda: Path("data"), validation_alias=AliasChoices("CLEVERAGENTS_DATA_DIR"), ) ``` The default is `Path("data")` — a **relative path** that resolves to `<current working directory>/data`. This is incorrect in two ways: 1. It is a relative path, not an absolute path. 2. It points to `data/` not `~/.cleveragents`. Similarly, `storage_base_path` (lines 136–139) also defaults to `Path("data")`. **Steps to reproduce:** 1. Unset `CLEVERAGENTS_DATA_DIR` env var. 2. Instantiate `Settings()`. 3. Check `settings.data_dir` — it returns `Path("data")` (relative) instead of `Path.home() / ".cleveragents"`. ## Expected Behavior When `CLEVERAGENTS_DATA_DIR` is not set, `Settings().data_dir` should return `Path.home() / ".cleveragents"` — an absolute path matching the spec and the `ConfigService` registry default. ## Impact 1. When `CLEVERAGENTS_DATA_DIR` is not set, the application stores data in `<cwd>/data/` instead of `~/.cleveragents/`. 2. Data is scattered across different directories depending on where the CLI is invoked. 3. The `CleanupService` uses `settings.data_dir` to locate checkpoints and backups — these will be in the wrong location. 4. The runtime `Settings` default and the `ConfigService` registry default are inconsistent, violating the spec as the source of truth. ## Subtasks - [ ] Change `default_factory=lambda: Path("data")` to `default_factory=lambda: Path.home() / ".cleveragents"` for the `data_dir` field in `src/cleveragents/config/settings.py` (line 133) - [ ] Evaluate whether `storage_base_path` (line 137) should also be updated to `~/.cleveragents` or if it serves a different purpose; update accordingly - [ ] Update any Behave unit tests that assert `data_dir` default is `Path("data")` - [ ] Verify `nox -e typecheck` passes - [ ] Verify `nox -e unit_tests` passes - [ ] Verify `nox -e coverage_report` passes with coverage >= 97% - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - [ ] `Settings().data_dir` returns `Path.home() / ".cleveragents"` when `CLEVERAGENTS_DATA_DIR` is not set - [ ] `Settings` default matches `ConfigService` registry default for `core.data-dir` - [ ] Behave unit tests updated to reflect the correct default - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.5.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Backlog — Config default mismatch. The runtime uses <cwd>/data instead of ~/.cleveragents, causing data to scatter across directories.
  • Story Points: 1 — XS — Single default_factory lambda change in settings.py.
  • MoSCoW: Should Have — The spec explicitly defines ~/.cleveragents as the default data directory. The runtime disagreeing with the config registry creates a real user-facing inconsistency where data ends up in the wrong place. Related to #3660.
  • Parent Epic: #397

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Backlog — Config default mismatch. The runtime uses `<cwd>/data` instead of `~/.cleveragents`, causing data to scatter across directories. - **Story Points**: 1 — XS — Single `default_factory` lambda change in settings.py. - **MoSCoW**: Should Have — The spec explicitly defines `~/.cleveragents` as the default data directory. The runtime disagreeing with the config registry creates a real user-facing inconsistency where data ends up in the wrong place. Related to #3660. - **Parent Epic**: #397 --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#397 Epic: Server & Autonomy Infrastructure
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3645
No description provided.