From 44808dc5961336e9186be97c9ce2f31bb99a84e1 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Sun, 15 Nov 2026 12:23:29 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20ci(v6-topup):=20never=20auto-dro?= =?UTF-8?q?p=20v5=20changes=20to=20the=20split=20config.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The resolver kept v6's side of any src/pkg/config/config.go conflict. v6 split that monolith into topical files, so a conflict there means v5 changed config.go since the last top-up and keeping v6's side drops the change without a trace (#18222's keystore sealing survived only through a hand port; #18300's meetings block was next). config.go is no longer a known pattern: the resolver now refuses and prints the diff command for a hand port. The manifest path check for the index.html regeneration now matches webstatic.ParseIndexManifest's clean-relative-path rule. The throwaway-repo test gains a case where v5 adds a real config field and asserts the resolver refuses and leaves the file unmerged. Signed-off-by: Andy Anderson --- .github/scripts/test-v6-topup-autoresolve.sh | 29 ++++++++++++++++++-- .github/scripts/v6-topup-autoresolve.sh | 29 ++++++++++++++------ .github/workflows/v6-topup.yml | 3 +- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/.github/scripts/test-v6-topup-autoresolve.sh b/.github/scripts/test-v6-topup-autoresolve.sh index 46ea8ae185..1e37b1c954 100755 --- a/.github/scripts/test-v6-topup-autoresolve.sh +++ b/.github/scripts/test-v6-topup-autoresolve.sh @@ -63,7 +63,6 @@ case_all_known() { echo v5bot > discord/bot.go printf '# Changelog\n\n## Unreleased\n\n## 1.1.0 (v5)\n\n- v5 entry\n\n## 1.0.0\n\n- base\n' > CHANGELOG.md echo v5 > src/scripts/b.sh - echo 'package config // v5 monolith edit' > src/pkg/config/config.go echo A5 > src/pkg/dashboard/static-src/a.html printf 'A5\nB\n' > src/pkg/dashboard/static/index.html git add -A && git commit -qm v5 && finish_pin v5 @@ -79,7 +78,7 @@ case_all_known() { bash "$RESOLVER" git commit -q --no-edit [ ! -e discord/bot.go ] || { echo "discord not deleted"; return 1; } - grep -q 'v6 slim' src/pkg/config/config.go || { echo "config.go not v6"; return 1; } + grep -q 'v6 slim' src/pkg/config/config.go || { echo "config.go lost v6's one-sided edit"; return 1; } grep -q '6.1.0 (v6)' CHANGELOG.md && grep -q '1.1.0 (v5)' CHANGELOG.md || { echo "changelog lost a side"; return 1; } ! grep -qE '^(<<<<<<<|=======|>>>>>>>)' CHANGELOG.md .github/scripts/integration-governance.cjs || { echo "markers left"; return 1; } [ "$(cat src/pkg/dashboard/static/index.html)" = "$(printf 'A5\nB6')" ] || { echo "index not regenerated"; return 1; } @@ -106,7 +105,33 @@ case_pin_file_real_edit() { bash "$RESOLVER" } +# v5 adds a real field to the monolith config.go while v6 has split it. The +# resolver must refuse (keeping v6's side would drop the field silently) and +# must leave config.go unmerged for the human, even when every other conflict +# is a known pattern. +case_config_real_field() { + new_repo "$WORK/config" && cd "$WORK/config" + printf 'package config // base\n\ntype Config struct {\n\tMeetings MeetingsConfig `yaml:"meetings"`\n}\n' > src/pkg/config/config.go + printf '# Changelog\n\n## Unreleased\n\n## 1.1.0 (v5)\n\n- v5 entry\n\n## 1.0.0\n\n- base\n' > CHANGELOG.md + git commit -qam "v5 adds a config field" + git checkout -q v6 + echo 'package config // v6 slim (structs moved to types.go)' > src/pkg/config/config.go + printf '# Changelog\n\n## Unreleased\n\n## 6.1.0 (v6)\n\n- v6 entry\n\n## 1.0.0\n\n- base\n' > CHANGELOG.md + git commit -qam "v6 splits config.go" + git merge --no-ff -q v5 -m merge >/dev/null 2>&1 && { echo "expected conflicts"; return 1; } + # Exit 0 here means the resolver accepted the conflict, which is the bug; + # `expect ... fail` turns that into a test failure. + local out rc=0 + out="$(bash "$RESOLVER" 2>&1)" || rc=$? + printf '%s\n' "$out" + [ "$rc" -ne 0 ] || return 0 + git status --porcelain | grep -q '^UU src/pkg/config/config.go$' || { echo "config.go was resolved"; return 0; } + printf '%s\n' "$out" | grep -q 'port v5.s change by hand' || { echo "no hand-port hint"; return 0; } + return 1 +} + expect all-known-patterns-resolve ok case_all_known +expect config-go-real-field-refused fail case_config_real_field expect unknown-conflict-refused fail case_unknown_conflict expect pin-file-real-edit-refused fail case_pin_file_real_edit diff --git a/.github/scripts/v6-topup-autoresolve.sh b/.github/scripts/v6-topup-autoresolve.sh index faa9333b54..252ddb5f45 100755 --- a/.github/scripts/v6-topup-autoresolve.sh +++ b/.github/scripts/v6-topup-autoresolve.sh @@ -10,8 +10,6 @@ # Known patterns: # - DU discord/** and DU/UD .github/workflows/discord-syntax.yml: v6 removed # discord/ (#9277) while v5 still develops it. Keep v6's deletion. -# - UU src/pkg/config/config.go: v6 split the monolith into topical files -# (#9386, #9956). Keep v6's side. # - UU CHANGELOG.md: both lines prepend their own release sections under # "## Unreleased" on every release, so the top of the file conflicts on # almost every top-up. Keep both sides' lines (v6's block first, then @@ -25,6 +23,17 @@ # it as the byte-exact concatenation of static-src/manifest.txt (what # webstatic.ConcatIndex and TestIndexHTMLIsGenerated do), provided no # static-src file is itself conflicted. +# +# Deliberately NOT a known pattern: +# - UU src/pkg/config/config.go. v6 split the monolith into topical files +# (#9386, #9956), and an earlier version of this script kept v6's side of +# any config.go conflict. A conflict there means v5 changed config.go since +# the last top-up, and keeping v6's side drops that change without a trace: +# #18222's keystore sealing survived only because it was hand-ported into +# v6's load.go/save.go. A config.go conflict always goes to a human, who +# ports v5's change into the matching split file. Whether v6 already has an +# equivalent change cannot be decided mechanically (the code moved), so +# there is no "safe subset" to auto-resolve. set -euo pipefail PIN_FILE=.github/scripts/integration-governance.cjs @@ -35,10 +44,14 @@ PIN_RE="^const TRUSTED_SCRIPTS_TREE = '[0-9a-f]{40}';\$" unmerged="$(git status --porcelain | grep -E '^(DD|AU|UD|UA|DU|AA|UU) ' || true)" [ -n "$unmerged" ] || { echo "v6-topup-autoresolve: no conflicts to resolve"; exit 1; } -known='^DU discord/|^(DU|UD) \.github/workflows/discord-syntax\.yml$|^UU src/pkg/config/config\.go$|^UU CHANGELOG\.md$|^UU \.github/scripts/integration-governance\.cjs$|^UU src/pkg/dashboard/static/index\.html$' +known='^DU discord/|^(DU|UD) \.github/workflows/discord-syntax\.yml$|^UU CHANGELOG\.md$|^UU \.github/scripts/integration-governance\.cjs$|^UU src/pkg/dashboard/static/index\.html$' if unknown="$(printf '%s\n' "$unmerged" | grep -vE "$known")"; then echo "v6-topup-autoresolve: conflicts outside the known patterns:" printf '%s\n' "$unknown" + if printf '%s\n' "$unknown" | grep -q ' src/pkg/config/config\.go$'; then + echo "v6-topup-autoresolve: v5 changed src/pkg/config/config.go, which v6 split into topical files;" + echo " port v5's change by hand: git diff \$(git merge-base HEAD MERGE_HEAD) MERGE_HEAD -- src/pkg/config/config.go" + fi exit 1 fi @@ -70,10 +83,6 @@ while IFS= read -r entry; do "DU "*|"UD "*) git rm -q -- "$file" ;; - "UU src/pkg/config/config.go") - git checkout --ours -- "$file" - git add -- "$file" - ;; "UU CHANGELOG.md") tmp="$(mktemp -d)" git show ":1:$file" > "$tmp/base" @@ -107,7 +116,11 @@ if [ "$regen_index" = 1 ]; then while IFS= read -r line || [ -n "$line" ]; do line="$(printf '%s' "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" case "$line" in ''|'#'*) continue ;; esac - case "$line" in /*|..*) echo "v6-topup-autoresolve: unsafe manifest path $line"; exit 1 ;; esac + # The same clean-relative-path rule as webstatic.ParseIndexManifest. + case "$line" in + /*|..*|./*|*/|*//*|*/./*|*/../*|*/.|*/..) + echo "v6-topup-autoresolve: unsafe manifest path $line"; exit 1 ;; + esac cat "$STATIC_SRC/$line" >> "$INDEX_FILE" done < "$STATIC_SRC/manifest.txt" git add -- "$INDEX_FILE" diff --git a/.github/workflows/v6-topup.yml b/.github/workflows/v6-topup.yml index dd58072398..c8142c43d7 100644 --- a/.github/workflows/v6-topup.yml +++ b/.github/workflows/v6-topup.yml @@ -93,7 +93,6 @@ jobs: # them with their history): # - discord/ + discord-syntax.yml modify/delete: keep v6's # deletion (#9277, #11551). - # - src/pkg/config/config.go: keep v6's split (#9386, #9956). # - CHANGELOG.md: both lines prepend release sections, keep both. # - integration-governance.cjs TRUSTED_SCRIPTS_TREE literal only: # re-pin to the merged src/scripts tree. @@ -101,6 +100,8 @@ jobs: # When the ONLY conflicts match those patterns, resolve them and # finish the merge. Anything else (other content conflicts, other # deletions, other hunks in the pin file) still fails loudly below. + # src/pkg/config/config.go is deliberately NOT auto-resolved: v6 + # split it, so keeping v6's side would silently drop v5's change. # The resolver runs from the copy taken off the triggering ref # before the checkout, not from v6's tree. elif bash "$RUNNER_TEMP/v6-topup-autoresolve.sh"; then