Repository navigation
own-language budget step charges master's foreign lines to a PR whose base.sha is stale #7489
Description
The foreign-line budget step in .github/workflows/own-language.yml diffs github.event.pull_request.base.sha...github.event.pull_request.head.sha. GitHub does not move pull_request.base.sha when master moves; it stays at the base the PR last saw (here: the base at PR creation). When a PR then merges a newer master into its branch, the three-dot diff starts at the old base, and every foreign line master gained in between is charged to the PR.
Seen on #7425 (Part of #6063): run 37603940543 used BASE cfda070b2 for head dca980b6f, which already contains master up to ba161bba1. The step denied cli/t27b/src/codegen.rs, ir.rs and tests/differential.rs, all from #7398 (lane 3), not from the PR. Diffed against current master the same head is inside the budget (49 foreign lines). Locally, the same check_budget against the stale bases of #7418 and #7447 also denies, and against current master all four lane 5 PRs pass.
Workaround used: gh api -X PATCH repos/gHashTag/t27/pulls/N -f base=master refreshes base.sha to the current master tip; a label toggle then re-runs the workflow with the fresh payload.
Possible fix (the workflow is protected, so this needs the owner's label): after checkout, compute the base as git merge-base origin/master "$HEAD" (or fetch github.base_ref and diff origin/$BASE_REF...$HEAD) instead of trusting the event's base.sha. The path check in the same file reads $BASE:tools/policy/foreign-exceptions.txt and has the same staleness, so an exception block that landed on master after the PR opened is not seen either.
Part of #6063
Boundary
.github/workflows/own-language.ymlcli/t27b/src/codegen.rstests/differential.rstools/policy/foreign-exceptions.txt
User Scenarios
- Given a pull request whose
base.shais stale becausemasterhas advanced since the PR was created, When theown-language.ymlworkflow runs its foreign-line budget step, Then the step must compute the diff base at runtime using the current merge-base withorigin/master(ororigin/$BASE_REF) instead of trusting the event'sbase.sha, so that only foreign lines introduced by the PR itself are counted. - Given a PR that merges a newer
masterinto its branch, When the workflow readstools/policy/foreign-exceptions.txtfor the path check, Then it must read the file from the computed current base so that exception blocks added tomasterafter the PR opened are honored.
Requirements
- FR-001: The workflow
.github/workflows/own-language.ymlMUST replace the three-dot diffgithub.event.pull_request.base.sha...github.event.pull_request.head.shawith a diff computed fromgit merge-base origin/master "$HEAD"(ororigin/${{ github.base_ref }}...$HEAD) so the base reflects the current tip of the target branch. - FR-002: The foreign-exceptions file read in the same workflow (
$BASE:tools/policy/foreign-exceptions.txt) MUST use the computed current base instead of the stale eventbase.sha.
Success Criteria
grep -q 'merge-base origin/master' .github/workflows/own-language.ymlexits 0.grep -q 'merge-base origin/\${{ github.base_ref }}' .github/workflows/own-language.yml || grep -q 'origin/\${{ github.base_ref }}\.\.\.\$HEAD' .github/workflows/own-language.ymlexits 0.- The workflow run on a PR with stale
base.shawheremastergained foreign lines since PR creation reports foreign-line count ≤ budget for a head that is within budget against currentmaster(exit 0 on the budget step). - The path check for
tools/policy/foreign-exceptions.txtin the workflow references the computed base variable (exit 0 ongrep -q '\${COMPUTED_BASE:-.*}:tools/policy/foreign-exceptions.txt' .github/workflows/own-language.ymlor equivalent). - All four lane-5 PRs (e.g., specs: layernorm, wrapup-auto and ternary_mac_synth test what they claim (Closes #7404) #7418, t27b: a test local named for a module var (Closes #7668) #7447) pass the budget step when re-run against current
master(4 PRs pass).
Activity
gHashTag commentedon Oct 7, 2026
It recurs on every master merge: after pushing the re-merges of #7418, #7425, #7447 and #7470 (master b94f486), all four PRs still carried
base.shad5cefde, from the previous PATCH. A diff from there would charge #7462'slower.rsandsource.rslines to them. Refreshed again with PATCH plus a label toggle.gHashTag commentedon Oct 7, 2026
Reopened 2026-10-07: the bulk close of issues without a
## Boundarysection was reverted by the owner. Nothing to do here; this comment replaces the earlier close notice.