fix: ignore verified obsolete BPM display fields

This commit is contained in:
abaishu0730 committed 2026-10-26 11:22:53 +08:00
1 parent 5bae83922c
commit f2e6dfeac3
9 files changed
+105 -14

No files matched your search

+16 -5
View File
@@ -74,11 +74,21 @@ class OrderExecutionCoordinator{
}
}
resetCaptureRetry(task){delete task.retryPolicy;delete task.retryCount;delete task.nextRetryAt;delete task.errorCode;delete task.captureDiagnostics;delete task.captureEvidenceError;}
markUnavailableCaptures(rows,connection){
verifiedCurrentDiscovery(connection,{rows,runId,startedAt,finishedAt}){
const start=Date.parse(startedAt),finish=Date.parse(finishedAt),now=+this.clock();
if(!runId||!Array.isArray(rows)||!Number.isFinite(start)||!Number.isFinite(finish)||start>finish||finish>now||now-start>300000)return null;
const saved=this.store.get('execution-discovery-runs',hash([connection.id,runId]));
const latest=this.store.get('execution-discoveries',connection.id);
if(!saved||!latest||latest.runId!==runId||latest.startedAt!==startedAt||latest.finishedAt!==finishedAt)return null;
if(saved.connectionId!==connection.id||saved.runId!==runId||saved.startedAt!==startedAt||saved.finishedAt!==finishedAt||hash(saved.rows)!==hash(rows))return null;
return startedAt;
}
markUnavailableCaptures(rows,connection,{notAfter}={}){
const absent=[];
this.store.transaction(()=>{
for(const task of this.store.all('execution-tasks')){
if(task.connectionId!==connection.id||task.step!=='capture'||!['failed','blocked'].includes(task.status)||task.sampleId||task.conflict||task.missedWindow||task.supersededBy||task.revisionIgnored)continue;
if(notAfter&&(!Number.isFinite(Date.parse(task.updatedAt))||Date.parse(task.updatedAt)>Date.parse(notAfter)))continue;
const order=task.orderId&&this.store.get('orders',task.orderId);
if(order&&(order.archive||reserved(order)||['batched','sending','sent','unknown','ignored'].includes(order.status)))continue;
if(rows.some(row=>row.source==='todo'&&taskIdentity.sameTask(task,row)))continue;
@@ -194,7 +204,7 @@ class OrderExecutionCoordinator{
window:task.missedWindow,error:task.error,orderIds:task.orderId?[task.orderId]:[],
});
}
scan(input,principal,{rows:trustedRows,runId,startedAt}={}){
scan(input,principal,{rows:trustedRows,runId,startedAt,finishedAt}={}){
// Reserve the shared boundary synchronously, including work queued behind a retry.
this.store.activeDiscoveries++;
return this.serialize(async()=>{
@@ -296,9 +306,10 @@ class OrderExecutionCoordinator{
await this.checkArchivedRuntime(task,order,connection,principal);
}
if(input.automatic&&!this.store.settings().processingEnabled)throw Error('自动处理已暂停,待处理对账保留到恢复后继续。');
// Durable discovery hints can replay an older complete list. Only a fresh,
// fully successful provider scan can establish that a retained task left.
if(trustedRows===undefined)for(const task of this.markUnavailableCaptures(rows,connection))await this.exception(task,connection,false);
// Durable hints can replay old lists. Absence requires a fresh direct scan
// or exact persisted latest proof, and cannot invalidate newer task work.
const proof=trustedRows===undefined?null:this.verifiedCurrentDiscovery(connection,{rows,runId,startedAt,finishedAt});
if(trustedRows===undefined||proof)for(const task of this.markUnavailableCaptures(rows,connection,{notAfter:proof}))await this.exception(task,connection,false);
this.query={...this.query,status:'complete',finishedAt:this.now(),rowCount:rows.length,targetCount:considered};this.store.put('execution-requests',{id:key,at:this.now()});
}catch(error){this.query={...this.query,status:'failed',error:error.message,finishedAt:this.now()};throw error;}
finally{