Default stacked PR runs to top-of-stack with configurable on.pull_request.max-stack - #49420
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
on.pull_request.max-stack
There was a problem hiding this comment.
Pull request overview
Adds configurable stack-aware gating for pull-request workflows, defaulting execution to the top PR.
Changes:
- Adds the
on.pull_request.max-stackschema and compiler filter. - Comments compiler-processed configuration in generated YAML.
- Adds unit coverage and recompiles affected workflows.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/frontmatter_on_section_cleanup.go |
Comments processed max-stack fields. |
pkg/workflow/filters.go |
Implements stack gating. |
pkg/workflow/filters_stack_test.go |
Tests stack-filter configurations. |
pkg/workflow/compiler_orchestrator_workflow.go |
Invokes stack filtering. |
pkg/parser/schemas/main_workflow_schema.json |
Defines max-stack. |
.github/workflows/visual-regression-checker.lock.yml |
Adds generated stack conditions. |
.github/workflows/test-quality-sentinel.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-update-cross-repo-pr.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-test-tools.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-temporary-id.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-project.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-pi.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-opencode.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-multi-pr.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-gemini.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-create-cross-repo-pr.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-copilot-arm.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-codex.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-claude.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-ci.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-call-workflow.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-antigravity.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-agent-scoped-approved.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-agent-public-none.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-agent-public-approved.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-agent-all-none.lock.yml |
Adds generated stack conditions. |
.github/workflows/smoke-agent-all-merged.lock.yml |
Adds generated stack conditions. |
.github/workflows/refiner.lock.yml |
Adds generated stack conditions. |
.github/workflows/pr-description-caveman.lock.yml |
Adds generated stack conditions. |
.github/workflows/pr-code-quality-reviewer.lock.yml |
Adds generated stack conditions. |
.github/workflows/mattpocock-skills-reviewer.lock.yml |
Adds generated stack conditions. |
.github/workflows/impeccable-skills-reviewer.lock.yml |
Adds generated stack conditions. |
.github/workflows/firewall-escape.lock.yml |
Adds generated stack conditions. |
.github/workflows/design-decision-gate.lock.yml |
Adds generated stack conditions. |
.github/workflows/changeset.lock.yml |
Adds generated stack conditions. |
.github/workflows/ai-moderator.lock.yml |
Adds generated stack conditions. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 36/36 changed files
- Comments generated: 3
- Review effort level: Balanced
| "type": "integer", | ||
| "minimum": -1, | ||
| "description": "Maximum number of top stack layers to run on for stacked pull requests. Default is 1 (only the latest/top pull request in the stack). Set to -1 to disable stack protection and run on every pull request in the stack." |
There was a problem hiding this comment.
Fixed. Changed max-stack schema from {"type":"integer","minimum":-1} to an anyOf that accepts only const: -1 or minimum: 1, so 0, -2, and other invalid values are now rejected with a schema validation error. Schema tests covering rejection of 0 and -2 added in pkg/parser/schema_location_test.go.
| } | ||
|
|
||
| stackCondition := fmt.Sprintf( | ||
| "github.event_name != 'pull_request' || github.event.pull_request.stack == null || github.event.pull_request.stack.position + %d > github.event.pull_request.stack.size", |
There was a problem hiding this comment.
Fixed. GitHub Actions expressions don't support arithmetic operators, so the generated if: condition was rewritten:
max-stack: 1(default): Usesgithub.event.pull_request.stack.position == github.event.pull_request.stack.size(equality only — always a supported operator). All 266 lock files have been recompiled with this corrected expression.max-stack: N > 1: Instead of arithmetic inif:, injects apre-stepsbash step that computessize - position < Nvia shell arithmetic and exits 1 if the PR is not in the top-N layers. This keeps the job-levelif:free of arithmetic.
Integration tests in pkg/workflow/filters_stack_integration_test.go (build-tagged integration) verify that no arithmetic operators appear in the compiled job-level if: conditions.
| "max-stack": { | ||
| "type": "integer", | ||
| "minimum": -1, | ||
| "description": "Maximum number of top stack layers to run on for stacked pull requests. Default is 1 (only the latest/top pull request in the stack). Set to -1 to disable stack protection and run on every pull request in the stack." |
There was a problem hiding this comment.
Added. A "Stacked PR Filtering (max-stack:)" subsection has been added to docs/src/content/docs/reference/triggers.md in the Pull Request Triggers section. It covers default behavior (run only the top PR), custom N (max-stack: 2), the disable mode (max-stack: -1), and explains why lower stack layers are skipped.
|
test body
|
PR Triage
|
|
Warning threat detection engine error DetailsThe threat detection engine failed to produce results. Review the workflow run logs for details. @copilot Please address the outstanding review feedback, refresh the branch, and run the
|
|
Warning threat detection engine error DetailsThe threat detection engine failed to produce results. Review the workflow run logs for details. Hey ✅ Tests are in place for default behavior, custom values, and disable mode. This looks ready for review and merge. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "patchdiff.githubusercontent.com"See Network Configuration for more information.
|
…ema, add docs Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed all three review items in the latest commit:
|
|
🎉 This pull request is included in a new release. Release: |
Agentic workflows currently run on every PR in a stack, which multiplies CI cost. This change adds stack-aware gating so workflows default to running only on the latest stack layer, with an explicit frontmatter override.
Frontmatter contract (
on.pull_request)max-stackto workflow schema.1(run only top/latest PR in a stack)N > 1: run on topNstack layers-1: disable stack protection (run all layers)Compiler behavior
pull_requesttrigger is present.Generated workflow readability
on:cleanup/commenting to markmax-stackas compiler-applied (like other derived trigger filters), so lock output remains clear about source-of-truth behavior.Coverage updates
max-stack, disable mode (-1), and trigger-shape handling (on: pull_requestvs object form).Warning
threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.
Details
The threat detection engine failed to produce results.
Review the workflow run logs for details.
run: https://github.com/github/gh-aw/actions/runs/30676859249