agents project doesn't show created projects. #589

Closed
opened 2026-03-05 00:36:06 +00:00 by brent.edwards · 5 comments
Member

Metadata

  • Commit Message: fix(project): persist project to database during creation
  • Branch: feature/m3-fix-project-create-persist

Background and Context

agents project create project1 appears to succeed (no error) but the project is not persisted to the database. Subsequent agents project list shows "No projects found." This suggests that the project creation path does not commit the new project record to the database, or the project is created in a transient scope that is discarded.

Reported by Brent Edwards on Day 25.

Steps to reproduce:

cd ~
mkdir data
uv venv
source .venv/bin/activate
uv pip install -e /app
agents init
agents project create project1
agents project list
# Expected: project1 appears
# Actual: "No projects found."

Expected Behavior

After agents project create project1, agents project list shows project1 among the projects.

Acceptance Criteria

  • agents project create project1 persists the project to the database.
  • agents project list shows the created project.
  • Multiple projects can be created and listed.
  • Creating a duplicate project name produces a clear error.

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • 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.

Subtasks

  • Code: Investigate project create command path — trace from CLI through service to repository to find where persistence fails.
  • Code: Fix the persistence issue so project records are committed to the database.
  • Code: Verify project list queries the same database/scope as project create.
  • Tests (Behave): Add scenario for create-then-list round-trip.
  • Tests (Robot): Add smoke test for agents project create + agents project list.
  • Quality: Verify coverage >=97% via nox -s coverage_report.
  • Quality: Run nox (all default sessions), fix any errors.
## Metadata - **Commit Message**: `fix(project): persist project to database during creation` - **Branch**: `feature/m3-fix-project-create-persist` ## Background and Context `agents project create project1` appears to succeed (no error) but the project is not persisted to the database. Subsequent `agents project list` shows "No projects found." This suggests that the project creation path does not commit the new project record to the database, or the project is created in a transient scope that is discarded. Reported by Brent Edwards on Day 25. **Steps to reproduce:** ```bash cd ~ mkdir data uv venv source .venv/bin/activate uv pip install -e /app agents init agents project create project1 agents project list # Expected: project1 appears # Actual: "No projects found." ``` ## Expected Behavior After `agents project create project1`, `agents project list` shows `project1` among the projects. ## Acceptance Criteria - [ ] `agents project create project1` persists the project to the database. - [ ] `agents project list` shows the created project. - [ ] Multiple projects can be created and listed. - [ ] Creating a duplicate project name produces a clear error. ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - 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. ## Subtasks - [ ] Code: Investigate `project create` command path — trace from CLI through service to repository to find where persistence fails. - [ ] Code: Fix the persistence issue so project records are committed to the database. - [ ] Code: Verify `project list` queries the same database/scope as `project create`. - [ ] Tests (Behave): Add scenario for create-then-list round-trip. - [ ] Tests (Robot): Add smoke test for `agents project create` + `agents project list`. - [ ] Quality: Verify coverage >=97% via `nox -s coverage_report`. - [ ] Quality: Run `nox` (all default sessions), fix any errors.
freemo added this to the v3.2.0 milestone 2026-03-05 00:56:28 +00:00
Author
Member

TDD Tests Submitted — PR #591

Opened PR #591 with TDD failing tests that reproduce this bug.

Root Cause Analysis

NamespacedProjectRepository.create() at repositories.py:2828-2855 calls session.flush() but never session.commit(). The CLI create command at project.py:544 calls repo.create(project) without committing. Since each CLI invocation gets a fresh session from the factory, flushed-but-uncommitted data is invisible to subsequent invocations (list, re-fetch via get).

Test Design

Tests use file-based SQLite with a fresh NamespacedProjectRepository per CLI invocation to faithfully reproduce the bug. A shared in-memory session pattern (used by some existing tests) would mask the problem because flushed data is visible within the same session.

Deliverables

  • 3 Behave BDD scenarios (@wip, @tdd, @bug589) — all expected to fail until fix is applied
  • Robot Framework integration smoke tests
  • ASV round-trip benchmark with project-count tracker
  • CHANGELOG entry

Next Steps

The bug-fix author should branch from feature/m3-fix-project-create-persist and add session.commit() to the create path (or wrap in a UnitOfWork). When the fix PR merges, these TDD tests will pass.

## TDD Tests Submitted — PR #591 Opened PR #591 with TDD failing tests that reproduce this bug. ### Root Cause Analysis `NamespacedProjectRepository.create()` at `repositories.py:2828-2855` calls `session.flush()` but never `session.commit()`. The CLI `create` command at `project.py:544` calls `repo.create(project)` without committing. Since each CLI invocation gets a fresh session from the factory, flushed-but-uncommitted data is invisible to subsequent invocations (`list`, re-fetch via `get`). ### Test Design Tests use **file-based SQLite** with a **fresh `NamespacedProjectRepository`** per CLI invocation to faithfully reproduce the bug. A shared in-memory session pattern (used by some existing tests) would mask the problem because flushed data is visible within the same session. ### Deliverables - 3 Behave BDD scenarios (`@wip`, `@tdd`, `@bug589`) — all expected to **fail** until fix is applied - Robot Framework integration smoke tests - ASV round-trip benchmark with project-count tracker - CHANGELOG entry ### Next Steps The bug-fix author should branch from `feature/m3-fix-project-create-persist` and add `session.commit()` to the create path (or wrap in a UnitOfWork). When the fix PR merges, these TDD tests will pass.
Owner

PM Acknowledgment — Day 25 Review

Good catch, @brent.edwards. The flush() without commit() in NamespacedProjectRepository.create() is a clear persistence bug. Excellent test design note about file-based SQLite vs shared in-memory sessions — that distinction is critical for faithfully reproducing the issue.

Triage Notes

  • Shared root cause with #590 — the session.commit() fix will resolve both.
  • TDD PR #591 assigned to @freemo for review and fix implementation.
  • Fix approach: Add session.commit() to the create path in repositories.py:2828-2855, or wrap in a UnitOfWork as Brent suggested.
  • Priority: Medium — blocks M3 acceptance gate.

Dependencies

  • PR #591 TDD tests should be reviewed first, then @freemo implements the fix on the same branch or a dependent branch.
  • Once fixed, #590 should also be retested and closed.
## PM Acknowledgment — Day 25 Review Good catch, @brent.edwards. The `flush()` without `commit()` in `NamespacedProjectRepository.create()` is a clear persistence bug. Excellent test design note about file-based SQLite vs shared in-memory sessions — that distinction is critical for faithfully reproducing the issue. ### Triage Notes - **Shared root cause** with #590 — the `session.commit()` fix will resolve both. - **TDD PR #591** assigned to @freemo for review and fix implementation. - **Fix approach**: Add `session.commit()` to the create path in `repositories.py:2828-2855`, or wrap in a UnitOfWork as Brent suggested. - **Priority**: Medium — blocks M3 acceptance gate. ### Dependencies - PR #591 TDD tests should be reviewed first, then @freemo implements the fix on the same branch or a dependent branch. - Once fixed, #590 should also be retested and closed.
Owner

Implementation Notes

Root Cause

NamespacedProjectRepository.create() called session.flush() but never session.commit(). This made the project visible within the same SQLAlchemy session but not persisted to disk. Any subsequent operation using a new session (like project list) couldn't see the project.

Fix Applied

Added session.commit() after session.flush() in NamespacedProjectRepository.create() (infrastructure/database/repositories.py). Removed @wip tags from the Behave test scenarios so they now run and pass.

Verification

  • lint: passed, typecheck: passed, unit_tests: 8503 scenarios passed
  • integration_tests: 1195/1196 passed (1 pre-existing failure on master)
  • coverage: 97%

PR: #591 (updated with fix commit on top of existing test commit)

## Implementation Notes ### Root Cause `NamespacedProjectRepository.create()` called `session.flush()` but never `session.commit()`. This made the project visible within the same SQLAlchemy session but not persisted to disk. Any subsequent operation using a new session (like `project list`) couldn't see the project. ### Fix Applied Added `session.commit()` after `session.flush()` in `NamespacedProjectRepository.create()` (`infrastructure/database/repositories.py`). Removed `@wip` tags from the Behave test scenarios so they now run and pass. ### Verification - lint: passed, typecheck: passed, unit_tests: 8503 scenarios passed - integration_tests: 1195/1196 passed (1 pre-existing failure on master) - coverage: 97% PR: #591 (updated with fix commit on top of existing test commit)
Member

PR !591 merged, this ticket is pending on the TTD ticket #632, marking this ticket as completed but not closed due to opening dependencies.

PR !591 merged, this ticket is pending on the TTD ticket #632, marking this ticket as completed but not closed due to opening dependencies.
Owner

PM Status — Day 29

Bug fix merged in PR #591. TDD counterpart #632 now also closed (tests already on master). Closing this issue as complete.

## PM Status — Day 29 Bug fix merged in PR #591. TDD counterpart #632 now also closed (tests already on master). Closing this issue as complete.
Sign in to join this conversation.
No milestone
No project
No assignees
3 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#589
No description provided.