6.5.11 · D2Research Frontiers & Practice

Visual walkthrough — Contributing to open-source ML

2,122 words10 min readBack to topic

Prerequisites you may want open in another tab: Code Review Best Practices, Testing ML Systems, Version Control with Git.


Step 1 — What is a "PR" and what are we even scoring?

WHAT. A Pull Request (PR) is a proposal: "Here is a bundle of code changes — please add them to the project." A human maintainer reads it and answers a single yes/no question: merge it, or not?

WHY we need a score. If the answer is just yes/no, we want to understand what pushes it toward yes. A score is just a number we attach to the PR that predicts "will this be merged?" — higher number, more likely to merge. We will call that number , read aloud as "the quality of the pull request". The subscript "PR" is just a label reminding us what the refers to; it does no maths.

PICTURE. Think of the PR as a package arriving at a gate. The gatekeeper (maintainer) inspects it and either opens the gate (merge) or turns it away (reject).

Figure — Contributing to open-source ML

Step 2 — Break the package into four honest questions

WHAT. A maintainer's decision is not one gut feeling; it is really four separate checks. Each check is a plain question with a yes/no answer:

  • Does it actually work? — call this check .
  • Can a stranger read it and understand what it does? — call this .
  • Will it still work next month when someone else edits nearby code? — call this .
  • Was this the right problem to solve, and this the right way? — call this .

The letter just stands for Check. The subscript names which check.

WHY these four and not others. These map exactly onto the four things a reviewer physically does when reading a PR (see Code Review Best Practices): run it, read it, look for tests, and ask "why". Nothing a reviewer cares about falls outside these four — so they are complete. And they don't overlap — passing "it runs" tells you nothing about "is it readable" — so they are independent. Complete + independent is exactly what you want from a checklist.

PICTURE. The one package now passes through four gates in a row, each stamping a (pass) or (fail).

Figure — Contributing to open-source ML

Step 3 — Why combine them with multiplication, not addition?

Here is the heart of the whole formula. We have four numbers, each or . We must combine them into one score. There are two natural candidates.

Candidate A — add them: . Candidate B — multiply them: .

WHY multiplication wins. Ask: what should happen if the PR fails exactly one check? Say the code is correct, clear, and justified — but has no tests, so .

  • Addition gives . That is a high score — as if three-out-of-four is "pretty good". But an untested change to a machine-learning library will not be merged. Addition rewards partial credit, and partial credit is a lie here.
  • Multiplication gives . Any single failure zeroes the whole thing. That is exactly the real rule: one fatal flaw sinks the PR no matter how good the rest is.

This "any zero kills everything" behaviour is the defining superpower of multiplication with inputs — it acts as a logical AND. The reason we choose this tool over addition is precisely that a mergeable PR must pass all checks simultaneously, never "mostly".

PICTURE. Below, the same four gates, but we watch what a single does to the running product versus the running sum.

Figure — Contributing to open-source ML

Step 4 — Why each factor is exactly or (and nothing between)

WHAT. We declared each to be binary in Step 2. Now let's justify why we don't allow, say, ("kind of readable").

WHY binary. The moment you allow fractions, the "AND" meaning breaks. Watch:

  • If (half-tested) and everything else is , then . That reads as "half-mergeable" — but there is no such thing. It either merges or it doesn't.
  • Binary values keep itself binary: a product of s and s is always or . So the output stays a clean verdict.

The reviewer's job during Revisions (from the parent's lifecycle) is precisely to flip any up to a . Each round of code review targets one failing factor and fixes it — turning — until the product finally reaches .

PICTURE. A truth-table grid: every combination of the four switches, and the single lit cell where the product equals .

Figure — Contributing to open-source ML

Step 5 — The maximum value is 1: why it can't be bigger

WHAT. We claim can never exceed ; its best possible value is exactly .

WHY. Multiply the largest allowed value of each factor: . Since no factor can be larger than , no product can be larger than . So — the score lives on two values only, and is the ceiling.

This is why "a perfect PR scores " is meaningful: is not an arbitrary grade, it is the mathematical maximum of the expression. Reaching it means every gate stamped a pass.

PICTURE. A number line with only two dots — and — and every one of the 16 combinations landing on one of them.

Figure — Contributing to open-source ML

Step 6 — The degenerate cases (never leave a gap)

Let's deliberately walk the corners so no scenario surprises you.

Case A — the empty PR (no changes at all). There is nothing to be correct, clear, tested, or justified. Convention: an empty PR has (it fixes nothing), so . Good — an empty package should not merge.

Case B — all four fail. . Merges? No. Consistent.

Case C — three pass, one fails (any position). Because multiplication doesn't care which factor is the zero, all four "three-out-of-four" cases collapse to the same verdict . Failing tests is exactly as fatal as failing clarity. This symmetry is a feature: no factor is secretly optional.

Case D — the perfect PR. . Merges. The only route to .

PICTURE. The four corner scenarios side by side with their arithmetic.

Figure — Contributing to open-source ML

The one-picture summary

Figure — Contributing to open-source ML

The whole derivation in one image: four binary gates feeding a multiplier, one lit output. AND-logic made visible.

Recall Feynman retelling — say it back in plain words

Imagine you mail a box of code to a project. A guard checks four things, and only four: does it work, can I read it, are there tests, and did you solve the right thing? Each check is a light switch — on if the answer is yes, off if no. Now, how do I turn four switches into one verdict? If I add them up, then three good answers out of four looks like a decent score — but that's a trap, because a missing test alone gets you turned away at the gate. So instead I multiply the switches. Multiplying zeros and ones is just the word "AND": every switch must be on, because a single off-switch multiplies the whole thing to zero. Since each switch is at most a one, the biggest the product can ever be is one — that's the "perfect PR", the single lit cell out of sixteen. Every other combination — empty box, all-off, or any three-out-of-four — lands on zero. The reviewer's whole job during revisions is to walk around flipping off-switches back on until, at last, the product clicks to one and the gate opens.

Recall

Why multiply the four checks instead of adding them? ::: Multiplying values behaves like logical AND — any single zeroes the product, matching the fact that one fatal flaw makes a PR unmergeable. Adding would wrongly reward partial credit. What is the maximum value of and when is it reached? ::: , reached only when all four checks equal (correct AND clear AND tested AND justified). Why must each be binary rather than a fraction? ::: A fraction would produce a fractional ("half-mergeable"), which is meaningless — the merge decision is yes/no, so the factors and the output must both stay or . Of the combinations of the switches, how many give ? ::: Exactly one — the all-ones row. Which lifecycle step secures before coding? ::: "Find Issue" — confirming maintainers want the change and it solves the right problem.


Connected reading