Implement the following plan: E2E Testing Framework with Real Agent Calls Summary Create…
- User
Implement the following plan:
E2E Testing Framework with Real Agent Calls
Summary
Create a Go-based E2E testing framework that invokes real agent CLIs (Claude Code with haiku, potentially Gemini CLI later) to test the Entire CLI's checkpoint system. This replaces the bash script
scripts/test-attribution-e2e.shwith proper Go tests.Key insight: The CLI already has multi-agent support via the
agent.Agentinterface (seecmd/entire/cli/agent/agent.go). The e2e framework should follow this pattern with anAgentRunnerinterface.Directory Structure
cmd/entire/cli/e2e_test/ ├── setup_test.go # TestMain: builds binary, checks agent availability ├── testenv.go # E2ETestEnv: standalone env with AgentRunner ├── agent_runner.go # AgentRunner interface + ClaudeCodeRunner impl ├── prompts.go # Deterministic prompt templates ├── assertions.go # Verification helpers ├── scenario_basic_workflow_test.go # P0: Basic prompt→changes→commit ├── scenario_checkpoint_test.go # P0: Checkpoint metadata verification ├── scenario_rewind_test.go # P0: Rewind functionality └── scenario_agent_commit_test.go # P1: Agent commits during turnKey Components
1. AgentRunner Interface (
agent_runner.go)Multi-agent design following the existing
agent.Agentpattern:// AgentRunner abstracts invoking a coding agent for e2e tests type AgentRunner interface { // Name returns the agent name (e.g., "claude-code", "gemini-cli") Name() string // IsAvailable checks if the agent CLI is installed and authenticated IsAvailable() (bool, error) // RunPrompt executes a prompt and returns the result RunPrompt(ctx context.Context, prompt string) (*AgentResult, error) // RunPromptWithTools executes with specific allowed tools RunPromptWithTools(ctx context.Context, prompt string, tools []string) (*AgentResult, error) } // AgentResult holds the result of an agent invocation type AgentResult struct { Stdout string Stderr string ExitCode int Duration time.Duration }2. ClaudeCodeRunner (implements AgentRunner)
type ClaudeCodeRunner struct { RepoDir string Model string // Default: "haiku" Timeout time.Duration // Default: 2m AllowedTools []string // Default: ["Edit", "Read", "Write", "Bash"] T *testing.T } func (r *ClaudeCodeRunner) IsAvailable() (bool, error) { // Check: claude CLI in PATH if _, err := exec.LookPath("claude"); err != nil { return false, fmt.Errorf("claude CLI not found: %w", err) } // Check: claude is authenticated (try --version or similar non-auth command) cmd := exec.Command("claude", "--version") if err := cmd.Run(); err != nil { return false, fmt.Errorf("claude CLI not working: %w", err) } return true, nil } Assistant
I'll implement this E2E testing framework. Let me start by exploring the existing codebase to understand the patterns, then create the new files.
Assistant
Now let me read the mise.toml to understand the task structure, then create all the e2e test files.
Assistant
Let me read the setup_test.go and key parts of testenv.go to understand the exact patterns.
Assistant
Let me read the rest of the mise.toml to see the lint task structure, and also check hooks.go for session patterns.
Assistant
Now I have a clear picture of the patterns. Let me create the E2E testing framework. I'll create all the files in parallel.
Assistant
Now let me create the test scenario files and update mise.toml.
Assistant
The LSP warnings are expected because the
e2ebuild tag isn't active. Now let me update mise.toml with the test tasks.Assistant
Now let me verify the code compiles with the e2e build tag.
Assistant
The issue is that
setup_test.gocontains variables that are only available during test compilation. Let me verify withgo test -cwhich is the correct way to compile tests.Assistant
Tests compile correctly. Let me run the linter on the new files.
Assistant
Let me fix the lint issues.
Assistant
The linter already fixed the
errors.Asissue. Let me fix the remaining lint issues across all files.Assistant
Now let me fix the remaining files.
Assistant
Now let me fix testenv.go.
Assistant
Now let me fix the remaining lint issues in testenv.go.
Assistant
Now let me fix assertions.go with the updated type name and error handling.
Assistant
Now I need to update the test scenario files to use the renamed functions.
Assistant
Now let me run the linter again to verify all issues are fixed.
Assistant
I need to fix the remaining issues. The nolint comments were removed by the linter auto-fix, and I need to use context for exec.Command calls.
Assistant
I need to add noctx nolint comments since the test code doesn't need context propagation.
Assistant
Let me run the linter again to verify.
Assistant
All lint issues are fixed. Let me verify the tests compile correctly.
Assistant
Let me run the formatter to ensure everything is properly formatted.
Assistant
All files are properly formatted. Let me verify the regular tests still pass as well.
Assistant
All unit tests pass. Let me list all the files created.
Assistant
The E2E testing framework has been implemented. Here's a summary of what was created:
Files Created
cmd/entire/cli/e2e_test/setup_test.go- TestMain that builds the CLI binary and checks agent availabilitytestenv.go-TestEnvstruct with standalone helpers for test isolationagent_runner.go-AgentRunnerinterface withClaudeCodeRunnerandGeminiCLIRunnerimplementationsprompts.go- Deterministic prompt templates (CreateHelloGo, CreateCalculator, etc.)
- User
Assistant
The tests are failing because the hooks aren't being triggered when Claude runs. The E2E tests need to set up Claude's hooks configuration so that when Claude runs, it triggers the Entire hooks. Let me fix this.
Assistant
Now I understand. The E2E tests need to set up
.claude/settings.jsonwith hooks configured. Let me update the testenv to install the hooks.- User
[Request interrupted by user]
- User
you just should run
entire enable --telemetry false --agent claudethat will setup everything Assistant
You're right - I should just use the existing CLI command. Let me update the test environment to run
entire enableafter setup.Assistant
Done. The
NewFeatureBranchEnvnow runsentire enable --agent claude-code --strategy <strategy> --telemetry=false --forceto set up everything properly, including the hooks in.claude/settings.json. This ensures Claude will trigger the Entire hooks during its session.You can now run the tests again with
mise run test:e2e.- User
Assistant
All 10 tests pass. The E2E testing framework is working correctly with real Claude Code invocations.
The key fix was calling
entire enable --agent claude-code --strategy <strategy> --telemetry=false --forcewhich properly sets up:.entire/settings.jsonwith the strategy configuration.claude/settings.jsonwith all 7 hooks configured- The
entire/checkpoints/v1orphan branch for metadata
The tests verify:
- Basic workflow: Agent creates files → checkpoints created → user commits → checkpoint trailer added
- Multiple changes: Multiple agent prompts create multiple rewind points
- Checkpoint metadata: Rewind points have proper metadata, condensation works
- Checkpoint ID format: 12-char hex IDs are correctly generated
- Auto-commit strategy: Commits are created automatically with trailers
- Rewind to checkpoint: Files are correctly restored from shadow branch
- Rewind after commit: Logs-only rewind behavior works
- : File deletion/restoration works correctly