fix(scripts): read comments by extension, lock origins by canonical form (#476)

meaningful() now depends on the file extension: in .rs, .ts, .tsx and .js
only a line that starts with // is a comment (// @ts- and /// <reference
stay code, and so do #[ and #!); in .toml, .yml and .sh a # line, except a
#! shebang; nothing in .json, .md or any other file. The old rule took any
# or // line of any file for a comment, so an attribute added to lib.rs
came out normal.

A lock origin is judged on its canonical form instead of its host: a
Cargo source other than the crates.io index, or an npm resolved other than
https://registry.npmjs.org/<name>/-/<short name>-<version>.tgz for the key
and version that package-lock.json gives at the PR head (read from the
API only when the diff adds a resolved line). A tarball of another package
on registry.npmjs.org, or another index on github.com, used to pass.

CONSENT_FILES adds the Feedback Hub consent (LogViewerCard.tsx,
FeedbackConsentDialog.tsx), and a fetchPrice( added outside
PriceFetchControl.tsx and the tests is high. is_test() replaces the
substring match on "test", which also skipped DownloadLatestButton.tsx.

PROBES take the hunks of a synthetic diff: one probe per "toujours"
pattern that no PR of #344-#452 exercises, an attribute and a comment
added to lib.rs, both lock origins and a canonical bump, both new consent
files, a new fetchPrice caller and a test that calls it. A lock probe's
hunk covers the whole file, its post-image being the lock at the head.
The docstring lists what the script does not model, and says that a PR's
level is read in REVIEW.md, never in its output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-24 21:51:27 -04:00
commit 628864937f

View file

@ -11,16 +11,38 @@ with its trial level (pilot document, section 4.3) and its REVIEW.md level,
then the distributions for the 39 reference PRs and for the whole range then the distributions for the 39 reference PRs and for the whole range
(a set with no PR in the range is skipped). (a set with no PR in the range is skipped).
--check compares the patterns of this script with the first column of the --check compares the patterns of this script with the first column of the
Haut table of REVIEW.md, runs the offline PROBES (a path and its expected Haut table of REVIEW.md, runs the offline PROBES (a path, the hunks of a
level), and exits 1 on any difference: a PR that changes the Niveaux synthetic diff, the expected level), and exits 1 on any difference: a PR
section updates this script in the same diff. that changes the Niveaux section updates this script in the same diff.
--check does not prove the conditions of the table: they stay with the
high-level review.
The content conditions of the Haut table are approximated from the diff: A PR's level is read in REVIEW.md, never in this script's output (neither
lib.rs (only generate_handler![] entries are exempt), Tauri configuration /pr-review, #457, nor the pilot, #458, runs it on an open PR): the content
and manifests (only the app's version is exempt), lock files (a package conditions of the Haut table are only approximated from the diff.
added or removed, an origin changed), check workflows (a change that can - Comments, by file extension: a line that starts with // in .rs, .ts, .tsx
turn a failing check green, read against the PR's merge base), network and .js (// @ts- and /// <reference stay code, like #[ and #!), with # in
calls (reqwest in Rust, fetch to an absolute URL in TS), consent files. .toml, .yml and .sh (a #! shebang stays code), none in .json, .md or any
other file. They and blank lines are skipped wherever the script reads
the changed lines, while REVIEW.md says "hors commentaires" for lib.rs
and the manifests only.
- lib.rs: only generate_handler![] entries are exempt, not the tests module.
- Tauri configuration and manifests: only a line that sets a version.
- Lock files: a package added or removed; an added source or resolved
outside its canonical form (the crates.io index; the npm tarball of the
key's name at the version that the lock read at the PR head gives that
key); a checksum or integrity added in a hunk that adds no version.
- Check workflows: a change that can turn a failing check green, read
against the PR's merge base; an env: block added at the workflow or job
level, or a run: step that deletes or edits a file (rm, sed -i), comes
out normal.
- Network calls: reqwest in Rust, fetch to an absolute URL in TS; an opened
URL is not seen.
- Consents: a changed line that says "consent" in CONSENT_FILES, and a
fetchPrice( added outside PriceFetchControl.tsx and the tests; a change
without the word, or a new path to FeedbackDialog, is not seen.
- Hooks and MCP servers: a file that .claude/settings.json or .mcp.json
makes the agents run is not detected.
""" """
import itertools import itertools
import json import json
@ -65,8 +87,18 @@ HIGH_ALWAYS = [
"**/.cargo/**", "**/.cargo/**",
".claude/settings.json", ".mcp.json", ".claude/settings.json", ".mcp.json",
] ]
# REVIEW.md, row "code livré": the price consent, then the Feedback Hub one
# (openFeedback of LogViewerCard.tsx, the only path to FeedbackDialog).
CONSENT_FILES = {"src/components/balance/PriceFetchControl.tsx", CONSENT_FILES = {"src/components/balance/PriceFetchControl.tsx",
"src/components/settings/PriceFetchConsentToggle.tsx"} "src/components/settings/PriceFetchConsentToggle.tsx",
"src/components/settings/LogViewerCard.tsx",
"src/components/settings/FeedbackConsentDialog.tsx"}
# The one caller of prices.fetchPrice, behind the price consent.
PRICE_CALLER = "src/components/balance/PriceFetchControl.tsx"
CRATES_IO = "registry+https://github.com/rust-lang/crates.io-index"
# Comment syntax by extension (REVIEW.md, "commentaire"); any other: none.
SLASH_COMMENT = (".rs", ".ts", ".tsx", ".js")
HASH_COMMENT = (".toml", ".yml", ".sh")
TAURI_CONFIG = ["src-tauri/{tauri*.conf.json*,Tauri*.toml}"] TAURI_CONFIG = ["src-tauri/{tauri*.conf.json*,Tauri*.toml}"]
CHECK_WORKFLOWS = {".forgejo/workflows/check-rust.yml", ".forgejo/workflows/check-frontend.yml"} CHECK_WORKFLOWS = {".forgejo/workflows/check-rust.yml", ".forgejo/workflows/check-frontend.yml"}
SHIPPED = ["src/**", "src-tauri/src/**", "index.html", "public/**"] SHIPPED = ["src/**", "src-tauri/src/**", "index.html", "public/**"]
@ -84,6 +116,10 @@ def get(path, raw=False):
return data if raw else json.loads(data) return data if raw else json.loads(data)
def raw_file(path, ref):
return get(f"/raw/{path}?ref={ref}", raw=True).decode()
def expand_braces(pat): def expand_braces(pat):
m = re.search(r"\{([^{}]*)\}", pat) m = re.search(r"\{([^{}]*)\}", pat)
if not m: if not m:
@ -118,47 +154,73 @@ def file_blocks(diff):
return out return out
def meaningful(text): def meaningful(text, path):
"""False for a blank line and for a comment, by the extension of path."""
t = text.strip() t = text.strip()
return t != "" and not t.startswith(("#", "//")) if t == "":
return False
if path.endswith(SLASH_COMMENT):
# compiler directives are code, and so are #[...] and #! (no //)
return not t.startswith("//") or re.match(r"//+\s*@ts-|///\s*<reference", t) is not None
if path.endswith(HASH_COMMENT):
return not t.startswith("#") or t.startswith("#!")
return True
def changed(block): def changed(block, path):
return [l for l in block.split("\n") return [l for l in block.split("\n")
if l[:1] in "+-" and not l.startswith(("+++", "---")) and meaningful(l[1:])] if l[:1] in "+-" and not l.startswith(("+++", "---")) and meaningful(l[1:], path)]
def lock_adds_or_removes(name, block): def is_test(path):
return re.search(r"\.test\.[cm]?[jt]sx?$", path) is not None or path.startswith("src/test/")
def npm_canonical(key, version):
# the name follows the key's last node_modules/; a scoped tarball drops the scope
name = key.rsplit("node_modules/", 1)[-1]
return f"https://registry.npmjs.org/{name}/-/{name.split('/')[-1]}-{version}.tgz"
def off_canonical(cargo, added, head):
"""The added source or resolved values outside the canonical form of their package."""
if cargo:
return [s for s in added if s != CRATES_IO]
try:
packages = json.loads(head())["packages"]
except (ValueError, KeyError, TypeError):
return added # a lock that cannot be read at the head: the condition counts as met
out = []
for url in added:
keys = [k for k, v in packages.items() if isinstance(v, dict) and v.get("resolved") == url]
if not keys or any(url != npm_canonical(k, packages[k].get("version")) for k in keys):
out.append(url)
return out
def lock_adds_or_removes(name, block, head):
"""head() returns the lock at the PR head, read only when an origin line is added."""
cargo = name.endswith("Cargo.lock") cargo = name.endswith("Cargo.lock")
lines = block.split("\n") lines = block.split("\n")
if cargo and any(re.match(r'^[+-]name = ', l) for l in lines): if cargo and any(re.match(r'^[+-]name = ', l) for l in lines):
return True return True
if not cargo and any(re.match(r'^[+-]\s+"node_modules/[^"]+": \{', l) for l in lines): if not cargo and any(re.match(r'^[+-]\s+"node_modules/[^"]+": \{', l) for l in lines):
return True return True
source = r'^([+-])source = "([^"]+)"' if cargo else r'^([+-])\s+"resolved": "([^"]+)"' # an origin outside the canonical form, with or without a new version
digest = r'^\+(checksum) = ' if cargo else r'^\+\s+"(integrity)": ' source = r'^\+source = "([^"]+)"' if cargo else r'^\+\s+"resolved": "([^"]+)"'
added = [m.group(1) for m in (re.match(source, l) for l in lines) if m]
if added and off_canonical(cargo, added, head):
return True
# a checksum or integrity that changes without a new version
digest = r'^\+checksum = ' if cargo else r'^\+\s+"integrity": '
version = r'^\+version = ' if cargo else r'^\+\s+"version": ' version = r'^\+version = ' if cargo else r'^\+\s+"version": '
for hunk in re.split(r"(?m)^@@", block)[1:]: for hunk in re.split(r"(?m)^@@", block)[1:]:
hl = hunk.split("\n") hl = hunk.split("\n")
# an origin whose host or scheme changes, with or without a new version
before, after = set(), set()
for l in hl:
m = re.match(source, l)
if m:
(before if m.group(1) == "-" else after).add(origin_of(m.group(2)))
if after - before:
return True
# a checksum or integrity that changes without a new version
if any(re.match(digest, l) for l in hl) and not any(re.match(version, l) for l in hl): if any(re.match(digest, l) for l in hl) and not any(re.match(version, l) for l in hl):
return True return True
return False return False
def origin_of(url):
m = re.match(r"^([a-z+]+)://([^/]+)", url)
return m.group(1) + "://" + m.group(2) if m else url
STEP = re.compile(r"^\s*- (name|uses):") STEP = re.compile(r"^\s*- (name|uses):")
VERDICT = re.compile(r"npm ci|npm run build|npm test|cargo check|cargo test|cargo audit|cargo-audit|Verify", re.I) VERDICT = re.compile(r"npm ci|npm run build|npm test|cargo check|cargo test|cargo audit|cargo-audit|Verify", re.I)
@ -191,14 +253,14 @@ def regions(base):
return region, lines return region, lines
def weakening(block, base): def weakening(path, block, base):
"""Ways a check-workflow diff could turn a failing check green (empty = none).""" """Ways a check-workflow diff could turn a failing check green (empty = none)."""
region, lines = regions(base) region, lines = regions(base)
reasons, old, plus = set(), 0, [] reasons, old, plus = set(), 0, []
def flush(pos): def flush(pos):
texts = [p[1:] for p in plus] texts = [p[1:] for p in plus]
active = [t for t in texts if meaningful(t)] # comments never count active = [t for t in texts if meaningful(t, path)] # comments never count
if any(re.search(r"continue-on-error|\|\|\s*true", t) for t in active): if any(re.search(r"continue-on-error|\|\|\s*true", t) for t in active):
reasons.add("continue-on-error or || true added") reasons.add("continue-on-error or || true added")
if any(re.search(r"GITHUB_ENV|GITHUB_PATH|npm pkg set|git checkout|git restore", t) for t in active): if any(re.search(r"GITHUB_ENV|GITHUB_PATH|npm pkg set|git checkout|git restore", t) for t in active):
@ -209,7 +271,7 @@ def weakening(block, base):
reasons.add("install step changes the toolchain or the PATH") reasons.add("install step changes the toolchain or the PATH")
if any(re.match(r"^(\s{4})?(if|defaults):", t) for t in active): if any(re.match(r"^(\s{4})?(if|defaults):", t) for t in active):
reasons.add("job-level if/defaults changed") reasons.add("job-level if/defaults changed")
first = next((t for t in texts if meaningful(t)), None) first = next((t for t in texts if meaningful(t, path)), None)
if first is None or STEP.match(first): if first is None or STEP.match(first):
return return
prev, nxt = region.get(pos - 1, "other"), region.get(pos, "other") prev, nxt = region.get(pos - 1, "other"), region.get(pos, "other")
@ -235,7 +297,7 @@ def weakening(block, base):
plus.append(line); continue plus.append(line); continue
flush(old); plus = [] flush(old); plus = []
if line.startswith("-") and not line.startswith("---"): if line.startswith("-") and not line.startswith("---"):
if meaningful(line[1:]): if meaningful(line[1:], path):
if re.match(r"^(\s{4})?(if|defaults):", line[1:]): if re.match(r"^(\s{4})?(if|defaults):", line[1:]):
reasons.add("job-level if/defaults changed") reasons.add("job-level if/defaults changed")
if re.search(r"rustup|toolchain|\bPATH\b|/bin/", line[1:]): if re.search(r"rustup|toolchain|\bPATH\b|/bin/", line[1:]):
@ -255,7 +317,7 @@ def weakening(block, base):
def adds_network_call(path, block): def adds_network_call(path, block):
if not match(SHIPPED, path) or re.search(r"test", path): if not match(SHIPPED, path) or is_test(path):
return False return False
for l in block.split("\n"): for l in block.split("\n"):
if l.startswith("+") and not l.startswith("+++"): if l.startswith("+") and not l.startswith("+++"):
@ -272,7 +334,8 @@ def trial_level(paths):
return "bas" if all(match(TRIAL_LOW, p) for p in paths) else "normal" return "bas" if all(match(TRIAL_LOW, p) for p in paths) else "normal"
def review_level(number, files, diff, merge_base): def review_level(number, files, diff, merge_base, head, read=raw_file):
"""read(path, ref) returns a file at the merge base or at the PR head."""
blocks = file_blocks(diff) blocks = file_blocks(diff)
triggers = [] triggers = []
for f in files: for f in files:
@ -281,25 +344,23 @@ def review_level(number, files, diff, merge_base):
if match(HIGH_ALWAYS, path): if match(HIGH_ALWAYS, path):
triggers.append(path) triggers.append(path)
elif path == "src-tauri/src/lib.rs": elif path == "src-tauri/src/lib.rs":
if [l for l in changed(b) if not re.match(r"^[+-]\s*commands::\w+,?\s*$", l)]: if [l for l in changed(b, path) if not re.match(r"^[+-]\s*commands::\w+,?\s*$", l)]:
triggers.append(path) triggers.append(path)
elif path == "src-tauri/src/commands/balance_commands.rs": elif path == "src-tauri/src/commands/balance_commands.rs":
hunks = re.split(r"(?m)^(?=@@)", b)[1:] hunks = re.split(r"(?m)^(?=@@)", b)[1:]
if any(re.search(r"fetch_price|activation", h.split("\n")[0]) or if any(re.search(r"fetch_price|activation", h.split("\n")[0]) or
any(re.search(r"fetch_price|activation", l) for l in changed(h)) for h in hunks): any(re.search(r"fetch_price|activation", l) for l in changed(h, path)) for h in hunks):
triggers.append(path) triggers.append(path)
elif match(TAURI_CONFIG, path) or path in ("src-tauri/Cargo.toml", "package.json"): elif match(TAURI_CONFIG, path) or path in ("src-tauri/Cargo.toml", "package.json"):
if [l for l in changed(b) if not re.match(r'^[+-]\s*"?version"?\s*[:=]', l)]: if [l for l in changed(b, path) if not re.match(r'^[+-]\s*"?version"?\s*[:=]', l)]:
triggers.append(path) triggers.append(path)
elif path in ("src-tauri/Cargo.lock", "package-lock.json"): elif path in ("src-tauri/Cargo.lock", "package-lock.json"):
if lock_adds_or_removes(path, b): if lock_adds_or_removes(path, b, lambda: read(path, head)):
triggers.append(path) triggers.append(path)
elif path == ".forgejo/workflows/audit.yml" and changed(b): elif path == ".forgejo/workflows/audit.yml" and changed(b, path):
triggers.append(path) triggers.append(path)
elif path in CHECK_WORKFLOWS: elif path in CHECK_WORKFLOWS:
wf = path.split("/")[-1] if weakening(path, b, read(path, merge_base)):
base = get(f"/raw/.forgejo/workflows/{wf}?ref={merge_base}", raw=True).decode()
if weakening(b, base):
triggers.append(path) triggers.append(path)
elif path.startswith(".forgejo/workflows/") and f["status"] == "added": elif path.startswith(".forgejo/workflows/") and f["status"] == "added":
triggers.append(path + " (new workflow)") triggers.append(path + " (new workflow)")
@ -310,8 +371,11 @@ def review_level(number, files, diff, merge_base):
added = [l for l in b.split("\n") if l.startswith("+") and not l.startswith("+++")] added = [l for l in b.split("\n") if l.startswith("+") and not l.startswith("+++")]
if path.startswith(".forgejo/workflows/") and any(re.search(r"\bsecrets\b|pull_request_target", l) for l in added): if path.startswith(".forgejo/workflows/") and any(re.search(r"\bsecrets\b|pull_request_target", l) for l in added):
triggers.append(path + " (secrets or pull_request_target added)") triggers.append(path + " (secrets or pull_request_target added)")
if path in CONSENT_FILES and any(re.search(r"consent", l, re.I) for l in changed(b)): if path in CONSENT_FILES and any(re.search(r"consent", l, re.I) for l in changed(b, path)):
triggers.append(path + " (consent)") triggers.append(path + " (consent)")
if (match(SHIPPED, path) and not is_test(path) and path != PRICE_CALLER and any(
l.startswith("+") and re.search(r"\bfetchPrice\(", l) for l in changed(b, path))):
triggers.append(path + " (fetchPrice caller)")
parts = path.split("/") parts = path.split("/")
top_level = len(parts) == 1 or (parts[0] == "src-tauri" and len(parts) == 2) top_level = len(parts) == 1 or (parts[0] == "src-tauri" and len(parts) == 2)
new_hidden = f["status"] == "added" and any( new_hidden = f["status"] == "added" and any(
@ -334,16 +398,94 @@ CONDITIONAL = {
".forgejo/workflows/{check-rust,check-frontend}.yml", "REVIEW.md", ".forgejo/workflows/{check-rust,check-frontend}.yml", "REVIEW.md",
} }
# Offline probes run by --check. A typo shared by the Haut table and the # A lock probe's one hunk covers the whole file: its post-image is the lock
# script passes the pattern comparison, and the replay cannot see it on the # that the script reads at the PR head.
# Release row: every PR of the range that touches verify-release.sh also NPM_OFF_CANONICAL = """@@ -1,10 +1,10 @@
# touches release.yml (review of #498, mutation M4). {
"lockfileVersion": 3,
"packages": {
"node_modules/foo": {
- "version": "1.2.3",
- "resolved": "https://registry.npmjs.org/foo/-/foo-1.2.3.tgz",
- "integrity": "sha512-b2xk"
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/evil-foo/-/evil-foo-1.2.4.tgz",
+ "integrity": "sha512-ZXZp"
}
}
}"""
NPM_CANONICAL_BUMP = """@@ -1,10 +1,10 @@
{
"lockfileVersion": 3,
"packages": {
"node_modules/foo/node_modules/@scope/bar": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@scope/bar/-/bar-2.0.0.tgz",
- "integrity": "sha512-b2xk"
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@scope/bar/-/bar-2.0.1.tgz",
+ "integrity": "sha512-ZXZp"
}
}
}"""
CARGO_OFF_INDEX = '''@@ -1,5 +1,5 @@
[[package]]
name = "foo"
version = "1.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+source = "registry+https://github.com/evil/crates.io-index"
checksum = "e3b0c442"'''
# Offline probes run by --check: a path, the hunks of its diff (None: an empty
# diff) and the expected level. A typo shared by the Haut table and the script
# passes the pattern comparison, and the replay sees it only when a PR of the
# range has that pattern for its only high trigger (review of #498, mutation
# M4). Hence one probe per "toujours" pattern that no PR of #344-#452
# exercises, the two of the Release row, and one per rule of this script that
# the range does not exercise either (#476).
PROBES = [ PROBES = [
(".claude/skills/release/scripts/verify-release.sh", "haut"), (".claude/skills/release/scripts/verify-release.sh", None, "haut"),
(".claude/skills/release/SKILL.md", "normal"), (".claude/skills/release/SKILL.md", None, "normal"),
(".claude/skills/issue-license/SKILL.md", None, "haut"),
("src-tauri/src/commands/export_import_commands.rs", None, "haut"),
("src-tauri/src/commands/feedback_commands.rs", None, "haut"),
("src/services/feedbackService.ts", None, "haut"),
("src-tauri/capabilities/default.json", None, "haut"),
("src-tauri/build.rs", None, "haut"),
("vite.config.ts", None, "haut"),
(".postcssrc.json", None, "haut"),
(".npmrc", None, "haut"),
("src-tauri/rust-toolchain.toml", None, "haut"),
("Cargo.toml", None, "haut"),
(".cargo/audit.toml", None, "haut"),
(".claude/settings.json", None, "haut"),
(".mcp.json", None, "haut"),
# an attribute is code, a // line a comment
("src-tauri/src/lib.rs", '@@ -1 +1,2 @@\n+#[cfg(feature = "dev-override")]\n pub fn run() {', "haut"),
("src-tauri/src/lib.rs", "@@ -1 +1,2 @@\n+// Builds the app.\n pub fn run() {", "normal"),
("package-lock.json", NPM_OFF_CANONICAL, "haut"),
("package-lock.json", NPM_CANONICAL_BUMP, "normal"),
("src-tauri/Cargo.lock", CARGO_OFF_INDEX, "haut"),
("src/components/settings/LogViewerCard.tsx",
'@@ -21 +21 @@\n- const accepted = localStorage.getItem(FEEDBACK_CONSENT_KEY) === "true";\n'
"+ const accepted = true;", "haut"),
("src/components/settings/FeedbackConsentDialog.tsx",
'@@ -47 +47 @@\n- <p>{t("feedback.consent.body")}</p>\n+ <p>{t("feedback.consent.short")}</p>', "haut"),
("src/components/balance/SnapshotLineRow.tsx",
'@@ -1 +1,2 @@\n import { prices } from "../../services/balance.service";\n'
'+void prices.fetchPrice(symbol, date);', "haut"),
("src/services/balance.service.test.ts",
'@@ -1 +1,2 @@\n import { prices } from "./balance.service";\n'
'+const result = await prices.fetchPrice("AAPL", "2026-04-25");', "normal"),
] ]
def image(hunks, post):
"""The post-image (at the head) or the pre-image (at the base) of a probe's hunks."""
keep = "+" if post else "-"
return "\n".join(l[1:] for l in (hunks or "").split("\n") if l[:1] in (" ", keep))
def check(): def check():
"""Compare this script's patterns with the first column of the Haut table, then run PROBES.""" """Compare this script's patterns with the first column of the Haut table, then run PROBES."""
text = open(REVIEW_MD, encoding="utf-8").read() text = open(REVIEW_MD, encoding="utf-8").read()
@ -358,8 +500,10 @@ def check():
for pattern in sorted(extra): for pattern in sorted(extra):
print(f"{label}: {pattern}") print(f"{label}: {pattern}")
failed = documented != coded failed = documented != coded
for path, want in PROBES: for path, hunks, want in PROBES:
got = review_level(0, [{"filename": path, "status": "changed"}], "", None)[0] diff = f"diff --git a/{path} b/{path}\n--- a/{path}\n+++ b/{path}\n{hunks}\n" if hunks else ""
got = review_level(0, [{"filename": path, "status": "changed"}], diff, "base", "head",
lambda p, ref, h=hunks: image(h, ref == "head"))[0]
if got != want: if got != want:
print(f"probe: {path} is {got}, expected {want}") print(f"probe: {path} is {got}, expected {want}")
failed = True failed = True
@ -393,9 +537,9 @@ def main():
files += fb files += fb
fpage += 1 fpage += 1
diff = get(f"/pulls/{n}.diff", raw=True).decode("utf-8", "replace") diff = get(f"/pulls/{n}.diff", raw=True).decode("utf-8", "replace")
merge_base = get(f"/pulls/{n}")["merge_base"] pr = get(f"/pulls/{n}")
trial = trial_level([f["filename"] for f in files]) trial = trial_level([f["filename"] for f in files])
level, triggers = review_level(n, files, diff, merge_base) level, triggers = review_level(n, files, diff, pr["merge_base"], pr["head"]["sha"])
rows.append((n, trial, level, triggers)) rows.append((n, trial, level, triggers))
print(f"#{n}\t{'ref' if n in REF39 else ' '}\t{trial}\t{level}\t{'; '.join(triggers)}") print(f"#{n}\t{'ref' if n in REF39 else ' '}\t{trial}\t{level}\t{'; '.join(triggers)}")
for label, keep in (("39 reference PRs", lambda n: n in REF39), (f"{len(rows)} PRs #{first}-#{last}", lambda n: True)): for label, keep in (("39 reference PRs", lambda n: n in REF39), (f"{len(rows)} PRs #{first}-#{last}", lambda n: True)):