UAT: RollbackResult model missing spec-required fields — CLI uses getattr fallbacks for missing data #3509

Open
opened 2026-04-05 18:43:36 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/rollback-result-missing-spec-fields
  • Commit Message: fix(domain): add missing spec-required fields to RollbackResult model
  • Milestone: Backlog
  • Parent Epic: #358

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

Summary

The RollbackResult domain model (src/cleveragents/domain/models/core/checkpoint.py) is missing several fields that the spec requires rollback to report. The CLI command agents plan rollback attempts to access these fields via getattr(..., None) fallbacks, meaning they silently display nothing instead of the actual rollback impact data.

Spec Reference

The spec's agents plan rollback command output includes:

Changes Reverted:
  - file.py: restored
  - other.py: restored

Impact:
  - Child Plans Invalidated: <N>
  - Sandbox: restored to <checkpoint_id>
  - Decisions After CP: <N> discarded
  - Tool Calls After CP: <N> undone

Post-Rollback State:
  - Phase: execute
  - State: queued
  - Checkpoints Remaining: <N>

The spec also states:

All changes made after the target checkpoint are reverted: files are restored or removed, decisions are discarded, and tool calls are undone. Child plans spawned after the checkpoint are invalidated.

Current Implementation

The RollbackResult model only has:

class RollbackResult(BaseModel):
    restored_files_count: int
    changed_paths: list[str]
    from_checkpoint_id: str

The CLI at src/cleveragents/cli/commands/plan.py (lines 3459-3497) tries to access these fields via getattr:

child_plans_invalidated = getattr(result, "child_plans_invalidated", None)
sandbox_state = getattr(result, "sandbox", None)
decisions_after_cp = getattr(result, "decisions_after_cp", None)
tool_calls_after_cp = getattr(result, "tool_calls_after_cp", None)
checkpoints_remaining = getattr(result, "checkpoints_remaining", None)
phase = getattr(result, "phase", None) or "execute"
state = getattr(result, "state", None) or "queued"
label = getattr(result, "label", None) or ""
changes_reverted = getattr(result, "changes_reverted", None)

All of these return None because the fields don't exist on RollbackResult. The Impact panel only shows Sandbox: restored to <checkpoint_id> — all other impact data is silently omitted.

Missing Fields

The RollbackResult model should include:

  • child_plans_invalidated: int | None — number of child plans invalidated
  • decisions_after_cp: int | None — number of decisions discarded
  • tool_calls_after_cp: int | None — number of tool calls undone
  • checkpoints_remaining: int | None — checkpoints remaining after rollback
  • phase: str — plan phase after rollback (e.g., "execute")
  • state: str — plan processing state after rollback (e.g., "queued")
  • label: str | None — optional checkpoint label
  • changes_reverted: list[dict] | None — structured list of reverted changes with file + action

Impact

  • The agents plan rollback command's Impact panel is nearly empty — users cannot see how many decisions were discarded or child plans invalidated
  • The spec's rollback semantics (invalidating child plans, discarding decisions) are not tracked or reported
  • The CheckpointService.rollback_to_checkpoint() only does a git reset --hard — it does not invalidate child plans or discard decisions from the database

Code Locations

  • src/cleveragents/domain/models/core/checkpoint.pyRollbackResult model
  • src/cleveragents/cli/commands/plan.py lines 3459–3497 — CLI rollback output
  • src/cleveragents/application/services/checkpoint_service.pyrollback_to_checkpoint() method

Subtasks

  • Add missing fields to RollbackResult in src/cleveragents/domain/models/core/checkpoint.py
  • Update CheckpointService.rollback_to_checkpoint() to populate all new fields (child plan invalidation, decision discard count, tool call undo count, checkpoints remaining, phase, state, label, changes_reverted)
  • Remove getattr fallbacks in CLI (src/cleveragents/cli/commands/plan.py lines 3459–3497) and access fields directly
  • Tests (Behave): Add/update unit test scenarios for RollbackResult field population
  • Tests (Behave): Add scenarios verifying CLI rollback output renders all Impact and Post-Rollback State fields
  • Tests (Robot): Add/update integration test for agents plan rollback verifying full output
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • RollbackResult contains all spec-required fields with correct types.
  • CheckpointService.rollback_to_checkpoint() correctly populates all fields, including invalidating child plans and discarding decisions/tool calls from the database.
  • The CLI agents plan rollback Impact and Post-Rollback State panels display all spec-required data without any getattr fallbacks.
  • 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.
  • All nox stages pass.
  • Coverage >= 97%.

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

## Metadata - **Branch**: `fix/rollback-result-missing-spec-fields` - **Commit Message**: `fix(domain): add missing spec-required fields to RollbackResult model` - **Milestone**: Backlog - **Parent Epic**: #358 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.3.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Summary The `RollbackResult` domain model (`src/cleveragents/domain/models/core/checkpoint.py`) is missing several fields that the spec requires rollback to report. The CLI command `agents plan rollback` attempts to access these fields via `getattr(..., None)` fallbacks, meaning they silently display nothing instead of the actual rollback impact data. ## Spec Reference The spec's `agents plan rollback` command output includes: ``` Changes Reverted: - file.py: restored - other.py: restored Impact: - Child Plans Invalidated: <N> - Sandbox: restored to <checkpoint_id> - Decisions After CP: <N> discarded - Tool Calls After CP: <N> undone Post-Rollback State: - Phase: execute - State: queued - Checkpoints Remaining: <N> ``` The spec also states: > All changes made after the target checkpoint are **reverted**: files are restored or removed, decisions are discarded, and tool calls are undone. Child plans spawned after the checkpoint are invalidated. ## Current Implementation The `RollbackResult` model only has: ```python class RollbackResult(BaseModel): restored_files_count: int changed_paths: list[str] from_checkpoint_id: str ``` The CLI at `src/cleveragents/cli/commands/plan.py` (lines 3459-3497) tries to access these fields via `getattr`: ```python child_plans_invalidated = getattr(result, "child_plans_invalidated", None) sandbox_state = getattr(result, "sandbox", None) decisions_after_cp = getattr(result, "decisions_after_cp", None) tool_calls_after_cp = getattr(result, "tool_calls_after_cp", None) checkpoints_remaining = getattr(result, "checkpoints_remaining", None) phase = getattr(result, "phase", None) or "execute" state = getattr(result, "state", None) or "queued" label = getattr(result, "label", None) or "" changes_reverted = getattr(result, "changes_reverted", None) ``` All of these return `None` because the fields don't exist on `RollbackResult`. The Impact panel only shows `Sandbox: restored to <checkpoint_id>` — all other impact data is silently omitted. ## Missing Fields The `RollbackResult` model should include: - `child_plans_invalidated: int | None` — number of child plans invalidated - `decisions_after_cp: int | None` — number of decisions discarded - `tool_calls_after_cp: int | None` — number of tool calls undone - `checkpoints_remaining: int | None` — checkpoints remaining after rollback - `phase: str` — plan phase after rollback (e.g., `"execute"`) - `state: str` — plan processing state after rollback (e.g., `"queued"`) - `label: str | None` — optional checkpoint label - `changes_reverted: list[dict] | None` — structured list of reverted changes with file + action ## Impact - The `agents plan rollback` command's Impact panel is nearly empty — users cannot see how many decisions were discarded or child plans invalidated - The spec's rollback semantics (invalidating child plans, discarding decisions) are not tracked or reported - The `CheckpointService.rollback_to_checkpoint()` only does a `git reset --hard` — it does not invalidate child plans or discard decisions from the database ## Code Locations - `src/cleveragents/domain/models/core/checkpoint.py` — `RollbackResult` model - `src/cleveragents/cli/commands/plan.py` lines 3459–3497 — CLI rollback output - `src/cleveragents/application/services/checkpoint_service.py` — `rollback_to_checkpoint()` method ## Subtasks - [ ] Add missing fields to `RollbackResult` in `src/cleveragents/domain/models/core/checkpoint.py` - [ ] Update `CheckpointService.rollback_to_checkpoint()` to populate all new fields (child plan invalidation, decision discard count, tool call undo count, checkpoints remaining, phase, state, label, changes_reverted) - [ ] Remove `getattr` fallbacks in CLI (`src/cleveragents/cli/commands/plan.py` lines 3459–3497) and access fields directly - [ ] Tests (Behave): Add/update unit test scenarios for `RollbackResult` field population - [ ] Tests (Behave): Add scenarios verifying CLI rollback output renders all Impact and Post-Rollback State fields - [ ] Tests (Robot): Add/update integration test for `agents plan rollback` verifying full output - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - `RollbackResult` contains all spec-required fields with correct types. - `CheckpointService.rollback_to_checkpoint()` correctly populates all fields, including invalidating child plans and discarding decisions/tool calls from the database. - The CLI `agents plan rollback` Impact and Post-Rollback State panels display all spec-required data without any `getattr` fallbacks. - 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. - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.3.0 milestone 2026-04-05 20:36:07 +00:00
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
Reference
cleveragents/cleveragents-core#3509
No description provided.