assemblyline.sh

Act towards a goal state

A station that changes something outside the line, such as posting an invoice to a ledger, filing an email or creating a task, works towards an end state: "this invoice is in the ledger", "this email is in the processed folder". It doesn't replay a fixed list of moves. On each workpiece it:

  1. Reads where the target stands now.
  2. Compares that with the goal.
  3. Does only what is missing, and records what it did, including "nothing: already there".
The ledger hasThe station
Nothing for this invoiceCreates the entry
The same entryLeaves it, and records "already posted"
An older version of the entryReplaces it
An entry whose invoice was withdrawnVoids it

Why

  • A re-run is safe. If the station dies after posting but before moving the workpiece on, the next run finds the entry already there and only finishes the move. Nothing is posted twice.
  • People can work alongside the line. If someone posts an invoice by hand, the station sees it and does nothing.
  • What happened is on record. "Created", "already there" and "replaced" are different outcomes, and the run report counts each.

Read again right before you write

The target can change between the moment the line looked at it and the moment the station acts: a person categorises a bank line by hand, another run gets there first. Just before each write, read the target again. If what you were about to change has moved, skip it and record why.

When the goal can't be reached yet

Sometimes the station can't act yet: the invoice isn't approved, the vendor doesn't exist in the ledger, the payment hasn't cleared. That is a precondition that isn't met yet. It is not a failure: nothing is wrong, and it will clear once something else happens. Never send it to failed/. Choose one of two ways to wait:

Hold the workpieceLet a later run bring it back
Do thisMove it to a waiting station that checks the precondition on a timer and releases itFinish the workpiece, record "not yet" and the reason, and act when the source shows it again
WhenOnly this workpiece will ever carry the work forwardThe line head reads the source again on every run, or another path in the line finishes the job
ExampleAn invoice waits for a manager's approval, then goes on to be postedA bank line waits for its bill to be approved; the next day's run reads the bank feed again and finds it still open

Either way, the station doesn't force a half-met goal, and it doesn't call other stations to meet the precondition for it. It reads what earlier stations and people have done, and acts when the goal can be reached.