feat(paper): gate canonical execution on durable feed readiness
This commit is contained in:
parent
c01e96e4dd
commit
75abae2cfc
24 changed files with 3720 additions and 66 deletions
|
|
@ -35,6 +35,44 @@ function accountState(raw: unknown): CanonicalAccount {
|
|||
) {
|
||||
throw new ExecutionConflictError('Canonical envelope identity or revision mismatch');
|
||||
}
|
||||
if (
|
||||
account.host &&
|
||||
canonicalJson(account.host.configuration.matching) !== canonicalJson(account.checkpoint.config)
|
||||
) {
|
||||
throw new ExecutionConflictError(
|
||||
'Canonical host configuration differs from financial configuration'
|
||||
);
|
||||
}
|
||||
if (account.host) {
|
||||
const { configuration, connection, quotes, quoteHighWater } = account.host;
|
||||
if (
|
||||
configuration.strategies.length !== account.definitions.length ||
|
||||
configuration.strategies.some(
|
||||
selection =>
|
||||
!account.definitions.some(
|
||||
definition =>
|
||||
definition.ownerId === selection.ownerId &&
|
||||
definition.strategyId === selection.strategyId &&
|
||||
definition.strategyVersion === selection.strategyVersion &&
|
||||
definition.seed === selection.seed &&
|
||||
definition.mode === 'target'
|
||||
)
|
||||
) ||
|
||||
(connection && connection.sourceId !== configuration.policy.sourceId) ||
|
||||
[quotes, quoteHighWater].some(
|
||||
clocks =>
|
||||
new Set(clocks.map(quote => quote.instrumentId)).size !== clocks.length ||
|
||||
clocks.some(
|
||||
quote =>
|
||||
!configuration.matching.series.some(
|
||||
series => series.instrumentId === quote.instrumentId
|
||||
)
|
||||
)
|
||||
)
|
||||
) {
|
||||
throw new ExecutionConflictError('Canonical host strategy or feed binding mismatch');
|
||||
}
|
||||
}
|
||||
return account;
|
||||
}
|
||||
|
||||
|
|
@ -59,11 +97,13 @@ export class PostgresCanonicalExecutionRepository implements CanonicalExecutionR
|
|||
identity: account.identity,
|
||||
config: account.checkpoint.config,
|
||||
definitions: account.definitions,
|
||||
hostConfiguration: account.host?.configuration ?? null,
|
||||
}) !==
|
||||
canonicalJson({
|
||||
identity: expected.identity,
|
||||
config: expected.checkpoint.config,
|
||||
definitions: expected.definitions,
|
||||
hostConfiguration: expected.host?.configuration ?? null,
|
||||
})
|
||||
) {
|
||||
throw new ExecutionConflictError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue