1 Commits

Author SHA1 Message Date
hamza.khyari 814a5167ef feat(plan): implement plan diff using git worktree branch
CI / push-validation (pull_request) Successful in 23s
CI / helm (pull_request) Successful in 33s
CI / build (pull_request) Successful in 3m54s
CI / lint (pull_request) Successful in 3m55s
CI / quality (pull_request) Successful in 4m25s
CI / typecheck (pull_request) Successful in 4m45s
CI / security (pull_request) Successful in 4m46s
CI / e2e_tests (pull_request) Successful in 7m37s
CI / integration_tests (pull_request) Successful in 7m54s
CI / unit_tests (pull_request) Successful in 8m43s
CI / docker (pull_request) Successful in 1m29s
CI / coverage (pull_request) Successful in 15m0s
CI / status-check (pull_request) Successful in 3s
CI / benchmark-regression (pull_request) Has been cancelled
CI / benchmark-publish (pull_request) Has been cancelled
plan diff now detects the worktree branch cleveragents/plan-<id> created
during plan execute and runs git diff HEAD...<branch> to display actual
file changes.  Falls back to changeset-based diff when no worktree branch
exists.

Infrastructure layer:
- GitWorktreeSandbox.diff_against_head() classmethod: checks branch
  existence via rev-parse, runs git diff, returns diff text or None
- Uses _run_git() helper (existing) for subprocess calls with proper
  CalledProcessError/TimeoutExpired handling

CLI layer:
- _get_worktree_diff() thin wrapper: resolves plan -> project -> resource
  via DI container, delegates to GitWorktreeSandbox.diff_against_head()
- Specific exception handling (NotFoundError, CleverAgentsError) with
  structlog debug logging
- Input validation: empty plan_id returns None early
- Called in plan_diff() before changeset fallback (spec §13225)

Tests:
- 4 Behave scenarios covering: branch exists with diff, no branch,
  service resolution path, no linked resources fallback

Fixes:
- CheckpointRepository prune test: use shared session so flush() in
  create() is visible to prune() within the same scenario

ISSUES CLOSED: #9231
2026-04-21 11:31:15 +00:00