Skip to content

Commit 067635c

Browse files
authored
fix(ui): prevent generated locale rebase conflicts (#109393)
* ci(ui): make locale refresh bot-owned * test(ui): keep locale gate coverage scoped * fix(ci): preserve generated PR merge policy * fix(ci): wait for generated PR head convergence * fix(ci): retry transient guard API failures * fix(ci): enforce locale isolation across CI events * fix(ci): harden generated PR publication * fix(ci): validate release gate merge tree * fix(ci): allow trusted main locale output
1 parent 172c63d commit 067635c

26 files changed

Lines changed: 817 additions & 556 deletions

‎.github/actions/publish-generated-pr/action.yml‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ inputs:
4343
description: Whether stale inputs or owned-path overlap defer to a successor run or fail.
4444
required: false
4545
default: defer
46+
auto-merge:
47+
description: Enable squash auto-merge; false rejects an inherited auto-merge request.
48+
required: false
49+
default: "false"
4650

4751
runs:
4852
using: composite
@@ -70,6 +74,7 @@ runs:
7074
GENERATED_PATHS: ${{ inputs.generated-paths }}
7175
INVALIDATION_PATHS: ${{ inputs.invalidation-paths }}
7276
OVERLAP_POLICY: ${{ inputs.overlap-policy }}
77+
AUTO_MERGE: ${{ inputs.auto-merge }}
7378
run: |
7479
set -euo pipefail
7580
export GH_PROMPT_DISABLED=1
@@ -93,6 +98,13 @@ runs:
9398
exit 1
9499
;;
95100
esac
101+
case "${AUTO_MERGE}" in
102+
true | false) ;;
103+
*)
104+
echo "Generated PR publication auto-merge must be 'true' or 'false'." >&2
105+
exit 1
106+
;;
107+
esac
96108
97109
generated_paths=()
98110
while IFS= read -r generated_path; do
@@ -321,6 +333,7 @@ runs:
321333
if [[ -n "${final_pr_url}" ]]; then
322334
final_pr_head="${final_pr_record#*$'\t'}"
323335
if [[ "${final_pr_head}" = "${published_commit}" ]]; then
336+
published_pr_url="${final_pr_url}"
324337
echo "Generated pull request: ${final_pr_url}" >> "${GITHUB_STEP_SUMMARY}"
325338
return 0
326339
fi
@@ -343,6 +356,99 @@ runs:
343356
echo "::error::Generated branch has no open same-repository pull request."
344357
return 1
345358
}
359+
read_auto_merge_record_for_head() {
360+
local attempt auto_merge_record observed_head
361+
local expected_head="$1"
362+
local pr_url="$2"
363+
for attempt in 1 2 3; do
364+
auto_merge_record="$(
365+
timeout --signal=TERM --kill-after=10s 60s \
366+
gh pr view "${pr_url}" --repo "${GITHUB_REPOSITORY}" \
367+
--json autoMergeRequest,headRefOid \
368+
--jq '[.headRefOid, (.autoMergeRequest.mergeMethod // "")] | @tsv'
369+
)"
370+
observed_head="${auto_merge_record%%$'\t'*}"
371+
if [[ "${observed_head}" = "${expected_head}" ]]; then
372+
printf '%s\n' "${auto_merge_record}"
373+
return 0
374+
fi
375+
if [[ "${attempt}" -eq 3 ]]; then
376+
return 1
377+
fi
378+
echo "::notice::Generated pull request head has not converged yet; rechecking." >&2
379+
sleep "${attempt}"
380+
done
381+
}
382+
ensure_auto_merge_compatible() {
383+
local attempt auto_merge_method auto_merge_record existing_pr_head existing_pr_record
384+
local existing_pr_url
385+
local expected_head="$1"
386+
for attempt in 1 2 3; do
387+
existing_pr_record="$(find_open_pr)"
388+
existing_pr_url="${existing_pr_record%%$'\t'*}"
389+
if [[ -z "${existing_pr_url}" ]]; then
390+
return 0
391+
fi
392+
existing_pr_head="${existing_pr_record#*$'\t'}"
393+
if [[ "${existing_pr_head}" = "${expected_head}" ]]; then
394+
break
395+
fi
396+
if [[ "${attempt}" -eq 3 ]]; then
397+
echo "::error::Generated pull request head does not match the observed automation branch."
398+
return 1
399+
fi
400+
echo "::notice::Generated pull request head has not converged yet; rechecking."
401+
sleep "${attempt}"
402+
done
403+
if ! auto_merge_record="$(
404+
read_auto_merge_record_for_head "${expected_head}" "${existing_pr_url}"
405+
)"; then
406+
echo "::error::Generated pull request moved during auto-merge compatibility validation."
407+
return 1
408+
fi
409+
auto_merge_method="${auto_merge_record#*$'\t'}"
410+
if [[ "${AUTO_MERGE}" != "true" && -n "${auto_merge_method}" ]]; then
411+
echo "::error::Generated pull request still has auto-merge enabled while publication opted out."
412+
return 1
413+
fi
414+
if [[ -n "${auto_merge_method}" && "${auto_merge_method}" != "SQUASH" ]]; then
415+
echo "::error::Generated pull request already uses incompatible ${auto_merge_method} auto-merge."
416+
return 1
417+
fi
418+
}
419+
enable_auto_merge() {
420+
local auto_merge_method auto_merge_record current_remote_head
421+
if [[ "${AUTO_MERGE}" != "true" || -z "${published_pr_url:-}" ]]; then
422+
return 0
423+
fi
424+
if ! auto_merge_record="$(
425+
read_auto_merge_record_for_head "${published_commit}" "${published_pr_url}"
426+
)"; then
427+
current_remote_head="$(read_remote_head)"
428+
if [[ "${current_remote_head}" != "${published_commit}" ]]; then
429+
echo "Generated pull request moved before auto-merge reconciliation." \
430+
>> "${GITHUB_STEP_SUMMARY}"
431+
return 0
432+
fi
433+
echo "::error::Generated pull request head did not converge for auto-merge reconciliation."
434+
return 1
435+
fi
436+
auto_merge_method="${auto_merge_record#*$'\t'}"
437+
if [[ "${auto_merge_method}" = "SQUASH" ]]; then
438+
echo "Squash auto-merge already enabled for generated pull request: ${published_pr_url}" \
439+
>> "${GITHUB_STEP_SUMMARY}"
440+
return 0
441+
fi
442+
if [[ -n "${auto_merge_method}" ]]; then
443+
echo "::error::Generated pull request already uses incompatible ${auto_merge_method} auto-merge."
444+
return 1
445+
fi
446+
timeout --signal=TERM --kill-after=10s 60s \
447+
gh pr merge "${published_pr_url}" --repo "${GITHUB_REPOSITORY}" \
448+
--auto --squash --match-head-commit "${published_commit}"
449+
echo "Enabled squash auto-merge for exact generated head: ${published_pr_url}" \
450+
>> "${GITHUB_STEP_SUMMARY}"
451+
}
346452
347453
source_commit="$(git rev-parse HEAD)"
348454
git config user.name "github-actions[bot]"
@@ -388,6 +494,7 @@ runs:
388494
389495
# Lease the exact observed automation head so a cancelled run cannot overwrite newer output.
390496
remote_head="$(read_remote_head)"
497+
ensure_auto_merge_compatible "${remote_head}"
391498
push_log="${RUNNER_TEMP}/generated-pr-push.log"
392499
if ! push_generated_branch "${remote_head}"; then
393500
current_remote_head="$(read_remote_head)"
@@ -455,3 +562,4 @@ runs:
455562
fi
456563
exit 1
457564
fi
565+
enable_auto_merge

‎.github/workflows/ci.yml‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
run_format_check: ${{ steps.manifest.outputs.run_format_check }}
121121
compatibility_target: ${{ steps.manifest.outputs.compatibility_target }}
122122
run_control_ui_i18n: ${{ steps.manifest.outputs.run_control_ui_i18n }}
123+
strict_control_ui_i18n: ${{ steps.changed_scope.outputs.strict_control_ui_i18n }}
123124
run_ui_tests: ${{ steps.manifest.outputs.run_ui_tests }}
124125
run_native_i18n: ${{ steps.manifest.outputs.run_native_i18n }}
125126
run_checks_windows: ${{ steps.manifest.outputs.run_checks_windows }}
@@ -248,16 +249,34 @@ jobs:
248249
id: diff_base
249250
env:
250251
EVENT_BASE_SHA: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha || '' }}
252+
PULL_REQUEST_NUMBER: ${{ inputs.pull_request_number }}
253+
RELEASE_GATE: ${{ inputs.release_gate }}
251254
run: |
252255
set -euo pipefail
253256
base_sha="$EVENT_BASE_SHA"
257+
head_sha="$(git rev-parse HEAD)"
254258
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
255259
# A long-lived PR event can retain an old base SHA. The tested merge
256260
# commit's first parent is the exact target tree for this run.
257261
base_sha="$(node scripts/lib/merge-head-diff-base.mjs \
258262
--base "$base_sha" --head HEAD --prefer-first-parent)"
259263
fi
264+
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ] && [ "$RELEASE_GATE" = "true" ]; then
265+
merge_ref="refs/remotes/origin/release-gate-merge"
266+
timeout --signal=TERM --kill-after=10s 120s git fetch \
267+
--no-tags --no-recurse-submodules --depth=2 origin \
268+
"+refs/pull/${PULL_REQUEST_NUMBER}/merge:${merge_ref}"
269+
release_gate_head="$(git rev-parse "${merge_ref}^2")"
270+
target_head="$(git rev-parse HEAD)"
271+
if [ "$release_gate_head" != "$target_head" ]; then
272+
echo "release_gate pull request head ${release_gate_head} does not match target ${target_head}" >&2
273+
exit 1
274+
fi
275+
base_sha="$(git rev-parse "${merge_ref}^1")"
276+
head_sha="$(git rev-parse "$merge_ref")"
277+
fi
260278
echo "sha=$base_sha" >> "$GITHUB_OUTPUT"
279+
echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT"
261280
262281
- name: Validate historical release target
263282
id: historical_target
@@ -319,17 +338,23 @@ jobs:
319338

320339
- name: Detect changed scopes
321340
id: changed_scope
322-
if: github.event_name != 'workflow_dispatch' && steps.docs_scope.outputs.docs_only != 'true'
341+
if: (github.event_name != 'workflow_dispatch' && steps.docs_scope.outputs.docs_only != 'true') || (github.event_name == 'workflow_dispatch' && inputs.release_gate)
323342
shell: bash
343+
env:
344+
OPENCLAW_ALLOW_RELEASE_GENERATED_MIX: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository }}
324345
run: |
325346
set -euo pipefail
326347
327348
if [ "${{ github.event_name }}" = "push" ]; then
328349
BASE="${{ steps.diff_base.outputs.sha }}"
329350
node scripts/ci-changed-scope.mjs --base "$BASE" --head HEAD
330-
else
351+
elif [ "${{ github.event_name }}" = "pull_request" ]; then
331352
BASE="${{ steps.diff_base.outputs.sha }}"
332353
node scripts/ci-changed-scope.mjs --base "$BASE" --head HEAD --merge-head-first-parent
354+
else
355+
BASE="${{ steps.diff_base.outputs.sha }}"
356+
HEAD_SHA="${{ steps.diff_base.outputs.head_sha }}"
357+
node scripts/ci-changed-scope.mjs --base "$BASE" --head "$HEAD_SHA"
333358
fi
334359
335360
- name: Build CI manifest
@@ -1232,9 +1257,9 @@ jobs:
12321257
name: control-ui-i18n
12331258
needs: [preflight]
12341259
if: needs.preflight.outputs.run_control_ui_i18n == 'true'
1235-
# Locale refresh runs separately on main and nightly. Keep drift visible on
1236-
# automatic runs without blocking unrelated work; release CI stays strict.
1237-
continue-on-error: ${{ github.event_name != 'workflow_dispatch' }}
1260+
# Source PR drift stays advisory because the post-merge bot owns repair.
1261+
# Generated locale PRs and release CI must pass the strict catalog gate.
1262+
continue-on-error: ${{ github.event_name != 'workflow_dispatch' && needs.preflight.outputs.strict_control_ui_i18n != 'true' }}
12381263
runs-on: ${{ github.event_name == 'workflow_dispatch' && 'ubuntu-24.04' || (github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04') }}
12391264
timeout-minutes: 10
12401265
steps:

‎.github/workflows/control-ui-locale-refresh.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ jobs:
296296
head-branch: automation/control-ui-locale-refresh
297297
commit-message: "chore(ui): refresh control ui locales"
298298
pr-title: "chore(ui): refresh control ui locales"
299+
auto-merge: "true"
299300
generated-paths: ui/src/i18n
300301
invalidation-paths: |
301302
ui/src/i18n/locales/en.ts

‎docs/ci.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Standalone Periphery workflows enforce zero dead-code findings for the iOS and m
6060
1. `runner-admission` waits only for canonical `main` pushes; a newer push cancels the run before Blacksmith registration.
6161
2. `preflight` decides which lanes exist at all. The `docs-scope` and `changed-scope` logic are steps inside this job, not standalone jobs.
6262
3. `security-fast`, `check-*`, `check-additional-*`, `check-docs`, and `skills-python` fail quickly without waiting on the heavier artifact and platform matrix jobs.
63-
4. `build-artifacts` and the advisory `control-ui-i18n` check overlap with the fast Linux lanes. Generated locale drift stays visible while the standalone refresh workflow repairs it in the background.
63+
4. `build-artifacts` and the advisory `control-ui-i18n` check overlap with the fast Linux lanes. Source PRs exclude generated locale snapshots; the standalone refresh workflow repairs and auto-merges an isolated generated PR in the background. Canonical `release/YYYY.M.PATCH` branches may include release-prep locale repairs with the other generated release output.
6464
5. Heavier platform and runtime lanes fan out after that: `checks-fast-core`, `checks-fast-contracts-plugins-*`, `checks-fast-contracts-channels-*`, `checks-node-*`, `checks-windows`, `macos-node`, `macos-swift`, `ios-build`, and `android`.
6565
6. `openclaw/ci-gate` waits for every selected lane. Admission, preflight, and security must succeed; downstream jobs may skip only when the manifest did not select them. A failed or canceled selected lane fails the aggregate.
6666

@@ -148,7 +148,7 @@ Treat GitHub titles, comments, bodies, review text, branch names, and commit mes
148148

149149
## Manual dispatches
150150

151-
Manual CI dispatches run the same job graph as normal CI but force every non-Android scoped lane on: Linux Node shards, bundled-plugin shards, plugin and channel contract shards, Node 22 compatibility, `check-*`, `check-additional-*`, built-artifact smoke checks, docs checks, Python skills, Windows, macOS, iOS build, and Control UI i18n. Control UI locale parity is advisory on automatic PR and `main` runs because the standalone refresh workflow repairs generated drift in the background; it is blocking on manual CI and therefore on Full Release Validation. Standalone manual CI dispatches run Android only with `include_android=true` (the `release_gate` input also forces Android); the full release umbrella enables Android by passing `include_android=true`. Plugin prerelease static checks, the release-only `agentic-plugins` shard, the full extension batch sweep, and plugin prerelease Docker lanes are excluded from CI. The Docker prerelease suite runs only when `Full Release Validation` dispatches the separate `Plugin Prerelease` workflow with the release-validation gate enabled.
151+
Manual CI dispatches run the same job graph as normal CI but force every non-Android scoped lane on: Linux Node shards, bundled-plugin shards, plugin and channel contract shards, Node 22 compatibility, `check-*`, `check-additional-*`, built-artifact smoke checks, docs checks, Python skills, Windows, macOS, iOS build, and Control UI i18n. Control UI locale parity is advisory on automatic PR and `main` runs because the standalone refresh workflow repairs generated drift in the background; it is blocking on manual CI and therefore on Full Release Validation. Release prep runs the same locale sync before the Code SHA is frozen, then verifies the strict zero-fallback state. Standalone manual CI dispatches run Android only with `include_android=true` (the `release_gate` input also forces Android); the full release umbrella enables Android by passing `include_android=true`. Plugin prerelease static checks, the release-only `agentic-plugins` shard, the full extension batch sweep, and plugin prerelease Docker lanes are excluded from CI. The Docker prerelease suite runs only when `Full Release Validation` dispatches the separate `Plugin Prerelease` workflow with the release-validation gate enabled.
152152

153153
PR max-lines checks derive the baseline from the checked-out synthetic merge tree and verify its head parent against the event head. Manual runs use a unique concurrency group so a release-candidate full suite is not cancelled by another push or PR run on the same ref. The optional `target_ref` input lets a trusted caller run that graph against a branch, tag, or full commit SHA while using the workflow file from the selected dispatch ref; the max-lines baseline is compared with the target's merge base against the default-branch head resolved for that run. The `release_gate` input is an exact-SHA maintainer fallback for capacity-stalled PR CI: it requires `target_ref` to be a full commit SHA that matches the dispatched branch head and `pull_request_number` to identify the open PR whose merge tree is validated.
154154

‎docs/reference/RELEASING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ A legacy fallback correction tag may reuse base-package evidence only when the c
212212
- Run `pnpm check:test-types` before release preflight so test TypeScript stays covered outside the faster local `pnpm check` gate.
213213
- Run `pnpm check:architecture` before release preflight so the broader import cycle and architecture boundary checks are green outside the faster local gate.
214214
- Run `pnpm build && pnpm ui:build` before `pnpm release:check` so the expected `dist/*` release artifacts and Control UI bundle exist for the pack validation step.
215-
- Run `pnpm release:prep` after the root version bump and before tagging. It runs every deterministic release generator that commonly drifts after a version/config/API change: plugin versions, npm shrinkwraps, plugin inventory, base config schema, bundled channel config metadata, config docs baseline, plugin SDK exports, and plugin SDK API baseline. `pnpm release:check` re-runs those guards in check mode (plus a plugin SDK surface budget check) and reports every generated drift failure in one pass before running package release checks.
215+
- Run `pnpm release:prep` after the root version bump and before tagging. It runs every deterministic release generator that commonly drifts after a version/config/API change: plugin versions, npm shrinkwraps, plugin inventory, base config schema, bundled channel config metadata, config docs baseline, plugin SDK exports, plugin SDK API baseline, and Control UI locale bundles. `pnpm release:check` re-runs those guards in check mode (including the strict zero-fallback locale gate plus the plugin SDK surface budget) and reports every generated drift failure in one pass before running package release checks.
216216
- Plugin version sync updates the publishable `@openclaw/ai` runtime package, official plugin package versions, and existing `openclaw.compat.pluginApi` floors to the OpenClaw release version by default. Treat that field as the plugin SDK/runtime API floor, not just a copy of the package version: for plugin-only releases that intentionally remain compatible with older OpenClaw hosts, keep the floor at the oldest supported host API and document that choice in the plugin release proof.
217217
- Run the manual `Full Release Validation` workflow before release approval to kick off all pre-release test boxes from one entrypoint. It accepts a branch, tag, or full commit SHA, dispatches manual `CI`, and dispatches `OpenClaw Release Checks` for install smoke, package acceptance, cross-OS package checks, QA Lab parity, Matrix, and Telegram lanes. Stable and full runs always include exhaustive live/E2E and Docker release-path soak; `run_release_soak=true` is retained for an explicit beta soak. Package Acceptance provides the canonical package Telegram E2E during candidate validation, avoiding a second concurrent live poller.
218218

‎docs/reference/full-release-validation.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ read_when:
99

1010
`Full Release Validation` is the release product-validation umbrella. Most work
1111
happens in child workflows so a failed box can be rerun without restarting the
12-
whole release.
12+
whole release. Run release preparation before freezing the Code SHA; it
13+
refreshes Control UI locale output when the background bot has not landed it
14+
yet, then enforces the same strict zero-fallback check used by release CI.
1315

1416
Freeze the product-complete pre-changelog commit as the **Code SHA**, then run:
1517

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,6 @@
20102010
"ui:i18n:baseline": "node --import tsx scripts/control-ui-i18n-verify.ts baseline",
20112011
"ui:i18n:check": "node --import tsx scripts/control-ui-i18n.ts check",
20122012
"ui:i18n:report": "node --import tsx scripts/control-ui-i18n-report.ts",
2013-
"ui:i18n:resolve-conflicts": "node --import tsx scripts/control-ui-i18n-resolve-conflicts.ts",
20142013
"ui:i18n:sync": "node --import tsx scripts/control-ui-i18n.ts sync --write",
20152014
"ui:i18n:verify": "node --import tsx scripts/control-ui-i18n-verify.ts verify",
20162015
"native:i18n:check": "node --import tsx scripts/native-app-i18n.ts check",

0 commit comments

Comments
 (0)