-
Notifications
You must be signed in to change notification settings - Fork 12
feat(retro): add flapping detection to retro analysis skill #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
de40314
ca31c01
6495895
30c8f64
b11fab1
f581d10
ca4b912
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,46 @@ After subagents return their findings, use your main context to: | |
| 3. Form hypotheses about root causes | ||
| 4. Decide what changes to propose and where | ||
|
|
||
| ## Flapping detection | ||
|
|
||
| Check whether the workflow exhibits fix-break oscillation. Flapping wastes agent cycles and often indicates a deeper problem (conflicting instructions, flaky tests, or an approach the agent cannot converge on). | ||
|
|
||
| ### Signals to check | ||
|
|
||
| Flapping detection applies to PR-based workflows with code/fix cycles. Derive the PR number from the originating URL, branching on its shape: | ||
|
|
||
| - If `$ORIGINATING_URL` matches `/pull/`, extract directly: `PR_NUMBER="${ORIGINATING_URL##*/}"` | ||
| - If it matches `/issues/`, check for a linked PR before skipping (issue-triggered retros routinely have downstream code dispatches once the issue reaches `ready-to-code`). Query `gh issue view "$ORIGINATING_URL" --json closedByPullRequestsReferences` and use the `repository` field on each entry to identify which repo the PR lives in. If no linked PR is found, skip flapping detection for this retro. | ||
|
|
||
| Dispatch subagents to gather the data. Substitute `<DISPATCH_REPO>`, `<REPO>`, and `<PR_NUMBER>` with the concrete values resolved in Setup before dispatching. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH — Line 135 says: "Dispatch subagents to gather the data. Substitute Every one of the three dispatch prompts (Run discovery, Review history, CI results) depends on Suggestion: Add explicit lines binding both placeholders, e.g. |
||
|
|
||
| - **Run discovery:** "List all code, fix, and review workflow runs via `gh run list --workflow=code.yml --repo <DISPATCH_REPO> --limit 100`, `gh run list --workflow=fix.yml --repo <DISPATCH_REPO> --limit 100`, and `gh run list --workflow=review.yml --repo <DISPATCH_REPO> --limit 100`. Filter to runs belonging to PR #<PR_NUMBER> by grepping each run's logs (`gh run view <RUN_ID> --repo <DISPATCH_REPO> --log | grep -i '<issue-or-branch-reference>'`). For each matching code/fix run, correlate it to a PR commit by matching the run's timestamp against the PR's commit history (no direct run-to-SHA mapping is exposed); if two candidate commits/runs fall within a short window, mark the correlation as uncertain. Then fetch that commit's changed files via `gh api repos/<REPO>/commits/<SHA>` (`.files`). Use workflow-run boundaries to define 'runs', not individual commits; a single run may produce more than one commit." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HIGH — Run discovery's The Run discovery subagent prompt filters candidate runs with Since this grep is the sole mechanism for filtering the many candidate runs down to the ones belonging to the target PR, leaving it undefined causes the filter to either match nothing (silently reporting no flapping) or be filled in ad hoc and inconsistently by whichever agent executes it. Suggestion: Add |
||
| - **Review history:** "Fetch all reviews for PR #<PR_NUMBER> via `gh api repos/<REPO>/pulls/<PR_NUMBER>/reviews --paginate`, then fetch per-review comments. Summarize the findings from each review cycle so that finding content can be compared across cycles." | ||
| - **CI results:** "For each commit correlated to a code/fix run, query `gh api repos/<REPO>/commits/<SHA>/check-runs` and report the test pass/fail results." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM — CI results subagent implicitly depends on Run discovery's output with no stated sequencing The three subagent bullets (Run discovery, Review history, CI results) are presented as a flat bulleted list, matching the style this file otherwise uses for genuinely independent, parallel-dispatchable subagents (see "Dispatch subagents for each investigation thread", lines 108-114). But "CI results" (this line) says "For each commit correlated to a code/fix run, query ... check-runs" — the correlated-commit list only exists as an output of the "Run discovery" subagent's own work (line 137's timestamp-based correlation). Nothing in the section states that Run discovery must complete before CI results is dispatched, or that Run discovery's resulting SHA list must be fed into the CI results prompt. Suggestion: State explicitly that Run discovery must run first and that its correlated commit SHAs should be substituted into the CI results subagent prompt, rather than presenting all three bullets as independently dispatchable. |
||
|
|
||
| Then check for these patterns: | ||
|
|
||
| 1. **File oscillation:** the same file was changed in two or more consecutive runs, and the changes reverse each other (lines added in run N were removed in run N+1, or vice versa). | ||
| 2. **Test result flipping:** a test that passed after run N fails after run N+1, then passes again after run N+2, and the flapping test covers a file the agent modified in the same run. Tests that flip independently of agent changes may be pre-existing flaky tests, not agent-caused oscillation. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM — Test-result-flipping signal requires a test-to-file coverage mapping that no described data source provides Pattern 2 requires knowing that "the flapping test covers a file the agent modified in the same run" to distinguish real agent-caused oscillation from pre-existing flaky tests. But the data-gathering subagent prompt only collects changed-file lists (from code/fix runs) and check-run pass/fail status per commit (via Suggestion: Either specify a concrete heuristic (e.g., match test file paths whose names substring-match a changed file's basename, or parse coverage-report artifacts if one exists), or relax the pattern to something checkable from the collected data (e.g., "a test flips status across 3+ runs; treat as higher-confidence flapping if a related-by-name file also changed in the same runs") and note the strict per-file-coverage version as a future refinement once that data source exists. |
||
| 3. **Cycle count:** more than 2 review-fix cycles on the same PR without convergence (the review keeps requesting changes on the same or alternating findings, e.g. a fix for one issue reintroducing a previously resolved one counts as flapping too). This threshold is a starting point; see [flapping-convergence.md](https://github.com/fullsend-ai/fullsend/blob/main/docs/problems/flapping-convergence.md) for open questions on making it configurable per repo/task type. | ||
|
|
||
| ### When flapping is detected | ||
|
|
||
| Include a proposal with these specifics: | ||
|
|
||
| - **target_repo:** the repo where the fix should land (see Localization guidance below) | ||
| - **title:** Start with "Flapping detected:" followed by what oscillated | ||
| - **what_happened:** List each cycle with the run IDs, which files changed, and how the changes reversed | ||
| - **what_could_go_better:** Identify what might be causing the loop (conflicting review criteria, flaky test, ambiguous instructions) | ||
| - **proposed_change:** Suggest a concrete intervention (clarify the conflicting instruction, fix the flaky test, add a convergence guard) | ||
| - **validation_criteria:** Define a measurable outcome tied to the specific pattern. For example: "The next 2 fix cycles touching <file> should not re-introduce the change reverted in run N+1." | ||
|
|
||
| ### When NOT to flag | ||
|
|
||
| - A single rework cycle (review requested changes, fix addressed them, review approved) is normal, not flapping. | ||
| - Different files changing across runs is normal iteration, not oscillation. | ||
| - Only flag when you see the same changes being applied and reversed repeatedly. | ||
|
|
||
|
Comment on lines
+124
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Protected skills/ file modified This PR modifies a protected governance/infrastructure path (skills/retro-analysis/SKILL.md), so it must not be auto-approved and requires explicit human review controls. Without enforcing this, governance-critical content can change without appropriate oversight. Agent Prompt
|
||
| ## Before proposing: check for existing issues | ||
|
|
||
| **This step is mandatory.** Before including any proposal in your output, verify that no open issue already covers the same improvement. The retro agent is the primary source of systemic proposals — without this check, repeated runs produce duplicate issues that waste human triage time. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MEDIUM — No selection rule when
closedByPullRequestsReferencesreturns multiple linked-PR entriesFor issue URLs, this line says to query
gh issue view "$ORIGINATING_URL" --json closedByPullRequestsReferencesand "use therepositoryfield on each entry to identify which repo the PR lives in" (plural "each entry"), but an issue can be closed by more than one PR. The text never states which entry's PR number/repo to use when multiple are returned, unlike the file's general convention of explicitly handling ambiguity elsewhere (e.g. the timestamp-window uncertainty note in the Run discovery prompt).Suggestion: Add a tie-breaking rule — e.g. "if multiple PRs are linked, prefer the one in
$REPO_FULL_NAME; otherwise use the most recently updated entry and note the ambiguity in the retro summary" or "run flapping detection against each linked PR separately."