From 601e1a4bc736588f2eaab9f6370f67b8d6af55bb Mon Sep 17 00:00:00 2001 From: verify Date: Thu, 30 Jul 2026 09:37:11 +0800 Subject: [PATCH 1/6] fix(autofix): never defer maintainer feedback in Critical-only mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critical-only mode (after 5 change-producing rounds) classifies feedback lexically: only a literal **[Critical]** tag or a CHANGES_REQUESTED review survives; everything else is deferred before the agent reads a word of it. That rule was built to stop the review bot's suggestion ping-pong, but it catches maintainers too. Observed four times in two days (#8037, #7944, #7885, #7799): a maintainer's review with explicit merge-blocking findings — #8037's said 'I'd fix before merge' on a correctness bug and a security-adjacent one — was wholesale-deferred as one 'non-Critical item', and the bot then reported 'No Critical feedback. The Issue-level comments sections are empty', which was lexically true and substantively false. The bot's own advertised definition ('correctness bugs, security issues, or formally requested changes') is exactly what the deferred comments contained; the agent that could have applied that definition never saw them. The lexical test now applies exclusively to the review bot's output: - All three actionable filters (reviews, inline, issue-level) pass anything not authored by the review bot straight through in Critical-only mode — the agent judges maintainer feedback on content, as everywhere else. - All three deferred-list builders keep only review-bot items, so a maintainer comment can never appear as an 'audit record'. - The deferral note says what is actually deferred (the automated reviewer's non-Critical suggestions), states that maintainer feedback is never deferred, and names the exit (@qwen-code /retry opens a fresh counting window). - SKILL.md's Critical-only policy now marks everything rendered in the actionable sections as in scope, so the agent does not re-refuse what the filter passed through. Behavioral test updated both ways: maintainer comments/reviews stay actionable in Critical-only mode across all three sources, bot suggestions still defer, and structural pins hold the bypass and the bot-only select in all six filters. --- .github/workflows/qwen-autofix.yml | 13 ++-- .qwen/skills/autofix/SKILL.md | 8 ++- scripts/tests/qwen-autofix-workflow.test.js | 79 +++++++++++++++++---- 3 files changed, 77 insertions(+), 23 deletions(-) diff --git a/.github/workflows/qwen-autofix.yml b/.github/workflows/qwen-autofix.yml index cc65d6dbb28..429a48002d7 100644 --- a/.github/workflows/qwen-autofix.yml +++ b/.github/workflows/qwen-autofix.yml @@ -2832,14 +2832,14 @@ 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 is never deferred. (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}" ' .[] | select((.submitted_at // "") > $wm) | select((.user.login // "") != $ab) - | select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb) + | select((.user.login // "") == $rb) | select((.state // "") == "COMMENTED") | select(((.body // "") | contains("**[Critical]**")) | not) | "- Review by @\(.user.login): \(.html_url // $pr_url)"' \ @@ -2852,7 +2852,7 @@ jobs: | $comments[] | select((.created_at // "") > $wm) | select((.user.login // "") != $ab) - | select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb) + | select((.user.login // "") == $rb) | select(( ((.body // "") | contains("**[Critical]**")) or ((.in_reply_to_id // null) as $root @@ -2873,7 +2873,7 @@ jobs: .[] | select((.created_at // "") > $wm) | select((.user.login // "") != $ab) - | select(((.author_association // "") | IN($trust[])) or (.user.login // "") == $rb) + | select((.user.login // "") == $rb) | select((.body // "") | test("") ] | .[] + | {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) + | {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}" @@ -2832,27 +2884,27 @@ jobs: { echo '## Deferred non-Critical feedback' echo - 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 is never deferred. (A maintainer can lift the mode itself: \`@qwen-code /retry\` starts a fresh counting window.)" + 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((.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((.user.login // "") == $rb) + | select(((.user.login // "") == $rb) or ((.user.login // "") | IN($over[]))) | select(( ((.body // "") | contains("**[Critical]**")) or ((.in_reply_to_id // null) as $root @@ -2869,21 +2921,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((.user.login // "") == $rb) + | select(((.user.login // "") == $rb) or ((.user.login // "") | IN($over[]))) | select((.body // "") | test("`, + }); + const humanC = (login, at, assoc = 'MEMBER', body = 'feedback') => ({ + user: { login }, + created_at: at, + author_association: assoc, + body, + }); + const budgetDir = mkdtempSync(join(tmpdir(), 'over-budget-')); + try { + writeFileSync( + join(budgetDir, 'ic.json'), + JSON.stringify([ + markerC('2026-07-02T00:00:00Z', 'true', 5, '2026-07-02T01:00:00Z'), + markerC('2026-07-03T00:00:00Z', 'true', 6, '2026-07-03T01:00:00Z'), + markerC('2026-07-04T00:00:00Z', 'false', 6, '2026-07-04T01:00:00Z'), + humanC('looper', '2026-07-02T12:00:00Z'), + humanC('looper', '2026-07-03T12:00:00Z'), + humanC('onetime', '2026-07-03T13:00:00Z'), + humanC('looper', '2026-07-01T12:00:00Z'), + humanC('looper', '2026-07-05T00:00:00Z'), + humanC('rando', '2026-07-02T13:00:00Z', 'NONE'), + humanC( + 'looper', + '2026-07-02T13:00:00Z', + 'MEMBER', + '@qwen-code /review', + ), + ]), + ); + writeFileSync(join(budgetDir, 'rv.json'), '[]'); + writeFileSync(join(budgetDir, 'rc.json'), '[]'); + const overOut = execFileSync( + 'bash', + [ + '-c', + [ + 'set -uo pipefail', + `WORKDIR='${budgetDir}'`, + `LIVE_REARM_KEY='${WKEY}'`, + "AUTOFIX_BOT='qwen-code-dev-bot'", + "REVIEW_BOT='qwen-code-ci-bot'", + `TRUSTED_ASSOC='["OWNER","MEMBER","COLLABORATOR"]'`, + 'CRITICAL_ONLY_AFTER_ROUND=5', + 'CRITICAL_ONLY_HUMAN_BATCHES=2', + censusBlock.replace(/\n {10}/g, '\n'), + 'printf %s "${OVER_BUDGET_AUTHORS}"', + ].join('\n'), + ], + { encoding: 'utf8' }, + ); + expect(JSON.parse(overOut)).toEqual(['looper']); + } finally { + rmSync(budgetDir, { recursive: true, force: true }); + } + // The deferral note names over-budget authors with the escapes. + expect(prepareBranchAndFeedbackStep).toContain('is at this window'); + expect(prepareBranchAndFeedbackStep).toContain('regular-feedback budget'); expect(inlineFilter).toContain('pull_request_review_id'); // Scan still selects fresh suggestions so a no-op report can advance the From ddeb14566beb6dc5cef994463415b2737d09999b Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Thu, 30 Jul 2026 05:09:44 +0000 Subject: [PATCH 3/6] fix(autofix): fix deferred-feedback bash quoting and drop a dead jq binding (#8071) --- .github/workflows/qwen-autofix.yml | 8 +-- scripts/tests/qwen-autofix-workflow.test.js | 62 ++++++++++++++++----- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/.github/workflows/qwen-autofix.yml b/.github/workflows/qwen-autofix.yml index 0a39751bb66..8ae88a9b580 100644 --- a/.github/workflows/qwen-autofix.yml +++ b/.github/workflows/qwen-autofix.yml @@ -2989,10 +2989,10 @@ jobs: { echo '## Deferred non-Critical feedback' echo - 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 "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 over "${OVER_BUDGET_AUTHORS}" ' + --arg pr_url "${PR_URL}" --argjson over "${OVER_BUDGET_AUTHORS}" ' .[] | select((.submitted_at // "") > $wm) | select((.user.login // "") != $ab) @@ -3002,7 +3002,7 @@ jobs: | "- 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 over "${OVER_BUDGET_AUTHORS}" \ + --arg pr_url "${PR_URL}" --argjson over "${OVER_BUDGET_AUTHORS}" \ --slurpfile reviews "${WORKDIR}/rv.json" ' add as $comments | ($reviews | add) as $reviews @@ -3026,7 +3026,7 @@ 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 over "${OVER_BUDGET_AUTHORS}" ' + --arg pr_url "${PR_URL}" --argjson over "${OVER_BUDGET_AUTHORS}" ' .[] | select((.created_at // "") > $wm) | select((.user.login // "") != $ab) diff --git a/scripts/tests/qwen-autofix-workflow.test.js b/scripts/tests/qwen-autofix-workflow.test.js index 73c2e37cf46..69b7be12b89 100644 --- a/scripts/tests/qwen-autofix-workflow.test.js +++ b/scripts/tests/qwen-autofix-workflow.test.js @@ -240,6 +240,23 @@ describe('qwen-autofix workflow', () => { expect(workflow).not.toMatch(/^\s*(fi|done|esac)"\s*$/m); }); + it('keeps the prepare-branch-and-feedback run block bash-parseable', () => { + // The deferred-feedback echo sits inside a double-quoted string, where the + // '"'"' idiom is a literal apostrophe followed by a string CLOSER rather + // than an embedded quote — a parse-time syntax error that aborts the step + // for every run while the jq-filter tests (which never run the echo lines) + // stay green. bash -n the whole run block so a future quoting regression in + // this step fails CI instead of breaking every autofix run. + const runBlock = + prepareBranchAndFeedbackStep.match(/run: \|-\n([\s\S]*)$/)?.[1]; + expect(runBlock).toBeTruthy(); + const res = spawnSync('bash', ['-n'], { + encoding: 'utf8', + input: runBlock.replace(/^ {10}/gm, ''), + }); + expect(res.status).toBe(0); + }); + it('runs scheduled autofix as a 10-minute multi-target fan-out worker', () => { expect(workflow).toContain("cron: '*/10 * * * *'"); expect(workflow).not.toContain("cron: '0 0,12 * * *'"); @@ -3821,7 +3838,7 @@ describe('qwen-autofix workflow', () => { // Deferred queries: extract and execute against fixture data, // mirroring the actionable inline filter test above. const deferredReviewsFilter = prepareBranchAndFeedbackStep.match( - /## Deferred non-Critical feedback[\s\S]*?jq -r --arg wm "\$\{WATERMARK\}" --arg rb "\$\{REVIEW_BOT\}" --arg ab "\$\{AUTOFIX_BOT\}" \\\n\s+--argjson trust "\$\{TRUSTED_ASSOC\}" --arg pr_url "\$\{PR_URL\}" --argjson over "\$\{OVER_BUDGET_AUTHORS\}" '([\s\S]*?)' \\\n\s+"\$\{WORKDIR\}\/rv\.json"/, + /## Deferred non-Critical feedback[\s\S]*?jq -r --arg wm "\$\{WATERMARK\}" --arg rb "\$\{REVIEW_BOT\}" --arg ab "\$\{AUTOFIX_BOT\}" \\\n\s+--arg pr_url "\$\{PR_URL\}" --argjson over "\$\{OVER_BUDGET_AUTHORS\}" '([\s\S]*?)' \\\n\s+"\$\{WORKDIR\}\/rv\.json"/, )?.[1]; expect(deferredReviewsFilter).toBeTruthy(); const deferredReviews = [ @@ -3868,9 +3885,6 @@ describe('qwen-autofix workflow', () => { '--arg', 'ab', 'qwen-code-dev-bot', - '--argjson', - 'trust', - '["OWNER","MEMBER","COLLABORATOR"]', '--arg', 'pr_url', 'https://github.com/test/pull/1', @@ -3889,7 +3903,7 @@ describe('qwen-autofix workflow', () => { expect(countDeferredReviews(['maintainer'])).toBe(2); const deferredInlineFilter = prepareBranchAndFeedbackStep.match( - /jq -rs --arg wm "\$\{WATERMARK\}" --arg rb "\$\{REVIEW_BOT\}" --arg ab "\$\{AUTOFIX_BOT\}" \\\n\s+--argjson trust "\$\{TRUSTED_ASSOC\}" --arg pr_url "\$\{PR_URL\}" --argjson over "\$\{OVER_BUDGET_AUTHORS\}" \\\n\s+--slurpfile reviews "\$\{WORKDIR\}\/rv\.json" '([\s\S]*?)' \\\n\s+"\$\{WORKDIR\}\/rc\.json"/, + /jq -rs --arg wm "\$\{WATERMARK\}" --arg rb "\$\{REVIEW_BOT\}" --arg ab "\$\{AUTOFIX_BOT\}" \\\n\s+--arg pr_url "\$\{PR_URL\}" --argjson over "\$\{OVER_BUDGET_AUTHORS\}" \\\n\s+--slurpfile reviews "\$\{WORKDIR\}\/rv\.json" '([\s\S]*?)' \\\n\s+"\$\{WORKDIR\}\/rc\.json"/, )?.[1]; expect(deferredInlineFilter).toBeTruthy(); const countDeferredInline = (over = []) => @@ -3907,9 +3921,6 @@ describe('qwen-autofix workflow', () => { '--arg', 'ab', 'qwen-code-dev-bot', - '--argjson', - 'trust', - '["OWNER","MEMBER","COLLABORATOR"]', '--arg', 'pr_url', 'https://github.com/test/pull/1', @@ -3934,7 +3945,7 @@ describe('qwen-autofix workflow', () => { expect(countDeferredInline(['maintainer'])).toBe(2); const deferredIssueFilter = prepareBranchAndFeedbackStep.match( - /"\$\{WORKDIR\}\/rc\.json"\n\s+jq -r --arg wm "\$\{WATERMARK\}" --arg rb "\$\{REVIEW_BOT\}" --arg ab "\$\{AUTOFIX_BOT\}" \\\n\s+--argjson trust "\$\{TRUSTED_ASSOC\}" --arg pr_url "\$\{PR_URL\}" --argjson over "\$\{OVER_BUDGET_AUTHORS\}" '([\s\S]*?)' \\\n\s+"\$\{WORKDIR\}\/ic\.json"/, + /"\$\{WORKDIR\}\/rc\.json"\n\s+jq -r --arg wm "\$\{WATERMARK\}" --arg rb "\$\{REVIEW_BOT\}" --arg ab "\$\{AUTOFIX_BOT\}" \\\n\s+--arg pr_url "\$\{PR_URL\}" --argjson over "\$\{OVER_BUDGET_AUTHORS\}" '([\s\S]*?)' \\\n\s+"\$\{WORKDIR\}\/ic\.json"/, )?.[1]; expect(deferredIssueFilter).toBeTruthy(); const issueComments = [ @@ -3985,9 +3996,6 @@ describe('qwen-autofix workflow', () => { '--arg', 'ab', 'qwen-code-dev-bot', - '--argjson', - 'trust', - '["OWNER","MEMBER","COLLABORATOR"]', '--arg', 'pr_url', 'https://github.com/test/pull/1', @@ -4069,8 +4077,32 @@ describe('qwen-autofix workflow', () => { ), ]), ); - writeFileSync(join(budgetDir, 'rv.json'), '[]'); - writeFileSync(join(budgetDir, 'rc.json'), '[]'); + // A second author whose two consumed batches arrive through the review + // (.submitted_at) and inline-comment (.created_at) branches, not ic.json: + // both are untagged, so they count under either census semantic. + writeFileSync( + join(budgetDir, 'rv.json'), + JSON.stringify([ + { + user: { login: 'reviewer2' }, + author_association: 'MEMBER', + state: 'COMMENTED', + submitted_at: '2026-07-02T12:30:00Z', + body: 'feedback delivered through a review', + }, + ]), + ); + writeFileSync( + join(budgetDir, 'rc.json'), + JSON.stringify([ + { + user: { login: 'reviewer2' }, + author_association: 'MEMBER', + created_at: '2026-07-03T13:30:00Z', + body: 'feedback delivered through an inline comment', + }, + ]), + ); const overOut = execFileSync( 'bash', [ @@ -4090,7 +4122,7 @@ describe('qwen-autofix workflow', () => { ], { encoding: 'utf8' }, ); - expect(JSON.parse(overOut)).toEqual(['looper']); + expect(JSON.parse(overOut)).toEqual(['looper', 'reviewer2']); } finally { rmSync(budgetDir, { recursive: true, force: true }); } From 5bf5140b2ca817e2f0477793f5cb3dd4b6c72113 Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Thu, 30 Jul 2026 06:39:34 +0000 Subject: [PATCH 4/6] test(autofix): exercise census window-isolation guard with a stale-window fixture (#8071) --- scripts/tests/qwen-autofix-workflow.test.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/tests/qwen-autofix-workflow.test.js b/scripts/tests/qwen-autofix-workflow.test.js index 69b7be12b89..ab7c45ef898 100644 --- a/scripts/tests/qwen-autofix-workflow.test.js +++ b/scripts/tests/qwen-autofix-workflow.test.js @@ -4044,10 +4044,10 @@ describe('qwen-autofix workflow', () => { )?.[0]; expect(censusBlock).toBeTruthy(); const WKEY = '2026-07-01T00:00:00Z'; - const markerC = (ts, acted, round, at) => ({ + const markerC = (ts, acted, round, at, win = WKEY) => ({ user: { login: 'qwen-code-dev-bot' }, created_at: at, - body: `head\n`, + body: `head\n`, }); const humanC = (login, at, assoc = 'MEMBER', body = 'feedback') => ({ user: { login }, @@ -4063,9 +4063,19 @@ describe('qwen-autofix workflow', () => { markerC('2026-07-02T00:00:00Z', 'true', 5, '2026-07-02T01:00:00Z'), markerC('2026-07-03T00:00:00Z', 'true', 6, '2026-07-03T01:00:00Z'), markerC('2026-07-04T00:00:00Z', 'false', 6, '2026-07-04T01:00:00Z'), + // Stale-window marker: qualifies for a span but win != WKEY. + markerC( + '2026-06-15T00:00:00Z', + 'true', + 6, + '2026-06-15T01:00:00Z', + '2026-06-01T00:00:00Z', + ), humanC('looper', '2026-07-02T12:00:00Z'), humanC('looper', '2026-07-03T12:00:00Z'), humanC('onetime', '2026-07-03T13:00:00Z'), + // Stale-window human inside the stale span; must not count. + humanC('onetime', '2026-06-14T12:00:00Z'), humanC('looper', '2026-07-01T12:00:00Z'), humanC('looper', '2026-07-05T00:00:00Z'), humanC('rando', '2026-07-02T13:00:00Z', 'NONE'), From 7d2c53803643332f371a55d9a0a2ac6db6cacee2 Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Thu, 30 Jul 2026 08:19:25 +0000 Subject: [PATCH 5/6] test(autofix): make census command-exclusion observable; surface census stderr (#8071) --- .github/workflows/qwen-autofix.yml | 2 +- scripts/tests/qwen-autofix-workflow.test.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/qwen-autofix.yml b/.github/workflows/qwen-autofix.yml index 8ae88a9b580..1d6057e7b91 100644 --- a/.github/workflows/qwen-autofix.yml +++ b/.github/workflows/qwen-autofix.yml @@ -2976,7 +2976,7 @@ jobs: | {login: $c.login, span: .hi} ] | group_by(.login) | map(select((map(.span) | unique | length) >= $k) | .[0].login) - ' 2> /dev/null || echo '[]')" + ' || 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 diff --git a/scripts/tests/qwen-autofix-workflow.test.js b/scripts/tests/qwen-autofix-workflow.test.js index ab7c45ef898..fd6fb628ce4 100644 --- a/scripts/tests/qwen-autofix-workflow.test.js +++ b/scripts/tests/qwen-autofix-workflow.test.js @@ -4040,7 +4040,7 @@ describe('qwen-autofix workflow', () => { // feedback, untrusted authors, and command comments never count. expect(workflow).toContain("CRITICAL_ONLY_HUMAN_BATCHES: '2'"); const censusBlock = prepareBranchAndFeedbackStep.match( - /OVER_BUDGET_AUTHORS="\$\(jq -n[\s\S]*?' 2> \/dev\/null \|\| echo '\[\]'\)"/, + /OVER_BUDGET_AUTHORS="\$\(jq -n[\s\S]*?' \|\| echo '\[\]'\)"/, )?.[0]; expect(censusBlock).toBeTruthy(); const WKEY = '2026-07-01T00:00:00Z'; @@ -4085,6 +4085,22 @@ describe('qwen-autofix workflow', () => { 'MEMBER', '@qwen-code /review', ), + // Command-only author: both items are /commands, so with the + // command-exclusion filter they count 0 consumed spans and stay + // absent; dropping the filter would surface them and fail the + // assertion, which is what makes the guard observable. + humanC( + 'commander', + '2026-07-02T14:00:00Z', + 'MEMBER', + '@qwen-code /review', + ), + humanC( + 'commander', + '2026-07-03T14:00:00Z', + 'MEMBER', + '@qwen-code /retry', + ), ]), ); // A second author whose two consumed batches arrive through the review From 80c53cb2cd2423c6f8d52fce857c363bbaba7f6e Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Thu, 30 Jul 2026 10:31:32 +0000 Subject: [PATCH 6/6] fix(autofix): exclude never-deferrable feedback from the budget census (#8071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Critical-only per-author budget census counted every trusted review, inline comment, and issue comment, including feedback the deferred renderer would never defer: **[Critical]**-tagged comments, Request changes / APPROVED reviews, inline replies rooted at a Critical comment, and inline comments attached to a Request changes review. A maintainer who followed the documented escape hatches (tag Critical, request changes) thereby spent their own budget and had later untagged feedback silently deferred — the exact bug this PR fixes, re-created one level down. Mirror the three deferred-builder predicates in the census item filter so a batch is counted only when it is actually deferrable. Extend the census replay test with protected authors (Critical-only, Request changes, APPROVED, Critical-rooted replies, Request-changes-review inlines, the review bot as a trusted MEMBER, and a sentinel-ts marker probe) that each carry two consumed-span batches yet must stay absent, so dropping any one exclusion now fails the suite. Also fold bash's stderr into the bash -n guard assertion so a future quoting regression reports the syntax error, not just a non-zero exit. --- .github/workflows/qwen-autofix.yml | 31 ++++- scripts/tests/qwen-autofix-workflow.test.js | 137 +++++++++++++++++++- 2 files changed, 163 insertions(+), 5 deletions(-) diff --git a/.github/workflows/qwen-autofix.yml b/.github/workflows/qwen-autofix.yml index 1d6057e7b91..79ce66866b3 100644 --- a/.github/workflows/qwen-autofix.yml +++ b/.github/workflows/qwen-autofix.yml @@ -2949,6 +2949,11 @@ jobs: # 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. + # Only feedback the deferred renderer below would actually defer is + # counted: Critical-tagged items, Request changes / APPROVED reviews, + # and inline comments rooted at a Critical comment or attached to a + # Request changes review are never deferrable, so they must not burn + # an author's budget — the item filter mirrors those predicates. OVER_BUDGET_AUTHORS='[]' if [[ "${CRITICAL_ONLY}" == "true" ]]; then OVER_BUDGET_AUTHORS="$(jq -n \ @@ -2966,10 +2971,28 @@ jobs: | ($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) - | {at: (.created_at // ""), login: (.user.login // ""), assoc: (.author_association // "")} ]) + | ($rv | add) as $reviews + | ($rc | add) as $comments + | ([ $reviews[] + | select((.state // "") == "COMMENTED") + | select(((.body // "") | contains("**[Critical]**")) | not) + | {at: (.submitted_at // ""), login: (.user.login // ""), assoc: (.author_association // "")} ] + + [ $comments[] + | select(( + ((.body // "") | contains("**[Critical]**")) + or ((.in_reply_to_id // null) as $root + | $root != null + and any($comments[]; .id == $root and ((.body // "") | contains("**[Critical]**")))) + or ((.pull_request_review_id // null) as $review + | $review != null + and any($reviews[]; .id == $review and ((.state // "") == "CHANGES_REQUESTED"))) + ) | not) + | {at: (.created_at // ""), login: (.user.login // ""), assoc: (.author_association // "")} ] + + [ ($ic | add)[] + | select((.body // "") | test("