refactor(application): move ReactiveCleverAgentsApp verbosity logging to child logger to stop mutating root logger #49

Open
opened 2026-06-12 17:38:29 +00:00 by hurui200320 · 0 comments
Member

Background

ReactiveCleverAgentsApp.__init__ currently calls logging.getLogger().setLevel(log_level) and then sets the level on all existing root-logger handlers. This mutates global logging state for the entire process, which causes test isolation failures and is a production-side defect for any long-running user process that creates a ReactiveCleverAgentsApp (e.g., a router that handles multiple requests in the same process).

A test-side workaround was added in features/environment.py (PR #48) that saves and restores the root logger level around each BDD scenario. However, the handler-level contamination (also mutated by __init__) is not restored, and the root cause in production code remains.

This issue was identified during the review of PR #48 (issue #17).

Metadata

  • Commit Message: refactor(application): move ReactiveCleverAgentsApp verbosity logging to child logger
  • Branch: refactor/49-application-child-logger

Acceptance Criteria

  1. ReactiveCleverAgentsApp.__init__ no longer calls logging.getLogger().setLevel(...).
  2. Verbosity logic is applied to a named child logger (e.g., logging.getLogger("cleveractors")) instead of the root logger.
  3. All existing handler-level mutations on the root logger are removed from __init__.
  4. The test-side workaround in features/environment.py (the _root_log_original_level save/restore) can be removed or simplified once the production fix is in place.
  5. All existing tests continue to pass.

Subtasks

  • Audit ReactiveCleverAgentsApp.__init__ in src/cleveractors/core/application.py for all root-logger mutations
  • Replace logging.getLogger() calls with logging.getLogger("cleveractors") (or an appropriate named logger)
  • Verify that the verbose parameter still controls log verbosity for the cleveractors package as intended
  • Update or remove the _root_log_original_level save/restore in features/environment.py if no longer needed
  • Run nox -e unit_tests and nox -e coverage_report to verify all tests pass
  • Verify nox -e lint and nox -e typecheck pass

Definition of Done

This issue is complete when:

  • All subtasks above 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.
## Background `ReactiveCleverAgentsApp.__init__` currently calls `logging.getLogger().setLevel(log_level)` and then sets the level on all existing root-logger handlers. This mutates global logging state for the entire process, which causes test isolation failures and is a production-side defect for any long-running user process that creates a `ReactiveCleverAgentsApp` (e.g., a router that handles multiple requests in the same process). A test-side workaround was added in `features/environment.py` (PR #48) that saves and restores the root logger level around each BDD scenario. However, the handler-level contamination (also mutated by `__init__`) is not restored, and the root cause in production code remains. This issue was identified during the review of PR #48 (issue #17). ## Metadata - **Commit Message**: `refactor(application): move ReactiveCleverAgentsApp verbosity logging to child logger` - **Branch**: `refactor/49-application-child-logger` ## Acceptance Criteria 1. `ReactiveCleverAgentsApp.__init__` no longer calls `logging.getLogger().setLevel(...)`. 2. Verbosity logic is applied to a named child logger (e.g., `logging.getLogger("cleveractors")`) instead of the root logger. 3. All existing handler-level mutations on the root logger are removed from `__init__`. 4. The test-side workaround in `features/environment.py` (the `_root_log_original_level` save/restore) can be removed or simplified once the production fix is in place. 5. All existing tests continue to pass. ## Subtasks - [ ] Audit `ReactiveCleverAgentsApp.__init__` in `src/cleveractors/core/application.py` for all root-logger mutations - [ ] Replace `logging.getLogger()` calls with `logging.getLogger("cleveractors")` (or an appropriate named logger) - [ ] Verify that the `verbose` parameter still controls log verbosity for the `cleveractors` package as intended - [ ] Update or remove the `_root_log_original_level` save/restore in `features/environment.py` if no longer needed - [ ] Run `nox -e unit_tests` and `nox -e coverage_report` to verify all tests pass - [ ] Verify `nox -e lint` and `nox -e typecheck` pass ## Definition of Done This issue is complete when: - All subtasks above 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.
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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveractors-core#49
No description provided.