fix(firstleg): atomically finalize PDA completion

This commit is contained in:
2026-09-01 11:11:43 +08:00
parent de0eddeee8
commit b5bc77b153
10 changed files with 181 additions and 46 deletions
@@ -11,6 +11,7 @@ const locationTests = read('../../warehouse/src/test/java/com/baiyue/warehouse/s
const settlementService = read('../../warehouse/src/main/java/com/baiyue/warehouse/service/PalletLocationAllocationService.java')
const settlementTests = read('../../warehouse/src/test/java/com/baiyue/warehouse/service/PalletLocationAllocationServiceTest.java')
const finalizeHttp = read('phase3-loading-finalize.mjs')
const loadingPickService = read('../../firstleg/src/main/java/com/baiyue/firstleg/service/LoadingPickService.java')
function releaseDecision({ sharedOverflow, locationStatus, activeOccupanciesAfterRelease }) {
if (sharedOverflow) return 'SHARED_STATUS_UNCHANGED'
@@ -63,10 +64,16 @@ test('same settlement key replays without a second release or transfer', () => {
assert.match(settlementTests, /verify\(locations,\s*never\(\)\)\.transferToChildByReservation/)
})
test('HTTP failure contract proves task plan allocation location history outbox operation zero drift', () => {
for (const fact of ['task', 'plan', 'inbound', 'allocation', 'location', 'history', 'outbox', 'operation']) {
test('acceptance failure is zero-write before worker and final local convergence is transactional', () => {
for (const fact of ['task', 'plan', 'inbound', 'operation']) {
assert.match(finalizeHttp, new RegExp(fact, 'i'), `missing ${fact} failure baseline`)
}
assert.match(finalizeHttp, /A0409/)
assert.match(finalizeHttp, /零写入|零漂移/)
assert.match(loadingPickService, /completionTransaction\.executeWithoutResult/)
const finalizer = loadingPickService.slice(loadingPickService.indexOf('private void finalizeCompletion'),
loadingPickService.indexOf('private void requireColoadConservation'))
for (const fact of ['COMPLETE_LOADING', 'finishFromPda', 'publishCompletedEvent', 'completeAccepted']) {
assert.match(finalizer, new RegExp(fact), `missing transactional ${fact}`)
}
})