test: integrate reliable event recovery and receiving evidence

This commit is contained in:
2026-10-02 20:14:17 +08:00
parent d0df738bba
commit 4b531c7e22
17 changed files with 1527 additions and 37 deletions
@@ -1,3 +1,5 @@
import { validDirectDeliveryReplayProof } from './direct-delivery-replay-proof.mjs'
const MODULE = 'phase4-cross-region-events'
const OPTIONS = { scenario: 'phase4-cross-region-events', deploymentBlocker: true }
@@ -139,7 +141,18 @@ export async function run(context) {
success(writtenBackAgain) && frozen.every((field) => (replaySnapshot[field] ?? null) === (snapshot[field] ?? null))
&& traced(writtenBackAgain),
evidence(writtenBackAgain, `containerId=${id(domesticMatches[0].id)}, sourceVersion=${snapshot.emptyReportSourceVersion ?? 'missing'}`), OPTIONS)
blockingGap(context, '真实投递重试与同事件幂等证据',
const reader = context.context?.directDeliveryReplayEvidenceReader
if (typeof reader !== 'function') blockingGap(context, '真实投递重试与同事件幂等证据',
'两次GET仅证明读取稳定;需按event-outbox-operations.mjs的受保护内部运维流程,在本轮事件上验证故障后有限重试/DEAD及同eventId+payloadHash重复消费,保存逐次尝试与业务计数证据。不得重放SENT、改表或伪造新事件。',
'missing-direct-delivery-replay-evidence')
const scope = { marker: context.marker, loadingPlanId: id(phase3.loadingPlanId),
customerId: id(phase3.tenantId), containerBookingId: id(phase3.containerBookingId) }
const proof = await reader(scope)
context.createdResources.directDeliveryReplayProof = proof
const valid = validDirectDeliveryReplayProof(proof, scope)
context.assert(MODULE, '本轮原事件12次失败DEAD人工恢复DUPLICATE且业务零新增', null, valid,
`loadingPlanId=${scope.loadingPlanId}, attempts=${proof?.attempts?.length || 0}, restored=${proof?.restored === true}`, OPTIONS)
if (!valid) blockingGap(context, '真实投递重试证据不完整或身份漂移',
'本轮事件身份/摘要、12次有限重试、DEAD、人工恢复审计、重复消费及业务计数和恢复直连必须同时核平',
'invalid-direct-delivery-replay-evidence')
}