fix(xiaoyi): settle expired adoption checks before reporting a stage
This commit is contained in:
parent
419182862e
commit
d1347f6344
@ -300,9 +300,9 @@ export async function runWholeDetail(host, runAgent, loadKnowledge, {pause=delay
|
||||
journal.items[slot.id]={...journal.items[slot.id],label:slot.label,...fields};
|
||||
await atomic(path.join(store.dir,journalFile),journal);
|
||||
});
|
||||
if(production)for(const slot of slots){
|
||||
const reconcileAdoption=async slot=>{
|
||||
const item=journal.items[slot.id], pending=item?.pendingAdoption;
|
||||
if(!pending)continue;
|
||||
if(!pending)return;
|
||||
signal?.throwIfAborted();
|
||||
const adoption={outputId,productVariantId:plan.productVariantId,slotId:slot.id};
|
||||
const startedAt=pending.startedAt??Date.now();
|
||||
@ -321,12 +321,14 @@ export async function runWholeDetail(host, runAgent, loadKnowledge, {pause=delay
|
||||
}else if(receipt?.phase==='complete'&&receipt.candidateId===pending.candidateId&&receipt.persistence==='checkpoint'){
|
||||
await save(slot,{state:'manual',pendingAdoption:null,reason:'原采纳已落盘,当前图位已变化,保留当前画布'});
|
||||
}else if(Date.now()-startedAt>=ADOPTION_RECONCILE_MS){
|
||||
written.delete(slot.id);
|
||||
await save(slot,{state:'adoption_failed',pendingAdoption:null,unconfirmedAdoption:{...pending,startedAt},
|
||||
reason:'原采纳核查超时,已保留候选与操作记录'});
|
||||
}else{
|
||||
await save(slot,{state:'placement',pendingAdoption:{...pending,startedAt},reason:'正在核查原画布采纳结果'});
|
||||
}
|
||||
}
|
||||
};
|
||||
if(production)for(const slot of slots)await reconcileAdoption(slot);
|
||||
const waitUntil=async(deadline,signal)=>{
|
||||
const duration=Math.max(0,deadline-Date.now());
|
||||
for(let remaining=duration;remaining>0;remaining-=1000){
|
||||
@ -2479,6 +2481,12 @@ export async function runWholeDetail(host, runAgent, loadKnowledge, {pause=delay
|
||||
const summarize=async()=>{
|
||||
if(production&©Fields&&!stopped)textPending=(await copyFields()).length;
|
||||
const ready=verifiedProduction&&!stopped?await loadSlots(canvas,outputId):null;
|
||||
if(production&&!stopped)for(const slot of ready?.slots??slots){
|
||||
const pending=journal.items[slot.id]?.pendingAdoption;
|
||||
if(pending&&Date.now()-(pending.startedAt??Date.now())>=ADOPTION_RECONCILE_MS){
|
||||
await reconcileAdoption(slot);
|
||||
}
|
||||
}
|
||||
const unverified=(ready?.slots??[]).filter(slot=>{
|
||||
if(!slot.selectedCandidateId)return true;
|
||||
return !approvals(slot,journal.items[slot.id]).some(review=>review.candidateId===slot.selectedCandidateId);
|
||||
|
||||
@ -697,6 +697,30 @@ test('an in-memory adoption receipt keeps the original until a checkpoint is pro
|
||||
assert.deepEqual(f.calls.map(call=>call.intent),['generate_candidate','adopt_candidate']);
|
||||
});
|
||||
|
||||
test('the current production stage settles an adoption when the initial check times out',async t=>{
|
||||
const f=await fixture(t,{total:1,production:true,outputId:'main_images'});
|
||||
f.slots[0].sourcePolicy='product';
|
||||
const execute=f.canvas.workflowExecute;
|
||||
const now=Date.now;
|
||||
let elapsed=0;
|
||||
t.mock.method(Date,'now',()=>now()+elapsed);
|
||||
f.canvas.workflowExecute=async operation=>{
|
||||
if(operation.intent!=='adopt_candidate')return execute(operation);
|
||||
f.calls.push(operation);
|
||||
elapsed=181_000;
|
||||
throw Error('画布未确认操作,请保留当前状态');
|
||||
};
|
||||
f.canvas.workflowReconcile=async operation=>({...operation,phase:'unknown'});
|
||||
const result=await f.run(undefined,async()=>({source:'product',prompt:'保留同款细节',referenceIndex:0}));
|
||||
assert.equal(result.production.complete,false);
|
||||
assert.match(result.production.issues[0].reason,/核查超时/);
|
||||
const item=(await f.store.get('production-main_images-wood.json')).items['slot-0'];
|
||||
assert.equal(item.state,'adoption_failed');
|
||||
assert.equal(item.pendingAdoption,null);
|
||||
assert.equal(item.unconfirmedAdoption.operationId,f.calls.at(-1).operationId);
|
||||
assert.deepEqual(f.calls.map(call=>call.intent),['generate_candidate','adopt_candidate']);
|
||||
});
|
||||
|
||||
for(const expired of [false,true])test(`a reopened main image ${expired?'settles an expired adoption':'resubmits just the unexecuted adoption'}`,async t=>{
|
||||
const f=await fixture(t,{total:2,production:true,outputId:'main_images'});
|
||||
for(const slot of f.slots)slot.sourcePolicy='product';
|
||||
|
||||
@ -152,3 +152,7 @@ D01 受控验证以 21 张历史采用图为固定输入。人工打开第 1、5
|
||||
|
||||
证据为 `02-fixed-text-native.log`、`enterprise-export-evidence.json`、`enterprise-page-draft.jpg`。后者是已发布电脑桌原稿的可解码草稿,未送到成品目录。
|
||||
|
||||
### 1. 采纳恢复补充
|
||||
|
||||
当前阶段结算时会再核对已经到时限的本地采纳。已核实的结果按对应回执收口,仍无法确认的图位从本次已完成计数移出并记录失败原因。定向回归用两种输出验证了同轮超时和重开后对账,9 项通过。证据为 `01-adoption-node-same-stage.log`。
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user