Skip to content
82 changes: 72 additions & 10 deletions .github/workflows/qwen-autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ env:
# changes, failed checks, and base conflicts may drive code changes;
# lower-severity feedback is recorded and left open.
CRITICAL_ONLY_AFTER_ROUND: '5'
# Per-author tail budget inside Critical-only mode. An account is an
# ACCOUNTABILITY unit, not a throttle: a human login can host an automated
# reviewer loop with the exact regeneration property the review bot has
# (feedback re-generated after every push, at zero marginal cost). So the
# brake keys on measured regeneration, not identity: every source gets a
# bounded number of untagged feedback batches per counting window once
# Critical-only engages — the review bot's budget is zero (all deferred),
# a human's is this many CONSUMED batches. Past it, continuing requires
# one conscious act (**[Critical]**, a Request changes review, or /retry),
# which is precisely what separates intent from automation.
CRITICAL_ONLY_HUMAN_BATCHES: '2'
# An auth/access model error (401/402/403, "no access"/"does not exist")
# never self-heals - only a maintainer can fix the key - and every retry
# costs an agent run AND a PR comment. Cap those attempts far below
Expand Down Expand Up @@ -2928,6 +2939,47 @@ jobs:
if [[ "${ROUND}" -ge "${CRITICAL_ONLY_AFTER_ROUND}" ]]; then
CRITICAL_ONLY='true'
fi
# Which trusted humans have exhausted their per-window regular
# feedback budget (see CRITICAL_ONLY_HUMAN_BATCHES). A batch is
# COUNTED only when a Critical-only round actually consumed it:
# feedback items are bucketed into the (prev marker ts, marker ts]
# span that evaluated them, spans are kept only for markers that
# ran in Critical-only territory (acted rounds numbered past the
# threshold, no-change rounds at it), and an author needs >= K
# distinct consumed spans to land here. Fresh, not-yet-evaluated
# feedback never counts against its own author, and everything is
# window-scoped so a /retry resets the budget with the window.
OVER_BUDGET_AUTHORS='[]'
if [[ "${CRITICAL_ONLY}" == "true" ]]; then
OVER_BUDGET_AUTHORS="$(jq -n \
--arg key "${LIVE_REARM_KEY}" --arg ab "${AUTOFIX_BOT}" --arg rb "${REVIEW_BOT}" \
--argjson trust "${TRUSTED_ASSOC}" \
--argjson r5 "${CRITICAL_ONLY_AFTER_ROUND}" \
--argjson k "${CRITICAL_ONLY_HUMAN_BATCHES}" \
--slurpfile rv "${WORKDIR}/rv.json" --slurpfile rc "${WORKDIR}/rc.json" --slurpfile ic "${WORKDIR}/ic.json" '
([ ($ic | add)[] | select((.user.login // "") == $ab) | . as $c | ($c.body // "")
| [ scan("<!-- autofix-eval ts=([^ ]+) acted=([^ ]+) round=([0-9]+)(?: win=([^ ]+))? -->") ] | .[]
| {ts: .[0], acted: .[1], round: (.[2] | tonumber), win: (.[3] // "none"), at: ($c.created_at // "")} ]
| map(select(.win == $key) | select(.ts != "9999-12-31T23:59:59Z"))
| sort_by(.at)) as $ms
| ([ range(0; ($ms | length)) as $i
| ($ms[$i]
| select((.acted == "true" and .round > $r5) or (.acted == "false" and .round >= $r5))
| {lo: (if $i == 0 then "" else ($ms[$i - 1].ts) end), hi: .ts}) ]) as $spans
| ([ ($rv | add)[] | {at: (.submitted_at // ""), login: (.user.login // ""), assoc: (.author_association // "")} ]
+ [ ($rc | add)[] | {at: (.created_at // ""), login: (.user.login // ""), assoc: (.author_association // "")} ]
+ [ ($ic | add)[] | select((.body // "") | test("^\\s*@qwen-code /") | not)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Valid finding — the census does count tagged items (a **[Critical]** comment or a CHANGES_REQUESTED review) toward the per-author budget, while the CRITICAL_ONLY_HUMAN_BATCHES env comment describes the budget as untagged batches with those tagged items as the escapes that cut through "past it". I confirmed the reproduction against the census jq. I'm leaving this thread open because the fix is a semantic call about what the brake should count, and the two resolutions have different behavioral consequences:

  1. Narrow the census to untagged items (mirror the escapes the actionable/deferred filters already recognise: drop CHANGES_REQUESTED/**[Critical]** reviews, Critical comments, replies-to-Critical, and CR-associated inline comments from the collected batches), plus a two-span fixture asserting a tagged-only author is NOT listed. This matches the documented design and this PR's intent to protect maintainer feedback from over-eager deferral, but it is a non-trivial change to a carefully-tested jq program and carries census regression risk.
  2. Update the env comment and SKILL.md to state that all consumed batches (tagged or not) count. Low-risk, but it redefines a deliberately-worded design statement; impact is bounded either way since tagged items still cut through the actionable-filter escapes and a maintainer can tag a plain comment to lift it.

My recommendation is option 1 (it matches the documented intent), but only with maintainer eyes on the jq change. Which semantic do you want the budget to implement?

中文说明

发现成立——census 确实会把带标签的条目(**[Critical]** 评论或 CHANGES_REQUESTED review)计入每位作者的预算,而 CRITICAL_ONLY_HUMAN_BATCHES 的环境变量注释把预算描述为未带标签的批次,并将这些带标签条目作为「超过预算后」仍可穿透的逃生口。我已对照 census 的 jq 复现了这一点。我把这个线程保持开放,因为修复方式是一个关于「刹车应统计什么」的语义抉择,两种方案有不同的行为后果:

  1. 将 census 收窄到未带标签条目(镜像 actionable/deferred 过滤器已识别的逃生口:从统计的批次中剔除 CHANGES_REQUESTED/**[Critical]** review、Critical 评论、对 Critical 的回复,以及关联 CR 的行内评论),并新增一个跨两个 span 的断言用例,验证仅提交带标签反馈的作者不会被列入。这符合文档化的设计,也符合本 PR 保护维护者反馈不被过度延后的意图,但它是对于一个经过充分测试的 jq 程序的非平凡改动,带有 census 回归风险。
  2. 更新环境变量注释与 SKILL.md,声明所有被消费的批次(无论是否带标签)都计数。风险低,但这会重新定义一段刻意措辞的设计陈述;无论哪种方案影响都有限,因为带标签条目仍能通过 actionable 过滤器的逃生口穿透,维护者也可以给普通评论加标签来解除限制。

我的推荐是方案 1(它符合文档意图),但希望由维护者审视该 jq 改动。你希望预算实现哪种语义?

| {at: (.created_at // ""), login: (.user.login // ""), assoc: (.author_association // "")} ])
| map(select(.login != "" and .login != $ab and .login != $rb) | select(.assoc | IN($trust[])))
| [ .[] | . as $c
| ([ $spans[] | select($c.at > .lo and $c.at <= .hi) ] | .[0] // empty)
| {login: $c.login, span: .hi} ]
| group_by(.login)
| map(select((map(.span) | unique | length) >= $k) | .[0].login)
' 2> /dev/null || echo '[]')"
[[ -z "${OVER_BUDGET_AUTHORS}" ]] && OVER_BUDGET_AUTHORS='[]'
[[ "${OVER_BUDGET_AUTHORS}" != '[]' ]] && echo "🚦 regular-feedback budget exhausted this window for: $(jq -r 'join(", ")' <<< "${OVER_BUDGET_AUTHORS}")"
fi
echo "stale=${STALE}" >> "${GITHUB_OUTPUT}"
echo "effective_round=${ROUND}" >> "${GITHUB_OUTPUT}"

Expand All @@ -2937,27 +2989,27 @@ jobs:
{
echo '## Deferred non-Critical feedback'
echo
echo "Critical-only mode is active after ${CRITICAL_ONLY_AFTER_ROUND} change-producing rounds. Any items listed below stay open for human follow-up; do not modify code, resolve threads, or reply on their behalf."
echo "Critical-only mode is active after ${CRITICAL_ONLY_AFTER_ROUND} change-producing rounds: the automated reviewer's non-Critical suggestions below are deferred and stay open for human follow-up — do not modify code, resolve threads, or reply on their behalf. Maintainer feedback defers only once its author has already had ${CRITICAL_ONLY_HUMAN_BATCHES} regular feedback batches addressed in this window'"'"'s Critical-only tail — an account can host an automated reviewer loop, so the brake keys on measured regeneration, not identity; authors at their budget, if any, are named below. (A maintainer can lift the mode itself: \`@qwen-code /retry\` starts a fresh counting window.)"
echo
jq -r --arg wm "${WATERMARK}" --arg rb "${REVIEW_BOT}" --arg ab "${AUTOFIX_BOT}" \
--argjson trust "${TRUSTED_ASSOC}" --arg pr_url "${PR_URL}" '
--argjson trust "${TRUSTED_ASSOC}" --arg pr_url "${PR_URL}" --argjson over "${OVER_BUDGET_AUTHORS}" '
.[]
| select((.submitted_at // "") > $wm)
| select((.user.login // "") != $ab)
| select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb)
| select(((.user.login // "") == $rb) or ((.user.login // "") | IN($over[])))
| select((.state // "") == "COMMENTED")
| select(((.body // "") | contains("**[Critical]**")) | not)
| "- Review by @\(.user.login): \(.html_url // $pr_url)"' \
"${WORKDIR}/rv.json"
jq -rs --arg wm "${WATERMARK}" --arg rb "${REVIEW_BOT}" --arg ab "${AUTOFIX_BOT}" \
--argjson trust "${TRUSTED_ASSOC}" --arg pr_url "${PR_URL}" \
--argjson trust "${TRUSTED_ASSOC}" --arg pr_url "${PR_URL}" --argjson over "${OVER_BUDGET_AUTHORS}" \
--slurpfile reviews "${WORKDIR}/rv.json" '
add as $comments
| ($reviews | add) as $reviews
| $comments[]
| select((.created_at // "") > $wm)
| select((.user.login // "") != $ab)
| select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb)
| select(((.user.login // "") == $rb) or ((.user.login // "") | IN($over[])))
| select((
((.body // "") | contains("**[Critical]**"))
or ((.in_reply_to_id // null) as $root
Expand All @@ -2974,21 +3026,25 @@ jobs:
| "- Inline rc:\(.id) \(.path // "?"):\(.line // "?"): \(.html_url // $pr_url)"' \
"${WORKDIR}/rc.json"
jq -r --arg wm "${WATERMARK}" --arg rb "${REVIEW_BOT}" --arg ab "${AUTOFIX_BOT}" \
--argjson trust "${TRUSTED_ASSOC}" --arg pr_url "${PR_URL}" '
--argjson trust "${TRUSTED_ASSOC}" --arg pr_url "${PR_URL}" --argjson over "${OVER_BUDGET_AUTHORS}" '
.[]
| select((.created_at // "") > $wm)
| select((.user.login // "") != $ab)
| select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb)
| select(((.user.login // "") == $rb) or ((.user.login // "") | IN($over[])))
| select((.body // "") | test("<!-- (autofix-eval|autofix-rearm|qwen-triage|qwen-review-suggestion-summary|pr-force-push|qwen-review-ack) ") | not)
| select((.body // "") | test("^\\s*@qwen-code /") | not)
| select(((.body // "") | contains("**[Critical]**")) | not)
| "- PR comment by @\(.user.login): \(.html_url // $pr_url)"' \
"${WORKDIR}/ic.json"
if [[ "${OVER_BUDGET_AUTHORS}" != '[]' ]]; then
echo
jq -r '.[] | "- @" + . + " is at this window'"'"'s regular-feedback budget — to continue: tag **[Critical]**, submit a Request changes review, or comment `@qwen-code /retry` for a fresh window. / @" + . + " 本窗口常规反馈预算已用完——继续请标 **[Critical]**、提交 Request changes、或评论 `@qwen-code /retry` 开新窗口。"' <<< "${OVER_BUDGET_AUTHORS}"
fi
echo
echo '<details>'
echo '<summary>中文说明</summary>'
echo
echo "完成 ${CRITICAL_ONLY_AFTER_ROUND} 个产生改动的轮次后,进入仅处理 Critical 的模式。以上内容保持开放,留待人工跟进;不要为其修改代码、解决线程或代为回复。"
echo "完成 ${CRITICAL_ONLY_AFTER_ROUND} 个产生改动的轮次后进入仅处理 Critical 的模式:以上为自动评审的非 Critical 建议,予以延后、保持开放并留待人工跟进——不要为其修改代码、解决线程或代为回复。维护者的反馈仅在其本人于本窗口 Critical-only 阶段已被处理 ${CRITICAL_ONLY_HUMAN_BATCHES} 批常规反馈之后才会被延后——账号可能挂着自动评审循环,因此刹车依据实测的再生频度而非身份;达到预算的作者(如有)在下方点名。(如需解除该模式,评论 \`@qwen-code /retry\` 即可开启新的计数窗口。)"
echo
echo '</details>'
} > "${WORKDIR}/deferred-feedback.md"
Expand All @@ -3005,13 +3061,15 @@ jobs:
echo
echo "## Reviews"
jq -r --arg wm "${WATERMARK}" --arg rb "${REVIEW_BOT}" --arg ab "${AUTOFIX_BOT}" \
--argjson critical_only "${CRITICAL_ONLY}" --argjson trust "${TRUSTED_ASSOC}" '
--argjson critical_only "${CRITICAL_ONLY}" --argjson trust "${TRUSTED_ASSOC}" \
--argjson over "${OVER_BUDGET_AUTHORS}" '
.[]
| select((.submitted_at // "") > $wm)
| select((.user.login // "") != $ab)
| select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb)
| select((.state // "") | IN("CHANGES_REQUESTED", "COMMENTED"))
| select(($critical_only | not)
or (((.user.login // "") != $rb) and (((.user.login // "") | IN($over[])) | not))
or (.state // "") == "CHANGES_REQUESTED"
or ((.body // "") | contains("**[Critical]**")))
| "- [\(.state)] @\(.user.login): \(.body // "" | gsub("\r"; ""))"' \
Expand All @@ -3020,6 +3078,7 @@ jobs:
echo "## Inline comments"
jq -rs --arg wm "${WATERMARK}" --arg rb "${REVIEW_BOT}" --arg ab "${AUTOFIX_BOT}" \
--argjson critical_only "${CRITICAL_ONLY}" --argjson trust "${TRUSTED_ASSOC}" \
--argjson over "${OVER_BUDGET_AUTHORS}" \
--slurpfile reviews "${WORKDIR}/rv.json" '
add as $comments
| ($reviews | add) as $reviews
Expand All @@ -3028,6 +3087,7 @@ jobs:
| select((.user.login // "") != $ab)
| select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb)
| select(($critical_only | not)
or (((.user.login // "") != $rb) and (((.user.login // "") | IN($over[])) | not))
or ((.body // "") | contains("**[Critical]**"))
or ((.in_reply_to_id // null) as $root
| $root != null
Expand All @@ -3044,14 +3104,16 @@ jobs:
echo
echo "## Issue-level comments"
jq -r --arg wm "${WATERMARK}" --arg rb "${REVIEW_BOT}" --arg ab "${AUTOFIX_BOT}" \
--argjson critical_only "${CRITICAL_ONLY}" --argjson trust "${TRUSTED_ASSOC}" '
--argjson critical_only "${CRITICAL_ONLY}" --argjson trust "${TRUSTED_ASSOC}" \
--argjson over "${OVER_BUDGET_AUTHORS}" '
.[]
| select((.created_at // "") > $wm)
| select((.user.login // "") != $ab)
| select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb)
| select((.body // "") | test("<!-- (autofix-eval|autofix-rearm|qwen-triage|qwen-review-suggestion-summary|pr-force-push|qwen-review-ack) ") | not)
| select((.body // "") | test("^\\s*@qwen-code /") | not)
| select(($critical_only | not)
or (((.user.login // "") != $rb) and (((.user.login // "") | IN($over[])) | not))
or ((.body // "") | contains("**[Critical]**")))
| "- @\(.user.login): \(.body // "" | gsub("\r"; ""))"' \
"${WORKDIR}/ic.json"
Expand Down
11 changes: 8 additions & 3 deletions .qwen/skills/autofix/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,14 @@ implement — satisfying a nit is never a reason to bloat the code.
`Deferred non-Critical feedback` section, the PR has already completed five
suggestion-capable, change-producing rounds. That section is an audit record,
not work: do not modify code, resolve threads, or write comment replies for
those items. Act only on Critical feedback and formally requested changes
rendered in the actionable sections, failed checks, and the requested
base-conflict resolution.
those items. Everything rendered in the actionable sections IS in scope —
the deterministic filter defers the automated reviewer's non-Critical
suggestions and, past a small per-window budget of already-addressed
batches, a human author's untagged feedback too (an account can host an
automated reviewer loop, so the brake keys on measured regeneration, not
identity). A maintainer writing "fix X before merge" after round five
means exactly that when it reaches you — plus failed checks and the
requested base-conflict resolution.
- Needs a maintainer's decision: a finding that turns on a judgment that is
NOT yours to make — a product or scope tradeoff (is this acceptable for v1?
should the PR be split?), two reviewers asking for opposite things, or whether
Expand Down
Loading
Loading