Skip to content

L-201 · TE 201

Designing an engine

You will be able to lay out an engine for one decision: inputs, tables, rules, tests, and the first review queue.

For experts and the people who will work with them: estimators, engineers, dispatchers, and their managers. About 90 minutes.

LESSON 01 · 12 MIN

Choosing the inputs

An input is anything the expert looks at before answering. Write them all down, then sort them: the ones that change the answer and the ones that only change the explanation. Casing size changes the sacks. The operator's name changes nothing, until the day it does, and then it becomes a rule condition.

Inputs should be the units the trade uses. A cementer thinks in feet, inches, pounds per foot, and sacks. If the engine asks for meters it is wrong before it starts. Unit conversions live inside the engine and are tested.

Every input has a range the expert would believe. Below or above it, the engine should refuse, not guess. A plug 50 ft long is a plug; a plug 5,000 ft long is a typo.

  • List everything the expert looks at; sort by whether it changes the answer.
  • Use the trade's units. Convert inside, with tests.
  • Every input has a believable range; refuse outside it.

HANDS-ON · LONGLEAF PLUG DESIGNER

Enter a plug interval of 20,000 to 30,000 ft. The engine refuses with a reason. That refusal is a rule too.

Open the demo

LESSON 02 · 15 MIN

Encoding the tables

The tables are the engine's core and they are usually in a spreadsheet. The job is to move each one into code without changing it, then write one test per row that proves the code gives the spreadsheet's number.

Capacity tables are the classic case. Pipe capacity in bbl/ft is ID² ÷ 1029.4; annular capacity is (D² − d²) ÷ 1029.4; a barrel is 42 gallons and 5.615 ft³. A balanced plug is the slurry volume for the interval plus excess, the displacement that puts the top of cement where you want it, and the spacer ahead and behind. Each of those is a short function with a known answer.

Encode the regulator's rules the same way. Texas Statewide Rule 14, Louisiana 29-B, and the Mississippi board each say how long a plug must be and where. Those are tests, not prose: given a state and a casing shoe depth, the engine should fail a plug that is too short.

  • Move tables to code unchanged; one test per row.
  • Capacity arithmetic is three formulas and two constants.
  • Regulatory minimums are tests the engine must pass.

LAB · CAPACITY AND THE BALANCED PLUG

Pick a casing and a plug interval. The lab shows the capacity, slurry volume, sacks, and displacement, with the formula for each. Change the excess and see which numbers move.

Casing capacity4.892² ÷ 1029.40.02325 bbl/ft
Annular capacity(4.892² − 2.875²) ÷ 1029.40.01522 bbl/ft
Workstring capacity2.441² ÷ 1029.40.00579 bbl/ft
Slurry100 ft × 0.02325 × 1.22.79 bbl = 15.7 ft³
Sacks15.7 ÷ 1.18 ft³/sk, rounded up14 sk
Mix water14 × 5.2 gal/sk ÷ 421.7 bbl
Balanced height2.79 ÷ (0.01522 + 0.00579)133 ft

LESSON 03 · 15 MIN

Rules: corrections with conditions

A rule has three parts: when (the conditions), then (what changes), and why (the expert's note). 'When depth is below 9,000 ft and class is H, add 0.3 gal/sk retarder. Why: thickening time at BHCT.' The why is for the next expert, and for the day the rule is wrong.

Rules are ordered and the expert's rules win. If a table says one thing and a rule says another, the rule applies and the proposal shows both. That is how the engine stays honest about what it changed.

Conditions should be as narrow as the expert actually means. If they correct one job, the first rule is for that job's conditions. If they correct three similar jobs, the rule widens. The engine can suggest the wider rule; the expert confirms it.

  • When, then, why. Always the why.
  • Rules beat tables, and the proposal shows the override.
  • Start narrow; widen on evidence.

LAB · WRITE A RULE

Build a rule from a correction. Choose the conditions, the change, and write the why. The lab shows which of the sample jobs the rule would touch.

WHEN (always) → THEN retarder = true · WHY …

Touches 12 of 12 sample jobs: J-001, J-002, J-003, J-004, J-005, J-006, J-007, J-008, J-009, J-010, J-011, J-012.

LESSON 04 · 12 MIN

Tests and the first review queue

Before the expert reviews anything, the engine passes two kinds of tests: table tests (each row reproduces the spreadsheet) and job tests (each of the ten to twenty past jobs reproduces the expert's answer, or the difference is explained).

Then the queue opens. The first week's proposals are mostly corrections; that is the point. By the third week the expert is accepting more than they change. Each session is fifteen to thirty minutes, and the dashboard shows the agreement rate climbing by job type.

Keep a held-out set: a few past jobs the engine never sees. Agreement on those is the honest number. Agreement on jobs the rules were written from is not.

  • Table tests and job tests before any review.
  • First week mostly corrections; by week three mostly accepts.
  • Measure agreement on jobs the rules never saw.

HANDS-ON · LOOP LAB

Work ten proposals in the Loop Lab. Note the agreement on the held-out set before and after your rules.

Open the demo

LESSON 05 · 12 MIN

From proposal to ticket

A proposal the customer can see needs a price. The ticket is line items: material by the unit, service by the hour or the job, equipment rentals, mileage, standby. Rates are a table like any other, with an effective date.

The expert's pricing judgment is also tacit: the minimum charge, the customer who always gets standby waived, the job that needs a second truck. Those are rules on the ticket, captured the same way.

A customer-facing first pass shows the ticket with ranges, not exact figures, and only for job types whose agreement rate is above the threshold the owner set. Everything else routes to a human.

  • Rates are a table with an effective date.
  • Pricing judgment becomes rules on the ticket.
  • Customer first pass: ranges, gated by agreement rate.

HANDS-ON · LONGLEAF PLUG DESIGNER

Open the ticket on any design. Change the mileage and the standby hours; the total recalculates and the line items show their rates.

Open the demo

CHECK YOUR UNDERSTANDING

Quiz

  1. 1. Pipe capacity in barrels per foot is

  2. 2. A rule's three parts are

  3. 3. The honest agreement number comes from

  4. 4. When should a customer see a price from the engine?