UAT: DomainEvent model missing parent_plan_id, phase, state, and attempt log correlation fields required by spec #3931

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

Metadata

  • Branch: fix/domain-event-missing-log-correlation-fields
  • Commit Message: fix(events): add parent_plan_id, phase, state, and attempt log correlation fields to DomainEvent
  • Milestone: None (Backlog)
  • Parent Epic: #397

Summary

The DomainEvent base model in src/cleveragents/infrastructure/events/models.py is missing four fields required by the specification for log correlation: parent_plan_id, phase, state, and attempt. Without these fields, log entries cannot be correlated across plan hierarchies as described in the spec.

Expected Behavior (from spec)

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

Log correlation: Every log entry within a plan execution context includes plan_id, root_plan_id, parent_plan_id, phase, state, and attempt. This enables tracing a single decision through the entire plan hierarchy using standard log querying tools (e.g., jq '.plan_id == "01HXR1C1..."').

The DomainEvent model should include:

parent_plan_id: str | None = None  # Parent plan in hierarchy
phase: str | None = None           # Plan phase (action/strategize/execute/apply)
state: str | None = None           # Plan state
attempt: int | None = None         # Retry attempt number

Actual Behavior

The current DomainEvent model (src/cleveragents/infrastructure/events/models.py) only has:

  • event_type
  • timestamp
  • correlation_id
  • plan_id
  • root_plan_id
  • session_id
  • actor_name
  • project_name
  • user_identity
  • details

Missing: parent_plan_id, phase, state, attempt

Root Cause

The DomainEvent model was implemented with a subset of the spec-required correlation fields. The parent_plan_id, phase, state, and attempt fields were omitted.

Impact

  • Log entries cannot be correlated across plan hierarchies using parent_plan_id
  • Plan phase transitions cannot be tracked in event logs
  • Plan state cannot be observed from event logs
  • Retry attempts cannot be correlated in event logs
  • The spec-required log querying capability is incomplete

Code Location

src/cleveragents/infrastructure/events/models.pyDomainEvent class

Subtasks

  • Add parent_plan_id: str | None = Field(default=None, ...) to DomainEvent
  • Add phase: str | None = Field(default=None, ...) to DomainEvent
  • Add state: str | None = Field(default=None, ...) to DomainEvent
  • Add attempt: int | None = Field(default=None, ge=0, ...) to DomainEvent
  • Update LoggingEventBus.emit() to include new fields in structured log output
  • Update unit tests in features/event_bus.feature to cover new fields
  • Verify all event emitters pass the new fields where applicable

Definition of Done

  • DomainEvent has all 4 missing fields
  • LoggingEventBus logs all correlation fields
  • Unit tests cover the new fields
  • PR merged
  • All nox stages pass
  • Coverage >= 97%

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.


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

## Metadata - **Branch**: `fix/domain-event-missing-log-correlation-fields` - **Commit Message**: `fix(events): add parent_plan_id, phase, state, and attempt log correlation fields to DomainEvent` - **Milestone**: None (Backlog) - **Parent Epic**: #397 ## Summary The `DomainEvent` base model in `src/cleveragents/infrastructure/events/models.py` is missing four fields required by the specification for log correlation: `parent_plan_id`, `phase`, `state`, and `attempt`. Without these fields, log entries cannot be correlated across plan hierarchies as described in the spec. ## Expected Behavior (from spec) Per `docs/specification.md` §Structured Logging (line ~45830): > **Log correlation**: Every log entry within a plan execution context includes `plan_id`, `root_plan_id`, `parent_plan_id`, `phase`, `state`, and `attempt`. This enables tracing a single decision through the entire plan hierarchy using standard log querying tools (e.g., `jq '.plan_id == "01HXR1C1..."'`). The `DomainEvent` model should include: ```python parent_plan_id: str | None = None # Parent plan in hierarchy phase: str | None = None # Plan phase (action/strategize/execute/apply) state: str | None = None # Plan state attempt: int | None = None # Retry attempt number ``` ## Actual Behavior The current `DomainEvent` model (`src/cleveragents/infrastructure/events/models.py`) only has: - `event_type` - `timestamp` - `correlation_id` - `plan_id` - `root_plan_id` - `session_id` - `actor_name` - `project_name` - `user_identity` - `details` Missing: `parent_plan_id`, `phase`, `state`, `attempt` ## Root Cause The `DomainEvent` model was implemented with a subset of the spec-required correlation fields. The `parent_plan_id`, `phase`, `state`, and `attempt` fields were omitted. ## Impact - Log entries cannot be correlated across plan hierarchies using `parent_plan_id` - Plan phase transitions cannot be tracked in event logs - Plan state cannot be observed from event logs - Retry attempts cannot be correlated in event logs - The spec-required log querying capability is incomplete ## Code Location `src/cleveragents/infrastructure/events/models.py` — `DomainEvent` class ## Subtasks - [ ] Add `parent_plan_id: str | None = Field(default=None, ...)` to `DomainEvent` - [ ] Add `phase: str | None = Field(default=None, ...)` to `DomainEvent` - [ ] Add `state: str | None = Field(default=None, ...)` to `DomainEvent` - [ ] Add `attempt: int | None = Field(default=None, ge=0, ...)` to `DomainEvent` - [ ] Update `LoggingEventBus.emit()` to include new fields in structured log output - [ ] Update unit tests in `features/event_bus.feature` to cover new fields - [ ] Verify all event emitters pass the new fields where applicable ## Definition of Done - [ ] `DomainEvent` has all 4 missing fields - [ ] `LoggingEventBus` logs all correlation fields - [ ] Unit tests cover the new fields - [ ] PR merged - [ ] All nox stages pass - [ ] Coverage >= 97% > **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. --- **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.

Blocks
#397 Epic: Server & Autonomy Infrastructure
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3931
No description provided.