tdd(cli): prevent actor list from triggering database updates #1151

Merged
brent.edwards merged 1 commit from bugfix/m3-actor-list-no-db-update into master 2026-03-28 05:27:14 +00:00
Member

Summary

  • Fix bug #797: agents actor list no longer triggers database writes (upsert_actor, set_default_actor) by removing ensure_built_in_actors() from ActorRegistry.list() and ActorRegistry.list_actors()
  • Include TDD regression tests from #841 with @tdd_expected_fail removed per Bug Fix Workflow
  • Update three existing test suites that relied on the old behavior to call ensure_built_in_actors() explicitly

Root Cause

ActorRegistry.list_actors() and ActorRegistry.list() both unconditionally called self.ensure_built_in_actors() before delegating to the actor service. ensure_built_in_actors() iterates all configured providers and calls _actor_service.upsert_actor() for each — a database WRITE operation. It may also call _actor_service.set_default_actor() if no default exists — another WRITE. This means every read-only agents actor list command triggered database writes and could prompt for pending migrations on fresh checkouts.

Changes

Bug Fix

  • src/cleveragents/actor/registry.py — Removed self.ensure_built_in_actors() from list() and list_actors(). Both methods now delegate directly to the service layer without triggering writes. All write-heavy methods (add, upsert_actor, get, get_actor, remove, remove_actor, set_default_actor, get_default_actor) still call ensure_built_in_actors().

TDD Tests (from #841, @tdd_expected_fail removed)

  • features/tdd_actor_list_no_db_update.feature — 2 Behave scenarios verifying upsert_actor and set_default_actor are not called during actor list
  • features/steps/tdd_actor_list_no_db_update_steps.py — Step definitions
  • robot/tdd_actor_list_no_db_update.robot — 2 Robot Framework integration tests
  • robot/helper_tdd_actor_list_no_db_update.py — Robot helper script

Test Adjustments

Three existing test suites relied on the old (buggy) behavior where list_actors() called ensure_built_in_actors():

  1. features/consolidated_actor.feature — Scenario updated to explicitly call ensure_built_in_actors() before list_actors()
  2. features/steps/tdd_actor_list_validation_steps.py + robot/helper_tdd_actor_list_validation.py (bug #592) — Updated to call ensure_built_in_actors() explicitly before CLI invocation
  3. features/steps/actor_list_empty_steps.py (bug #592) — Updated with explicit ensure_built_in_actors() call and capturing upsert pattern

Quality Gates

Gate Result
nox -e lint Pass
nox -e typecheck Pass (0 errors)
nox -e unit_tests Pass (468 features, 12367 scenarios, 0 failures)
nox -e integration_tests ⚠️ 6 pre-existing failures (timeouts/OOM)
nox -e coverage_report 98% (>= 97% threshold)

The 6 integration test failures are pre-existing infrastructure issues (SIGTERM/SIGKILL timeouts) unrelated to this change: Container Resolve Crash (3), M3 E2E Verification (2), Resource CLI (1).

Closes #797

## Summary - Fix bug #797: `agents actor list` no longer triggers database writes (`upsert_actor`, `set_default_actor`) by removing `ensure_built_in_actors()` from `ActorRegistry.list()` and `ActorRegistry.list_actors()` - Include TDD regression tests from #841 with `@tdd_expected_fail` removed per Bug Fix Workflow - Update three existing test suites that relied on the old behavior to call `ensure_built_in_actors()` explicitly ## Root Cause `ActorRegistry.list_actors()` and `ActorRegistry.list()` both unconditionally called `self.ensure_built_in_actors()` before delegating to the actor service. `ensure_built_in_actors()` iterates all configured providers and calls `_actor_service.upsert_actor()` for each — a database WRITE operation. It may also call `_actor_service.set_default_actor()` if no default exists — another WRITE. This means every read-only `agents actor list` command triggered database writes and could prompt for pending migrations on fresh checkouts. ## Changes ### Bug Fix - **`src/cleveragents/actor/registry.py`** — Removed `self.ensure_built_in_actors()` from `list()` and `list_actors()`. Both methods now delegate directly to the service layer without triggering writes. All write-heavy methods (`add`, `upsert_actor`, `get`, `get_actor`, `remove`, `remove_actor`, `set_default_actor`, `get_default_actor`) still call `ensure_built_in_actors()`. ### TDD Tests (from #841, `@tdd_expected_fail` removed) - **`features/tdd_actor_list_no_db_update.feature`** — 2 Behave scenarios verifying `upsert_actor` and `set_default_actor` are not called during `actor list` - **`features/steps/tdd_actor_list_no_db_update_steps.py`** — Step definitions - **`robot/tdd_actor_list_no_db_update.robot`** — 2 Robot Framework integration tests - **`robot/helper_tdd_actor_list_no_db_update.py`** — Robot helper script ### Test Adjustments Three existing test suites relied on the old (buggy) behavior where `list_actors()` called `ensure_built_in_actors()`: 1. **`features/consolidated_actor.feature`** — Scenario updated to explicitly call `ensure_built_in_actors()` before `list_actors()` 2. **`features/steps/tdd_actor_list_validation_steps.py`** + **`robot/helper_tdd_actor_list_validation.py`** (bug #592) — Updated to call `ensure_built_in_actors()` explicitly before CLI invocation 3. **`features/steps/actor_list_empty_steps.py`** (bug #592) — Updated with explicit `ensure_built_in_actors()` call and capturing upsert pattern ## Quality Gates | Gate | Result | |------|--------| | `nox -e lint` | ✅ Pass | | `nox -e typecheck` | ✅ Pass (0 errors) | | `nox -e unit_tests` | ✅ Pass (468 features, 12367 scenarios, 0 failures) | | `nox -e integration_tests` | ⚠️ 6 pre-existing failures (timeouts/OOM) | | `nox -e coverage_report` | ✅ 98% (>= 97% threshold) | The 6 integration test failures are pre-existing infrastructure issues (SIGTERM/SIGKILL timeouts) unrelated to this change: Container Resolve Crash (3), M3 E2E Verification (2), Resource CLI (1). Closes #797
brent.edwards added this to the v3.2.0 milestone 2026-03-24 18:12:40 +00:00
freemo approved these changes 2026-03-27 17:09:55 +00:00
Dismissed
freemo left a comment

Review: fix(cli): prevent actor list from triggering database updates

Approved with comments. The TDD test code is well-implemented.

Issues to Address

1. Misleading PR title (Medium)
The PR title says fix(cli): but the PR contains only TDD tests — no actual fix. The commit correctly uses test(cli):. The title should be updated to test(cli): TDD failing tests for actor list database update (bug #797).

2. Missing PR description (Medium)
Per CONTRIBUTING.md, PRs submitted without a description will not be reviewed. The commit message is thorough, but a PR description would help reviewers scanning PR lists.

What's Good

  • Clean step definitions with proper type annotations and from __future__ import annotations.
  • Correct @tdd_expected_fail @tdd_bug @tdd_bug_797 tags.
  • Step names properly suffixed with for tdd-actor-list-no-db-update to avoid Behave AmbiguousStep collisions.
  • Good Robot Framework helper with sentinel-based pass/fail and NoReturn type hint on _fail().
  • Two focused scenarios covering both upsert_actor and set_default_actor write operations.

Minor Nit

_DEFAULT_PROVIDERS is a module-level mutable list. Since it's never mutated, tuple would be more defensively correct.

## Review: fix(cli): prevent actor list from triggering database updates **Approved with comments.** The TDD test code is well-implemented. ### Issues to Address **1. Misleading PR title (Medium)** The PR title says `fix(cli):` but the PR contains **only TDD tests** — no actual fix. The commit correctly uses `test(cli):`. The title should be updated to `test(cli): TDD failing tests for actor list database update (bug #797)`. **2. Missing PR description (Medium)** Per CONTRIBUTING.md, PRs submitted without a description will not be reviewed. The commit message is thorough, but a PR description would help reviewers scanning PR lists. ### What's Good - Clean step definitions with proper type annotations and `from __future__ import annotations`. - Correct `@tdd_expected_fail @tdd_bug @tdd_bug_797` tags. - Step names properly suffixed with `for tdd-actor-list-no-db-update` to avoid Behave `AmbiguousStep` collisions. - Good Robot Framework helper with sentinel-based pass/fail and `NoReturn` type hint on `_fail()`. - Two focused scenarios covering both `upsert_actor` and `set_default_actor` write operations. ### Minor Nit `_DEFAULT_PROVIDERS` is a module-level mutable `list`. Since it's never mutated, `tuple` would be more defensively correct.
brent.edwards changed title from fix(cli): prevent actor list from triggering database updates to tdd(cli): prevent actor list from triggering database updates 2026-03-28 02:51:50 +00:00
brent.edwards force-pushed bugfix/m3-actor-list-no-db-update from 1571e2d50a
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 13s
CI / lint (pull_request) Successful in 3m19s
CI / typecheck (pull_request) Successful in 3m46s
CI / quality (pull_request) Successful in 3m43s
CI / security (pull_request) Successful in 3m58s
CI / unit_tests (pull_request) Successful in 5m58s
CI / integration_tests (pull_request) Successful in 6m13s
CI / docker (pull_request) Successful in 1m15s
CI / e2e_tests (pull_request) Successful in 9m25s
CI / coverage (pull_request) Successful in 10m28s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 1h6m2s
to 40af026237
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 24s
CI / helm (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 3m18s
CI / quality (pull_request) Successful in 3m41s
CI / typecheck (pull_request) Successful in 4m3s
CI / security (pull_request) Successful in 4m4s
CI / integration_tests (pull_request) Successful in 6m56s
CI / unit_tests (pull_request) Successful in 7m17s
CI / docker (pull_request) Successful in 1m43s
CI / e2e_tests (pull_request) Successful in 12m8s
CI / coverage (pull_request) Successful in 11m49s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 55m16s
2026-03-28 02:58:50 +00:00
Compare
brent.edwards dismissed freemo's review 2026-03-28 02:58:50 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

brent.edwards scheduled this pull request to auto merge when all checks succeed 2026-03-28 04:21:29 +00:00
brent.edwards force-pushed bugfix/m3-actor-list-no-db-update from a20c34f40a
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 31s
CI / helm (pull_request) Successful in 36s
CI / lint (pull_request) Successful in 3m44s
CI / quality (pull_request) Successful in 4m9s
CI / typecheck (pull_request) Successful in 4m22s
CI / security (pull_request) Successful in 4m19s
CI / integration_tests (pull_request) Successful in 9m51s
CI / unit_tests (pull_request) Successful in 10m14s
CI / docker (pull_request) Successful in 1m30s
CI / e2e_tests (pull_request) Successful in 14m9s
CI / coverage (pull_request) Successful in 11m44s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Failing after 35m28s
to 6b7652919f
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 38s
CI / build (pull_request) Successful in 30s
CI / helm (pull_request) Successful in 39s
CI / typecheck (pull_request) Successful in 3m57s
CI / security (pull_request) Successful in 4m8s
CI / quality (pull_request) Successful in 3m39s
CI / integration_tests (pull_request) Successful in 9m30s
CI / unit_tests (pull_request) Successful in 9m44s
CI / docker (pull_request) Successful in 1m32s
CI / e2e_tests (pull_request) Successful in 11m56s
CI / coverage (pull_request) Successful in 11m28s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Failing after 20m56s
2026-03-28 05:11:46 +00:00
Compare
brent.edwards scheduled this pull request to auto merge when all checks succeed 2026-03-28 05:12:04 +00:00
brent.edwards deleted branch bugfix/m3-actor-list-no-db-update 2026-03-28 05:27:15 +00:00
Sign in to join this conversation.
No reviewers
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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!1151
No description provided.