A pricing engine for oil & gas well schedules. It splits insurance premium across four coverages, flags every row it cannot price, and checks itself against an 83-well reference file it has to reproduce exactly.
A well schedule is a list of wells and the facts recorded about each one, and the premium for that schedule has to be split across four insurance coverages. Control of Well pays to regain control of a well that blows out. General Liability covers injury and property damage claims arising from the operation, and above it sit two layers that pay only once the coverage beneath them is used up, a $5MM Umbrella and then a $5MM Excess. Each is priced on its own basis and reads the schedule for something different.
That split used to come out of a spreadsheet whose numbers could not be fully audited. The output showed what each coverage was allocated but not what the allocation came from, so checking a figure meant rebuilding the derivation by hand, and part of it depended on inputs that never appeared.
Depth on a well schedule is two numbers rather than one, and they do different jobs. Total vertical depth is how deep the well reaches straight down, and it picks the rate band, the depth bracket that sets the rate charged against the well. Total measured depth is the length of hole actually drilled, longer than the vertical depth on any well not drilled straight down, and it drives net footage. Substitute one for the other and you break a different thing each way: the vertical number moves the band a well is rated in, the measured number the footage it is rated on. Vertical depth also picks a General Liability depth band, but that one only chooses which flat amount applies once eligibility has been settled elsewhere.
Two other columns are both called interest and do entirely different jobs, and that is where the old process came apart.
Interest to be insured is the share of the well the policy actually covers, and it is the other half of net footage. Net footage is total measured depth multiplied by that share, and Control of Well premium is net footage multiplied by the rate, so a half share of a 20,000-foot hole prices as 10,000 feet.
Working interest from the operator scales nothing; it works as a switch. A well qualifies for General Liability if the insured operates it, meaning the insured runs the well rather than just holding a stake in one somebody else runs. A non-operated well qualifies only if that stake is real working interest, an ownership share that carries a share of the costs, rather than a nominal or empty entry. A well failing both tests gets no General Liability, and therefore no Umbrella and no Excess either, since both of those are allocated off it. One column moves three of the four coverages.
That second test never appeared in the legacy output. For an operated well you could see the reason, because the value deciding it printed, but for a non-operated well the deciding value sat in the one column nobody printed. The old output was auditable for one kind of well and opaque for the other, with nothing marking which was which, and finding that column was the work.
The legacy template provisioned roughly 1,185 rows, a fact about the template rather than about well schedules, and row count changes how the interface behaves, never the arithmetic.
A schedule is dropped in and used exactly as it arrives, with no reformatting step and no pre-cleaning pass, and rates are entered fresh each run.
The code sits in four parts, ingest, engine, export, and the Streamlit application, across 24 Python modules, with the tests in a separate tree of another 24. The engine prices every row it can and flags the rest rather than stopping, and it ships as a Docker image.
There is an 83-well reference file, a real schedule whose correct answers are already known, and re-running it has to reproduce them exactly, not close and not within tolerance, but the same figures.
The golden tests compare fresh output against those known answers, and they are the specification. When one goes red the cheapest move is to open it, see what the code now produces, and write that in as the expected value. Under this rule that move is off the table, because the expected value is not an expectation about the code but the definition of the right answer, and a change that disagrees with it is wrong until someone proves otherwise.
Test coverage can tell you the General Liability eligibility branch executed, but not that it decided correctly, that a well which should have been excluded was. The reference file settles that by construction: the total for those 83 wells either matches or it does not, and the well-level figures name which wells moved. That file is also what makes the engine safe to change, since four coverages share inputs and changing how depth or interest is handled for one can quietly move a number under another.
The uploaded schedule is read and left alone, with corrections kept in the platform's own working copy, so the original stays exactly as it arrived and can still be checked against. A file corrected in place cannot be the reference for its own corrections.
A row the engine cannot price stays in the schedule, flagged and un-priced but still editable alongside the rows that priced normally. Validating at import and refusing the file is simpler to write, but it ends the session and hands back a rejection instead of a schedule, including every row that was fine. Flagging keeps the good rows priced and the bad ones in front of whoever can correct them.
Corrections are written to a file the user keeps, so closing the session does not lose them. Session state is the obvious shortcut and works until the tab closes, at which point everything has to be entered again.
The test suite was green, and deployment produced six defects anyway, every one of them in the gap between the code and the container it runs in.
The clearest was the health endpoint, the check that reports whether the application is alive, and it answered. From outside the container looked correct, the check returned and the deployment reported healthy, while the application inside could not actually run, because the check only ever reported that the endpoint was up, never that the application behind it had started.
The 24 test modules had no opinion about whether the container could start the application, and none of them were built to, so the defects surfaced at deployment, the first moment the two halves were tested against each other.
The engine went live in August 2026 and is still in beta, with one defect open: a saved configuration will currently accept a negative band rate without flagging it, so a number that cannot be a rate can be carried into a run.
There is no outcome data, so take the rest as intent.
The old allocation could not be re-derived by the person holding it and this one can be, because every input is visible, including the working-interest column that used to decide eligibility off-screen. Ask why one well carries General Liability and another does not, and the answer is a specific column holding a specific value, on screen.
The 83-well reference file is the other half: its correct numbers travel with it, so whoever receives an allocation can re-run it and compare figure by figure, same wells, same rates, same output.
← All projects