assemblyline.sh

Code first, the model for judgment

If a rule can decide something, code decides it. A model gets only the work rules can't do, and code checks its answer before anything acts on it.

code: fetch and check   →   model: judge what's left   →   code: check the answer   →   act

Where the model earns its place

Give the modelKeep in code
Reading input whose layout keeps changing: an invoice from any vendor, an email from any senderComparing two values: does the invoice total equal subtotal plus tax?
Interpreting failed checks: which findings share a cause, what the cause probably is, what to doArithmetic: do the lines add up to the subtotal?
A decision no rule settles: is this request in scope?Validating a format: is this a real date, a well-formed tax number?
Choosing which checks to run

Why code first

  • Reproducible. The same input gives the same result, and a reviewer can read the rule.
  • Explainable. "The lines add up to 1,180 and the total says 1,000" is evidence. "The model thought it looked wrong" isn't.
  • Cheap and fast. A model call costs money and seconds. Spend them only where rules run out.
  • Less to judge. Whatever code settles never reaches the model. At acme, IN1 checks every invoice in code, and only the invoices with failed checks go to the model.

Run the cheap test first, as the first thing the station does. An invoice that already matches its purchase order needs no judgment. A request that already has an open ticket needs no second review. An email whose subject has none of the words the line looks for never reaches the model.

Give the model the facts, not the flags

The model gets every check's result together with the evidence behind it: the amounts, the dates, the differences. "Failed" alone doesn't let it see that a difference of 180 on the total matches the tax on line 3.

The checks are fixed in code. The model interprets their results; it never chooses them.

AskDon't ask
"The lines add up to 1,180 but the total says 1,000. What explains it?""Do the lines add up?"
"Given these 11 check results, what is the verdict?""What should we check on this invoice?"

Ask for a fixed shape

The model answers in a schema: a verdict, a judgment on each check, the actions to take, and a summary. An answer that doesn't fit the schema is a failure. Don't try to rescue it by parsing loosely.

Check the answer with code

A model's answer can fit the schema and still be wrong. Code checks it before anything acts on it:

  • an extracted date is a real date, an amount is a positive number, a period starts before it ends;
  • page ranges lie inside the document and don't overlap;
  • a finding that cites a file and a line points to a real file, and the quoted text is on that line.

An answer that fails these checks sends the workpiece to failed/, with the problems listed. A wrong amount that reaches the books costs more than a workpiece sitting where everyone can see it. See Nothing leaves silently.

A judgment never changes a fact

A failed check stays failed. The judgment goes beside it:

CheckResultJudgment
Lines add up to the totalfaildismissed, low: the lines are printed including tax
Vendor tax number is validfailaction needed, high: the check digit is wrong

The report shows both columns. Anyone who disagrees with the judgment can still see the fact it was about. A person who judges follows the same contract: facts in, interpretation out, facts unchanged.

A model's proposal to change something a person owns, such as renaming their file, goes to that person before anything changes. Give that wait its own station: see Nothing leaves silently.

Record who judged

Every result records what produced it: which rules ran, with a version for each, and which model gave the judgment. Then a verdict can be explained months later, and work judged by an old rule can be found and checked again.

Where judgment sits in a station

The model works after every check and before any action: Design the checks gives the full order. The judgment can be a function inside the station's body, or a station of its own when it needs its own retries or a slower pace than the checks.