diff --git a/scripts/review-levels.py b/scripts/review-levels.py
index 470ee1b..54ef75f 100755
--- a/scripts/review-levels.py
+++ b/scripts/review-levels.py
@@ -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
(a set with no PR in the range is skipped).
--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
-level), and exits 1 on any difference: a PR that changes the Niveaux
-section updates this script in the same diff.
+Haut table of REVIEW.md, runs the offline PROBES (a path, the hunks of a
+synthetic diff, the expected level), and exits 1 on any difference: a PR
+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:
-lib.rs (only generate_handler![] entries are exempt), Tauri configuration
-and manifests (only the app's version is exempt), lock files (a package
-added or removed, an origin changed), check workflows (a change that can
-turn a failing check green, read against the PR's merge base), network
-calls (reqwest in Rust, fetch to an absolute URL in TS), consent files.
+A PR's level is read in REVIEW.md, never in this script's output (neither
+/pr-review, #457, nor the pilot, #458, runs it on an open PR): the content
+conditions of the Haut table are only approximated from the diff.
+- Comments, by file extension: a line that starts with // in .rs, .ts, .tsx
+ and .js (// @ts- and ///
{t("feedback.consent.short")}
', "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(): """Compare this script's patterns with the first column of the Haut table, then run PROBES.""" text = open(REVIEW_MD, encoding="utf-8").read() @@ -358,8 +500,10 @@ def check(): for pattern in sorted(extra): print(f"{label}: {pattern}") failed = documented != coded - for path, want in PROBES: - got = review_level(0, [{"filename": path, "status": "changed"}], "", None)[0] + for path, hunks, want in PROBES: + 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: print(f"probe: {path} is {got}, expected {want}") failed = True @@ -393,9 +537,9 @@ def main(): files += fb fpage += 1 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]) - 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)) 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)):