Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8b8dc72
feat(review): skip the automatic round when a synchronize only refres…
wenshao Aug 26, 2026
88fe914
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
wenshao Aug 26, 2026
fad703a
refactor(review): move the base-refresh gate body into .github/scripts
wenshao Aug 26, 2026
a7e8811
fix(review): tighten base-refresh gate certification per review feedback
qwen-code-dev-bot Aug 26, 2026
5ac05ba
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
wenshao Aug 27, 2026
21cce5f
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 27, 2026
3d449b8
fix(review): harden the base-refresh ledger lookup against bodyless r…
qwen-code-dev-bot Aug 27, 2026
90c99a7
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 28, 2026
4cf0f3a
fix(review): harden the base-refresh gate per round-2 findings (#10116)
qwen-code-dev-bot Aug 28, 2026
a81269d
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 28, 2026
a15bd5c
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 28, 2026
64fffbf
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
422a5e7
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
402bb22
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
cba5231
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
6e77b50
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
cf5dc5d
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
cad0cf0
fix(review): harden base-refresh gate certification and test isolation
qwen-code-dev-bot Aug 29, 2026
16b58ab
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 29, 2026
aae221b
Merge branch 'main' into feat/review-skip-base-refresh-only-sync
qwen-code-dev-bot Aug 30, 2026
c7499d5
fix(review): close planted-git-config class and marker fall-through i…
qwen-code-dev-bot Aug 30, 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
273 changes: 273 additions & 0 deletions .github/scripts/review-base-refresh-gate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
#!/usr/bin/env bash
# Decide whether an automatic `synchronize` review round may be skipped
# because the push only refreshed the base branch (#10111): an update-branch
# merge fires `synchronize` like any push, but a full automatic round costs
# hours for a head whose PR-side diff is unchanged.
#
# Two facts are certified before any review compute is spent: every
# first-parent commit since the head the last completed automatic round
# reviewed is a two-parent merge of the base branch whose tree equals
# its parents' clean merge (a commit-tree-crafted merge relocating the
# reviewed hunks fails open), and the PR's own three-dot diff kept the
# same canonical digest — every changed and
# context byte is hashed, binary bytes included (--binary renders them as
# content-carrying GIT binary patches, not the content-free "Binary files
# ... differ" marker), after stripping only unstable diff metadata (index
# lines, hunk offsets), so an upstream edit touching the PR's own hunks
# (whitespace included) fails the equality and the full round runs.
#
# The reviewed head is the newest SUBMITTED bot review carrying a ledger
# marker (APPROVED, CHANGES_REQUESTED, or COMMENTED, with a submitted_at)
# posted by the AUTHENTICATED account — resolved live via `gh api user`,
# same norm as the fallback dedup — so a participant posting the marker
# text in their own review, a PENDING draft, or a DISMISSED review can
# never certify a head this gate would skip. The newest marker decides:
# the review pipeline withholds the marker's `sha` anchor on fail-closed
# rounds (an undecided blocker, unproven scope, a truncated finding
# list), so a withheld or malformed anchor fails open instead of falling
# back to an older marker — certifying while the newest round's debt
# stays uncovered — and the marker's recorded `base` must equal the
# current base ref, or a round that reviewed against the old base would
# certify a retargeted one. Markers without a `base` field fail open
# like any unmatched shape.
#
# Scope limit: docs-only-classified PRs never skip — their automatic
# rounds are downgraded to medium with --comment stripped, and medium
# posts no review, so such a PR never gains a ledger-marked review for
# this lookup to resolve.
#
# The git calls below run against a reused self-hosted workspace whose
# .git config and refs an earlier, possibly prompt-injected run can have
# planted, so the whole planted-config class is closed, not entrance by
# entrance: they follow the CLI's sanitizedGitEnv() norm (external diff
# drivers and textconv are disabled — both execute code on a plain
# `git diff` — and GIT_NO_REPLACE_OBJECTS=1 keeps planted refs/replace/*
# from falsifying the digest and ancestry computations), ambient
# system/global gitconfig is masked outright, every call pins
# core.hooksPath=/dev/null so the ref-updating fetch cannot execute a
# planted reference-transaction (or any other) hook, the repo-local keys
# that execute code — merge drivers (no git flag disables one), diff
# command/textconv drivers, core.attributesFile — are scrubbed before
# any call, a planted $GIT_DIR/info/attributes fails the gate open, and
# the digest pins -U3 so a planted diff.context cannot shrink the hashed
# context.
#
# Fail-open contract: every probe error or unmatched shape records
# skip=false and the full round runs, and the script never exits non-zero —
# the caller treats a step failure as a pipeline failure worth a fallback
# comment, which a skipped gate is not.
#
# Outputs (GITHUB_OUTPUT): skip=true|false, reviewed_sha, reason.
set -uo pipefail
export GIT_NO_REPLACE_OBJECTS=1
Comment on lines +61 to +62

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.

Deferred to the next round on round-budget grounds — not disagreement; the finding is verified real, including the fetch-time entrances live today. This round ships four verified fixes with red-before witnesses (R5-3 test isolation, R7-1 newest-marker-wins, R3-3 jq coercions, R5-2 clean-merge tree check). The structural fix this finding asks for — closing the surface whole, via workspace-wide git-state sanitization before the gate (wiring resanitize-git-config.sh or an equivalent hardened wrapper: GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null, hooks/fsmonitor disabling, --upload-pack=git-upload-pack pinned on both fetches, grafts fail-open, and one executed sentinel per channel) — is a dedicated work item; a partial per-channel patch would be exactly the instance-chasing the convergence notes warn against. The existing plantAttackChannels() coverage keeps the three already-hardened channels pinned in the meantime.

中文说明

按轮次预算延后至下一轮——并非不同意;该发现已核实为真,包括当前即为活通道的 fetch 时入口。本轮已落地四项带"修复前为红"见证的修复(R5-3 测试隔离、R7-1 最新标记优先、R3-3 jq 强转、R5-2 干净合并树检查)。本发现要求的结构性修复——整体封闭该表面:门运行前对整个工作区做 git 状态净化(接入 resanitize-git-config.sh 或等效加固包装:GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null、禁用 hooks/fsmonitor、两处 fetch 钉住 --upload-pack=git-upload-pack、grafts 向开放侧倒、每通道一个已执行哨兵)——是一项专门的工作;逐通道的局部修补正是收敛说明所警告的"追实例"。既有的 plantAttackChannels() 覆盖在此期间继续钉住已加固的三个通道。

# Same isolation the suite's harness exports for its children, exported
# here so ambient system/global gitconfig (a prior run's diff.context,
# merge drivers, attributesFile) reaches no gate git call in production.
export GIT_CONFIG_GLOBAL=/dev/null
export GIT_CONFIG_SYSTEM=/dev/null
export GIT_CONFIG_NOSYSTEM=1

# The workflow's GIT_SAFE idiom: core.hooksPath=/dev/null keeps a planted
# hook (reference-transaction fires on the fallback fetch's ref update;
# core.hooksPath plants are overridden the same way) out of every call,
# and core.fsmonitor= keeps a planted fsmonitor command out of the reads.
GIT_SAFE=(git -c core.hooksPath=/dev/null -c core.fsmonitor=)

# Required environment, restated so a misconfigured caller dies naming the
# missing input instead of probing git with empty arguments.
PR_NUMBER="${PR_NUMBER:?}"
EVENT_HEAD_SHA="${EVENT_HEAD_SHA:?}"
BASE_REF="${BASE_REF:?}"
RUN_URL="${RUN_URL:?}"
GITHUB_REPOSITORY="${GITHUB_REPOSITORY:?}"
GITHUB_OUTPUT="${GITHUB_OUTPUT:?}"
GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY:?}"

SKIP=false
REVIEWED_SHA=''
REASON=''

# Canonical digest of the diff between two commits: every changed and
# context byte is hashed, stripping only unstable metadata (index lines,
# hunk offsets). `git patch-id` is whitespace-insensitive and would
# certify an indentation-only rewrite of PR-owned lines; plain `git diff`
# renders binary files as one content-free marker line, so --binary keeps
# their bytes in the hash. --no-ext-diff and --no-textconv keep a planted
# diff.external / diff.<driver>.textconv from executing code in this
# PAT-bearing step; -U3 pins the hashed geometry so a planted diff.context
# cannot shrink it to changed-only lines.
diff_digest() {
local diff
diff="$(
"${GIT_SAFE[@]}" diff --binary --no-ext-diff --no-textconv -U3 "$1" "$2" \
2>/dev/null
)" || return 1
[[ -n "${diff}" ]] || return 0
printf '%s\n' "${diff}" |
sed -E '/^index [0-9a-f]+\.\.[0-9a-f]+/d; /^@@ /d' |
"${GIT_SAFE[@]}" hash-object --stdin
}

decide() {
# A planted $GIT_DIR/info/attributes maps files to planted merge/diff
# drivers from inside the git dir, where no config scrub reaches; fail
# open instead of deleting a file this step does not own.
local git_dir
REASON='planted git attributes present'
git_dir="$("${GIT_SAFE[@]}" rev-parse --git-dir 2>/dev/null)" || return
[[ ! -e "${git_dir}/info/attributes" ]] || return
# No git flag disables a merge driver (merge-tree executes one on any
# both-sides-modified path the attributes map to it), so strip the
# code-executing repo-local keys before any git call below can honor
# them. Ambient sources are already masked by the exports above.
local key
REASON='workspace git config scrub failed'
while IFS= read -r key; do
[[ -n "${key}" ]] || continue
"${GIT_SAFE[@]}" config --local --unset-all "${key}" || return
done < <(
"${GIT_SAFE[@]}" config --local --name-only --get-regexp \
'^(merge\..*\.driver|diff\..*\.(command|textconv)|core\.attributesfile)$' \
2>/dev/null || true
)

REASON='pr head fetch failed'
"${GIT_SAFE[@]}" fetch --no-tags --quiet origin \
"refs/pull/${PR_NUMBER}/head" || return
REASON='event head not reachable from the PR head ref'
"${GIT_SAFE[@]}" cat-file -e "${EVENT_HEAD_SHA}^{commit}" 2>/dev/null || return
REASON='base branch ref unavailable'
if ! "${GIT_SAFE[@]}" rev-parse -q --verify "origin/${BASE_REF}^{commit}" \
>/dev/null; then
"${GIT_SAFE[@]}" fetch --no-tags --quiet origin "${BASE_REF}" || return
"${GIT_SAFE[@]}" rev-parse -q --verify "origin/${BASE_REF}^{commit}" \
>/dev/null || return
fi

REASON='reviewed-head lookup failed'
local bot_login reviews marker reviewed_base
bot_login="$(gh api user --jq '.login')" && [[ -n "${bot_login}" ]] || return
reviews="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews" --method GET --paginate -F per_page=100)" || return
# The marker PAYLOAD is the certification: the newest submitted bot
# review whose body CARRIES a marker decides, and anything malformed or
# withheld fails open — no fall-through to an older marker, since a
# fail-closed round withholds its `sha` precisely so the next round
# re-covers what it could not certify, and an unparseable payload (a
# writer bug, body truncation, a hand-edit) is the same unreadable
# state. Selecting on parseability instead would drop the newest
# unparseable marker inside the array and certify from the older one
# beside it. Non-string `sha`/`base` values are coerced before matching
# so a writer bug drops out instead of aborting the whole jq program
# (and every later lookup on the PR). Control characters are stripped
# from the untrusted base value so a forged marker cannot inject extra
# GITHUB_OUTPUT lines through the reason text.
marker="$(
printf '%s' "${reviews}" | jq -sr --arg login "${bot_login}" '
[.[][]
| select(.user.login == $login)
| select(.state == "APPROVED" or .state == "CHANGES_REQUESTED"
or .state == "COMMENTED")
| select(.submitted_at != null)
| select((.body // "") | contains("<!-- qwen-review-ledger "))]
| last // empty
| ((.body // "")
| capture("<!-- qwen-review-ledger (?<p>\\{.*\\}) -->")
| .p
| fromjson)?
| select(((.sha? // "") | tostring) | test("^[0-9a-f]{7,64}$"))
| "\(.sha)\t\(((.base // "") | tostring) | gsub("[\\x00-\\x1f\\x7f]"; ""))"'
)" || return
REVIEWED_SHA="${marker%%$'\t'*}"
reviewed_base="${marker#*$'\t'}"
REASON='no completed automatic round on this PR'
[[ -n "${REVIEWED_SHA}" ]] || return
if [[ "${reviewed_base}" != "${BASE_REF}" ]]; then

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.

Deferred to the follow-up queue — verified real (same disposition as this finding's sibling threads). The probe arm A reproduces at this head: a marker shaped as serializeLedger emits it (sha, no base) fails open with reviewed round certified against base 'unknown', not 'main', so skip=true is unreachable in production while the PR body says Closes #10111. The writer half (emit base beside sha, withheld whenever sha is withheld) lives in packages/cli, outside this PR's footprint, and pairs with R4-2's base-commit recording — recorded for the follow-up queue. Maintainer note: until it lands, the Closes #10111 keyword should be dropped so the issue stays open.

中文说明

延后至后续队列——已核实为真(与本发现同族线程同一处置)。探针 arm A 在本 head 复现:按 serializeLedger 实际输出形态的标记(有 sha、无 base)以 reviewed round certified against base 'unknown', not 'main' 向开放侧倒,因此生产中 skip=true 不可达,而 PR 正文写着 Closes #10111。写入端一半(在 sha 旁输出 base,且在 sha 被扣留时一并扣留)位于 packages/cli,在本 PR 足迹之外,且与 R4-2 的 base 提交记录配对——已记录到后续队列。提示 maintainer:在其落地前,应移除 Closes #10111 关键字,让 issue 保持打开。

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.

Stays deferred to the follow-up queue (first recorded in round 12). Re-verified at this head: the certification still keys on the ref name only, and the writer-side base-commit field still does not exist. The disposition is unchanged for the reason in the finding itself — no gate-only fix exists. The gate-side ancestor check (git merge-base --is-ancestor "$REVIEWED_BASE_SHA" "origin/$BASE_REF") only has meaning once the ledger writer emits the base commit, and that writer half lives in packages/cli, outside this PR's footprint and paired with the deferred R2-4. Shipping the gate half alone would add dead code keyed on an unpinned future field; the follow-up lands both halves plus the executed rebased_base fixture together. The hole is latent until then (no marker carries base, the gate never skips in production).

中文说明

继续保持延后处理,已记录至后续队列(第 12 轮首次记录)。已在本 head 上重新核实:认证仍仅以分支名为键,写入端 base 提交字段仍不存在。处置不变,原因即该发现自身所述——不存在仅门侧的修复。门侧祖先检查(git merge-base --is-ancestor "$REVIEWED_BASE_SHA" "origin/$BASE_REF")只有在台账写入端输出 base 提交后才有意义,而写入端位于本 PR 足迹之外的 packages/cli,并与已延后的 R2-4 配对。仅交付门侧一半会引入依赖未钉住的未来字段的死代码;后续工作将把两侧与执行夹具 rebased_base 一并落地。在此之前该漏洞处于潜伏状态(没有标记携带 base,门在生产中从不跳过)。

REASON="reviewed round certified against base '${reviewed_base:-unknown}', not '${BASE_REF}'"
return
fi
Comment on lines +184 to +187

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.

Deferred to the follow-up queue — verified real. serializeLedger (packages/cli/src/commands/review/lib/ledger.ts) emits no base at this commit, so the gate's base-equality check fails open for every production marker and skip=true stays unreachable until the writer half ships. The writer change lives in packages/cli, outside this PR's footprint, and pairs with R4-2's base-commit recording, so it is recorded as a focused follow-up rather than implemented this round. Until then the gate degrades to today's behavior (the full round runs), so nothing ships armed in the wrong direction. Maintainer note: the PR body still says Closes #10111 — that keyword should be dropped, or the writer half scheduled, since the issue's failure replays unchanged until the writer emits base.

中文说明

延后至后续队列——已核实为真。本提交上 serializeLedger(packages/cli/src/commands/review/lib/ledger.ts)不输出 base,因此对每条生产标记门的 base 相等检查都向开放侧倒,写入端一半落地前 skip=true 不可达。写入端改动位于 packages/cli,在本 PR 足迹之外,且与 R4-2 的 base 提交记录配对,故记录为专门的后续项而非本轮实现。在此之前门退化为今天的状态(完整轮照跑),不会有错误方向的武装状态落地。提示 maintainer:PR 正文仍写着 Closes #10111——应移除该关键字或为写入端一半排期,因为在写入端输出 base 之前,issue 记录的故障原样复现。

Comment on lines +184 to +187

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.

Deferred to the follow-up queue — verified real (same disposition as this finding's sibling threads). serializeLedger emits no base at this commit; the gate's base-equality check therefore fails open for every production marker, and the issue-10111 failure replays unchanged until the writer half ships. The writer change lives in packages/cli, outside this PR's footprint, and pairs with R4-2 — recorded for the follow-up queue. Maintainer note: the PR body's Closes #10111 keyword should be dropped, or the writer half scheduled, for the same reason.

中文说明

延后至后续队列——已核实为真(与本发现同族线程同一处置)。本提交上 serializeLedger 不输出 base;因此对每条生产标记门的 base 相等检查都向开放侧倒,在写入端一半落地前,issue 10111 的故障原样复现。写入端改动位于 packages/cli,在本 PR 足迹之外,且与 R4-2 配对——已记录到后续队列。提示 maintainer:同理,应移除 PR 正文中的 Closes #10111 关键字,或为写入端一半排期。

REASON='reviewed head not in the fetched history'
"${GIT_SAFE[@]}" cat-file -e "${REVIEWED_SHA}^{commit}" 2>/dev/null || return
REASON='reviewed head is not an ancestor of the pushed head'
"${GIT_SAFE[@]}" merge-base --is-ancestor "${REVIEWED_SHA}" \
"${EVENT_HEAD_SHA}" 2>/dev/null || return

# Bounded walk: a stale reviewed head must not buy an unbounded ancestry
# scan, and past ten first-parent steps this is not the cheap shape the
# gate exists for anyway.
local count c p2 clean_tree walked_tree
REASON='commit walk failed'
count="$("${GIT_SAFE[@]}" rev-list --first-parent --count \
"${REVIEWED_SHA}..${EVENT_HEAD_SHA}" 2>/dev/null)" || return
[[ "${count}" =~ ^[0-9]+$ ]] || return
REASON='no new commits since the reviewed head'
[[ "${count}" -ge 1 ]] || return
REASON="too many commits since the reviewed head (${count})"
[[ "${count}" -le 10 ]] || return
for c in $("${GIT_SAFE[@]}" rev-list --first-parent \
"${REVIEWED_SHA}..${EVENT_HEAD_SHA}" 2>/dev/null); do
REASON="non-merge commit since the reviewed head: ${c}"
p2="$("${GIT_SAFE[@]}" rev-parse -q --verify "${c}^2" 2>/dev/null)" || return
REASON="octopus merge since the reviewed head: ${c}"
if "${GIT_SAFE[@]}" rev-parse -q --verify "${c}^3" >/dev/null 2>&1; then
return
fi
REASON="merge of a non-base branch since the reviewed head: ${c}"
"${GIT_SAFE[@]}" merge-base --is-ancestor "${p2}" "origin/${BASE_REF}" \
2>/dev/null || return
# Parentage is not content: a commit-tree-crafted merge can carry the
# reviewed hunks at a position the offset-stripped digest cannot see,
# so require the walked tree to be its parents' clean merge; a git
# without --write-tree (< 2.38) fails open through the same || return.
REASON="walk commit tree deviates from the clean merge: ${c}"
clean_tree="$("${GIT_SAFE[@]}" merge-tree --write-tree "${c}^1" "${p2}" \
2>/dev/null)" || return
clean_tree="${clean_tree%%$'\n'*}"
walked_tree="$("${GIT_SAFE[@]}" rev-parse -q --verify "${c}^{tree}" \
2>/dev/null)" || return
[[ "${walked_tree}" = "${clean_tree}" ]] || return
done

local mb_r mb_h digest_r digest_h
REASON='merge-base resolution failed'
mb_r="$("${GIT_SAFE[@]}" merge-base "origin/${BASE_REF}" "${REVIEWED_SHA}" \
2>/dev/null)" || return
mb_h="$("${GIT_SAFE[@]}" merge-base "origin/${BASE_REF}" "${EVENT_HEAD_SHA}" \
2>/dev/null)" || return
REASON='PR-side diff computation failed'
digest_r="$(diff_digest "${mb_r}" "${REVIEWED_SHA}")" || return
digest_h="$(diff_digest "${mb_h}" "${EVENT_HEAD_SHA}")" || return
Comment on lines +237 to +238

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.

Deferred to the follow-up queue — verified real, pairs with R2-4. The probe shape reproduces: after a same-named base rewrite, the landed three-dot diff gains content the reviewed round never saw, and the gate still emits skip=true, because the marker carries no base-commit identity to compare. As the finding states, no gate-only fix exists — the information must ride the marker, and that writer change lives in packages/cli, outside this PR's footprint. It is tracked with R2-4's writer half in the follow-up queue; the gate-side ancestor check (git merge-base --is-ancestor "$REVIEWED_BASE_SHA" "origin/${BASE_REF}" || return, failing open) ships with it.

中文说明

延后至后续队列——已核实为真,与 R2-4 配对。探针形态复现:同名 base 被重写后,落地的三点 diff 新增了已评审轮从未见过的内容,而门仍输出 skip=true,因为标记中没有任何 base 提交身份可供比较。如该发现所述,不存在仅门侧的修复——该信息必须由标记携带,而该写入端改动位于 packages/cli,在本 PR 足迹之外。已与 R2-4 的写入端一半一并记录到后续队列;门侧祖先检查(git merge-base --is-ancestor "$REVIEWED_BASE_SHA" "origin/${BASE_REF}" || return,向开放侧倒)随其一并落地。

REASON='empty PR-side diff'
{ [[ -n "${digest_r}" ]] && [[ -n "${digest_h}" ]]; } || return
REASON='the PR-side diff changed'
[[ "${digest_r}" = "${digest_h}" ]] || return

REASON=''
SKIP=true
}
decide

{
echo "skip=${SKIP}"
echo "reviewed_sha=${REVIEWED_SHA}"
echo "reason=${REASON}"
} >> "${GITHUB_OUTPUT}"
if [[ "${SKIP}" != 'true' ]]; then
echo "Base-refresh gate: full round proceeds (${REASON})." >> "${GITHUB_STEP_SUMMARY}"
exit 0
fi
echo "Base-refresh gate: head ${EVENT_HEAD_SHA} only merges ${BASE_REF} into reviewed head ${REVIEWED_SHA}; skipping the automatic round." >> "${GITHUB_STEP_SUMMARY}"

# One marker-deduped note per PR, updated in place via the shared upsert
# helper (author-scoped lookup, retried). Blank line after the marker, or
# none of the prose renders — the HTML-block quirk the ack comment documents.
# Note failures only warn: the skip decision is already recorded above.
body_file="$(mktemp "${RUNNER_TEMP:-/tmp}/qwen-review-base-refresh.XXXXXX")" || exit 0
# shellcheck disable=SC2016
printf '<!-- qwen-review-base-refresh -->\n\n🔁 **Base refresh detected** — head `%s` only merges `%s` into the last reviewed head `%s`; the PR-side diff is unchanged, so that review still applies and no new automatic round was spent ([this run](%s)). Comment `@qwen-code /review` for a fresh full review.\n\n<details>\n<summary>中文说明</summary>\n\n🔁 **检测到 base 刷新** —— head `%s` 仅把 `%s` 合入上次已评审的 head `%s`,PR 侧 diff 未变,原有评审结论仍然适用,本次未消耗新的自动评审轮次([本次运行](%s))。如需全新完整评审,请评论 `@qwen-code /review`。\n\n</details>' \
"${EVENT_HEAD_SHA}" "${BASE_REF}" "${REVIEWED_SHA}" "${RUN_URL}" \
"${EVENT_HEAD_SHA}" "${BASE_REF}" "${REVIEWED_SHA}" "${RUN_URL}" > "${body_file}"
"$(dirname "${BASH_SOURCE[0]}")/upsert-bot-comment.sh" \

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.

Stays deferred to the follow-up queue (first recorded in round 12). Verified again at this head: qwen-review-base-refresh occurs 0 times in .github/workflows/qwen-autofix.yml, while the note this gate posts is authored by the REVIEW_BOT account and would count as actionable feedback. The fix — adding the marker to the exclusion alternation at every REVIEW_BOT-admitting filter site, plus the static assertion pairing it with the qwen-review docs-only-medium exclusion — lives entirely in qwen-autofix.yml: outside this PR's diff, and inside the autofix loop's own workflow area, which this PR's review rounds must not modify. It remains recorded for the follow-up queue. The waste stays latent until the writer follow-up lands: no writer emits base today, so the gate cannot skip and the note cannot post in production.

中文说明

继续保持延后处理,已记录至后续队列(第 12 轮首次记录)。已在本 head 上再次核实:qwen-review-base-refresh 在 .github/workflows/qwen-autofix.yml 中出现 0 次,而本门发布的说明恰由 REVIEW_BOT 账号发出,会被计为可执行反馈。修复方案——在每处接纳 REVIEW_BOT 的过滤器位点把该标记加入排除选项组,外加将其与 qwen-review docs-only-medium 排除配对的静态断言——完全位于 qwen-autofix.yml:既在本 PR diff 之外,又属于 autofix 循环自身的工作流区域,本 PR 的评审轮次不得修改该区域。该项继续记录在后续队列中。在写入端后续落地之前该浪费保持潜伏:今天没有写入端输出 base,门无法跳过,说明也不可能在生产中发出。

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.

Stays deferred to the follow-up queue (first recorded in round 12). Disposition unchanged from the round-12 thread: the defect is verified (zero occurrences of the marker in qwen-autofix.yml at this head, re-grepped), but the entire fix is an edit to .github/workflows/qwen-autofix.yml — outside this PR's footprint and inside the autofix loop's own workflow area, which review rounds on this PR are not permitted to modify. The follow-up queue entry carries the fix shape: add qwen-review-base-refresh (trailing space, matching the exclusion regex) to every actionable-feedback filter admitting REVIEW_BOT issue comments, and add the static assertion so dropping the marker from BOT_COMMENT_FILTER turns the suite red.

中文说明

继续保持延后处理,已记录至后续队列(第 12 轮首次记录)。处置与第 12 轮线程相同:缺陷已核实(本 head 上该标记在 qwen-autofix.yml 中出现零次,已重新扫描确认),但整个修复都是对 .github/workflows/qwen-autofix.yml 的编辑——位于本 PR 足迹之外,且属于 autofix 循环自身的工作流区域,本 PR 的评审轮次不得修改。后续队列条目已记录修复形态:在每处接纳 REVIEW_BOT issue 评论的可执行反馈过滤器中加入 qwen-review-base-refresh (带尾随空格,与排除正则形态一致),并新增静态断言,使从 BOT_COMMENT_FILTER 中去掉该标记时测试套件变红。

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.

Stays deferred to the follow-up queue (first recorded in round 12). Verified at this head as in rounds 12–13: the marker appears 0 times in qwen-autofix.yml. This round's gate-script changes (planted-config class closure, -U3 digest pin, marker fall-through fix) do not touch the note path's filter interaction, so the disposition is unchanged: the fix is a qwen-autofix.yml-only edit — outside this PR's footprint and inside the autofix loop's own workflow area, off-limits to this PR's review rounds — and it stays recorded for the follow-up queue with its acceptance criterion (the static assertion pairing the new marker with the docs-only exclusion). Latent until the writer follow-up lands: with no writer emitting base, the gate cannot skip and the note cannot post in production.

中文说明

继续保持延后处理,已记录至后续队列(第 12 轮首次记录)。本 head 上的核实结果与第 12–13 轮一致:该标记在 qwen-autofix.yml 中出现 0 次。本轮门脚本改动(植入配置类封闭、-U3 摘要钉住、标记回退修复)不涉及说明路径与过滤器的交互,因此处置不变:修复是仅针对 qwen-autofix.yml 的编辑——位于本 PR 足迹之外,且属于 autofix 循环自身的工作流区域,本 PR 的评审轮次不得触碰——该项继续连同其验收标准(将新标记与 docs-only 排除配对的静态断言)记录在后续队列中。在写入端后续落地之前保持潜伏:没有写入端输出 base,门无法跳过,说明也不可能在生产中发出。

"${GITHUB_REPOSITORY}" "${PR_NUMBER}" '<!-- qwen-review-base-refresh -->' "${body_file}" \

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.

Deferred to the follow-up queue — verified real. qwen-review-base-refresh appears in none of qwen-autofix.yml's actionable-feedback filters at this head (checked BOT_COMMENT_FILTER at line 3404 and the inline copies), so an engaged PR receiving the note spends a full no-action round per base refresh once the gate can skip. The fix (add the marker to every filter copy admitting REVIEW_BOT issue comments, plus a static assertion pairing it with the docs-only exclusion) lives in qwen-autofix.yml — the autofix loop's own workflow, outside this PR's footprint and a protected area — so it is recorded for the follow-up queue rather than implemented here.

中文说明

延后至后续队列——已核实为真。本 head 上 qwen-review-base-refresh 未出现在 qwen-autofix.yml 的任何可执行反馈过滤器中(已检查第 3404 行的 BOT_COMMENT_FILTER 与各内联副本),因此一旦门可以跳过,收到该说明的被接管 PR 会在每次 base 刷新时消耗一整轮"无需操作"的轮次。修复(把该标记加入所有接纳 REVIEW_BOT issue 评论的过滤器副本,并新增与仅文档排除配对的静态断言)位于 qwen-autofix.yml——autofix 循环自己的 workflow,在本 PR 足迹之外且属受保护区域——故记录到后续队列,不在此实现。

|| echo "::warning::could not post the base-refresh note"
rm -f "${body_file}"
exit 0
37 changes: 33 additions & 4 deletions .github/workflows/qwen-code-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,43 @@ jobs:
echo "auto_review=$AUTO_REVIEW"
} >> "$GITHUB_OUTPUT"

# An update-branch base refresh (merging current main into the PR
# branch) fires `synchronize` like any push, but adds nothing on the
# PR side — and a full automatic round costs hours (#10111: two base
# refreshes on PR #9729 spent one full round plus one cancelled one).
# The script certifies that shape deterministically (pure base-merge
# chain since the last submitted ledger-marked reviewed head,
# PR-side diff unchanged apart from hunk offsets and index lines)
# and posts one marker-deduped note when it
# skips; its full contract lives in its header. Everything fails OPEN
# into the full round — the script never exits non-zero (a step
# failure would be misreported as a pipeline failure by the fallback
# comment) and continue-on-error is the belt for an unexpected crash.
- name: 'Skip base-refresh-only synchronize'
id: 'base_refresh'
if: |-
steps.context.outputs.should_run == 'true' &&
steps.context.outputs.auto_review == 'true' &&
github.event.action == 'synchronize'
continue-on-error: true
timeout-minutes: 5
env:
GH_TOKEN: '${{ secrets.CI_BOT_PAT }}'
PR_NUMBER: '${{ steps.context.outputs.pr_number }}'
EVENT_HEAD_SHA: '${{ github.event.pull_request.head.sha }}'
BASE_REF: '${{ github.event.pull_request.base.ref }}'
RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
run: |-
.github/scripts/review-base-refresh-gate.sh

- name: 'Setup Node.js for hosted review'
if: "steps.context.outputs.should_run == 'true' && (github.repository != 'QwenLM/qwen-code' || vars.MAINTAINER_ECS_RUNNER_DISABLED == 'true')"
if: "steps.context.outputs.should_run == 'true' && steps.base_refresh.outputs.skip != 'true' && (github.repository != 'QwenLM/qwen-code' || vars.MAINTAINER_ECS_RUNNER_DISABLED == 'true')"
uses: 'actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e' # v6.4.0
with:
node-version: '22.x'

- name: 'Install Qwen CLI if missing'
if: "steps.context.outputs.should_run == 'true'"
if: "steps.context.outputs.should_run == 'true' && steps.base_refresh.outputs.skip != 'true'"
run: |-
set -euo pipefail
if command -v qwen >/dev/null 2>&1; then
Expand All @@ -775,7 +804,7 @@ jobs:
# inside (set +e, trailing exit 0) are its suspenders. It only decides
# which rung this runner can reach.
- name: 'Install capture tools (tmux + freeze)'
if: "steps.context.outputs.should_run == 'true'"
if: "steps.context.outputs.should_run == 'true' && steps.base_refresh.outputs.skip != 'true'"
continue-on-error: true
# continue-on-error bounds failure, not duration: a hung `sudo
# apt-get update` against a stalled mirror has no other bound and
Expand Down Expand Up @@ -926,7 +955,7 @@ jobs:

- name: 'Run review'
id: 'review'
if: "steps.context.outputs.should_run == 'true'"
if: "steps.context.outputs.should_run == 'true' && steps.base_refresh.outputs.skip != 'true'"
env:
GH_TOKEN: '${{ secrets.CI_BOT_PAT }}'
OPENAI_API_KEY: '${{ secrets.REVIEW_OPENAI_API_KEY }}'
Expand Down
Loading
Loading