fix(firstleg): finalize loading before customs acceptance

This commit is contained in:
2026-08-24 12:52:23 +08:00
parent 4377a7acd9
commit 92dbeb1676
7 changed files with 41 additions and 10 deletions
@@ -90,6 +90,7 @@ test('downstream finalizer uses the frozen truck-coupled complete contract', ()
'结算递增 inboundVersion 后 final complete 必须使用最新版本',
'入库单终态 LOADED、版本递增且审计历史存在',
])
assert.match(finalize, /const taskDetailPath = `\$\{taskPath\}\?warehouseId=/)
assert.doesNotMatch(finalize, /BLOCKED_CONTRACT/)
assert.doesNotMatch(finalize, /truck\?\.finalStatus === 'COMPLETED'/)
assert.doesNotMatch(finalize, /\/loading\/complete\?tenantId=/)
@@ -70,7 +70,8 @@ export async function run(context) {
const base = `/api/platform/v1/inbounds/${inboundId}`
const taskPath = `/api/platform/v1/first-leg/pda-loading/tasks/${encodeURIComponent(taskId)}`
const taskBeforeResponse = await context.request('GET', taskPath)
const taskDetailPath = `${taskPath}?warehouseId=${encodeURIComponent(id(fixture.warehouseId))}`
const taskBeforeResponse = await context.request('GET', taskDetailPath)
const taskBefore = context.apiSuccess(MODULE, '读取最终完成前 PDA 任务即时版本', taskBeforeResponse, '', OPTIONS)
context.assert(MODULE, '最终完成前四元身份稳定且任务等待人工确认', taskBeforeResponse,
id(taskBefore?.id) === taskId && id(taskBefore?.inboundId) === inboundId
@@ -105,7 +106,7 @@ export async function run(context) {
if (completeResponse.http !== 200 || codeOf(completeResponse) !== '200') {
context.addStep(MODULE, '结算递增 inboundVersion 后 final complete 必须使用最新版本', completeResponse, false,
`expected=success after settlement refresh; HTTP=${completeResponse.http}, code=${codeOf(completeResponse)}, message=${completeResponse.body?.message || 'missing'}, taskId=${taskId}, inboundId=${inboundId}, taskVersion=${taskBefore?.version ?? 'missing'}, inboundVersion=${version}, requestId=${completeResponse.requestId || 'missing'}, traceId=${completeResponse.traceId || 'missing'}`, OPTIONS)
const taskAfterFailureResponse = await context.request('GET', taskPath)
const taskAfterFailureResponse = await context.request('GET', taskDetailPath)
const taskAfterFailure = context.apiSuccess(MODULE, 'final complete 失败后回查 PDA 任务', taskAfterFailureResponse, '', OPTIONS)
const planAfterFailureResponse = await context.request('GET', planPath)
const planAfterFailure = context.apiSuccess(MODULE, 'final complete 失败后回查计划', planAfterFailureResponse, '', OPTIONS)
@@ -508,15 +508,15 @@ test('downstream container consumers prefer the phase3Loading fixture', () => {
assert.match(schedules, /if \(containerBookingId && !knownAllocation\)/)
})
test('default acceptance order verifies loading evidence before finalizing LOADED', () => {
test('default acceptance order finalizes LOADED before customs reads fulfillment slices', () => {
const entry = source('../admin-test-env-acceptance.mjs')
assertOrder(entry, [
"'phase3-loading'",
"'phase3-loading-model-bridge'",
"'phase3-pda-convergence'",
"'phase3-evidence-gate'",
"'phase3-customs'",
"'phase3-loading-finalize'",
"'phase3-customs'",
])
})