refactor(orchestrator): share pure strategy bookkeeping (CL19)
This commit is contained in:
parent
984dc1a9cc
commit
6055aeeee9
17 changed files with 297 additions and 157 deletions
|
|
@ -94,6 +94,20 @@ export const matchingCommandSchema = z
|
|||
.strict();
|
||||
export type CanonicalMatchingCommand = z.input<typeof matchingCommandSchema>;
|
||||
|
||||
/** Event ordering must agree with Rust, including UTF-8 instrument identity ties. */
|
||||
export function compareEventKeys(
|
||||
a: CanonicalMatchingCommand['key'],
|
||||
b: CanonicalMatchingCommand['key']
|
||||
): number {
|
||||
const phases = { Observation: 0, Decision: 1, Execution: 2, SessionClose: 3 };
|
||||
return (
|
||||
a.at - b.at ||
|
||||
phases[a.phase] - phases[b.phase] ||
|
||||
Buffer.compare(Buffer.from(a.instrumentId), Buffer.from(b.instrumentId)) ||
|
||||
a.sourceSequence - b.sourceSequence
|
||||
);
|
||||
}
|
||||
|
||||
/** Metadata and shapes only. Rust restores and validates all nested receipts,
|
||||
* reservations, accounting and indexes before any transition. */
|
||||
export const canonicalExecutionCheckpointSchema = z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue