feat: complete native BOM and Harness execution acceptance

This commit is contained in:
阿白叔 committed 2026-11-12 19:21:55 +08:00
1 parent 4f8fbd7806
commit 65438cb7e5
234 files changed
+24402 -865

No files matched your search

+22 -3
View File
@@ -30,10 +30,29 @@ await writeFile(process.env.DX_DSH_CONTEXT_FILE,JSON.stringify({task_id:'usage-f
const restored={id:'restored-session',session:{snapshotEvents:()=>historicalEvents}};
agents.set(restored.id,restored);
const runtime=await registerRuntimeUsage(fixture,{admit:()=>true});
assert.deepEqual(runtime.snapshot().settings,{response_timeout_seconds:0,model_context_limit:0});
assert.equal(runtime.snapshot().context_limit_mode,'native_model');
// Deep reasoning can exceed 90 seconds without the observer cancelling it.
const longRequest=Object.freeze({sessionId:restored.id,signal:new AbortController().signal});
mock.timers.enable({apis:['setTimeout','Date']});
let finished=false;
const longResponse=(async()=>{
for await(const chunk of listeners.get('llm/stream')(longRequest,async function*(){
await new Promise(resolve=>setTimeout(resolve,120000));
yield {type:'finish',reason:{kind:'stop'}};
})){}
finished=true;
})();
mock.timers.tick(90001);await Promise.resolve();
assert.equal(finished,false);
assert.equal(runtime.snapshot().sessions[0].status,'generating');
mock.timers.tick(30000);await longResponse;
assert.equal(runtime.snapshot().sessions[0].status,'completed');
mock.timers.reset();
let restoredRow=runtime.snapshot().sessions.find(row=>row.session_id===restored.id);
assert.equal(restoredRow.input_tokens,36);assert.equal(restoredRow.output_tokens,12);
assert.equal(restoredRow.cached_tokens,24);assert.equal(restoredRow.total_tokens,72);
assert.equal(restoredRow.usage_complete,false);assert.equal(restoredRow.response_count,4);
assert.equal(restoredRow.usage_complete,false);assert.equal(restoredRow.response_count,5);
assert.equal(restoredRow.elapsed_seconds,null);
assert.ok(!JSON.stringify(restoredRow).includes('PRIVATE_HISTORY_TEXT'));
// Re-announcement and a fresh response must not recharge historical events.
@@ -66,7 +85,7 @@ await writeFile(process.env.DX_DSH_CONTEXT_FILE,JSON.stringify({task_id:'usage-f
assert.equal(runtime.snapshot().sessions[0].status,'error');
await Promise.all([runtime.configure({response_timeout_seconds:120}),runtime.configure({model_context_limit:8000})]);
assert.deepEqual(runtime.snapshot().settings,{response_timeout_seconds:120,model_context_limit:8000});
await runtime.configure({response_timeout_seconds:90,model_context_limit:16000});
await runtime.configure({response_timeout_seconds:0,model_context_limit:0});
runtime.dispose();assert.equal(listeners.size,0);
}
if(process.argv.includes('--unit-only')){console.log('usage lifecycle boundary checks passed');process.exit(0);}
@@ -88,7 +107,7 @@ try{
const headers={Cookie:cookie,'Content-Type':'application/json'};
const get=async()=>{const response=await fetch(base+'/dx/runtime',{headers});assert.equal(response.status,200);return response.json();};
const control=body=>fetch(base+'/dx/runtime/control',{method:'POST',headers,body:JSON.stringify(body)});
assert.equal((await get()).settings.response_timeout_seconds,90);
assert.equal((await get()).settings.response_timeout_seconds,0);
for(const body of [{action:'configure',response_timeout_seconds:14},
{action:'configure',response_timeout_seconds:true},{action:'configure',model_context_limit:128001},
{action:'configure',model_context_limit:3000,secret:'rejected'},