Skip to content

Fix e2e flakes in opencode lifecycle and test assertions#971

Closed
pfleidi wants to merge 15 commits intomainfrom
fix/e2e-opencode-flakes
Closed

Fix e2e flakes in opencode lifecycle and test assertions#971
pfleidi wants to merge 15 commits intomainfrom
fix/e2e-opencode-flakes

Conversation

@pfleidi
Copy link
Copy Markdown
Contributor

@pfleidi pfleidi commented Apr 16, 2026

Summary

  • harden OpenCode lifecycle hook emission by adding robust turn-start fallback and deduplicated turn-end handling, with regression coverage for generated plugin content
  • exclude internal runtime artifacts under .opencode/ and .entire/ from checkpoint file tracking while preserving user-managed opencode.json in files_touched
  • stabilize flaky E2E expectations by increasing cursor prompt timeout, allowing ±1 attribution-line variance for mixed commits, and making subagent commit flow wait on file creation while keeping a single-prompt scenario

Verification

  • go build ./...
  • go vet ./...
  • mise run check
  • targeted E2E reruns for failing cases (opencode, cursor-cli, claude-code)

Note

Medium Risk
Adjusts OpenCode hook emission and file-attribution filtering logic used for checkpointing; mistakes could cause missing/duplicate lifecycle hooks or incorrect files_touched/attribution in edge cases.

Overview
Hardens the OpenCode plugin’s turn lifecycle signaling by adding a maybeStartTurn helper, a message.updated fallback for missing/late message.part.updated events, and per-session tracking to dedupe/guard turn-end on idle events.

Tightens checkpoint file attribution by introducing isInternalTrackingPath and filtering .entire/ and .opencode/ runtime artifacts out of FilesTouched/fallback committed-file lists, while keeping user project files (e.g., opencode.json) eligible.

Stabilizes tests by adding regression coverage for the generated OpenCode plugin guards, excluding internal paths in unit tests, and relaxing/flaking-proofing E2E assertions (±1 line attribution tolerance, longer timeouts, and waiting/staging only expected files in subagent flows).

Reviewed by Cursor Bugbot for commit 21172e2. Configure here.

pfleidi added 8 commits April 16, 2026 13:25
Entire-Checkpoint: 3ab3686c3abf
Entire-Checkpoint: b620f59b4502
…FromLiveTranscript

Restructure the normalization loop to compute the relative path first,
then filter and append once, instead of repeating the isInternalTrackingPath
check and append in both if/else-if branches.

Entire-Checkpoint: fd68e2e3a47f
@pfleidi pfleidi requested a review from a team as a code owner April 16, 2026 22:32
Copilot AI review requested due to automatic review settings April 16, 2026 22:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens OpenCode hook lifecycle handling and stabilizes E2E tests by reducing timing sensitivity and by excluding internal runtime artifacts from file attribution/tracking in the manual-commit strategy.

Changes:

  • Add more robust OpenCode turn lifecycle handling (turn-start fallback + turn-end dedupe) and regression assertions for generated plugin content.
  • Exclude .entire/ and .opencode/ runtime artifacts from files_touched / committed-file fallback logic while preserving user-managed opencode.json.
  • Stabilize flaky E2E tests via longer prompt timeouts, tolerance for minor attribution variance, and waiting for file creation before committing.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
e2e/tests/subagent_commit_flow_test.go Waits for file creation before staging/committing and narrows git add scope.
e2e/tests/edge_cases_test.go Increases prompt timeout for two prompts to reduce flakiness.
e2e/tests/attribution_test.go Allows ±1 line variance in mixed attribution assertions.
cmd/entire/cli/strategy/manual_commit_test.go Expands tests to cover .opencode/ exclusion and mergeFilesTouched filtering.
cmd/entire/cli/strategy/manual_commit_hooks.go Filters internal tracking paths from FilesTouched and transcript-derived modified files.
cmd/entire/cli/strategy/manual_commit_git.go Filters internal tracking paths during FilesTouched merge/deduping.
cmd/entire/cli/strategy/manual_commit_condensation.go Uses shared internal-path filter when excluding metadata from committed-file fallback.
cmd/entire/cli/strategy/common.go Introduces isInternalTrackingPath for .entire/ + .opencode/ runtime/config paths.
cmd/entire/cli/agent/opencode/hooks_test.go Adds regression test asserting lifecycle guard code is present in generated plugin.
cmd/entire/cli/agent/opencode/entire_plugin.ts Implements open-turn tracking, turn-start fallback, and turn-end dedupe/cleanup.

Comment thread cmd/entire/cli/agent/opencode/entire_plugin.ts Outdated
Comment thread e2e/tests/edge_cases_test.go
@pfleidi
Copy link
Copy Markdown
Contributor Author

pfleidi commented Apr 16, 2026

Bugbot run

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 21172e2. Configure here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread cmd/entire/cli/strategy/manual_commit_condensation.go Outdated
Comment thread cmd/entire/cli/strategy/manual_commit_test.go
@pfleidi pfleidi marked this pull request as draft April 17, 2026 01:06
@pfleidi pfleidi closed this Apr 17, 2026
@pfleidi pfleidi deleted the fix/e2e-opencode-flakes branch April 17, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants