UAT: 108 source files use import logging (stdlib) instead of structlog — violates spec requirement for unified structured logging #3930

Open
opened 2026-04-06 07:33:36 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/migrate-stdlib-logging-to-structlog
  • Commit Message: fix(observability): replace stdlib logging with structlog in all 108 source files for unified structured log output
  • Milestone: None (backlog — non-critical, discovered during autonomous UAT)
  • Parent Epic: #940

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Summary

The specification states "All logging uses structlog with JSON output format." However, 108 source files in src/cleveragents/ use Python's standard import logging module directly instead of structlog. This creates inconsistent log output: some log entries are structured JSON (from structlog), while others are plain text (from stdlib logging), breaking the unified observability pipeline.

Expected Behavior (from spec)

Per docs/specification.md §Structured Logging (line ~45793):

All logging uses structlog with JSON output format. Every log entry includes contextual fields that enable correlation across plan hierarchies.

All modules should use:

import structlog
logger = structlog.get_logger(__name__)

Actual Behavior

108 files use import logging and logging.getLogger(__name__) directly. Examples:

  • src/cleveragents/application/services/trace_service.py
  • src/cleveragents/application/services/async_worker.py
  • src/cleveragents/infrastructure/sandbox/manager.py
  • src/cleveragents/infrastructure/sandbox/git_worktree.py
  • src/cleveragents/langgraph/graph.py
  • src/cleveragents/core/error_handling.py
  • src/cleveragents/core/retry_patterns.py
  • (and 101 more files)

Only 82 files use import structlog.

Root Cause

The codebase was not consistently migrated to structlog. Many files were written using the stdlib logging module and were never updated to use structlog.

Impact

  • Log entries from stdlib-logging modules are NOT processed through the structlog processor chain
  • Secrets masking (secrets_masking_processor) is NOT applied to stdlib log entries — potential secret leakage in logs
  • Log entries from stdlib modules lack structured fields (plan_id, actor_name, etc.) required for log correlation
  • JSON output format is not applied to stdlib log entries in production mode
  • The observability pipeline is fragmented — some logs are structured, others are not

Steps to Reproduce

grep -rn "import logging\b" src/cleveragents/ | grep -v ".pyc" | wc -l
# Returns: 108

Subtasks

  • Audit all 108 files using stdlib logging
  • Replace import logging + logging.getLogger(__name__) with import structlog + structlog.get_logger(__name__) in each file
  • Verify secrets masking processor is applied to all log entries
  • Update unit tests to verify structured log output
  • Run nox -e lint and nox -e typecheck to verify no regressions
  • Verify coverage remains ≥ 97%

Definition of Done

  • All source files in src/cleveragents/ use structlog for logging
  • No import logging + getLogger pattern remains (except in config/logging.py which configures the stdlib bridge)
  • All log entries pass through the structlog processor chain including secrets masking
  • Tests pass and coverage ≥ 97%
  • All nox stages pass
  • Coverage >= 97%
  • PR merged

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/migrate-stdlib-logging-to-structlog` - **Commit Message**: `fix(observability): replace stdlib logging with structlog in all 108 source files for unified structured log output` - **Milestone**: None (backlog — non-critical, discovered during autonomous UAT) - **Parent Epic**: #940 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Summary The specification states "All logging uses **structlog** with JSON output format." However, 108 source files in `src/cleveragents/` use Python's standard `import logging` module directly instead of `structlog`. This creates inconsistent log output: some log entries are structured JSON (from structlog), while others are plain text (from stdlib logging), breaking the unified observability pipeline. ## Expected Behavior (from spec) Per `docs/specification.md` §Structured Logging (line ~45793): > All logging uses **structlog** with JSON output format. Every log entry includes contextual fields that enable correlation across plan hierarchies. All modules should use: ```python import structlog logger = structlog.get_logger(__name__) ``` ## Actual Behavior 108 files use `import logging` and `logging.getLogger(__name__)` directly. Examples: - `src/cleveragents/application/services/trace_service.py` - `src/cleveragents/application/services/async_worker.py` - `src/cleveragents/infrastructure/sandbox/manager.py` - `src/cleveragents/infrastructure/sandbox/git_worktree.py` - `src/cleveragents/langgraph/graph.py` - `src/cleveragents/core/error_handling.py` - `src/cleveragents/core/retry_patterns.py` - (and 101 more files) Only 82 files use `import structlog`. ## Root Cause The codebase was not consistently migrated to structlog. Many files were written using the stdlib logging module and were never updated to use structlog. ## Impact - Log entries from stdlib-logging modules are NOT processed through the structlog processor chain - Secrets masking (`secrets_masking_processor`) is NOT applied to stdlib log entries — potential secret leakage in logs - Log entries from stdlib modules lack structured fields (`plan_id`, `actor_name`, etc.) required for log correlation - JSON output format is not applied to stdlib log entries in production mode - The observability pipeline is fragmented — some logs are structured, others are not ## Steps to Reproduce ```bash grep -rn "import logging\b" src/cleveragents/ | grep -v ".pyc" | wc -l # Returns: 108 ``` ## Subtasks - [ ] Audit all 108 files using stdlib `logging` - [ ] Replace `import logging` + `logging.getLogger(__name__)` with `import structlog` + `structlog.get_logger(__name__)` in each file - [ ] Verify secrets masking processor is applied to all log entries - [ ] Update unit tests to verify structured log output - [ ] Run `nox -e lint` and `nox -e typecheck` to verify no regressions - [ ] Verify coverage remains ≥ 97% ## Definition of Done - [ ] All source files in `src/cleveragents/` use `structlog` for logging - [ ] No `import logging` + `getLogger` pattern remains (except in `config/logging.py` which configures the stdlib bridge) - [ ] All log entries pass through the structlog processor chain including secrets masking - [ ] Tests pass and coverage ≥ 97% - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] PR merged --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
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.

Reference
cleveragents/cleveragents-core#3930
No description provided.