Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ff76452
fix(autofix): make the brake's BLOCKED handoff a first-class round ou…
wenshao Aug 17, 2026
3d2a046
Merge branch 'main' into fix/autofix-handoff-output-contract
qwen-code-dev-bot Aug 17, 2026
ed1ea96
fix(autofix): align the handoff outcome's consumers and pins with its…
qwen-code-dev-bot Aug 17, 2026
5c766ff
fix(autofix): classify a no-commit handoff before the gate's structur…
qwen-code-dev-bot Aug 17, 2026
e5a3106
fix(autofix): reject a no-commit handoff written over a dirty workspa…
qwen-code-dev-bot Aug 17, 2026
c0f1c75
fix(autofix): report a dirty-handoff rejection honestly, not as a fai…
qwen-code-dev-bot Aug 18, 2026
57664b9
Merge branch 'main' into fix/autofix-handoff-output-contract
qwen-code-dev-bot Aug 18, 2026
ef859bd
fix(autofix): reject a handoff written beside a round commit, non-ret…
qwen-code-dev-bot Aug 18, 2026
d8d4845
fix(ci): classify the committed handoff shape as its own non-retryabl…
wenshao Aug 18, 2026
5edd7f8
Merge remote-tracking branch 'wenshao/fix/autofix-handoff-output-cont…
wenshao Aug 18, 2026
9901ba8
fix(ci): count committed-handoff rounds in the milestone census rejec…
qwen-code-dev-bot Aug 18, 2026
8972874
fix(autofix): publish brake violations green and preserve handoffs ac…
qwen-code-dev-bot Aug 18, 2026
f1f2d17
test(ci): give four subprocess-heavy replays explicit budgets
wenshao Aug 19, 2026
a4fa22f
Merge remote-tracking branch 'origin/main' into fix/autofix-handoff-o…
wenshao Aug 19, 2026
cc3a05d
fix(ci): mirror the handoff outcome consumers into the recovery clone…
qwen-code-dev-bot Aug 20, 2026
955a32c
Merge remote-tracking branch 'origin/main' into fix/autofix-handoff-o…
wenshao Aug 20, 2026
8fb2ed0
Merge remote-tracking branch 'origin/main' into fix/autofix-handoff-o…
wenshao Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions .github/scripts/run-autofix-review-verification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,62 @@ if [[ -f "${WORKDIR}/failure.md" ]]; then
exit 1
fi

# A handoff claims the round changed NOTHING — dirt beside it is a
# brake-violating partial patch (otherwise reported as a clean stop and
# discarded silently with the runner), and untracked leftovers would trip
# the NEXT round's dirty assert on the persistent pool. The ref-level
# commit diff below is blind to both. Non-retryable like failure.md+dirty
# above (a retryable rejection would engage the repair pass, which deletes
# handoff.md and may commit against the brake), but under its OWN outcome:
# outcome=failed would make the report step dress the rejection as a
# failed FIX ("could not produce a passing fix", or a stale-base retry
# promise) when no fix existed — the report step gives this shape its own
# honest headline.
if [[ -s "${WORKDIR}/handoff.md" && -n "$(git status --porcelain)" ]]; then
Comment thread
wenshao marked this conversation as resolved.
Resolved
echo "❌ Agent wrote handoff.md after leaving a dirty workspace:"
Comment thread
wenshao marked this conversation as resolved.
Resolved
git status --short
sed 's/::/;;/g' "${WORKDIR}/handoff.md"
echo "outcome=dirty_handoff" >> "${GITHUB_OUTPUT}"
exit 1
fi

# The committed sibling of the brake violation above: the round HAS a commit
# beside handoff.md. Judged by dirt alone it slips both guards — the dirty
# check sees a clean tree, and the no-commit handoff branch below requires
# an unchanged ref — so it would reach the structural checks, where
# reject_fix defaults to retryable and the repair pass deletes
# handoff.md and may commit AGAIN against the brake's stop. Non-retryable
# under its OWN outcome: a commit DID happen, so the dirty-handoff headline
# claiming nothing was committed would misreport it. Same reasoning as the
# dirty guard otherwise.
if [[ -s "${WORKDIR}/handoff.md" && "${committed_rc:-0}" -eq 1 ]]; then
echo "❌ Agent wrote handoff.md but the round HAS a commit — a brake violation:"
git log --oneline "origin/${BRANCH}..${BRANCH}"
sed 's/::/;;/g' "${WORKDIR}/handoff.md"
echo "outcome=committed_handoff" >> "${GITHUB_OUTPUT}"
exit 1
fi

# No-commit brake handoff, classified BEFORE the structural checks below:
# those judge the PR's OWN diff (core rebuild, schema freshness, contracts)
# and reject_fix on failure, and the growth brake fires on exactly the red
# PRs whose diff trips them. A compliant handoff commits nothing, so
# running the checks first would reclassify it as a retryable failure —
# the repair pass would delete handoff.md and commit against the brake's
# stop. A handoff claims nothing (acted=false, deferred to a human), so
# the checks' false-no-action rationale does not apply. failure.md
# coexistence keeps the failed classification via the exits above.
if git diff --quiet "origin/${BRANCH}...${BRANCH}" \
&& [[ -s "${WORKDIR}/handoff.md" ]]; then
Comment thread
wenshao marked this conversation as resolved.
Resolved
Comment thread
wenshao marked this conversation as resolved.
Resolved
echo "🤝 Branch unchanged with a handoff — the agent stopped under instruction and deferred this item to a human:"
# Agent-written content: a line-start `::` would be parsed as a workflow
# command (::error::, ::add-mask::), the same reason 'Show run artifacts'
# neutralizes these files.
sed 's/::/;;/g' "${WORKDIR}/handoff.md"
echo "outcome=handoff" >> "${GITHUB_OUTPUT}"
exit 0
fi

# Convention: hooks are severed at EVERY host checkout of the PR
# branch (no secret sits in this step's env, but a post-checkout
# hook still runs branch code on the host).
Expand Down Expand Up @@ -337,7 +393,8 @@ fi
# no-op/unchanged return: on a stale-schema PR the agent can wrongly
# write no-action.md, and without this the no-op path would report the
# feedback as evaluated (acted=false) while CI stays red — the exact bug
# this PR fixes. So it runs on EVERY path. The gate is shared with the
# this PR fixes. So it runs on every path but the no-commit handoff,
# which claims nothing and exits above. The gate is shared with the
# issue-fix verify step (rationale + the generator crash guard live in
# the script); the write is on a tracked file compared by `git status`,
# not the commit-level no-op git-diff below, and it is restored on
Expand All @@ -354,7 +411,8 @@ run_check_no_ab 'cross-package contract verification failed' \
assert_verification_tree

if git diff --quiet "origin/${BRANCH}...${BRANCH}"; then
Comment thread
wenshao marked this conversation as resolved.
Resolved
# No new commit. That is only legitimate as a deliberate no-action.
# No new commit. That is only legitimate as a deliberate no-action; the
# no-commit handoff was classified before the structural checks above.
if [[ -s "${WORKDIR}/no-action.md" ]]; then
echo "🟰 No action needed:"
cat "${WORKDIR}/no-action.md"
Expand Down
92 changes: 80 additions & 12 deletions .github/workflows/qwen-autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6090,7 +6090,19 @@ jobs:
echo "verified_head=${VERIFIED_HEAD}" >> "${GITHUB_OUTPUT}"
fi
case "${OUTCOME}" in
fixed|noop) ;;
# handoff and the two brake-violation rejections are
# deliberate, PUBLISHED verdicts, not failures: the agent
# stopped under instruction (the growth-brake BLOCKED stop)
# and the 'Report dry-run / failure' step posts the honest
# headline, the handoff note, and the eval marker for all
# three. Failing the job here would leave a red
# review-address check that completes AFTER the marker's
# ts=NEWEST — the next scan's N_FAILED_CHECKS includes this
# workflow's own review-address checks, so it would count
# the round's own rejection as NEW feedback and re-dispatch
# the very item the headline promises not to retry, turning
# one deliberate stop into a self-feeding loop.
fixed|noop|handoff|dirty_handoff|committed_handoff) ;;
Comment thread
wenshao marked this conversation as resolved.
Resolved
*) exit 1 ;;
esac

Expand Down Expand Up @@ -6752,15 +6764,21 @@ jobs:
# lines can embed provider error text.
N_TIMEOUT="$(grep -c 'AutoFix ran out of time before finishing' <<< "${WIN_HEADS}" || true)"
# Both wordings of the gate-rejection handoff, past and
# present — the census must not silently zero when the
# headline is reworded.
N_REJECTED="$(grep -cE 'Could not (address the latest feedback|produce a passing fix)' <<< "${WIN_HEADS}" || true)"
# present, plus both handoff brake violations, dirty and
# committed (the gate rejects each under its own outcome)
# — the census must not silently zero when the headline is
# reworded.
N_REJECTED="$(grep -cE 'Could not (address the latest feedback|produce a passing fix)|wrote a handoff but (left a dirty workspace|the round HAS a commit)' <<< "${WIN_HEADS}" || true)"
# The brake's deliberate stop — its own bucket, not the
# residual crash bucket: it tells the maintainer a human
# decision is already waiting on this PR.
N_HANDOFF="$(grep -c 'deferred this item to a human under instruction' <<< "${WIN_HEADS}" || true)"
# Every other outcome (crash, model error, gate error,
# infra) lands in a residual bucket: a window that burned
# 80% of its budget on crashes must be the LOUDEST line in
# the digest, not four zeros quieter than a healthy one.
N_TOTAL=$(( $(grep -c . <<< "${WIN_HEADS}" || true) + 1 ))
N_OTHER=$(( N_TOTAL - N_PUSHED - N_NOOP - N_TIMEOUT - N_REJECTED ))
N_OTHER=$(( N_TOTAL - N_PUSHED - N_NOOP - N_TIMEOUT - N_REJECTED - N_HANDOFF ))
(( N_OTHER < 0 )) && N_OTHER=0
# Base updates carry their own marker with no win= field;
# their window is recovered by timestamp (the window key IS
Expand All @@ -6777,7 +6795,7 @@ jobs:
WIN_DESC='since the PR opened (no counting window yet)'
WIN_DESC_ZH='自 PR 创建以来(尚无计数窗口)'
fi
if gh pr comment "${PR}" --repo "${REPO}" --body "$(printf '📊 Takeover milestone — round %s/%s, %s. Census: %s pushed fix(es), %s no-change review(s), %s timeout(s), %s rejected attempt(s), %s other round(s) (crash / model error / gate error / infra), %s base update(s).\n\nThis many rounds deserves a human look. Options: keep going (fine — nothing changes), split or reduce the PR if rounds keep accumulating, or release takeover (remove the `%s` label or comment `%s stop`). Management continues unchanged unless you act.\n\n<details>\n<summary>中文说明</summary>\n\n📊 接管里程碑 —— 第 %s/%s 轮(%s)。统计:推送修复 %s 次、审阅无需改动 %s 次、超时 %s 次、验证拒绝 %s 次、其他轮次(崩溃/模型错误/门错误/infra)%s 次、base 更新 %s 次。\n\n轮次到这个量值得人工看一眼。可选:继续(无需操作);若轮次持续累积,考虑拆分或缩减 PR;或释放接管(移除 `%s` 标签或评论 `%s stop`)。不操作则托管照常继续。\n\n</details>\n\n<!-- autofix-milestone round=%s win=%s -->' "${NEXT_ROUND}" "${MAX_ROUNDS}" "${WIN_DESC}" "${N_PUSHED}" "${N_NOOP}" "${N_TIMEOUT}" "${N_REJECTED}" "${N_OTHER}" "${N_BASE}" "${TAKEOVER_LABEL}" "${TAKEOVER_COMMAND}" "${NEXT_ROUND}" "${MAX_ROUNDS}" "${WIN_DESC_ZH}" "${N_PUSHED}" "${N_NOOP}" "${N_TIMEOUT}" "${N_REJECTED}" "${N_OTHER}" "${N_BASE}" "${TAKEOVER_LABEL}" "${TAKEOVER_COMMAND}" "${NEXT_ROUND}" "${WINDOW:-none}")"; then
if gh pr comment "${PR}" --repo "${REPO}" --body "$(printf '📊 Takeover milestone — round %s/%s, %s. Census: %s pushed fix(es), %s no-change review(s), %s timeout(s), %s rejected attempt(s), %s deliberate stop(s) under instruction (deferred to a human), %s other round(s) (crash / model error / gate error / infra), %s base update(s).\n\nThis many rounds deserves a human look. Options: keep going (fine — nothing changes), split or reduce the PR if rounds keep accumulating, or release takeover (remove the `%s` label or comment `%s stop`). Management continues unchanged unless you act.\n\n<details>\n<summary>中文说明</summary>\n\n📊 接管里程碑 —— 第 %s/%s 轮(%s)。统计:推送修复 %s 次、审阅无需改动 %s 次、超时 %s 次、验证拒绝 %s 次、按指示有意停止(移交人工)%s 次、其他轮次(崩溃/模型错误/门错误/infra)%s 次、base 更新 %s 次。\n\n轮次到这个量值得人工看一眼。可选:继续(无需操作);若轮次持续累积,考虑拆分或缩减 PR;或释放接管(移除 `%s` 标签或评论 `%s stop`)。不操作则托管照常继续。\n\n</details>\n\n<!-- autofix-milestone round=%s win=%s -->' "${NEXT_ROUND}" "${MAX_ROUNDS}" "${WIN_DESC}" "${N_PUSHED}" "${N_NOOP}" "${N_TIMEOUT}" "${N_REJECTED}" "${N_HANDOFF}" "${N_OTHER}" "${N_BASE}" "${TAKEOVER_LABEL}" "${TAKEOVER_COMMAND}" "${NEXT_ROUND}" "${MAX_ROUNDS}" "${WIN_DESC_ZH}" "${N_PUSHED}" "${N_NOOP}" "${N_TIMEOUT}" "${N_REJECTED}" "${N_HANDOFF}" "${N_OTHER}" "${N_BASE}" "${TAKEOVER_LABEL}" "${TAKEOVER_COMMAND}" "${NEXT_ROUND}" "${WINDOW:-none}")"; then
echo "📊 milestone digest posted on #${PR} (round ${NEXT_ROUND})"
else
echo "::warning::milestone digest failed to post on PR #${PR}; the round report above already landed"
Expand All @@ -6802,7 +6820,7 @@ jobs:

- name: 'Report dry-run / failure'
if: |-
${{ always() && (needs.route.outputs.dry_run == 'true' || failure() || cancelled()) }}
${{ always() && (needs.route.outputs.dry_run == 'true' || failure() || cancelled() || steps.final_verify.outputs.outcome == 'handoff' || steps.final_verify.outputs.outcome == 'dirty_handoff' || steps.final_verify.outputs.outcome == 'committed_handoff') }}
env:
OUTCOME: '${{ steps.final_verify.outputs.outcome }}'
COMMITTED: '${{ steps.final_verify.outputs.committed }}'
Expand Down Expand Up @@ -6891,7 +6909,15 @@ jobs:
# consumes a round.
POST_HANDOFF=false
if [[ "${DRY_RUN}" != "true" && "${STALE:-}" != "true" && -n "${GITHUB_TOKEN:-}" && "${OUTCOME:-unknown}" != "fixed" && "${OUTCOME:-unknown}" != "noop" ]]; then
if [[ "${OUTCOME:-unknown}" == "failed" || "${JOB_STATUS:-}" != "success" ]]; then
# handoff rounds end with a SUCCESS job status (a deliberate
# verdict), so they must trigger on the outcome itself — without
# this clause nothing would post and the loop would go silent on
# exactly the rounds that most need a visible human handoff. The
# two brake-violation rejections are green, published verdicts
# for the same reason (finalize passes them so their own check
# cannot re-select the PR), so they key on the outcome the same
# way.
if [[ "${OUTCOME:-unknown}" == "failed" || "${OUTCOME:-unknown}" == "handoff" || "${OUTCOME:-unknown}" == "dirty_handoff" || "${OUTCOME:-unknown}" == "committed_handoff" || "${JOB_STATUS:-}" != "success" ]]; then
POST_HANDOFF=true
fi
fi
Expand Down Expand Up @@ -7065,6 +7091,44 @@ jobs:
MARK_ROUND="${MAX_ROUNDS}"
fi
else
if [[ "${OUTCOME:-}" == 'handoff' ]]; then
# A deliberate stop, not a failed fix: the agent stopped
# under instruction and deferred the item to a human. No
# stale-base retry (there is no fix to re-attempt) and the
# headline says what actually happened — the old
# "could not produce a passing fix" wording reported the
# brake's decision as a failure and buried the handoff.
# Wording guard: no "🤖 AutoFix stopped" prefix — the fleet
# shepherd's REASON regex reads that as a TERMINAL stop
# reason, and this stop is transient (the loop stays
# engaged); the shepherd contract test pins the distinction.
HEADLINE="🤖 AutoFix deferred this item to a human under instruction (round ${MARK_ROUND}/${MAX_ROUNDS}) — the agent's handoff note below names the decision and the options. The loop stays engaged and still picks up new feedback and base conflicts, but will not retry this item on its own."
elif [[ "${OUTCOME:-}" == 'dirty_handoff' ]]; then
# A brake VIOLATION, not a failed fix: the agent stopped
# under instruction but left a dirty workspace, so the
# gate rejected the round under its own outcome (never
# retryable — a repair pass would commit against the
# brake). No stale-base probe: there is no fix to
# re-attempt, and the probe's update-branch would merge
# main for a retry that must not happen. The watermark
# still advances (the feedback WAS read), so the item
# hands to a human without any automatic-retry promise.
# Wording guard: no "🤖 AutoFix stopped" prefix, same
# reason as the handoff branch above.
HEADLINE="🤖 AutoFix rejected this round — the agent wrote a handoff but left a dirty workspace, violating the brake's commit-nothing stop (round ${MARK_ROUND}/${MAX_ROUNDS}). Nothing was committed; the uncommitted work was discarded with the runner. The handoff note below names what the agent stopped on, and the run log lists the dirty files. The loop stays engaged and still picks up new feedback and base conflicts, but will not retry this item on its own."
elif [[ "${OUTCOME:-}" == 'committed_handoff' ]]; then
# The committed sibling of the dirty-handoff violation:
# the round HAS a commit beside handoff.md. The gate
# rejected it non-retryably under its own outcome, so the
# repair pass never engages and the handoff note survives
# to be posted. The runner-side commit was NOT pushed —
# only 'Push and report' (fixed/noop) publishes — so it is
# discarded with the runner, the same committed_rc the
# failure.md "commit discarded" wording keys on.
# Wording guard: no "🤖 AutoFix stopped" prefix, same
# reason as the handoff branch above.
HEADLINE="🤖 AutoFix rejected this round — the agent wrote a handoff but the round HAS a commit, violating the brake's commit-nothing stop (round ${MARK_ROUND}/${MAX_ROUNDS}). The commit was NOT pushed and is discarded with the runner; the run log lists it. The handoff note below names what the agent stopped on. The loop stays engaged and still picks up new feedback and base conflicts, but will not retry this item on its own."
else
# The gate ran and rejected the agent's fix (a build/test
# failure). Before handing to a human, check whether the PR is
# merely BEHIND main: a build that fails on something main
Expand Down Expand Up @@ -7134,6 +7198,7 @@ jobs:
fi
HEADLINE="🤖 Could not produce a passing fix for this feedback (round ${MARK_ROUND}/${MAX_ROUNDS})${GATE_CLAUSE}. This item now needs a human; the loop stays engaged and still picks up new feedback and base conflicts, but will not retry this item on its own."
fi
fi
fi
elif [[ "${PREPARE_OUTCOME}" != 'success' && "${PREPARE_OUTCOME}" != 'failure' ]]; then
# NEWEST is empty because Prepare never RAN TO A VERDICT — an
Expand Down Expand Up @@ -7236,7 +7301,7 @@ jobs:
done <<< "${PRIOR_HEADS}"
if [[ "${CONSEC_FAIL}" -ge "${CONSECUTIVE_FAILURE_CAP}" ]]; then
MARK_ROUND="${MAX_ROUNDS}"
HEADLINE="🤖 AutoFix stopped after ${CONSEC_FAIL} consecutive rounds that failed to push anything (timeouts and/or gate rejections). Retrying at the same per-round budget is not converging — this usually means the PR is too large or conflicts with a fast-moving \`main\`. A human should rebase, split, or reduce it, then comment \`${RETRY_COMMAND}\` to re-arm. Until then future scans will skip this PR."
HEADLINE="🤖 AutoFix stopped after ${CONSEC_FAIL} consecutive rounds that pushed nothing (failed rounds, timeouts, gate rejections, or stops under instruction). Retrying at the same per-round budget is not converging — this usually means the PR is too large or conflicts with a fast-moving \`main\`. A human should rebase, split, or reduce it, then comment \`${RETRY_COMMAND}\` to re-arm. Until then future scans will skip this PR."
Comment thread
wenshao marked this conversation as resolved.
Resolved
Comment thread
wenshao marked this conversation as resolved.
Resolved
fi
# CUMULATIVE timeout breaker — the sibling of the consecutive
# one above, for the failure shape it cannot see: timeouts
Expand Down Expand Up @@ -7470,9 +7535,12 @@ jobs:
if [[ "${ROUND_DISPLAY}" =~ ^[0-9]+$ ]]; then
ROUND_DISPLAY="$((ROUND_DISPLAY + 1))"
fi
# 'fixed'/'noop' are the two outcomes that published a round report;
# anything else means the round stopped before publishing one.
if [[ "${OUTCOME:-}" == 'fixed' || "${OUTCOME:-}" == 'noop' ]]; then
# 'fixed'/'noop'/'handoff'/'dirty_handoff'/'committed_handoff' are
# the outcomes that published a round report — handoff and the two
# brake-violation rejections post their note + eval marker from the
# report step; anything else means the round stopped before
# publishing one.
if [[ "${OUTCOME:-}" == 'fixed' || "${OUTCOME:-}" == 'noop' || "${OUTCOME:-}" == 'handoff' || "${OUTCOME:-}" == 'dirty_handoff' || "${OUTCOME:-}" == 'committed_handoff' ]]; then
EN="$(printf '✅ **AutoFix round %s finished** — [view run](%s). See this round'"'"'s report below.' "${ROUND_DISPLAY}" "${RUN_URL}")"
ZH="$(printf '✅ **AutoFix 第 %s 轮已完成** —— [查看运行](%s)。本轮报告见下方。' "${ROUND_DISPLAY}" "${RUN_URL}")"
else
Expand Down
Loading