Documentation
¶
Index ¶
- Variables
- func ArtifactRunDir() string
- func AssertCheckpointAdvanced(t *testing.T, s *RepoState)
- func AssertCheckpointExists(t *testing.T, dir string, checkpointID string)
- func AssertCheckpointFilesTouched(t *testing.T, dir string, checkpointID string, expected []string)
- func AssertCheckpointFilesTouchedContains(t *testing.T, dir string, checkpointID string, file string)
- func AssertCheckpointHasSingleSession(t *testing.T, dir string, checkpointID string)
- func AssertCheckpointIDFormat(t *testing.T, checkpointID string)
- func AssertCheckpointInLastN(t *testing.T, dir string, checkpointID string, n int)
- func AssertCheckpointMetadataComplete(t *testing.T, dir string, checkpointID string)
- func AssertCheckpointNotAdvanced(t *testing.T, s *RepoState)
- func AssertCommitLinkedToCheckpoint(t *testing.T, dir string, ref string)
- func AssertDistinctSessions(t *testing.T, dir string, checkpointIDs []string)
- func AssertFileExists(t *testing.T, dir string, glob string)
- func AssertHasCheckpointTrailer(t *testing.T, dir string, ref string) string
- func AssertHasShadowBranches(t *testing.T, dir string)
- func AssertNewCommits(t *testing.T, s *RepoState, atLeast int)
- func AssertNoCheckpointTrailer(t *testing.T, dir string, ref string)
- func AssertNoShadowBranches(t *testing.T, dir string)
- func CaptureArtifacts(t *testing.T, s *RepoState)
- func CheckpointIDs(t *testing.T, dir string) []string
- func CheckpointPath(id string) string
- func ForEachAgent(t *testing.T, timeout time.Duration, ...)
- func GetCheckpointTrailer(t *testing.T, dir string, ref string) string
- func Git(t *testing.T, dir string, args ...string)
- func GitOutput(t *testing.T, dir string, args ...string) string
- func GitOutputErr(dir string, args ...string) (string, error)
- func NewCheckpointCommits(t *testing.T, s *RepoState) []string
- func PatchSettings(t *testing.T, dir string, extra map[string]any)
- func SetRunDir(dir string)
- func SetupBareRemote(t *testing.T, s *RepoState) string
- func ValidateCheckpointDeep(t *testing.T, dir string, v DeepCheckpointValidation)
- func WaitForCheckpoint(t *testing.T, s *RepoState, timeout time.Duration)
- func WaitForCheckpointAdvanceFrom(t *testing.T, dir string, fromRef string, timeout time.Duration)
- func WaitForFileExists(t *testing.T, dir string, glob string, timeout time.Duration)
- func WaitForSessionIdle(t *testing.T, dir string, timeout time.Duration)
- type Attribution
- type CheckpointMetadata
- type DeepCheckpointValidation
- type RepoState
- func (s *RepoState) Git(t *testing.T, args ...string)
- func (s *RepoState) IsExternalAgent() bool
- func (s *RepoState) RunPrompt(t *testing.T, ctx context.Context, prompt string, opts ...agents.Option) (agents.Output, error)
- func (s *RepoState) Send(t *testing.T, session agents.Session, input string)
- func (s *RepoState) StartSession(t *testing.T, ctx context.Context) agents.Session
- func (s *RepoState) WaitFor(t *testing.T, session agents.Session, pattern string, timeout time.Duration)
- type SessionMetadata
- type SessionRef
- type TokenUsage
Constants ¶
This section is empty.
Variables ¶
var ArtifactRoot string
ArtifactRoot is the absolute path to the artifact output directory. Must be set in TestMain before any tests run.
var ArtifactTimestamp = time.Now().Format("2006-01-02T15-04-05")
ArtifactTimestamp is the timestamp subdirectory for this test run.
Functions ¶
func ArtifactRunDir ¶
func ArtifactRunDir() string
ArtifactRunDir returns the directory for the current test run.
func AssertCheckpointAdvanced ¶
AssertCheckpointAdvanced asserts the checkpoint branch moved forward.
func AssertCheckpointExists ¶
AssertCheckpointExists asserts that the checkpoint ID is mentioned on the checkpoint branch and that its metadata.json exists in the tree.
func AssertCheckpointFilesTouched ¶
AssertCheckpointFilesTouched asserts the checkpoint metadata lists exactly the expected files in files_touched (order-independent).
func AssertCheckpointFilesTouchedContains ¶
func AssertCheckpointFilesTouchedContains(t *testing.T, dir string, checkpointID string, file string)
AssertCheckpointFilesTouchedContains asserts files_touched contains a specific file path (subset check, unlike the exact-match AssertCheckpointFilesTouched).
func AssertCheckpointHasSingleSession ¶
AssertCheckpointHasSingleSession asserts checkpoint metadata has exactly one session.
func AssertCheckpointIDFormat ¶
AssertCheckpointIDFormat asserts the checkpoint ID is 12 lowercase hex chars.
func AssertCheckpointInLastN ¶
AssertCheckpointInLastN asserts the given checkpoint ID appears in at least n commits on the checkpoint branch (e.g. initial + catchup). Uses --grep to find matching commits regardless of position, so extra commits from multi-commit agent turns don't cause false failures.
func AssertCheckpointMetadataComplete ¶
AssertCheckpointMetadataComplete asserts essential fields in checkpoint metadata are populated.
func AssertCheckpointNotAdvanced ¶
AssertCheckpointNotAdvanced asserts the checkpoint branch has NOT moved.
func AssertCommitLinkedToCheckpoint ¶
AssertCommitLinkedToCheckpoint asserts the trailer exists AND the checkpoint data exists on the checkpoint branch.
func AssertDistinctSessions ¶
AssertDistinctSessions asserts session metadata across checkpoints has unique session IDs.
func AssertFileExists ¶
AssertFileExists asserts that at least one file matches the glob pattern relative to dir.
func AssertHasCheckpointTrailer ¶
AssertHasCheckpointTrailer asserts the commit has an Entire-Checkpoint trailer, validates its format, and returns its value.
func AssertHasShadowBranches ¶
AssertHasShadowBranches asserts that at least one shadow branch (entire/*) exists, excluding entire/checkpoints/*. Use this when the shadow branch is expected to persist (e.g., session is still idle).
func AssertNewCommits ¶
AssertNewCommits polls until at least `atLeast` new commits exist since setup, or fails after 20 seconds. Polling handles the race where an interactive agent's prompt pattern appears before its git commit lands on disk.
func AssertNoCheckpointTrailer ¶
AssertNoCheckpointTrailer asserts the commit does NOT have an Entire-Checkpoint trailer.
func AssertNoShadowBranches ¶
AssertNoShadowBranches asserts that no shadow branches (entire/*) remain, excluding entire/checkpoints/*. Shadow branches should be cleaned up after commits condense session data to the metadata branch.
func CaptureArtifacts ¶
CaptureArtifacts captures git state, checkpoint metadata, entire logs, and console output to the artifact directory.
func CheckpointIDs ¶
CheckpointIDs lists all checkpoint IDs from the tree at the tip of the checkpoint branch. It parses the two-level directory structure ({prefix}/{suffix}/metadata.json) and returns the concatenated IDs.
func CheckpointPath ¶
func ForEachAgent ¶
func ForEachAgent(t *testing.T, timeout time.Duration, fn func(t *testing.T, s *RepoState, ctx context.Context))
ForEachAgent runs fn as a parallel subtest for every registered agent. It handles repo setup, concurrency gating, context timeout, and cleanup. The timeout is scaled by each agent's TimeoutMultiplier.
If RunPrompt detects a transient API error (e.g. rate limit, token refresh failure), it panics with errScenarioRestart. ForEachAgent recovers from the panic and restarts the entire scenario with a fresh repository, up to maxScenarioRestarts times. This avoids stale CLI session state from the failed attempt poisoning the retry.
func GetCheckpointTrailer ¶
GetCheckpointTrailer extracts the Entire-Checkpoint trailer value from a code commit. Returns the trimmed trailer value, or an empty string if the trailer is not present.
func Git ¶
Git runs a git command in the given directory and fails the test if it returns a non-zero exit code.
func GitOutput ¶
GitOutput runs a git command in the given directory, returns its trimmed stdout, and fails the test on error.
func GitOutputErr ¶
GitOutputErr runs a git command and returns (output, error) without failing the test. For commands expected to fail.
func NewCheckpointCommits ¶
NewCheckpointCommits returns the SHAs of commits added to the entire/checkpoints/v1 branch since the test was set up, oldest first.
func PatchSettings ¶
PatchSettings merges extra keys into .entire/settings.json.
func SetRunDir ¶
func SetRunDir(dir string)
SetRunDir overrides the artifact run directory (e.g. from E2E_ARTIFACT_DIR).
func SetupBareRemote ¶
SetupBareRemote creates a bare git repo, adds it as "origin", and pushes the initial commit. Returns the bare repo path.
func ValidateCheckpointDeep ¶
func ValidateCheckpointDeep(t *testing.T, dir string, v DeepCheckpointValidation)
ValidateCheckpointDeep performs comprehensive validation of checkpoint metadata on the checkpoint branch, including transcript JSONL validity, content hash verification, and prompt content checking.
func WaitForCheckpoint ¶
WaitForCheckpoint polls until the checkpoint branch advances from its initial state, or fails the test after timeout. Use this before any assertions that depend on the checkpoint branch (post-commit hook is async).
func WaitForCheckpointAdvanceFrom ¶
WaitForCheckpointAdvanceFrom polls until the checkpoint branch advances from the given ref, or fails the test after timeout. Use this when waiting for a second (or subsequent) checkpoint after recording the branch position.
func WaitForFileExists ¶
WaitForFileExists polls until at least one file matches the glob pattern relative to dir, or fails the test after timeout. Handles the race where an interactive agent's prompt pattern appears before file writes land on disk.
func WaitForSessionIdle ¶
WaitForSessionIdle polls the session state files in .git/entire-sessions/ until no session has phase "active", or fails the test after timeout. This handles the race where an agent's prompt pattern appears in the TUI before the turn-end hook has completed (transitioning ACTIVE → IDLE).
Types ¶
type Attribution ¶
type Attribution struct {
CalculatedAt time.Time `json:"calculated_at"`
AgentLines int `json:"agent_lines"`
HumanAdded int `json:"human_added"`
HumanModified int `json:"human_modified"`
HumanRemoved int `json:"human_removed"`
TotalCommitted int `json:"total_committed"`
AgentPercentage float64 `json:"agent_percentage"`
}
type CheckpointMetadata ¶
type CheckpointMetadata struct {
CLIVersion string `json:"cli_version"`
CheckpointID string `json:"checkpoint_id"`
Strategy string `json:"strategy"`
Branch string `json:"branch"`
CheckpointsCount int `json:"checkpoints_count"`
FilesTouched []string `json:"files_touched"`
Sessions []SessionRef `json:"sessions"`
TokenUsage TokenUsage `json:"token_usage"`
}
func ReadCheckpointMetadata ¶
func ReadCheckpointMetadata(t *testing.T, dir string, checkpointID string) CheckpointMetadata
ReadCheckpointMetadata reads the checkpoint-level metadata.json from the tip of the checkpoint branch for the given checkpoint ID.
type DeepCheckpointValidation ¶
type DeepCheckpointValidation struct {
CheckpointID string
Strategy string
FilesTouched []string
ExpectedPrompts []string
ExpectedTranscriptContent []string
}
DeepCheckpointValidation contains expected values for comprehensive checkpoint validation.
type RepoState ¶
type RepoState struct {
Agent agents.Agent
Dir string
ArtifactDir string
HeadBefore string
CheckpointBefore string
ConsoleLog *os.File
// contains filtered or unexported fields
}
RepoState holds the working state for a single test's cloned repository.
func SetupRepo ¶
SetupRepo creates a fresh git repository in a temporary directory, seeds it with an initial commit, and runs `entire enable` for the given agent. Artifact capture is registered as a cleanup function.
When E2E_KEEP_REPOS is set, the temporary directory is not cleaned up so it can be inspected after the test. A symlink in the artifact dir points to the preserved repo.
func (*RepoState) IsExternalAgent ¶ added in v0.5.1
IsExternalAgent returns true if the agent implements the ExternalAgent interface and reports itself as external.
func (*RepoState) RunPrompt ¶
func (s *RepoState) RunPrompt(t *testing.T, ctx context.Context, prompt string, opts ...agents.Option) (agents.Output, error)
RunPrompt runs an agent prompt, logs the command and output to ConsoleLog, and returns the result. If the agent reports a transient API error, it panics with errScenarioRestart to trigger a full scenario restart in ForEachAgent (see runScenario).
func (*RepoState) Send ¶
Send sends input to an interactive session and logs it to ConsoleLog. Fails the test on error.
func (*RepoState) StartSession ¶
StartSession starts an interactive session and registers it for pane capture in artifacts. Returns nil if the agent does not support interactive mode. The session is closed automatically during test cleanup.
type SessionMetadata ¶
type SessionMetadata struct {
CLIVersion string `json:"cli_version"`
CheckpointID string `json:"checkpoint_id"`
SessionID string `json:"session_id"`
Strategy string `json:"strategy"`
CreatedAt time.Time `json:"created_at"`
Branch string `json:"branch"`
Agent string `json:"agent"`
CheckpointsCount int `json:"checkpoints_count"`
FilesTouched []string `json:"files_touched"`
TokenUsage TokenUsage `json:"token_usage"`
InitialAttribution Attribution `json:"initial_attribution"`
TranscriptPath string `json:"transcript_path"`
}
func ReadSessionMetadata ¶
func ReadSessionMetadata(t *testing.T, dir string, checkpointID string, sessionIndex int) SessionMetadata
ReadSessionMetadata reads a session's metadata.json from the tip of the checkpoint branch for the given checkpoint ID and session index.
func WaitForSessionMetadata ¶
func WaitForSessionMetadata(t *testing.T, dir string, checkpointID string, sessionIndex int, timeout time.Duration) SessionMetadata
WaitForSessionMetadata polls until session metadata exists on the checkpoint branch for the given checkpoint ID and session index, then returns it. This handles the race where the checkpoint branch advances before session metadata is fully committed.