Rectify: Merge Gate Diagnosis Context Loss#3893
Merged
Trecek merged 6 commits intoJun 8, 2026
Merged
Conversation
Previously diagnose_merge_gate fell through to failure_subtype=unknown and hardcoded failure_type=test when called with empty test output, which misclassified pre-test failures (dirty_tree, rebase, etc.) as test failures and created an unwinnable flake-suspected retry loop. - Add failed_step parameter to diagnose_merge_gate signature. - Add exhaustive dispatch on _PRE_TEST_STEPS / _TEST_STEPS / backward compat branches. - Rename _classify_subtype to _classify_test_subtype with early-return for empty input. - Change hardcoded "failure_type = test" literal to f-string interpolation; emit failure_type in Structured Output section. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Update the three pipeline recipes (remediation, implementation, implementation-groups) to capture result.failed_step on the merge step and pass it through to diagnose_merge_gate. The diagnose_merge_gate run_python call now receives failed_step from context, and the field is added to optional_context_refs so it is not required at the iteration boundary. Also add failed_step to the diagnose_merge_gate callable contract in skill_contracts.yaml so the rules_callable_inputs validation accepts recipe with: blocks that pass it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a new semantic rule that fires when a merge_worktree step routes on result.failed_step to a chain reaching diagnose_merge_gate, but the merge_worktree capture block does not include result.failed_step. Without this capture, diagnose_merge_gate receives no failed_step argument and falls back to failure_type=test, misclassifying pre-test failures (dirty_tree, rebase, etc.) as test failures and creating an unwinnable retry loop. The rule uses BFS from each route target to find the diagnose_merge_gate step (parallel to the existing _find_resolve_failures_step helper), then checks the merge_worktree capture block for any field whose from_ references failed_step. Add tests covering: rule fires when capture is missing, rule does not fire when capture is present, and rule does not fire on the three fixed pipeline recipes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Update pre-compiled JSON for remediation, implementation, and implementation-groups recipes to match the YAML source after adding merge_failed_step capture and failed_step input to diagnose_merge_gate. Generated by `task regen-contracts && task compile-recipes`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ed_step capture The merge-failed-step-not-captured rule's BFS traversed through intermediate merge_worktree steps that already capture result.failed_step, causing false positives on pre_remediation_merge which routes through the main merge step (that independently provides context). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When failed_step is non-empty but not in _PRE_TEST_STEPS or _TEST_STEPS, emit subtype="unrecognized_step" instead of silently falling through to content-based test classification. This prevents upstream coding errors or newly added steps from being mislabeled as test failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
diagnose_merge_gateclassifies failure subtype from test output strings alone, with no knowledge of whichmerge_worktreefailure step triggered the diagnosis. When called after adirty_treefailure (where no tests ran), it receives empty strings, falls through tofailure_subtype = unknown, and hardcodesfailure_type = test. This misleadsresolve-failuresinto treating a worktree-hygiene problem as a flaky test, creating an unwinnable loop.The architectural weakness: the recipe routing layer consumes
failed_stepfor branching but never captures it into context, so downstream classification functions must re-derive failure category from output content — an inherently lossy operation when some failure modes produce no output.The immunity approach: make
diagnose_merge_gateaccept the failure step as a typed parameter, capture it in recipe context, add a semantic rule to enforce capture, and use exhaustive dispatch so that pre-test failures are correctly classified without consulting empty test output.Implementation Plan
Plan file:
/home/talon/projects/autoskillit-runs/remediation-20260607-163912-937216/.autoskillit/temp/rectify/rectify_merge_gate_diagnosis_context_loss_2026-06-07_164500.mdCloses #3890
🤖 Generated with Claude Code via AutoSkillit
Token Usage Summary
* Step used a non-Anthropic provider; caching behavior may differ.
Token Efficiency
Model Usage Breakdown