fix(xiaoyi): isolate slot receipts from project recovery
This commit is contained in:
parent
58ecb3cc93
commit
0bd4dfcce6
@ -96,8 +96,8 @@ export async function openProductionOperations(host) {
|
||||
return written;
|
||||
};
|
||||
const save=(slot,fields)=>update(()=>{journal.items[slot.id]={...journal.items[slot.id],...fields};});
|
||||
const operationHost=()=>Object.assign(Object.create(host),{
|
||||
nativeUnresolved:null,nativeToolActive:false,nativeToolOwner:null,generatedCandidates:new Map(),
|
||||
const operationHost=()=>Object.assign(Object.create(host,{nativeUnresolved:{value:null,writable:true}}),{
|
||||
nativeToolActive:false,nativeToolOwner:null,generatedCandidates:new Map(),
|
||||
});
|
||||
const current=async()=>{
|
||||
const value=await canvas.workflowRead({section:'overview',outputId});
|
||||
|
||||
@ -514,7 +514,7 @@ export async function runWholeDetail(host, runAgent, loadKnowledge, {pause=delay
|
||||
if(!archived)return;
|
||||
await retainArchive(archived,null,null,rejected);
|
||||
}
|
||||
const newOperationHost=()=>Object.assign(Object.create(host),{nativeToolActive:false,nativeToolOwner:null,nativeUnresolved:null,
|
||||
const newOperationHost=()=>Object.assign(Object.create(host,{nativeUnresolved:{value:null,writable:true}}),{nativeToolActive:false,nativeToolOwner:null,
|
||||
canvasWritesStopped:false,canvasNotificationsDetached:false,generatedCandidates:new Map(),
|
||||
readWorkflow:args=>canvas.workflowRead(args)});
|
||||
const operationHost=newOperationHost();
|
||||
|
||||
@ -5,6 +5,7 @@ import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { openProductionOperations } from '../src/production-operations.mjs';
|
||||
import { cleanup } from './cleanup.mjs';
|
||||
import { bindRecovery } from '../src/desktop-host.mjs';
|
||||
|
||||
test('Pi chooses each image operation and keeps an unresolved paid request on its original',async t=>{
|
||||
const dir=await fs.mkdtemp(path.join(os.tmpdir(),'jiansun-pi-'));
|
||||
@ -18,8 +19,9 @@ test('Pi chooses each image operation and keeps an unresolved paid request on it
|
||||
const pixels={type:'image',data:'evidence',mimeType:'image/jpeg'};
|
||||
const submissions=[];
|
||||
let revision=3,modelCalls=0,lookups=0,recovered=false,reviewGate,waitingAt;
|
||||
const identity={scope:'scope',project:'project',documentId:23,accountId:'account',origin:'local'};
|
||||
const canvas={
|
||||
run:'native-run',documentId:23,
|
||||
run:'native-run',documentId:23,identity,
|
||||
workflowRead:async()=>({available:true,canvasFirst:true,version:1,outputId,productVariantId:variantId,
|
||||
template:{contentHash:'lamp-template'},revisions:{creation:1},totalSlots:slots.length,slots}),
|
||||
detailCopyFields:async()=>({fields:structuredClone(fields)}),
|
||||
@ -51,7 +53,7 @@ test('Pi chooses each image operation and keeps an unresolved paid request on it
|
||||
workflowReconcile:async operation=>({...operation,phase:'unknown',candidateId:'existing-candidate'}),
|
||||
};
|
||||
const host={canvas,productionGoal:{outputId,variantId},
|
||||
store:{dir,get:async()=>null,appendEvent:async()=>{}},
|
||||
store:{dir,identity,get:async()=>null,appendEvent:async()=>{}},
|
||||
runDetailAgent:async(_slot,_system,prompt,tools)=>{
|
||||
modelCalls++;
|
||||
const {candidateId}=JSON.parse(prompt);
|
||||
@ -60,6 +62,12 @@ test('Pi chooses each image operation and keeps an unresolved paid request on it
|
||||
await review.execute('review-fixture',{candidateId,verdict:'pass',
|
||||
checks:{structure:true,color:true,composition:false,evidence:true},reason:'配色及结构与实拍一致,背景细节看不清'});
|
||||
}};
|
||||
const recovery=new Map();
|
||||
t.after(bindRecovery(host,recovery,identity));
|
||||
const originalNative={kind:'native',job:17,documentId:23,identity};
|
||||
const nextNative={kind:'native',job:18,documentId:23,identity};
|
||||
host.nativeUnresolved=originalNative;
|
||||
host.nativeUnresolved=nextNative;
|
||||
const actions=await openProductionOperations(host);
|
||||
await actions.plan_production({});
|
||||
assert.deepEqual(await actions.read_copy_fields({pageId:''}), await actions.read_copy_fields({}));
|
||||
@ -84,6 +92,8 @@ test('Pi chooses each image operation and keeps an unresolved paid request on it
|
||||
assert.deepEqual((await actions.write_copy_fields(proposal)).appliedLayers,[7]);
|
||||
const first=await actions.generate_slot_image({slotId:'lamp',source:'generate',prompt:'场景桌面上的一盏灯'});
|
||||
assert.equal(first.phase,'unknown');
|
||||
assert.equal(host.nativeUnresolved,originalNative);
|
||||
assert.deepEqual([...recovery.values()][0].pending,[originalNative,nextNative]);
|
||||
assert.equal(first.requestedSource,'generate');
|
||||
assert.match(submissions[0].instruction,/场景桌面上的一盏灯$/u);
|
||||
assert.equal((await actions.generate_slot_image({slotId:'lamp',source:'generate',prompt:'更换灯罩角度'})).phase,'unknown');
|
||||
@ -135,4 +145,5 @@ test('Pi chooses each image operation and keeps an unresolved paid request on it
|
||||
const result=await actions.finish_production({revision});
|
||||
assert.equal(result.production.canvasRevision,revision);
|
||||
assert.equal(result.production.complete,true);
|
||||
assert.deepEqual([...recovery.values()][0].pending,[originalNative,nextNative]);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user