UAT: ADR-025 Violation — Widespread use of stdlib logging instead of structlog across 100+ source files #4053

Closed
opened 2026-04-06 09:37:31 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/adr-025-stdlib-logging-violations
  • Commit Message: fix(observability): replace stdlib logging with structlog across all modules
  • 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.

⚠️ Potential Duplicate: Issue #3930 covers the same root cause (108 source files using stdlib logging instead of structlog). This issue provides additional ADR-025 context and a more detailed affected-files list. Human review recommended to determine whether to merge or close as duplicate.

Bug Report

What was tested: ADR-025 (Observability and Logging) compliance across the codebase

Expected behavior (from ADR-025):
ADR-025 mandates that CleverAgents uses structlog (>= 24.4.0) for ALL structured JSON logging with context binding. The ADR explicitly states:

  • "All log events must be structured JSON. Unstructured string messages are prohibited."
  • "Context binding must include at minimum plan_id and actor_name for events within plan execution."
  • structlog is the chosen logging library per ADR-005 (Technical Stack)

Actual behavior:
Over 100 source files use Python's stdlib import logging / logging.getLogger(__name__) instead of structlog. This produces unstructured log output that:

  • Does not produce JSON-structured events
  • Does not support context binding (plan_id, actor_name, decision_id, tool_name)
  • Cannot be correlated across plan hierarchies
  • Violates the ADR-025 requirement for structured observability

Affected files (representative sample — 100+ total):

  • src/cleveragents/domain/models/core/definition_of_done.py (line 18)
  • src/cleveragents/domain/models/acms/python_analyzer.py (line 24)
  • src/cleveragents/domain/models/acms/markdown_analyzer.py (line 26)
  • src/cleveragents/domain/models/acms/docker_compose_analyzer.py (line 29)
  • src/cleveragents/domain/models/acms/postgresql_analyzer.py (line 28)
  • src/cleveragents/domain/models/core/container_lifecycle.py (line 40)
  • src/cleveragents/application/services/skill_service.py (line 17)
  • src/cleveragents/application/services/validation_pipeline.py (line 22)
  • src/cleveragents/application/services/checkpoint_service.py (line 23)
  • src/cleveragents/application/services/decomposition_service.py (line 22)
  • src/cleveragents/application/services/autonomy_controller.py (line 16)
  • src/cleveragents/application/services/resource_registry_service.py (line 63)
  • src/cleveragents/tool/router.py (line 30)
  • src/cleveragents/tool/actor_runtime.py (line 33)
  • src/cleveragents/resource/schema.py (line 19)
  • src/cleveragents/mcp/client.py (line 33)
  • src/cleveragents/mcp/adapter.py (line 18)
  • src/cleveragents/infrastructure/sandbox/manager.py (line 17)
  • src/cleveragents/infrastructure/sandbox/git_worktree.py (line 14)
  • src/cleveragents/cli/commands/resource.py (line 57)
  • src/cleveragents/reactive/stream_router.py (line 9)
  • src/cleveragents/langgraph/bridge.py (line 7)
  • src/cleveragents/langgraph/state.py (line 6)
  • ... and 80+ more files

Steps to reproduce:

grep -r "import logging" src/cleveragents/ --include="*.py" | wc -l
# Returns 100+
grep -r "logging.getLogger" src/cleveragents/ --include="*.py" | wc -l
# Returns 100+

Impact:

  • Structured observability is broken for all code paths using stdlib logging
  • Context binding (plan_id, actor_name) is absent from these log events
  • Log correlation across plan hierarchies is impossible for these modules
  • ADR-025 compliance is severely compromised

Fix:
Replace all import logging / logging.getLogger(__name__) usages with:

import structlog
_logger = structlog.get_logger(__name__)

And update all log calls to use keyword arguments for structured context binding per ADR-025.

Note: src/cleveragents/config/logging.py correctly configures structlog and provides a get_logger() helper — all modules should use this instead of stdlib logging.

Subtasks

  • Audit all files using import logging in src/cleveragents/
  • Replace stdlib logger with structlog.get_logger(__name__) in domain layer files
  • Replace stdlib logger with structlog.get_logger(__name__) in application layer files
  • Replace stdlib logger with structlog.get_logger(__name__) in infrastructure layer files
  • Replace stdlib logger with structlog.get_logger(__name__) in CLI/presentation layer files
  • Replace stdlib logger with structlog.get_logger(__name__) in tool/resource/skill/mcp modules
  • Add context binding (plan_id, actor_name) where appropriate per ADR-025
  • Add CI lint rule to prevent future stdlib logging imports
  • Tests (Behave): Update unit tests to verify structured log output
  • Tests (Robot): Add integration test verifying JSON log output in plan execution paths
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

  • Zero import logging / logging.getLogger usages in src/cleveragents/ (except config/logging.py which configures the stdlib bridge)
  • All log events in plan execution paths include plan_id and actor_name context binding
  • CI lint rule prevents regression
  • Tests verify structured JSON log output
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/adr-025-stdlib-logging-violations` - **Commit Message**: `fix(observability): replace stdlib logging with structlog across all modules` - **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. > **⚠️ Potential Duplicate:** Issue #3930 covers the same root cause (108 source files using stdlib `logging` instead of `structlog`). This issue provides additional ADR-025 context and a more detailed affected-files list. Human review recommended to determine whether to merge or close as duplicate. ## Bug Report **What was tested:** ADR-025 (Observability and Logging) compliance across the codebase **Expected behavior (from ADR-025):** ADR-025 mandates that CleverAgents uses **structlog** (>= 24.4.0) for ALL structured JSON logging with context binding. The ADR explicitly states: - "All log events must be structured JSON. Unstructured string messages are prohibited." - "Context binding must include at minimum `plan_id` and `actor_name` for events within plan execution." - structlog is the chosen logging library per ADR-005 (Technical Stack) **Actual behavior:** Over 100 source files use Python's stdlib `import logging` / `logging.getLogger(__name__)` instead of `structlog`. This produces unstructured log output that: - Does not produce JSON-structured events - Does not support context binding (plan_id, actor_name, decision_id, tool_name) - Cannot be correlated across plan hierarchies - Violates the ADR-025 requirement for structured observability **Affected files (representative sample — 100+ total):** - `src/cleveragents/domain/models/core/definition_of_done.py` (line 18) - `src/cleveragents/domain/models/acms/python_analyzer.py` (line 24) - `src/cleveragents/domain/models/acms/markdown_analyzer.py` (line 26) - `src/cleveragents/domain/models/acms/docker_compose_analyzer.py` (line 29) - `src/cleveragents/domain/models/acms/postgresql_analyzer.py` (line 28) - `src/cleveragents/domain/models/core/container_lifecycle.py` (line 40) - `src/cleveragents/application/services/skill_service.py` (line 17) - `src/cleveragents/application/services/validation_pipeline.py` (line 22) - `src/cleveragents/application/services/checkpoint_service.py` (line 23) - `src/cleveragents/application/services/decomposition_service.py` (line 22) - `src/cleveragents/application/services/autonomy_controller.py` (line 16) - `src/cleveragents/application/services/resource_registry_service.py` (line 63) - `src/cleveragents/tool/router.py` (line 30) - `src/cleveragents/tool/actor_runtime.py` (line 33) - `src/cleveragents/resource/schema.py` (line 19) - `src/cleveragents/mcp/client.py` (line 33) - `src/cleveragents/mcp/adapter.py` (line 18) - `src/cleveragents/infrastructure/sandbox/manager.py` (line 17) - `src/cleveragents/infrastructure/sandbox/git_worktree.py` (line 14) - `src/cleveragents/cli/commands/resource.py` (line 57) - `src/cleveragents/reactive/stream_router.py` (line 9) - `src/cleveragents/langgraph/bridge.py` (line 7) - `src/cleveragents/langgraph/state.py` (line 6) - ... and 80+ more files **Steps to reproduce:** ```bash grep -r "import logging" src/cleveragents/ --include="*.py" | wc -l # Returns 100+ grep -r "logging.getLogger" src/cleveragents/ --include="*.py" | wc -l # Returns 100+ ``` **Impact:** - Structured observability is broken for all code paths using stdlib logging - Context binding (plan_id, actor_name) is absent from these log events - Log correlation across plan hierarchies is impossible for these modules - ADR-025 compliance is severely compromised **Fix:** Replace all `import logging` / `logging.getLogger(__name__)` usages with: ```python import structlog _logger = structlog.get_logger(__name__) ``` And update all log calls to use keyword arguments for structured context binding per ADR-025. Note: `src/cleveragents/config/logging.py` correctly configures structlog and provides a `get_logger()` helper — all modules should use this instead of stdlib logging. ## Subtasks - [ ] Audit all files using `import logging` in `src/cleveragents/` - [ ] Replace stdlib logger with `structlog.get_logger(__name__)` in domain layer files - [ ] Replace stdlib logger with `structlog.get_logger(__name__)` in application layer files - [ ] Replace stdlib logger with `structlog.get_logger(__name__)` in infrastructure layer files - [ ] Replace stdlib logger with `structlog.get_logger(__name__)` in CLI/presentation layer files - [ ] Replace stdlib logger with `structlog.get_logger(__name__)` in tool/resource/skill/mcp modules - [ ] Add context binding (plan_id, actor_name) where appropriate per ADR-025 - [ ] Add CI lint rule to prevent future stdlib logging imports - [ ] Tests (Behave): Update unit tests to verify structured log output - [ ] Tests (Robot): Add integration test verifying JSON log output in plan execution paths - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] Zero `import logging` / `logging.getLogger` usages in `src/cleveragents/` (except `config/logging.py` which configures the stdlib bridge) - [ ] All log events in plan execution paths include `plan_id` and `actor_name` context binding - [ ] CI lint rule prevents regression - [ ] Tests verify structured JSON log output - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Author
Owner

Duplicate of #3930

This issue covers the same problem as #3930: widespread use of stdlib logging instead of structlog across 100+ source files, violating ADR-025 and the spec's structured logging requirement. Issue #3930 was filed earlier (2026-04-06T07:33:36Z vs this issue at 2026-04-06T09:37:31Z). This issue itself acknowledges the potential duplicate in its body ("⚠️ Potential Duplicate: Issue #3930 covers the same root cause"). Closing as a duplicate — please track the fix in #3930.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

**Duplicate of #3930** This issue covers the same problem as #3930: widespread use of stdlib `logging` instead of `structlog` across 100+ source files, violating ADR-025 and the spec's structured logging requirement. Issue #3930 was filed earlier (2026-04-06T07:33:36Z vs this issue at 2026-04-06T09:37:31Z). This issue itself acknowledges the potential duplicate in its body ("⚠️ Potential Duplicate: Issue #3930 covers the same root cause"). Closing as a duplicate — please track the fix in #3930. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
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#4053
No description provided.