medirulekit
Moore's law, spelled backwards. Since the 1950s, the number of new medicines a billion research dollars buys has halved roughly every nine years — a hundredfold fall, over the same decades in which everything else in technology got cheaper.
Scannell et al., Nature Reviews Drug Discovery, 2012The most expensive part is the clinical trial — the slow, human years where an idea meets real patients. And every trial is governed by a single document: the protocol, hundreds of pages of prose deciding who may enter, what gets measured, and what counts as an answer.
Buried in that stack are the entry rules. Get them wrong and the trial screens the wrong people, amendments follow at half a million dollars each, and the mistake surfaces only after the money is spent.
keep scrolling — this is where the story startsscroll
medirulekit
The plain-language tour. No code needed, about six minutes, and it builds as it goes, so read it in order. There is an engineers' edition of the same story; the last section links to it.
01the clinical side
A clinical trial tests a new medicine on volunteers. Its eligibility criteriathe rules for who may join decide who gets the experimental drug and who is turned away for their own safety.
Those criteria are written in statute language: "participants are required to have", "must be excluded if". It sounds exact the way a law sounds exact, and it works the way a law works, through whoever happens to be applying it. The protocolthe trial's rulebook document is the statute book. There is no court attached. Every screener at every hospital rules on it alone, and a wrong ruling can hurt somebody.
So five teams copy the law into whatever tool they use, and each copy is a reading, not the law. Below is one rule about eGFRa standard kidney score: the trial wants a score of 30 or better. Watch what happens to that number.
Sooner or later the drift, or a flaw in the rules themselves, forces an amendmenta formal mid-trial rule change. The word is borrowed from law for a reason: this is changing the statute mid-trial. It looks like a page turning. It is re-printing, re-training, regulator re-approval, and sometimes re-consenting every volunteer at every hospital in the trial.
median direct cost of one substantial amendment in Phase IIthe mid-stage test
Tufts CSDD
median direct cost in Phase IIIthe large late-stage test
Tufts CSDD
of substantial amendments judged avoidable
Tufts CSDD
Source: Tufts Center for the Study of Drug Development, on the cost of protocol amendments.
Half a million dollars is a house, spent on changing a paragraph. Nearly half of those changes were avoidable, so the industry keeps buying houses it never needed. If you can test the rules, you find the flaw while it is still cheap to fix.
chapter 02 · the engine
the statute stops here. what follows is a file you can run.
02the engine
rulekit keeps each entry rule as a few lines of structured text. The protocol's original sentence sits right next to the logic, in the same file, so anyone can hold one up against the other. The next scene performs the translation on the statute's own words, one word at a time.
the engine · the whole trick, once
the difference between a statute and working code, in four moves
“…participants are required to have an eGFR of at least 30 at the time of screening…”
One file holds every rule, and every edit to it is tracked the way code changes are tracked. That alone kills the five drifting readings: there is one binding text again, and this one runs. The three ideas that follow are what you get once the law is a file.
the engine · idea one
yes, no, and "I don't know", and the third one is the whole point
02the engine · idea two
Once the rules are logic, a checker can lay them out on a number line and prove when two of them collide. Here is the collision planted in the project's teaching example, drawn slowly.
rule 1 to get in
"eGFR at least 30" … kidney score must be 30 or more to join.
rule 2 to be kept out · the row the page turn added, by a different author
"eGFR below 45 at screening" … anyone under 45 is turned away.
the same collision, walked
the floor is the statute. seven patients cross it. where the two clauses disagree there is no floor, and one patient, scoring exactly 30, is left hanging from the edge.
02the engine · idea three
A patient's verdict is computed exactly once. The printed report and the visual app both read that one result, so two screens can never show different counts.
chapter 03 · the AI part
a machine starts reading the notes. it still does not decide.
03the AI part
The hard part of screening is that the facts are buried in doctors' notes, written for other doctors. rulekit lets an AI read a note and suggest facts. Every suggestion has to carry the exact quote it came from, and a person approves it or throws it out.
The scene below runs on a note somebody wrote by hand for this page. The suggested fact is an NYHA classa heart-failure severity grade, and the number beside it is a confidencethe AI's own certainty guess, which only decides what gets reviewed first.
every document, patient and clinician here is synthetic
CLINICAL CORRELATION
She reports marked limitation of physical activity, comfortable at rest, with breathlessness on climbing a single flight of stairs; symptoms consistent with NYHA class III heart failure. She was hospitalized for decompensated heart failure in November 2025.
chapter 04 · what exists
ten synthetic charts arriving. seven fail a rule, three need a human, none get in. the funnel below counts the same ten.
04what exists
Not a slide deck. It is a public code repository that runs on a laptop: no account, no cloud, nothing leaves the machine.
automated tests, all passing, re-run on every change (green CIchecks that run on every change)
trial rule packs. One was built from the published entry criteria of COMMANDER HF, a real heart-failure trial (registry id NCT01877915): 12 criteria, 8 of them turned into runnable rules, the other 4 left as plain text because the language cannot say what they mean.
invented patients: 100 generated and 10 hand-written edge cases. Every person in this project is synthetic.
a working screening report (who fails, on which rule, and which single rule change would admit the most people) and an interactive workbenchthe visual app with five screens, including the live funnel below
0%
Of 12,060 entry criteria pulled from 996 real trials, 56.7% look like the rule language could express them as written, 12.2% partially, and 31.1% not at all. That is a heuristic estimate: pattern matching over the text, never checked against human judges. It reads two ways at once. The language handles more than half of what real trials ask, and a third of it is beyond what the language can say. Both numbers are the result.
05the build
This is a prototype built in the open. The next part of it needs people who run trials.
Emmanuel Cuyugan built this against public registry text and invented patients. No coordinator, no screener and no data manager has yet held it up against a real screening day. That is the part he wants to do next, alongside the people who do that work. What follows is how the thing was made, so you can judge whether it was made with any care.
The rule format was written down before the engine existed, so the code had something fixed to be wrong against. Reviewers were then told to attack it, and a claimed flaw only counted if it came with code that proved it. Every proven flaw became a permanent regression testkeeps fixed bugs fixed before anyone was allowed to fix it. Three of the scars:
Where it wants to go next is more trial packs, written with the people who screen for those trials, and an honest written record of every criterion the language cannot hold. The third of criteria it cannot express is the interesting part, not the part to hide. So: if you run trials, or you sit close to the people who do, he would like to hear what this gets wrong.
chapter 06 · close
pull back and the parts are small, and you have met every one of them: a compiled chip, a patient, the collision band, a stamp. a page, a file, one check, one answer, printed twice.
06close
The narrow claim: there is no open implementation of this whole shape in one place. AI suggestions that carry their quotes. Human approval as the only way in. A deterministicsame input, same answer, always engine as the only thing that decides. And the rule format written down separately, so somebody else can go build a second engine. from the project README, stated with its own caveats attached
Where to look next: README.md in the repository for the runnable version of all this, FORMAT.md for the rule language itself, and the technical thesis (also docs/thesis.html in the repository), which is this same story told longer, for engineers, with the engine's real output in it.
The repository itself is at github.com/emmcygn/rulekit. There will also be the engineering readlink to follow, a shorter account of the build decisions and the things that had to be reversed.
The real engine, running on ten synthetic patients in your browser. No sign-up.
Every verdict this page handed down is one of these three marks. There is no fourth.
agents propose·humans confirm·the engine decides
In that order, every time, with no way around the middle step.
medirulekit · the home of rulekit · Apache-2.0 · set in Public Sans, Spline Sans Mono & Martian Mono
R&D efficiency decline: Scannell et al., Nat. Rev. Drug Discovery 2012 · amendment costs: Tufts CSDD · criteria coverage: Chia corpus (CC-BY-4.0, Kury et al. 2020) · trial criteria quoted from ClinicalTrials.gov