evaluate method
Implementation
@override
DVGateOutcome evaluate(DVReleaseGateContext context) {
final int? locked = lock.current?.protocol;
if (locked != context.candidate.protocolVersion) {
return DVGateOutcome.hold(
name,
'the protocol lock is at ${locked ?? 'no version'} and release '
'${context.candidate.id} records protocol '
'${context.candidate.protocolVersion}; the window cannot be read for it',
overridable: false,
);
}
final DVReleaseRecord? previous = context.previous;
final DVContractDecision decision = DVContractDecision.evaluate(
windowed: window.served(lock, now: context.now),
readsOldShape: (int protocol) => _readBy(protocol).isNotEmpty,
replacing: previous == null
? null
: (release: previous.id, builtFor: previous.schema[migration]),
);
final List<int> served = decision.windowed!;
if (decision.readers.isNotEmpty) {
const String code = 'DV-RELEASE-005';
final List<String> readers = <String>[
for (final int protocol in decision.readers)
'protocol $protocol reads ${_readBy(protocol).join(', ')}',
];
final String message =
'contract of $migration refused: ${readers.join('; ')}, inside the '
'window $served';
_diagnose(code, message);
return DVGateOutcome.hold(
name,
message,
code: code,
overridable: false,
evidence: <String, Object?>{'served': served, 'readers': readers},
);
}
if (decision.replacingReadsOldShape) {
final DVContractReplacing replacing = decision.replacing!;
return DVGateOutcome.hold(
name,
'contract of $migration refused: ${replacing.release}, the release '
'being replaced, was built for '
'${replacing.builtFor?.name ?? 'the shape before it'} and still reads '
'what the contract drops',
overridable: false,
);
}
return DVGateOutcome.pass(
name,
evidence: <String, Object?>{'served': served},
);
}