Repository navigation
fix(#2086): gate each dev-lead retry payload on the target repo's pinned parser #2088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7d496c4
feat: implement issue #2086 — dev-lead-retry: resolve the dev-lead ch…
18e7ff3
Merge branch 'main' into dev-lead/issue-2086-20261009-0347
don-petry d732c64
fix(reviews): capture command-substitution status before branching in…
don-petry 9ab9b73
Merge branch 'main' into dev-lead/issue-2086-20261009-0347
don-petry 77b9637
Merge branch 'main' into dev-lead/issue-2086-20261009-0347
don-petry 30b530e
Merge branch 'main' into dev-lead/issue-2086-20261009-0347
don-petry c74b251
Merge branch 'main' into dev-lead/issue-2086-20261009-0347
don-petry 2021740
fix(#2086): gate each retry payload on the target's pinned parser, no…
136ccf1
fix(#2086): a contents 404 means 'no dev-lead.yml' only when the repo…
47348db
fix(#2086): keep the gate's cache in per-sweep files so it survives s…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| #!/usr/bin/env bash | ||
| # dispatch-channel-gate.sh — skip a dispatch target whose dev-lead channel pin is | ||
| # older than the sweep's (#2086). | ||
| # | ||
| # WHY THIS EXISTS | ||
| # dev-lead-retry.yml runs scripts/ at ONE release: the channel this repo's | ||
| # dev-lead.yml pins via `agent_ref` (#2050). The sweep then sends | ||
| # repository_dispatch to every repo in the org, and each target runs its | ||
| # harness at ITS OWN dev-lead.yml pin (the stub contract allows a per-repo | ||
| # ring/channel pin). A target pinned to an older channel than the sweep can be | ||
| # sent a client_payload field its harness cannot read yet — the #2017 / #2050 | ||
| # skew again, across repos instead of across time. | ||
| # | ||
| # WHAT THIS LIBRARY DECIDES | ||
| # For each target repo, read its dev-lead.yml `agent_ref` and compare it with | ||
| # the sweep's channel by git ancestry (the compare API on the dev-lead host | ||
| # repo), not by tag name — rings of one major sit on different commits, and a | ||
| # rollback can move a channel backwards: | ||
| # identical | behind the target has every commit the sweep has → scan | ||
| # ahead | diverged the sweep has commits the target lacks → SKIP, warn | ||
| # no dev-lead.yml nothing in that repo receives a dispatch → skip | ||
| # unreadable / unknown cannot prove compatibility → SKIP, warn (fail closed) | ||
| # A skipped repo keeps its markers; its retries resume once it is repinned to | ||
| # the sweep's channel or newer (or the sweep's channel moves back to it). | ||
| # | ||
| # Env: | ||
| # DCG_HOST_REPO repo that hosts the dev-lead reusable, its channel tags and | ||
| # the sweep's own dev-lead.yml (default: $GITHUB_REPOSITORY, | ||
| # else petry-projects/.github-private) | ||
| # SWEEP_AGENT_REF override the sweep's channel (default: DCG_HOST_REPO's pin — | ||
| # the same ref dev-lead-retry.yml checks scripts/ out at) | ||
|
|
||
| DCG_HOST_REPO="${DCG_HOST_REPO:-${GITHUB_REPOSITORY:-petry-projects/.github-private}}" | ||
| # Same channel-tag shape dev-lead-retry.yml accepts for the sweep's own pin. | ||
| DCG_CHANNEL_RE='^dev-lead/v[0-9]+-(next|ring0|ring1|stable)$' | ||
| # target agent_ref -> 0 (compatible) | 1 (older) | 2 (unknown), per sweep run. | ||
| declare -gA _DCG_COMPAT_CACHE=() | ||
|
|
||
| # dcg_parse_agent_ref: stdin = dev-lead.yml text; prints its `agent_ref` channel | ||
| # tag. Returns 1 (prints nothing) when it is missing or not a channel tag. | ||
| dcg_parse_agent_ref() { | ||
| local ref | ||
| ref="$(sed -nE "s/^[[:space:]]*agent_ref:[[:space:]]*[\"']?([^\"'[:space:]#]*).*/\1/p" | head -n 1)" | ||
| [[ "$ref" =~ $DCG_CHANNEL_RE ]] || return 1 | ||
| printf '%s\n' "$ref" | ||
| } | ||
|
|
||
| # dcg_read_repo_pin <repo>: prints the repo's dev-lead.yml agent_ref (default | ||
| # branch). Returns 2 when the repo has no dev-lead.yml, 1 on any other read | ||
| # failure or a malformed pin. | ||
| dcg_read_repo_pin() { | ||
| local repo="$1" out gh_status=0 | ||
| out="$(gh api "repos/${repo}/contents/.github/workflows/dev-lead.yml" \ | ||
| -H "Accept: application/vnd.github.raw" 2>&1)" || gh_status=$? | ||
| if [ "$gh_status" -ne 0 ]; then | ||
| if [[ "$out" == *"HTTP 404"* ]]; then | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| return 2 | ||
| fi | ||
| return 1 | ||
| fi | ||
| dcg_parse_agent_ref <<<"$out" | ||
| } | ||
|
|
||
| # dcg_resolve_sweep_ref: prints the channel the sweep's scripts/ run at. | ||
| dcg_resolve_sweep_ref() { | ||
| if [ -n "${SWEEP_AGENT_REF:-}" ]; then | ||
| [[ "$SWEEP_AGENT_REF" =~ $DCG_CHANNEL_RE ]] || return 1 | ||
| printf '%s\n' "$SWEEP_AGENT_REF" | ||
| return 0 | ||
| fi | ||
| dcg_read_repo_pin "$DCG_HOST_REPO" | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
don-petry marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| # dcg_pin_compat <target_ref> <sweep_ref>: 0 = the target's channel has every | ||
| # commit the sweep's has; 1 = it is older (or diverged); 2 = unknown. Cached. | ||
| dcg_pin_compat() { | ||
| local target="$1" sweep="$2" status rc cmp_status=0 | ||
| [ "$target" = "$sweep" ] && return 0 | ||
| if [ -n "${_DCG_COMPAT_CACHE[$target]+set}" ]; then | ||
| return "${_DCG_COMPAT_CACHE[$target]}" | ||
| fi | ||
| status="$(gh api "repos/${DCG_HOST_REPO}/compare/${target}...${sweep}" --jq '.status' 2>/dev/null)" || cmp_status=$? | ||
| if [ "$cmp_status" -ne 0 ]; then | ||
| status="" | ||
| fi | ||
| case "$status" in | ||
| identical|behind) rc=0 ;; | ||
| ahead|diverged) rc=1 ;; | ||
| *) rc=2 ;; | ||
| esac | ||
| _DCG_COMPAT_CACHE[$target]="$rc" | ||
| return "$rc" | ||
| } | ||
|
|
||
| # dcg_repo_dispatch_allowed <repo> <sweep_ref>: 0 = scan and dispatch to the | ||
| # repo; 1 = skip it. Logs the reason to stderr. | ||
| dcg_repo_dispatch_allowed() { | ||
| local repo="$1" sweep="$2" target rc=0 | ||
| target="$(dcg_read_repo_pin "$repo")" || rc=$? | ||
| case "$rc" in | ||
| 0) ;; | ||
| 2) | ||
| echo "[retry] skipping ${repo}: no dev-lead.yml, so nothing receives a dispatch" >&2 | ||
| return 1 ;; | ||
| *) | ||
| echo "::warning::[retry] skipping ${repo}: cannot read a dev-lead channel from its dev-lead.yml agent_ref, so payload compatibility with the sweep's ${sweep} is unproven (#2086)" >&2 | ||
| return 1 ;; | ||
| esac | ||
|
|
||
| rc=0 | ||
| dcg_pin_compat "$target" "$sweep" || rc=$? | ||
| case "$rc" in | ||
| 0) return 0 ;; | ||
| 1) | ||
| echo "::warning::[retry] skipping ${repo}: its dev-lead.yml pins ${target}, older than the sweep's ${sweep}; its harness may not read the sweep's dispatch payloads (#2086). Repin it to ${sweep} or newer." >&2 | ||
| return 1 ;; | ||
| *) | ||
| echo "::warning::[retry] skipping ${repo}: could not compare its pin ${target} with the sweep's ${sweep} (#2086)" >&2 | ||
| return 1 ;; | ||
| esac | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.