Algorithm studies
DoneSix pieces of math from Reef, Grade Lab and Social Lab, written up to show how changing an input changes the decision.
The products are private. These studies aren’t. Each figure comes from a JavaScript port of the real function with its real constants. The inputs are samples I made to show one behavior clearly, so none of the numbers are measurements unless the text says so.
- Role
- Solo builder, directing coding agents
- Stack
- JavaScript ports of Python functions
- Pinned
- Reef at
9d2b7ffca, Grade Lab at62d3d87 - Links
- Showcase repo
- As of
- Nov 1, 2026
The house rule
Each port follows one function in one commit. When a port and its source disagree, the source is right and the port is a bug.
The six studies
Giving color back with distance
Water takes red away with distance and lays a blue-green veil over everything. Grade Lab undoes that in a Fusion Fuse I wrote, ReefSeaThru, which reads distance from Resolve’s own Depth Map. It’s the figure at the top of this page.
Version 2 restored color everywhere. On cut 30 I said “i guess it does become pink tho and the divers leg does look worse.” Nearer than the nearest veil reading there’s almost no water to take out, so v2 was subtracting a veil that wasn’t there. Version 3 fades the restoration out along that path, down to none at the nearest thing.
Instead of the same restoration at every distance
Pushing water cyan without touching the fish
A global hue shift turns the water cyan and the garibaldi green with it. Grade Lab’s look node decides per pixel instead. It measures how blue a pixel is relative to its brightest channel, (b − r) / peak. Pixels with enough blue evidence get the water shift, pixels with the opposite evidence get the warm shift, and each pixel is rescaled to the luminance it started with, so the shift changes hue and not exposure.
Instead of a global hue shift
Starting from a grade I already liked
Grade Lab doesn’t average my past grades. For a new shot it measures a fingerprint of 17 numbers, z-scored across the library, and the distance d to an old shot is the root mean square of the differences. A version’s outcome halves for every 21 days since my newest verdict. Of the five nearest shots, the seed is the praised one with the best e^(−d) · (1 + max(0, outcome)).
Instead of averaging past grades
Where a moment starts and stops
Reef’s moment finder scores every quarter second for how usable it is: 0.4·sharp + 0.6·subject + 0.15·residual − 0.5·whip, where whip is camera motion times blur. A single threshold on that curve breaks one shot into fragments, so a run starts at 0.35 and keeps going until it falls below 0.22. Runs less than 2 seconds apart merge, and anything shorter than 2 seconds after merging is dropped. Those values were set on my own dive clips.
Instead of a single threshold
Undoing one edit and keeping the rest
An undo stack can’t do this. The agent trims a shot. Then I change its speed. Now I want the agent’s trim gone and my speed kept. Reef’s history.revert undoes the changes one revision made and keeps every later change to other fields. It writes a new revision instead of rewriting old ones, refuses if a field it would undo was changed again later, and says who changed it. An agent can only revert agent revisions.
Instead of an undo stack

Calling a post a breakout
A million views means nothing for a creator who averages two million. Social Lab only calls a post a breakout when it beats the creator’s own feed on three measures at once: lift of at least 3, robust z of at least 2 and cautious lift of at least 2. It won’t score a creator with fewer than ten other posts.
Instead of view counts
How they’re checked
- Pinned source
- Each port follows one function in one commit: Reef at
9d2b7ffca, Grade Lab at62d3d87. - Notes
- The derivations, the parts left out, and where each constant came from are in the repo’s notes folder.
Where it stands
Works today
- Six public studies, each runnable, each a port of one real function.
Left out
- The inputs are samples, and each figure runs only the step it studies. The real functions do more, and the notes say what.