assemblyline.sh

Cutting work into lines

Before you design a station, decide how many lines the work needs and where they meet. Cut where the work changes in kind, not where it feels like a new stage, and be able to name the reason for every cut.

The test

Compare the work on both sides of a possible cut:

AskSame lineNew line
Unit: what is one piece of work?Both work on one invoiceOne invoice, then one vendor across all its invoices
Trigger: what starts it?Both run when an invoice arrivesAn invoice arrives, then the month ends
Kind: what does it do?Both read what one invoice saysRead one document, then decide what is true across many
Writes: what state does it own?Both add files to the invoice's workpieceThe facts from each document, then the agreed balance per vendor

The unit is the surest sign. When one piece of work starts to mean several earlier pieces taken together (a vendor, an account, a month), start a new line. Its line head makes those units into workpieces of their own: one per vendor, one per account, one per month.

A split is not a new unit. A file that turns out to hold four invoices stays on the line, as four invoices: see Splitting work.

Reading and reconciling are two lines

The cut most often missed is between reading each document and deciding what is true across documents.

IN  read each invoice      what each invoice says           unit: one invoice
RC  match across invoices  what is true for each vendor     unit: one vendor

A reconciler bolted onto the reading line runs once per new invoice and overwrites what it decided before. A late credit note, or an old invoice scanned again, quietly replaces the current answer. On a line of its own, the reconciler takes all of a vendor's invoices together, and runs again whenever one more arrives.

Interpreting the facts goes where its unit is. Judging one invoice's findings is a station on the invoice line. A picture of the whole month is a line of its own.

What doesn't need a new line

A line costs a line head, conveyors, bins and a schedule of its own. Don't pay that when the work fits a line you have:

New needPut itExample
Another source of the same unitAnother line head on the same line, feeding the same next stationInvoices from a shared folder and from a supplier portal: IN0a and IN0b both feed IN1
Another kind of the same unitA route in a sorting station, with a sub-bin per kindCredit notes go to IN1/output/credit_notes
A condition the work must meet firstA checking station on the lineIN1 holds invoices with no purchase order

A source whose unit is different is a line of its own. An email holding three invoices, whose sender gets one reply, has the email as its unit. The email line drops each attachment where the invoice line takes work in, and replies on its own line.

How lines meet

A line hands work to another line in one of two ways:

  • Through the next line's way in. The email line drops attachments into the folder the invoice line's head watches.
  • Through a system both use. The invoice line posts bills to the ledger; the reconciling line reads the ledger as its queue.

A line may read another line's files to report on them, as the email line does to tell the sender what became of each invoice. It never writes to them. So each line keeps its own head, schedule and failures, and you can stop, fix or rerun one without touching the others.

The same work for another client

When a second client needs the same work, copy the line under a new code: IN-AC for acme, IN-GX for globex.

  • Each copy has its own line file, with its own location and its own config values: folders, accounts, which credentials to use.
  • The station code is shared. Each copy's stations run the same handlers, so a bug fixed once is fixed for both. In Assembly Line, the handler lives in src/shared/ and each station wraps it: see Write a station.
  • Each copy can change on its own. One client gets an extra check, or a different prompt, without the other noticing.

The test: should a change to one line reach the other without anyone deciding it should? Unless the answer is a sure yes, they are two lines. One line made to serve several clients turns every change into a change for all of them.

A second machine doing the same client's work is not a new line. It changes where the line runs, not what it does.

Procedure

  1. List the transforms the work needs, end to end.
  2. Write down for each its unit, trigger, kind and what it writes.
  3. Join neighbours that agree on all four as stations of one line.
  4. Cut where the unit changes to a group of earlier units.
  5. Name the reason for every cut. A cut you can't name is a guess; look at it again.
  6. Fold in extra sources, kinds and conditions, as in the table above.
  7. Write each line's unit, trigger, and what it writes and never writes in its description, so the next person sees why the cut is where it is.

Then decide the stations inside each line: One job per station.