Engineering and data curation notes from Ptree, a tree of life explorer: DOM-as-state layout, modern CSS, read-only SQLite, cross-kingdom classification, and executable tours. See also the revision history or subscribe via Atom.
Press Nocturnal on birds under Mass, drag a mass window on mammals under Conservation, or move the pointer over the sidebar's world map, and every property readout and the legend's box-whisker plot summarize only the matching part of the clade, recomputed in the browser on every frame the filter changes. The estimate needs no request. Each tile already carries a summary of every property its descendants hold, and I pool the summaries of the children on screen, each weighted by how much of it matches the filter. Unfiltered, pooling a class's orders this way recovers its true median within a percent or two. Filtered, it rests on one assumption, so it is an estimate, shown until the exact answer from the leaf index replaces it, within a second of the filter coming to rest.
Every value in Ptree rolls up through its tree to Life, and I give every category present in a clade at least two device pixels of its tile, however small its share. Together those make the tree a debugger for its own data. A quarter of one species out of fourteen thousand living mammals still shows as a line on the Mammalia tile, and clicking whichever child carries the line, again and again, walks you down to the single record responsible: a wasp filed in the red panda's genus, a bacterium's diet on a land snail's page. What that turns up goes on the source errors page under one rule: upstream's errors are shown, and mine are fixed.
The path from the root of life to Homo sapiens is seven columns in GBIF's taxonomy, 18 in the Catalogue of Life, 31 in NCBI's, and 33 in Open Tree's, and a readable screen holds three or four columns of names. Miller columns, the Finder's column view, answer depth by scrolling sideways until the root is gone. I fold instead: the Tree view keeps as many live columns as the width allows and stands every shallower column on end in one strip along the left edge. The folded tiles are the same tiles, rotated, with their connectors still attached, so the trunk back to the root stays on screen and one click from any depth, and several open branches fold into ribbons that route around each other.
Ptree's question box doesn't answer in a paragraph. It answers by operating the viewer on your screen: a cursor clicks tiles, presses legend cells, and drags filters while a voice reads the captions, and when it's done you are left on the screen it found, having watched every click it took to get there. A model writes that script, and models name targets that aren't there. So every stop is played first on a copy of the real viewer, booted from the viewer's own modules in a worker on the server, while the model is still writing. The first stop that can't land ends the model's request on the spot, and it rewrites from there while the stops already accepted are playing for you.
I judge a structural choice by what the features nobody has planned will cost. Every representation, owner, name, and table key I choose is paid for again by every later version of the app that passes through it, so the right choice is the one whose cost barely moves when the future pulls it in a direction I didn't anticipate: another source, another property, another view, another device. The test is concrete. When an unplanned request arrives, does it fall out of the structure that's already there, or does it need guards, adapters, parallel structures, and exception lists? If it needs those, the shape is what's wrong, and I move the shape instead of paying the detour.
Open Mammalia, press group on Organization, and switch to Longevity: the median lifespan of group-living mammals reads 19.0 years, and pressing single instead drops it to 7.0. Group-living mammals are also heavier, a median 2.1 kg against 91 g, but families of matching weight show the same gap. A 2023 paper in Nature Communications reported, from a phylogenetic comparative analysis, that group-living mammals live longer than solitary ones; in Ptree the same contrast takes three clicks, and so do the others below.
With fossils hidden, the beaver family is two species of 20 to 25 kilograms. With fossils shown it is thirty measured species with a median of 1.2 kilograms, because most beavers that ever lived were small. I store a living and an all-time summary for every property of every node, side by side in one profile, so the Fossils toggle swaps one for the other on every tile at once, and the question "what did extinction take from this branch?" is one click on any branch of the tree.
Per-clade box plots and category shares bound a filtered mean only loosely: they never say whether the species assessed for conservation status are the species weighed for body mass. A bound that assumes they are excludes the exact answer on 8 of 26 benchmark queries, by up to ×3.69 for the mass of group-living mammals. Dropping the assumption gives the worst-case interval of Manski's partial identification, which held at every one of 17,126 frontiers recorded and is still ×3.48 wide at the median after sixty clades are opened.
The browser estimates a filtered clade's summary by pooling its loaded children, assuming the filters and the target property are independent inside each child. This post asks what the same summaries can prove without that assumption: an exact identity for the estimate's error, an interval from seven quantiles, a mean, and category counts that no arrangement of species consistent with them can escape, a score for which clade to open next, and how all of it fares against exact answers from the depth-first leaf index. With only the subject's children loaded (the first row), the estimate is within ×1.30 of the exact answer at the median. The interval that assumes nothing held at every frontier recorded and is still ×3.48 wide at the median after sixty clades are opened, because the summaries cannot say whether the species measured for one trait are the species recorded for another.
Filter a vertebrate class in Ptree to its Vulnerable, Endangered, and Critically Endangered species and look at Mass. Threatened sharks and rays have a median of 21 kilograms against 1.2 for Least Concern species, threatened mammals 434 grams against 55, threatened birds 74 grams against 31. In lizards and snakes, and in frogs and salamanders, the direction reverses: the threatened species are the smaller ones. Conservation and body mass come from unrelated sources, and the contrast exists only because they sit on one tree.
I want a class to be a term in an algebra, not a name. BEM goes the other way: toolbar__button--first bakes the block, the element, and the position into one token, so every new group restates all three and gets its own rules. In Ptree a segmented control is drawn by three classes, Raised, Start, and End, the same three Ptable has used for decades, and a group exists because I marked where it starts and where it ends. The legend divides a property's questions without a single grouping element, and page state lives in one class on the nearest container everything that reads it shares.
Every line in Ptree's Tree view, from a flat link between neighbors to a detour routed around the folded gutter, is an SVG path with the same four commands, M C L C. CSS can interpolate d only between paths with the same command list, so I made every connector the same kind of path, and now the browser can morph any connector into any other. A layout writes each path's final shape once, and CSS transitions do all the motion. There is no animation code.
Add &location= to any Ptree address, with a country, a state, a lake, a sea, a mountain range, or a latitude and longitude, and every tile whose range doesn't reach that place dims. Every property and every legend filter keeps working on what stays lit. I didn't build a regional view. The whole tree of life becomes one place's flora and fauna, still arranged by relationship, and you can ask it anything you could ask of all life.
Press one legend category at the top of the tree and every branch that holds it stays lit while the rest of life dims. Because I made each bin mean the same thing in every kingdom, that one press is a picture of convergence: flight lights birds, bats, insects, and gliding lizards; eating animals lights five flowering-plant orders that are not each other's relatives, and a green alga; live birth lights mammals, sharks, seahorses, river snails, isopods, and the coelacanth.
Every trait database I know keeps each source's vocabulary in its own column. That's faithful, and it leaves nothing you can compare across the tree. I read every word every source uses into a small set of bins per property, chosen so that one bin means the same thing on a bacterium, a fern, a coral, and a bird: a flagellar motor and a cheetah's legs both answer mobile, a seed and an egg are both released, and a seabird colony and a bryozoan colony are both colonial. A word nobody has read stops the build with an error naming it, and the source's exact word stays under every colored tile.
I define taste as the ability to rank a piece of work by the product of the effort put into it and its maker's mastery, judged from the output alone. That definition becomes practical now that coding agents produce effort for free. Effort is the factor they inflate, so the work that is left for a person is detecting mastery, or its absence, in code that looks diligent.
Ptree has never had a mockup. A mockup records one state at one width with names someone typed in, and the forces that break a design aren't in it: a long name, a narrow window, a finger instead of a mouse, the moment between two states. I design in the page, and the three pieces below came out of that. None of them could have been drawn first and built after, because each one is a rule rather than a picture: a column count that is one CSS expression, a range filter that is two native inputs whose thumbs cast a shadow a screen wide, and a legend carousel that is every key stacked in one grid cell.
Ptree colors the tree with a few hundred OKLCH values in one stylesheet, and every one of them holds three promises at once: black text reads on it, it stays distinct from its neighbors for a viewer with mild color-vision deficiency, and it stays distinct while it fades toward white as a clade's coverage thins. The third is the hard one. A sparsely covered category washing toward white starts to look like a different, well-covered category at full strength, so I check every washed color against every other color unwashed, not only against its own palette.
Every browser ships a reactive dataflow engine with interpolation built in. The cascade recomputes every derived value from its inputs, and a transition tweens a typed input on every frame without running a line of script. Ptable and Ptree are built so that engine does the work: each element is the state and outlives every change, script writes a few final values, and the cascade derives the picture from them while the browser moves it. A framework can't reach that engine, because it keeps the truth in JavaScript and hands the browser one finished snapshot after another. I recently pointed an agent building an unrelated, futuristic animation at Ptree's source, and its animation went to 60 frames a second once its script wrote final values and left the frames to the browser.
I write Ptree against the newest CSS and DOM and treat the native path as the design. When an engine misreads a standard, I reduce it to the smallest failing case, report it, and isolate the workaround to the narrowest branch that detects exactly what's missing, so the native path stays untouched and the branch can be deleted the day the fix ships. A gate is a claim about an engine, so I also test every @supports gate the stylesheets use against what each engine actually does. The current list is on known browser issues.
When you open a branch in Ptree, its children appear at once as placeholders, in exactly the rows the real children will take, even with fossils hidden. I can do that because every taxon arrives already carrying the shape of its own first page of children: one integer whose bits say which slots are fossils. A count tells a client how many rows to draw. The mask tells it which ones, so the placeholders obey the same visibility rules the real taxa will, and nothing moves when the response lands.
I send every number to the browser unrounded, and beside it the resolution its source wrote, as a step in the value's own unit. A raven's mass typed as 928 in a column formatted to one decimal reads 0.9280 kg in its provenance, and a hedgehog weaned at 42 days stays 42 days after passing through another database's years. The obvious alternative, rounding the wire to a few significant digits, moved plot positions by several device pixels and turned a fossil interval of 201.4 to 227.3 million years into 201 to 227.
Ptree's location filter dims every taxon on screen whose range doesn't reach a chosen point or place, and the server has no table of which taxa occur where. The browser decides, with isPointInPath on a 1×1 OffscreenCanvas, against the range outlines the tiles already carry for their maps. That works because I made ranges and places out of the same thing: both are sets of H3 cells at resolution 3, drawn into one equirectangular world, so a place can travel as its cells' centers, and a center lies inside a range's outline exactly when the range holds that cell. Ask for the primates that reach Madagascar in the expert ranges and you get five families, every one a lemur.
In Ptree white means one thing on every property: no source has spoken for that branch. A tile's color washes toward white in proportion to how few of its species have records, so the same tree that shows what life is like also shows what biology has bothered to measure. Body mass is known for most living lizards and snakes and for twenty of over a million insect species. The IUCN has assessed nearly nine in ten birds and about four in a thousand fungi.
Ptree shows eleven taxonomic trees and keeps you on the same organism when you switch between them. That takes one identity relation over every source that names a taxon, and the obvious join key, the scientific name, is the one thing I can't use: the codes of nomenclature let Batis be a coastal shrub, a flycatcher, and a fossil ray at the same time. So identity is evidence, gated, and stored as a relation of its own. Where the other tree has no counterpart at all, the destination of every switch is decided once per build, not searched for while you wait.
Ptree's numeric legends draw a box-whisker plot for whichever taxon is under the pointer, and moving from hummingbirds to rorqual whales glides every part of it across twenty-two orders of magnitude of the Mass axis. There is no animation code. The legend writes six custom properties registered as <percentage>, and the browser interpolates the whisker, the box, the median, the mean, and the end labels from one value to the next. The same six numbers draw the very different glyphs of Temperature, pH, Salinity, and the back-to-back depth and elevation of Vertical range.
Richard Gabriel's "worse is better" sorts designers into two schools. The MIT school keeps the interface simple and lets the implementation absorb the cost; the New Jersey school keeps the implementation simple and lets the interface absorb it. I hold neither side fixed. When something on screen is wrong, I look for the change that makes the screen and the code simpler together, and when I find it, it usually deletes more than it adds. If either side still needs an exception, I haven't found it yet.
Every taxon card in Ptree opens its Wikipedia article from a book of about half a million articles that I cut from Kiwix's full 127 GB English Wikipedia, served by kiwix-serve behind Apache on the viewer's own origin. I rewrite every article with a real DOM when the book is built. Apache splices one stylesheet link into each page as it passes through. And because the article is same-origin, the viewer reaches into it and marks every link to an organism by which of the eleven trees hold it, so a link in the text is also a way to switch trees.
My tests state what is true of organisms, not what my rules produce, so many of them fail for months while the pipeline catches up. I keep them in the suite. Each known failure is listed with a sentence of cause, and a release is blocked in two cases: a failure the list doesn't name, and a listed test that has started to pass. The second rule makes the list shrink by itself as causes are fixed, and a true statement about an ostrich or a whiptail lizard stays in front of me on every run, never skipped, softened, or rewritten to agree with the output.
Ptree's API serves eleven taxonomic trees, 13.9 million nodes, with their properties, photos, sounds, interactions, range maps, and search, from a few dozen SQLite files opened read-only by Node's built-in node:sqlite. There is no database server. The data is built on one machine, shipped as files, and never written while it is served, and three choices follow from that: every store is opened immutable, the few slow routes share one worker pool so identical requests share one computation, and only pages that were slow to build are cached at all.
A guard on something your own code created doesn't make the code safer. It turns a broken invariant into a quiet wrong answer three steps later, and it adds a state, "the thing that can't be missing is missing", that every later edit has to reason about. So I check only at real boundaries, where input comes from outside, and trust everything else. Ptree's viewer has eleven try blocks, and each one either restores an attribute in a finally or stands at such a boundary: the address bar, an id the server no longer serves, a search superseded by the next keystroke, a tour step a model wrote. When an invariant breaks anywhere else, it throws at the line that assumed it, and the error report carries the stack.
The viewer's stylesheets have no :has(), and the view never asks the browser what is animating. Both come from the same principle: state is written down, never read up. A rule that reaches up from a container to ask about a control inside it is a restyle of everything under that container whenever anything inside changes, and a script that asks which animations are running forces layout to find out what it already caused. So state is a class written on the nearest container its readers share, and the view learns that motion has stopped by counting the transition events the browser already sends.
Ptree picks one representative recording per species from xeno-canto and iNaturalist, and metadata alone cannot tell you which one to play. Among four top-graded clean songs of a single bird, the bird measured 4 dB over the background floor in one and 87 dB in another. On hippos, a rustling phone clip with someone talking at the end carried higher metadata than a crisp Kruger Park chorus.
A few of Ptree's stores can't be rebuilt from a download: measurements of audio files that were fetched once and thrown away, strain records pulled one at a time from a rate-limited API, the license of every Commons image a taxon shows. They grow over months, and their shape still changes. None of them has a migration file. Each declares its tables once, as the CREATE TABLE statements I'd write for a fresh store, and one function has SQLite parse that declaration into a scratch database in memory, compares the two schemas through SQLite's own pragmas, and adds or drops columns and indexes until the held store matches the declaration.
I draw Ptree's property bins the way a Voronoi diagram divides a plane. Each bin's word is a seed, and every value any source can write falls into the cell of the nearest seed. A word is wrong when it puts a case on the wrong side of a border, and the test that finds it is to reason down from the word into cases it was never written for, above all the cases of another kingdom. Write the word from the evidence up, then check it from the word down.
Every piece of data in Ptree was made by someone who would object to what I do with it. A parasitologist would not file a leaf miner beside a tick. A statistician would not draw one box plot over one species' mean mass and another's maximum. A taxonomist publishing one backbone would not show ten rivals beside it as equals. Each objection is correct inside the community that makes it, and together they are why a tree of life you can color by what organisms eat, how they move, and how big they are, across every kingdom at once, didn't exist before. It takes someone outside every one of those communities, answerable to none of them, to make the comparison none of them would sign.
Much of Ptree's pipeline, its tests, its viewer refinements, and this blog were written with AI coding agents. An agent searches well inside the frame it is given and rarely leaves it. Asking it to review its own output searches the same frame again, with the same prior that wrote the code doing the judging. What follows is what I have found myself supplying: first a set of rules that keep the agent away from its default habits, then the moves that change the frame it is working in.