ReadonlyspendThe window the spend limits measure over — engines read their ledgers back this far.
Resolves once every wake sent has finished. For tests and orderly shutdown.
Spend in the window across every registered repository: closed cost and open or reserved estimates.
OptionalrequesterLabel: stringOptionalsuperseded: ReadonlySet<string>Slots occupied: live reservations plus startup holds still standing.
Make a repository known: it enters the spend sum and the round-robin, and
must seed before anything is granted. displayName is how the refusal
words name it (#502); the key is used when there is none.
Whether the repository is registered now (not unregistered, not unknown).
The repository's ledgers, read by gather. Replaces its previous report.
The governor calls gather itself so that it knows which settlements the
report can have seen: those released before gather began. A report
that arrives after a newer one has been applied is ignored.
One repository's spend in the window. Closed entries opened inside the window at their real cost (an undated one counts — the ceiling bounds unattended spend, and a fact it cannot date is not a reason to spend more), plus dispatches that settled since the report began gathering, at the cost they were released with. Then entries still open at their estimate, and the governor's own reservations and startup holds at theirs. Every dispatch is counted once, however the report, the reservation and the settlement overlap:
at) counts only as that closed entry;A settlement leaves the window like a closed entry, by when it settled,
whether or not its repository reports again. superseded names holds a
request is about to take over, so their estimate is not counted beside
the request's own.
Optionalsuperseded: ReadonlySet<string>Check the cap, the machine's spend window and the repository's ceiling, and grant or refuse. Synchronous on purpose: there is no await between the check and the grant, so two engines asking for the last slot in the same instant cannot both be told yes.
The repository's open entries at startup. Marks it seeded; additive.
What the governor holds right now, for the heartbeat and for tests. The
counts are read from the same maps reserve reads, never recomputed.
Settled dispatches counted by the governor until a report replaces them.
Be woken when a slot this repository was refused may be free. Returns the unsubscribe.
The repositories the machine's spend window is not counting (#502): each was unregistered after its startup seed failed or timed out, before it ever reported, so what it spent in the window is unknown to the governor until it seeds. Empty unless a machine spend limit is enforced, since only then is anything decided on that sum.
Forget a repository whose engine has stopped (#502).
Slots and the seed gate are freed. Its live reservations are released
(a later release() of one does nothing), its startup holds and any slot
offered to it are dropped, it leaves the round-robin — the turn passes to
the repository after it — and the governor no longer waits for it to
seed. Every repository refused meanwhile is woken.
Money is not. What it spent inside the window was real, and dropping it would let the others spend the machine's window twice over. So its closed entries and settlements in the window stay in the machine's sum at what they cost, and leave it as the window rolls past them, exactly as they would have. Entries still open, holds and live reservations stay in the sum at their estimate, dated now: a detached role may still be running, and its cost is not known. An undated closed entry is dated now too, so it leaves the window one window from now rather than never.
None of it counts toward the repository's own ceiling, which is gone with it. If the repository registers again, its first report replaces what it left behind, since that report reads the same ledgers.
The registered repositories that have not yet seeded — the ones the seed gate is waiting on.
The seam (#34): what an engine needs from whatever admits its dispatches.
Governoris the in-process implementation.