UAT: TUI session database path mismatch — spec requires ~/.local/state/cleveragents/tui.db but get_database_url() falls back to CWD-relative .cleveragents/db.sqlite #5548

Open
opened 2026-04-09 07:22:03 +00:00 by HAL9000 · 0 comments
Owner

Bug Report

Feature Area: TUI Session Persistence — SQLite Database Path
Severity: Backlog (the TUI-specific SQLite database is not yet implemented at all; this tracks the path configuration gap specifically)
Spec Reference: §TUI — Session Persistence and Resume, §TUI — Storage


What Was Tested

Code analysis of src/cleveragents/application/container.py (get_database_url()) and src/cleveragents/config/settings.py compared against the spec's storage requirements for TUI session persistence.

Expected Behavior (from spec)

The spec (§TUI — Session Persistence and Resume) states:

Sessions are stored in an SQLite database at ~/.local/state/cleveragents/tui.db

The spec also states (§TUI — Acceptance Criteria):

Session database: TUI session state stored in ~/.local/state/cleveragents/tui.db (SQLite); separate from main ~/.local/share/cleveragents/data.db.

The TUI session database must be:

  1. Located at ~/.local/state/cleveragents/tui.db (XDG state directory)
  2. Separate from the main application database
  3. Contain TUI-specific session metadata (persona_name, actor_identity, title, prompt_count, total_cost, created_at, last_used, project_path, meta_json)

Actual Behavior (from code)

get_database_url() in container.py (lines 212–234) uses a CWD-relative path as fallback:

def get_database_url() -> str:
    for key in ("CLEVERAGENTS_DATABASE_URL", "CLEVERAGENTS_TEST_DATABASE_URL"):
        env_url = os.environ.get(key)
        if env_url:
            return env_url
    # Fallback to file-based SQLite in the current working directory
    db_path = Path.cwd() / ".cleveragents" / "db.sqlite"
    return f"sqlite:///{db_path.absolute()}"

The Settings.database_url field in config/settings.py (lines 310–315) defaults to:

database_url: str = Field(
    default_factory=lambda: (
        f"sqlite:///{Path.home() / '.cleveragents' / 'cleveragents.db'}"
    ),
    ...
)

Neither path matches the spec's ~/.local/state/cleveragents/tui.db. Additionally:

  1. There is no separate TUI-specific database — the TUI would share the main application database
  2. The TUI-specific schema (columns: persona_name, actor_identity, title, prompt_count, total_cost, last_used, project_path, meta_json) does not exist in any migration
  3. The existing sessions table (from alembic/versions/a7_001_session_persistence.py) is the domain Session model table, not the TUI-specific session metadata table

Code Locations

  • File: src/cleveragents/application/container.py, get_database_url() (lines 212–234)
  • File: src/cleveragents/config/settings.py, Settings.database_url (lines 310–315)
  • Migration: alembic/versions/a7_001_session_persistence.py (domain sessions table — not TUI-specific)

Impact

When the TUI session persistence feature is implemented, it will use the wrong database path unless this is corrected. The spec explicitly requires:

  • XDG state directory (~/.local/state/) not home directory (~/.cleveragents/)
  • A separate tui.db file, not the shared cleveragents.db
  • A TUI-specific schema with different columns than the domain Session model

This is a foundational path configuration issue that will affect all TUI session persistence work.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area**: TUI Session Persistence — SQLite Database Path **Severity**: Backlog (the TUI-specific SQLite database is not yet implemented at all; this tracks the path configuration gap specifically) **Spec Reference**: §TUI — Session Persistence and Resume, §TUI — Storage --- ## What Was Tested Code analysis of `src/cleveragents/application/container.py` (`get_database_url()`) and `src/cleveragents/config/settings.py` compared against the spec's storage requirements for TUI session persistence. ## Expected Behavior (from spec) The spec (§TUI — Session Persistence and Resume) states: > Sessions are stored in an SQLite database at `~/.local/state/cleveragents/tui.db` The spec also states (§TUI — Acceptance Criteria): > **Session database**: TUI session state stored in `~/.local/state/cleveragents/tui.db` (SQLite); separate from main `~/.local/share/cleveragents/data.db`. The TUI session database must be: 1. Located at `~/.local/state/cleveragents/tui.db` (XDG state directory) 2. **Separate** from the main application database 3. Contain TUI-specific session metadata (persona_name, actor_identity, title, prompt_count, total_cost, created_at, last_used, project_path, meta_json) ## Actual Behavior (from code) `get_database_url()` in `container.py` (lines 212–234) uses a CWD-relative path as fallback: ```python def get_database_url() -> str: for key in ("CLEVERAGENTS_DATABASE_URL", "CLEVERAGENTS_TEST_DATABASE_URL"): env_url = os.environ.get(key) if env_url: return env_url # Fallback to file-based SQLite in the current working directory db_path = Path.cwd() / ".cleveragents" / "db.sqlite" return f"sqlite:///{db_path.absolute()}" ``` The `Settings.database_url` field in `config/settings.py` (lines 310–315) defaults to: ```python database_url: str = Field( default_factory=lambda: ( f"sqlite:///{Path.home() / '.cleveragents' / 'cleveragents.db'}" ), ... ) ``` Neither path matches the spec's `~/.local/state/cleveragents/tui.db`. Additionally: 1. There is **no separate TUI-specific database** — the TUI would share the main application database 2. The TUI-specific schema (columns: `persona_name`, `actor_identity`, `title`, `prompt_count`, `total_cost`, `last_used`, `project_path`, `meta_json`) does not exist in any migration 3. The existing `sessions` table (from `alembic/versions/a7_001_session_persistence.py`) is the domain Session model table, not the TUI-specific session metadata table ## Code Locations - **File**: `src/cleveragents/application/container.py`, `get_database_url()` (lines 212–234) - **File**: `src/cleveragents/config/settings.py`, `Settings.database_url` (lines 310–315) - **Migration**: `alembic/versions/a7_001_session_persistence.py` (domain sessions table — not TUI-specific) ## Impact When the TUI session persistence feature is implemented, it will use the wrong database path unless this is corrected. The spec explicitly requires: - XDG state directory (`~/.local/state/`) not home directory (`~/.cleveragents/`) - A separate `tui.db` file, not the shared `cleveragents.db` - A TUI-specific schema with different columns than the domain Session model This is a foundational path configuration issue that will affect all TUI session persistence work. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
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.

Reference
cleveragents/cleveragents-core#5548
No description provided.