UAT: agents plan diff shows ChangeSet metadata only — does not produce actual unified diff from git worktree sandbox #5734

Open
opened 2026-04-09 08:54:36 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: git-worktree-sandbox — agents plan diff <plan_id>
Severity: Priority/Backlog — plan diff output is misleading; shows file paths and hash stubs instead of actual content diffs

What Was Tested

Code-level analysis of agents plan diff <plan_id> against the v3.0.0 milestone acceptance criterion:

agents plan diff <plan_id> shows pending changes in the sandbox

Expected Behavior (from spec)

agents plan diff <plan_id> should produce a unified diff showing the actual content changes in the git worktree sandbox — i.e., what git diff HEAD would show inside the worktree directory.

Actual Behavior

PlanApplyService.diff() (src/cleveragents/application/services/plan_apply_service.py, line 286) calls _resolve_changeset() which reads a SpecChangeSet from the ChangeSetStore (database). The SpecChangeSet contains:

  • File paths
  • Operation types (create/modify/delete)
  • Before/after content hashes (SHA256)

The diff output is rendered by _render_diff_plain() / _render_diff_rich() which shows:

--- a/src/auth/session.py
+++ b/src/auth/session.py
@@ modified @@
- hash: abc123def456...
+ hash: 789xyz012abc...

This is not a unified diff — it shows hash stubs, not actual line-by-line content changes.

Root Cause

The SpecChangeSet stores content hashes but not actual file content. The ChangeSetCapture tool records what files were changed and their hashes, but does not store the full before/after content.

The actual file content differences are only available in the git worktree sandbox directory (via git diff HEAD inside the worktree). But PlanApplyService.diff() never reads from the worktree — it only reads from the ChangeSetStore.

Additionally, as noted in issue #5721, the SandboxManager is in-memory only, so the worktree is not accessible in a new CLI process anyway.

Code Locations

  • plan diff command: src/cleveragents/cli/commands/plan.py, diff command (search for @app.command("diff"))
  • PlanApplyService.diff(): src/cleveragents/application/services/plan_apply_service.py, line 286
  • _render_diff_plain(): src/cleveragents/application/services/plan_apply_service.py, line 172 — shows hash stubs, not content
  • _render_diff_rich(): src/cleveragents/application/services/plan_apply_service.py, line 197 — same issue
  • SpecChangeSet: src/cleveragents/domain/models/core/change.py — stores hashes, not content

Impact

  • Users running agents plan diff <plan_id> see file paths and hash stubs instead of actual content changes
  • The output is not a standard unified diff format that tools like patch or code review systems can consume
  • Users cannot review the actual content of changes before applying

Fix Required

PlanApplyService.diff() should:

  1. Read plan.sandbox_refs[0] to get the worktree path
  2. Run git diff HEAD inside the worktree to get the actual unified diff
  3. Fall back to the SpecChangeSet metadata display if the worktree is not available

This requires resolving issue #5721 first (sandbox reconnection across CLI invocations).


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

## Bug Report **Feature Area**: git-worktree-sandbox — `agents plan diff <plan_id>` **Severity**: Priority/Backlog — `plan diff` output is misleading; shows file paths and hash stubs instead of actual content diffs ## What Was Tested Code-level analysis of `agents plan diff <plan_id>` against the v3.0.0 milestone acceptance criterion: > `agents plan diff <plan_id>` shows pending changes in the sandbox ## Expected Behavior (from spec) `agents plan diff <plan_id>` should produce a **unified diff** showing the actual content changes in the git worktree sandbox — i.e., what `git diff HEAD` would show inside the worktree directory. ## Actual Behavior `PlanApplyService.diff()` (`src/cleveragents/application/services/plan_apply_service.py`, line 286) calls `_resolve_changeset()` which reads a `SpecChangeSet` from the `ChangeSetStore` (database). The `SpecChangeSet` contains: - File paths - Operation types (create/modify/delete) - Before/after content hashes (SHA256) The diff output is rendered by `_render_diff_plain()` / `_render_diff_rich()` which shows: ``` --- a/src/auth/session.py +++ b/src/auth/session.py @@ modified @@ - hash: abc123def456... + hash: 789xyz012abc... ``` This is **not a unified diff** — it shows hash stubs, not actual line-by-line content changes. ## Root Cause The `SpecChangeSet` stores content hashes but not actual file content. The `ChangeSetCapture` tool records what files were changed and their hashes, but does not store the full before/after content. The actual file content differences are only available in the git worktree sandbox directory (via `git diff HEAD` inside the worktree). But `PlanApplyService.diff()` never reads from the worktree — it only reads from the `ChangeSetStore`. Additionally, as noted in issue #5721, the `SandboxManager` is in-memory only, so the worktree is not accessible in a new CLI process anyway. ## Code Locations - **`plan diff` command**: `src/cleveragents/cli/commands/plan.py`, `diff` command (search for `@app.command("diff")`) - **`PlanApplyService.diff()`**: `src/cleveragents/application/services/plan_apply_service.py`, line 286 - **`_render_diff_plain()`**: `src/cleveragents/application/services/plan_apply_service.py`, line 172 — shows hash stubs, not content - **`_render_diff_rich()`**: `src/cleveragents/application/services/plan_apply_service.py`, line 197 — same issue - **`SpecChangeSet`**: `src/cleveragents/domain/models/core/change.py` — stores hashes, not content ## Impact - Users running `agents plan diff <plan_id>` see file paths and hash stubs instead of actual content changes - The output is not a standard unified diff format that tools like `patch` or code review systems can consume - Users cannot review the actual content of changes before applying ## Fix Required `PlanApplyService.diff()` should: 1. Read `plan.sandbox_refs[0]` to get the worktree path 2. Run `git diff HEAD` inside the worktree to get the actual unified diff 3. Fall back to the `SpecChangeSet` metadata display if the worktree is not available This requires resolving issue #5721 first (sandbox reconnection across CLI invocations). --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-09 09:05:17 +00:00
Author
Owner

Label compliance fix applied:

  • Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Label compliance fix applied: - Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
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#5734
No description provided.