Skip to content

Commit cd70b2f

Browse files
authored
fix(ci): the semantic check scores a fork's pull request a maintainer names, and says which one it is (#2225) (#2227)
## Summary The `semantic diff (advisory)` check never scored a pull request from a fork. Each fork pull request measured so far (#2178, #2188, #2222) got "NOT MEASURED: no open pull request of this repository holds this commit" on its measured head while it was open: GitHub's commit-to-pull-request listing returned nothing for those commits then (it lists all three now that they are merged), and the check does not take a fork's pull request by its commit anyway, since anyone can open one holding any commit. - `Semantic check` takes an optional `pr` input when dispatched. `tools/ci/jev_check.py --pr` takes the named pull request when it is into this repository and holds the measured commit, in any state (`pull_named`), and the check's summary says it was named, which fork it comes from, its state, and who last edited its description and when (GraphQL `editor` and `lastEditedAt`: REST's `updated_at` moves on any activity, and a maintainer may have edited the description). Only a maintainer can dispatch the workflow, so a contributor cannot steer which description is scored; the description is still untrusted text from a fork's pull request, sent to Jev as data for an advisory check. `arm.sh` refuses only on a fail, so a pass scored this way stands in for nothing more than a same-repository one. - Without `pr`, when the listing names no pull request of this repository, the reason now says a fork's pull request that holds the commit is scored by dispatching with `pr`; and if exactly one open pull request from a fork has the measured commit as its head, it names that one (`fork_pull_at_head`). It still never takes it. - The docs said a context without the key is NOT MEASURED, never a pass; an empty diff has always passed with no call, since there is nothing to ask. The header, the module docstring and `docs/maintaining.md` now say so. - The input is checked as 1 to 7 digits in the workflow and in Python. The Trust header of `semantic-check.yml` and `docs/maintaining.md` say what is scored and whose text it is. Closes #2225. ## Testing - `python3 tools/ci/test_jev_check.py`: 60 tests pass, the existing "a fork's pull request is never taken" ones unchanged. The new ones cover the three pure helpers' failure modes, written first: a closed, moved-on, other-repository or same-repository pull request, or two forks at one head, name none; a pull request that could not be read, has another number, is into another repository or does not hold the commit (also among 250 listed) is refused; a merged fork pull request whose head moved on is taken when it holds the commit; a number that is not 1 to 7 ASCII digits above zero is refused. - End to end on the real `semantic-diff` artifacts of the three fork pull requests' Measure runs, `--dry-run` (no Jev call, nothing posted): [46492757357](https://github.com/DrunkOnJava/rvt-rs/actions/runs/46492757357) (#2222's `690c4cc0`), [46192799262](https://github.com/DrunkOnJava/rvt-rs/actions/runs/46192799262) (#2178) and [46220190100](https://github.com/DrunkOnJava/rvt-rs/actions/runs/46220190100) (#2188). Named with `--pr`, each is a pass (no semantic difference in 42 models) and the summary names the pull request, `shifatrHtH/rvt-rs`, merged, and who last edited the description (on #2222, "last edited by `DrunkOnJava` at 2026-11-30T21:17:26Z", the maintainer's edit; on #2188, "has not been edited since `shifatrHtH` opened it"). Without `--pr`, #2222's stays NOT MEASURED; with `--pr 2226` it is NOT MEASURED, "pull request #2226 does not hold the measured commit". - None of the fork runs has a semantic difference, so none of them reads a description. The new step is where the body comes from: `lookup_pull_request` with `--pr 2178` returns #2178's real Summary (231 characters) and Testing through `describe_change`, and that Summary is inside a request `request_body` builds from it, the same functions the same-repository path uses after that. - The fallback's fetch, traced on `4f8cdf6f` (a commit GitHub ties to no pull request): the commit listing returned an empty list, the open pull requests were read, and with no fork's at that head the reason says how to name one. The case where it names a fork's pull request itself waits for the next open one. - `actionlint` and `zizmor --offline` on `semantic-check.yml`: no findings. - The workflow itself, dispatched from this branch with `-f run_id=46492757357 -f pr=2222` (run [46519603865](https://github.com/DrunkOnJava/rvt-rs/actions/runs/46519603865), from `7f05ad58`; a branch run has no key, and an empty diff needs none): it wrote a pass on `690c4cc0` naming #2222, `shifatrHtH/rvt-rs` and merged. Once this lands, both of #2222's runs (46477382592 and 46492757357) are scored again from main with `-f pr=2222`, so the verdicts on its commits come from main's code. - The run this pull request triggers on itself (it changes the workflow) ended at "no Measure run to score", so the step runs with an empty `pr`. ## Source provenance No format finding.
1 parent 507e1dc commit cd70b2f

4 files changed

Lines changed: 261 additions & 24 deletions

File tree

‎.github/workflows/semantic-check.yml‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,20 @@
2323
# posts nothing, with a notice. The check is written on the commit the artifact
2424
# says Measure measured (found again through the API as the head of a
2525
# same-repository pull request, else NOT MEASURED), never on a pull request's
26-
# live head, which may be another pull request's or have moved. Only a run that
26+
# live head, which may be another pull request's or have moved. A pull request
27+
# from a fork is never found that way (#2225: GitHub does not tie a fork's
28+
# commit to it while it is open, and anyone can open one holding any commit), so
29+
# a maintainer scores one by dispatching this workflow with `run_id` and `pr`:
30+
# the named pull request is taken when it is into this repository and holds the
31+
# measured commit (tools/ci/jev_check.py `pull_named`). Its description, text
32+
# from a fork's pull request, then reaches Jev as data for this advisory check,
33+
# and the check says whose pull request it is and who last edited its
34+
# description, when. Only a run that
2735
# measured every open model (no `models` filter, the office and the Revit 2025
2836
# models on) writes a check, and it can be a pass only if every one of them is
2937
# compared in full (tools/ci/jev_check.py); a context without the key is scored
30-
# with no call: NOT MEASURED, never a pass.
38+
# with no call: NOT MEASURED, never a pass, unless the diff is empty (nothing to
39+
# ask, so no call is needed).
3140
#
3241
# Triggers. workflow_run on Measure (every dispatched run with a base and a
3342
# dump on both sides); workflow_dispatch with a run id, to score an older run or
@@ -51,6 +60,9 @@ on:
5160
run_id:
5261
description: The Measure run whose semantic-diff artifact is scored
5362
required: true
63+
pr:
64+
description: The pull request whose description is scored, when GitHub does not tie the measured commit to it (a fork's)
65+
required: false
5466
pull_request:
5567
paths:
5668
- .github/workflows/semantic-check.yml
@@ -95,15 +107,26 @@ jobs:
95107
EVENT: ${{ github.event_name }}
96108
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
97109
INPUT_RUN_ID: ${{ inputs.run_id }}
110+
INPUT_PR: ${{ inputs.pr }}
98111
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
99112
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
100113
run: |
101114
set -euo pipefail
102115
run_id=""
103116
check_sha=""
117+
pr=""
104118
case "$EVENT" in
105119
workflow_run) run_id="$WORKFLOW_RUN_ID" ;;
106-
workflow_dispatch) run_id="$INPUT_RUN_ID" ;;
120+
workflow_dispatch)
121+
run_id="$INPUT_RUN_ID"
122+
if [ -n "${INPUT_PR:-}" ]; then
123+
if ! [[ "$INPUT_PR" =~ ^[1-9][0-9]{0,6}$ ]]; then
124+
echo "::error::pr must be a pull request number"
125+
exit 1
126+
fi
127+
pr="$INPUT_PR"
128+
fi
129+
;;
107130
pull_request)
108131
if [ "$PR_HEAD_REPO" != "$REPO" ]; then
109132
echo "::notice::a pull request from a fork: nothing is scored and no check run is written"
@@ -144,6 +167,7 @@ jobs:
144167
echo "found=true"
145168
echo "run_id=$run_id"
146169
echo "head_sha=$check_sha"
170+
echo "pr=$pr"
147171
} >> "$GITHUB_OUTPUT"
148172
echo "scoring Measure run $run_id (dispatched in $REPO)"
149173
- name: Download the semantic diff
@@ -163,11 +187,13 @@ jobs:
163187
REPO: ${{ github.repository }}
164188
RUN_ID: ${{ steps.run.outputs.run_id }}
165189
HEAD_SHA: ${{ steps.run.outputs.head_sha }}
190+
PR_NUMBER: ${{ steps.run.outputs.pr }}
166191
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
167192
run: |
168193
set -euo pipefail
169194
args=(semantic-diff --run-id "$RUN_ID" --repo "$REPO" --run-url "$RUN_URL" --post --result semantic-check.json --summary semantic-check.md)
170195
[ -z "$HEAD_SHA" ] || args+=(--head-sha "$HEAD_SHA")
196+
[ -z "$PR_NUMBER" ] || args+=(--pr "$PR_NUMBER")
171197
python3 tools/ci/jev_check.py "${args[@]}"
172198
cat semantic-check.md >> "$GITHUB_STEP_SUMMARY"
173199
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2

‎docs/maintaining.md‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ warn or a fail found in what was compared stays. The check lands on the commit
512512
Measure measured, which the compare job takes from the plan job's resolved refs
513513
(a shard job runs the measured code, so its `commit.txt` is not trusted), and
514514
which is found again through the API: the same-repository pull request whose
515-
head or merge commit it is, or else the one open pull request that holds it,
515+
head or merge commit it is, or else the one open pull request that holds it (or
516+
the pull request a maintainer names with `-f pr`, below),
516517
since a head moves on after Measure starts (the MCP contract sync alone does).
517518
The verdict stays on the commit that was measured, and reads the pull request's
518519
Summary as it is then. If several open pull requests hold the commit, or it is a
@@ -632,8 +633,10 @@ Measure's `ifc.sha256` is what says that an export is identical.
632633
the check's summary says so on a fail), then measure the new head. A Summary
633634
that only names the area ("improves rooms") covers nothing. `NOT MEASURED` is
634635
neither: it names its cause, and the check is run again once the cause is gone.
635-
- **NOT MEASURED, never a pass.** No key in the context, a pull request from a
636-
fork or no same-repository pull request that holds the measured commit, a
636+
- **NOT MEASURED, never a pass.** No key in the context when the diff has
637+
findings (an empty diff needs no call, so it can pass without one), a pull request from a
638+
fork that no maintainer named or no same-repository pull request that holds
639+
the measured commit, a
637640
pull request with no `## Summary` or an empty one (the template's comment
638641
alone) when the diff has findings, HTTP 402 or a 429 for exhausted quota (the
639642
credit is out; not retried), a key refused, a reply from another model than the
@@ -657,7 +660,13 @@ Measure's `ifc.sha256` is what says that an export is identical.
657660
they post nothing (see the trust bullet). Run it
658661
again with `gh run rerun <semantic check run>`, or score a Measure run from
659662
main with `gh workflow run semantic-check.yml --ref main -f run_id=<Measure run
660-
id>`.
663+
id>`. A pull request from a fork is never found by its commit (#2225: GitHub
664+
does not tie it to the commit while it is open, and the check would not take a
665+
fork's anyway, since anyone can open one): its verdict says to name it, and
666+
names it while its head is still the measured commit, and a maintainer scores
667+
it by adding `-f pr=<number>`. The named pull request must be into this
668+
repository and hold the measured commit, and the check says whose it is and who
669+
last edited its description, when.
661670
- **Cost.** Jev bills $0.042 per million input tokens; a diff of a few hundred
662671
kilobytes costs well under a cent, so the results are not cached (the Actions
663672
cache is not private to the workflows that write it, and the artifact of the

0 commit comments

Comments
 (0)