/** * A case's rows and this engine's frames, and the destination between them. * * Both directions are here because they are one correspondence: a case names an * order by an ordinal and an engine knows it by an id, so `Delivery` reads an * ordinal into the id of the intent the run placed, and `framedAs` writes an id * back out as the ordinal a case file prints. Split between two files, the two * halves of it drift, and a suite whose rows say one thing and whose records * say another is one nobody can read. * * `conformance.md` section 3: `frames.csv` supplies order frames the way * `bars.csv` supplies bars, so a strategy case asserts the fold against input * the engine did not choose. `simulate.ts` is the other destination this module * has, the one that reads a bar and works out what a venue would have said. * This one works nothing out. It holds the rows a case supplied, hands over the * ones each boundary names, and the whole of its behaviour is the mapping * between a row and a frame. * * **An ordinal is what a case can name, and an id is not.** A row names the nth * intent the run placed, because no case can know the id an engine minted, so * the intents are counted here in the order the run handed them over and the * ordinal is read against that count. A row naming an ordinal the run never * placed is delivered all the same, carrying an id no run mints: step 1 of * `stdlib.md` 17.8 refuses a frame naming no row of the ledger, and that * refusal is the ledger's to make. A destination that dropped the row instead * would answer nothing at all where section 3 hands an engine a frame about an * order its ledger does not hold, and the case would pass by the frame never * having arrived. * * **What a row does not carry, this does not invent.** `host-interface.md` 7.2 * lets a frame say which instrument and product the destination booked the * order under, and the file has no column for either, so neither is stated and * the row keeps what its placement put there. The instant is the one the file * does carry: a row states one or states `none`, and one that states none * leaves `updatedAt` where the placement put it, which is what the fold does * with a frame whose destination stated no instant. */ import type { OrderFrame, OrderIntent, RoutedEffect } from '../engine/index.js'; import type { RecordedFrame } from './record.js'; /** One frame, the boundary it was handed over at, and the row it came from. */ export interface Delivered { readonly frame: OrderFrame; readonly afterBar: number; /** * The row a case supplied, or null where the run's own destination answered * the frame and there is no row until the record is written. */ readonly row: RecordedFrame | null; } /** Where a run's orders go, and what it is told between two of its bars. */ export interface Destination { /** Step 9: what the strategy decided, on the bar it decided it. */ route(effect: RoutedEffect, barIndex: number): void; /** What this destination hands over at the boundary after `barIndex`. */ answers(barIndex: number): readonly Delivered[]; /** Every intent it was handed, in the order it was handed them. */ readonly intents: readonly OrderIntent[]; } /** * A destination holding one case's frames, ready at the boundaries they name. * * Built before the run rather than during it, because the rows are input: what * a boundary hands over was decided by whoever wrote the case and not by * anything this run does. The one thing it learns as the run goes is which * intent an ordinal names, which only the run can say. */ export declare class Delivery implements Destination { readonly intents: OrderIntent[]; /** The rows of each boundary, in file order, which section 3 fixes as the delivery order. */ private readonly rows; constructor(frames: readonly RecordedFrame[]); /** Nothing is decided by an order arriving here: it is counted, and that is all. */ route(effect: RoutedEffect): void; answers(barIndex: number): readonly Delivered[]; } /** * The ordinal of every intent, which is how a case names one. * * One, two, three in the order the run placed them, because no engine can know * the id another minted and a case that named one would only ever be readable * by the engine that wrote it. */ export declare function ordinalsOf(intents: readonly OrderIntent[]): ReadonlyMap; /** * One delivered frame, in the columns a case file prints. * * The instant travels with it. `stdlib.md` 17.7 folds `updatedAt` from a * frame's `time`, so a driver that dropped the field here wrote a record whose * ledger no engine could fold from the record's own frames: it would have * nothing to move that field to and would leave it at `placedAt`. */ export declare function framedAs(frame: OrderFrame, afterBar: number, ordinals: ReadonlyMap): RecordedFrame; //# sourceMappingURL=deliver.d.ts.map