From a8047ea47202911900efb059700ba967d44a3a28 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Tue, 10 Nov 2026 21:58:05 -0600 Subject: [PATCH 01/19] fix(ci-policy checker): verify push branches: [main] for the main tier (#7950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The agreement checker counted any trigger named `push` as satisfying the main tier, though the pinned contract is a push on branches: [main] (.github/ci-policy.md). A push that can never run on main — branches: [release], branches-ignore: [main], tags-only — was certified as agreeing, and for waived workflows it flipped the verdict to STALE WAIVER, ordering the waiver deleted and erasing the record of the disagreement. Add push_targets_main: parse the push trigger's own sub-keys from the workflow's on: block (flow and block-sequence list forms) and judge the main leg by whether the trigger actually targets main. A bare/unfiltered push still counts; an explicit branches: filter must list main; branches-ignore: naming main, a branches: list without main, and a tags-only push keep the leg in disagreement — recorded against its waiver when one exists, never stale. Other tiers, the waiver set, and the named-equivalent-venue clause are untouched. Contract tests grow from 5 to 11: the three mis-filtered forms keep mcpx-nixbuild's waived main leg WAIVED (tree still passes), flow and block-sequence branches: [main] satisfy the leg (waiver stale), and an unwaived main leg with branches-ignore: [main] fails as a disagreement. The checker stays green on the current-main tree with the recorded waiver set unchanged (10 waived disagreements). --- .github/scripts/check-ci-policy-agreement.sh | 134 +++++++++++++++++- .../scripts/check-ci-policy-agreement.test.sh | 100 +++++++++++++ 2 files changed, 231 insertions(+), 3 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 812f3ede45..40dceaae32 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -118,6 +118,113 @@ triggers_of() { ' "$file" } +# push_targets_main : print "yes" when the workflow +# declares a push trigger that runs on main, "no" when it declares a +# push trigger that cannot run on main, and "absent" when it declares +# no push trigger at all. The main tier's contract is a push on +# branches: [main] (ci-policy.md), so the trigger *name* is not +# enough (#7950): a bare/unfiltered push counts; an explicit +# branches: filter must list main; branches-ignore: naming main, a +# branches: list without main, and a tags-only push never run on +# main and do not satisfy the leg. Path gates do not affect the +# verdict ("path gates as before"). +push_targets_main() { + local file="$1" + awk ' + function clean(tok) { + gsub(/["\047\[\],]/, "", tok) + return tok + } + function add_tokens(str, n, parts, i, tok, out) { + out = "" + n = split(str, parts, /[[:space:],]+/) + for (i = 1; i <= n; i++) { + tok = clean(parts[i]) + if (tok != "") out = out " " tok + } + return out + } + /^"?on"?:[[:space:]]*\[/ { + line = $0 + sub(/^"?on"?:[[:space:]]*\[/, "", line) + sub(/\].*/, "", line) + if (line ~ /(^|,)[[:space:]]*push[[:space:]]*(,|$)/) verdict = "yes" + else verdict = "absent" + done = 1 + exit + } + /^"?on"?:[[:space:]]*[a-z_]/ { + line = $0 + sub(/^"?on"?:[[:space:]]*/, "", line) + sub(/[[:space:]].*/, "", line) + verdict = (line == "push") ? "yes" : "absent" + done = 1 + exit + } + /^"?on"?:[[:space:]]*$/ { inblock = 1; next } + inblock && /^ [a-z_]+:/ { + key = $0 + sub(/^ /, "", key) + sub(/:.*/, "", key) + inpush = (key == "push") + if (inpush) seen_push = 1 + subkey = "" + next + } + inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0 } + inpush && /^ [a-z-]+:/ { + line = $0 + subkey = line + sub(/^ /, "", subkey) + sub(/:.*/, "", subkey) + val = line + sub(/^[^:]*:[[:space:]]*/, "", val) + if (subkey == "branches") { + seen_branches = 1 + branches_list = add_tokens(val) + } else if (subkey == "branches-ignore") { + ignore_list = add_tokens(val) + } else if (subkey == "tags") { + seen_tags = 1 + } + next + } + inpush && /^ -[[:space:]]/ { + item = $0 + sub(/^ -[[:space:]]*/, "", item) + if (subkey == "branches") { + seen_branches = 1 + branches_list = branches_list " " clean(item) + } else if (subkey == "branches-ignore") { + ignore_list = ignore_list " " clean(item) + } else if (subkey == "tags") { + seen_tags = 1 + } + next + } + END { + if (done) { + print verdict + exit + } + if (!seen_push) { + print "absent" + exit + } + if ((" " ignore_list " ") ~ / main /) { + print "no" + } else if (seen_branches) { + if ((" " branches_list " ") ~ / main /) print "yes" + else print "no" + } else if (seen_tags) { + print "no" + } else { + print "yes" + } + } + ' "$file" +} + waiver_for() { # waiver_for -> issue or empty local entry for entry in "${WAIVERS[@]}"; do @@ -162,7 +269,20 @@ for row in "${REGISTRY[@]}"; do IFS=',' read -ra tier_list <<<"$tiers" for tier in "${tier_list[@]}"; do req="$(required_trigger "$tier")" - if printf '%s\n' "$triggers" | grep -qx "$req"; then + agrees=0 + mistargeted=0 + if [ "$tier" = "main" ]; then + # The main leg agrees only when the push trigger targets main + # (#7950): a mis-filtered push keeps the leg in disagreement, + # so a waiver for it is recorded, never stale. + case "$(push_targets_main "$wf")" in + yes) agrees=1 ;; + no) mistargeted=1 ;; + esac + elif printf '%s\n' "$triggers" | grep -qx "$req"; then + agrees=1 + fi + if [ "$agrees" -eq 1 ]; then if [ -n "$(waiver_for "$file" "$tier")" ]; then echo "::error::STALE WAIVER $file: $tier leg now agrees (trigger '$req' declared) — delete the waiver for issue #$(waiver_for "$file" "$tier") in this PR" fail=1 @@ -172,9 +292,17 @@ for row in "${REGISTRY[@]}"; do if [ -n "$issue" ]; then SEEN_WAIVER["$file|$tier"]=1 waived=$((waived + 1)) - echo "::warning::WAIVED $file: $tier tier requires trigger '$req', not declared — disagreement recorded against issue #$issue (Phase 2-3 of #7089, awaiting Drew's ruling)" + if [ "$mistargeted" -eq 1 ]; then + echo "::warning::WAIVED $file: $tier tier requires a push trigger on branches: [main]; the declared push does not target main — disagreement recorded against issue #$issue (Phase 2-3 of #7089, awaiting Drew's ruling)" + else + echo "::warning::WAIVED $file: $tier tier requires trigger '$req', not declared — disagreement recorded against issue #$issue (Phase 2-3 of #7089, awaiting Drew's ruling)" + fi else - echo "::error::DISAGREEMENT $file: $tier tier requires trigger '$req', not declared and no waiver records it — restore the trigger, strike the tier from ci-policy.md, or record a waiver naming its phase issue (#7089)" + if [ "$mistargeted" -eq 1 ]; then + echo "::error::DISAGREEMENT $file: $tier tier requires a push trigger on branches: [main]; the declared push does not target main and no waiver records it — retarget the push to main, strike the tier from ci-policy.md, or record a waiver naming its phase issue (#7089)" + else + echo "::error::DISAGREEMENT $file: $tier tier requires trigger '$req', not declared and no waiver records it — restore the trigger, strike the tier from ci-policy.md, or record a waiver naming its phase issue (#7089)" + fi fail=1 fi fi diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 0ebc2e89c1..69141511a7 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -23,6 +23,17 @@ wf() { # wf } >"$root/.github/workflows/$file" } +wf_raw() { # wf_raw : workflow whose on: block is stdin + local root="$1" file="$2" + mkdir -p "$root/.github/workflows" + { + echo "name: $file" + echo "on:" + cat + echo "jobs: {}" + } >"$root/.github/workflows/$file" +} + policy() { # policy : a ci-policy.md naming every registry row local root="$1" mkdir -p "$root/.github" @@ -83,6 +94,95 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/stale.out" echo "pass: a waiver whose leg now agrees fails as stale" +# Main-tier branch filters (#7950): a push that cannot run on main +# does NOT satisfy the main leg. mcpx-nixbuild's main leg is waived +# (#6981), so a mis-filtered push keeps the waiver recorded — the +# tree still passes and the verdict is WAIVED, never STALE. +for case in release ignore_main tags_only; do + build_tree "$TMP/filter-$case" +done +wf_raw "$TMP/filter-release" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [release] +EOF +bash "$SCRIPT" "$TMP/filter-release" >"$TMP/filter-release.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-release.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-release.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-release.out"; then + echo "FAIL: branches: [release] was certified as main-tier agreement" >&2 + exit 1 +fi +echo "pass: push branches: [release] keeps the main leg waived, not stale" + +wf_raw "$TMP/filter-ignore_main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: [main] +EOF +bash "$SCRIPT" "$TMP/filter-ignore_main" >"$TMP/filter-ignore_main.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-ignore_main.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-ignore_main.out" +echo "pass: push branches-ignore: [main] keeps the main leg waived, not stale" + +wf_raw "$TMP/filter-tags_only" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + tags: ["v*"] +EOF +bash "$SCRIPT" "$TMP/filter-tags_only" >"$TMP/filter-tags_only.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-tags_only.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-tags_only.out" +echo "pass: tags-only push keeps the main leg waived, not stale" + +# A push that does target main satisfies the leg: the #6981 waiver +# for mcpx-nixbuild's main leg is stale and must be deleted. Both +# the flow-list and the block-sequence branches: forms agree. +build_tree "$TMP/filter-main" +wf_raw "$TMP/filter-main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [main] +EOF +if bash "$SCRIPT" "$TMP/filter-main" >"$TMP/filter-main.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a main-targeting push" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-main.out" +echo "pass: push branches: [main] satisfies the main leg (waiver stale)" + +build_tree "$TMP/filter-main-list" +wf_raw "$TMP/filter-main-list" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: + - release + - main +EOF +if bash "$SCRIPT" "$TMP/filter-main-list" >"$TMP/filter-main-list.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a block-sequence branches: [main]" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-main-list.out" +echo "pass: block-sequence branches including main satisfies the main leg" + +# An unwaived main leg with a mis-filtered push is a disagreement, +# never an agreement: mcpx-fix-test-guard's main leg has no waiver. +build_tree "$TMP/filter-unwaived" +wf_raw "$TMP/filter-unwaived" mcpx-fix-test-guard.yml <<'EOF' + pull_request: + workflow_dispatch: + push: + branches-ignore: + - main +EOF +if bash "$SCRIPT" "$TMP/filter-unwaived" >"$TMP/filter-unwaived.out" 2>&1; then + echo "FAIL: checker certified an unwaived main leg whose push excludes main" >&2 + exit 1 +fi +grep -q "DISAGREEMENT mcpx-fix-test-guard.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-unwaived.out" +echo "pass: unwaived main leg with branches-ignore: [main] fails as disagreement" + # Missing policy row: production-line guard's row vanishes. build_tree "$TMP/norow" grep -v "production-line guard" "$TMP/norow/.github/ci-policy.md" >"$TMP/norow/policy.tmp" From 94bedcf9c3671d49d8810f13f07328c0170cb617 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:02:59 -0600 Subject: [PATCH 02/19] fix(ci-policy checker): pattern/comment/tags-ignore semantics for push_targets_main (Codex P2 x3 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 54 +++++++++-- .../scripts/check-ci-policy-agreement.test.sh | 90 +++++++++++++++++++ 2 files changed, 136 insertions(+), 8 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 40dceaae32..4174505492 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -124,10 +124,13 @@ triggers_of() { # no push trigger at all. The main tier's contract is a push on # branches: [main] (ci-policy.md), so the trigger *name* is not # enough (#7950): a bare/unfiltered push counts; an explicit -# branches: filter must list main; branches-ignore: naming main, a -# branches: list without main, and a tags-only push never run on -# main and do not satisfy the leg. Path gates do not affect the -# verdict ("path gates as before"). +# branches: filter must match main as a pattern (an ordered list, +# so a later '!main' negation unmatches it); branches-ignore: with +# any pattern matching main, a branches: list whose patterns do not +# match main, and a tags-only push (tags: or tags-ignore:, with no +# branch filter) never run on main and do not satisfy the leg. +# Trailing YAML comments on filter lines are not filter entries. +# Path gates do not affect the verdict ("path gates as before"). push_targets_main() { local file="$1" awk ' @@ -144,6 +147,39 @@ push_targets_main() { } return out } + function glob_regex(pat, out, i, c) { + out = "^" + for (i = 1; i <= length(pat); i++) { + c = substr(pat, i, 1) + if (c == "*") out = out ".*" + else if (c == "?") out = out "." + else if (c ~ /[.+()|^${}]/) out = out "\\" c + else out = out c + } + return out "$" + } + function list_matches_main(list, n, parts, i, tok) { + n = split(list, parts, /[[:space:]]+/) + for (i = 1; i <= n; i++) { + tok = parts[i] + if (tok != "" && ("main" ~ glob_regex(tok))) return 1 + } + return 0 + } + function branches_allow_main(list, n, parts, i, tok, allow) { + allow = 0 + n = split(list, parts, /[[:space:]]+/) + for (i = 1; i <= n; i++) { + tok = parts[i] + if (tok == "") continue + if (substr(tok, 1, 1) == "!") { + if ("main" ~ glob_regex(substr(tok, 2))) allow = 0 + } else if ("main" ~ glob_regex(tok)) { + allow = 1 + } + } + return allow + } /^"?on"?:[[:space:]]*\[/ { line = $0 sub(/^"?on"?:[[:space:]]*\[/, "", line) @@ -179,12 +215,13 @@ push_targets_main() { sub(/:.*/, "", subkey) val = line sub(/^[^:]*:[[:space:]]*/, "", val) + if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) if (subkey == "branches") { seen_branches = 1 branches_list = add_tokens(val) } else if (subkey == "branches-ignore") { ignore_list = add_tokens(val) - } else if (subkey == "tags") { + } else if (subkey == "tags" || subkey == "tags-ignore") { seen_tags = 1 } next @@ -192,12 +229,13 @@ push_targets_main() { inpush && /^ -[[:space:]]/ { item = $0 sub(/^ -[[:space:]]*/, "", item) + if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", item) if (subkey == "branches") { seen_branches = 1 branches_list = branches_list " " clean(item) } else if (subkey == "branches-ignore") { ignore_list = ignore_list " " clean(item) - } else if (subkey == "tags") { + } else if (subkey == "tags" || subkey == "tags-ignore") { seen_tags = 1 } next @@ -211,10 +249,10 @@ push_targets_main() { print "absent" exit } - if ((" " ignore_list " ") ~ / main /) { + if (list_matches_main(ignore_list)) { print "no" } else if (seen_branches) { - if ((" " branches_list " ") ~ / main /) print "yes" + if (branches_allow_main(branches_list)) print "yes" else print "no" } else if (seen_tags) { print "no" diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 69141511a7..5cc71f4a51 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -204,4 +204,94 @@ fi grep -q "DISAGREEMENT map-build.yml: workflow file missing" "$TMP/nofile.out" echo "pass: a missing workflow file fails naming it" + +# Codex P2 regressions on #8513: pattern, comment and tags-ignore +# semantics of the same main-tier question. A tags-ignore-only push +# never runs for branch pushes, including main. +build_tree "$TMP/filter-tags_ignore" +wf_raw "$TMP/filter-tags_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + tags-ignore: ["v*"] +EOF +bash "$SCRIPT" "$TMP/filter-tags_ignore" >"$TMP/filter-tags_ignore.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-tags_ignore.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-tags_ignore.out" +echo "pass: tags-ignore-only push keeps the main leg waived, not stale" + +# A trailing YAML comment is not a filter entry: the word main in a +# comment must not certify a branches: [release] push. +build_tree "$TMP/filter-comment_branches" +wf_raw "$TMP/filter-comment_branches" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [release] # main is intentionally excluded +EOF +bash "$SCRIPT" "$TMP/filter-comment_branches" >"$TMP/filter-comment_branches.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-comment_branches.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-comment_branches.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-comment_branches.out"; then + echo "FAIL: a YAML comment was treated as a branches entry" >&2 + exit 1 +fi +echo "pass: trailing comment on branches: is not a filter entry" + +# ...and the mirror image: a comment must not turn an agreeing +# branches-ignore into a disagreement either. +build_tree "$TMP/filter-comment_ignore" +wf_raw "$TMP/filter-comment_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: [release] # main remains enabled +EOF +if bash "$SCRIPT" "$TMP/filter-comment_ignore" >"$TMP/filter-comment_ignore.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a comment-bearing branches-ignore" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-comment_ignore.out" +echo "pass: trailing comment on branches-ignore: is not a filter entry" + +# Branch filters are patterns evaluated in order: a later '!main' +# unmatches an earlier literal main. +build_tree "$TMP/filter-negated" +wf_raw "$TMP/filter-negated" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [main, '!main'] +EOF +bash "$SCRIPT" "$TMP/filter-negated" >"$TMP/filter-negated.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-negated.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-negated.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-negated.out"; then + echo "FAIL: branches: [main, '!main'] was certified as main-tier agreement" >&2 + exit 1 +fi +echo "pass: branches: [main, '!main'] keeps the main leg waived, not stale" + +# branches-ignore patterns match as globs: '*' excludes main too. +build_tree "$TMP/filter-ignore_star" +wf_raw "$TMP/filter-ignore_star" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: ['*'] +EOF +bash "$SCRIPT" "$TMP/filter-ignore_star" >"$TMP/filter-ignore_star.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-ignore_star.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-ignore_star.out" +echo "pass: branches-ignore: ['*'] keeps the main leg waived, not stale" + +# A glob that matches main satisfies the leg like a literal listing. +build_tree "$TMP/filter-pattern_main" +wf_raw "$TMP/filter-pattern_main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ['m*'] +EOF +if bash "$SCRIPT" "$TMP/filter-pattern_main" >"$TMP/filter-pattern_main.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a pattern-matched main push" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-pattern_main.out" +echo "pass: branches: ['m*'] satisfies the main leg (waiver stale)" + echo "check-ci-policy-agreement.test: all contract tests passed" From 3ff8a463791a340d863ec8ff54640a83427361c7 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:10:20 -0600 Subject: [PATCH 03/19] fix(ci-policy checker): indentless sequences + branches-ignore/tags interplay (Codex P2 round 2 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 10 ++++-- .../scripts/check-ci-policy-agreement.test.sh | 34 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 4174505492..d2e7d867c0 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -218,22 +218,26 @@ push_targets_main() { if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) if (subkey == "branches") { seen_branches = 1 + seen_branch_filter = 1 branches_list = add_tokens(val) } else if (subkey == "branches-ignore") { + seen_branch_filter = 1 ignore_list = add_tokens(val) } else if (subkey == "tags" || subkey == "tags-ignore") { seen_tags = 1 } next } - inpush && /^ -[[:space:]]/ { + inpush && /^ ( )?-[[:space:]]/ { item = $0 - sub(/^ -[[:space:]]*/, "", item) + sub(/^ ( )?-[[:space:]]*/, "", item) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", item) if (subkey == "branches") { seen_branches = 1 + seen_branch_filter = 1 branches_list = branches_list " " clean(item) } else if (subkey == "branches-ignore") { + seen_branch_filter = 1 ignore_list = ignore_list " " clean(item) } else if (subkey == "tags" || subkey == "tags-ignore") { seen_tags = 1 @@ -254,6 +258,8 @@ push_targets_main() { } else if (seen_branches) { if (branches_allow_main(branches_list)) print "yes" else print "no" + } else if (seen_branch_filter) { + print "yes" } else if (seen_tags) { print "no" } else { diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 5cc71f4a51..c6c2ebdc03 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -294,4 +294,38 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-pattern_main.out" echo "pass: branches: ['m*'] satisfies the main leg (waiver stale)" + +# Codex P2 regressions on #8513 round 2: indentless block sequences +# are valid YAML — items aligned with the filter key still count. +build_tree "$TMP/filter-indentless" +wf_raw "$TMP/filter-indentless" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: + - main +EOF +if bash "$SCRIPT" "$TMP/filter-indentless" >"$TMP/filter-indentless.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for an indentless branches sequence" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-indentless.out" +echo "pass: indentless branches sequence including main satisfies the main leg" + +# A branch filter that does not exclude main means branch pushes +# run, even when a tag filter is also declared (the tag filter +# governs tag pushes separately) — not a tags-only push. +build_tree "$TMP/filter-ignore_plus_tags" +wf_raw "$TMP/filter-ignore_plus_tags" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: [release] + tags: ['v*'] +EOF +if bash "$SCRIPT" "$TMP/filter-ignore_plus_tags" >"$TMP/filter-ignore_plus_tags.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a branches-ignore + tags push" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-ignore_plus_tags.out" +echo "pass: branches-ignore (not main) plus tags still satisfies the main leg" + echo "check-ci-policy-agreement.test: all contract tests passed" From 99fa66cf626b3f9b672588f7ee326397a71764ec Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:18:11 -0600 Subject: [PATCH 04/19] fix(ci-policy checker): GitHub pattern quantifiers + multiline flow sequences (Codex P2 round 3 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 40 +++++++++++++-- .../scripts/check-ci-policy-agreement.test.sh | 50 +++++++++++++++++++ 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index d2e7d867c0..2d15f1a0ad 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -147,13 +147,29 @@ push_targets_main() { } return out } - function glob_regex(pat, out, i, c) { + function glob_regex(pat, out, i, c, cls) { + # GitHub filter-pattern syntax (workflow-syntax cheat sheet), + # not shell glob: ? and + quantify the preceding character, + # * matches within a path segment, ** across segments. out = "^" for (i = 1; i <= length(pat); i++) { c = substr(pat, i, 1) - if (c == "*") out = out ".*" - else if (c == "?") out = out "." - else if (c ~ /[.+()|^${}]/) out = out "\\" c + if (c == "*") { + if (substr(pat, i + 1, 1) == "*") { out = out ".*"; i++ } + else out = out "[^/]*" + } + else if (c == "?" || c == "+") out = out c + else if (c == "[") { + cls = "[" + i++ + if (substr(pat, i, 1) == "!") { cls = cls "^"; i++ } + for (; i <= length(pat); i++) { + cls = cls substr(pat, i, 1) + if (substr(pat, i, 1) == "]") break + } + out = out cls + } + else if (c ~ /[.^$()|{}]/) out = out "\\" c else out = out c } return out "$" @@ -216,6 +232,7 @@ push_targets_main() { val = line sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) + if ((subkey == "branches" || subkey == "branches-ignore") && val ~ /\[/ && val !~ /\]/) flow_key = subkey if (subkey == "branches") { seen_branches = 1 seen_branch_filter = 1 @@ -228,6 +245,21 @@ push_targets_main() { } next } + inpush && flow_key != "" { + seg = $0 + sub(/[[:space:]]#.*/, "", seg) + if (seg ~ /\]/) { + sub(/\].*/, "", seg) + if (flow_key == "branches") branches_list = branches_list add_tokens(seg) + else if (flow_key == "branches-ignore") ignore_list = ignore_list add_tokens(seg) + flow_key = "" + } else if (flow_key == "branches") { + branches_list = branches_list add_tokens(seg) + } else if (flow_key == "branches-ignore") { + ignore_list = ignore_list add_tokens(seg) + } + next + } inpush && /^ ( )?-[[:space:]]/ { item = $0 sub(/^ ( )?-[[:space:]]*/, "", item) diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index c6c2ebdc03..ae3e856b84 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -328,4 +328,54 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-ignore_plus_tags.out" echo "pass: branches-ignore (not main) plus tags still satisfies the main leg" + +# Codex P2 regressions on #8513 round 3: GitHub filter patterns use +# quantifiers, not shell glob — 'main?' excludes main (the ? makes +# the preceding n optional), and 'ma+in' matches it. +build_tree "$TMP/filter-ignore_quantifier" +wf_raw "$TMP/filter-ignore_quantifier" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: ['main?'] +EOF +bash "$SCRIPT" "$TMP/filter-ignore_quantifier" >"$TMP/filter-ignore_quantifier.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-ignore_quantifier.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-ignore_quantifier.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-ignore_quantifier.out"; then + echo "FAIL: branches-ignore: ['main?'] was certified as main-tier agreement" >&2 + exit 1 +fi +echo "pass: branches-ignore: ['main?'] keeps the main leg waived, not stale" + +build_tree "$TMP/filter-plus_quantifier" +wf_raw "$TMP/filter-plus_quantifier" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ['ma+in'] +EOF +if bash "$SCRIPT" "$TMP/filter-plus_quantifier" >"$TMP/filter-plus_quantifier.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a ma+in pattern push" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-plus_quantifier.out" +echo "pass: branches: ['ma+in'] satisfies the main leg (waiver stale)" + +# Multiline flow sequences: the entries live on their own lines +# between the [ and ] lines and must all be collected. +build_tree "$TMP/filter-flow_multiline" +wf_raw "$TMP/filter-flow_multiline" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [ + release, + main + ] +EOF +if bash "$SCRIPT" "$TMP/filter-flow_multiline" >"$TMP/filter-flow_multiline.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a multiline flow branches list" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-flow_multiline.out" +echo "pass: multiline flow branches list including main satisfies the main leg" + echo "check-ci-policy-agreement.test: all contract tests passed" From 92eda871b7cb3df64713124d1e3afa997400a7ed Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:24:56 -0600 Subject: [PATCH 05/19] fix(ci-policy checker): preserve character classes in branch patterns (Codex P2 round 4 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 4 ++- .../scripts/check-ci-policy-agreement.test.sh | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 2d15f1a0ad..a42f05ce5e 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -135,10 +135,12 @@ push_targets_main() { local file="$1" awk ' function clean(tok) { - gsub(/["\047\[\],]/, "", tok) + gsub(/["\047,]/, "", tok) return tok } function add_tokens(str, n, parts, i, tok, out) { + sub(/^[[:space:]]*\[/, "", str) + sub(/\][[:space:]]*$/, "", str) out = "" n = split(str, parts, /[[:space:],]+/) for (i = 1; i <= n; i++) { diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index ae3e856b84..f6f4c8dec9 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -378,4 +378,32 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-flow_multiline.out" echo "pass: multiline flow branches list including main satisfies the main leg" + +# Codex P2 regression on #8513 round 4: character classes inside a +# pattern are pattern syntax, not YAML delimiters — '[a-z]ain' +# matches main, in both the positive and the ignore list. +build_tree "$TMP/filter-class_main" +wf_raw "$TMP/filter-class_main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ['[a-z]ain'] +EOF +if bash "$SCRIPT" "$TMP/filter-class_main" >"$TMP/filter-class_main.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a character-class main push" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-class_main.out" +echo "pass: branches: ['[a-z]ain'] satisfies the main leg (waiver stale)" + +build_tree "$TMP/filter-class_ignore" +wf_raw "$TMP/filter-class_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: ['[a-z]ain'] +EOF +bash "$SCRIPT" "$TMP/filter-class_ignore" >"$TMP/filter-class_ignore.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-class_ignore.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-class_ignore.out" +echo "pass: branches-ignore: ['[a-z]ain'] keeps the main leg waived, not stale" + echo "check-ci-policy-agreement.test: all contract tests passed" From 9453847916d7da6fac9a7a3cdc1f977e4dd77b12 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:34:39 -0600 Subject: [PATCH 06/19] fix(ci-policy checker): globstar zero-dir, quoted-scalar tokenizing, inline push mappings (Codex P2 round 5 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 53 +++++++++++++--- .../scripts/check-ci-policy-agreement.test.sh | 62 +++++++++++++++++++ 2 files changed, 107 insertions(+), 8 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index a42f05ce5e..decb0885dd 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -135,20 +135,49 @@ push_targets_main() { local file="$1" awk ' function clean(tok) { - gsub(/["\047,]/, "", tok) + if (length(tok) >= 2) { + if ((substr(tok, 1, 1) == "\047" && substr(tok, length(tok), 1) == "\047") || (substr(tok, 1, 1) == "\"" && substr(tok, length(tok), 1) == "\"")) tok = substr(tok, 2, length(tok) - 2) + } return tok } - function add_tokens(str, n, parts, i, tok, out) { + function add_tokens(str, i, c, q, tok, out) { sub(/^[[:space:]]*\[/, "", str) sub(/\][[:space:]]*$/, "", str) out = "" - n = split(str, parts, /[[:space:],]+/) - for (i = 1; i <= n; i++) { - tok = clean(parts[i]) - if (tok != "") out = out " " tok + tok = "" + q = "" + for (i = 1; i <= length(str); i++) { + c = substr(str, i, 1) + if (q != "") { + if (c == q) q = "" + else tok = tok c + } else if (c == "\047" || c == "\"") { + q = c + } else if (c ~ /[[:space:],]/) { + if (tok != "") { out = out " " tok; tok = "" } + } else { + tok = tok c + } } + if (tok != "") out = out " " tok return out } + function apply_inline_filters(str, seg) { + if (match(str, /branches-ignore:[[:space:]]*\[[^]]*\]/)) { + seg = substr(str, RSTART, RLENGTH) + sub(/^[^[]*\[/, "[", seg) + seen_branch_filter = 1 + ignore_list = ignore_list add_tokens(seg) + } + if (match(str, /branches:[[:space:]]*\[[^]]*\]/)) { + seg = substr(str, RSTART, RLENGTH) + sub(/^[^[]*\[/, "[", seg) + seen_branches = 1 + seen_branch_filter = 1 + branches_list = branches_list add_tokens(seg) + } + if (str ~ /tags:/ || str ~ /tags-ignore:/) seen_tags = 1 + } function glob_regex(pat, out, i, c, cls) { # GitHub filter-pattern syntax (workflow-syntax cheat sheet), # not shell glob: ? and + quantify the preceding character, @@ -157,7 +186,10 @@ push_targets_main() { for (i = 1; i <= length(pat); i++) { c = substr(pat, i, 1) if (c == "*") { - if (substr(pat, i + 1, 1) == "*") { out = out ".*"; i++ } + if (substr(pat, i + 1, 1) == "*") { + if (substr(pat, i + 2, 1) == "/") { out = out "(.*/)?"; i += 2 } + else { out = out ".*"; i++ } + } else out = out "[^/]*" } else if (c == "?" || c == "+") out = out c @@ -221,7 +253,12 @@ push_targets_main() { sub(/^ /, "", key) sub(/:.*/, "", key) inpush = (key == "push") - if (inpush) seen_push = 1 + if (inpush) { + seen_push = 1 + rest = $0 + sub(/^ [a-z_]+:[[:space:]]*/, "", rest) + if (rest ~ /^\{/) apply_inline_filters(rest) + } subkey = "" next } diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index f6f4c8dec9..b0ec929631 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -406,4 +406,66 @@ grep -q "ci-policy-agreement: OK" "$TMP/filter-class_ignore.out" grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-class_ignore.out" echo "pass: branches-ignore: ['[a-z]ain'] keeps the main leg waived, not stale" + +# Codex P2 regressions on #8513 round 5. A **/ component matches +# zero directories: '**/main' excludes main. +build_tree "$TMP/filter-globstar_ignore" +wf_raw "$TMP/filter-globstar_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: ['**/main'] +EOF +bash "$SCRIPT" "$TMP/filter-globstar_ignore" >"$TMP/filter-globstar_ignore.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-globstar_ignore.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-globstar_ignore.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-globstar_ignore.out"; then + echo "FAIL: branches-ignore: ['**/main'] was certified as main-tier agreement" >&2 + exit 1 +fi +echo "pass: branches-ignore: ['**/main'] keeps the main leg waived, not stale" + +# A comma inside a quoted scalar is content, not a separator: +# 'release,main' is one branch pattern that is not main. +build_tree "$TMP/filter-quoted_comma" +wf_raw "$TMP/filter-quoted_comma" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ['release,main'] +EOF +bash "$SCRIPT" "$TMP/filter-quoted_comma" >"$TMP/filter-quoted_comma.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_comma.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_comma.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_comma.out"; then + echo "FAIL: a quoted comma manufactured a main branch entry" >&2 + exit 1 +fi +echo "pass: branches: ['release,main'] keeps the main leg waived, not stale" + +# An inline push mapping carries its filters on the same line. +build_tree "$TMP/filter-inline_map" +wf_raw "$TMP/filter-inline_map" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches: [release]} +EOF +bash "$SCRIPT" "$TMP/filter-inline_map" >"$TMP/filter-inline_map.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_map.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-inline_map.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_map.out"; then + echo "FAIL: an inline push mapping was treated as an unfiltered push" >&2 + exit 1 +fi +echo "pass: inline push mapping with branches: [release] keeps the main leg waived" + +build_tree "$TMP/filter-inline_map_main" +wf_raw "$TMP/filter-inline_map_main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches: [main]} +EOF +if bash "$SCRIPT" "$TMP/filter-inline_map_main" >"$TMP/filter-inline_map_main.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for an inline main push mapping" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_map_main.out" +echo "pass: inline push mapping with branches: [main] satisfies the main leg" + echo "check-ci-policy-agreement.test: all contract tests passed" From 89ad994a708dc69b68a3f121663cb2c0375f0733 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:36:45 -0600 Subject: [PATCH 07/19] fix(ci-policy checker): quote-aware flow-list terminators (Codex P2 round 5b on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 36 ++++++++++++++----- .../scripts/check-ci-policy-agreement.test.sh | 32 +++++++++++++++++ 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index decb0885dd..05b24b3062 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -162,16 +162,35 @@ push_targets_main() { if (tok != "") out = out " " tok return out } + function unquoted_close(str, j, c, q) { + q = "" + for (j = 1; j <= length(str); j++) { + c = substr(str, j, 1) + if (q != "") { if (c == q) q = "" } + else if (c == "\047" || c == "\"") q = c + else if (c == "]") return j + } + return 0 + } + function flow_span(str, key, i, start, seg) { + i = index(str, key) + if (i == 0) return "" + start = index(substr(str, i), "[") + if (start == 0) return "" + start = i + start - 1 + seg = substr(str, start) + i = unquoted_close(seg) + if (i == 0) return "" + return substr(seg, 1, i) + } function apply_inline_filters(str, seg) { - if (match(str, /branches-ignore:[[:space:]]*\[[^]]*\]/)) { - seg = substr(str, RSTART, RLENGTH) - sub(/^[^[]*\[/, "[", seg) + seg = flow_span(str, "branches-ignore:") + if (seg != "") { seen_branch_filter = 1 ignore_list = ignore_list add_tokens(seg) } - if (match(str, /branches:[[:space:]]*\[[^]]*\]/)) { - seg = substr(str, RSTART, RLENGTH) - sub(/^[^[]*\[/, "[", seg) + seg = flow_span(str, "branches:") + if (seg != "") { seen_branches = 1 seen_branch_filter = 1 branches_list = branches_list add_tokens(seg) @@ -287,8 +306,9 @@ push_targets_main() { inpush && flow_key != "" { seg = $0 sub(/[[:space:]]#.*/, "", seg) - if (seg ~ /\]/) { - sub(/\].*/, "", seg) + k = unquoted_close(seg) + if (k > 0) { + seg = substr(seg, 1, k - 1) if (flow_key == "branches") branches_list = branches_list add_tokens(seg) else if (flow_key == "branches-ignore") ignore_list = ignore_list add_tokens(seg) flow_key = "" diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index b0ec929631..0145e27c8b 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -468,4 +468,36 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_map_main.out" echo "pass: inline push mapping with branches: [main] satisfies the main leg" + +# Codex P2 regression on #8513 round 5b: a quoted character class +# contains its own ] — that bracket is not the flow-list terminator, +# in multiline sequences or inline mappings. +build_tree "$TMP/filter-flow_class" +wf_raw "$TMP/filter-flow_class" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [ + '[a-z]ain', + release + ] +EOF +if bash "$SCRIPT" "$TMP/filter-flow_class" >"$TMP/filter-flow_class.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a flow list with a quoted class" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-flow_class.out" +echo "pass: multiline flow list with a quoted character class satisfies the main leg" + +build_tree "$TMP/filter-inline_class" +wf_raw "$TMP/filter-inline_class" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches: ['[a-z]ain']} +EOF +if bash "$SCRIPT" "$TMP/filter-inline_class" >"$TMP/filter-inline_class.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for an inline mapping with a quoted class" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_class.out" +echo "pass: inline push mapping with a quoted character class satisfies the main leg" + echo "check-ci-policy-agreement.test: all contract tests passed" From d2619cc81670d7116fc1ede5194e914c6f3e4df8 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:44:20 -0600 Subject: [PATCH 08/19] fix(ci-policy checker): dynamic child indent, quote-aware flow-open, generated oracle coverage (Codex round 6 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 35 +++- .../scripts/check-ci-policy-agreement.test.sh | 190 ++++++++++++++++++ 2 files changed, 217 insertions(+), 8 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 05b24b3062..9387c5c72c 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -172,6 +172,18 @@ push_targets_main() { } return 0 } + function flow_unclosed(str, j, c, q, open) { + q = "" + open = 0 + for (j = 1; j <= length(str); j++) { + c = substr(str, j, 1) + if (q != "") { if (c == q) q = "" } + else if (c == "\047" || c == "\"") q = c + else if (c == "[") open = 1 + else if (c == "]" && open) open = 0 + } + return open + } function flow_span(str, key, i, start, seg) { i = index(str, key) if (i == 0) return "" @@ -272,6 +284,7 @@ push_targets_main() { sub(/^ /, "", key) sub(/:.*/, "", key) inpush = (key == "push") + if (!inpush) child_indent = 0 if (inpush) { seen_push = 1 rest = $0 @@ -281,16 +294,19 @@ push_targets_main() { subkey = "" next } - inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0 } - inpush && /^ [a-z-]+:/ { + inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0; child_indent = 0 } + inpush && /^ +[a-z-]+:/ { line = $0 - subkey = line - sub(/^ /, "", subkey) + match(line, /^ +/) + ind = RLENGTH + if (child_indent == 0) child_indent = ind + if (ind != child_indent) next + subkey = substr(line, ind + 1) sub(/:.*/, "", subkey) - val = line + val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) - if ((subkey == "branches" || subkey == "branches-ignore") && val ~ /\[/ && val !~ /\]/) flow_key = subkey + if ((subkey == "branches" || subkey == "branches-ignore") && flow_unclosed(val)) flow_key = subkey if (subkey == "branches") { seen_branches = 1 seen_branch_filter = 1 @@ -319,9 +335,12 @@ push_targets_main() { } next } - inpush && /^ ( )?-[[:space:]]/ { + inpush && /^ +-[[:space:]]/ { item = $0 - sub(/^ ( )?-[[:space:]]*/, "", item) + match(item, /^ +/) + ind = RLENGTH + if (child_indent == 0 || (ind != child_indent && ind != child_indent + 2)) next + sub(/^ +-[[:space:]]*/, "", item) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", item) if (subkey == "branches") { seen_branches = 1 diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 0145e27c8b..83197d935d 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -500,4 +500,194 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_class.out" echo "pass: inline push mapping with a quoted character class satisfies the main leg" + + +# Codex P2 regression on #8513 round 6: push children may sit at +# any consistent indentation depth, not only four spaces. +build_tree "$TMP/filter-deep_indent" +wf_raw "$TMP/filter-deep_indent" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: [release] +EOF +bash "$SCRIPT" "$TMP/filter-deep_indent" >"$TMP/filter-deep_indent.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-deep_indent.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-deep_indent.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-deep_indent.out"; then + echo "FAIL: a six-space branches filter was treated as an unfiltered push" >&2 + exit 1 +fi +echo "pass: six-space-deep branches: [release] keeps the main leg waived" + +build_tree "$TMP/filter-deep_indent_list" +wf_raw "$TMP/filter-deep_indent_list" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: + - main +EOF +if bash "$SCRIPT" "$TMP/filter-deep_indent_list" >"$TMP/filter-deep_indent_list.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a deep-indented branches list" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-deep_indent_list.out" +echo "pass: deep-indented branches list including main satisfies the main leg" + +# Codex P1 regression on #8513: generated coverage for the parser. +# Equivalent YAML representations of the same logical push filter +# must yield the same verdict. Oracle: an independent Python +# reference for GitHub filter-pattern semantics over the single +# branch name "main" (ordered branches evaluation with negation, +# any-match branches-ignore, branch-filter presence beats the +# tags-only rule) — expectations are computed by the oracle from +# the case definitions, never copied from the awk implementation. +# Representations generated per case: flow list, indented block +# sequence, indentless block sequence, multiline flow list. +python3 - "$SCRIPT" "$TMP" <<'PYEOF' +import os, re, subprocess, sys + +script, tmp = sys.argv[1], sys.argv[2] + +def translate(pat): + out, i = [], 0 + while i < len(pat): + c = pat[i] + if c == '*': + if pat[i:i+2] == '**': + if pat[i+2:i+3] == '/': + out.append('(?:.*/)?'); i += 3 + else: + out.append('.*'); i += 2 + else: + out.append('[^/]*'); i += 1 + elif c in '?+': + out.append(c); i += 1 + elif c == '[': + j = i + 1 + if pat[j:j+1] == '!': + j += 1 + while j < len(pat) and pat[j] != ']': + j += 1 + cls = pat[i+1:j] + if cls.startswith('!'): + cls = '^' + cls[1:] + out.append('[' + cls + ']'); i = j + 1 + else: + out.append(re.escape(c)); i += 1 + return '^' + ''.join(out) + '$' + +def matches(pat): + return re.match(translate(pat), 'main') is not None + +def verdict(branches=None, ignore=None, tags=False): + if ignore and any(matches(p) for p in ignore): + return 'no' + if branches is not None: + allow = False + for p in branches: + if p.startswith('!'): + if matches(p[1:]): + allow = False + elif matches(p): + allow = True + return 'yes' if allow else 'no' + if ignore is not None: + return 'yes' + return 'no' if tags else 'yes' + +def q(p): + if any(ch in p for ch in ',#[] ') or p.startswith('!'): + return "'" + p + "'" + return p + +def render(kind, pats, style): + if style == 'flow': + return [f" {kind}: [{', '.join(q(x) for x in pats)}]"] + if style == 'block': + return [f" {kind}:"] + [f" - {q(x)}" for x in pats] + if style == 'indentless': + return [f" {kind}:"] + [f" - {q(x)}" for x in pats] + if style == 'multiline': + lines = [f" {kind}: ["] + lines += [f" {q(x)}," for x in pats[:-1]] + if pats: + lines.append(f" {q(pats[-1])}") + lines.append(" ]") + return lines + raise ValueError(style) + +POLICY = """| workflow-lint | basic | — | — | +| proxy-port-fallbacks | basic | — | — | +| fleet-search-parity-guard | basic | — | — | +| opencode-config-guard | basic | main | — | +| mcpx fix-test guard (#1969) | basic | main | — | +| production-line guard (#1411) | basic | — | — | +| go modules build / identity build / map build / mcpx nix build | class-3 | main | — | +""" +BASE = { + 'workflow-lint.yml': ['pull_request', 'workflow_dispatch'], + 'proxy-port-fallbacks.yml': ['pull_request'], + 'fleet-search-parity-guard.yml': ['pull_request', 'workflow_dispatch'], + 'opencode-config-guard.yml': ['pull_request', 'workflow_dispatch'], + 'mcpx-fix-test-guard.yml': ['pull_request', 'push', 'workflow_dispatch'], + 'production-line-guard.yml': ['workflow_dispatch'], + 'go-modules-build.yml': ['workflow_dispatch'], + 'identity-build.yml': ['workflow_dispatch'], + 'map-build.yml': ['workflow_dispatch'], +} + +def build(case_root, push_lines): + os.makedirs(case_root + '/.github/workflows', exist_ok=True) + with open(case_root + '/.github/ci-policy.md', 'w') as f: + f.write(POLICY) + for name, triggers in BASE.items(): + with open(f'{case_root}/.github/workflows/{name}', 'w') as f: + f.write(f'name: {name}\non:\n') + for tr in triggers: + f.write(f' {tr}:\n') + f.write('jobs: {}\n') + with open(case_root + '/.github/workflows/mcpx-nixbuild.yml', 'w') as f: + f.write('name: mcpx-nixbuild.yml\non:\n workflow_dispatch:\n push:\n') + f.write('\n'.join(push_lines) + '\njobs: {}\n') + +BRANCH_CASES = [ + ['main'], ['release'], ['main', '!main'], ['!main', 'main'], + ['m*'], ['*'], ['**/main'], ['ma+in'], ['main?'], ['[a-z]ain'], + ['[!a]ain'], ['release,main'], ['mai'], [], +] +IGNORE_CASES = [ + ['main'], ['release'], ['*'], ['**/main'], ['main?'], ['[a-z]ain'], +] +STYLES = ['flow', 'block', 'indentless', 'multiline'] + +cases = [] +for pats in BRANCH_CASES: + cases.append((f'branches {pats}', render('branches', pats, 'flow'), verdict(branches=pats))) + for style in STYLES[1:]: + cases.append((f'branches {pats} [{style}]', render('branches', pats, style), verdict(branches=pats))) +for pats in IGNORE_CASES: + for style in STYLES: + cases.append((f'branches-ignore {pats} [{style}]', render('branches-ignore', pats, style), verdict(ignore=pats))) +cases.append(('tags only', render('tags', ['v*'], 'flow'), verdict(tags=True))) +cases.append(('ignore + tags', render('branches-ignore', ['release'], 'flow') + render('tags', ['v*'], 'flow'), verdict(ignore=['release'], tags=True))) + +failures = 0 +for idx, (name, push_lines, want) in enumerate(cases): + root = f'{tmp}/gen-{idx}' + build(root, push_lines) + proc = subprocess.run(['bash', script, root], capture_output=True, text=True) + out = proc.stdout + proc.stderr + if want == 'yes': + ok = proc.returncode != 0 and 'STALE WAIVER mcpx-nixbuild.yml: main leg now agrees' in out + else: + ok = proc.returncode == 0 and 'WAIVED mcpx-nixbuild.yml: main tier' in out and 'STALE WAIVER mcpx-nixbuild.yml' not in out + if not ok: + failures += 1 + print(f'GEN FAIL {name}: want verdict {want}, rc={proc.returncode}') + print(out[:600]) +print(f'generated coverage: {len(cases)} cases, {failures} failures') +sys.exit(1 if failures else 0) +PYEOF +echo "pass: generated representation/pattern coverage agrees with the oracle" + echo "check-ci-policy-agreement.test: all contract tests passed" From 09a3b9c601c704875c9afb28ff2c8acce4212729 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 05:55:05 -0600 Subject: [PATCH 09/19] fix(ci-policy checker): quoted keys + trim-before-unquote (Codex P2 round 7 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 11 +++-- .../scripts/check-ci-policy-agreement.test.sh | 46 +++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 9387c5c72c..6ff25aec17 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -107,10 +107,11 @@ triggers_of() { exit } /^"?on"?:[[:space:]]*$/ { inblock = 1; next } - inblock && /^ [a-z_]+:/ { + inblock && /^ ["\047]?[a-z_]+["\047]?:/ { key = $0 sub(/^ /, "", key) sub(/:.*/, "", key) + gsub(/["\047]/, "", key) print key next } @@ -135,6 +136,8 @@ push_targets_main() { local file="$1" awk ' function clean(tok) { + sub(/^[[:space:]]+/, "", tok) + sub(/[[:space:]]+$/, "", tok) if (length(tok) >= 2) { if ((substr(tok, 1, 1) == "\047" && substr(tok, length(tok), 1) == "\047") || (substr(tok, 1, 1) == "\"" && substr(tok, length(tok), 1) == "\"")) tok = substr(tok, 2, length(tok) - 2) } @@ -279,10 +282,11 @@ push_targets_main() { exit } /^"?on"?:[[:space:]]*$/ { inblock = 1; next } - inblock && /^ [a-z_]+:/ { + inblock && /^ ["\047]?[a-z_]+["\047]?:/ { key = $0 sub(/^ /, "", key) sub(/:.*/, "", key) + gsub(/["\047]/, "", key) inpush = (key == "push") if (!inpush) child_indent = 0 if (inpush) { @@ -295,7 +299,7 @@ push_targets_main() { next } inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0; child_indent = 0 } - inpush && /^ +[a-z-]+:/ { + inpush && /^ +["\047]?[a-z-]+["\047]?:/ { line = $0 match(line, /^ +/) ind = RLENGTH @@ -303,6 +307,7 @@ push_targets_main() { if (ind != child_indent) next subkey = substr(line, ind + 1) sub(/:.*/, "", subkey) + gsub(/["\047]/, "", subkey) val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 83197d935d..96d3da3bbb 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -533,6 +533,52 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-deep_indent_list.out" echo "pass: deep-indented branches list including main satisfies the main leg" + +# Codex P2 regressions on #8513 round 7: a quoted block item with a +# trailing comment still unquotes, and quoted filter keys name the +# same filters as bare keys. +build_tree "$TMP/filter-quoted_item_comment" +wf_raw "$TMP/filter-quoted_item_comment" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: + - 'main' # main branch +EOF +bash "$SCRIPT" "$TMP/filter-quoted_item_comment" >"$TMP/filter-quoted_item_comment.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_item_comment.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_item_comment.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_item_comment.out"; then + echo "FAIL: a quoted block item with a trailing comment was not unquoted" >&2 + exit 1 +fi +echo "pass: quoted branches-ignore item with trailing comment keeps the main leg waived" + +build_tree "$TMP/filter-quoted_key" +wf_raw "$TMP/filter-quoted_key" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + "branches": [release] +EOF +bash "$SCRIPT" "$TMP/filter-quoted_key" >"$TMP/filter-quoted_key.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_key.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_key.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_key.out"; then + echo "FAIL: a quoted branches key was treated as an unfiltered push" >&2 + exit 1 +fi +echo "pass: quoted branches key with [release] keeps the main leg waived" + +build_tree "$TMP/filter-quoted_key_ignore" +wf_raw "$TMP/filter-quoted_key_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + 'branches-ignore': [main] +EOF +bash "$SCRIPT" "$TMP/filter-quoted_key_ignore" >"$TMP/filter-quoted_key_ignore.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_key_ignore.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_key_ignore.out" +echo "pass: quoted branches-ignore key with [main] keeps the main leg waived" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From 121b455762e1889a6cd7a5f82df13af72f5ad23a Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 06:05:35 -0600 Subject: [PATCH 10/19] fix(ci-policy checker): quoted push key inline rest + mapping-key tag detection (Codex P2 round 8 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 16 +++++++--- .../scripts/check-ci-policy-agreement.test.sh | 30 +++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 6ff25aec17..089e1a6fac 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -187,8 +187,15 @@ push_targets_main() { } return open } - function flow_span(str, key, i, start, seg) { - i = index(str, key) + function flow_span(str, key, i, start, seg, from, prev) { + from = 1 + while ((i = index(substr(str, from), key)) > 0) { + i = from + i - 1 + prev = (i == 1) ? "" : substr(str, i - 1, 1) + if (prev == "" || prev == "{" || prev == "," || prev == " ") break + from = i + length(key) + i = 0 + } if (i == 0) return "" start = index(substr(str, i), "[") if (start == 0) return "" @@ -210,7 +217,8 @@ push_targets_main() { seen_branch_filter = 1 branches_list = branches_list add_tokens(seg) } - if (str ~ /tags:/ || str ~ /tags-ignore:/) seen_tags = 1 + if (str ~ /(^|[{,][[:space:]]*)["\047]?tags-ignore["\047]?[[:space:]]*:/) seen_tags = 1 + if (str ~ /(^|[{,][[:space:]]*)["\047]?tags["\047]?[[:space:]]*:/) seen_tags = 1 } function glob_regex(pat, out, i, c, cls) { # GitHub filter-pattern syntax (workflow-syntax cheat sheet), @@ -292,7 +300,7 @@ push_targets_main() { if (inpush) { seen_push = 1 rest = $0 - sub(/^ [a-z_]+:[[:space:]]*/, "", rest) + sub(/^ ["\047]?[a-z_]+["\047]?:[[:space:]]*/, "", rest) if (rest ~ /^\{/) apply_inline_filters(rest) } subkey = "" diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 96d3da3bbb..08b7d19f29 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -579,6 +579,36 @@ grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_key_ignore.out" grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_key_ignore.out" echo "pass: quoted branches-ignore key with [main] keeps the main leg waived" + +# Codex P2 regressions on #8513 round 8: a quoted push key still +# yields its inline mapping, and a tags: substring inside a path +# scalar is not a tag filter. +build_tree "$TMP/filter-quoted_push_inline" +wf_raw "$TMP/filter-quoted_push_inline" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + "push": {branches: [release]} +EOF +bash "$SCRIPT" "$TMP/filter-quoted_push_inline" >"$TMP/filter-quoted_push_inline.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_push_inline.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_push_inline.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_push_inline.out"; then + echo "FAIL: a quoted push key hid its inline branch filter" >&2 + exit 1 +fi +echo "pass: quoted push key with inline branches: [release] keeps the main leg waived" + +build_tree "$TMP/filter-paths_tags_substring" +wf_raw "$TMP/filter-paths_tags_substring" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {paths: ['docs/tags:/**']} +EOF +if bash "$SCRIPT" "$TMP/filter-paths_tags_substring" >"$TMP/filter-paths_tags_substring.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a paths-only inline push" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-paths_tags_substring.out" +echo "pass: a tags: substring inside a path scalar is not a tag filter (waiver stale)" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From 95f17cb6b5c6da2b6c3ea293f76603f952f06ac2 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 06:12:42 -0600 Subject: [PATCH 11/19] fix(ci-policy checker): collect multiline inline push mappings (Codex P2 round 9 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 19 ++++++++++- .../scripts/check-ci-policy-agreement.test.sh | 32 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 089e1a6fac..d7411efe5a 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -301,12 +301,29 @@ push_targets_main() { seen_push = 1 rest = $0 sub(/^ ["\047]?[a-z_]+["\047]?:[[:space:]]*/, "", rest) - if (rest ~ /^\{/) apply_inline_filters(rest) + if (rest ~ /^\{/) { + if (rest ~ /\}/) apply_inline_filters(rest) + else { inline_collect = 1; inline_buf = rest } + } } subkey = "" next } inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0; child_indent = 0 } + inline_collect { + if ($0 ~ /^[^[:space:]#]/) { + apply_inline_filters(inline_buf) + inline_collect = 0 + } else { + inline_buf = inline_buf " " $0 + if ($0 ~ /\}/) { + apply_inline_filters(inline_buf) + inline_collect = 0 + } + next + } + } + inpush && /^ +["\047]?[a-z-]+["\047]?:/ { line = $0 match(line, /^ +/) diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 08b7d19f29..f033e64ca6 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -609,6 +609,38 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-paths_tags_substring.out" echo "pass: a tags: substring inside a path scalar is not a tag filter (waiver stale)" + +# Codex P2 regression on #8513 round 9: an inline push mapping may +# span lines — the whole mapping is collected before its filters +# are evaluated. +build_tree "$TMP/filter-inline_split" +wf_raw "$TMP/filter-inline_split" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches: [ + release]} +EOF +bash "$SCRIPT" "$TMP/filter-inline_split" >"$TMP/filter-inline_split.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_split.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-inline_split.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_split.out"; then + echo "FAIL: a split inline push mapping was treated as an unfiltered push" >&2 + exit 1 +fi +echo "pass: split inline push mapping with branches: [release] keeps the main leg waived" + +build_tree "$TMP/filter-inline_split_main" +wf_raw "$TMP/filter-inline_split_main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches: [ + main]} +EOF +if bash "$SCRIPT" "$TMP/filter-inline_split_main" >"$TMP/filter-inline_split_main.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a split inline main mapping" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_split_main.out" +echo "pass: split inline push mapping with branches: [main] satisfies the main leg" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From e2df53081fda0fd097438d6d3a86d901eac77a3a Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 06:44:47 -0600 Subject: [PATCH 12/19] fix(ci-policy checker): accept deeper indentation for block-sequence filter items (#7950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex P2 on PR #8513: block-sequence items were accepted only at the filter key indent or key+2, so a branches-ignore key at four spaces with its - main item at eight was skipped — the parser recorded a branch filter with an empty ignore list and certified main coverage for a push that excludes main. The parser now learns the sequence indent from the first item of each filter key (any consistent depth greater than the key, indentless sequences retained) and accepts items at that learned depth. Regression cases: deep-indented branches-ignore still excludes main (disagreement), deep-indented branches including main still satisfies the leg (waiver stale). Full contract suite passes, including the 82 generated oracle cases. --- .github/scripts/check-ci-policy-agreement.sh | 8 ++++- .../scripts/check-ci-policy-agreement.test.sh | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index d7411efe5a..a59afcccd8 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -330,6 +330,8 @@ push_targets_main() { ind = RLENGTH if (child_indent == 0) child_indent = ind if (ind != child_indent) next + seq_key_indent = ind + seq_indent = 0 subkey = substr(line, ind + 1) sub(/:.*/, "", subkey) gsub(/["\047]/, "", subkey) @@ -369,7 +371,11 @@ push_targets_main() { item = $0 match(item, /^ +/) ind = RLENGTH - if (child_indent == 0 || (ind != child_indent && ind != child_indent + 2)) next + if (seq_indent == 0) { + if (ind < seq_key_indent) next + seq_indent = ind + } + if (ind != seq_indent) next sub(/^ +-[[:space:]]*/, "", item) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", item) if (subkey == "branches") { diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index f033e64ca6..ede2360ee6 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -183,6 +183,42 @@ fi grep -q "DISAGREEMENT mcpx-fix-test-guard.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-unwaived.out" echo "pass: unwaived main leg with branches-ignore: [main] fails as disagreement" +# Codex P2 (PR #8513): block-sequence items indented deeper than +# key+2 are valid YAML and must still be read — a branches-ignore +# key at four spaces with its item at eight excludes main exactly +# like the six-space form above. +build_tree "$TMP/filter-unwaived-deep" +wf_raw "$TMP/filter-unwaived-deep" mcpx-fix-test-guard.yml <<'EOF' + pull_request: + workflow_dispatch: + push: + branches-ignore: + - main +EOF +if bash "$SCRIPT" "$TMP/filter-unwaived-deep" >"$TMP/filter-unwaived-deep.out" 2>&1; then + echo "FAIL: checker certified an unwaived main leg whose deep-indented branches-ignore excludes main" >&2 + exit 1 +fi +grep -q "DISAGREEMENT mcpx-fix-test-guard.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-unwaived-deep.out" +echo "pass: deep-indented block-sequence branches-ignore item still excludes main" + +# And the mirror image: a deep-indented branches block list that +# includes main satisfies the main leg (the waiver goes stale). +build_tree "$TMP/filter-main-list-deep" +wf_raw "$TMP/filter-main-list-deep" mcpx-nixbuild.yml <<'EOF' + pull_request: + workflow_dispatch: + push: + branches: + - main +EOF +if bash "$SCRIPT" "$TMP/filter-main-list-deep" >"$TMP/filter-main-list-deep.out" 2>&1; then + echo "FAIL: checker accepted a stale waiver for a deep-indented block-sequence branches: [main]" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-main-list-deep.out" +echo "pass: deep-indented block-sequence branches including main satisfies the main leg" + # Missing policy row: production-line guard's row vanishes. build_tree "$TMP/norow" grep -v "production-line guard" "$TMP/norow/.github/ci-policy.md" >"$TMP/norow/policy.tmp" From dbbc7ae93150f3c8cd8317b412f25d8f8912f437 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 07:31:00 -0600 Subject: [PATCH 13/19] fix(ci-policy checker): decode YAML double-quoted escapes before pattern matching (Codex P2 round 11 on #8513) --- .github/scripts/check-ci-policy-agreement.sh | 65 ++++++++++++++++++- .../scripts/check-ci-policy-agreement.test.sh | 44 +++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index a59afcccd8..007acbf352 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -135,23 +135,81 @@ triggers_of() { push_targets_main() { local file="$1" awk ' + function hexval(str, v, i, d) { + v = 0 + for (i = 1; i <= length(str); i++) { + d = index("0123456789abcdef", tolower(substr(str, i, 1))) - 1 + if (d < 0) return -1 + v = v * 16 + d + } + return v + } + function codepoint_char(cp, b1, b2, b3, b4) { + if (cp < 128) return sprintf("%c", cp) + if (cp < 2048) return sprintf("%c%c", 192 + int(cp / 64), 128 + (cp % 64)) + if (cp < 65536) return sprintf("%c%c%c", 224 + int(cp / 4096), 128 + (int(cp / 64) % 64), 128 + (cp % 64)) + return sprintf("%c%c%c%c", 240 + int(cp / 262144), 128 + (int(cp / 4096) % 64), 128 + (int(cp / 64) % 64), 128 + (cp % 64)) + } + function decode_dq(str, out, i, c, n, dn, cp) { + # Decode the escapes of a YAML double-quoted scalar: the simple + # escapes and the \xXX / \uXXXX / \UXXXXXXXX forms. An + # unrecognized or truncated escape keeps its backslash; + # decoding never invents characters. + out = "" + for (i = 1; i <= length(str); i++) { + c = substr(str, i, 1) + if (c != "\\") { out = out c; continue } + if (i == length(str)) { out = out "\\"; break } + n = substr(str, i + 1, 1) + if (n == "0") { out = out sprintf("%c", 0); i++ } + else if (n == "a") { out = out sprintf("%c", 7); i++ } + else if (n == "b") { out = out sprintf("%c", 8); i++ } + else if (n == "t") { out = out "\t"; i++ } + else if (n == "n") { out = out "\n"; i++ } + else if (n == "v") { out = out sprintf("%c", 11); i++ } + else if (n == "f") { out = out sprintf("%c", 12); i++ } + else if (n == "r") { out = out "\r"; i++ } + else if (n == "e") { out = out sprintf("%c", 27); i++ } + else if (n == " ") { out = out " "; i++ } + else if (n == "\"") { out = out "\""; i++ } + else if (n == "/") { out = out "/"; i++ } + else if (n == "\\") { out = out "\\"; i++ } + else if (n == "N") { out = out codepoint_char(133); i++ } + else if (n == "_") { out = out codepoint_char(160); i++ } + else if (n == "L") { out = out codepoint_char(8232); i++ } + else if (n == "P") { out = out codepoint_char(8233); i++ } + else if (n == "x" || n == "u" || n == "U") { + dn = (n == "x") ? 2 : (n == "u") ? 4 : 8 + if (i + 1 + dn <= length(str) && (cp = hexval(substr(str, i + 2, dn))) >= 0) { out = out codepoint_char(cp); i += 1 + dn } + else out = out "\\" + } + else out = out "\\" + } + return out + } function clean(tok) { sub(/^[[:space:]]+/, "", tok) sub(/[[:space:]]+$/, "", tok) if (length(tok) >= 2) { - if ((substr(tok, 1, 1) == "\047" && substr(tok, length(tok), 1) == "\047") || (substr(tok, 1, 1) == "\"" && substr(tok, length(tok), 1) == "\"")) tok = substr(tok, 2, length(tok) - 2) + if (substr(tok, 1, 1) == "\047" && substr(tok, length(tok), 1) == "\047") tok = substr(tok, 2, length(tok) - 2) + else if (substr(tok, 1, 1) == "\"" && substr(tok, length(tok), 1) == "\"") tok = decode_dq(substr(tok, 2, length(tok) - 2)) } return tok } - function add_tokens(str, i, c, q, tok, out) { + function add_tokens(str, i, c, q, tok, seg, out) { sub(/^[[:space:]]*\[/, "", str) sub(/\][[:space:]]*$/, "", str) out = "" tok = "" + seg = "" q = "" for (i = 1; i <= length(str); i++) { c = substr(str, i, 1) - if (q != "") { + if (q == "\"") { + if (c == "\"") { tok = tok decode_dq(seg); seg = ""; q = "" } + else if (c == "\\" && i < length(str)) { seg = seg c substr(str, i + 1, 1); i++ } + else seg = seg c + } else if (q != "") { if (c == q) q = "" else tok = tok c } else if (c == "\047" || c == "\"") { @@ -162,6 +220,7 @@ push_targets_main() { tok = tok c } } + if (q == "\"") tok = tok decode_dq(seg) if (tok != "") out = out " " tok return out } diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index ede2360ee6..cf996587fd 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -677,6 +677,50 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_split_main.out" echo "pass: split inline push mapping with branches: [main] satisfies the main leg" +# Codex P2 regression on #8513 round 11: a double-quoted YAML +# scalar's escapes decode before pattern matching -- "ma\u0069n" +# is the branch main, in flow lists and block items alike. A +# single-quoted scalar keeps its backslashes literally. +build_tree "$TMP/filter-dq_escape_flow" +wf_raw "$TMP/filter-dq_escape_flow" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ["ma\u0069n"] +EOF +if bash "$SCRIPT" "$TMP/filter-dq_escape_flow" >"$TMP/filter-dq_escape_flow.out" 2>&1; then + echo "FAIL: checker missed a \u-escaped main in a flow list" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-dq_escape_flow.out" +echo "pass: double-quoted \u escape in a flow list satisfies the main leg" + +build_tree "$TMP/filter-dq_escape_block" +wf_raw "$TMP/filter-dq_escape_block" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: + - "ma\u0069n" +EOF +if bash "$SCRIPT" "$TMP/filter-dq_escape_block" >"$TMP/filter-dq_escape_block.out" 2>&1; then + echo "FAIL: checker missed a \u-escaped main in a block item" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-dq_escape_block.out" +echo "pass: double-quoted \u escape in a block item satisfies the main leg" + +build_tree "$TMP/filter-dq_escape_hex" +wf_raw "$TMP/filter-dq_escape_hex" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ["m\x61in", 'lit\u0065ral'] +EOF +if bash "$SCRIPT" "$TMP/filter-dq_escape_hex" >"$TMP/filter-dq_escape_hex.out" 2>&1; then + echo "FAIL: checker missed a \x-escaped main in a flow list" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-dq_escape_hex.out" +echo "pass: double-quoted \x escape in a flow list satisfies the main leg" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From 378032f0b4f06148fd10c51d5bd48851b43058fa Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 08:25:37 -0600 Subject: [PATCH 14/19] =?UTF-8?q?fix(ci-policy):=20quote-aware=20structura?= =?UTF-8?q?l=20scanning=20=E2=80=94=20quoted=20braces=20and=20escaped=20qu?= =?UTF-8?q?otes=20(#7950)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex P2 round 12 on PR #8513: (1) a } inside a quoted scalar ended an inline mapping early, hiding the continuation branches-ignore; (2) an escaped quote ended the flow scanners quoted state, discarding the whole branch filter. unquoted_close/flow_unclosed now honor backslash escapes in double-quoted scalars and doubled quotes in single-quoted scalars, and inline-mapping completion is decided by a new has_unquoted_brace scanner on both the opening and continuation lines. Two regression cases pin both findings; the suite (incl. 82 generated oracle cases) passes with the fix and fails without it. --- .github/scripts/check-ci-policy-agreement.sh | 44 +++++++++++++++++-- .../scripts/check-ci-policy-agreement.test.sh | 34 ++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 007acbf352..415368b31d 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -224,11 +224,25 @@ push_targets_main() { if (tok != "") out = out " " tok return out } + # Quote discipline for the structural scanners (Codex P2, PR + # #8513 round 12): inside a double-quoted scalar a backslash + # escapes the next character, so \" does not end the scalar; + # inside a single-quoted scalar a doubled '' is an escaped + # quote, not the end. The scalar decoder (decode_dq) already + # honors the escapes — the scanners that decide where scalars + # and structures end must honor them too, or a delimiter inside + # a quoted scalar is mistaken for structure. function unquoted_close(str, j, c, q) { q = "" for (j = 1; j <= length(str); j++) { c = substr(str, j, 1) - if (q != "") { if (c == q) q = "" } + if (q == "\"") { + if (c == "\\") j++ + else if (c == "\"") q = "" + } else if (q == "\047") { + if (c == "\047" && substr(str, j + 1, 1) == "\047") j++ + else if (c == "\047") q = "" + } else if (c == "\047" || c == "\"") q = c else if (c == "]") return j } @@ -239,13 +253,35 @@ push_targets_main() { open = 0 for (j = 1; j <= length(str); j++) { c = substr(str, j, 1) - if (q != "") { if (c == q) q = "" } + if (q == "\"") { + if (c == "\\") j++ + else if (c == "\"") q = "" + } else if (q == "\047") { + if (c == "\047" && substr(str, j + 1, 1) == "\047") j++ + else if (c == "\047") q = "" + } else if (c == "\047" || c == "\"") q = c else if (c == "[") open = 1 else if (c == "]" && open) open = 0 } return open } + function has_unquoted_brace(str, j, c, q) { + q = "" + for (j = 1; j <= length(str); j++) { + c = substr(str, j, 1) + if (q == "\"") { + if (c == "\\") j++ + else if (c == "\"") q = "" + } else if (q == "\047") { + if (c == "\047" && substr(str, j + 1, 1) == "\047") j++ + else if (c == "\047") q = "" + } + else if (c == "\047" || c == "\"") q = c + else if (c == "}") return 1 + } + return 0 + } function flow_span(str, key, i, start, seg, from, prev) { from = 1 while ((i = index(substr(str, from), key)) > 0) { @@ -361,7 +397,7 @@ push_targets_main() { rest = $0 sub(/^ ["\047]?[a-z_]+["\047]?:[[:space:]]*/, "", rest) if (rest ~ /^\{/) { - if (rest ~ /\}/) apply_inline_filters(rest) + if (has_unquoted_brace(rest)) apply_inline_filters(rest) else { inline_collect = 1; inline_buf = rest } } } @@ -375,7 +411,7 @@ push_targets_main() { inline_collect = 0 } else { inline_buf = inline_buf " " $0 - if ($0 ~ /\}/) { + if (has_unquoted_brace($0)) { apply_inline_filters(inline_buf) inline_collect = 0 } diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index cf996587fd..64d0788821 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -721,6 +721,40 @@ fi grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-dq_escape_hex.out" echo "pass: double-quoted \x escape in a flow list satisfies the main leg" +# Codex P2 regressions on #8513 round 12: a brace inside a quoted +# scalar does not end an inline mapping, and an escaped quote does +# not end a double-quoted scalar for the structural scanners. In +# both cases branches-ignore: [main] must be seen — main is +# excluded, so the main leg stays waived. +build_tree "$TMP/filter-inline_quoted_brace" +wf_raw "$TMP/filter-inline_quoted_brace" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {paths: ['docs/}file'], + branches-ignore: [main]} +EOF +bash "$SCRIPT" "$TMP/filter-inline_quoted_brace" >"$TMP/filter-inline_quoted_brace.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_quoted_brace.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-inline_quoted_brace.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_quoted_brace.out"; then + echo "FAIL: a quoted brace ended the inline mapping early and hid branches-ignore" >&2 + exit 1 +fi +echo "pass: quoted brace inside an inline mapping does not hide the continuation's branches-ignore" + +build_tree "$TMP/filter-flow_escaped_quote" +wf_raw "$TMP/filter-flow_escaped_quote" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches-ignore: ["release\"x", "main"]} +EOF +bash "$SCRIPT" "$TMP/filter-flow_escaped_quote" >"$TMP/filter-flow_escaped_quote.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-flow_escaped_quote.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-flow_escaped_quote.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-flow_escaped_quote.out"; then + echo "FAIL: an escaped quote broke flow scanning and discarded branches-ignore" >&2 + exit 1 +fi +echo "pass: escaped quote in a flow list does not discard the branch filter" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From 066a9802dfcefd073d33cc1ab1c0f05bdd7696e1 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 09:03:31 -0600 Subject: [PATCH 15/19] fix(ci-policy): YAML comments end structural scans; resolve anchored/aliased push filters (#7950) --- .github/scripts/check-ci-policy-agreement.sh | 131 +++++++++++++++++- .../scripts/check-ci-policy-agreement.test.sh | 89 ++++++++++++ 2 files changed, 214 insertions(+), 6 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 415368b31d..87b4e4e62d 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -232,6 +232,10 @@ push_targets_main() { # honors the escapes — the scanners that decide where scalars # and structures end must honor them too, or a delimiter inside # a quoted scalar is mistaken for structure. + # A YAML comment starts at an unquoted # that begins the line + # or follows whitespace (Codex P2, PR #8513 round 13): braces + # and brackets inside comments are not structure, so every + # structural scanner stops there. function unquoted_close(str, j, c, q) { q = "" for (j = 1; j <= length(str); j++) { @@ -244,6 +248,7 @@ push_targets_main() { else if (c == "\047") q = "" } else if (c == "\047" || c == "\"") q = c + else if (c == "#" && (j == 1 || substr(str, j - 1, 1) ~ /[[:space:]]/)) return 0 else if (c == "]") return j } return 0 @@ -261,6 +266,7 @@ push_targets_main() { else if (c == "\047") q = "" } else if (c == "\047" || c == "\"") q = c + else if (c == "#" && (j == 1 || substr(str, j - 1, 1) ~ /[[:space:]]/)) return open else if (c == "[") open = 1 else if (c == "]" && open) open = 0 } @@ -278,6 +284,7 @@ push_targets_main() { else if (c == "\047") q = "" } else if (c == "\047" || c == "\"") q = c + else if (c == "#" && (j == 1 || substr(str, j - 1, 1) ~ /[[:space:]]/)) return 0 else if (c == "}") return 1 } return 0 @@ -315,6 +322,30 @@ push_targets_main() { if (str ~ /(^|[{,][[:space:]]*)["\047]?tags-ignore["\047]?[[:space:]]*:/) seen_tags = 1 if (str ~ /(^|[{,][[:space:]]*)["\047]?tags["\047]?[[:space:]]*:/) seen_tags = 1 } + function resolve_push_alias(name, before) { + # An aliased push inherits the anchored mapping filters + # (Codex P2, PR #8513 round 13). An alias that resolves to + # no recorded filter is unsupported syntax: mark it so the + # verdict never certifies it as an unfiltered push. + if (name in anchor_body) { + before = seen_branches seen_branch_filter seen_tags + apply_inline_filters(anchor_body[name]) + if ((seen_branches seen_branch_filter seen_tags) == before) alias_unknown = 1 + } else if ((name in anchor_seen_branches) || (name in anchor_seen_ignore) || (name in anchor_seen_tags)) { + if (name in anchor_seen_ignore) { + seen_branch_filter = 1 + ignore_list = ignore_list anchor_ignore[name] + } + if (name in anchor_seen_branches) { + seen_branches = 1 + seen_branch_filter = 1 + branches_list = branches_list anchor_branches[name] + } + if (name in anchor_seen_tags) seen_tags = 1 + } else { + alias_unknown = 1 + } + } function glob_regex(pat, out, i, c, cls) { # GitHub filter-pattern syntax (workflow-syntax cheat sheet), # not shell glob: ? and + quantify the preceding character, @@ -392,33 +423,119 @@ push_targets_main() { gsub(/["\047]/, "", key) inpush = (key == "push") if (!inpush) child_indent = 0 + rest = $0 + sub(/^ ["\047]?[a-z_]+["\047]?:[[:space:]]*/, "", rest) + # YAML anchors (Codex P2, PR #8513 round 13): a mapping + # value may carry &name and be referenced later as *name. + # Record anchored bodies so an aliased push resolves to + # its filters instead of looking like an unfiltered push. + anchor_here = "" + if (rest ~ /^&[A-Za-z0-9_-]+([[:space:]]|$)/) { + anchor_here = rest + sub(/^&/, "", anchor_here) + sub(/[[:space:]].*/, "", anchor_here) + sub(/^&[A-Za-z0-9_-]+[[:space:]]*/, "", rest) + if (rest ~ /^\{/) anchor_body[anchor_here] = rest + } + cur_anchor = anchor_here + anchor_child_indent = 0 + anchor_flow_key = "" + anchor_seq_indent = 0 if (inpush) { seen_push = 1 - rest = $0 - sub(/^ ["\047]?[a-z_]+["\047]?:[[:space:]]*/, "", rest) - if (rest ~ /^\{/) { + if (rest ~ /^\*[A-Za-z0-9_-]+/) { + alias = substr(rest, 2) + sub(/[^A-Za-z0-9_-].*/, "", alias) + resolve_push_alias(alias) + } else if (rest ~ /^\{/) { if (has_unquoted_brace(rest)) apply_inline_filters(rest) - else { inline_collect = 1; inline_buf = rest } + else { inline_collect = 1; inline_buf = rest; inline_anchor = anchor_here } } } subkey = "" next } - inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0; child_indent = 0 } + inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0; child_indent = 0; cur_anchor = "" } inline_collect { if ($0 ~ /^[^[:space:]#]/) { apply_inline_filters(inline_buf) + if (inline_anchor != "") { anchor_body[inline_anchor] = inline_buf; inline_anchor = "" } inline_collect = 0 } else { inline_buf = inline_buf " " $0 if (has_unquoted_brace($0)) { apply_inline_filters(inline_buf) + if (inline_anchor != "") { anchor_body[inline_anchor] = inline_buf; inline_anchor = "" } inline_collect = 0 } next } } + !inpush && cur_anchor != "" && /^ +["\047]?[a-z-]+["\047]?:/ { + line = $0 + match(line, /^ +/) + ind = RLENGTH + if (anchor_child_indent == 0) anchor_child_indent = ind + if (ind != anchor_child_indent) next + anchor_seq_key_indent = ind + anchor_seq_indent = 0 + subkey_a = substr(line, ind + 1) + sub(/:.*/, "", subkey_a) + gsub(/["\047]/, "", subkey_a) + val = substr(line, ind + 1) + sub(/^[^:]*:[[:space:]]*/, "", val) + if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") sub(/[[:space:]]#.*/, "", val) + if ((subkey_a == "branches" || subkey_a == "branches-ignore") && flow_unclosed(val)) anchor_flow_key = subkey_a + if (subkey_a == "branches") { + anchor_seen_branches[cur_anchor] = 1 + anchor_branches[cur_anchor] = add_tokens(val) + } else if (subkey_a == "branches-ignore") { + anchor_seen_ignore[cur_anchor] = 1 + anchor_ignore[cur_anchor] = add_tokens(val) + } else if (subkey_a == "tags" || subkey_a == "tags-ignore") { + anchor_seen_tags[cur_anchor] = 1 + } + next + } + !inpush && cur_anchor != "" && anchor_flow_key != "" { + seg = $0 + sub(/[[:space:]]#.*/, "", seg) + k = unquoted_close(seg) + if (k > 0) { + seg = substr(seg, 1, k - 1) + if (anchor_flow_key == "branches") anchor_branches[cur_anchor] = anchor_branches[cur_anchor] add_tokens(seg) + else if (anchor_flow_key == "branches-ignore") anchor_ignore[cur_anchor] = anchor_ignore[cur_anchor] add_tokens(seg) + anchor_flow_key = "" + } else if (anchor_flow_key == "branches") { + anchor_branches[cur_anchor] = anchor_branches[cur_anchor] add_tokens(seg) + } else if (anchor_flow_key == "branches-ignore") { + anchor_ignore[cur_anchor] = anchor_ignore[cur_anchor] add_tokens(seg) + } + next + } + !inpush && cur_anchor != "" && /^ +-[[:space:]]/ { + item = $0 + match(item, /^ +/) + ind = RLENGTH + if (anchor_seq_indent == 0) { + if (ind < anchor_seq_key_indent) next + anchor_seq_indent = ind + } + if (ind != anchor_seq_indent) next + sub(/^ +-[[:space:]]*/, "", item) + if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") sub(/[[:space:]]#.*/, "", item) + if (subkey_a == "branches") { + anchor_seen_branches[cur_anchor] = 1 + anchor_branches[cur_anchor] = anchor_branches[cur_anchor] " " clean(item) + } else if (subkey_a == "branches-ignore") { + anchor_seen_ignore[cur_anchor] = 1 + anchor_ignore[cur_anchor] = anchor_ignore[cur_anchor] " " clean(item) + } else if (subkey_a == "tags" || subkey_a == "tags-ignore") { + anchor_seen_tags[cur_anchor] = 1 + } + next + } inpush && /^ +["\047]?[a-z-]+["\047]?:/ { line = $0 match(line, /^ +/) @@ -494,7 +611,9 @@ push_targets_main() { print "absent" exit } - if (list_matches_main(ignore_list)) { + if (alias_unknown) { + print "no" + } else if (list_matches_main(ignore_list)) { print "no" } else if (seen_branches) { if (branches_allow_main(branches_list)) print "yes" diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 64d0788821..e164fc514f 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -755,6 +755,95 @@ if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-flow_escaped_quote.out" fi echo "pass: escaped quote in a flow list does not discard the branch filter" +# Codex P2 regressions on #8513 round 13: a brace inside a YAML +# comment does not terminate an inline mapping, and YAML anchors / +# aliases on trigger mappings resolve to their filters instead of +# looking like unfiltered pushes. +build_tree "$TMP/filter-inline_comment_brace" +wf_raw "$TMP/filter-inline_comment_brace" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: { # closing brace } in comment + branches-ignore: [main]} +EOF +bash "$SCRIPT" "$TMP/filter-inline_comment_brace" >"$TMP/filter-inline_comment_brace.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_comment_brace.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-inline_comment_brace.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_comment_brace.out"; then + echo "FAIL: a brace in a YAML comment ended the inline mapping early and hid branches-ignore" >&2 + exit 1 +fi +echo "pass: brace in a YAML comment does not hide the continuation's branches-ignore" + +build_tree "$TMP/filter-inline_comment_brace_main" +wf_raw "$TMP/filter-inline_comment_brace_main" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: { # } comment + branches: [main]} +EOF +if bash "$SCRIPT" "$TMP/filter-inline_comment_brace_main" >"$TMP/filter-inline_comment_brace_main.out" 2>&1; then + echo "FAIL: checker missed branches: [main] after a comment brace" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_comment_brace_main.out" +echo "pass: branches: [main] after a comment brace satisfies the main leg" + +build_tree "$TMP/filter-anchor_alias_block" +wf_raw "$TMP/filter-anchor_alias_block" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: &release_only + branches: [release] + push: *release_only +EOF +bash "$SCRIPT" "$TMP/filter-anchor_alias_block" >"$TMP/filter-anchor_alias_block.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_alias_block.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_alias_block.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_alias_block.out"; then + echo "FAIL: an aliased release-only push was certified as targeting main" >&2 + exit 1 +fi +echo "pass: push aliased to an anchored block mapping inherits its branches filter" + +build_tree "$TMP/filter-anchor_inline_push" +wf_raw "$TMP/filter-anchor_inline_push" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: &release_only {branches: [release]} +EOF +bash "$SCRIPT" "$TMP/filter-anchor_inline_push" >"$TMP/filter-anchor_inline_push.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_inline_push.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_inline_push.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_inline_push.out"; then + echo "FAIL: an anchored inline release-only push was certified as targeting main" >&2 + exit 1 +fi +echo "pass: anchored inline push mapping applies its branches filter" + +build_tree "$TMP/filter-anchor_alias_inline" +wf_raw "$TMP/filter-anchor_alias_inline" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: &release_only {branches: [release]} + push: *release_only +EOF +bash "$SCRIPT" "$TMP/filter-anchor_alias_inline" >"$TMP/filter-anchor_alias_inline.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_alias_inline.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_alias_inline.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_alias_inline.out"; then + echo "FAIL: an aliased inline-anchored push was certified as targeting main" >&2 + exit 1 +fi +echo "pass: push aliased to an anchored inline mapping inherits its branches filter" + +build_tree "$TMP/filter-anchor_unknown_alias" +wf_raw "$TMP/filter-anchor_unknown_alias" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: *never_defined +EOF +bash "$SCRIPT" "$TMP/filter-anchor_unknown_alias" >"$TMP/filter-anchor_unknown_alias.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_unknown_alias.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_unknown_alias.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_unknown_alias.out"; then + echo "FAIL: an unresolvable alias was certified as an unfiltered push" >&2 + exit 1 +fi +echo "pass: an unresolvable push alias is never certified as targeting main" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From a86189a18363fab3f514c380e895ef99123ad613 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 11:27:03 -0600 Subject: [PATCH 16/19] fix(ci-policy): strip comments per physical line in split inline mappings; accept spaced colons (Codex round 14 on #8513) Split inline push mappings now strip each physical line comment (quote-aware) before joining, so a comment ending a line no longer swallows the closing bracket of a branch filter on the continuation line. Block, anchored-block, top-level, triggers_of and inline filter keys accept whitespace before the mapping colon and trim it from the extracted key. Anchor-test assertions normalized to the same escaping as the rest of the suite. Four new contract cases; full suite green incl 82 oracle cases; real-tree run still OK with the recorded waiver set. --- .github/scripts/check-ci-policy-agreement.sh | 46 +++++++++-- .../scripts/check-ci-policy-agreement.test.sh | 77 +++++++++++++++++-- 2 files changed, 110 insertions(+), 13 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 87b4e4e62d..3bd0d52fa3 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -107,11 +107,12 @@ triggers_of() { exit } /^"?on"?:[[:space:]]*$/ { inblock = 1; next } - inblock && /^ ["\047]?[a-z_]+["\047]?:/ { + inblock && /^ ["\047]?[a-z_]+["\047]?[[:space:]]*:/ { key = $0 sub(/^ /, "", key) sub(/:.*/, "", key) gsub(/["\047]/, "", key) + sub(/[[:space:]]+$/, "", key) print key next } @@ -253,6 +254,29 @@ push_targets_main() { } return 0 } + # strip_comment: the text of a line up to (not including) an + # unquoted comment start, with the same quote discipline as + # unquoted_close. Joining physical lines into one logical line + # (inline_collect) must strip each line first (Codex P2, PR + # #8513 round 14): flattening first puts a closing bracket + # that follows a comment inside that comment, and the filter + # it closes is silently discarded. + function strip_comment(str, j, c, q) { + q = "" + for (j = 1; j <= length(str); j++) { + c = substr(str, j, 1) + if (q == "\"") { + if (c == "\\") j++ + else if (c == "\"") q = "" + } else if (q == "\047") { + if (c == "\047" && substr(str, j + 1, 1) == "\047") j++ + else if (c == "\047") q = "" + } + else if (c == "\047" || c == "\"") q = c + else if (c == "#" && (j == 1 || substr(str, j - 1, 1) ~ /[[:space:]]/)) return substr(str, 1, j - 1) + } + return str + } function flow_unclosed(str, j, c, q, open) { q = "" open = 0 @@ -309,11 +333,13 @@ push_targets_main() { } function apply_inline_filters(str, seg) { seg = flow_span(str, "branches-ignore:") + if (seg == "") seg = flow_span(str, "branches-ignore :") if (seg != "") { seen_branch_filter = 1 ignore_list = ignore_list add_tokens(seg) } seg = flow_span(str, "branches:") + if (seg == "") seg = flow_span(str, "branches :") if (seg != "") { seen_branches = 1 seen_branch_filter = 1 @@ -416,15 +442,16 @@ push_targets_main() { exit } /^"?on"?:[[:space:]]*$/ { inblock = 1; next } - inblock && /^ ["\047]?[a-z_]+["\047]?:/ { + inblock && /^ ["\047]?[a-z_]+["\047]?[[:space:]]*:/ { key = $0 sub(/^ /, "", key) sub(/:.*/, "", key) gsub(/["\047]/, "", key) + sub(/[[:space:]]+$/, "", key) inpush = (key == "push") if (!inpush) child_indent = 0 rest = $0 - sub(/^ ["\047]?[a-z_]+["\047]?:[[:space:]]*/, "", rest) + sub(/^ ["\047]?[a-z_]+["\047]?[[:space:]]*:[[:space:]]*/, "", rest) # YAML anchors (Codex P2, PR #8513 round 13): a mapping # value may carry &name and be referenced later as *name. # Record anchored bodies so an aliased push resolves to @@ -449,7 +476,7 @@ push_targets_main() { resolve_push_alias(alias) } else if (rest ~ /^\{/) { if (has_unquoted_brace(rest)) apply_inline_filters(rest) - else { inline_collect = 1; inline_buf = rest; inline_anchor = anchor_here } + else { inline_collect = 1; inline_buf = strip_comment(rest); inline_anchor = anchor_here } } } subkey = "" @@ -462,8 +489,9 @@ push_targets_main() { if (inline_anchor != "") { anchor_body[inline_anchor] = inline_buf; inline_anchor = "" } inline_collect = 0 } else { - inline_buf = inline_buf " " $0 - if (has_unquoted_brace($0)) { + inline_line = strip_comment($0) + inline_buf = inline_buf " " inline_line + if (has_unquoted_brace(inline_line)) { apply_inline_filters(inline_buf) if (inline_anchor != "") { anchor_body[inline_anchor] = inline_buf; inline_anchor = "" } inline_collect = 0 @@ -472,7 +500,7 @@ push_targets_main() { } } - !inpush && cur_anchor != "" && /^ +["\047]?[a-z-]+["\047]?:/ { + !inpush && cur_anchor != "" && /^ +["\047]?[a-z-]+["\047]?[[:space:]]*:/ { line = $0 match(line, /^ +/) ind = RLENGTH @@ -483,6 +511,7 @@ push_targets_main() { subkey_a = substr(line, ind + 1) sub(/:.*/, "", subkey_a) gsub(/["\047]/, "", subkey_a) + sub(/[[:space:]]+$/, "", subkey_a) val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") sub(/[[:space:]]#.*/, "", val) @@ -536,7 +565,7 @@ push_targets_main() { } next } - inpush && /^ +["\047]?[a-z-]+["\047]?:/ { + inpush && /^ +["\047]?[a-z-]+["\047]?[[:space:]]*:/ { line = $0 match(line, /^ +/) ind = RLENGTH @@ -547,6 +576,7 @@ push_targets_main() { subkey = substr(line, ind + 1) sub(/:.*/, "", subkey) gsub(/["\047]/, "", subkey) + sub(/[[:space:]]+$/, "", subkey) val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index e164fc514f..840d1823e0 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -767,7 +767,7 @@ wf_raw "$TMP/filter-inline_comment_brace" mcpx-nixbuild.yml <<'EOF' EOF bash "$SCRIPT" "$TMP/filter-inline_comment_brace" >"$TMP/filter-inline_comment_brace.out" grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_comment_brace.out" -grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-inline_comment_brace.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-inline_comment_brace.out" if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_comment_brace.out"; then echo "FAIL: a brace in a YAML comment ended the inline mapping early and hid branches-ignore" >&2 exit 1 @@ -795,7 +795,7 @@ wf_raw "$TMP/filter-anchor_alias_block" mcpx-nixbuild.yml <<'EOF' EOF bash "$SCRIPT" "$TMP/filter-anchor_alias_block" >"$TMP/filter-anchor_alias_block.out" grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_alias_block.out" -grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_alias_block.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-anchor_alias_block.out" if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_alias_block.out"; then echo "FAIL: an aliased release-only push was certified as targeting main" >&2 exit 1 @@ -809,7 +809,7 @@ wf_raw "$TMP/filter-anchor_inline_push" mcpx-nixbuild.yml <<'EOF' EOF bash "$SCRIPT" "$TMP/filter-anchor_inline_push" >"$TMP/filter-anchor_inline_push.out" grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_inline_push.out" -grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_inline_push.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-anchor_inline_push.out" if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_inline_push.out"; then echo "FAIL: an anchored inline release-only push was certified as targeting main" >&2 exit 1 @@ -823,7 +823,7 @@ wf_raw "$TMP/filter-anchor_alias_inline" mcpx-nixbuild.yml <<'EOF' EOF bash "$SCRIPT" "$TMP/filter-anchor_alias_inline" >"$TMP/filter-anchor_alias_inline.out" grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_alias_inline.out" -grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_alias_inline.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-anchor_alias_inline.out" if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_alias_inline.out"; then echo "FAIL: an aliased inline-anchored push was certified as targeting main" >&2 exit 1 @@ -837,13 +837,80 @@ wf_raw "$TMP/filter-anchor_unknown_alias" mcpx-nixbuild.yml <<'EOF' EOF bash "$SCRIPT" "$TMP/filter-anchor_unknown_alias" >"$TMP/filter-anchor_unknown_alias.out" grep -q "ci-policy-agreement: OK" "$TMP/filter-anchor_unknown_alias.out" -grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-anchor_unknown_alias.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-anchor_unknown_alias.out" if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_unknown_alias.out"; then echo "FAIL: an unresolvable alias was certified as an unfiltered push" >&2 exit 1 fi echo "pass: an unresolvable push alias is never certified as targeting main" +# Round-14 (Codex P2): a comment that ends the first physical line +# of a split inline mapping must not swallow the closing bracket +# on the continuation line — the comment ends at the newline, so +# the release-only filter survives and the leg stays waived. +build_tree "$TMP/filter-inline_comment_split" +wf_raw "$TMP/filter-inline_comment_split" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches: [ # release only + release]} +EOF +bash "$SCRIPT" "$TMP/filter-inline_comment_split" >"$TMP/filter-inline_comment_split.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_comment_split.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-inline_comment_split.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_comment_split.out"; then + echo "FAIL: a comment on a split inline mapping line swallowed its branch filter" >&2 + exit 1 +fi +echo "pass: a comment ending a split inline mapping line does not swallow the closing bracket" + +# Round-14 (Codex P2): YAML allows whitespace before a mapping +# colon — branches : [release] is the same filter as +# branches: [release], and branches-ignore : [main] still +# excludes main; neither may be read as an unfiltered push. +build_tree "$TMP/filter-spaced_colon" +wf_raw "$TMP/filter-spaced_colon" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches : [release] +EOF +bash "$SCRIPT" "$TMP/filter-spaced_colon" >"$TMP/filter-spaced_colon.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-spaced_colon.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-spaced_colon.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-spaced_colon.out"; then + echo "FAIL: a spaced-colon branches filter was read as an unfiltered push" >&2 + exit 1 +fi +echo "pass: branches with a spaced colon keeps the main leg waived" + +build_tree "$TMP/filter-spaced_colon_ignore" +wf_raw "$TMP/filter-spaced_colon_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore : [main] +EOF +bash "$SCRIPT" "$TMP/filter-spaced_colon_ignore" >"$TMP/filter-spaced_colon_ignore.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-spaced_colon_ignore.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-spaced_colon_ignore.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-spaced_colon_ignore.out"; then + echo "FAIL: a spaced-colon branches-ignore filter was read as an unfiltered push" >&2 + exit 1 +fi +echo "pass: branches-ignore with a spaced colon keeps the main leg waived" + +build_tree "$TMP/filter-spaced_colon_inline" +wf_raw "$TMP/filter-spaced_colon_inline" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {branches : [release]} +EOF +bash "$SCRIPT" "$TMP/filter-spaced_colon_inline" >"$TMP/filter-spaced_colon_inline.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-spaced_colon_inline.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-spaced_colon_inline.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-spaced_colon_inline.out"; then + echo "FAIL: a spaced-colon inline branches filter was read as an unfiltered push" >&2 + exit 1 +fi +echo "pass: inline branches with a spaced colon keeps the main leg waived" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From 01a8df5801c16e461e7fdabb750adf85e10e743d Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 11:40:37 -0600 Subject: [PATCH 17/19] fix(ci-policy): quote-aware comment stripping on every filter path (Codex round 15 on #8513) All six quote-naive comment substitutions on filter values, flow continuations, block items and anchored filters now go through the quote-aware strip_comment(), so a # inside a quoted pattern no longer truncates the filter. Three new contract cases (branches-ignore flow, branches flow, anchored block); full suite green incl 82 oracle cases; real-tree run still OK. --- .github/scripts/check-ci-policy-agreement.sh | 20 ++++---- .../scripts/check-ci-policy-agreement.test.sh | 47 +++++++++++++++++++ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 3bd0d52fa3..f515188a57 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -260,7 +260,11 @@ push_targets_main() { # (inline_collect) must strip each line first (Codex P2, PR # #8513 round 14): flattening first puts a closing bracket # that follows a comment inside that comment, and the filter - # it closes is silently discarded. + # it closes is silently discarded. Every filter-value path + # strips through this helper, never a quote-naive substitution + # (Codex P2, round 15): a # inside a quoted pattern is data, + # not a comment, and truncating there discards the rest of + # the filter. function strip_comment(str, j, c, q) { q = "" for (j = 1; j <= length(str); j++) { @@ -514,7 +518,7 @@ push_targets_main() { sub(/[[:space:]]+$/, "", subkey_a) val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) - if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") sub(/[[:space:]]#.*/, "", val) + if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") val = strip_comment(val) if ((subkey_a == "branches" || subkey_a == "branches-ignore") && flow_unclosed(val)) anchor_flow_key = subkey_a if (subkey_a == "branches") { anchor_seen_branches[cur_anchor] = 1 @@ -528,8 +532,7 @@ push_targets_main() { next } !inpush && cur_anchor != "" && anchor_flow_key != "" { - seg = $0 - sub(/[[:space:]]#.*/, "", seg) + seg = strip_comment($0) k = unquoted_close(seg) if (k > 0) { seg = substr(seg, 1, k - 1) @@ -553,7 +556,7 @@ push_targets_main() { } if (ind != anchor_seq_indent) next sub(/^ +-[[:space:]]*/, "", item) - if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") sub(/[[:space:]]#.*/, "", item) + if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") item = strip_comment(item) if (subkey_a == "branches") { anchor_seen_branches[cur_anchor] = 1 anchor_branches[cur_anchor] = anchor_branches[cur_anchor] " " clean(item) @@ -579,7 +582,7 @@ push_targets_main() { sub(/[[:space:]]+$/, "", subkey) val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) - if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", val) + if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") val = strip_comment(val) if ((subkey == "branches" || subkey == "branches-ignore") && flow_unclosed(val)) flow_key = subkey if (subkey == "branches") { seen_branches = 1 @@ -594,8 +597,7 @@ push_targets_main() { next } inpush && flow_key != "" { - seg = $0 - sub(/[[:space:]]#.*/, "", seg) + seg = strip_comment($0) k = unquoted_close(seg) if (k > 0) { seg = substr(seg, 1, k - 1) @@ -619,7 +621,7 @@ push_targets_main() { } if (ind != seq_indent) next sub(/^ +-[[:space:]]*/, "", item) - if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") sub(/[[:space:]]#.*/, "", item) + if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") item = strip_comment(item) if (subkey == "branches") { seen_branches = 1 seen_branch_filter = 1 diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 840d1823e0..8f030a0e4e 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -911,6 +911,53 @@ if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-spaced_colon_inline.out fi echo "pass: inline branches with a spaced colon keeps the main leg waived" +# Round-15 (Codex P2): a # inside a quoted filter pattern is +# data, not a comment — truncating the value there discards the +# rest of the filter, including a main entry that excludes or +# includes main. +build_tree "$TMP/filter-quoted_hash_ignore" +wf_raw "$TMP/filter-quoted_hash_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: ['release # marker', main] +EOF +bash "$SCRIPT" "$TMP/filter-quoted_hash_ignore" >"$TMP/filter-quoted_hash_ignore.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_hash_ignore.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_hash_ignore.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_hash_ignore.out"; then + echo "FAIL: a quoted # in branches-ignore discarded the main exclusion" >&2 + exit 1 +fi +echo "pass: a quoted hash in branches-ignore does not discard the main exclusion" + +build_tree "$TMP/filter-quoted_hash_branches" +wf_raw "$TMP/filter-quoted_hash_branches" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ["release # marker", main] +EOF +if bash "$SCRIPT" "$TMP/filter-quoted_hash_branches" >"$TMP/filter-quoted_hash_branches.out" 2>&1; then + echo "FAIL: checker missed branches including main after a quoted hash" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-quoted_hash_branches.out" +echo "pass: a quoted hash in branches does not discard the main inclusion" + +build_tree "$TMP/filter-quoted_hash_anchor" +wf_raw "$TMP/filter-quoted_hash_anchor" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: &excl + branches-ignore: ['release # marker', main] + push: *excl +EOF +bash "$SCRIPT" "$TMP/filter-quoted_hash_anchor" >"$TMP/filter-quoted_hash_anchor.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-quoted_hash_anchor.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-quoted_hash_anchor.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_hash_anchor.out"; then + echo "FAIL: a quoted # in an anchored branches-ignore discarded the main exclusion" >&2 + exit 1 +fi +echo "pass: a quoted hash in an anchored branches-ignore does not discard the main exclusion" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From af5059f94fbb8fb899ed26ebf6c0cae2d63c436c Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 11:49:20 -0600 Subject: [PATCH 18/19] fix(ci-policy): doubled apostrophe in single-quoted filter values is one literal apostrophe (Codex round 16 on #8513) add_tokens now collapses a doubled single-quote escape to one literal apostrophe instead of dropping both (which rewrote the ma-apostrophe-in pattern as plain main), and clean() does the same for block-sequence items. Two new contract cases; full suite green incl 82 oracle cases; real-tree run still OK. --- .github/scripts/check-ci-policy-agreement.sh | 8 +++-- .../scripts/check-ci-policy-agreement.test.sh | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index f515188a57..3e13a14c94 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -192,7 +192,7 @@ push_targets_main() { sub(/^[[:space:]]+/, "", tok) sub(/[[:space:]]+$/, "", tok) if (length(tok) >= 2) { - if (substr(tok, 1, 1) == "\047" && substr(tok, length(tok), 1) == "\047") tok = substr(tok, 2, length(tok) - 2) + if (substr(tok, 1, 1) == "\047" && substr(tok, length(tok), 1) == "\047") { tok = substr(tok, 2, length(tok) - 2); gsub(/\047\047/, "\047", tok) } else if (substr(tok, 1, 1) == "\"" && substr(tok, length(tok), 1) == "\"") tok = decode_dq(substr(tok, 2, length(tok) - 2)) } return tok @@ -211,7 +211,11 @@ push_targets_main() { else if (c == "\\" && i < length(str)) { seg = seg c substr(str, i + 1, 1); i++ } else seg = seg c } else if (q != "") { - if (c == q) q = "" + # Single-quoted scalar: a doubled '' is one literal + # apostrophe (Codex P2, PR #8513 round 16); dropping + # both rewrites an apostrophe pattern as plain main. + if (c == q && substr(str, i + 1, 1) == q) { tok = tok q; i++ } + else if (c == q) q = "" else tok = tok c } else if (c == "\047" || c == "\"") { q = c diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index 8f030a0e4e..bda907d8f2 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -958,6 +958,38 @@ if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-quoted_hash_anchor.out" fi echo "pass: a quoted hash in an anchored branches-ignore does not discard the main exclusion" +# Round-16 (Codex P2): a doubled '' inside a single-quoted +# scalar is one literal apostrophe — 'ma''in' targets ma'in, +# not main. Dropping both apostrophes rewrites the pattern as +# main and certifies coverage that does not exist. +build_tree "$TMP/filter-doubled_apostrophe" +wf_raw "$TMP/filter-doubled_apostrophe" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches: ['ma''in'] +EOF +bash "$SCRIPT" "$TMP/filter-doubled_apostrophe" >"$TMP/filter-doubled_apostrophe.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-doubled_apostrophe.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \[main\]" "$TMP/filter-doubled_apostrophe.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-doubled_apostrophe.out"; then + echo "FAIL: a doubled apostrophe in branches was rewritten as main" >&2 + exit 1 +fi +echo "pass: a doubled apostrophe in branches is a literal apostrophe, not main" + +build_tree "$TMP/filter-doubled_apostrophe_ignore" +wf_raw "$TMP/filter-doubled_apostrophe_ignore" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: ['ma''in'] +EOF +if bash "$SCRIPT" "$TMP/filter-doubled_apostrophe_ignore" >"$TMP/filter-doubled_apostrophe_ignore.out" 2>&1; then + echo "FAIL: checker treated 'ma''in' in branches-ignore as excluding main" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-doubled_apostrophe_ignore.out" +echo "pass: a doubled apostrophe in branches-ignore does not exclude main" + # Codex P1 regression on #8513: generated coverage for the parser. # Equivalent YAML representations of the same logical push filter # must yield the same verdict. Oracle: an independent Python From 1bde5dbb26484a717e42550bc2774657ea15bf34 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Thu, 12 Nov 2026 15:53:43 -0600 Subject: [PATCH 19/19] fix(ci-policy): handle inline keys and filter aliases --- .github/scripts/check-ci-policy-agreement.sh | 130 +++++++++++++++--- .../scripts/check-ci-policy-agreement.test.sh | 76 +++++++++- 2 files changed, 183 insertions(+), 23 deletions(-) diff --git a/.github/scripts/check-ci-policy-agreement.sh b/.github/scripts/check-ci-policy-agreement.sh index 3e13a14c94..6fd4ac7843 100755 --- a/.github/scripts/check-ci-policy-agreement.sh +++ b/.github/scripts/check-ci-policy-agreement.sh @@ -321,51 +321,103 @@ push_targets_main() { } return 0 } - function flow_span(str, key, i, start, seg, from, prev) { - from = 1 - while ((i = index(substr(str, from), key)) > 0) { - i = from + i - 1 + function flow_key_colon(str, key, i, j, c, q, prev, word) { + q = "" + for (i = 1; i <= length(str); i++) { + c = substr(str, i, 1) + if (q == "\"") { + if (c == "\\") i++ + else if (c == "\"") q = "" + continue + } + if (q == "\047") { + if (c == "\047" && substr(str, i + 1, 1) == "\047") i++ + else if (c == "\047") q = "" + continue + } + if (c == "#" && (i == 1 || substr(str, i - 1, 1) ~ /[[:space:]]/)) return 0 + if (c == "\"" || c == "\047") { + q = c + j = i + 1 + word = "" + while (j <= length(str)) { + c = substr(str, j, 1) + if (q == "\"" && c == "\\") { j++; word = word substr(str, j, 1); j++; continue } + if (c == q) { + if (q == "\047" && substr(str, j + 1, 1) == q) { word = word q; j += 2; continue } + break + } + word = word c + j++ + } + if (word == key && j <= length(str)) { + j++ + while (substr(str, j, 1) ~ /[[:space:]]/) j++ + if (substr(str, j, 1) == ":") return j + } + i = j + q = "" + continue + } prev = (i == 1) ? "" : substr(str, i - 1, 1) - if (prev == "" || prev == "{" || prev == "," || prev == " ") break - from = i + length(key) - i = 0 + if ((prev == "" || prev == "{" || prev == "," || prev ~ /[[:space:]]/) && substr(str, i, length(key)) == key) { + j = i + length(key) + while (substr(str, j, 1) ~ /[[:space:]]/) j++ + if (substr(str, j, 1) == ":") return j + } } - if (i == 0) return "" - start = index(substr(str, i), "[") - if (start == 0) return "" - start = i + start - 1 + return 0 + } + function flow_span(str, key, colon, start, seg, i) { + colon = flow_key_colon(str, key) + if (colon == 0) return "" + start = colon + 1 + while (substr(str, start, 1) ~ /[[:space:]]/) start++ + if (substr(str, start, 1) != "[") return "" seg = substr(str, start) i = unquoted_close(seg) if (i == 0) return "" return substr(seg, 1, i) } - function apply_inline_filters(str, seg) { - seg = flow_span(str, "branches-ignore:") - if (seg == "") seg = flow_span(str, "branches-ignore :") + function resolve_sequence_value(val, name) { + sub(/^[[:space:]]+/, "", val) + sub(/[[:space:]]+$/, "", val) + if (val !~ /^\*[A-Za-z0-9_-]+$/) return val + name = substr(val, 2) + if (name in sequence_anchor) return sequence_anchor[name] + alias_unknown = 1 + return "" + } + function apply_inline_filters(str, seg, colon) { + seg = flow_span(str, "branches-ignore") + if (seg == "") { + colon = flow_key_colon(str, "branches-ignore") + if (colon) seg = resolve_sequence_value(substr(str, colon + 1)) + } if (seg != "") { seen_branch_filter = 1 ignore_list = ignore_list add_tokens(seg) } - seg = flow_span(str, "branches:") - if (seg == "") seg = flow_span(str, "branches :") + seg = flow_span(str, "branches") + if (seg == "") { + colon = flow_key_colon(str, "branches") + if (colon) seg = resolve_sequence_value(substr(str, colon + 1)) + } if (seg != "") { seen_branches = 1 seen_branch_filter = 1 branches_list = branches_list add_tokens(seg) } - if (str ~ /(^|[{,][[:space:]]*)["\047]?tags-ignore["\047]?[[:space:]]*:/) seen_tags = 1 - if (str ~ /(^|[{,][[:space:]]*)["\047]?tags["\047]?[[:space:]]*:/) seen_tags = 1 + if (flow_key_colon(str, "tags-ignore") || flow_key_colon(str, "tags")) seen_tags = 1 } - function resolve_push_alias(name, before) { + function resolve_push_alias(name) { # An aliased push inherits the anchored mapping filters # (Codex P2, PR #8513 round 13). An alias that resolves to # no recorded filter is unsupported syntax: mark it so the # verdict never certifies it as an unfiltered push. if (name in anchor_body) { - before = seen_branches seen_branch_filter seen_tags apply_inline_filters(anchor_body[name]) - if ((seen_branches seen_branch_filter seen_tags) == before) alias_unknown = 1 - } else if ((name in anchor_seen_branches) || (name in anchor_seen_ignore) || (name in anchor_seen_tags)) { + } else if ((name in anchor_mapping_seen) || (name in anchor_seen_branches) || (name in anchor_seen_ignore) || (name in anchor_seen_tags)) { if (name in anchor_seen_ignore) { seen_branch_filter = 1 ignore_list = ignore_list anchor_ignore[name] @@ -490,6 +542,38 @@ push_targets_main() { subkey = "" next } + inblock && !inpush && cur_anchor == "" && /^ +["\047]?[a-z_-]+["\047]?[[:space:]]*:/ { + line = $0 + match(line, /^ +/) + sequence_key_indent = RLENGTH + keyval = substr(line, sequence_key_indent + 1) + sub(/:.*/, "", keyval) + gsub(/["\047]/, "", keyval) + val = substr(line, sequence_key_indent + 1) + sub(/^[^:]*:[[:space:]]*/, "", val) + sequence_anchor_pending = "" + if (val ~ /^&[A-Za-z0-9_-]+([[:space:]]|$)/) { + sequence_anchor_pending = val + sub(/^&/, "", sequence_anchor_pending) + sub(/[[:space:]].*/, "", sequence_anchor_pending) + sub(/^&[A-Za-z0-9_-]+[[:space:]]*/, "", val) + if (val ~ /^\[/) { + sequence_anchor[sequence_anchor_pending] = add_tokens(val) + sequence_anchor_pending = "" + } + } + next + } + inblock && !inpush && cur_anchor == "" && sequence_anchor_pending != "" && /^ +-[[:space:]]/ { + item = $0 + match(item, /^ +/) + if (RLENGTH > sequence_key_indent) { + sub(/^ +-[[:space:]]*/, "", item) + sequence_anchor[sequence_anchor_pending] = sequence_anchor[sequence_anchor_pending] " " clean(item) + next + } + sequence_anchor_pending = "" + } inblock && /^[^[:space:]#]/ { inblock = 0; inpush = 0; child_indent = 0; cur_anchor = "" } inline_collect { if ($0 ~ /^[^[:space:]#]/) { @@ -520,6 +604,7 @@ push_targets_main() { sub(/:.*/, "", subkey_a) gsub(/["\047]/, "", subkey_a) sub(/[[:space:]]+$/, "", subkey_a) + anchor_mapping_seen[cur_anchor] = 1 val = substr(line, ind + 1) sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey_a == "branches" || subkey_a == "branches-ignore" || subkey_a == "tags" || subkey_a == "tags-ignore") val = strip_comment(val) @@ -588,6 +673,7 @@ push_targets_main() { sub(/^[^:]*:[[:space:]]*/, "", val) if (subkey == "branches" || subkey == "branches-ignore" || subkey == "tags" || subkey == "tags-ignore") val = strip_comment(val) if ((subkey == "branches" || subkey == "branches-ignore") && flow_unclosed(val)) flow_key = subkey + if (subkey == "branches" || subkey == "branches-ignore") val = resolve_sequence_value(val) if (subkey == "branches") { seen_branches = 1 seen_branch_filter = 1 diff --git a/.github/scripts/check-ci-policy-agreement.test.sh b/.github/scripts/check-ci-policy-agreement.test.sh index bda907d8f2..4734311bea 100755 --- a/.github/scripts/check-ci-policy-agreement.test.sh +++ b/.github/scripts/check-ci-policy-agreement.test.sh @@ -844,6 +844,80 @@ if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-anchor_unknown_alias.ou fi echo "pass: an unresolvable push alias is never certified as targeting main" +# A resolved mapping anchor with only non-branch filters is still a +# recognized push mapping; it has no main-excluding filter, so the +# main-tier leg agrees just like a bare push. +build_tree "$TMP/filter-anchor_paths_only" +wf_raw "$TMP/filter-anchor_paths_only" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: &paths_only + paths: [docs/**] + push: *paths_only +EOF +if bash "$SCRIPT" "$TMP/filter-anchor_paths_only" >"$TMP/filter-anchor_paths_only.out" 2>&1; then + echo "FAIL: a resolved paths-only anchor was not treated as a push mapping" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-anchor_paths_only.out" +echo "pass: resolved paths-only block anchor is not mistaken for an unknown alias" + +build_tree "$TMP/filter-inline_quoted_key_spaced_colon" +wf_raw "$TMP/filter-inline_quoted_key_spaced_colon" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {"branches-ignore" : [main]} +EOF +bash "$SCRIPT" "$TMP/filter-inline_quoted_key_spaced_colon" >"$TMP/filter-inline_quoted_key_spaced_colon.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-inline_quoted_key_spaced_colon.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-inline_quoted_key_spaced_colon.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-inline_quoted_key_spaced_colon.out"; then + echo "FAIL: quoted inline branches-ignore key with spaced colon was missed" >&2 + exit 1 +fi +echo "pass: quoted inline branches-ignore key with arbitrary colon spacing is recognized" + +build_tree "$TMP/filter-inline_quoted_fake_key" +wf_raw "$TMP/filter-inline_quoted_fake_key" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: {paths: ["{branches: [main]} {tags: [v*]}"]} +EOF +if bash "$SCRIPT" "$TMP/filter-inline_quoted_fake_key" >"$TMP/filter-inline_quoted_fake_key.out" 2>&1; then + echo "FAIL: key-like text inside a quoted path scalar was treated as filters" >&2 + exit 1 +fi +grep -q "STALE WAIVER mcpx-nixbuild.yml: main leg now agrees" "$TMP/filter-inline_quoted_fake_key.out" +echo "pass: branch/tag-like text inside a quoted path scalar is ignored" + +build_tree "$TMP/filter-sequence_alias" +wf_raw "$TMP/filter-sequence_alias" opencode-config-guard.yml <<'EOF' + pull_request: + branches: &release_branches [release] +EOF +wf_raw "$TMP/filter-sequence_alias" mcpx-nixbuild.yml <<'EOF' + push: + branches: *release_branches +EOF +bash "$SCRIPT" "$TMP/filter-sequence_alias" >"$TMP/filter-sequence_alias.out" +grep -q "ci-policy-agreement: OK" "$TMP/filter-sequence_alias.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-sequence_alias.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-sequence_alias.out"; then + echo "FAIL: a sequence alias was not expanded before branch matching" >&2 + exit 1 +fi +echo "pass: branch sequence aliases contribute their resolved patterns" + +build_tree "$TMP/filter-sequence_alias_unknown" +wf_raw "$TMP/filter-sequence_alias_unknown" mcpx-nixbuild.yml <<'EOF' + workflow_dispatch: + push: + branches-ignore: *not_defined +EOF +bash "$SCRIPT" "$TMP/filter-sequence_alias_unknown" >"$TMP/filter-sequence_alias_unknown.out" +grep -q "WAIVED mcpx-nixbuild.yml: main tier requires a push trigger on branches: \\[main\\]" "$TMP/filter-sequence_alias_unknown.out" +if grep -q "STALE WAIVER mcpx-nixbuild.yml" "$TMP/filter-sequence_alias_unknown.out"; then + echo "FAIL: an unresolved filter alias was treated as a pattern or unfiltered push" >&2 + exit 1 +fi +echo "pass: unresolved filter aliases fail closed" + # Round-14 (Codex P2): a comment that ends the first physical line # of a split inline mapping must not swallow the closing bracket # on the continuation line — the comment ends at the newline, so @@ -1053,7 +1127,7 @@ def verdict(branches=None, ignore=None, tags=False): return 'no' if tags else 'yes' def q(p): - if any(ch in p for ch in ',#[] ') or p.startswith('!'): + if any(ch in p for ch in ',#[] ') or p.startswith(('!', '*')): return "'" + p + "'" return p