fix(config): resolve database_url relative to CLEVERAGENTS_HOME, not CWD

Ensure that when database_url is a relative path (like sqlite:///cleveragents.db),
it resolves relative to CLEVERAGENTS_HOME instead of the current working directory.
This fixes E2E test isolation where data from previous runs persisted across runs
at CWD, causing UNIQUE constraint failures.

Changes:
- Added _resolve_database_urls model validator in Settings to rewrite relative
  SQLite paths to absolute paths under CLEVERAGENTS_HOME
- Updated get_database_url() in container.py to use CLEVERAGENTS_HOME as base
  directory and create parent directories when CLEVERAGENTS_HOME is explicitly set
- Updated _check_database() in system.py to walk up directory tree for writable
  ancestor check, handling cases where intermediate directories have not yet been
  created
- Removed @tdd_expected_fail from TDD test (now passes genuinely)

ISSUES CLOSED: #1024
This commit is contained in:
2026-03-25 05:14:44 +00:00
committed by Forgejo
parent 00d12c844d
commit 2b6ac00263
8 changed files with 134 additions and 28 deletions
-2
View File
@@ -15,14 +15,12 @@ Feature: TDD Issue #1024 — SQLite DB URL resolves to CWD instead of CLEVERAGEN
Bug: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1024
TDD: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1034
@tdd_issue @tdd_issue_4288 @tdd_expected_fail
Scenario: Default database_url resolves inside CLEVERAGENTS_HOME not CWD
Given a fresh CLEVERAGENTS_HOME temp directory for DB URL testing
When I resolve the effective database URL from Settings
Then the resolved database path should be inside CLEVERAGENTS_HOME
And the resolved database path should not be inside the original CWD
@tdd_issue @tdd_issue_4288 @tdd_expected_fail
Scenario: Settings database_url default resolves inside CLEVERAGENTS_HOME
Given a fresh CLEVERAGENTS_HOME temp directory for DB URL testing
When I resolve the Settings database_url default