TDD: Write failing test for #1023 — E2E tests fail without explicit init #1033

Closed
opened 2026-03-17 18:19:06 +00:00 by freemo · 3 comments
Owner

Metadata

  • Commit Message: test: add TDD bug-capture test for #1023 — implicit init requirement
  • Branch: tdd/m4-e2e-implicit-init

Background and Context

This is the TDD counterpart to bug #1023. Per CONTRIBUTING.md Bug Fix Workflow, a tagged test must be written first.

See #1023 for full bug details.

Expected Behavior

A test captures that CLI commands fail when agents init has not been explicitly run first, even though the specification implies implicit initialization.

Acceptance Criteria

  • Tagged with @tdd_bug, @tdd_bug_1023, @tdd_expected_fail.
  • CI passes. Tag validation passes. Coverage >=97%.

Definition of Done

Commit pushed, PR merged to master.

Subtasks

  • Code: Analyze the implicit init requirement described in #1023.
  • Tests (Behave): Write scenario exercising CLI without prior init. Tag appropriately.
  • Tests (Robot): Add Robot test if E2E behavior warrants it.
  • Docs: Comment in test file.
  • Quality: CI, tag validation, coverage, nox.
## Metadata - **Commit Message**: `test: add TDD bug-capture test for #1023 — implicit init requirement` - **Branch**: `tdd/m4-e2e-implicit-init` ## Background and Context This is the TDD counterpart to bug #1023. Per `CONTRIBUTING.md` Bug Fix Workflow, a tagged test must be written first. See #1023 for full bug details. ## Expected Behavior A test captures that CLI commands fail when `agents init` has not been explicitly run first, even though the specification implies implicit initialization. ## Acceptance Criteria - [x] Tagged with `@tdd_bug`, `@tdd_bug_1023`, `@tdd_expected_fail`. - [x] CI passes. Tag validation passes. Coverage >=97%. ## Definition of Done Commit pushed, PR merged to `master`. ## Subtasks - [x] Code: Analyze the implicit init requirement described in #1023. - [x] Tests (Behave): Write scenario exercising CLI without prior `init`. Tag appropriately. - [x] Tests (Robot): Add Robot test if E2E behavior warrants it. - [x] Docs: Comment in test file. - [x] Quality: CI, tag validation, coverage, nox.
freemo added this to the v3.3.0 milestone 2026-03-17 18:19:22 +00:00
Author
Owner

Planning Agent — Dependency Note

This TDD issue (#1033) blocks bug fix #1023. Bug #1023 depends on this issue per TDD workflow.

Dependencies to create in Forgejo UI:

  • #1023 depends on → #1033 (this issue)
  • Please add via Forgejo UI: open #1023, add #1033 under "depends on".
**Planning Agent — Dependency Note** This TDD issue (#1033) blocks bug fix #1023. Bug #1023 depends on this issue per TDD workflow. **Dependencies to create in Forgejo UI**: - #1023 depends on → #1033 (this issue) - Please add via Forgejo UI: open #1023, add #1033 under "depends on".
Author
Owner

Assigned to @brent.edwards for TDD test writing for bug #1023 (E2E init requirement). This TDD counterpart is top priority per project policy — bugs always take precedence over feature work.

Assigned to @brent.edwards for TDD test writing for bug #1023 (E2E init requirement). This TDD counterpart is top priority per project policy — bugs always take precedence over feature work.
Member

Implementation Notes

Analysis of Bug #1023

Bug #1023 reports that CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true triggers schema migrations on an existing database but does NOT create the database file or its parent directory structure. Any CLI command touching the database (e.g., resource add, project create) in a fresh environment fails with sqlite3.OperationalError: unable to open database file.

The implicit init expectation is that when CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true is set, the system should automatically create the .cleveragents/ directory and database file, not just run migrations on a pre-existing database.

Test Design

Behave tests (features/tdd_e2e_implicit_init.feature + features/steps/tdd_e2e_implicit_init_steps.py):

  • Two scenarios: one for resource add and one for project create, both exercised in a pristine temp directory without prior agents init.
  • Tagged @tdd_expected_fail @tdd_bug @tdd_bug_1023 at the feature level.
  • Uses Typer's CliRunner with real CLI invocation (no service-layer mocks).
  • Environment manipulation: saves/removes CLEVERAGENTS_DATABASE_URL, CLEVERAGENTS_TEST_DATABASE_URL, sets CLEVERAGENTS_HOME to pristine temp dir, sets CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true.
  • Cleanup registered via context.add_cleanup() for env var restoration and tmpdir removal.

Robot tests (robot/tdd_e2e_implicit_init.robot + robot/helper_tdd_e2e_implicit_init.py):

  • Two test cases mirroring the Behave scenarios.
  • Tagged tdd_bug tdd_bug_1023 tdd_expected_fail — the tdd_expected_fail tag enables the tdd_expected_fail_listener.py to invert results while the bug is unfixed.
  • Helper script (helper_tdd_e2e_implicit_init.py) exercises real CLI via CliRunner in a pristine temp directory. Exits 0 with sentinel on success (bug fixed), exits 1 on failure (bug present).

Quality Gate Results

Gate Result
nox -s lint PASS
nox -s typecheck PASS (0 errors)
nox -s unit_tests PASS (462 features, 12232 scenarios, 0 failed)
nox -s integration_tests PASS (1674 tests, 1674 passed, 0 failed)
nox -s coverage_report PASS (98% coverage, threshold 97%)

Files Added

  • features/tdd_e2e_implicit_init.feature — Behave feature with 2 scenarios
  • features/steps/tdd_e2e_implicit_init_steps.py — Step definitions (148 lines)
  • robot/tdd_e2e_implicit_init.robot — Robot Framework integration test (2 test cases)
  • robot/helper_tdd_e2e_implicit_init.py — Robot helper script (155 lines)
## Implementation Notes ### Analysis of Bug #1023 Bug #1023 reports that `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true` triggers schema migrations on an **existing** database but does NOT create the database file or its parent directory structure. Any CLI command touching the database (e.g., `resource add`, `project create`) in a fresh environment fails with `sqlite3.OperationalError: unable to open database file`. The implicit init expectation is that when `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true` is set, the system should automatically create the `.cleveragents/` directory and database file, not just run migrations on a pre-existing database. ### Test Design **Behave tests** (`features/tdd_e2e_implicit_init.feature` + `features/steps/tdd_e2e_implicit_init_steps.py`): - Two scenarios: one for `resource add` and one for `project create`, both exercised in a pristine temp directory without prior `agents init`. - Tagged `@tdd_expected_fail @tdd_bug @tdd_bug_1023` at the feature level. - Uses Typer's `CliRunner` with real CLI invocation (no service-layer mocks). - Environment manipulation: saves/removes `CLEVERAGENTS_DATABASE_URL`, `CLEVERAGENTS_TEST_DATABASE_URL`, sets `CLEVERAGENTS_HOME` to pristine temp dir, sets `CLEVERAGENTS_AUTO_APPLY_MIGRATIONS=true`. - Cleanup registered via `context.add_cleanup()` for env var restoration and tmpdir removal. **Robot tests** (`robot/tdd_e2e_implicit_init.robot` + `robot/helper_tdd_e2e_implicit_init.py`): - Two test cases mirroring the Behave scenarios. - Tagged `tdd_bug tdd_bug_1023 tdd_expected_fail` — the `tdd_expected_fail` tag enables the `tdd_expected_fail_listener.py` to invert results while the bug is unfixed. - Helper script (`helper_tdd_e2e_implicit_init.py`) exercises real CLI via CliRunner in a pristine temp directory. Exits 0 with sentinel on success (bug fixed), exits 1 on failure (bug present). ### Quality Gate Results | Gate | Result | |------|--------| | `nox -s lint` | ✅ PASS | | `nox -s typecheck` | ✅ PASS (0 errors) | | `nox -s unit_tests` | ✅ PASS (462 features, 12232 scenarios, 0 failed) | | `nox -s integration_tests` | ✅ PASS (1674 tests, 1674 passed, 0 failed) | | `nox -s coverage_report` | ✅ PASS (98% coverage, threshold 97%) | ### Files Added - `features/tdd_e2e_implicit_init.feature` — Behave feature with 2 scenarios - `features/steps/tdd_e2e_implicit_init_steps.py` — Step definitions (148 lines) - `robot/tdd_e2e_implicit_init.robot` — Robot Framework integration test (2 test cases) - `robot/helper_tdd_e2e_implicit_init.py` — Robot helper script (155 lines)
brent.edwards added reference tdd/m4-e2e-implicit-init 2026-03-23 00:29:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#1033
No description provided.