[events/LoggingEventBus] LoggingEventBus.emit() omits timestamp, root_plan_id, session_id, project_name, user_identity from structured log — incomplete audit trail #10307

Open
opened 2026-04-18 08:29:59 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit: fix(events): include all DomainEvent fields in LoggingEventBus structured log output
  • Branch: fix/logging-event-bus-missing-fields

Background and Context

LoggingEventBus.emit() in src/cleveragents/infrastructure/events/logging_bus.py silently omits five DomainEvent fields from its structured log output. The LoggingEventBus is documented as "useful for audit trails" but produces an incomplete audit record, missing timestamp, root_plan_id, session_id, project_name, and user_identity.

Expected Behavior

LoggingEventBus.emit() should log ALL DomainEvent fields in the structured log record, consistent with its documented purpose as an audit trail bus.

Current Behaviour

# src/cleveragents/infrastructure/events/logging_bus.py
_logger.info(
    "domain_event",
    event_type=str(event.event_type),
    correlation_id=event.correlation_id,
    plan_id=event.plan_id,
    actor_name=event.actor_name,
    details=event.details,
    # MISSING: timestamp, root_plan_id, session_id, project_name, user_identity
)

The DomainEvent model defines 10 fields. Only 5 are logged. The omitted fields include:

  • timestamp — when the event occurred (critical for audit ordering)
  • root_plan_id — top-level plan in a hierarchy (needed for tracing)
  • session_id — session context (needed for session-level audit)
  • project_name — project context (needed for multi-project audit)
  • user_identity — authenticated user (critical for security audit of AUTH_SUCCESS/AUTH_FAILURE events)

Impact

  • Security audit events (AUTH_SUCCESS, AUTH_FAILURE) are logged without the user_identity field, making it impossible to determine which user authenticated or failed to authenticate from logs alone.
  • Hierarchical plan tracing is broken — root_plan_id is missing, so log queries cannot reconstruct the full plan hierarchy.
  • Session-level audit is incomplete — session_id is missing.
  • Log timestamps are absent — timestamp (the event creation time) is not logged, only the log emission time is available.

Fix

Update LoggingEventBus.emit() in src/cleveragents/infrastructure/events/logging_bus.py:

_logger.info(
    "domain_event",
    event_type=str(event.event_type),
    timestamp=event.timestamp.isoformat(),
    correlation_id=event.correlation_id,
    plan_id=event.plan_id,
    root_plan_id=event.root_plan_id,
    session_id=event.session_id,
    actor_name=event.actor_name,
    project_name=event.project_name,
    user_identity=event.user_identity,
    details=event.details,
)

Acceptance Criteria

  • LoggingEventBus.emit() logs all 10 DomainEvent fields
  • timestamp is logged as ISO 8601 string
  • user_identity is logged (may be None in local mode)
  • TDD test (see blocked-by issue #10306) passes after fix
  • nox passes with coverage ≥ 97%

Subtasks

  • Update LoggingEventBus.emit() to include all missing fields
  • Verify user_identity is logged for AUTH_SUCCESS/AUTH_FAILURE events
  • Update/add tests to verify all fields are present in structured log output
  • Run nox to confirm coverage ≥ 97%

Definition of Done

This issue is closed when:

  1. LoggingEventBus.emit() logs all 10 DomainEvent fields
  2. The TDD test (blocked-by issue #10306) passes
  3. nox passes with coverage ≥ 97%
  4. A PR is reviewed and merged to main

References

  • src/cleveragents/infrastructure/events/logging_bus.pyLoggingEventBus.emit() (lines ~60-70)
  • src/cleveragents/infrastructure/events/models.pyDomainEvent model

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit**: `fix(events): include all DomainEvent fields in LoggingEventBus structured log output` - **Branch**: `fix/logging-event-bus-missing-fields` ## Background and Context `LoggingEventBus.emit()` in `src/cleveragents/infrastructure/events/logging_bus.py` silently omits five `DomainEvent` fields from its structured log output. The `LoggingEventBus` is documented as "useful for audit trails" but produces an incomplete audit record, missing `timestamp`, `root_plan_id`, `session_id`, `project_name`, and `user_identity`. ## Expected Behavior `LoggingEventBus.emit()` should log ALL `DomainEvent` fields in the structured log record, consistent with its documented purpose as an audit trail bus. ## Current Behaviour ```python # src/cleveragents/infrastructure/events/logging_bus.py _logger.info( "domain_event", event_type=str(event.event_type), correlation_id=event.correlation_id, plan_id=event.plan_id, actor_name=event.actor_name, details=event.details, # MISSING: timestamp, root_plan_id, session_id, project_name, user_identity ) ``` The `DomainEvent` model defines 10 fields. Only 5 are logged. The omitted fields include: - `timestamp` — when the event occurred (critical for audit ordering) - `root_plan_id` — top-level plan in a hierarchy (needed for tracing) - `session_id` — session context (needed for session-level audit) - `project_name` — project context (needed for multi-project audit) - `user_identity` — authenticated user (critical for security audit of `AUTH_SUCCESS`/`AUTH_FAILURE` events) ## Impact - Security audit events (`AUTH_SUCCESS`, `AUTH_FAILURE`) are logged without the `user_identity` field, making it impossible to determine which user authenticated or failed to authenticate from logs alone. - Hierarchical plan tracing is broken — `root_plan_id` is missing, so log queries cannot reconstruct the full plan hierarchy. - Session-level audit is incomplete — `session_id` is missing. - Log timestamps are absent — `timestamp` (the event creation time) is not logged, only the log emission time is available. ## Fix Update `LoggingEventBus.emit()` in `src/cleveragents/infrastructure/events/logging_bus.py`: ```python _logger.info( "domain_event", event_type=str(event.event_type), timestamp=event.timestamp.isoformat(), correlation_id=event.correlation_id, plan_id=event.plan_id, root_plan_id=event.root_plan_id, session_id=event.session_id, actor_name=event.actor_name, project_name=event.project_name, user_identity=event.user_identity, details=event.details, ) ``` ## Acceptance Criteria - [ ] `LoggingEventBus.emit()` logs all 10 `DomainEvent` fields - [ ] `timestamp` is logged as ISO 8601 string - [ ] `user_identity` is logged (may be `None` in local mode) - [ ] TDD test (see blocked-by issue #10306) passes after fix - [ ] `nox` passes with coverage ≥ 97% ## Subtasks - [ ] Update `LoggingEventBus.emit()` to include all missing fields - [ ] Verify `user_identity` is logged for `AUTH_SUCCESS`/`AUTH_FAILURE` events - [ ] Update/add tests to verify all fields are present in structured log output - [ ] Run `nox` to confirm coverage ≥ 97% ## Definition of Done This issue is closed when: 1. `LoggingEventBus.emit()` logs all 10 `DomainEvent` fields 2. The TDD test (blocked-by issue #10306) passes 3. `nox` passes with coverage ≥ 97% 4. A PR is reviewed and merged to `main` ## References - `src/cleveragents/infrastructure/events/logging_bus.py` — `LoggingEventBus.emit()` (lines ~60-70) - `src/cleveragents/infrastructure/events/models.py` — `DomainEvent` model --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-18 08:40:52 +00:00
Author
Owner

[GROOMED] Quality Analysis Complete

Summary

Issue #10307 has been analyzed and verified as a PRIORITY/CRITICAL bug requiring immediate attention.

Analysis Results

Validity Assessment: VALID & ACTIONABLE

  • Problem: LoggingEventBus.emit() omits 5 critical DomainEvent fields (timestamp, root_plan_id, session_id, project_name, user_identity)
  • Impact: Security audit events lack user_identity, hierarchical tracing broken, session audit incomplete
  • Well-documented: Clear problem statement, specific code examples, and detailed acceptance criteria provided
  • Actionable: Specific file locations, line numbers, and fix provided

Required Labels: COMPLETE

  • State/: ✓ State/Unverified (needs transition to State/Verified)
  • Type/: ✓ Type/Bug
  • Priority/: ✓ Priority/Critical

Milestone Assignment: ASSIGNED

  • Assigned to: v3.5.0 (M6: Autonomy Hardening)
  • Rationale: Infrastructure/events work with event queue publish/subscribe requirements

⚠️ State Transition: PENDING MANUAL ACTION

  • Current: State/Unverified
  • Recommended: State/Verified
  • Note: Label update via API encountered restrictions. Manual transition required.

Critical Flags

🚨 PRIORITY/CRITICAL - This issue requires immediate human attention:

  • Affects security audit trail (AUTH_SUCCESS/AUTH_FAILURE events)
  • Breaks hierarchical plan tracing
  • Incomplete session-level audit
  • No assignee yet - needs assignment to development team
  • No State/In Progress - needs scheduling

Acceptance Criteria Status

All acceptance criteria are well-defined:

  • LoggingEventBus.emit() logs all 10 DomainEvent fields
  • timestamp logged as ISO 8601 string
  • user_identity logged (may be None in local mode)
  • TDD test (blocked-by #10306) passes
  • nox passes with coverage ≥ 97%

Subtasks Identified

  • Update LoggingEventBus.emit() to include all missing fields
  • Verify user_identity logged for AUTH_SUCCESS/AUTH_FAILURE events
  • Update/add tests for all fields in structured log output
  • Run nox to confirm coverage ≥ 97%

Recommendations

  1. Immediate: Manually transition State/Unverified → State/Verified
  2. Urgent: Assign to a developer for implementation
  3. Schedule: Add to sprint planning for v3.5.0 milestone
  4. Dependency: Note blocking relationship with issue #10306

Automated by CleverAgents Bot
Supervisor: Grooming | Agent: grooming-pool-supervisor

[GROOMED] Quality Analysis Complete ## Summary Issue #10307 has been analyzed and verified as a **PRIORITY/CRITICAL** bug requiring immediate attention. ## Analysis Results ### ✅ Validity Assessment: VALID & ACTIONABLE - **Problem**: LoggingEventBus.emit() omits 5 critical DomainEvent fields (timestamp, root_plan_id, session_id, project_name, user_identity) - **Impact**: Security audit events lack user_identity, hierarchical tracing broken, session audit incomplete - **Well-documented**: Clear problem statement, specific code examples, and detailed acceptance criteria provided - **Actionable**: Specific file locations, line numbers, and fix provided ### ✅ Required Labels: COMPLETE - State/: ✓ State/Unverified (needs transition to State/Verified) - Type/: ✓ Type/Bug - Priority/: ✓ Priority/Critical ### ✅ Milestone Assignment: ASSIGNED - **Assigned to**: v3.5.0 (M6: Autonomy Hardening) - **Rationale**: Infrastructure/events work with event queue publish/subscribe requirements ### ⚠️ State Transition: PENDING MANUAL ACTION - **Current**: State/Unverified - **Recommended**: State/Verified - **Note**: Label update via API encountered restrictions. Manual transition required. ## Critical Flags 🚨 **PRIORITY/CRITICAL** - This issue requires immediate human attention: - Affects security audit trail (AUTH_SUCCESS/AUTH_FAILURE events) - Breaks hierarchical plan tracing - Incomplete session-level audit - No assignee yet - needs assignment to development team - No State/In Progress - needs scheduling ## Acceptance Criteria Status All acceptance criteria are well-defined: - [ ] LoggingEventBus.emit() logs all 10 DomainEvent fields - [ ] timestamp logged as ISO 8601 string - [ ] user_identity logged (may be None in local mode) - [ ] TDD test (blocked-by #10306) passes - [ ] nox passes with coverage ≥ 97% ## Subtasks Identified - [ ] Update LoggingEventBus.emit() to include all missing fields - [ ] Verify user_identity logged for AUTH_SUCCESS/AUTH_FAILURE events - [ ] Update/add tests for all fields in structured log output - [ ] Run nox to confirm coverage ≥ 97% ## Recommendations 1. **Immediate**: Manually transition State/Unverified → State/Verified 2. **Urgent**: Assign to a developer for implementation 3. **Schedule**: Add to sprint planning for v3.5.0 milestone 4. **Dependency**: Note blocking relationship with issue #10306 --- **Automated by CleverAgents Bot** Supervisor: Grooming | Agent: grooming-pool-supervisor
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/cleveragents-core#10307
No description provided.