The routing logic as numbered steps. Each step has one clear condition made of AND / OR.
Checked in order. The first step whose condition is true decides the order. If it is false, go to the next step.
| Step | Route to | Condition (every line must be true) | Flag / note |
|---|---|---|---|
| 1 | DC |
DC frame stock ≥ 1
AND DC open jobs < daily cap
|
A lens never blocks DC. LENS_OOS_SUBSTITUTE if DC lens stock = 0. |
| 2 | Client's HUB |
Client has a HUB
AND HUB frame stock ≥ 1
AND HUB lens stock ≥ 1
AND HUB open jobs < daily cap
|
No flag. |
| 3 | TOG |
The lens is in the TOG list
AND TOG frame stock ≥ 1
AND TOG open jobs < daily cap
|
TOG makes its lenses on demand. No flag. |
| 4 | Client's HUB (the client sends their own frame) |
Client has a HUB
AND DC frame stock = 0
AND HUB frame stock = 0
AND TOG frame stock = 0
AND HUB open jobs < daily cap
AND (
HUB lens stock ≥ 1
OR DC lens stock ≥ 1
)
|
The lens ships from DC if the HUB has none. FRAME_OOS_CLIENT_FRAME_HUB. |
| 5 | DC (the client sends their own frame) |
DC frame stock = 0
AND TOG frame stock = 0
AND (
Client has no HUB
OR HUB frame stock = 0
)
|
FRAME_OOS_CLIENT_FRAME, plus LENS_OOS_SUBSTITUTE if DC lens stock = 0. |
| 6 | First usable portal: DC, then HUB, then TOG |
Take the first portal, in the order DC, then HUB, then TOG, for which all of these are true:
It can be used: it is DC, or it is the HUB and the client has a HUB, or it is TOG and the lens is in the TOG list
AND Its open jobs < daily cap
AND It can get the frame: its own frame stock ≥ 1 OR the other of DC / HUB has frame stock ≥ 1 (TOG never ships anything)
AND It can get the lens: its own lens stock ≥ 1 OR the other of DC / HUB has lens stock ≥ 1 OR it is DC (DC substitutes). Nothing is taken from TOG.
|
The missing frame or lens ships in. LENS_OOS_SUBSTITUTE only if DC glazes with no lens stock anywhere. |
| 7 | DC (overflow) |
None of the steps above applied
|
CAP_OVERFLOW, plus LENS_OOS_SUBSTITUTE if DC lens stock = 0. The order waits and is re-run next morning. |