Repository navigation
feat: implement issue #2038 — Markets collapse package §3/§4: re-render pr-auto-review and pr-review concurrency to ADR-0010 and mark the ruling ratified #2039
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 all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
79e7de1
feat: implement issue #2038 — Markets collapse package §3/§4: re-rend…
don-petry c645dc8
chore: dev-lead update (review-changes) [skip ci-relay]
don-petry 4373a99
fix(reviews): address review comments [skip ci-relay]
don-petry 4800b68
fix(reviews): address review comments [skip ci-relay]
don-petry fe72bb8
Merge branch 'main' into dev-lead/issue-2038-20261002-2311
don-petry a146c7b
Merge branch 'main' into dev-lead/issue-2038-20261002-2311
don-petry 9c0d4c7
Merge branch 'main' into dev-lead/issue-2038-20261002-2311
don-petry 1e3d5c3
fix(reviews): address review comments [skip ci-relay]
don-petry b6b0bd4
Merge branch 'main' into dev-lead/issue-2038-20261002-2311
don-petry 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,122 @@ | ||
| #!/usr/bin/env bats | ||
| # Regression test for the markets collapse package (#2038, ADR-0010): the §3 | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| # `agent-ingress.yml` in docs/initiatives/agent-ingress-collapse-markets.md must | ||
| # pass BOTH ingress guards as rendered, so the package cannot drift back to a | ||
| # non-conforming concurrency block (run_id / inputs.* fallbacks, expression | ||
| # cancel-in-progress). The §3 YAML is extracted from the doc itself — the test | ||
| # reads the package, not a copy of it. | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| # | ||
| # The pinned reusables are resolved from trimmed snapshots | ||
| # (tests/fixtures/agent-ingress/markets-pinned-reusables/) via VCI_RESOLVE_DIR so | ||
| # the collision check is deterministic and offline. Changes to checked inputs or | ||
| # concurrency declarations behind channel refs are not fetched; refresh the | ||
| # snapshots to test those changes. | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)" | ||
| PACKAGE="$SCRIPT_DIR/docs/initiatives/agent-ingress-collapse-markets.md" | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| SNAPSHOTS="$SCRIPT_DIR/tests/fixtures/agent-ingress/markets-pinned-reusables" | ||
|
|
||
| setup() { | ||
| ROOT="$(mktemp -d)" || { echo "Failed to create temp dir" >&2; return 1; } | ||
| mkdir -p "$ROOT/.github/workflows" | ||
| INGRESS="$ROOT/.github/workflows/agent-ingress.yml" | ||
| # The first ```yaml fence after the "## 3." heading is the §3 ingress. | ||
| awk ' | ||
| /^## 3\./ { in3 = 1; next } | ||
| in3 && /^## / { exit } | ||
| in3 && !open && /^```yaml$/ { open = 1; next } | ||
| open && /^```$/ { exit } | ||
| open { print } | ||
| ' "$PACKAGE" > "$INGRESS" | ||
| } | ||
|
|
||
| teardown() { | ||
| rm -rf "$ROOT" | ||
| } | ||
|
|
||
| @test "markets §3: the ingress block is extracted and declares the five role jobs" { | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| [ -s "$INGRESS" ] | ||
| run yq -r '.jobs | keys | sort | join(",")' "$INGRESS" | ||
| [ "$status" -eq 0 ] | ||
| [ "$output" = "ci-failure-analyst,dev-lead,pr-auto-review,pr-review,pr-review-mention" ] | ||
| } | ||
|
|
||
| @test "markets §3: validate-ingress-if.sh passes (pure if:, bounded concurrency)" { | ||
| VIIF_ROOT="$ROOT" run bash "$SCRIPT_DIR/scripts/validate-ingress-if.sh" | ||
| echo "$output" | ||
| [ "$status" -eq 0 ] | ||
| [[ "$output" == *"ingress-if: OK"* ]] | ||
| } | ||
|
|
||
| @test "markets §3: every snapshot's recorded uses: target is still the ingress's pin (PINNED-USES)" { | ||
| local uses rec n=0 | ||
| for rec in "$SNAPSHOTS"/*.yml; do | ||
| uses="$(sed -n 's/^# PINNED-USES: //p' "$rec")" | ||
| yq '.jobs[].uses' "$INGRESS" | grep -qxF "$uses" | ||
|
don-petry marked this conversation as resolved.
Resolved
don-petry marked this conversation as resolved.
Resolved
|
||
| n=$((n + 1)) | ||
| done | ||
| [ "$n" -ge 4 ] | ||
| } | ||
|
|
||
| @test "markets §3: each role job uses the target recorded in its own snapshot" { | ||
| local expected | ||
| expected="$(sed -n 's/^# PINNED-USES: //p' "$SNAPSHOTS/pr-auto-review-reusable.yml")" | ||
| [ -n "$expected" ] | ||
| [ "$(yq -r '.jobs["pr-auto-review"].uses' "$INGRESS")" = "$expected" ] | ||
|
|
||
| expected="$(sed -n 's/^# PINNED-USES: //p' "$SNAPSHOTS/ci-failure-analyst-reusable.yml")" | ||
| [ -n "$expected" ] | ||
| [ "$(yq -r '.jobs["ci-failure-analyst"].uses' "$INGRESS")" = "$expected" ] | ||
| } | ||
|
|
||
| @test "markets §3: validate-caller-inputs.sh passes against the pinned reusables (no collision)" { | ||
| VCI_ROOT="$ROOT" VCI_RESOLVE_DIR="$SNAPSHOTS" run bash "$SCRIPT_DIR/scripts/validate-caller-inputs.sh" | ||
|
don-petry marked this conversation as resolved.
Resolved
don-petry marked this conversation as resolved.
Resolved
don-petry marked this conversation as resolved.
Resolved
|
||
| echo "$output" | ||
| [ "$status" -eq 0 ] | ||
| [[ "$output" == *"pr-review' concurrency group does not collide"* ]] | ||
| [[ "$output" == *"pr-auto-review' concurrency group does not collide"* ]] | ||
| [[ "$output" == *"ci-failure-analyst' concurrency group does not collide"* ]] | ||
| } | ||
|
|
||
| @test "markets §3: every concurrency group is role-prefixed and every cancel-in-progress is a literal boolean" { | ||
| source "$SCRIPT_DIR/scripts/validate-ingress-if.sh" | ||
| local job group cancel stem n=0 | ||
| for job in pr-auto-review pr-review ci-failure-analyst; do | ||
| IFS=$'\x1f' read -r group cancel < <(viif_job_concurrency "$INGRESS" "$job") | ||
| [ -n "$group" ] | ||
| [[ "$cancel" == "true" || "$cancel" == "false" ]] | ||
| while IFS= read -r stem; do | ||
| [[ "$stem" == "$job"-* ]] | ||
| n=$((n + 1)) | ||
| done < <(viif_group_stems "$group") | ||
| done | ||
| [ "$n" -ge 3 ] | ||
| } | ||
|
|
||
| @test "markets §3: no group falls back to github.run_id or the inputs.* context" { | ||
| run yq '.jobs[].concurrency.group // ""' "$INGRESS" | ||
| [ "$status" -eq 0 ] | ||
| [[ "$output" != *"run_id"* ]] | ||
| # github.event.inputs.* is the workflow_dispatch payload; a bare inputs.* is not. | ||
| ! printf '%s\n' "$output" | grep -Eq '(^|[^.[:alnum:]_])inputs\.' | ||
| } | ||
|
|
||
| @test "markets §3: pr-review's shared fallback slot is not the reusable's pr-review-batch" { | ||
| # The collision check compares literal stems (a tripwire, ADR-0010). A caller | ||
| # fallback of 'batch' would resolve to the reusable's own 'pr-review-batch' | ||
| # group while passing the stem check, so pin the chosen literal here. | ||
| run yq '.jobs["pr-review"].concurrency.group' "$INGRESS" | ||
| [ "$status" -eq 0 ] | ||
| [[ "$output" == pr-review-* ]] | ||
| [[ "$output" != *"'batch'"* ]] | ||
| # PR-identity branches must stay, in order, ahead of the 'enumerate' fallback. | ||
| local re="pull_request\\.number.*check_suite\\.pull_requests\\[0\\]\\.number.*inputs\\.pr_url.*client_payload\\.pr_url.*'enumerate'" | ||
| printf '%s' "$output" | tr '\n' ' ' | grep -Eq "$re" | ||
| } | ||
|
|
||
| @test "markets §3: ci-failure-analyst concurrency is unchanged" { | ||
| run yq -r '.jobs["ci-failure-analyst"].concurrency.group' "$INGRESS" | ||
| [ "$output" = 'ci-failure-analyst-${{ github.event.check_run.head_sha }}' ] | ||
| run yq '.jobs["ci-failure-analyst"].concurrency["cancel-in-progress"]' "$INGRESS" | ||
| [ "$output" = "false" ] | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
tests/fixtures/agent-ingress/markets-pinned-reusables/ci-failure-analyst-reusable.yml
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,15 @@ | ||
| # PINNED-USES: petry-projects/.github-private/.github/workflows/ci-failure-analyst-reusable.yml@79747178007d3238bb3afddf7f4d952a293987bd | ||
| # SNAPSHOT (trimmed) of petry-projects/.github-private | ||
| # .github/workflows/ci-failure-analyst-reusable.yml @ 79747178007d3238bb3afddf7f4d952a293987bd, | ||
| # read 2026-10-02 for #2038. The reusable declares NO concurrency group at | ||
| # workflow or job level; the markets caller forwards no with: inputs. | ||
| name: CI Failure Analyst (reusable) | ||
|
|
||
| on: | ||
| workflow_call: {} | ||
|
|
||
| jobs: | ||
| analyze: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo snapshot |
20 changes: 20 additions & 0 deletions
20
tests/fixtures/agent-ingress/markets-pinned-reusables/dev-lead-reusable.yml
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,20 @@ | ||
| # PINNED-USES: petry-projects/.github-private/.github/workflows/dev-lead-reusable.yml@dev-lead/v139-stable | ||
| # SNAPSHOT (trimmed) of petry-projects/.github-private | ||
| # .github/workflows/dev-lead-reusable.yml @ dev-lead/v139-stable, read 2026-10-02 | ||
| # for #2038. Only the agent_ref input the markets caller forwards is kept; the | ||
| # markets dev-lead job declares no caller concurrency group. | ||
| name: Dev-Lead (reusable) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| agent_ref: | ||
| type: string | ||
| required: false | ||
| default: "" | ||
|
|
||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo snapshot |
15 changes: 15 additions & 0 deletions
15
tests/fixtures/agent-ingress/markets-pinned-reusables/pr-auto-review-reusable.yml
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,15 @@ | ||
| # PINNED-USES: petry-projects/.github/.github/workflows/pr-auto-review-reusable.yml@pr-auto-review/v1-stable | ||
| # SNAPSHOT (trimmed) of petry-projects/.github | ||
| # .github/workflows/pr-auto-review-reusable.yml @ pr-auto-review/v1-stable, | ||
| # read 2026-10-02 for #2038. The reusable declares NO concurrency group at | ||
| # workflow or job level; the markets caller forwards no with: inputs. | ||
| name: PR Auto Review (reusable) | ||
|
|
||
| on: | ||
| workflow_call: {} | ||
|
|
||
| jobs: | ||
| ready-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo snapshot |
58 changes: 58 additions & 0 deletions
58
tests/fixtures/agent-ingress/markets-pinned-reusables/pr-review.yml
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,58 @@ | ||
| # PINNED-USES: petry-projects/.github-private/.github/workflows/pr-review.yml@pr-review/stable | ||
| # SNAPSHOT (trimmed) of petry-projects/.github-private | ||
| # .github/workflows/pr-review.yml @ pr-review/stable (776c9585c8fff87a1ffefd469137791ab6467e61), | ||
| # read 2026-10-02 for #2038. Only the parts the two ingress guards read are kept: | ||
| # the workflow_call inputs (validate-caller-inputs.sh) and the workflow-level | ||
| # concurrency group verbatim (the ADR-0010 collision rule). Re-snapshot if the | ||
| # markets §3 pin moves. | ||
|
don-petry marked this conversation as resolved.
Resolved
|
||
| name: PR Review Agent | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| agent_ref: | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| pr_url: | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| dry_run: | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| force_review: | ||
| type: string | ||
| required: false | ||
| default: "" | ||
|
|
||
| concurrency: | ||
| group: >- | ||
| ${{ | ||
| (inputs.pr_url | ||
| || github.event.client_payload.pr_url | ||
| || (github.event.pull_request.number && format('{0}/pull/{1}', github.repository, github.event.pull_request.number)) | ||
| || (github.event.check_suite.pull_requests[0].number && format('{0}/pull/{1}', github.repository, github.event.check_suite.pull_requests[0].number))) | ||
| && format('pr-review-pr-{0}{1}', | ||
| inputs.pr_url | ||
| || github.event.client_payload.pr_url | ||
| || (github.event.pull_request.number && format('{0}/pull/{1}', github.repository, github.event.pull_request.number)) | ||
| || (github.event.check_suite.pull_requests[0].number && format('{0}/pull/{1}', github.repository, github.event.check_suite.pull_requests[0].number)), | ||
| (github.event.pull_request.head.sha | ||
| || github.event.check_suite.head_sha | ||
| || github.event.client_payload.sha) | ||
| && format('-{0}', | ||
| github.event.pull_request.head.sha | ||
| || github.event.check_suite.head_sha | ||
| || github.event.client_payload.sha) | ||
| || '') | ||
| || 'pr-review-batch' | ||
| }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo snapshot | ||
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.